etiquetas.js 1.0.0-alpha.2 → 1.0.0-alpha.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.
- package/README.md +11 -7
- 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-BmMBOPX1.js → index-BUpKxNQ0.js} +313 -29
- package/dist/index-BUpKxNQ0.js.map +1 -0
- package/dist/{index.es-DzWoeylQ.js → index.es-CCAzIpY-.js} +2 -2
- package/dist/{index.es-DzWoeylQ.js.map → index.es-CCAzIpY-.js.map} +1 -1
- package/package.json +2 -12
- package/dist/index-BmMBOPX1.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-CCAzIpY-.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,7 +58104,225 @@ const makeLamination = (mainObject) => {
|
|
|
58104
58104
|
}
|
|
58105
58105
|
return pdf.output("datauristring");
|
|
58106
58106
|
};
|
|
58107
|
-
const
|
|
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"
|
|
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
|
+
let LabelsAPI$1 = 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
|
+
};
|
|
58325
|
+
const LabelsAPI2 = {
|
|
58108
58326
|
getLabel: (id) => __async(void 0, null, function* () {
|
|
58109
58327
|
console.warn("LabelsAPI não carregado - usando placeholder");
|
|
58110
58328
|
return null;
|
|
@@ -58113,7 +58331,7 @@ const LabelsAPI$1 = {
|
|
|
58113
58331
|
function getTemplateById(templateId) {
|
|
58114
58332
|
return __async(this, null, function* () {
|
|
58115
58333
|
try {
|
|
58116
|
-
const labelData = yield
|
|
58334
|
+
const labelData = yield LabelsAPI2.getLabel(templateId);
|
|
58117
58335
|
if (!labelData) {
|
|
58118
58336
|
throw new Error(`Template/etiqueta não encontrado com ID: ${templateId}`);
|
|
58119
58337
|
}
|
|
@@ -58313,11 +58531,78 @@ const safeApplyTransformations = (data, fieldMap, options = {}) => {
|
|
|
58313
58531
|
}
|
|
58314
58532
|
};
|
|
58315
58533
|
const legacyFieldMap = {
|
|
58316
|
-
|
|
58317
|
-
|
|
58318
|
-
|
|
58319
|
-
|
|
58320
|
-
|
|
58534
|
+
PROJETO_ID: "project_id",
|
|
58535
|
+
PROJETO_NOME: "project_description",
|
|
58536
|
+
PROJETO_OBS: "project_note",
|
|
58537
|
+
CLIENTE_ID: "project_customer_id",
|
|
58538
|
+
CLIENTE_NOME: "project_customer_name",
|
|
58539
|
+
PECA_ID: "id",
|
|
58540
|
+
PECA_CODIGO: "pid",
|
|
58541
|
+
PECA_REF: ["pref", "ref"],
|
|
58542
|
+
MODULO_REF: "mref",
|
|
58543
|
+
MODULO_QTD: ["mqt", "module_quantity"],
|
|
58544
|
+
PECA_INDICE: "index",
|
|
58545
|
+
PECA_INDICE2: "number",
|
|
58546
|
+
PECA_NOME: "name",
|
|
58547
|
+
PECA_OBS: "note",
|
|
58548
|
+
LARGURA: "width",
|
|
58549
|
+
ALTURA: "height",
|
|
58550
|
+
ESPESSURA: "thickness",
|
|
58551
|
+
MN: ["materialName", "material", "material_name"],
|
|
58552
|
+
MA: "material_height",
|
|
58553
|
+
ML: "material_width",
|
|
58554
|
+
FURO_A: "code_a",
|
|
58555
|
+
FURO_B: "code_b",
|
|
58556
|
+
FE: "edge_left",
|
|
58557
|
+
FD: "edge_right",
|
|
58558
|
+
FS: "edge_top",
|
|
58559
|
+
FI: "edge_bottom",
|
|
58560
|
+
PECA_TIPO: "type",
|
|
58561
|
+
// vai usar o partTypes para traduzir
|
|
58562
|
+
MODULO_NOME: "mname",
|
|
58563
|
+
MODULO_OBS: "mnote",
|
|
58564
|
+
LOTE_ID: ["group_id", "groupId"],
|
|
58565
|
+
DATA_CRIACAO: ["date", "created_at"],
|
|
58566
|
+
LADO_USINAGEM: "machining_side",
|
|
58567
|
+
INSUMO_QTD: "qt",
|
|
58568
|
+
INSUMO_PESO: "weight",
|
|
58569
|
+
INSUMO_DIMENSOES: "dimensions",
|
|
58570
|
+
INSUMO_MARCA: "manufacturer",
|
|
58571
|
+
VOLUME_ID: "volume_id",
|
|
58572
|
+
VOLUME_NOME: "volume_name",
|
|
58573
|
+
SCRAP_ID: "scrapId",
|
|
58574
|
+
FURO_A2: "code_a2",
|
|
58575
|
+
FURO_B2: "code_b2",
|
|
58576
|
+
MATERIAL_NOME: ["materialName", "material", "material_name"],
|
|
58577
|
+
TAMPONAMENTO_ID: "id",
|
|
58578
|
+
// Supondo que seja o mesmo que PECA_ID para tamponamento
|
|
58579
|
+
TAMPONAMENTO_REF: ["pref", "ref"],
|
|
58580
|
+
TAMPONAMENTO_QT: "qt",
|
|
58581
|
+
TAMPONAMENTO_PESO: "weight",
|
|
58582
|
+
TAMPONAMENTO_NOME: "name",
|
|
58583
|
+
INSUMO_NOME: "name",
|
|
58584
|
+
INSUMO_ID: "id",
|
|
58585
|
+
INSUMO_REF: ["pref", "ref"],
|
|
58586
|
+
INSUMO_CATEGORIA: "category",
|
|
58587
|
+
INSUMO_FABRICANTE: "manufacturer",
|
|
58588
|
+
RETALHO_ID: "scrapId",
|
|
58589
|
+
RETALHO_INDICE: "index",
|
|
58590
|
+
RETALHO_NOME: "name",
|
|
58591
|
+
RETALHO_QT: "qt",
|
|
58592
|
+
RETALHO_PESO: "weight",
|
|
58593
|
+
RETALHO_DIMENSOES: "dimensions",
|
|
58594
|
+
RETALHO_MATERIAL: ["materialName", "material", "material_name"],
|
|
58595
|
+
RETALHO_ORIGEM: "origin",
|
|
58596
|
+
CODIGO_A: "code_a",
|
|
58597
|
+
CODIGO_B: "code_b",
|
|
58598
|
+
FURO_A_SD: "hole_a_sd",
|
|
58599
|
+
FURO_B_SD: "hole_b_sd",
|
|
58600
|
+
FURO_TOPO: "hole_top",
|
|
58601
|
+
VOLUME_PESO: "weight",
|
|
58602
|
+
VOLUME_DATA: ["date", "created_at"],
|
|
58603
|
+
VOLUME_DESCRICAO: "description",
|
|
58604
|
+
VOLUME_PECAS: "itemList",
|
|
58605
|
+
VOLUME_DIMENSOES: "dimensions",
|
|
58321
58606
|
/**
|
|
58322
58607
|
* Transformação de código A - adiciona '0' e remove primeiro caractere
|
|
58323
58608
|
* Exemplo: 'A123456' -> '0123456'
|
|
@@ -58577,7 +58862,7 @@ const sendLabel = (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function*
|
|
|
58577
58862
|
}
|
|
58578
58863
|
}
|
|
58579
58864
|
const pdf = yield makeLabel(labelData, labelId, options);
|
|
58580
|
-
const filename = options.
|
|
58865
|
+
const filename = options.fileName || `label-${Date.now()}.pdf`;
|
|
58581
58866
|
console.log("📄 PDF gerado:", pdf);
|
|
58582
58867
|
const result = yield sendToPrinter(pdf, __spreadValues({
|
|
58583
58868
|
filename,
|
|
@@ -59030,7 +59315,6 @@ const etiquetasAPI = {
|
|
|
59030
59315
|
applyTransformations,
|
|
59031
59316
|
legacyTransformer
|
|
59032
59317
|
};
|
|
59033
|
-
const LabelsAPI = null;
|
|
59034
59318
|
const LABEL_TYPES = {
|
|
59035
59319
|
PART: "part",
|
|
59036
59320
|
SCRAP: "scrap",
|
|
@@ -59065,7 +59349,7 @@ export {
|
|
|
59065
59349
|
downloadFile as I,
|
|
59066
59350
|
serializeXML as J,
|
|
59067
59351
|
createBuffer as K,
|
|
59068
|
-
|
|
59352
|
+
LABEL_TYPES as L,
|
|
59069
59353
|
base64Encode as M,
|
|
59070
59354
|
base64Decode as N,
|
|
59071
59355
|
processLabelForParts as O,
|
|
@@ -59081,7 +59365,7 @@ export {
|
|
|
59081
59365
|
getBorderColor as Y,
|
|
59082
59366
|
makeLamination as Z,
|
|
59083
59367
|
_typeof as _,
|
|
59084
|
-
|
|
59368
|
+
apiClient as a,
|
|
59085
59369
|
getAspectRatio as a0,
|
|
59086
59370
|
DEFAULT_LAMINATION_COLORS as a1,
|
|
59087
59371
|
stopCreatingLabels as a2,
|
|
@@ -59093,24 +59377,24 @@ export {
|
|
|
59093
59377
|
generateTableSVG as a8,
|
|
59094
59378
|
dataTypeList as a9,
|
|
59095
59379
|
getInputsByCategory as aa,
|
|
59096
|
-
|
|
59380
|
+
getPartLabels as b,
|
|
59097
59381
|
commonjsGlobal as c,
|
|
59098
|
-
|
|
59099
|
-
|
|
59100
|
-
|
|
59382
|
+
getScrapLabels as d,
|
|
59383
|
+
getThickenedLabels as e,
|
|
59384
|
+
getInputLabels as f,
|
|
59101
59385
|
getDefaultExportFromCjs as g,
|
|
59102
|
-
|
|
59103
|
-
|
|
59104
|
-
|
|
59105
|
-
|
|
59106
|
-
|
|
59107
|
-
|
|
59108
|
-
|
|
59109
|
-
|
|
59110
|
-
|
|
59111
|
-
|
|
59112
|
-
|
|
59113
|
-
|
|
59386
|
+
getVolumeLabels as h,
|
|
59387
|
+
LabelWorker as i,
|
|
59388
|
+
createLabelWorker as j,
|
|
59389
|
+
generateLabelsFromHookData as k,
|
|
59390
|
+
useLabelStore as l,
|
|
59391
|
+
getPartsForLabels as m,
|
|
59392
|
+
getInputForLabels as n,
|
|
59393
|
+
getPartsFromProjectToLabels as o,
|
|
59394
|
+
labelTypeNames as p,
|
|
59395
|
+
initialState as q,
|
|
59396
|
+
reducer as r,
|
|
59397
|
+
LabelsAPI$1 as s,
|
|
59114
59398
|
init as t,
|
|
59115
59399
|
useLabelData as u,
|
|
59116
59400
|
getPrinterStatus as v,
|
|
@@ -59119,4 +59403,4 @@ export {
|
|
|
59119
59403
|
downloadPDF as y,
|
|
59120
59404
|
sendToPrinter as z
|
|
59121
59405
|
};
|
|
59122
|
-
//# sourceMappingURL=index-
|
|
59406
|
+
//# sourceMappingURL=index-BUpKxNQ0.js.map
|