etiquetas.js 1.0.0-alpha.3 → 1.0.0-alpha.5
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/dist/etiquetas.es.js +19 -19
- package/dist/etiquetas.umd.js +17 -17
- package/dist/etiquetas.umd.js.map +1 -1
- package/dist/{index-BkmabrFq.js → index-B10y8IWE.js} +310 -32
- package/dist/index-B10y8IWE.js.map +1 -0
- package/dist/{index.es-B4lKWyrH.js → index.es-D4Dr85b7.js} +2 -2
- package/dist/{index.es-B4lKWyrH.js.map → index.es-D4Dr85b7.js.map} +1 -1
- package/package.json +2 -12
- package/dist/index-BkmabrFq.js.map +0 -1
|
@@ -11303,7 +11303,7 @@ function(t2) {
|
|
|
11303
11303
|
*/
|
|
11304
11304
|
function(t2) {
|
|
11305
11305
|
function e2() {
|
|
11306
|
-
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-
|
|
11306
|
+
return (n.canvg ? Promise.resolve(n.canvg) : import("./index.es-D4Dr85b7.js")).catch(function(t3) {
|
|
11307
11307
|
return Promise.reject(new Error("Could not load canvg: " + t3));
|
|
11308
11308
|
}).then(function(t3) {
|
|
11309
11309
|
return t3.default ? t3.default : t3;
|
|
@@ -58104,16 +58104,228 @@ const makeLamination = (mainObject) => {
|
|
|
58104
58104
|
}
|
|
58105
58105
|
return pdf.output("datauristring");
|
|
58106
58106
|
};
|
|
58107
|
-
const
|
|
58108
|
-
|
|
58109
|
-
|
|
58110
|
-
|
|
58111
|
-
|
|
58107
|
+
const API_BASE_URL = "https://db33.dev.dinabox.net/api";
|
|
58108
|
+
const apiClient$1 = axios.create({
|
|
58109
|
+
baseURL: API_BASE_URL,
|
|
58110
|
+
timeout: 1e4,
|
|
58111
|
+
headers: {
|
|
58112
|
+
"Content-Type": "application/json",
|
|
58113
|
+
"Accept": "application/json"
|
|
58114
|
+
}
|
|
58115
|
+
});
|
|
58116
|
+
const LABEL_TYPES$1 = {
|
|
58117
|
+
PART: "part",
|
|
58118
|
+
SCRAP: "scrap",
|
|
58119
|
+
THICKENED: "thickened",
|
|
58120
|
+
INPUT: "input",
|
|
58121
|
+
VOLUME: "volume"
|
|
58112
58122
|
};
|
|
58123
|
+
apiClient$1.interceptors.response.use(
|
|
58124
|
+
(response) => response,
|
|
58125
|
+
(error) => {
|
|
58126
|
+
var _a2;
|
|
58127
|
+
console.error("Erro na API:", ((_a2 = error.response) == null ? void 0 : _a2.data) || error.message);
|
|
58128
|
+
return Promise.reject(error);
|
|
58129
|
+
}
|
|
58130
|
+
);
|
|
58131
|
+
class LabelsAPI {
|
|
58132
|
+
/**
|
|
58133
|
+
* Lista etiquetas com filtros opcionais
|
|
58134
|
+
* GET /v1/labels
|
|
58135
|
+
*
|
|
58136
|
+
* @param {Object} params - Parâmetros de consulta
|
|
58137
|
+
* @param {number} [params.p] - Página
|
|
58138
|
+
* @param {string} [params.s] - Busca
|
|
58139
|
+
* @param {number} [params.label_id] - ID da etiqueta
|
|
58140
|
+
* @param {string} [params.label_type] - Tipo da etiqueta (part, scrap, thickened, input, volume)
|
|
58141
|
+
* @returns {Promise} Resposta da API
|
|
58142
|
+
*/
|
|
58143
|
+
static getLabels() {
|
|
58144
|
+
return __async(this, arguments, function* (params = {}) {
|
|
58145
|
+
try {
|
|
58146
|
+
const response = yield apiClient$1.get("/v1/labels", { params });
|
|
58147
|
+
return response.data;
|
|
58148
|
+
} catch (error) {
|
|
58149
|
+
throw new Error(`Erro ao buscar etiquetas: ${error.message}`);
|
|
58150
|
+
}
|
|
58151
|
+
});
|
|
58152
|
+
}
|
|
58153
|
+
/**
|
|
58154
|
+
* Busca etiquetas por página
|
|
58155
|
+
*
|
|
58156
|
+
* @param {number} page - Número da página
|
|
58157
|
+
* @param {Object} filters - Filtros adicionais
|
|
58158
|
+
* @returns {Promise} Resposta da API
|
|
58159
|
+
*/
|
|
58160
|
+
static getLabelsByPage() {
|
|
58161
|
+
return __async(this, arguments, function* (page = 1, filters = {}) {
|
|
58162
|
+
return this.getLabels(__spreadValues({ p: page }, filters));
|
|
58163
|
+
});
|
|
58164
|
+
}
|
|
58165
|
+
/**
|
|
58166
|
+
* Busca etiquetas por termo de pesquisa
|
|
58167
|
+
*
|
|
58168
|
+
* @param {string} searchTerm - Termo de busca
|
|
58169
|
+
* @param {Object} filters - Filtros adicionais
|
|
58170
|
+
* @returns {Promise} Resposta da API
|
|
58171
|
+
*/
|
|
58172
|
+
static searchLabels(_0) {
|
|
58173
|
+
return __async(this, arguments, function* (searchTerm, filters = {}) {
|
|
58174
|
+
return this.getLabels(__spreadValues({ s: searchTerm }, filters));
|
|
58175
|
+
});
|
|
58176
|
+
}
|
|
58177
|
+
/**
|
|
58178
|
+
* Busca etiquetas por tipo
|
|
58179
|
+
*
|
|
58180
|
+
* @param {string} labelType - Tipo da etiqueta
|
|
58181
|
+
* @param {Object} filters - Filtros adicionais
|
|
58182
|
+
* @returns {Promise} Resposta da API
|
|
58183
|
+
*/
|
|
58184
|
+
static getLabelsByType(_0) {
|
|
58185
|
+
return __async(this, arguments, function* (labelType, filters = {}) {
|
|
58186
|
+
this.validateLabelType(labelType, true);
|
|
58187
|
+
return this.getLabels(__spreadValues({ label_type: labelType }, filters));
|
|
58188
|
+
});
|
|
58189
|
+
}
|
|
58190
|
+
/**
|
|
58191
|
+
* Obtém uma etiqueta específica
|
|
58192
|
+
* GET /v1/label
|
|
58193
|
+
*
|
|
58194
|
+
* @param {number} labelId - ID da etiqueta
|
|
58195
|
+
* @returns {Promise} Resposta da API
|
|
58196
|
+
*/
|
|
58197
|
+
static getLabel(labelId) {
|
|
58198
|
+
return __async(this, null, function* () {
|
|
58199
|
+
try {
|
|
58200
|
+
const response = yield apiClient$1.get("/v1/label", {
|
|
58201
|
+
params: { label_id: labelId }
|
|
58202
|
+
});
|
|
58203
|
+
if (!response.data || !response.data.labels || !response.data.labels.length) {
|
|
58204
|
+
return null;
|
|
58205
|
+
}
|
|
58206
|
+
return response.data.labels.filter((label) => label.label_id == labelId)[0] || null;
|
|
58207
|
+
} catch (error) {
|
|
58208
|
+
throw new Error(`Erro ao buscar etiqueta ${labelId}: ${error.message}`);
|
|
58209
|
+
}
|
|
58210
|
+
});
|
|
58211
|
+
}
|
|
58212
|
+
/**
|
|
58213
|
+
* Cria uma nova etiqueta
|
|
58214
|
+
* POST /v1/label
|
|
58215
|
+
*
|
|
58216
|
+
* @param {Object} labelData - Dados da etiqueta
|
|
58217
|
+
* @param {string} [labelData.label_type] - Tipo da etiqueta
|
|
58218
|
+
* @param {string} [labelData.label_name] - Nome da etiqueta
|
|
58219
|
+
* @param {string} [labelData.label_content] - Conteúdo da etiqueta
|
|
58220
|
+
* @returns {Promise} Resposta da API
|
|
58221
|
+
*/
|
|
58222
|
+
static createLabel(labelData) {
|
|
58223
|
+
return __async(this, null, function* () {
|
|
58224
|
+
try {
|
|
58225
|
+
if (labelData.label_type) {
|
|
58226
|
+
this.validateLabelType(labelData.label_type, true);
|
|
58227
|
+
}
|
|
58228
|
+
const response = yield apiClient$1.post("/v1/label", labelData);
|
|
58229
|
+
return response.data;
|
|
58230
|
+
} catch (error) {
|
|
58231
|
+
throw new Error(`Erro ao criar etiqueta: ${error.message}`);
|
|
58232
|
+
}
|
|
58233
|
+
});
|
|
58234
|
+
}
|
|
58235
|
+
/**
|
|
58236
|
+
* Valida se o tipo de etiqueta é um dos tipos permitidos
|
|
58237
|
+
*
|
|
58238
|
+
* @param {string} labelType - Tipo de etiqueta a ser validado
|
|
58239
|
+
* @returns {boolean} True se for válido, false caso contrário
|
|
58240
|
+
* @throws {Error} Se o tipo for inválido e throwError for true
|
|
58241
|
+
*/
|
|
58242
|
+
static validateLabelType(labelType, throwError = false) {
|
|
58243
|
+
const isValid = Object.values(LABEL_TYPES$1).includes(labelType);
|
|
58244
|
+
if (!isValid && throwError) {
|
|
58245
|
+
throw new Error(`Tipo de etiqueta inválido: "${labelType}" não é um de part, scrap, thickened, input e volume.`);
|
|
58246
|
+
}
|
|
58247
|
+
return isValid;
|
|
58248
|
+
}
|
|
58249
|
+
/**
|
|
58250
|
+
* Retorna um tipo de etiqueta se for válido
|
|
58251
|
+
*
|
|
58252
|
+
* @param {string} labelType - Tipo de etiqueta a verificar
|
|
58253
|
+
* @returns {string} O tipo de etiqueta validado
|
|
58254
|
+
* @throws {Error} Se o tipo for inválido
|
|
58255
|
+
*/
|
|
58256
|
+
static labelByType(labelType) {
|
|
58257
|
+
this.validateLabelType(labelType, true);
|
|
58258
|
+
return labelType;
|
|
58259
|
+
}
|
|
58260
|
+
/**
|
|
58261
|
+
* Atualiza uma etiqueta existente
|
|
58262
|
+
* POST /v1/label (com label_id)
|
|
58263
|
+
*
|
|
58264
|
+
* @param {number} labelId - ID da etiqueta
|
|
58265
|
+
* @param {Object} labelData - Dados atualizados da etiqueta
|
|
58266
|
+
* @returns {Promise} Resposta da API
|
|
58267
|
+
*/
|
|
58268
|
+
static updateLabel(labelId, labelData) {
|
|
58269
|
+
return __async(this, null, function* () {
|
|
58270
|
+
try {
|
|
58271
|
+
if (labelData.label_type) {
|
|
58272
|
+
this.validateLabelType(labelData.label_type, true);
|
|
58273
|
+
}
|
|
58274
|
+
const response = yield apiClient$1.post("/v1/label", __spreadValues({
|
|
58275
|
+
label_id: labelId
|
|
58276
|
+
}, labelData));
|
|
58277
|
+
return response.data;
|
|
58278
|
+
} catch (error) {
|
|
58279
|
+
throw new Error(`Erro ao atualizar etiqueta ${labelId}: ${error.message}`);
|
|
58280
|
+
}
|
|
58281
|
+
});
|
|
58282
|
+
}
|
|
58283
|
+
/**
|
|
58284
|
+
* Remove uma etiqueta
|
|
58285
|
+
* DELETE /v1/label
|
|
58286
|
+
*
|
|
58287
|
+
* @param {number} labelId - ID da etiqueta
|
|
58288
|
+
* @returns {Promise} Resposta da API
|
|
58289
|
+
*/
|
|
58290
|
+
static deleteLabel(labelId) {
|
|
58291
|
+
return __async(this, null, function* () {
|
|
58292
|
+
try {
|
|
58293
|
+
const response = yield apiClient$1.delete("/v1/label", {
|
|
58294
|
+
params: { label_id: labelId }
|
|
58295
|
+
});
|
|
58296
|
+
return response.data;
|
|
58297
|
+
} catch (error) {
|
|
58298
|
+
throw new Error(`Erro ao deletar etiqueta ${labelId}: ${error.message}`);
|
|
58299
|
+
}
|
|
58300
|
+
});
|
|
58301
|
+
}
|
|
58302
|
+
/**
|
|
58303
|
+
* Configura o token de autenticação
|
|
58304
|
+
*
|
|
58305
|
+
* @param {string} token - Token de autenticação
|
|
58306
|
+
*/
|
|
58307
|
+
static setAuthToken(token) {
|
|
58308
|
+
apiClient$1.defaults.headers.common["Authorization"] = `${token}`;
|
|
58309
|
+
}
|
|
58310
|
+
/**
|
|
58311
|
+
* Remove o token de autenticação
|
|
58312
|
+
*/
|
|
58313
|
+
static removeAuthToken() {
|
|
58314
|
+
delete apiClient$1.defaults.headers.common["Authorization"];
|
|
58315
|
+
}
|
|
58316
|
+
/**
|
|
58317
|
+
* Configura a URL base da API
|
|
58318
|
+
*
|
|
58319
|
+
* @param {string} baseURL - Nova URL base
|
|
58320
|
+
*/
|
|
58321
|
+
static setBaseURL(baseURL) {
|
|
58322
|
+
apiClient$1.defaults.baseURL = baseURL;
|
|
58323
|
+
}
|
|
58324
|
+
}
|
|
58113
58325
|
function getTemplateById(templateId) {
|
|
58114
58326
|
return __async(this, null, function* () {
|
|
58115
58327
|
try {
|
|
58116
|
-
const labelData = yield LabelsAPI
|
|
58328
|
+
const labelData = yield LabelsAPI.getLabel(templateId);
|
|
58117
58329
|
if (!labelData) {
|
|
58118
58330
|
throw new Error(`Template/etiqueta não encontrado com ID: ${templateId}`);
|
|
58119
58331
|
}
|
|
@@ -58313,11 +58525,78 @@ const safeApplyTransformations = (data, fieldMap, options = {}) => {
|
|
|
58313
58525
|
}
|
|
58314
58526
|
};
|
|
58315
58527
|
const legacyFieldMap = {
|
|
58316
|
-
|
|
58317
|
-
|
|
58318
|
-
|
|
58319
|
-
|
|
58320
|
-
|
|
58528
|
+
PROJETO_ID: "project_id",
|
|
58529
|
+
PROJETO_NOME: "project_description",
|
|
58530
|
+
PROJETO_OBS: "project_note",
|
|
58531
|
+
CLIENTE_ID: "project_customer_id",
|
|
58532
|
+
CLIENTE_NOME: "project_customer_name",
|
|
58533
|
+
PECA_ID: "id",
|
|
58534
|
+
PECA_CODIGO: "pid",
|
|
58535
|
+
PECA_REF: ["pref", "ref"],
|
|
58536
|
+
MODULO_REF: "mref",
|
|
58537
|
+
MODULO_QTD: ["mqt", "module_quantity"],
|
|
58538
|
+
PECA_INDICE: "index",
|
|
58539
|
+
PECA_INDICE2: "number",
|
|
58540
|
+
PECA_NOME: "name",
|
|
58541
|
+
PECA_OBS: "note",
|
|
58542
|
+
LARGURA: "width",
|
|
58543
|
+
ALTURA: "height",
|
|
58544
|
+
ESPESSURA: "thickness",
|
|
58545
|
+
MN: ["materialName", "material", "material_name"],
|
|
58546
|
+
MA: "material_height",
|
|
58547
|
+
ML: "material_width",
|
|
58548
|
+
FURO_A: "code_a",
|
|
58549
|
+
FURO_B: "code_b",
|
|
58550
|
+
FE: "edge_left",
|
|
58551
|
+
FD: "edge_right",
|
|
58552
|
+
FS: "edge_top",
|
|
58553
|
+
FI: "edge_bottom",
|
|
58554
|
+
PECA_TIPO: "type",
|
|
58555
|
+
// vai usar o partTypes para traduzir
|
|
58556
|
+
MODULO_NOME: "mname",
|
|
58557
|
+
MODULO_OBS: "mnote",
|
|
58558
|
+
LOTE_ID: ["group_id", "groupId"],
|
|
58559
|
+
DATA_CRIACAO: ["date", "created_at"],
|
|
58560
|
+
LADO_USINAGEM: "machining_side",
|
|
58561
|
+
INSUMO_QTD: "qt",
|
|
58562
|
+
INSUMO_PESO: "weight",
|
|
58563
|
+
INSUMO_DIMENSOES: "dimensions",
|
|
58564
|
+
INSUMO_MARCA: "manufacturer",
|
|
58565
|
+
VOLUME_ID: "volume_id",
|
|
58566
|
+
VOLUME_NOME: "volume_name",
|
|
58567
|
+
SCRAP_ID: "scrapId",
|
|
58568
|
+
FURO_A2: "code_a2",
|
|
58569
|
+
FURO_B2: "code_b2",
|
|
58570
|
+
MATERIAL_NOME: ["materialName", "material", "material_name"],
|
|
58571
|
+
TAMPONAMENTO_ID: "id",
|
|
58572
|
+
// Supondo que seja o mesmo que PECA_ID para tamponamento
|
|
58573
|
+
TAMPONAMENTO_REF: ["pref", "ref"],
|
|
58574
|
+
TAMPONAMENTO_QT: "qt",
|
|
58575
|
+
TAMPONAMENTO_PESO: "weight",
|
|
58576
|
+
TAMPONAMENTO_NOME: "name",
|
|
58577
|
+
INSUMO_NOME: "name",
|
|
58578
|
+
INSUMO_ID: "id",
|
|
58579
|
+
INSUMO_REF: ["pref", "ref"],
|
|
58580
|
+
INSUMO_CATEGORIA: "category",
|
|
58581
|
+
INSUMO_FABRICANTE: "manufacturer",
|
|
58582
|
+
RETALHO_ID: "scrapId",
|
|
58583
|
+
RETALHO_INDICE: "index",
|
|
58584
|
+
RETALHO_NOME: "name",
|
|
58585
|
+
RETALHO_QT: "qt",
|
|
58586
|
+
RETALHO_PESO: "weight",
|
|
58587
|
+
RETALHO_DIMENSOES: "dimensions",
|
|
58588
|
+
RETALHO_MATERIAL: ["materialName", "material", "material_name"],
|
|
58589
|
+
RETALHO_ORIGEM: "origin",
|
|
58590
|
+
CODIGO_A: "code_a",
|
|
58591
|
+
CODIGO_B: "code_b",
|
|
58592
|
+
FURO_A_SD: "hole_a_sd",
|
|
58593
|
+
FURO_B_SD: "hole_b_sd",
|
|
58594
|
+
FURO_TOPO: "hole_top",
|
|
58595
|
+
VOLUME_PESO: "weight",
|
|
58596
|
+
VOLUME_DATA: ["date", "created_at"],
|
|
58597
|
+
VOLUME_DESCRICAO: "description",
|
|
58598
|
+
VOLUME_PECAS: "itemList",
|
|
58599
|
+
VOLUME_DIMENSOES: "dimensions",
|
|
58321
58600
|
/**
|
|
58322
58601
|
* Transformação de código A - adiciona '0' e remove primeiro caractere
|
|
58323
58602
|
* Exemplo: 'A123456' -> '0123456'
|
|
@@ -59030,7 +59309,6 @@ const etiquetasAPI = {
|
|
|
59030
59309
|
applyTransformations,
|
|
59031
59310
|
legacyTransformer
|
|
59032
59311
|
};
|
|
59033
|
-
const LabelsAPI = null;
|
|
59034
59312
|
const LABEL_TYPES = {
|
|
59035
59313
|
PART: "part",
|
|
59036
59314
|
SCRAP: "scrap",
|
|
@@ -59065,7 +59343,7 @@ export {
|
|
|
59065
59343
|
downloadFile as I,
|
|
59066
59344
|
serializeXML as J,
|
|
59067
59345
|
createBuffer as K,
|
|
59068
|
-
|
|
59346
|
+
LABEL_TYPES as L,
|
|
59069
59347
|
base64Encode as M,
|
|
59070
59348
|
base64Decode as N,
|
|
59071
59349
|
processLabelForParts as O,
|
|
@@ -59081,7 +59359,7 @@ export {
|
|
|
59081
59359
|
getBorderColor as Y,
|
|
59082
59360
|
makeLamination as Z,
|
|
59083
59361
|
_typeof as _,
|
|
59084
|
-
|
|
59362
|
+
apiClient as a,
|
|
59085
59363
|
getAspectRatio as a0,
|
|
59086
59364
|
DEFAULT_LAMINATION_COLORS as a1,
|
|
59087
59365
|
stopCreatingLabels as a2,
|
|
@@ -59093,24 +59371,24 @@ export {
|
|
|
59093
59371
|
generateTableSVG as a8,
|
|
59094
59372
|
dataTypeList as a9,
|
|
59095
59373
|
getInputsByCategory as aa,
|
|
59096
|
-
|
|
59374
|
+
getPartLabels as b,
|
|
59097
59375
|
commonjsGlobal as c,
|
|
59098
|
-
|
|
59099
|
-
|
|
59100
|
-
|
|
59376
|
+
getScrapLabels as d,
|
|
59377
|
+
getThickenedLabels as e,
|
|
59378
|
+
getInputLabels as f,
|
|
59101
59379
|
getDefaultExportFromCjs as g,
|
|
59102
|
-
|
|
59103
|
-
|
|
59104
|
-
|
|
59105
|
-
|
|
59106
|
-
|
|
59107
|
-
|
|
59108
|
-
|
|
59109
|
-
|
|
59110
|
-
|
|
59111
|
-
|
|
59112
|
-
|
|
59113
|
-
|
|
59380
|
+
getVolumeLabels as h,
|
|
59381
|
+
LabelWorker as i,
|
|
59382
|
+
createLabelWorker as j,
|
|
59383
|
+
generateLabelsFromHookData as k,
|
|
59384
|
+
useLabelStore as l,
|
|
59385
|
+
getPartsForLabels as m,
|
|
59386
|
+
getInputForLabels as n,
|
|
59387
|
+
getPartsFromProjectToLabels as o,
|
|
59388
|
+
labelTypeNames as p,
|
|
59389
|
+
initialState as q,
|
|
59390
|
+
reducer as r,
|
|
59391
|
+
LabelsAPI as s,
|
|
59114
59392
|
init as t,
|
|
59115
59393
|
useLabelData as u,
|
|
59116
59394
|
getPrinterStatus as v,
|
|
@@ -59119,4 +59397,4 @@ export {
|
|
|
59119
59397
|
downloadPDF as y,
|
|
59120
59398
|
sendToPrinter as z
|
|
59121
59399
|
};
|
|
59122
|
-
//# sourceMappingURL=index-
|
|
59400
|
+
//# sourceMappingURL=index-B10y8IWE.js.map
|