n8n-nodes-sotoros-gotenberg 1.0.5 → 1.0.6

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.
@@ -200,6 +200,57 @@ class Gotenberg {
200
200
  };
201
201
  return mimeToExt[mimeType] || 'bin';
202
202
  };
203
+ // Вспомогательная функция для форматирования структуры данных с заменой длинных base64 строк
204
+ const formatDataStructure = (data, maxDepth = 5, currentDepth = 0) => {
205
+ if (currentDepth >= maxDepth) {
206
+ return '[max depth reached]';
207
+ }
208
+ // Если это null или undefined
209
+ if (data === null || data === undefined) {
210
+ return data;
211
+ }
212
+ // Если это примитивный тип
213
+ if (typeof data !== 'object') {
214
+ // Если это строка и она похожа на base64 (длинная строка из base64 символов)
215
+ if (typeof data === 'string' && data.length > 100 && /^[A-Za-z0-9+/=]+$/.test(data)) {
216
+ return `[binary data: ${data.length} bytes]`;
217
+ }
218
+ // Если это очень длинная строка (не base64, но все равно длинная)
219
+ if (typeof data === 'string' && data.length > 200) {
220
+ return `[long string: ${data.length} chars]`;
221
+ }
222
+ return data;
223
+ }
224
+ // Если это массив
225
+ if (Array.isArray(data)) {
226
+ return data.map((item, index) => {
227
+ // Ограничиваем вывод массивов до 10 элементов
228
+ if (index >= 10) {
229
+ return `[${data.length - 10} more items...]`;
230
+ }
231
+ return formatDataStructure(item, maxDepth, currentDepth + 1);
232
+ }).slice(0, 10);
233
+ }
234
+ // Если это объект
235
+ const formatted = {};
236
+ for (const key in data) {
237
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
238
+ const value = data[key];
239
+ // Специальная обработка для binary данных
240
+ if (key === 'data' && typeof value === 'string' && value.length > 50) {
241
+ formatted[key] = `[binary data: ${value.length} bytes]`;
242
+ }
243
+ else if (key === 'binary' && typeof value === 'object' && value !== null) {
244
+ // Для binary объектов показываем структуру, но заменяем data
245
+ formatted[key] = formatDataStructure(value, maxDepth, currentDepth + 1);
246
+ }
247
+ else {
248
+ formatted[key] = formatDataStructure(value, maxDepth, currentDepth + 1);
249
+ }
250
+ }
251
+ }
252
+ return formatted;
253
+ };
203
254
  try {
204
255
  // Извлекаем список из JSON свойства агрегированного элемента
205
256
  let listData;
@@ -293,7 +344,63 @@ class Gotenberg {
293
344
  }
294
345
  }
295
346
  if (totalFilesCount === 0) {
296
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'No valid binary files found in any items. Please make sure binary data exists.');
347
+ // Собираем информацию о структуре элементов списка
348
+ const sampleItems = listData.slice(0, 3).map((item, index) => {
349
+ const itemInfo = {
350
+ index,
351
+ type: typeof item,
352
+ isObject: typeof item === 'object' && item !== null,
353
+ hasBinary: 'binary' in (item || {}),
354
+ hasBinaryProperty: binaryPropertyName in (item || {}),
355
+ keys: item && typeof item === 'object' ? Object.keys(item) : [],
356
+ };
357
+ // Если есть binary свойство, показываем его структуру
358
+ if (item && typeof item === 'object') {
359
+ if ('binary' in item && item.binary) {
360
+ itemInfo.binaryKeys = Object.keys(item.binary);
361
+ itemInfo.binaryStructure = formatDataStructure(item.binary);
362
+ }
363
+ if (binaryPropertyName in item) {
364
+ itemInfo[binaryPropertyName] = formatDataStructure(item[binaryPropertyName]);
365
+ }
366
+ // Показываем структуру json части (без длинных строк)
367
+ if ('json' in item) {
368
+ itemInfo.jsonKeys = Object.keys(item.json || {});
369
+ itemInfo.jsonSample = formatDataStructure(item.json);
370
+ }
371
+ else {
372
+ // Если нет json, показываем структуру самого объекта
373
+ itemInfo.objectSample = formatDataStructure(item);
374
+ }
375
+ }
376
+ return itemInfo;
377
+ });
378
+ // Форматируем структуру данных для отладки
379
+ const formattedStructure = formatDataStructure({
380
+ aggregatedItem: {
381
+ jsonKeys: Object.keys(aggregatedItem.json || {}),
382
+ binaryKeys: Object.keys(aggregatedItem.binary || {}),
383
+ jsonSample: formatDataStructure(aggregatedItem.json),
384
+ },
385
+ listDataInfo: {
386
+ length: listData.length,
387
+ propertyName: listPropertyName || '(root array)',
388
+ sampleItems,
389
+ },
390
+ configuration: {
391
+ binaryPropertyName,
392
+ listPropertyName: listPropertyName || '(root array)',
393
+ },
394
+ });
395
+ const structureInfo = JSON.stringify(formattedStructure, null, 2);
396
+ 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
+ `Input data structure:\n${structureInfo}\n\n` +
398
+ `Tips:\n` +
399
+ `- Check that binaryPropertyName "${binaryPropertyName}" matches the property name in your items\n` +
400
+ `- Verify that binary data exists in the items (check the "binary" property or the specified property)\n` +
401
+ `- Make sure binary data has a "data" field with base64 content\n` +
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}"]`);
297
404
  }
298
405
  // Добавляем опции в зависимости от операции
299
406
  if (operation === 'office' || operation === 'html' || operation === 'markdown') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-sotoros-gotenberg",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "n8n custom node for Gotenberg integration with binary data support",
5
5
  "keywords": [
6
6
  "n8n-community-node",