n8n-nodes-sotoros-gotenberg 1.0.6 → 1.0.7
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.
|
@@ -297,9 +297,11 @@ class Gotenberg {
|
|
|
297
297
|
// Элемент списка может быть INodeExecutionData (с полями json и binary)
|
|
298
298
|
// или обычным объектом с binary данными в разных местах
|
|
299
299
|
let itemBinary;
|
|
300
|
+
let binaryProperty;
|
|
300
301
|
// Вариант 1: элемент имеет структуру INodeExecutionData (json и binary)
|
|
301
302
|
if ('binary' in listItem && listItem.binary && typeof listItem.binary === 'object') {
|
|
302
303
|
itemBinary = listItem.binary;
|
|
304
|
+
binaryProperty = itemBinary[binaryPropertyName];
|
|
303
305
|
}
|
|
304
306
|
// Вариант 2: binary данные находятся в свойстве элемента напрямую
|
|
305
307
|
else if (binaryPropertyName in listItem) {
|
|
@@ -308,21 +310,25 @@ class Gotenberg {
|
|
|
308
310
|
// Может быть одиночным объектом или массивом
|
|
309
311
|
if (binaryProp.data) {
|
|
310
312
|
// Это одиночный binary объект
|
|
311
|
-
|
|
313
|
+
binaryProperty = binaryProp;
|
|
312
314
|
}
|
|
313
315
|
else if (Array.isArray(binaryProp)) {
|
|
314
316
|
// Это массив binary объектов
|
|
315
|
-
|
|
317
|
+
binaryProperty = binaryProp;
|
|
316
318
|
}
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
+
// Вариант 3: если binary данные не найдены в элементе списка,
|
|
322
|
+
// ищем их в aggregatedItem.binary по индексу
|
|
323
|
+
// Для первого элемента (index 0) используем binaryPropertyName, для остальных - binaryPropertyName_${index}
|
|
324
|
+
if (!binaryProperty && aggregatedItem.binary) {
|
|
325
|
+
const binaryKey = listIndex === 0 ? binaryPropertyName : `${binaryPropertyName}_${listIndex}`;
|
|
326
|
+
if (binaryKey in aggregatedItem.binary) {
|
|
327
|
+
binaryProperty = aggregatedItem.binary[binaryKey];
|
|
328
|
+
}
|
|
321
329
|
}
|
|
322
|
-
// Получаем binary свойство
|
|
323
|
-
const binaryProperty = itemBinary[binaryPropertyName];
|
|
324
330
|
if (!binaryProperty) {
|
|
325
|
-
continue; // Пропускаем элементы без
|
|
331
|
+
continue; // Пропускаем элементы без binary данных
|
|
326
332
|
}
|
|
327
333
|
// Обрабатываем как одиночное значение, так и массив
|
|
328
334
|
const binaryItems = Array.isArray(binaryProperty) ? binaryProperty : [binaryProperty];
|
|
@@ -334,8 +340,14 @@ class Gotenberg {
|
|
|
334
340
|
}
|
|
335
341
|
// Получаем buffer из binary данных (всегда base64 в n8n)
|
|
336
342
|
const dataBuffer = Buffer.from(binaryItem.data, 'base64');
|
|
343
|
+
// Используем fileName из метаданных элемента списка, если доступно
|
|
337
344
|
const fileName = binaryItem.fileName ||
|
|
338
|
-
|
|
345
|
+
(listItem && typeof listItem === 'object' && 'fileName' in listItem
|
|
346
|
+
? listItem.fileName
|
|
347
|
+
: undefined) ||
|
|
348
|
+
(listItem && typeof listItem === 'object' && 'fileExtension' in listItem
|
|
349
|
+
? `${binaryPropertyName}_${listIndex}.${listItem.fileExtension}`
|
|
350
|
+
: `${binaryPropertyName}_${listIndex}_${i}.${getFileExtensionFromMimeType(binaryItem.mimeType || '')}`);
|
|
339
351
|
formData.append('files', dataBuffer, {
|
|
340
352
|
filename: fileName,
|
|
341
353
|
contentType: binaryItem.mimeType || 'application/octet-stream',
|
|
@@ -375,11 +387,29 @@ class Gotenberg {
|
|
|
375
387
|
}
|
|
376
388
|
return itemInfo;
|
|
377
389
|
});
|
|
390
|
+
// Собираем информацию о binary данных в aggregatedItem
|
|
391
|
+
const aggregatedBinaryInfo = {
|
|
392
|
+
keys: Object.keys(aggregatedItem.binary || {}),
|
|
393
|
+
sampleBinaryData: {},
|
|
394
|
+
};
|
|
395
|
+
// Показываем структуру первых нескольких binary данных
|
|
396
|
+
const binaryKeysToShow = Object.keys(aggregatedItem.binary || {}).slice(0, 3);
|
|
397
|
+
for (const key of binaryKeysToShow) {
|
|
398
|
+
const binaryData = aggregatedItem.binary[key];
|
|
399
|
+
if (binaryData) {
|
|
400
|
+
aggregatedBinaryInfo.sampleBinaryData[key] = {
|
|
401
|
+
hasData: !!binaryData.data,
|
|
402
|
+
dataLength: binaryData.data ? binaryData.data.length : 0,
|
|
403
|
+
mimeType: binaryData.mimeType,
|
|
404
|
+
fileName: binaryData.fileName,
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
}
|
|
378
408
|
// Форматируем структуру данных для отладки
|
|
379
409
|
const formattedStructure = formatDataStructure({
|
|
380
410
|
aggregatedItem: {
|
|
381
411
|
jsonKeys: Object.keys(aggregatedItem.json || {}),
|
|
382
|
-
|
|
412
|
+
binaryInfo: aggregatedBinaryInfo,
|
|
383
413
|
jsonSample: formatDataStructure(aggregatedItem.json),
|
|
384
414
|
},
|
|
385
415
|
listDataInfo: {
|
|
@@ -390,17 +420,34 @@ class Gotenberg {
|
|
|
390
420
|
configuration: {
|
|
391
421
|
binaryPropertyName,
|
|
392
422
|
listPropertyName: listPropertyName || '(root array)',
|
|
423
|
+
expectedBinaryKeys: (() => {
|
|
424
|
+
const keys = [];
|
|
425
|
+
for (let i = 0; i < Math.min(listData.length, 10); i++) {
|
|
426
|
+
keys.push(i === 0 ? binaryPropertyName : `${binaryPropertyName}_${i}`);
|
|
427
|
+
}
|
|
428
|
+
return keys;
|
|
429
|
+
})(),
|
|
393
430
|
},
|
|
394
431
|
});
|
|
395
432
|
const structureInfo = JSON.stringify(formattedStructure, null, 2);
|
|
433
|
+
// Проверяем, есть ли binary данные в aggregatedItem.binary
|
|
434
|
+
const aggregatedBinaryKeys = Object.keys(aggregatedItem.binary || {});
|
|
435
|
+
const expectedBinaryKeys = [];
|
|
436
|
+
for (let i = 0; i < Math.min(listData.length, 10); i++) {
|
|
437
|
+
expectedBinaryKeys.push(i === 0 ? binaryPropertyName : `${binaryPropertyName}_${i}`);
|
|
438
|
+
}
|
|
396
439
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No valid binary files found in any items. Please make sure binary data exists.\n\n` +
|
|
397
440
|
`Input data structure:\n${structureInfo}\n\n` +
|
|
441
|
+
`Binary data search locations:\n` +
|
|
442
|
+
`1. In list item: item.binary["${binaryPropertyName}"] or item["${binaryPropertyName}"]\n` +
|
|
443
|
+
`2. In aggregated item: aggregatedItem.binary["${binaryPropertyName}"] (for first item)\n` +
|
|
444
|
+
`3. In aggregated item: aggregatedItem.binary["${binaryPropertyName}_${1}"] (for second item), etc.\n\n` +
|
|
445
|
+
`Found binary keys in aggregatedItem.binary: ${aggregatedBinaryKeys.length > 0 ? aggregatedBinaryKeys.join(', ') : 'none'}\n` +
|
|
446
|
+
`Expected binary keys for first 10 items: ${expectedBinaryKeys.join(', ')}\n\n` +
|
|
398
447
|
`Tips:\n` +
|
|
399
|
-
`- Check that binaryPropertyName "${binaryPropertyName}" matches the property name
|
|
400
|
-
`- Verify that binary data exists in
|
|
401
|
-
`- Make sure binary data has a "data" field with base64 content
|
|
402
|
-
`- If items have a "binary" property, binary data should be in binary["${binaryPropertyName}"]\n` +
|
|
403
|
-
`- If items have binary data directly, it should be in item["${binaryPropertyName}"]`);
|
|
448
|
+
`- Check that binaryPropertyName "${binaryPropertyName}" matches the property name\n` +
|
|
449
|
+
`- Verify that binary data exists in aggregatedItem.binary with keys: "${binaryPropertyName}", "${binaryPropertyName}_1", "${binaryPropertyName}_2", etc.\n` +
|
|
450
|
+
`- Make sure binary data has a "data" field with base64 content`);
|
|
404
451
|
}
|
|
405
452
|
// Добавляем опции в зависимости от операции
|
|
406
453
|
if (operation === 'office' || operation === 'html' || operation === 'markdown') {
|