@onyxsoft/n8n-nodes-netvy 1.6.1

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 (119) hide show
  1. package/README.md +84 -0
  2. package/dist/credentials/NetvyApi.credentials.d.ts +9 -0
  3. package/dist/credentials/NetvyApi.credentials.d.ts.map +1 -0
  4. package/dist/credentials/NetvyApi.credentials.js +48 -0
  5. package/dist/credentials/NetvyApi.credentials.js.map +1 -0
  6. package/dist/nodes/Netvy/GenericFunctions.d.ts +70 -0
  7. package/dist/nodes/Netvy/GenericFunctions.d.ts.map +1 -0
  8. package/dist/nodes/Netvy/GenericFunctions.js +245 -0
  9. package/dist/nodes/Netvy/GenericFunctions.js.map +1 -0
  10. package/dist/nodes/Netvy/Netvy.node.d.ts +6 -0
  11. package/dist/nodes/Netvy/Netvy.node.d.ts.map +1 -0
  12. package/dist/nodes/Netvy/Netvy.node.js +2341 -0
  13. package/dist/nodes/Netvy/Netvy.node.js.map +1 -0
  14. package/dist/nodes/Netvy/resources/articulos.d.ts +3 -0
  15. package/dist/nodes/Netvy/resources/articulos.d.ts.map +1 -0
  16. package/dist/nodes/Netvy/resources/articulos.js +108 -0
  17. package/dist/nodes/Netvy/resources/articulos.js.map +1 -0
  18. package/dist/nodes/Netvy/resources/auth.d.ts +3 -0
  19. package/dist/nodes/Netvy/resources/auth.d.ts.map +1 -0
  20. package/dist/nodes/Netvy/resources/auth.js +117 -0
  21. package/dist/nodes/Netvy/resources/auth.js.map +1 -0
  22. package/dist/nodes/Netvy/resources/catalog.d.ts +3 -0
  23. package/dist/nodes/Netvy/resources/catalog.d.ts.map +1 -0
  24. package/dist/nodes/Netvy/resources/catalog.js +181 -0
  25. package/dist/nodes/Netvy/resources/catalog.js.map +1 -0
  26. package/dist/nodes/Netvy/resources/cuentasContables.d.ts +3 -0
  27. package/dist/nodes/Netvy/resources/cuentasContables.d.ts.map +1 -0
  28. package/dist/nodes/Netvy/resources/cuentasContables.js +22 -0
  29. package/dist/nodes/Netvy/resources/cuentasContables.js.map +1 -0
  30. package/dist/nodes/Netvy/resources/empresas.d.ts +3 -0
  31. package/dist/nodes/Netvy/resources/empresas.d.ts.map +1 -0
  32. package/dist/nodes/Netvy/resources/empresas.js +29 -0
  33. package/dist/nodes/Netvy/resources/empresas.js.map +1 -0
  34. package/dist/nodes/Netvy/resources/eventos.d.ts +3 -0
  35. package/dist/nodes/Netvy/resources/eventos.d.ts.map +1 -0
  36. package/dist/nodes/Netvy/resources/eventos.js +36 -0
  37. package/dist/nodes/Netvy/resources/eventos.js.map +1 -0
  38. package/dist/nodes/Netvy/resources/gd.d.ts +3 -0
  39. package/dist/nodes/Netvy/resources/gd.d.ts.map +1 -0
  40. package/dist/nodes/Netvy/resources/gd.js +373 -0
  41. package/dist/nodes/Netvy/resources/gd.js.map +1 -0
  42. package/dist/nodes/Netvy/resources/imputaciones.d.ts +3 -0
  43. package/dist/nodes/Netvy/resources/imputaciones.d.ts.map +1 -0
  44. package/dist/nodes/Netvy/resources/imputaciones.js +59 -0
  45. package/dist/nodes/Netvy/resources/imputaciones.js.map +1 -0
  46. package/dist/nodes/Netvy/resources/mesPowermill.d.ts +3 -0
  47. package/dist/nodes/Netvy/resources/mesPowermill.d.ts.map +1 -0
  48. package/dist/nodes/Netvy/resources/mesPowermill.js +60 -0
  49. package/dist/nodes/Netvy/resources/mesPowermill.js.map +1 -0
  50. package/dist/nodes/Netvy/resources/notas.d.ts +3 -0
  51. package/dist/nodes/Netvy/resources/notas.d.ts.map +1 -0
  52. package/dist/nodes/Netvy/resources/notas.js +143 -0
  53. package/dist/nodes/Netvy/resources/notas.js.map +1 -0
  54. package/dist/nodes/Netvy/resources/ofertas.d.ts +3 -0
  55. package/dist/nodes/Netvy/resources/ofertas.d.ts.map +1 -0
  56. package/dist/nodes/Netvy/resources/ofertas.js +47 -0
  57. package/dist/nodes/Netvy/resources/ofertas.js.map +1 -0
  58. package/dist/nodes/Netvy/resources/oportunidades.d.ts +3 -0
  59. package/dist/nodes/Netvy/resources/oportunidades.d.ts.map +1 -0
  60. package/dist/nodes/Netvy/resources/oportunidades.js +41 -0
  61. package/dist/nodes/Netvy/resources/oportunidades.js.map +1 -0
  62. package/dist/nodes/Netvy/resources/proveedoresInternal.d.ts +3 -0
  63. package/dist/nodes/Netvy/resources/proveedoresInternal.d.ts.map +1 -0
  64. package/dist/nodes/Netvy/resources/proveedoresInternal.js +19 -0
  65. package/dist/nodes/Netvy/resources/proveedoresInternal.js.map +1 -0
  66. package/dist/nodes/Netvy/resources/proyectosOfCostes.d.ts +3 -0
  67. package/dist/nodes/Netvy/resources/proyectosOfCostes.d.ts.map +1 -0
  68. package/dist/nodes/Netvy/resources/proyectosOfCostes.js +18 -0
  69. package/dist/nodes/Netvy/resources/proyectosOfCostes.js.map +1 -0
  70. package/dist/nodes/Netvy/resources/quickmodules.d.ts +8 -0
  71. package/dist/nodes/Netvy/resources/quickmodules.d.ts.map +1 -0
  72. package/dist/nodes/Netvy/resources/quickmodules.js +126 -0
  73. package/dist/nodes/Netvy/resources/quickmodules.js.map +1 -0
  74. package/dist/nodes/Netvy/resources/recepciones.d.ts +3 -0
  75. package/dist/nodes/Netvy/resources/recepciones.d.ts.map +1 -0
  76. package/dist/nodes/Netvy/resources/recepciones.js +34 -0
  77. package/dist/nodes/Netvy/resources/recepciones.js.map +1 -0
  78. package/dist/nodes/Netvy/resources/restmodules.d.ts +17 -0
  79. package/dist/nodes/Netvy/resources/restmodules.d.ts.map +1 -0
  80. package/dist/nodes/Netvy/resources/restmodules.js +149 -0
  81. package/dist/nodes/Netvy/resources/restmodules.js.map +1 -0
  82. package/dist/nodes/Netvy/resources/rutasCostes.d.ts +3 -0
  83. package/dist/nodes/Netvy/resources/rutasCostes.d.ts.map +1 -0
  84. package/dist/nodes/Netvy/resources/rutasCostes.js +18 -0
  85. package/dist/nodes/Netvy/resources/rutasCostes.js.map +1 -0
  86. package/dist/nodes/Netvy/resources/sincronizadorDb.d.ts +3 -0
  87. package/dist/nodes/Netvy/resources/sincronizadorDb.d.ts.map +1 -0
  88. package/dist/nodes/Netvy/resources/sincronizadorDb.js +54 -0
  89. package/dist/nodes/Netvy/resources/sincronizadorDb.js.map +1 -0
  90. package/dist/nodes/Netvy/resources/soportesCostes.d.ts +3 -0
  91. package/dist/nodes/Netvy/resources/soportesCostes.d.ts.map +1 -0
  92. package/dist/nodes/Netvy/resources/soportesCostes.js +21 -0
  93. package/dist/nodes/Netvy/resources/soportesCostes.js.map +1 -0
  94. package/dist/nodes/Netvy/resources/tarjetas.d.ts +3 -0
  95. package/dist/nodes/Netvy/resources/tarjetas.d.ts.map +1 -0
  96. package/dist/nodes/Netvy/resources/tarjetas.js +29 -0
  97. package/dist/nodes/Netvy/resources/tarjetas.js.map +1 -0
  98. package/dist/nodes/Netvy/resources/tickets.d.ts +3 -0
  99. package/dist/nodes/Netvy/resources/tickets.d.ts.map +1 -0
  100. package/dist/nodes/Netvy/resources/tickets.js +196 -0
  101. package/dist/nodes/Netvy/resources/tickets.js.map +1 -0
  102. package/dist/nodes/Netvy/resources/variablesPublicas.d.ts +3 -0
  103. package/dist/nodes/Netvy/resources/variablesPublicas.d.ts.map +1 -0
  104. package/dist/nodes/Netvy/resources/variablesPublicas.js +27 -0
  105. package/dist/nodes/Netvy/resources/variablesPublicas.js.map +1 -0
  106. package/dist/nodes/Netvy/resources/webhooks.d.ts +3 -0
  107. package/dist/nodes/Netvy/resources/webhooks.d.ts.map +1 -0
  108. package/dist/nodes/Netvy/resources/webhooks.js +31 -0
  109. package/dist/nodes/Netvy/resources/webhooks.js.map +1 -0
  110. package/dist/nodes/Netvy/resources/wmsRecalculos.d.ts +3 -0
  111. package/dist/nodes/Netvy/resources/wmsRecalculos.d.ts.map +1 -0
  112. package/dist/nodes/Netvy/resources/wmsRecalculos.js +37 -0
  113. package/dist/nodes/Netvy/resources/wmsRecalculos.js.map +1 -0
  114. package/dist/nodes/NetvyTrigger/NetvyTrigger.node.d.ts +6 -0
  115. package/dist/nodes/NetvyTrigger/NetvyTrigger.node.d.ts.map +1 -0
  116. package/dist/nodes/NetvyTrigger/NetvyTrigger.node.js +138 -0
  117. package/dist/nodes/NetvyTrigger/NetvyTrigger.node.js.map +1 -0
  118. package/dist/nodes/netvyIcon.png +0 -0
  119. package/package.json +58 -0
