@pokash/n8n-nodes-optima-rest-api 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @pokash/n8n-nodes-optima-rest-api might be problematic. Click here for more details.

@@ -430,16 +430,29 @@ class OptimaRestApi {
430
430
  const responseData = response;
431
431
  // Extract customers array from response
432
432
  if (responseData.Customers && Array.isArray(responseData.Customers)) {
433
- const items = responseData.Customers.map(item => ({ json: item }));
434
- returnData.push(...items);
433
+ // For arrays, only preserve binary on first item to avoid duplication
434
+ const customers = responseData.Customers;
435
+ customers.forEach((item, index) => {
436
+ returnData.push({
437
+ json: item,
438
+ // Only preserve binary on first item when splitting 1 input into many outputs
439
+ binary: index === 0 ? items[i].binary : undefined
440
+ });
441
+ });
435
442
  }
436
443
  else if (responseData.Customers) {
437
- // Single customer
438
- returnData.push({ json: responseData.Customers });
444
+ // Single customer - preserve binary
445
+ returnData.push({
446
+ json: responseData.Customers,
447
+ binary: items[i].binary
448
+ });
439
449
  }
440
450
  else {
441
451
  // Fallback - return entire response if structure is unexpected
442
- returnData.push({ json: responseData });
452
+ returnData.push({
453
+ json: responseData,
454
+ binary: items[i].binary
455
+ });
443
456
  }
444
457
  }
445
458
  else if (operation === 'create') {
@@ -453,7 +466,10 @@ class OptimaRestApi {
453
466
  body: customerData,
454
467
  json: true,
455
468
  });
456
- returnData.push({ json: response });
469
+ returnData.push({
470
+ json: response,
471
+ binary: items[i].binary
472
+ });
457
473
  }
458
474
  else if (operation === 'update') {
459
475
  const customerId = this.getNodeParameter('customerId', i);
@@ -469,7 +485,10 @@ class OptimaRestApi {
469
485
  body: customerData,
470
486
  json: true,
471
487
  });
472
- returnData.push({ json: response });
488
+ returnData.push({
489
+ json: response,
490
+ binary: items[i].binary
491
+ });
473
492
  }
474
493
  else if (operation === 'delete') {
475
494
  const customerId = this.getNodeParameter('customerId', i);
@@ -481,7 +500,10 @@ class OptimaRestApi {
481
500
  },
482
501
  json: true,
483
502
  });
484
- returnData.push({ json: { success: true, id: customerId } });
503
+ returnData.push({
504
+ json: { success: true, id: customerId },
505
+ binary: items[i].binary
506
+ });
485
507
  }
486
508
  }
487
509
  else if (resource === 'document') {
@@ -497,7 +519,10 @@ class OptimaRestApi {
497
519
  body: documentData,
498
520
  json: true,
499
521
  });
500
- returnData.push({ json: response });
522
+ returnData.push({
523
+ json: response,
524
+ binary: items[i].binary
525
+ });
501
526
  }
502
527
  }
503
528
  else if (resource === 'dictionary') {
@@ -523,12 +548,22 @@ class OptimaRestApi {
523
548
  const responseData = response;
524
549
  // Extract dictionary array from response
525
550
  if (responseData[dictConfig.dataKey] && Array.isArray(responseData[dictConfig.dataKey])) {
526
- const items = responseData[dictConfig.dataKey].map(item => ({ json: item }));
527
- returnData.push(...items);
551
+ // For arrays, only preserve binary on first item to avoid duplication
552
+ const dictItems = responseData[dictConfig.dataKey];
553
+ dictItems.forEach((item, index) => {
554
+ returnData.push({
555
+ json: item,
556
+ // Only preserve binary on first item when splitting 1 input into many outputs
557
+ binary: index === 0 ? items[i].binary : undefined
558
+ });
559
+ });
528
560
  }
529
561
  else {
530
562
  // Fallback - return entire response if structure is unexpected
531
- returnData.push({ json: responseData });
563
+ returnData.push({
564
+ json: responseData,
565
+ binary: items[i].binary
566
+ });
532
567
  }
533
568
  }
534
569
  }
@@ -543,7 +578,10 @@ class OptimaRestApi {
543
578
  },
544
579
  json: true,
545
580
  });
546
- returnData.push({ json: response });
581
+ returnData.push({
582
+ json: response,
583
+ binary: items[i].binary
584
+ });
547
585
  }
548
586
  else if (operation === 'getAll') {
549
587
  const response = await this.helpers.request({
@@ -554,8 +592,15 @@ class OptimaRestApi {
554
592
  },
555
593
  json: true,
556
594
  });
557
- const items = response.map(item => ({ json: item }));
558
- returnData.push(...items);
595
+ // For arrays, only preserve binary on first item to avoid duplication
596
+ const products = response;
597
+ products.forEach((item, index) => {
598
+ returnData.push({
599
+ json: item,
600
+ // Only preserve binary on first item when splitting 1 input into many outputs
601
+ binary: index === 0 ? items[i].binary : undefined
602
+ });
603
+ });
559
604
  }
560
605
  }
561
606
  else if (resource === 'print') {
@@ -600,7 +645,10 @@ class OptimaRestApi {
600
645
  catch (error) {
601
646
  const errorMessage = error instanceof Error ? error.message : String(error);
602
647
  if (this.continueOnFail()) {
603
- returnData.push({ json: { error: errorMessage } });
648
+ returnData.push({
649
+ json: { error: errorMessage },
650
+ binary: items[i].binary
651
+ });
604
652
  continue;
605
653
  }
606
654
  throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",