@@ -0,0 +1,2341 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Netvy = void 0;
4
+ const GenericFunctions_1 = require("./GenericFunctions");
5
+ const auth_1 = require("./resources/auth");
6
+ const articulos_1 = require("./resources/articulos");
7
+ const tickets_1 = require("./resources/tickets");
8
+ const catalog_1 = require("./resources/catalog");
9
+ const gd_1 = require("./resources/gd");
10
+ const notas_1 = require("./resources/notas");
11
+ const ofertas_1 = require("./resources/ofertas");
12
+ const oportunidades_1 = require("./resources/oportunidades");
13
+ const tarjetas_1 = require("./resources/tarjetas");
14
+ const empresas_1 = require("./resources/empresas");
15
+ const quickmodules_1 = require("./resources/quickmodules");
16
+ const restmodules_1 = require("./resources/restmodules");
17
+ const cuentasContables_1 = require("./resources/cuentasContables");
18
+ const proveedoresInternal_1 = require("./resources/proveedoresInternal");
19
+ const recepciones_1 = require("./resources/recepciones");
20
+ const eventos_1 = require("./resources/eventos");
21
+ const imputaciones_1 = require("./resources/imputaciones");
22
+ const variablesPublicas_1 = require("./resources/variablesPublicas");
23
+ const webhooks_1 = require("./resources/webhooks");
24
+ const wmsRecalculos_1 = require("./resources/wmsRecalculos");
25
+ const mesPowermill_1 = require("./resources/mesPowermill");
26
+ const proyectosOfCostes_1 = require("./resources/proyectosOfCostes");
27
+ const rutasCostes_1 = require("./resources/rutasCostes");
28
+ const soportesCostes_1 = require("./resources/soportesCostes");
29
+ const sincronizadorDb_1 = require("./resources/sincronizadorDb");
30
+ class Netvy {
31
+ description = {
32
+ displayName: 'Netvy',
33
+ name: 'netvy',
34
+ icon: 'file:../netvyIcon.png',
35
+ group: ['transform'],
36
+ version: 1,
37
+ description: 'API unificada de Netvy — Auth, Artículos, Tickets, GD y más',
38
+ defaults: {
39
+ name: 'Netvy',
40
+ },
41
+ subtitle: '={{$parameter["resource"] + " → " + $parameter["operation"]}}',
42
+ inputs: ['main'],
43
+ outputs: ['main'],
44
+ credentials: [
45
+ {
46
+ name: 'netvyApi',
47
+ required: false,
48
+ },
49
+ ],
50
+ properties: [
51
+ // ── Authentication mode ──────────────────────────
52
+ {
53
+ displayName: 'Autenticación',
54
+ name: 'authentication',
55
+ type: 'options',
56
+ options: [
57
+ {
58
+ name: 'Usar Credenciales',
59
+ value: 'credential',
60
+ },
61
+ {
62
+ name: 'Desde el Item de Entrada',
63
+ value: 'input',
64
+ description: 'Usa campos usuario, contrasena, license y host del item de entrada',
65
+ },
66
+ ],
67
+ default: 'credential',
68
+ },
69
+ {
70
+ displayName: 'Host',
71
+ name: 'host',
72
+ type: 'string',
73
+ default: 'https://coapi.netvy.net',
74
+ displayOptions: {
75
+ show: { authentication: ['input'] },
76
+ },
77
+ description: 'URL base de la API de Netvy',
78
+ },
79
+ {
80
+ displayName: 'Licencia',
81
+ name: 'license',
82
+ type: 'string',
83
+ default: '',
84
+ displayOptions: {
85
+ show: { authentication: ['input'] },
86
+ },
87
+ description: 'Licencia opcional',
88
+ },
89
+ // ── Opciones de sesión (globales) ────────────────
90
+ {
91
+ displayName: 'Recordarme',
92
+ name: 'recordarme',
93
+ type: 'boolean',
94
+ default: true,
95
+ description: 'Extiende la duración del refresh token. Se envía en cada login automático.',
96
+ },
97
+ {
98
+ displayName: 'Forzar Cerrar Sesión Más Antigua',
99
+ name: 'cerrarSesionMasAntigua',
100
+ type: 'boolean',
101
+ default: false,
102
+ description: 'Si se excede el límite de sesiones, fuerza el cierre de la más antigua al hacer login.',
103
+ },
104
+ // ── Resource ─────────────────────────────────────
105
+ {
106
+ displayName: 'Recurso',
107
+ name: 'resource',
108
+ type: 'options',
109
+ noDataExpression: true,
110
+ options: [
111
+ { name: 'Autenticación (Auth)', value: 'auth' },
112
+ { name: 'Artículos WMS', value: 'articulos' },
113
+ { name: 'Tickets CRM', value: 'tickets' },
114
+ { name: 'Ofertas CRM', value: 'ofertas' },
115
+ { name: 'Oportunidades CRM', value: 'oportunidades' },
116
+ { name: 'Tarjetas Kanban', value: 'tarjetas' },
117
+ { name: 'Calls CRM', value: 'calls' },
118
+ { name: 'Cuentas CRM', value: 'cuentas' },
119
+ { name: 'Empresas', value: 'empresas' },
120
+ { name: 'Familias', value: 'familias' },
121
+ { name: 'Pedidos Compra', value: 'pedidoscompra' },
122
+ { name: 'Albaranes Venta', value: 'albaranes' },
123
+ { name: 'Procesos', value: 'procesos' },
124
+ { name: 'Operaciones', value: 'operaciones' },
125
+ { name: 'Proyectos', value: 'proyectos' },
126
+ { name: 'Registro Horas (MES)', value: 'registroHoras' },
127
+ { name: 'Kanban Producción', value: 'kanbanProd' },
128
+ { name: 'OF Consulta', value: 'ofConsulta' },
129
+ { name: 'Máquinas', value: 'machines' },
130
+ { name: 'WMS Movimientos', value: 'wmsMovimientos' },
131
+ { name: 'Monedas', value: 'monedas' },
132
+ { name: 'IVA', value: 'iva' },
133
+ { name: 'Geografía', value: 'geografia' },
134
+ { name: 'Tipos Cuenta', value: 'tiposCuenta' },
135
+ { name: 'Tipos Movimiento', value: 'tiposMovimiento' },
136
+ { name: 'Tarifas Venta', value: 'tarifasVenta' },
137
+ { name: 'Formas Pago/Cobro', value: 'formasPago' },
138
+ { name: 'Usuarios', value: 'usuarios' },
139
+ { name: 'Catálogos', value: 'catalogs' },
140
+ { name: 'Gestión Documental (GD)', value: 'gd' },
141
+ { name: 'Notas (GD)', value: 'notas' },
142
+ { name: 'Cuentas Contables', value: 'cuentasContables' },
143
+ { name: 'Proveedores (Interno)', value: 'proveedoresInternal' },
144
+ { name: 'Recepciones', value: 'recepciones' },
145
+ { name: 'Eventos (GD)', value: 'eventos' },
146
+ { name: 'Imputaciones (MES)', value: 'imputaciones' },
147
+ { name: 'Variables Públicas', value: 'variablesPublicas' },
148
+ { name: 'Webhooks', value: 'webhooks' },
149
+ { name: 'WMS Recálculos', value: 'wmsRecalculos' },
150
+ { name: 'MES PowerMill', value: 'mesPowermill' },
151
+ { name: 'Proyectos OF Costes', value: 'proyectosOfCostes' },
152
+ { name: 'Rutas Costes', value: 'rutasCostes' },
153
+ { name: 'Soportes Costes', value: 'soportesCostes' },
154
+ { name: 'Sincronizador DB', value: 'sincronizadorDb' },
155
+ ],
156
+ default: 'auth',
157
+ },
158
+ ...auth_1.authProperties,
159
+ ...articulos_1.articulosProperties,
160
+ ...tickets_1.ticketsProperties,
161
+ ...ofertas_1.ofertasProperties,
162
+ ...oportunidades_1.oportunidadesProperties,
163
+ ...tarjetas_1.tarjetasProperties,
164
+ ...quickmodules_1.callsProperties,
165
+ ...restmodules_1.cuentasProperties,
166
+ ...empresas_1.empresasProperties,
167
+ ...quickmodules_1.familiasProperties,
168
+ ...quickmodules_1.pedidoscompraProperties,
169
+ ...quickmodules_1.albaranesProperties,
170
+ ...restmodules_1.procesosProperties,
171
+ ...restmodules_1.operacionesProperties,
172
+ ...restmodules_1.proyectosProperties,
173
+ ...quickmodules_1.registroHorasProperties,
174
+ ...quickmodules_1.kanbanProduccionProperties,
175
+ ...restmodules_1.ofConsultaProperties,
176
+ ...restmodules_1.machinesProperties,
177
+ ...restmodules_1.wmsMovimientosProperties,
178
+ ...restmodules_1.monedasProperties,
179
+ ...restmodules_1.ivaProperties,
180
+ ...restmodules_1.geografiaProperties,
181
+ ...restmodules_1.tiposCuentaProperties,
182
+ ...restmodules_1.tiposMovimientoProperties,
183
+ ...restmodules_1.tarifasVentaProperties,
184
+ ...restmodules_1.formasPagoProperties,
185
+ ...restmodules_1.usuariosProperties,
186
+ ...catalog_1.catalogProperties,
187
+ ...gd_1.gdProperties,
188
+ ...notas_1.notasProperties,
189
+ ...cuentasContables_1.cuentasContablesProperties,
190
+ ...proveedoresInternal_1.proveedoresInternalProperties,
191
+ ...recepciones_1.recepcionesProperties,
192
+ ...eventos_1.eventosProperties,
193
+ ...imputaciones_1.imputacionesProperties,
194
+ ...variablesPublicas_1.variablesPublicasProperties,
195
+ ...webhooks_1.webhooksProperties,
196
+ ...wmsRecalculos_1.wmsRecalculosProperties,
197
+ ...mesPowermill_1.mesPowermillProperties,
198
+ ...proyectosOfCostes_1.proyectosOfCostesProperties,
199
+ ...rutasCostes_1.rutasCostesProperties,
200
+ ...soportesCostes_1.soportesCostesProperties,
201
+ ...sincronizadorDb_1.sincronizadorDbProperties,
202
+ ],
203
+ };
204
+ async execute() {
205
+ const items = this.getInputData();
206
+ const returnData = [];
207
+ const resource = this.getNodeParameter('resource', 0);
208
+ const operation = this.getNodeParameter('operation', 0);
209
+ // Helper: parse a string node param to number (returns 0 if empty)
210
+ const n = (name, i, def = '') => {
211
+ const v = this.getNodeParameter(name, i, def);
212
+ return v && v !== '' ? Number(v) : 0;
213
+ };
214
+ for (let i = 0; i < items.length; i++) {
215
+ try {
216
+ // ── AUTH ─────────────────────────────────────
217
+ if (resource === 'auth') {
218
+ if (operation === 'signIn') {
219
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
220
+ const body = {};
221
+ // netvySignIn ya lee recordarme/cerrarSesionMasAntigua de creds
222
+ const signInResp = await GenericFunctions_1.netvySignIn.call(this, creds, body);
223
+ returnData.push({
224
+ json: signInResp,
225
+ pairedItem: { item: i },
226
+ });
227
+ }
228
+ else if (operation === 'refresh') {
229
+ const tokenRenovacion = this.getNodeParameter('tokenRenovacion', i);
230
+ const credsRefresh = await GenericFunctions_1.netvyGetCredentials.call(this, i);
231
+ const options = {
232
+ method: 'POST',
233
+ url: `${credsRefresh.host}/api/v1/auth/refresh`,
234
+ headers: { 'Content-Type': 'application/json' },
235
+ body: { tokenRenovacion },
236
+ json: true,
237
+ };
238
+ const resp = await this.helpers.httpRequest(options);
239
+ returnData.push({
240
+ json: resp,
241
+ pairedItem: { item: i },
242
+ });
243
+ }
244
+ else if (operation === 'me' || operation === 'signOut' || operation === 'changeActiveCompany') {
245
+ // These need existing token
246
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
247
+ let endpoint;
248
+ let method = 'GET';
249
+ let body;
250
+ switch (operation) {
251
+ case 'me':
252
+ endpoint = '/api/v1/auth/me';
253
+ break;
254
+ case 'signOut':
255
+ endpoint = '/api/v1/auth/signout';
256
+ method = 'POST';
257
+ break;
258
+ case 'changeActiveCompany':
259
+ endpoint = '/api/v1/auth/active-company';
260
+ method = 'PATCH';
261
+ body = {
262
+ empresaID: this.getNodeParameter('empresaID', i),
263
+ };
264
+ break;
265
+ default:
266
+ continue;
267
+ }
268
+ const headers = {};
269
+ if (operation === 'changeActiveCompany') {
270
+ headers['x-company'] = this.getNodeParameter('xCompany', i);
271
+ }
272
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, method, endpoint, creds, body, undefined, headers);
273
+ returnData.push({
274
+ json: resp,
275
+ pairedItem: { item: i },
276
+ });
277
+ }
278
+ // ── ARTICULOS WMS ────────────────────────────
279
+ }
280
+ else if (resource === 'articulos') {
281
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
282
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
283
+ const hdrs = { 'x-company': xCompany };
284
+ if (operation === 'query') {
285
+ const body = {};
286
+ const busqueda = this.getNodeParameter('busqueda', i, '');
287
+ const pagina = n('pagina', i);
288
+ const tamanoPagina = n('tamanoPagina', i);
289
+ const codigo = this.getNodeParameter('codigo', i, '');
290
+ const nombre = this.getNodeParameter('nombre', i, '');
291
+ const familiaID = n('familiaID', i);
292
+ const subFamiliaID = n('subFamiliaID', i);
293
+ const codigoBarras = this.getNodeParameter('codigoBarras', i, '');
294
+ const codigoAlternativo = this.getNodeParameter('codigoAlternativo', i, '');
295
+ const descripcion = this.getNodeParameter('descripcion', i, '');
296
+ const abreviatura = this.getNodeParameter('abreviatura', i, '');
297
+ const tipoArticuloID = n('tipoArticuloID', i);
298
+ const grupoArticuloCodigo = this.getNodeParameter('grupoArticuloCodigo', i, '');
299
+ const familiaCodigo = this.getNodeParameter('familiaCodigo', i, '');
300
+ const subFamiliaCodigo = this.getNodeParameter('subFamiliaCodigo', i, '');
301
+ const estado = this.getNodeParameter('estado', i);
302
+ const grupoArticuloIDs = this.getNodeParameter('grupoArticuloIDs', i, '');
303
+ const tipoArticuloIDs = this.getNodeParameter('tipoArticuloIDs', i, '');
304
+ const palabraClaveIDs = this.getNodeParameter('palabraClaveIDs', i, '');
305
+ if (busqueda)
306
+ body.busqueda = busqueda;
307
+ if (pagina)
308
+ body.pagina = pagina;
309
+ if (tamanoPagina)
310
+ body.tamanoPagina = tamanoPagina;
311
+ if (codigo)
312
+ body.codigo = codigo;
313
+ if (nombre)
314
+ body.nombre = nombre;
315
+ if (familiaID)
316
+ body.familiaID = familiaID;
317
+ if (subFamiliaID)
318
+ body.subFamiliaID = subFamiliaID;
319
+ if (codigoBarras)
320
+ body.codigoBarras = codigoBarras;
321
+ if (codigoAlternativo)
322
+ body.codigoAlternativo = codigoAlternativo;
323
+ if (descripcion)
324
+ body.descripcion = descripcion;
325
+ if (abreviatura)
326
+ body.abreviatura = abreviatura;
327
+ if (tipoArticuloID)
328
+ body.tipoArticuloID = tipoArticuloID;
329
+ if (grupoArticuloCodigo)
330
+ body.grupoArticuloCodigo = grupoArticuloCodigo;
331
+ if (familiaCodigo)
332
+ body.familiaCodigo = familiaCodigo;
333
+ if (subFamiliaCodigo)
334
+ body.subFamiliaCodigo = subFamiliaCodigo;
335
+ if (estado)
336
+ body.estado = estado;
337
+ const parseIds = (s) => s ? s.split(',').map(Number).filter((n) => n > 0) : [];
338
+ const gIDs = parseIds(grupoArticuloIDs);
339
+ const tIDs = parseIds(tipoArticuloIDs);
340
+ const pIDs = parseIds(palabraClaveIDs);
341
+ if (gIDs.length)
342
+ body.grupoArticuloIDs = gIDs;
343
+ if (tIDs.length)
344
+ body.tipoArticuloIDs = tIDs;
345
+ if (pIDs.length)
346
+ body.palabraClaveIDs = pIDs;
347
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/wms/api/v1/articulos', creds, body, undefined, hdrs);
348
+ returnData.push({
349
+ json: resp, pairedItem: { item: i },
350
+ });
351
+ }
352
+ else if (operation === 'get') {
353
+ const articuloID = n('articuloID', i);
354
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `/wms/api/v1/articulos/${articuloID}`, creds, undefined, undefined, hdrs);
355
+ returnData.push({
356
+ json: resp, pairedItem: { item: i },
357
+ });
358
+ }
359
+ else if (operation === 'create') {
360
+ const body = {
361
+ codigo: this.getNodeParameter('codigoCreate', i),
362
+ nombre: this.getNodeParameter('nombreCreate', i),
363
+ familiaID: this.getNodeParameter('familiaIDCreate', i),
364
+ };
365
+ const additionalFields = this.getNodeParameter('additionalFields', i);
366
+ if (additionalFields.codigoAlternativo)
367
+ body.codigoAlternativo = additionalFields.codigoAlternativo;
368
+ if (additionalFields.subFamiliaID)
369
+ body.subFamiliaID = additionalFields.subFamiliaID;
370
+ if (additionalFields.tipoArticuloID)
371
+ body.tipoArticuloID = additionalFields.tipoArticuloID;
372
+ if (additionalFields.descripcion)
373
+ body.descripcion = additionalFields.descripcion;
374
+ if (additionalFields.noPublicar !== undefined)
375
+ body.noPublicar = additionalFields.noPublicar;
376
+ if (additionalFields.articuloFicticio !== undefined)
377
+ body.articuloFicticio = additionalFields.articuloFicticio;
378
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/wms/api/v1/articulos', creds, body, undefined, hdrs);
379
+ returnData.push({
380
+ json: resp, pairedItem: { item: i },
381
+ });
382
+ }
383
+ else if (operation === 'update') {
384
+ const articuloID = n('articuloID', i);
385
+ const updateFields = this.getNodeParameter('updateFields', i);
386
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `/wms/api/v1/articulos/${articuloID}`, creds, updateFields, undefined, hdrs);
387
+ returnData.push({
388
+ json: resp, pairedItem: { item: i },
389
+ });
390
+ }
391
+ else if (operation === 'delete') {
392
+ const articuloID = n('articuloID', i);
393
+ const motivoBajaID = n('motivoBajaID', i);
394
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `/wms/api/v1/articulos/${articuloID}`, creds, { motivoBajaID }, undefined, hdrs);
395
+ returnData.push({
396
+ json: { success: true, articuloID }, pairedItem: { item: i },
397
+ });
398
+ }
399
+ else if (operation === 'activate') {
400
+ const articuloID = n('articuloID', i);
401
+ await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `/wms/api/v1/articulos/${articuloID}/opciones/activar`, creds, undefined, undefined, hdrs);
402
+ returnData.push({
403
+ json: { success: true, articuloID }, pairedItem: { item: i },
404
+ });
405
+ }
406
+ else if (operation === 'queryPrecio') {
407
+ const articuloID = n('articuloID', i);
408
+ const monedaID = n('monedaID', i);
409
+ const body = {};
410
+ if (monedaID)
411
+ body.monedaID = monedaID;
412
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `/wms/api/v1/articulos/${articuloID}/precio`, creds, body, undefined, hdrs);
413
+ returnData.push({
414
+ json: resp, pairedItem: { item: i },
415
+ });
416
+ }
417
+ else if (operation === 'uploadImagen') {
418
+ const articuloID = n('articuloID', i);
419
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
420
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
421
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
422
+ const fileName = binaryData.fileName || 'imagen.jpg';
423
+ await GenericFunctions_1.netvyApiRequestUpload.call(this, `/wms/api/v1/articulos/${articuloID}/imagen`, creds, buffer, fileName, 'imagen', undefined, hdrs);
424
+ returnData.push({
425
+ json: { success: true, articuloID, fileName },
426
+ pairedItem: { item: i },
427
+ });
428
+ }
429
+ else if (operation === 'ajustePrecios') {
430
+ const articuloIDsStr = this.getNodeParameter('articuloIDs', i);
431
+ const tipoAjuste = this.getNodeParameter('tipoAjuste', i);
432
+ const valorAjuste = n('valorAjuste', i);
433
+ const ajustarPrecioVenta = this.getNodeParameter('ajustarPrecioVenta', i);
434
+ const ajustarPrecioCompra = this.getNodeParameter('ajustarPrecioCompra', i);
435
+ const ajustarCosteEstandar = this.getNodeParameter('ajustarCosteEstandar', i);
436
+ const articuloIDs = articuloIDsStr
437
+ .split(',')
438
+ .map(Number)
439
+ .filter((n) => n > 0);
440
+ const body = {
441
+ articuloIDs,
442
+ tipoAjuste,
443
+ valorAjuste,
444
+ ajustarPrecioVenta,
445
+ ajustarPrecioCompra,
446
+ ajustarCosteEstandar,
447
+ };
448
+ await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/wms/api/v1/articulos/ajuste-precios', creds, body, undefined, hdrs);
449
+ returnData.push({
450
+ json: { success: true, afectados: articuloIDs.length },
451
+ pairedItem: { item: i },
452
+ });
453
+ }
454
+ }
455
+ // ── TICKETS CRM ────────────────────────────
456
+ else if (resource === 'tickets') {
457
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
458
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
459
+ const headers = { 'x-company': xCompany };
460
+ const base = '/crm/api/v1/tickets';
461
+ if (operation === 'query') {
462
+ const body = {};
463
+ const p = n('pagina', i);
464
+ const tp = n('tamanoPagina', i);
465
+ if (p)
466
+ body.pagina = p;
467
+ if (tp)
468
+ body.tamanoPagina = tp;
469
+ const busqueda = this.getNodeParameter('busqueda', i, '');
470
+ const filters = this.getNodeParameter('queryFilters', i);
471
+ if (busqueda)
472
+ body.busqueda = busqueda;
473
+ if (filters.mailingIDs)
474
+ body.mailingIDs = filters.mailingIDs.split(',').map(Number).filter((n) => n > 0);
475
+ if (filters.contactoIDs)
476
+ body.contactoIDs = filters.contactoIDs.split(',').map(Number).filter((n) => n > 0);
477
+ if (filters.situacionIDs)
478
+ body.situacionIDs = filters.situacionIDs.split(',').map(Number).filter((n) => n > 0);
479
+ if (filters.prioridadIDs)
480
+ body.prioridadIDs = filters.prioridadIDs.split(',').map(Number).filter((n) => n > 0);
481
+ if (filters.tipoIDs)
482
+ body.tipoIDs = filters.tipoIDs.split(',').map(Number).filter((n) => n > 0);
483
+ if (filters.areaIDs)
484
+ body.areaIDs = filters.areaIDs.split(',').map(Number).filter((n) => n > 0);
485
+ if (filters.representanteIDs)
486
+ body.representanteIDs = filters.representanteIDs.split(',').map(Number).filter((n) => n > 0);
487
+ if (filters.estado)
488
+ body.estado = filters.estado;
489
+ if (filters.fechaDesde)
490
+ body.fechaDesde = filters.fechaDesde;
491
+ if (filters.fechaHasta)
492
+ body.fechaHasta = filters.fechaHasta;
493
+ if (filters.ordenarPor)
494
+ body.ordenarPor = filters.ordenarPor;
495
+ if (filters.direccionOrden)
496
+ body.direccionOrden = filters.direccionOrden;
497
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, headers);
498
+ returnData.push({ json: resp, pairedItem: { item: i } });
499
+ }
500
+ else if (operation === 'get') {
501
+ const ticketID = this.getNodeParameter('ticketID', i);
502
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${ticketID}`, creds, undefined, undefined, headers);
503
+ returnData.push({ json: resp, pairedItem: { item: i } });
504
+ }
505
+ else if (operation === 'create') {
506
+ const body = {
507
+ mailingID: n('mailingID', i),
508
+ titulo: this.getNodeParameter('tituloCreate', i),
509
+ };
510
+ const fields = this.getNodeParameter('createFields', i);
511
+ for (const [k, v] of Object.entries(fields)) {
512
+ if (v !== undefined && v !== '' && v !== 0)
513
+ body[k] = v;
514
+ }
515
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, headers);
516
+ returnData.push({ json: resp, pairedItem: { item: i } });
517
+ }
518
+ else if (operation === 'update') {
519
+ const ticketID = this.getNodeParameter('ticketID', i);
520
+ const body = this.getNodeParameter('updateFields', i);
521
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${ticketID}`, creds, body, undefined, headers);
522
+ returnData.push({ json: resp, pairedItem: { item: i } });
523
+ }
524
+ else if (operation === 'delete') {
525
+ const ticketID = this.getNodeParameter('ticketID', i);
526
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${base}/${ticketID}`, creds, undefined, undefined, headers);
527
+ returnData.push({ json: { success: true, ticketID }, pairedItem: { item: i } });
528
+ }
529
+ else if (operation === 'resolve') {
530
+ const ticketID = this.getNodeParameter('ticketID', i);
531
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/resolver`, creds, undefined, undefined, headers);
532
+ returnData.push({ json: resp, pairedItem: { item: i } });
533
+ }
534
+ else if (operation === 'finalize') {
535
+ const ticketID = this.getNodeParameter('ticketID', i);
536
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/finalizar`, creds, undefined, undefined, headers);
537
+ returnData.push({ json: resp, pairedItem: { item: i } });
538
+ }
539
+ else if (operation === 'reopen') {
540
+ const ticketID = this.getNodeParameter('ticketID', i);
541
+ const nota = this.getNodeParameter('notaReapertura', i);
542
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/reabrir`, creds, { notaReapertura: nota }, undefined, headers);
543
+ returnData.push({ json: resp, pairedItem: { item: i } });
544
+ }
545
+ else if (operation === 'approve') {
546
+ const ticketID = this.getNodeParameter('ticketID', i);
547
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/aprobar`, creds, undefined, undefined, headers);
548
+ returnData.push({ json: resp, pairedItem: { item: i } });
549
+ }
550
+ else if (operation === 'reject') {
551
+ const ticketID = this.getNodeParameter('ticketID', i);
552
+ const motivo = this.getNodeParameter('motivoRechazo', i);
553
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/rechazar`, creds, { motivoRechazo: motivo }, undefined, headers);
554
+ returnData.push({ json: resp, pairedItem: { item: i } });
555
+ }
556
+ else if (operation === 'changePriority') {
557
+ const ticketID = this.getNodeParameter('ticketID', i);
558
+ const nuevaPrioridadID = n('nuevaPrioridadID', i);
559
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/cambiar-prioridad`, creds, { nuevaPrioridadID }, undefined, headers);
560
+ returnData.push({ json: resp, pairedItem: { item: i } });
561
+ }
562
+ else if (operation === 'listCards') {
563
+ const ticketID = this.getNodeParameter('ticketID', i);
564
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${ticketID}/tarjetas`, creds, undefined, undefined, headers);
565
+ returnData.push({ json: resp, pairedItem: { item: i } });
566
+ }
567
+ else if (operation === 'associateCard') {
568
+ const ticketID = this.getNodeParameter('ticketID', i);
569
+ const tarjetaID = this.getNodeParameter('tarjetaID', i);
570
+ await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${ticketID}/tarjetas`, creds, { tarjetaID }, undefined, headers);
571
+ returnData.push({ json: { success: true, ticketID, tarjetaID }, pairedItem: { item: i } });
572
+ }
573
+ else if (operation === 'availableCards') {
574
+ const ticketID = this.getNodeParameter('ticketID', i);
575
+ const busqueda = this.getNodeParameter('busquedaTarjetas', i, '');
576
+ const qs = {};
577
+ if (busqueda)
578
+ qs.busqueda = busqueda;
579
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${ticketID}/tarjetas-disponibles`, creds, undefined, qs, headers);
580
+ returnData.push({ json: resp, pairedItem: { item: i } });
581
+ }
582
+ }
583
+ // ── OFERTAS CRM ────────────────────────────
584
+ else if (resource === 'ofertas') {
585
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
586
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
587
+ const hdrs = { 'x-company': xCompany };
588
+ const base = '/crm/api/v1/ofertas';
589
+ if (operation === 'query') {
590
+ const body = {};
591
+ const p = n('pagina', i);
592
+ if (p)
593
+ body.pagina = p;
594
+ const tp = n('tamanoPagina', i);
595
+ if (tp)
596
+ body.tamanoPagina = tp;
597
+ const b = this.getNodeParameter('busqueda', i, '');
598
+ if (b)
599
+ body.busqueda = b;
600
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
601
+ returnData.push({ json: resp, pairedItem: { item: i } });
602
+ }
603
+ else if (operation === 'related') {
604
+ const body = { mailingID: this.getNodeParameter('mailingID', i) };
605
+ const p = n('pagina', i);
606
+ if (p)
607
+ body.pagina = p;
608
+ const tp = n('tamanoPagina', i);
609
+ if (tp)
610
+ body.tamanoPagina = tp;
611
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${base}/relacionadas`, creds, body, undefined, hdrs);
612
+ returnData.push({ json: resp, pairedItem: { item: i } });
613
+ }
614
+ else if (operation === 'get') {
615
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('ofertaID', i)}`, creds, undefined, undefined, hdrs);
616
+ returnData.push({ json: resp, pairedItem: { item: i } });
617
+ }
618
+ else if (operation === 'create') {
619
+ const body = { mailingID: this.getNodeParameter('mailingIDCreate', i) };
620
+ const f = this.getNodeParameter('createFields', i);
621
+ for (const [k, v] of Object.entries(f)) {
622
+ if (v !== undefined && v !== '')
623
+ body[k] = v;
624
+ }
625
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
626
+ returnData.push({ json: resp, pairedItem: { item: i } });
627
+ }
628
+ else if (operation === 'update') {
629
+ const body = this.getNodeParameter('updateFields', i);
630
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('ofertaID', i)}`, creds, body, undefined, hdrs);
631
+ returnData.push({ json: resp, pairedItem: { item: i } });
632
+ }
633
+ }
634
+ // ── OPORTUNIDADES CRM ───────────────────────
635
+ else if (resource === 'oportunidades') {
636
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
637
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
638
+ const hdrs = { 'x-company': xCompany };
639
+ const base = '/crm/api/v1/oportunidades';
640
+ if (operation === 'query') {
641
+ const body = {};
642
+ const p = n('pagina', i);
643
+ if (p)
644
+ body.pagina = p;
645
+ const tp = n('tamanoPagina', i);
646
+ if (tp)
647
+ body.tamanoPagina = tp;
648
+ const b = this.getNodeParameter('busqueda', i, '');
649
+ if (b)
650
+ body.busqueda = b;
651
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
652
+ returnData.push({ json: resp, pairedItem: { item: i } });
653
+ }
654
+ else if (operation === 'search') {
655
+ const qs = {};
656
+ const b = this.getNodeParameter('busqueda', i, '');
657
+ if (b)
658
+ qs.busqueda = b;
659
+ const p = this.getNodeParameter('pagina', i, '');
660
+ if (p)
661
+ qs.pagina = p;
662
+ const tp = this.getNodeParameter('tamanoPagina', i, '');
663
+ if (tp)
664
+ qs.tamanoPagina = tp;
665
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/busqueda`, creds, undefined, qs, hdrs);
666
+ returnData.push({ json: resp, pairedItem: { item: i } });
667
+ }
668
+ else if (operation === 'get') {
669
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('oportunidadID', i)}`, creds, undefined, undefined, hdrs);
670
+ returnData.push({ json: resp, pairedItem: { item: i } });
671
+ }
672
+ else if (operation === 'create') {
673
+ const body = {
674
+ nombre: this.getNodeParameter('nombreCreate', i),
675
+ mailingID: this.getNodeParameter('mailingIDCreate', i),
676
+ };
677
+ const f = this.getNodeParameter('createFields', i);
678
+ for (const [k, v] of Object.entries(f)) {
679
+ if (v !== undefined && v !== '')
680
+ body[k] = v;
681
+ }
682
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
683
+ returnData.push({ json: resp, pairedItem: { item: i } });
684
+ }
685
+ else if (operation === 'update') {
686
+ const body = this.getNodeParameter('updateFields', i);
687
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('oportunidadID', i)}`, creds, body, undefined, hdrs);
688
+ returnData.push({ json: resp, pairedItem: { item: i } });
689
+ }
690
+ }
691
+ // ── TARJETAS KANBAN ─────────────────────────
692
+ else if (resource === 'tarjetas') {
693
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
694
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
695
+ const hdrs = { 'x-company': xCompany };
696
+ const base = '/crm/api/v1/tarjetas';
697
+ if (operation === 'kanban') {
698
+ const body = {};
699
+ const p = n('pagina', i);
700
+ if (p)
701
+ body.pagina = p;
702
+ const tp = n('tamanoPagina', i);
703
+ if (tp)
704
+ body.tamanoPagina = tp;
705
+ const b = this.getNodeParameter('busqueda', i, '');
706
+ if (b)
707
+ body.busqueda = b;
708
+ const u = this.getNodeParameter('usuarioID', i, '');
709
+ if (u)
710
+ body.usuarioID = u;
711
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${base}/kanban`, creds, body, undefined, hdrs);
712
+ returnData.push({ json: resp, pairedItem: { item: i } });
713
+ }
714
+ else if (operation === 'query') {
715
+ const body = {};
716
+ const p = n('pagina', i);
717
+ if (p)
718
+ body.pagina = p;
719
+ const tp = n('tamanoPagina', i);
720
+ if (tp)
721
+ body.tamanoPagina = tp;
722
+ const b = this.getNodeParameter('busqueda', i, '');
723
+ if (b)
724
+ body.busqueda = b;
725
+ const u = this.getNodeParameter('usuarioID', i, '');
726
+ if (u)
727
+ body.usuarioID = u;
728
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
729
+ returnData.push({ json: resp, pairedItem: { item: i } });
730
+ }
731
+ else if (operation === 'get') {
732
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('tarjetaID', i)}`, creds, undefined, undefined, hdrs);
733
+ returnData.push({ json: resp, pairedItem: { item: i } });
734
+ }
735
+ else if (operation === 'update') {
736
+ const body = this.getNodeParameter('updateFields', i);
737
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('tarjetaID', i)}`, creds, body, undefined, hdrs);
738
+ returnData.push({ json: resp, pairedItem: { item: i } });
739
+ }
740
+ else if (operation === 'delete') {
741
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${base}/${this.getNodeParameter('tarjetaID', i)}`, creds, undefined, undefined, hdrs);
742
+ returnData.push({ json: { success: true }, pairedItem: { item: i } });
743
+ }
744
+ }
745
+ // ── EMPRESAS ────────────────────────────────
746
+ else if (resource === 'empresas') {
747
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
748
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
749
+ const hdrs = { 'x-company': xCompany };
750
+ const base = '/api/v1/empresas';
751
+ if (operation === 'query') {
752
+ const body = {};
753
+ const p = n('pagina', i);
754
+ if (p)
755
+ body.pagina = p;
756
+ const tp = n('tamanoPagina', i);
757
+ if (tp)
758
+ body.tamanoPagina = tp;
759
+ const b = this.getNodeParameter('busqueda', i, '');
760
+ if (b)
761
+ body.busqueda = b;
762
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${base}/query`, creds, body, undefined, hdrs);
763
+ returnData.push({ json: resp, pairedItem: { item: i } });
764
+ }
765
+ else if (operation === 'get') {
766
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('empresaID', i)}`, creds, undefined, undefined, hdrs);
767
+ returnData.push({ json: resp, pairedItem: { item: i } });
768
+ }
769
+ else if (operation === 'create') {
770
+ const body = {
771
+ nombre: this.getNodeParameter('nombreCreate', i),
772
+ cif: this.getNodeParameter('cifCreate', i),
773
+ };
774
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
775
+ returnData.push({ json: resp, pairedItem: { item: i } });
776
+ }
777
+ else if (operation === 'update') {
778
+ const body = this.getNodeParameter('updateFields', i);
779
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('empresaID', i)}`, creds, body, undefined, hdrs);
780
+ returnData.push({ json: resp, pairedItem: { item: i } });
781
+ }
782
+ else if (operation === 'delete') {
783
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${base}/${this.getNodeParameter('empresaID', i)}`, creds, undefined, undefined, hdrs);
784
+ returnData.push({ json: { success: true }, pairedItem: { item: i } });
785
+ }
786
+ }
787
+ // ── CALLS CRM ──────────────────────────────
788
+ else if (resource === 'calls') {
789
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
790
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
791
+ const hdrs = { 'x-company': xCompany };
792
+ const base = '/gd/api/v1/calls';
793
+ if (operation === 'query') {
794
+ const body = {};
795
+ const p = n('pagina', i);
796
+ if (p)
797
+ body.pagina = p;
798
+ const tp = n('tamanoPagina', i);
799
+ if (tp)
800
+ body.tamanoPagina = tp;
801
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
802
+ returnData.push({ json: resp, pairedItem: { item: i } });
803
+ }
804
+ else if (operation === 'get') {
805
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('callID', i)}`, creds, undefined, undefined, hdrs);
806
+ returnData.push({ json: resp, pairedItem: { item: i } });
807
+ }
808
+ else if (operation === 'create') {
809
+ const body = {
810
+ mailingID: this.getNodeParameter('mailingID', i),
811
+ asunto: this.getNodeParameter('asuntoCreate', i),
812
+ };
813
+ const f = this.getNodeParameter('createFields', i);
814
+ for (const [k, v] of Object.entries(f)) {
815
+ if (v !== undefined && v !== '')
816
+ body[k] = v;
817
+ }
818
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
819
+ returnData.push({ json: resp, pairedItem: { item: i } });
820
+ }
821
+ else if (operation === 'update') {
822
+ const body = this.getNodeParameter('updateFields', i);
823
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('callID', i)}`, creds, body, undefined, hdrs);
824
+ returnData.push({ json: resp, pairedItem: { item: i } });
825
+ }
826
+ }
827
+ // ── FAMILIAS ────────────────────────────────
828
+ else if (resource === 'familias') {
829
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
830
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
831
+ const hdrs = { 'x-company': xCompany };
832
+ const base = '/crm/api/v1/familias';
833
+ if (operation === 'query') {
834
+ const body = {};
835
+ const p = n('pagina', i);
836
+ if (p)
837
+ body.pagina = p;
838
+ const tp = n('tamanoPagina', i);
839
+ if (tp)
840
+ body.tamanoPagina = tp;
841
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
842
+ returnData.push({ json: resp, pairedItem: { item: i } });
843
+ }
844
+ else if (operation === 'get') {
845
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('familiaID', i)}`, creds, undefined, undefined, hdrs);
846
+ returnData.push({ json: resp, pairedItem: { item: i } });
847
+ }
848
+ else if (operation === 'propagarNoPublicar') {
849
+ const id = this.getNodeParameter('familiaID', i);
850
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${id}/options/propagar-no-publicar`, creds, undefined, undefined, hdrs);
851
+ returnData.push({ json: resp, pairedItem: { item: i } });
852
+ }
853
+ else if (operation === 'cuentas') {
854
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('familiaID', i)}/cuentas-predeterminadas`, creds, undefined, undefined, hdrs);
855
+ returnData.push({ json: resp, pairedItem: { item: i } });
856
+ }
857
+ }
858
+ // ── PEDIDOS COMPRA ──────────────────────────
859
+ else if (resource === 'pedidoscompra') {
860
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
861
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
862
+ const hdrs = { 'x-company': xCompany };
863
+ const base = '/api/v1/pedidoscompra';
864
+ if (operation === 'query') {
865
+ const body = {};
866
+ const p = n('pagina', i);
867
+ if (p)
868
+ body.pagina = p;
869
+ const tp = n('tamanoPagina', i);
870
+ if (tp)
871
+ body.tamanoPagina = tp;
872
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
873
+ returnData.push({ json: resp, pairedItem: { item: i } });
874
+ }
875
+ else if (operation === 'get') {
876
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('pedidoID', i)}`, creds, undefined, undefined, hdrs);
877
+ returnData.push({ json: resp, pairedItem: { item: i } });
878
+ }
879
+ else if (operation === 'create') {
880
+ const body = { proveedorID: this.getNodeParameter('proveedorID', i) };
881
+ const f = this.getNodeParameter('createFields', i);
882
+ for (const [k, v] of Object.entries(f)) {
883
+ if (v !== undefined && v !== '')
884
+ body[k] = v;
885
+ }
886
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
887
+ returnData.push({ json: resp, pairedItem: { item: i } });
888
+ }
889
+ else if (operation === 'update') {
890
+ const body = this.getNodeParameter('updateFields', i);
891
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('pedidoID', i)}`, creds, body, undefined, hdrs);
892
+ returnData.push({ json: resp, pairedItem: { item: i } });
893
+ }
894
+ }
895
+ // ── ALBARANES VENTA ─────────────────────────
896
+ else if (resource === 'albaranes') {
897
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
898
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
899
+ const hdrs = { 'x-company': xCompany };
900
+ const base = '/api/v1/albaranes-venta';
901
+ if (operation === 'query') {
902
+ const body = {};
903
+ const p = n('pagina', i);
904
+ if (p)
905
+ body.pagina = p;
906
+ const tp = n('tamanoPagina', i);
907
+ if (tp)
908
+ body.tamanoPagina = tp;
909
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
910
+ returnData.push({ json: resp, pairedItem: { item: i } });
911
+ }
912
+ else if (operation === 'lineas') {
913
+ const id = this.getNodeParameter('albaranID', i);
914
+ const qs = {};
915
+ const p = this.getNodeParameter('pagina', i, '');
916
+ if (p)
917
+ qs.pagina = p;
918
+ const tp = this.getNodeParameter('tamanoPagina', i, '');
919
+ if (tp)
920
+ qs.tamanoPagina = tp;
921
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${id}/lineas`, creds, undefined, qs, hdrs);
922
+ returnData.push({ json: resp, pairedItem: { item: i } });
923
+ }
924
+ }
925
+ // ── REGISTRO HORAS ──────────────────────────
926
+ else if (resource === 'registroHoras') {
927
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
928
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
929
+ const hdrs = { 'x-company': xCompany };
930
+ const base = '/mes/api/v1/registro-horas';
931
+ if (operation === 'query') {
932
+ const body = {};
933
+ const p = n('pagina', i);
934
+ if (p)
935
+ body.pagina = p;
936
+ const tp = n('tamanoPagina', i);
937
+ if (tp)
938
+ body.tamanoPagina = tp;
939
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, hdrs);
940
+ returnData.push({ json: resp, pairedItem: { item: i } });
941
+ }
942
+ else if (operation === 'get') {
943
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${this.getNodeParameter('tiempoID', i)}`, creds, undefined, undefined, hdrs);
944
+ returnData.push({ json: resp, pairedItem: { item: i } });
945
+ }
946
+ else if (operation === 'create') {
947
+ const body = {
948
+ ofID: this.getNodeParameter('ofID', i),
949
+ horas: this.getNodeParameter('horas', i),
950
+ };
951
+ const f = this.getNodeParameter('createFields', i);
952
+ for (const [k, v] of Object.entries(f)) {
953
+ if (v !== undefined && v !== '')
954
+ body[k] = v;
955
+ }
956
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, hdrs);
957
+ returnData.push({ json: resp, pairedItem: { item: i } });
958
+ }
959
+ else if (operation === 'update') {
960
+ const body = this.getNodeParameter('updateFields', i);
961
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${this.getNodeParameter('tiempoID', i)}`, creds, body, undefined, hdrs);
962
+ returnData.push({ json: resp, pairedItem: { item: i } });
963
+ }
964
+ else if (operation === 'duplicate') {
965
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/${this.getNodeParameter('tiempoID', i)}/duplicar`, creds, undefined, undefined, hdrs);
966
+ returnData.push({ json: resp, pairedItem: { item: i } });
967
+ }
968
+ }
969
+ // ── KANBAN PRODUCCIÓN ───────────────────────
970
+ else if (resource === 'kanbanProd') {
971
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
972
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
973
+ const hdrs = { 'x-company': xCompany };
974
+ const base = '/api/v1/kanban';
975
+ const sub = this.getNodeParameter('subresource', i);
976
+ if (sub === 'tarjetas') {
977
+ const id = this.getNodeParameter('tarjetaID', i);
978
+ if (operation === 'planificar') {
979
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${id}/planificaciones`, creds, undefined, undefined, hdrs);
980
+ returnData.push({ json: resp, pairedItem: { item: i } });
981
+ }
982
+ else if (operation === 'replanificar') {
983
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${id}/replanificaciones`, creds, undefined, undefined, hdrs);
984
+ returnData.push({ json: resp, pairedItem: { item: i } });
985
+ }
986
+ else if (operation === 'iniciar') {
987
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${id}/inicio`, creds, undefined, undefined, hdrs);
988
+ returnData.push({ json: resp, pairedItem: { item: i } });
989
+ }
990
+ else if (operation === 'finalizar') {
991
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${id}/finalizacion`, creds, undefined, undefined, hdrs);
992
+ returnData.push({ json: resp, pairedItem: { item: i } });
993
+ }
994
+ else if (operation === 'bloquear') {
995
+ const taID = this.getNodeParameter('trabajoAsignadoID', i);
996
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${taID}/bloqueos`, creds, undefined, undefined, hdrs);
997
+ returnData.push({ json: resp, pairedItem: { item: i } });
998
+ }
999
+ else if (operation === 'desbloquear') {
1000
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${base}/tarjetas/${id}/desbloqueo-planificacion`, creds, undefined, undefined, hdrs);
1001
+ returnData.push({ json: resp, pairedItem: { item: i } });
1002
+ }
1003
+ }
1004
+ else if (sub === 'secciones') {
1005
+ const sid = this.getNodeParameter('seccionID', i, '');
1006
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/secciones${sid ? `/${sid}/empleados` : ''}`, creds, undefined, undefined, hdrs);
1007
+ returnData.push({ json: resp, pairedItem: { item: i } });
1008
+ }
1009
+ else if (sub === 'contexto') {
1010
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/contexto-usuario`, creds, undefined, undefined, hdrs);
1011
+ returnData.push({ json: resp, pairedItem: { item: i } });
1012
+ }
1013
+ else if (sub === 'tiposInterrupcion') {
1014
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/tipos-interrupcion`, creds, undefined, undefined, hdrs);
1015
+ returnData.push({ json: resp, pairedItem: { item: i } });
1016
+ }
1017
+ }
1018
+ // ── PROCESOS ────────────────────────────────
1019
+ else if (resource === 'procesos') {
1020
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1021
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1022
+ const h = { 'x-company': xc }, B = '/api/v1/procesos';
1023
+ if (operation === 'query' || operation === 'search') {
1024
+ const b = {};
1025
+ const p = n('pagina', i);
1026
+ if (p)
1027
+ b.pagina = p;
1028
+ const tp = n('tamanoPagina', i);
1029
+ if (tp)
1030
+ b.tamanoPagina = tp;
1031
+ const bu = this.getNodeParameter('busqueda', i, '');
1032
+ if (bu)
1033
+ b.busqueda = bu;
1034
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', operation === 'search' ? B + '/buscar' : B, creds, b, undefined, h);
1035
+ returnData.push({ json: r, pairedItem: { item: i } });
1036
+ }
1037
+ else if (operation === 'get') {
1038
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${this.getNodeParameter('procesoID', i)}`, creds, undefined, undefined, h);
1039
+ returnData.push({ json: r, pairedItem: { item: i } });
1040
+ }
1041
+ else if (operation === 'close') {
1042
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${this.getNodeParameter('procesoID', i)}/options/cerrar`, creds, undefined, undefined, h);
1043
+ returnData.push({ json: r, pairedItem: { item: i } });
1044
+ }
1045
+ else if (operation === 'open') {
1046
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${this.getNodeParameter('procesoID', i)}/options/abrir`, creds, undefined, undefined, h);
1047
+ returnData.push({ json: r, pairedItem: { item: i } });
1048
+ }
1049
+ }
1050
+ // ── OPERACIONES ──────────────────────────────
1051
+ else if (resource === 'operaciones') {
1052
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1053
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1054
+ const h = { 'x-company': xc }, B = '/api/v1/operaciones';
1055
+ if (operation === 'query' || operation === 'search') {
1056
+ const b = {};
1057
+ const p = n('pagina', i);
1058
+ if (p)
1059
+ b.pagina = p;
1060
+ const tp = n('tamanoPagina', i);
1061
+ if (tp)
1062
+ b.tamanoPagina = tp;
1063
+ const bu = this.getNodeParameter('busqueda', i, '');
1064
+ if (bu)
1065
+ b.busqueda = bu;
1066
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', operation === 'search' ? B + '/buscar' : B, creds, b, undefined, h);
1067
+ returnData.push({ json: r, pairedItem: { item: i } });
1068
+ }
1069
+ else if (operation === 'claves') {
1070
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/claves-precio`, creds, undefined, undefined, h);
1071
+ returnData.push({ json: r, pairedItem: { item: i } });
1072
+ }
1073
+ else if (operation === 'get') {
1074
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${this.getNodeParameter('operacionID', i)}`, creds, undefined, undefined, h);
1075
+ returnData.push({ json: r, pairedItem: { item: i } });
1076
+ }
1077
+ else if (operation === 'materiales') {
1078
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${this.getNodeParameter('operacionID', i)}/materiales`, creds, undefined, undefined, h);
1079
+ returnData.push({ json: r, pairedItem: { item: i } });
1080
+ }
1081
+ }
1082
+ // ── PROYECTOS ────────────────────────────────
1083
+ else if (resource === 'proyectos') {
1084
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1085
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1086
+ const h = { 'x-company': xc }, B = '/api/v1/proyectos';
1087
+ const pid = this.getNodeParameter('proyectoID', i);
1088
+ if (operation === 'query') {
1089
+ const b = {};
1090
+ const p = n('pagina', i);
1091
+ if (p)
1092
+ b.pagina = p;
1093
+ const tp = n('tamanoPagina', i);
1094
+ if (tp)
1095
+ b.tamanoPagina = tp;
1096
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', B, creds, b, undefined, h);
1097
+ returnData.push({ json: r, pairedItem: { item: i } });
1098
+ }
1099
+ else if (operation === 'get') {
1100
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${pid}`, creds, undefined, undefined, h);
1101
+ returnData.push({ json: r, pairedItem: { item: i } });
1102
+ }
1103
+ else if (operation === 'fases') {
1104
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${pid}/fases`, creds, undefined, undefined, h);
1105
+ returnData.push({ json: r, pairedItem: { item: i } });
1106
+ }
1107
+ else if (operation === 'close') {
1108
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${pid}/cerrar`, creds, undefined, undefined, h);
1109
+ returnData.push({ json: r, pairedItem: { item: i } });
1110
+ }
1111
+ else if (operation === 'open') {
1112
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${pid}/abrir`, creds, undefined, undefined, h);
1113
+ returnData.push({ json: r, pairedItem: { item: i } });
1114
+ }
1115
+ }
1116
+ // ── CUENTAS CRM ──────────────────────────────
1117
+ else if (resource === 'cuentas') {
1118
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1119
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1120
+ const h = { 'x-company': xc }, B = '/crm/api/v1/cuentas';
1121
+ const cid = this.getNodeParameter('cuentaID', i);
1122
+ if (operation === 'query' || operation === 'search') {
1123
+ const qs = {};
1124
+ const bu = this.getNodeParameter('busqueda', i, '');
1125
+ if (bu)
1126
+ qs.busqueda = bu;
1127
+ const p = this.getNodeParameter('pagina', i, '');
1128
+ if (p)
1129
+ qs.pagina = p;
1130
+ const tp = this.getNodeParameter('tamanoPagina', i, '');
1131
+ if (tp)
1132
+ qs.tamanoPagina = tp;
1133
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', operation === 'search' ? `${B}/buscar` : B, creds, undefined, qs, h);
1134
+ returnData.push({ json: r, pairedItem: { item: i } });
1135
+ }
1136
+ else if (operation === 'get') {
1137
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${cid}`, creds, undefined, undefined, h);
1138
+ returnData.push({ json: r, pairedItem: { item: i } });
1139
+ }
1140
+ else if (operation === 'contactos') {
1141
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${cid}/contactos`, creds, undefined, undefined, h);
1142
+ returnData.push({ json: r, pairedItem: { item: i } });
1143
+ }
1144
+ else if (operation === 'direcciones') {
1145
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${cid}/direcciones`, creds, undefined, undefined, h);
1146
+ returnData.push({ json: r, pairedItem: { item: i } });
1147
+ }
1148
+ }
1149
+ // ── CATÁLOGOS SIMPLES (monedas/iva/geografia/etc) ─
1150
+ else if (['monedas', 'iva', 'geografia', 'tiposCuenta', 'tiposMovimiento', 'tarifasVenta', 'formasPago', 'machines', 'usuarios', 'ofConsulta', 'wmsMovimientos'].includes(resource)) {
1151
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1152
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1153
+ const h = { 'x-company': xc };
1154
+ const bases = { monedas: '/api/v1/monedas', iva: '/api/v1/iva', geografia: '/api/v1', tiposCuenta: '/api/v1/tipos-cuenta', tiposMovimiento: '/api/v1/movimientos/tipos-movimiento', tarifasVenta: '/wms/api/v1/tarifas-venta', formasPago: '/api/v1/formas-pago-cobro', machines: '/api/v1/maquinas', usuarios: '/api/v1/usuarios', ofConsulta: '/mes/api/v1/of', wmsMovimientos: '/api/v1/movimientos' };
1155
+ const B = bases[resource] || '';
1156
+ const extraId = this.getNodeParameter(resource === 'machines' ? 'maquinaID' : resource === 'usuarios' ? 'usuarioID' : 'id', i, '');
1157
+ if (operation === 'query' || operation === 'continentes' || operation === 'paises' || operation === 'provincias') {
1158
+ const b = {};
1159
+ const p = n('pagina', i);
1160
+ if (p)
1161
+ b.pagina = p;
1162
+ const tp = n('tamanoPagina', i);
1163
+ if (tp)
1164
+ b.tamanoPagina = tp;
1165
+ let endpoint = B;
1166
+ if (resource === 'monedas')
1167
+ endpoint = `${B}/consulta`;
1168
+ else if (resource === 'iva')
1169
+ endpoint = `${B}/consulta`;
1170
+ else if (resource === 'geografia')
1171
+ endpoint = `${B}/${operation === 'continentes' ? 'continentes' : operation === 'paises' ? 'paises' : 'provincias'}/query`;
1172
+ else if (resource === 'tiposCuenta')
1173
+ endpoint = `${B}/consulta`;
1174
+ else if (resource === 'formasPago')
1175
+ endpoint = `${B}/consulta`;
1176
+ else if (resource === 'wmsMovimientos')
1177
+ endpoint = B;
1178
+ else if (resource === 'ofConsulta')
1179
+ endpoint = B;
1180
+ const r = resource === 'cuentas' || resource === 'machines' ? await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', endpoint, creds, b, undefined, h) : await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', endpoint, creds, b, undefined, h);
1181
+ returnData.push({ json: r, pairedItem: { item: i } });
1182
+ }
1183
+ else if (operation === 'get' && extraId) {
1184
+ let endpoint = `${B}/${extraId}`;
1185
+ if (resource === 'monedas')
1186
+ endpoint = `${B}/${extraId}`;
1187
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', endpoint, creds, undefined, undefined, h);
1188
+ returnData.push({ json: r, pairedItem: { item: i } });
1189
+ }
1190
+ else if (operation === 'totales') {
1191
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/totales`, creds, undefined, undefined, h);
1192
+ returnData.push({ json: r, pairedItem: { item: i } });
1193
+ }
1194
+ else if (operation === 'historicos' && extraId) {
1195
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${extraId}/historicos`, creds, undefined, undefined, h);
1196
+ returnData.push({ json: r, pairedItem: { item: i } });
1197
+ }
1198
+ else if (operation === 'search') {
1199
+ const b = {};
1200
+ const bu = this.getNodeParameter('busqueda', i, '');
1201
+ if (bu)
1202
+ b.busqueda = bu;
1203
+ const p = n('pagina', i);
1204
+ if (p)
1205
+ b.pagina = p;
1206
+ const tp = n('tamanoPagina', i);
1207
+ if (tp)
1208
+ b.tamanoPagina = tp;
1209
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${B}/buscar`, creds, b, undefined, h);
1210
+ returnData.push({ json: r, pairedItem: { item: i } });
1211
+ }
1212
+ }
1213
+ // ── CATÁLOGOS ──────────────────────────────
1214
+ else if (resource === 'catalogs') {
1215
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1216
+ const xCompany = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1217
+ const headers = { 'x-company': xCompany };
1218
+ const base = '/api/v1/tabla-general';
1219
+ if (operation === 'query') {
1220
+ const body = {
1221
+ clave: this.getNodeParameter('clave', i),
1222
+ };
1223
+ const pCat = n('pagina', i);
1224
+ const tpCat = n('tamanoPagina', i);
1225
+ if (pCat)
1226
+ body.pagina = pCat;
1227
+ if (tpCat)
1228
+ body.tamanoPagina = tpCat;
1229
+ const ordP = this.getNodeParameter('ordenarPor', i);
1230
+ const ordD = this.getNodeParameter('direccionOrden', i);
1231
+ if (ordP)
1232
+ body.ordenarPor = ordP;
1233
+ if (ordD)
1234
+ body.direccionOrden = ordD;
1235
+ const busqueda = this.getNodeParameter('busqueda', i, '');
1236
+ const descripcion = this.getNodeParameter('descripcion', i, '');
1237
+ const abreviatura = this.getNodeParameter('abreviatura', i, '');
1238
+ const incluirObsoletos = this.getNodeParameter('incluirObsoletos', i);
1239
+ const soloPorDefecto = this.getNodeParameter('soloPorDefecto', i);
1240
+ if (busqueda)
1241
+ body.busqueda = busqueda;
1242
+ if (descripcion)
1243
+ body.descripcion = descripcion;
1244
+ if (abreviatura)
1245
+ body.abreviatura = abreviatura;
1246
+ if (incluirObsoletos)
1247
+ body.incluirObsoletos = true;
1248
+ if (soloPorDefecto)
1249
+ body.soloPorDefecto = true;
1250
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body, undefined, headers);
1251
+ returnData.push({ json: resp, pairedItem: { item: i } });
1252
+ }
1253
+ else if (operation === 'get') {
1254
+ const id = this.getNodeParameter('tablaGeneralID', i);
1255
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${id}`, creds, undefined, undefined, headers);
1256
+ returnData.push({ json: resp, pairedItem: { item: i } });
1257
+ }
1258
+ else if (operation === 'create') {
1259
+ const body = {
1260
+ clave: this.getNodeParameter('claveCreate', i),
1261
+ descripcion: this.getNodeParameter('descripcionCreate', i),
1262
+ abreviatura: this.getNodeParameter('abreviaturaCreate', i),
1263
+ };
1264
+ const notas = this.getNodeParameter('notasCreate', i, '');
1265
+ const defecto = this.getNodeParameter('defectoCreate', i);
1266
+ if (notas)
1267
+ body.notas = notas;
1268
+ if (defecto)
1269
+ body.defecto = true;
1270
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body, undefined, headers);
1271
+ returnData.push({ json: resp, pairedItem: { item: i } });
1272
+ }
1273
+ else if (operation === 'update') {
1274
+ const id = this.getNodeParameter('tablaGeneralID', i);
1275
+ const body = this.getNodeParameter('updateFields', i);
1276
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${id}`, creds, body, undefined, headers);
1277
+ returnData.push({ json: resp, pairedItem: { item: i } });
1278
+ }
1279
+ else if (operation === 'delete') {
1280
+ const id = this.getNodeParameter('tablaGeneralID', i);
1281
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${base}/${id}`, creds, undefined, undefined, headers);
1282
+ returnData.push({ json: { success: true, tablaGeneralID: id }, pairedItem: { item: i } });
1283
+ }
1284
+ }
1285
+ // ── GESTIÓN DOCUMENTAL (GD) ─────────────────
1286
+ else if (resource === 'gd') {
1287
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1288
+ const subresource = this.getNodeParameter('subresource', i);
1289
+ const baseGD = '/gd/api/v1';
1290
+ if (subresource === 'carpetas') {
1291
+ if (operation === 'create') {
1292
+ const body = { nombre: this.getNodeParameter('carpetaNombre', i) };
1293
+ const padre = this.getNodeParameter('carpetaPadreID', i, '');
1294
+ if (padre)
1295
+ body.carpetaPadreID = padre;
1296
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${baseGD}/carpetas`, creds, body);
1297
+ returnData.push({ json: resp, pairedItem: { item: i } });
1298
+ }
1299
+ else if (operation === 'update') {
1300
+ const id = this.getNodeParameter('carpetaID', i);
1301
+ const body = this.getNodeParameter('carpetaUpdateFields', i);
1302
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/carpetas/${id}`, creds, body);
1303
+ returnData.push({ json: resp, pairedItem: { item: i } });
1304
+ }
1305
+ else if (operation === 'delete') {
1306
+ const id = this.getNodeParameter('carpetaID', i);
1307
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${baseGD}/carpetas/${id}`, creds);
1308
+ returnData.push({ json: { success: true, carpetaID: id }, pairedItem: { item: i } });
1309
+ }
1310
+ else if (operation === 'updatePermisos') {
1311
+ const id = this.getNodeParameter('carpetaID', i);
1312
+ const ids = this.getNodeParameter('permisosUsuarioIDs', i).split(',').map(Number).filter((n) => n > 0);
1313
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/carpetas/${id}/permisos`, creds, { usuarioIDs: ids });
1314
+ returnData.push({ json: resp, pairedItem: { item: i } });
1315
+ }
1316
+ else if (operation === 'move') {
1317
+ const id = this.getNodeParameter('carpetaID', i);
1318
+ const nueva = this.getNodeParameter('nuevaCarpetaPadreID', i);
1319
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/carpetas/${id}/carpeta-padre`, creds, { carpetaPadreID: nueva });
1320
+ returnData.push({ json: resp, pairedItem: { item: i } });
1321
+ }
1322
+ }
1323
+ else if (subresource === 'documentos') {
1324
+ if (operation === 'upload') {
1325
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1326
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
1327
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1328
+ const fileName = this.getNodeParameter('uploadFileName', i, '') || binaryData.fileName || 'file.bin';
1329
+ const carpetaID = this.getNodeParameter('uploadCarpetaID', i, '');
1330
+ const resp = await GenericFunctions_1.netvyApiRequestUpload.call(this, `${baseGD}/documentos`, creds, buffer, fileName, 'file', carpetaID ? { carpetaGestionDocumentalID: carpetaID } : undefined);
1331
+ returnData.push({ json: resp, pairedItem: { item: i } });
1332
+ }
1333
+ else if (operation === 'download') {
1334
+ const id = this.getNodeParameter('documentoID', i);
1335
+ const { data, headers: respHeaders } = await GenericFunctions_1.netvyApiRequestBinary.call(this, 'GET', `${baseGD}/documentos/${id}/archivo`, creds);
1336
+ let dlName = `documento_${id}`;
1337
+ const disp = respHeaders['content-disposition'];
1338
+ if (disp?.includes('filename=')) {
1339
+ const m = disp.match(/filename="?([^"]+)"?/);
1340
+ if (m?.[1])
1341
+ dlName = m[1];
1342
+ }
1343
+ const binary = await this.helpers.prepareBinaryData(data, dlName, respHeaders['content-type']);
1344
+ returnData.push({ json: { success: true, fileName: dlName }, binary: { data: binary }, pairedItem: { item: i } });
1345
+ }
1346
+ else if (operation === 'update') {
1347
+ const id = this.getNodeParameter('documentoID', i);
1348
+ const body = this.getNodeParameter('documentoUpdateFields', i);
1349
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/documentos/${id}`, creds, body);
1350
+ returnData.push({ json: resp, pairedItem: { item: i } });
1351
+ }
1352
+ else if (operation === 'move') {
1353
+ const id = this.getNodeParameter('documentoID', i);
1354
+ const nueva = this.getNodeParameter('nuevaCarpetaID', i);
1355
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/documentos/${id}/carpeta`, creds, { carpetaGestionDocumentalID: nueva });
1356
+ returnData.push({ json: resp, pairedItem: { item: i } });
1357
+ }
1358
+ else if (operation === 'updatePermisos') {
1359
+ const id = this.getNodeParameter('documentoID', i);
1360
+ const ids = this.getNodeParameter('permisosUsuarioIDs', i).split(',').map(Number).filter((n) => n > 0);
1361
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${baseGD}/documentos/${id}/permisos`, creds, { usuarioIDs: ids });
1362
+ returnData.push({ json: resp, pairedItem: { item: i } });
1363
+ }
1364
+ else if (operation === 'unlink') {
1365
+ const docId = this.getNodeParameter('documentoUnlinkID', i);
1366
+ const relId = this.getNodeParameter('relacionID', i);
1367
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${baseGD}/documentos/${docId}/relaciones/${relId}`, creds);
1368
+ returnData.push({ json: { success: true, documentoID: docId, relacionID: relId }, pairedItem: { item: i } });
1369
+ }
1370
+ }
1371
+ else if (subresource === 'archivosTemporales') {
1372
+ const hexaID = this.getNodeParameter('documentoHexaID', i);
1373
+ if (operation === 'downloadTemp') {
1374
+ const { data, headers: respHeaders } = await GenericFunctions_1.netvyApiRequestBinary.call(this, 'GET', `${baseGD}/archivos-temporales/${hexaID}`, creds);
1375
+ let dlName = hexaID;
1376
+ const disp = respHeaders['content-disposition'];
1377
+ if (disp?.includes('filename=')) {
1378
+ const m = disp.match(/filename="?([^"]+)"?/);
1379
+ if (m?.[1])
1380
+ dlName = m[1];
1381
+ }
1382
+ const binary = await this.helpers.prepareBinaryData(data, dlName, respHeaders['content-type']);
1383
+ returnData.push({ json: { success: true, fileName: dlName }, binary: { data: binary }, pairedItem: { item: i } });
1384
+ }
1385
+ else if (operation === 'deleteTemp') {
1386
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${baseGD}/archivos-temporales/${hexaID}`, creds);
1387
+ returnData.push({ json: { success: true, documentoHexaID: hexaID }, pairedItem: { item: i } });
1388
+ }
1389
+ }
1390
+ else if (subresource === 'favoritos') {
1391
+ if (operation === 'toggle') {
1392
+ const body = {
1393
+ elementoID: this.getNodeParameter('elementoID', i),
1394
+ tipo: this.getNodeParameter('elementoTipo', i),
1395
+ };
1396
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${baseGD}/favoritos`, creds, body);
1397
+ returnData.push({ json: resp, pairedItem: { item: i } });
1398
+ }
1399
+ else if (operation === 'deleteFav') {
1400
+ const id = this.getNodeParameter('favoritoID', i);
1401
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${baseGD}/favoritos/${id}`, creds);
1402
+ returnData.push({ json: { success: true, favoritoID: id }, pairedItem: { item: i } });
1403
+ }
1404
+ }
1405
+ else if (subresource === 'contenido') {
1406
+ const body = {};
1407
+ const pc = n('paginaContenido', i);
1408
+ const tc = n('tamanoPaginaContenido', i);
1409
+ if (pc)
1410
+ body.pagina = pc;
1411
+ if (tc)
1412
+ body.tamanoPagina = tc;
1413
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${baseGD}/contenido`, creds, body);
1414
+ returnData.push({ json: resp, pairedItem: { item: i } });
1415
+ }
1416
+ else if (subresource === 'extensiones') {
1417
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${baseGD}/extensiones`, creds, {});
1418
+ returnData.push({ json: resp, pairedItem: { item: i } });
1419
+ }
1420
+ else if (subresource === 'solicitudes') {
1421
+ const hexaID = this.getNodeParameter('documentoHexaID', i);
1422
+ const binaryPropertyName = this.getNodeParameter('solicitudBinaryPropertyName', i);
1423
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
1424
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1425
+ const fileName = binaryData.fileName || 'solicitud.bin';
1426
+ await GenericFunctions_1.netvyApiRequestUpload.call(this, `${baseGD}/solicitudes/${hexaID}/archivo`, creds, buffer, fileName, 'archivo');
1427
+ returnData.push({ json: { success: true, documentoHexaID: hexaID, fileName }, pairedItem: { item: i } });
1428
+ }
1429
+ else if (subresource === 'url') {
1430
+ const body = {
1431
+ url: this.getNodeParameter('urlDocumento', i),
1432
+ nombre: this.getNodeParameter('urlNombre', i),
1433
+ };
1434
+ const carpetaID = this.getNodeParameter('urlCarpetaID', i, '');
1435
+ if (carpetaID)
1436
+ body.carpetaGestionDocumentalID = carpetaID;
1437
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${baseGD}/url`, creds, body);
1438
+ returnData.push({ json: resp, pairedItem: { item: i } });
1439
+ }
1440
+ else if (subresource === 'emailsAdjuntos') {
1441
+ if (operation === 'create') {
1442
+ const binaryPropertyName = this.getNodeParameter('adjuntoBinaryPropertyName', i);
1443
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
1444
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1445
+ const fileName = binaryData.fileName || 'adjunto.bin';
1446
+ const resp = await GenericFunctions_1.netvyApiRequestUpload.call(this, `${baseGD}/emails-adjuntos`, creds, buffer, fileName, 'file');
1447
+ returnData.push({ json: resp, pairedItem: { item: i } });
1448
+ }
1449
+ else if (operation === 'download') {
1450
+ const adjuntoID = this.getNodeParameter('adjuntoID', i);
1451
+ const { data, headers: respHeaders } = await GenericFunctions_1.netvyApiRequestBinary.call(this, 'GET', `${baseGD}/emails-adjuntos/${adjuntoID}/archivo`, creds);
1452
+ let dlName = `adjunto_${adjuntoID}`;
1453
+ const disp = respHeaders['content-disposition'];
1454
+ if (disp?.includes('filename=')) {
1455
+ const m = disp.match(/filename="?([^"]+)"?/);
1456
+ if (m?.[1])
1457
+ dlName = m[1];
1458
+ }
1459
+ const binary = await this.helpers.prepareBinaryData(data, dlName, respHeaders['content-type']);
1460
+ returnData.push({ json: { success: true, fileName: dlName }, binary: { data: binary }, pairedItem: { item: i } });
1461
+ }
1462
+ }
1463
+ }
1464
+ // ── NOTAS (GD) ──────────────────────────────
1465
+ else if (resource === 'notas') {
1466
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1467
+ const base = '/gd/api/v1/notas';
1468
+ if (operation === 'query') {
1469
+ const body = {};
1470
+ const pN = n('pagina', i);
1471
+ const tpN = n('tamanoPagina', i);
1472
+ if (pN)
1473
+ body.pagina = pN;
1474
+ if (tpN)
1475
+ body.tamanoPagina = tpN;
1476
+ const filters = this.getNodeParameter('queryFilters', i);
1477
+ if (filters.asunto)
1478
+ body.asunto = filters.asunto;
1479
+ if (filters.contenido)
1480
+ body.contenido = filters.contenido;
1481
+ if (filters.leido)
1482
+ body.leido = Number(filters.leido);
1483
+ if (filters.fechaDesde)
1484
+ body.fechaDesde = filters.fechaDesde;
1485
+ if (filters.fechaHasta)
1486
+ body.fechaHasta = filters.fechaHasta;
1487
+ if (filters.tipoNotaID)
1488
+ body.tipoNotaID = filters.tipoNotaID;
1489
+ if (filters.mailingID)
1490
+ body.mailingID = filters.mailingID;
1491
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', base, creds, body);
1492
+ returnData.push({ json: resp, pairedItem: { item: i } });
1493
+ }
1494
+ else if (operation === 'get') {
1495
+ const id = n('notaID', i);
1496
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${base}/${id}`, creds);
1497
+ returnData.push({ json: resp, pairedItem: { item: i } });
1498
+ }
1499
+ else if (operation === 'create') {
1500
+ const body = { asunto: this.getNodeParameter('asuntoCreate', i) };
1501
+ const contenido = this.getNodeParameter('contenidoCreate', i, '');
1502
+ const destStr = this.getNodeParameter('destinatariosCreate', i, '');
1503
+ const tipoNotaID = n('tipoNotaIDCreate', i);
1504
+ const mailingID = n('mailingIDCreate', i);
1505
+ const requiereRespuesta = this.getNodeParameter('requiereRespuestaCreate', i);
1506
+ const tablaPadre = this.getNodeParameter('tablaPadreCreate', i, '');
1507
+ const tablaPadreID = n('tablaPadreIDCreate', i);
1508
+ if (contenido)
1509
+ body.contenido = contenido;
1510
+ if (destStr)
1511
+ body.destinatarioUsuarioIDs = destStr.split(',').map(Number).filter((n) => n > 0);
1512
+ if (tipoNotaID)
1513
+ body.tipoNotaID = tipoNotaID;
1514
+ if (mailingID)
1515
+ body.mailingID = mailingID;
1516
+ if (requiereRespuesta)
1517
+ body.requiereRespuesta = true;
1518
+ if (tablaPadre) {
1519
+ body.tablaPadre = tablaPadre;
1520
+ if (tablaPadreID)
1521
+ body.tablaPadreID = tablaPadreID;
1522
+ }
1523
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', base, creds, body);
1524
+ returnData.push({ json: resp, pairedItem: { item: i } });
1525
+ }
1526
+ else if (operation === 'update') {
1527
+ const id = n('notaID', i);
1528
+ const fields = this.getNodeParameter('updateFields', i);
1529
+ const body = {};
1530
+ if (fields.asunto)
1531
+ body.asunto = fields.asunto;
1532
+ if (fields.contenido)
1533
+ body.contenido = fields.contenido;
1534
+ if (fields.destinatarios)
1535
+ body.destinatarioUsuarioIDs = fields.destinatarios.split(',').map(Number).filter((n) => n > 0);
1536
+ if (fields.tipoNotaID)
1537
+ body.tipoNotaID = fields.tipoNotaID;
1538
+ if (fields.mailingID)
1539
+ body.mailingID = fields.mailingID;
1540
+ if (fields.requiereRespuesta !== undefined)
1541
+ body.requiereRespuesta = fields.requiereRespuesta;
1542
+ const resp = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${id}`, creds, body);
1543
+ returnData.push({ json: resp, pairedItem: { item: i } });
1544
+ }
1545
+ else if (operation === 'delete') {
1546
+ const id = n('notaID', i);
1547
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${base}/${id}`, creds);
1548
+ returnData.push({ json: { success: true, notaID: id }, pairedItem: { item: i } });
1549
+ }
1550
+ else if (operation === 'markRead') {
1551
+ const id = n('notaID', i);
1552
+ await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${base}/${id}/lectura`, creds);
1553
+ returnData.push({ json: { success: true, notaID: id }, pairedItem: { item: i } });
1554
+ }
1555
+ }
1556
+ // ── CUENTAS CONTABLES ────────────────────
1557
+ else if (resource === 'cuentasContables') {
1558
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1559
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1560
+ const h = { 'x-company': xc }, B = '/contabilidad/api/v1/cuentas-contables';
1561
+ if (operation === 'query') {
1562
+ const b = {};
1563
+ const p = n('pagina', i);
1564
+ if (p)
1565
+ b.pagina = p;
1566
+ const tp = n('tamanoPagina', i);
1567
+ if (tp)
1568
+ b.tamanoPagina = tp;
1569
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', B, creds, b, undefined, h);
1570
+ returnData.push({ json: r, pairedItem: { item: i } });
1571
+ }
1572
+ else if (operation === 'get') {
1573
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${this.getNodeParameter('id', i)}`, creds, undefined, undefined, h);
1574
+ returnData.push({ json: r, pairedItem: { item: i } });
1575
+ }
1576
+ else if (operation === 'validar') {
1577
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${B}/internal/cuentas-contables/validar`, creds, {}, undefined, h);
1578
+ returnData.push({ json: r, pairedItem: { item: i } });
1579
+ }
1580
+ }
1581
+ // ── PROVEEDORES INTERNAL ──────────────────
1582
+ else if (resource === 'proveedoresInternal') {
1583
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1584
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1585
+ const h = { 'x-company': xc };
1586
+ const b = {};
1587
+ const q = this.getNodeParameter('busqueda', i, '');
1588
+ if (q)
1589
+ b.q = q;
1590
+ const p = n('pagina', i);
1591
+ if (p)
1592
+ b.pagina = p;
1593
+ const tp = n('tamanoPagina', i);
1594
+ if (tp)
1595
+ b.tamanoPagina = tp;
1596
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/crm/api/v1/internal/proveedores/buscar', creds, b, undefined, h);
1597
+ returnData.push({ json: r, pairedItem: { item: i } });
1598
+ }
1599
+ // ── RECEPCIONES ────────────────────────────
1600
+ else if (resource === 'recepciones') {
1601
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1602
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1603
+ const h = { 'x-company': xc }, B = '/compras/api/v1/recepciones';
1604
+ if (operation === 'query') {
1605
+ const b = {};
1606
+ b.modo = this.getNodeParameter('modo', i, 'cabecera');
1607
+ const p = n('pagina', i);
1608
+ if (p)
1609
+ b.pagina = p;
1610
+ const tp = n('tamanoPagina', i);
1611
+ if (tp)
1612
+ b.tamanoPagina = tp;
1613
+ const bu = this.getNodeParameter('busqueda', i, '');
1614
+ if (bu)
1615
+ b.busqueda = bu;
1616
+ const op = this.getNodeParameter('ordenarPor', i, '');
1617
+ if (op)
1618
+ b.ordenarPor = op;
1619
+ const dd = this.getNodeParameter('direccionOrden', i, 'asc');
1620
+ if (dd)
1621
+ b.direccionOrden = dd;
1622
+ const fd = this.getNodeParameter('fechaDesde', i, '');
1623
+ if (fd)
1624
+ b.fechaDesde = fd;
1625
+ const fh = this.getNodeParameter('fechaHasta', i, '');
1626
+ if (fh)
1627
+ b.fechaHasta = fh;
1628
+ const pv = n('proveedorID', i);
1629
+ if (pv)
1630
+ b.proveedorID = pv;
1631
+ const ai = n('articuloID', i);
1632
+ if (ai)
1633
+ b.articuloID = ai;
1634
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', B, creds, b, undefined, h);
1635
+ returnData.push({ json: r, pairedItem: { item: i } });
1636
+ }
1637
+ else if (operation === 'lineas') {
1638
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${this.getNodeParameter('albaranCompraCabeceraID', i)}/lineas`, creds, undefined, undefined, h);
1639
+ returnData.push({ json: r, pairedItem: { item: i } });
1640
+ }
1641
+ }
1642
+ // ── EVENTOS ────────────────────────────────
1643
+ else if (resource === 'eventos') {
1644
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1645
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1646
+ const h = { 'x-company': xc }, B = '/gd/api/v1/eventos';
1647
+ const eid = this.getNodeParameter('eventoID', i);
1648
+ if (operation === 'create') {
1649
+ const body = {};
1650
+ const te = n('tipoEventoID', i);
1651
+ if (te)
1652
+ body.tipoEventoID = te;
1653
+ const ee = n('estadoEventoID', i);
1654
+ if (ee)
1655
+ body.estadoEventoID = ee;
1656
+ const ti = this.getNodeParameter('titulo', i, '');
1657
+ if (ti)
1658
+ body.titulo = ti;
1659
+ const de = this.getNodeParameter('descripcion', i, '');
1660
+ if (de)
1661
+ body.descripcion = de;
1662
+ const fi = this.getNodeParameter('fechaInicio', i, '');
1663
+ if (fi)
1664
+ body.fechaInicio = fi;
1665
+ const ff = this.getNodeParameter('fechaFin', i, '');
1666
+ if (ff)
1667
+ body.fechaFin = ff;
1668
+ body.diaCompleto = this.getNodeParameter('diaCompleto', i);
1669
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', B, creds, body, undefined, h);
1670
+ returnData.push({ json: r, pairedItem: { item: i } });
1671
+ }
1672
+ else if (operation === 'get') {
1673
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${eid}`, creds, undefined, undefined, h);
1674
+ returnData.push({ json: r, pairedItem: { item: i } });
1675
+ }
1676
+ else if (operation === 'update') {
1677
+ const body = {};
1678
+ const te = n('tipoEventoID', i);
1679
+ if (te)
1680
+ body.tipoEventoID = te;
1681
+ const ee = n('estadoEventoID', i);
1682
+ if (ee)
1683
+ body.estadoEventoID = ee;
1684
+ const ti = this.getNodeParameter('titulo', i, '');
1685
+ if (ti)
1686
+ body.titulo = ti;
1687
+ const de = this.getNodeParameter('descripcion', i, '');
1688
+ if (de)
1689
+ body.descripcion = de;
1690
+ const fi = this.getNodeParameter('fechaInicio', i, '');
1691
+ if (fi)
1692
+ body.fechaInicio = fi;
1693
+ const ff = this.getNodeParameter('fechaFin', i, '');
1694
+ if (ff)
1695
+ body.fechaFin = ff;
1696
+ body.diaCompleto = this.getNodeParameter('diaCompleto', i);
1697
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${B}/${eid}`, creds, body, undefined, h);
1698
+ returnData.push({ json: r, pairedItem: { item: i } });
1699
+ }
1700
+ else if (operation === 'delete') {
1701
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${B}/${eid}`, creds);
1702
+ returnData.push({ json: { success: true, eventoID: eid }, pairedItem: { item: i } });
1703
+ }
1704
+ else if (operation === 'abandon') {
1705
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${eid}/abandono`, creds, undefined, undefined, h);
1706
+ returnData.push({ json: r, pairedItem: { item: i } });
1707
+ }
1708
+ else if (operation === 'tipos') {
1709
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${B}/catalogos/tipos`, creds, {}, undefined, h);
1710
+ returnData.push({ json: r, pairedItem: { item: i } });
1711
+ }
1712
+ else if (operation === 'estados') {
1713
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${B}/catalogos/estados`, creds, {}, undefined, h);
1714
+ returnData.push({ json: r, pairedItem: { item: i } });
1715
+ }
1716
+ else if (operation === 'buscar') {
1717
+ const b = {};
1718
+ const q = this.getNodeParameter('busqueda', i, '');
1719
+ if (q)
1720
+ b.busqueda = q;
1721
+ const p = n('pagina', i);
1722
+ if (p)
1723
+ b.pagina = p;
1724
+ const tp = n('tamanoPagina', i);
1725
+ if (tp)
1726
+ b.tamanoPagina = tp;
1727
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', `${B}/buscar`, creds, b, undefined, h);
1728
+ returnData.push({ json: r, pairedItem: { item: i } });
1729
+ }
1730
+ }
1731
+ // ── IMPUTACIONES ───────────────────────────
1732
+ else if (resource === 'imputaciones') {
1733
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1734
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1735
+ const h = { 'x-company': xc }, B = '/mes/api/v1/imputaciones';
1736
+ const ttid = this.getNodeParameter('tiempoTrabajoID', i);
1737
+ if (operation === 'create') {
1738
+ const body = {
1739
+ empleadoID: n('empleadoID', i),
1740
+ fechaImputacion: this.getNodeParameter('fechaImputacion', i),
1741
+ inicio: this.getNodeParameter('inicio', i),
1742
+ ['final']: this.getNodeParameter('final', i),
1743
+ claveTrabajo: this.getNodeParameter('claveTrabajo', i),
1744
+ tipoHoraGrupoPrecioHoraID: n('tipoHoraGrupoPrecioHoraID', i),
1745
+ proyectoOFID: n('proyectoOFID', i),
1746
+ procesoID: n('procesoID', i),
1747
+ };
1748
+ const mi = n('maquinaID', i);
1749
+ if (mi)
1750
+ body.maquinaID = mi;
1751
+ const cf = n('cantidadFabricada', i);
1752
+ if (cf)
1753
+ body.cantidadFabricada = cf;
1754
+ const cr = n('cantidadRechazada', i);
1755
+ if (cr)
1756
+ body.cantidadRechazada = cr;
1757
+ const fo = n('factorOperario', i);
1758
+ if (fo)
1759
+ body.factorOperario = fo;
1760
+ const fm = n('factorMaquina', i);
1761
+ if (fm)
1762
+ body.factorMaquina = fm;
1763
+ const tt = n('tipoTurnoID', i);
1764
+ if (tt)
1765
+ body.tipoTurnoID = tt;
1766
+ const ti = n('tipoInterrupcionID', i);
1767
+ if (ti)
1768
+ body.tipoInterrupcionID = ti;
1769
+ const tr = n('tipoRechazoID', i);
1770
+ if (tr)
1771
+ body.tipoRechazoID = tr;
1772
+ const nt = this.getNodeParameter('notas', i, '');
1773
+ if (nt)
1774
+ body.notas = nt;
1775
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', B, creds, body, undefined, h);
1776
+ returnData.push({ json: r, pairedItem: { item: i } });
1777
+ }
1778
+ else if (operation === 'query') {
1779
+ const b = {};
1780
+ const p = n('pagina', i);
1781
+ if (p)
1782
+ b.pagina = p;
1783
+ const tp = n('tamanoPagina', i);
1784
+ if (tp)
1785
+ b.tamanoPagina = tp;
1786
+ const u = n('queryUsuarioID', i);
1787
+ if (u)
1788
+ b.usuarioID = u;
1789
+ const e = n('queryEmpleadoID', i);
1790
+ if (e)
1791
+ b.empleadoID = e;
1792
+ const f = this.getNodeParameter('queryFechaImputacion', i, '');
1793
+ if (f)
1794
+ b.fechaImputacion = f;
1795
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', B, creds, b, undefined, h);
1796
+ returnData.push({ json: r, pairedItem: { item: i } });
1797
+ }
1798
+ else if (operation === 'get') {
1799
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${ttid}`, creds, undefined, undefined, h);
1800
+ returnData.push({ json: r, pairedItem: { item: i } });
1801
+ }
1802
+ else if (operation === 'update') {
1803
+ const body = {};
1804
+ const cf = n('cantidadFabricada', i);
1805
+ if (cf)
1806
+ body.cantidadFabricada = cf;
1807
+ const cr = n('cantidadRechazada', i);
1808
+ if (cr)
1809
+ body.cantidadRechazada = cr;
1810
+ const fo = n('factorOperario', i);
1811
+ if (fo)
1812
+ body.factorOperario = fo;
1813
+ const fm = n('factorMaquina', i);
1814
+ if (fm)
1815
+ body.factorMaquina = fm;
1816
+ const mi = n('maquinaID', i);
1817
+ if (mi)
1818
+ body.maquinaID = mi;
1819
+ const tp = n('tipoHoraGrupoPrecioHoraID', i);
1820
+ if (tp)
1821
+ body.tipoHoraGrupoPrecioHoraID = tp;
1822
+ const ti = n('tipoInterrupcionID', i);
1823
+ if (ti)
1824
+ body.tipoInterrupcionID = ti;
1825
+ const tt = n('tipoTurnoID', i);
1826
+ if (tt)
1827
+ body.tipoTurnoID = tt;
1828
+ const nt = this.getNodeParameter('notas', i, '');
1829
+ if (nt)
1830
+ body.notas = nt;
1831
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${B}/${ttid}`, creds, body, undefined, h);
1832
+ returnData.push({ json: r, pairedItem: { item: i } });
1833
+ }
1834
+ else if (operation === 'delete') {
1835
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${B}/${ttid}`, creds);
1836
+ returnData.push({ json: { success: true, tiempoTrabajoID: ttid }, pairedItem: { item: i } });
1837
+ }
1838
+ else if (operation === 'validarMCP') {
1839
+ const body = {};
1840
+ const em = n('valEmpleadoID', i);
1841
+ if (em)
1842
+ body.empleadoID = em;
1843
+ const fi = this.getNodeParameter('valFechaImputacion', i, '');
1844
+ if (fi)
1845
+ body.fechaImputacion = fi;
1846
+ const ini = this.getNodeParameter('valInicio', i, '');
1847
+ if (ini)
1848
+ body.inicio = ini;
1849
+ const fin = this.getNodeParameter('valFinal', i, '');
1850
+ if (fin)
1851
+ body.final = fin;
1852
+ const ct = this.getNodeParameter('valClaveTrabajo', i, '');
1853
+ if (ct)
1854
+ body.claveTrabajo = ct;
1855
+ const th = n('valTipoHoraGrupoPrecioHoraID', i);
1856
+ if (th)
1857
+ body.tipoHoraGrupoPrecioHoraID = th;
1858
+ const pf = n('valProyectoOFID', i);
1859
+ if (pf)
1860
+ body.proyectoOFID = pf;
1861
+ const pr = n('valProcesoID', i);
1862
+ if (pr)
1863
+ body.procesoID = pr;
1864
+ const mi = n('maquinaID', i);
1865
+ if (mi)
1866
+ body.maquinaID = mi;
1867
+ const tt = n('tipoTurnoID', i);
1868
+ if (tt)
1869
+ body.tipoTurnoID = tt;
1870
+ const ti = n('tipoInterrupcionID', i);
1871
+ if (ti)
1872
+ body.tipoInterrupcionID = ti;
1873
+ const nt = this.getNodeParameter('notas', i, '');
1874
+ if (nt)
1875
+ body.notas = nt;
1876
+ const fo = n('factorOperario', i);
1877
+ if (fo)
1878
+ body.factorOperario = fo;
1879
+ const fm = n('factorMaquina', i);
1880
+ if (fm)
1881
+ body.factorMaquina = fm;
1882
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/validarMCP`, creds, body, undefined, h);
1883
+ returnData.push({ json: r, pairedItem: { item: i } });
1884
+ }
1885
+ else if (operation === 'rechazos') {
1886
+ const b = {};
1887
+ const p = n('pagina', i);
1888
+ if (p)
1889
+ b.pagina = p;
1890
+ const tp = n('tamanoPagina', i);
1891
+ if (tp)
1892
+ b.tamanoPagina = tp;
1893
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${ttid}/rechazos`, creds, undefined, b, h);
1894
+ returnData.push({ json: r, pairedItem: { item: i } });
1895
+ }
1896
+ }
1897
+ // ── SINCRONIZADOR DB ────────────────────────
1898
+ else if (resource === 'sincronizadorDb') {
1899
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1900
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1901
+ const h = { 'x-company': xc };
1902
+ const B = '/common/api/v1/sincronizador-db';
1903
+ if (operation === 'exportar') {
1904
+ const body = { sistema: this.getNodeParameter('sistema', i) };
1905
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/exportar`, creds, body, undefined, h);
1906
+ returnData.push({ json: r, pairedItem: { item: i } });
1907
+ }
1908
+ else if (operation === 'reparar') {
1909
+ const body = { sistema: this.getNodeParameter('sistema', i) };
1910
+ const idemKey = this.getNodeParameter('idempotencyKey', i);
1911
+ const hdrs = { ...h, 'Idempotency-Key': idemKey };
1912
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/reparar`, creds, body, undefined, hdrs);
1913
+ returnData.push({ json: r, pairedItem: { item: i } });
1914
+ }
1915
+ else if (operation === 'exportarEsquemas') {
1916
+ const body = { sistema: this.getNodeParameter('sistema', i) };
1917
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/exportar-esquemas`, creds, body, undefined, h);
1918
+ returnData.push({ json: r, pairedItem: { item: i } });
1919
+ }
1920
+ }
1921
+ // ── VARIABLES PÚBLICAS ─────────────────────
1922
+ else if (resource === 'variablesPublicas') {
1923
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1924
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1925
+ const h = { 'x-company': xc }, B = '/variables-publicas';
1926
+ const pid = this.getNodeParameter('parametrizacionID', i);
1927
+ if (operation === 'create') {
1928
+ const body = { codigo: this.getNodeParameter('codigo', i) };
1929
+ const de = this.getNodeParameter('descripcion', i, '');
1930
+ if (de)
1931
+ body.descripcion = de;
1932
+ const vi = this.getNodeParameter('valorInicial', i, '');
1933
+ if (vi)
1934
+ body.valorInicial = vi;
1935
+ const ap = this.getNodeParameter('apartado', i, '');
1936
+ if (ap)
1937
+ body.apartado = ap;
1938
+ const pv = this.getNodeParameter('posiblesValores', i, '');
1939
+ if (pv)
1940
+ body.posiblesValores = pv;
1941
+ const nt = this.getNodeParameter('notas', i, '');
1942
+ if (nt)
1943
+ body.notas = nt;
1944
+ const sc = this.getNodeParameter('script', i, '');
1945
+ if (sc)
1946
+ body.script = sc;
1947
+ const vc = this.getNodeParameter('valorCustomer', i, '');
1948
+ if (vc)
1949
+ body.valorCustomer = vc;
1950
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', B, creds, body, undefined, h);
1951
+ returnData.push({ json: r, pairedItem: { item: i } });
1952
+ }
1953
+ else if (operation === 'query') {
1954
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', B, creds, {}, undefined, h);
1955
+ returnData.push({ json: r, pairedItem: { item: i } });
1956
+ }
1957
+ else if (operation === 'get') {
1958
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${pid}`, creds, undefined, undefined, h);
1959
+ returnData.push({ json: r, pairedItem: { item: i } });
1960
+ }
1961
+ else if (operation === 'update') {
1962
+ const body = {};
1963
+ const de = this.getNodeParameter('descripcion', i, '');
1964
+ if (de)
1965
+ body.descripcion = de;
1966
+ const vi = this.getNodeParameter('valorInicial', i, '');
1967
+ if (vi)
1968
+ body.valorInicial = vi;
1969
+ const ap = this.getNodeParameter('apartado', i, '');
1970
+ if (ap)
1971
+ body.apartado = ap;
1972
+ const pv = this.getNodeParameter('posiblesValores', i, '');
1973
+ if (pv)
1974
+ body.posiblesValores = pv;
1975
+ const nt = this.getNodeParameter('notas', i, '');
1976
+ if (nt)
1977
+ body.notas = nt;
1978
+ const sc = this.getNodeParameter('script', i, '');
1979
+ if (sc)
1980
+ body.script = sc;
1981
+ const vc = this.getNodeParameter('valorCustomer', i, '');
1982
+ if (vc)
1983
+ body.valorCustomer = vc;
1984
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${B}/${pid}`, creds, body, undefined, h);
1985
+ returnData.push({ json: r, pairedItem: { item: i } });
1986
+ }
1987
+ else if (operation === 'delete') {
1988
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${B}/${pid}`, creds);
1989
+ returnData.push({ json: { success: true, parametrizacionID: pid }, pairedItem: { item: i } });
1990
+ }
1991
+ }
1992
+ // ── WEBHOOKS ────────────────────────────────
1993
+ else if (resource === 'webhooks') {
1994
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
1995
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
1996
+ const h = { 'x-company': xc }, B = '/webhooks';
1997
+ const wid = this.getNodeParameter('webhookID', i);
1998
+ if (operation === 'list') {
1999
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', B, creds, undefined, undefined, h);
2000
+ returnData.push({ json: r, pairedItem: { item: i } });
2001
+ }
2002
+ else if (operation === 'create') {
2003
+ const body = {
2004
+ url: this.getNodeParameter('url', i),
2005
+ name: this.getNodeParameter('name', i),
2006
+ eventTypeCode: this.getNodeParameter('eventTypeCode', i),
2007
+ };
2008
+ const de = this.getNodeParameter('description', i, '');
2009
+ if (de)
2010
+ body.description = de;
2011
+ const mt = this.getNodeParameter('method', i, 'POST');
2012
+ if (mt && mt !== 'POST')
2013
+ body.method = mt;
2014
+ const mr = n('maxRetries', i);
2015
+ if (mr)
2016
+ body.maxRetries = mr;
2017
+ const to = n('timeOut', i);
2018
+ if (to)
2019
+ body.timeOut = to;
2020
+ const se = this.getNodeParameter('isSecretEnabled', i);
2021
+ if (se)
2022
+ body.isSecretEnabled = true;
2023
+ const sc = this.getNodeParameter('secret', i, '');
2024
+ if (sc)
2025
+ body.secret = sc;
2026
+ const tr = this.getNodeParameter('isTrackingEnabled', i);
2027
+ if (tr)
2028
+ body.isTrackingEnabled = true;
2029
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', B, creds, body, undefined, h);
2030
+ returnData.push({ json: r, pairedItem: { item: i } });
2031
+ }
2032
+ else if (operation === 'get') {
2033
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${wid}`, creds, undefined, undefined, h);
2034
+ returnData.push({ json: r, pairedItem: { item: i } });
2035
+ }
2036
+ else if (operation === 'update') {
2037
+ const body = { activo: this.getNodeParameter('activo', i) };
2038
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'PATCH', `${B}/${wid}`, creds, body, undefined, h);
2039
+ returnData.push({ json: r, pairedItem: { item: i } });
2040
+ }
2041
+ else if (operation === 'delete') {
2042
+ await GenericFunctions_1.netvyApiRequest.call(this, 'DELETE', `${B}/${wid}`, creds);
2043
+ returnData.push({ json: { success: true, webhookID: wid }, pairedItem: { item: i } });
2044
+ }
2045
+ }
2046
+ // ── WMS RECÁLCULOS ─────────────────────────
2047
+ else if (resource === 'wmsRecalculos') {
2048
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
2049
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
2050
+ const h = { 'x-company': xc }, B = '/inventario/recalculos';
2051
+ const rid = this.getNodeParameter('recalculoID', i);
2052
+ const buildParams = () => {
2053
+ const b = {};
2054
+ const sa = this.getNodeParameter('soloAlmacenesDisponibles', i);
2055
+ if (sa)
2056
+ b.soloAlmacenesDisponibles = true;
2057
+ const ic = this.getNodeParameter('inicioCalculoPrecio', i, '');
2058
+ if (ic)
2059
+ b.inicioCalculoPrecio = ic;
2060
+ const fi = this.getNodeParameter('fechaInicioInventarioRetroactivo', i, '');
2061
+ if (fi)
2062
+ b.fechaInicioInventarioRetroactivo = fi;
2063
+ const p0 = this.getNodeParameter('tenerEnCuentaPrecioCero', i);
2064
+ if (p0)
2065
+ b.tenerEnCuentaPrecioCero = true;
2066
+ const pd = this.getNodeParameter('tenerEnCuentaPrecioDevolucion', i);
2067
+ if (pd)
2068
+ b.tenerEnCuentaPrecioDevolucion = true;
2069
+ const pp = this.getNodeParameter('tenerEnCuentaPrecioDevolucionEnPmpClasico', i);
2070
+ if (pp)
2071
+ b.tenerEnCuentaPrecioDevolucionEnPmpClasico = true;
2072
+ const cs = this.getNodeParameter('usarCosteEstandarSiSinPue', i);
2073
+ if (cs)
2074
+ b.usarCosteEstandarSiSinPue = true;
2075
+ const tp = this.getNodeParameter('tipoCalculoPmp', i, '');
2076
+ if (tp)
2077
+ b.tipoCalculoPmp = tp;
2078
+ const cf = this.getNodeParameter('calculoFifoPorProcedimiento', i);
2079
+ if (cf)
2080
+ b.calculoFifoPorProcedimiento = true;
2081
+ const ge = this.getNodeParameter('grabarExistenciasSinControlStock', i);
2082
+ if (ge)
2083
+ b.grabarExistenciasSinControlStock = true;
2084
+ const ei = n('excluirInventarioEnPedidoVentaLinea', i);
2085
+ if (ei)
2086
+ b.excluirInventarioEnPedidoVentaLinea = ei;
2087
+ const tp2 = n('tratamientoPedidosEntreAlmacenes', i);
2088
+ if (tp2)
2089
+ b.tratamientoPedidosEntreAlmacenes = tp2;
2090
+ const tpr = this.getNodeParameter('tenerEnCuentaPrelanzados', i);
2091
+ if (tpr)
2092
+ b.tenerEnCuentaPrelanzados = true;
2093
+ const dr = n('decimalesRedondeo', i);
2094
+ if (dr)
2095
+ b.decimalesRedondeo = dr;
2096
+ return b;
2097
+ };
2098
+ if (operation === 'consulta') {
2099
+ const b = buildParams();
2100
+ b.fechaCorte = this.getNodeParameter('fechaCorte', i);
2101
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/consulta`, creds, b, undefined, h);
2102
+ returnData.push({ json: r, pairedItem: { item: i } });
2103
+ }
2104
+ else if (operation === 'crear') {
2105
+ const b = buildParams();
2106
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', B, creds, b, undefined, h);
2107
+ returnData.push({ json: r, pairedItem: { item: i } });
2108
+ }
2109
+ else if (operation === 'estado') {
2110
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${rid}`, creds, undefined, undefined, h);
2111
+ returnData.push({ json: r, pairedItem: { item: i } });
2112
+ }
2113
+ else if (operation === 'articulos') {
2114
+ const qs = {};
2115
+ const ea = this.getNodeParameter('estadoArticulo', i, '');
2116
+ if (ea)
2117
+ qs.estado = ea;
2118
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${rid}/articulos`, creds, undefined, qs, h);
2119
+ returnData.push({ json: r, pairedItem: { item: i } });
2120
+ }
2121
+ else if (operation === 'reintentar') {
2122
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/${rid}/articulos/${this.getNodeParameter('articuloID', i)}/reintentar`, creds, undefined, undefined, h);
2123
+ returnData.push({ json: r, pairedItem: { item: i } });
2124
+ }
2125
+ else if (operation === 'resultado') {
2126
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/${rid}/resultado`, creds, undefined, undefined, h);
2127
+ returnData.push({ json: r, pairedItem: { item: i } });
2128
+ }
2129
+ }
2130
+ // ── MES POWERMILL ──────────────────────────
2131
+ else if (resource === 'mesPowermill') {
2132
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
2133
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
2134
+ const h = { 'x-company': xc };
2135
+ const pagBody = () => { const b = {}; const p = n('pagina', i); if (p)
2136
+ b.pagina = p; const tp = n('tamanoPagina', i); if (tp)
2137
+ b.tamanoPagina = tp; return b; };
2138
+ if (operation === 'queryUtillajes') {
2139
+ const b = pagBody();
2140
+ const c = this.getNodeParameter('ftCodigo', i, '');
2141
+ if (c)
2142
+ b.codigo = c;
2143
+ const fi = this.getNodeParameter('ftFamiliaID', i, '');
2144
+ if (fi)
2145
+ b.familiaID = fi;
2146
+ const ta = this.getNodeParameter('ftTipoArticuloID', i, '');
2147
+ if (ta)
2148
+ b.tipoArticuloID = ta;
2149
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/utillaje-herramienta', creds, b, undefined, h);
2150
+ returnData.push({ json: r, pairedItem: { item: i } });
2151
+ }
2152
+ else if (operation === 'createUtillaje') {
2153
+ const b = { codigo: this.getNodeParameter('codigo', i), familiaID: this.getNodeParameter('familiaID', i), nombre: this.getNodeParameter('nombre', i) };
2154
+ const ca = this.getNodeParameter('codigoAlmacen', i, '');
2155
+ if (ca)
2156
+ b.codigoAlmacen = ca;
2157
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/utillaje-herramienta', creds, b, undefined, h);
2158
+ returnData.push({ json: r, pairedItem: { item: i } });
2159
+ }
2160
+ else if (operation === 'queryRutas') {
2161
+ const b = pagBody();
2162
+ b.articuloID = this.getNodeParameter('articuloID', i);
2163
+ const nr = n('numeroRuta', i);
2164
+ if (nr)
2165
+ b.numeroRuta = nr;
2166
+ const t = this.getNodeParameter('tipoRuta', i, '');
2167
+ if (t)
2168
+ b.tipo = t;
2169
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/rutas-fabricacion', creds, b, undefined, h);
2170
+ returnData.push({ json: r, pairedItem: { item: i } });
2171
+ }
2172
+ else if (operation === 'createRuta') {
2173
+ const b = { articuloID: this.getNodeParameter('articuloID', i) };
2174
+ const nr = n('numeroRuta', i);
2175
+ if (nr)
2176
+ b.numeroRuta = nr;
2177
+ const t = this.getNodeParameter('tipoRuta', i, '');
2178
+ if (t)
2179
+ b.tipo = t;
2180
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/rutas-fabricacion', creds, b, undefined, h);
2181
+ returnData.push({ json: r, pairedItem: { item: i } });
2182
+ }
2183
+ else if (operation === 'queryOps') {
2184
+ const b = pagBody();
2185
+ b.rutaFabricacionID = this.getNodeParameter('rutaFabricacionID', i);
2186
+ b.operacionID = this.getNodeParameter('operacionID', i);
2187
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/rutas-fabricacion-operaciones', creds, b, undefined, h);
2188
+ returnData.push({ json: r, pairedItem: { item: i } });
2189
+ }
2190
+ else if (operation === 'createOp') {
2191
+ const b = { rutaFabricacionID: this.getNodeParameter('rutaFabricacionID', i), operacionID: this.getNodeParameter('operacionID', i), maquinaID: this.getNodeParameter('maquinaOpID', i), tiempo: n('tiempo', i), tiempoPreparacion: n('tiempoPreparacion', i) };
2192
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/rutas-fabricacion-operaciones', creds, b, undefined, h);
2193
+ returnData.push({ json: r, pairedItem: { item: i } });
2194
+ }
2195
+ else if (operation === 'queryUtillajesRuta') {
2196
+ const b = pagBody();
2197
+ b.rutaFabricacionOperacionID = this.getNodeParameter('rutaFabricacionOperacionID', i);
2198
+ b.articuloID = this.getNodeParameter('utArtArticuloID', i);
2199
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/rutas-fabricacion-utillajes', creds, b, undefined, h);
2200
+ returnData.push({ json: r, pairedItem: { item: i } });
2201
+ }
2202
+ else if (operation === 'createUtillajeRuta') {
2203
+ const b = { rutaFabricacionOperacionID: this.getNodeParameter('rutaFabricacionOperacionID', i), articuloID: this.getNodeParameter('utArtArticuloID', i), cantidad: n('cantidadUt', i), vidaUtil: n('vidaUtil', i) };
2204
+ const nt = this.getNodeParameter('notasUt', i, '');
2205
+ if (nt)
2206
+ b.notas = nt;
2207
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/rutas-fabricacion-utillajes', creds, b, undefined, h);
2208
+ returnData.push({ json: r, pairedItem: { item: i } });
2209
+ }
2210
+ else if (operation === 'queryOF') {
2211
+ const b = pagBody();
2212
+ const co = this.getNodeParameter('codigoOF', i, '');
2213
+ if (co)
2214
+ b.codigo = co;
2215
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/ordenes-fabricacion', creds, b, undefined, h);
2216
+ returnData.push({ json: r, pairedItem: { item: i } });
2217
+ }
2218
+ else if (operation === 'queryUtillajesProceso') {
2219
+ const b = pagBody();
2220
+ b.procesoID = this.getNodeParameter('procesoUtID', i);
2221
+ b.articuloID = this.getNodeParameter('procArtArticuloID', i);
2222
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/procesos-utillajes', creds, b, undefined, h);
2223
+ returnData.push({ json: r, pairedItem: { item: i } });
2224
+ }
2225
+ else if (operation === 'createUtillajeProceso') {
2226
+ const b = { procesoID: this.getNodeParameter('procesoUtID', i), rutaFabricacionUtillajeID: this.getNodeParameter('rutaFabricacionUtillajeID', i), articuloID: this.getNodeParameter('procArtArticuloID', i), cantidad: n('cantidadProc', i) };
2227
+ const nt = this.getNodeParameter('notasProc', i, '');
2228
+ if (nt)
2229
+ b.notas = nt;
2230
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', '/procesos-utillajes', creds, b, undefined, h);
2231
+ returnData.push({ json: r, pairedItem: { item: i } });
2232
+ }
2233
+ }
2234
+ // ── PROYECTOS OF COSTES ────────────────────
2235
+ else if (resource === 'proyectosOfCostes') {
2236
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
2237
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
2238
+ const h = { 'x-company': xc };
2239
+ const pofID = this.getNodeParameter('proyectoOFID', i), B = `/proyectos-of/${pofID}/costes`;
2240
+ if (operation === 'calcular') {
2241
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/calcular`, creds, undefined, undefined, h);
2242
+ returnData.push({ json: r, pairedItem: { item: i } });
2243
+ }
2244
+ else if (operation === 'resumen') {
2245
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', B, creds, undefined, undefined, h);
2246
+ returnData.push({ json: r, pairedItem: { item: i } });
2247
+ }
2248
+ else if (operation === 'arbol') {
2249
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/arbol`, creds, undefined, undefined, h);
2250
+ returnData.push({ json: r, pairedItem: { item: i } });
2251
+ }
2252
+ else if (operation === 'horas') {
2253
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/horas`, creds, undefined, undefined, h);
2254
+ returnData.push({ json: r, pairedItem: { item: i } });
2255
+ }
2256
+ else if (operation === 'facturacion') {
2257
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/facturacion`, creds, undefined, undefined, h);
2258
+ returnData.push({ json: r, pairedItem: { item: i } });
2259
+ }
2260
+ }
2261
+ // ── RUTAS COSTES ───────────────────────────
2262
+ else if (resource === 'rutasCostes') {
2263
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
2264
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
2265
+ const h = { 'x-company': xc };
2266
+ const rfID = this.getNodeParameter('rutaFabricacionID', i), B = `/rutas-fabricacion/${rfID}/costes`;
2267
+ if (operation === 'calcular') {
2268
+ const ps = this.getNodeParameter('persistir', i);
2269
+ const qs = {};
2270
+ if (ps)
2271
+ qs.persistir = 'true';
2272
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `${B}/calcular`, creds, undefined, qs, h);
2273
+ returnData.push({ json: r, pairedItem: { item: i } });
2274
+ }
2275
+ else if (operation === 'resumen') {
2276
+ const rc = this.getNodeParameter('recalcular', i);
2277
+ const qs = {};
2278
+ if (rc)
2279
+ qs.recalcular = 'true';
2280
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', B, creds, undefined, qs, h);
2281
+ returnData.push({ json: r, pairedItem: { item: i } });
2282
+ }
2283
+ else if (operation === 'arbol') {
2284
+ const rc = this.getNodeParameter('recalcular', i);
2285
+ const qs = {};
2286
+ if (rc)
2287
+ qs.recalcular = 'true';
2288
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', `${B}/arbol`, creds, undefined, qs, h);
2289
+ returnData.push({ json: r, pairedItem: { item: i } });
2290
+ }
2291
+ }
2292
+ // ── SOPORTES COSTES ────────────────────────
2293
+ else if (resource === 'soportesCostes') {
2294
+ const creds = await GenericFunctions_1.netvyGetCredentials.call(this, i);
2295
+ const xc = this.getNodeParameter('xCompany', i, '') || creds.empresaActivaID || '';
2296
+ const h = { 'x-company': xc };
2297
+ if (operation === 'actualizarPrecios') {
2298
+ const pofID = this.getNodeParameter('proyectoOFID', i);
2299
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'POST', `/proyectos-of/${pofID}/costes/actualizar-precios-movimientos`, creds, undefined, undefined, h);
2300
+ returnData.push({ json: r, pairedItem: { item: i } });
2301
+ }
2302
+ else if (operation === 'diasLaborables') {
2303
+ const b = {};
2304
+ const p = n('pagina', i);
2305
+ if (p)
2306
+ b.pagina = p;
2307
+ const tp = n('tamanoPagina', i);
2308
+ if (tp)
2309
+ b.tamanoPagina = tp;
2310
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'QUERY', '/calendario/dias-laborables', creds, b, undefined, h);
2311
+ returnData.push({ json: r, pairedItem: { item: i } });
2312
+ }
2313
+ else if (operation === 'turnos') {
2314
+ const qs = {};
2315
+ const p = n('pagina', i);
2316
+ if (p)
2317
+ qs.pagina = p;
2318
+ const tp = n('tamanoPagina', i);
2319
+ if (tp)
2320
+ qs.tamanoPagina = tp;
2321
+ const r = await GenericFunctions_1.netvyApiRequest.call(this, 'GET', '/calendario/turnos', creds, undefined, qs, h);
2322
+ returnData.push({ json: r, pairedItem: { item: i } });
2323
+ }
2324
+ }
2325
+ }
2326
+ catch (error) {
2327
+ if (this.continueOnFail()) {
2328
+ returnData.push({
2329
+ json: { error: error.message },
2330
+ pairedItem: { item: i },
2331
+ });
2332
+ continue;
2333
+ }
2334
+ throw error;
2335
+ }
2336
+ }
2337
+ return [returnData];
2338
+ }
2339
+ }
2340
+ exports.Netvy = Netvy;
2341
+ //# sourceMappingURL=Netvy.node.js.map