@pokash/n8n-nodes-optima-rest-api 1.1.4 → 1.1.5
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.
|
@@ -432,27 +432,34 @@ class OptimaRestApi {
|
|
|
432
432
|
if (responseData.Customers && Array.isArray(responseData.Customers)) {
|
|
433
433
|
// For arrays, only preserve binary on first item to avoid duplication
|
|
434
434
|
const customers = responseData.Customers;
|
|
435
|
+
const inputBinary = items[i].binary;
|
|
435
436
|
customers.forEach((item, index) => {
|
|
436
437
|
returnData.push({
|
|
437
438
|
json: item,
|
|
438
439
|
// Only preserve binary on first item when splitting 1 input into many outputs
|
|
439
|
-
|
|
440
|
+
...(index === 0 && inputBinary ? { binary: inputBinary } : {})
|
|
440
441
|
});
|
|
441
442
|
});
|
|
442
443
|
}
|
|
443
444
|
else if (responseData.Customers) {
|
|
444
445
|
// Single customer - preserve binary
|
|
445
|
-
|
|
446
|
-
json: responseData.Customers
|
|
447
|
-
|
|
448
|
-
|
|
446
|
+
const result = {
|
|
447
|
+
json: responseData.Customers
|
|
448
|
+
};
|
|
449
|
+
if (items[i].binary) {
|
|
450
|
+
result.binary = items[i].binary;
|
|
451
|
+
}
|
|
452
|
+
returnData.push(result);
|
|
449
453
|
}
|
|
450
454
|
else {
|
|
451
455
|
// Fallback - return entire response if structure is unexpected
|
|
452
|
-
|
|
453
|
-
json: responseData
|
|
454
|
-
|
|
455
|
-
|
|
456
|
+
const result = {
|
|
457
|
+
json: responseData
|
|
458
|
+
};
|
|
459
|
+
if (items[i].binary) {
|
|
460
|
+
result.binary = items[i].binary;
|
|
461
|
+
}
|
|
462
|
+
returnData.push(result);
|
|
456
463
|
}
|
|
457
464
|
}
|
|
458
465
|
else if (operation === 'create') {
|
|
@@ -466,10 +473,13 @@ class OptimaRestApi {
|
|
|
466
473
|
body: customerData,
|
|
467
474
|
json: true,
|
|
468
475
|
});
|
|
469
|
-
|
|
470
|
-
json: response
|
|
471
|
-
|
|
472
|
-
|
|
476
|
+
const result = {
|
|
477
|
+
json: response
|
|
478
|
+
};
|
|
479
|
+
if (items[i].binary) {
|
|
480
|
+
result.binary = items[i].binary;
|
|
481
|
+
}
|
|
482
|
+
returnData.push(result);
|
|
473
483
|
}
|
|
474
484
|
else if (operation === 'update') {
|
|
475
485
|
const customerId = this.getNodeParameter('customerId', i);
|
|
@@ -485,10 +495,13 @@ class OptimaRestApi {
|
|
|
485
495
|
body: customerData,
|
|
486
496
|
json: true,
|
|
487
497
|
});
|
|
488
|
-
|
|
489
|
-
json: response
|
|
490
|
-
|
|
491
|
-
|
|
498
|
+
const result = {
|
|
499
|
+
json: response
|
|
500
|
+
};
|
|
501
|
+
if (items[i].binary) {
|
|
502
|
+
result.binary = items[i].binary;
|
|
503
|
+
}
|
|
504
|
+
returnData.push(result);
|
|
492
505
|
}
|
|
493
506
|
else if (operation === 'delete') {
|
|
494
507
|
const customerId = this.getNodeParameter('customerId', i);
|
|
@@ -500,10 +513,13 @@ class OptimaRestApi {
|
|
|
500
513
|
},
|
|
501
514
|
json: true,
|
|
502
515
|
});
|
|
503
|
-
|
|
504
|
-
json: { success: true, id: customerId }
|
|
505
|
-
|
|
506
|
-
|
|
516
|
+
const result = {
|
|
517
|
+
json: { success: true, id: customerId }
|
|
518
|
+
};
|
|
519
|
+
if (items[i].binary) {
|
|
520
|
+
result.binary = items[i].binary;
|
|
521
|
+
}
|
|
522
|
+
returnData.push(result);
|
|
507
523
|
}
|
|
508
524
|
}
|
|
509
525
|
else if (resource === 'document') {
|
|
@@ -519,10 +535,13 @@ class OptimaRestApi {
|
|
|
519
535
|
body: documentData,
|
|
520
536
|
json: true,
|
|
521
537
|
});
|
|
522
|
-
|
|
523
|
-
json: response
|
|
524
|
-
|
|
525
|
-
|
|
538
|
+
const result = {
|
|
539
|
+
json: response
|
|
540
|
+
};
|
|
541
|
+
if (items[i].binary) {
|
|
542
|
+
result.binary = items[i].binary;
|
|
543
|
+
}
|
|
544
|
+
returnData.push(result);
|
|
526
545
|
}
|
|
527
546
|
}
|
|
528
547
|
else if (resource === 'dictionary') {
|
|
@@ -550,20 +569,27 @@ class OptimaRestApi {
|
|
|
550
569
|
if (responseData[dictConfig.dataKey] && Array.isArray(responseData[dictConfig.dataKey])) {
|
|
551
570
|
// For arrays, only preserve binary on first item to avoid duplication
|
|
552
571
|
const dictItems = responseData[dictConfig.dataKey];
|
|
572
|
+
const inputBinary = items[i].binary;
|
|
553
573
|
dictItems.forEach((item, index) => {
|
|
554
|
-
|
|
555
|
-
json: item
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
574
|
+
const result = {
|
|
575
|
+
json: item
|
|
576
|
+
};
|
|
577
|
+
// Only preserve binary on first item when splitting 1 input into many outputs
|
|
578
|
+
if (index === 0 && inputBinary) {
|
|
579
|
+
result.binary = inputBinary;
|
|
580
|
+
}
|
|
581
|
+
returnData.push(result);
|
|
559
582
|
});
|
|
560
583
|
}
|
|
561
584
|
else {
|
|
562
585
|
// Fallback - return entire response if structure is unexpected
|
|
563
|
-
|
|
564
|
-
json: responseData
|
|
565
|
-
|
|
566
|
-
|
|
586
|
+
const result = {
|
|
587
|
+
json: responseData
|
|
588
|
+
};
|
|
589
|
+
if (items[i].binary) {
|
|
590
|
+
result.binary = items[i].binary;
|
|
591
|
+
}
|
|
592
|
+
returnData.push(result);
|
|
567
593
|
}
|
|
568
594
|
}
|
|
569
595
|
}
|
|
@@ -578,10 +604,13 @@ class OptimaRestApi {
|
|
|
578
604
|
},
|
|
579
605
|
json: true,
|
|
580
606
|
});
|
|
581
|
-
|
|
582
|
-
json: response
|
|
583
|
-
|
|
584
|
-
|
|
607
|
+
const result = {
|
|
608
|
+
json: response
|
|
609
|
+
};
|
|
610
|
+
if (items[i].binary) {
|
|
611
|
+
result.binary = items[i].binary;
|
|
612
|
+
}
|
|
613
|
+
returnData.push(result);
|
|
585
614
|
}
|
|
586
615
|
else if (operation === 'getAll') {
|
|
587
616
|
const response = await this.helpers.request({
|
|
@@ -594,12 +623,16 @@ class OptimaRestApi {
|
|
|
594
623
|
});
|
|
595
624
|
// For arrays, only preserve binary on first item to avoid duplication
|
|
596
625
|
const products = response;
|
|
626
|
+
const inputBinary = items[i].binary;
|
|
597
627
|
products.forEach((item, index) => {
|
|
598
|
-
|
|
599
|
-
json: item
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
628
|
+
const result = {
|
|
629
|
+
json: item
|
|
630
|
+
};
|
|
631
|
+
// Only preserve binary on first item when splitting 1 input into many outputs
|
|
632
|
+
if (index === 0 && inputBinary) {
|
|
633
|
+
result.binary = inputBinary;
|
|
634
|
+
}
|
|
635
|
+
returnData.push(result);
|
|
603
636
|
});
|
|
604
637
|
}
|
|
605
638
|
}
|
|
@@ -645,10 +678,13 @@ class OptimaRestApi {
|
|
|
645
678
|
catch (error) {
|
|
646
679
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
647
680
|
if (this.continueOnFail()) {
|
|
648
|
-
|
|
649
|
-
json: { error: errorMessage }
|
|
650
|
-
|
|
651
|
-
|
|
681
|
+
const result = {
|
|
682
|
+
json: { error: errorMessage }
|
|
683
|
+
};
|
|
684
|
+
if (items[i].binary) {
|
|
685
|
+
result.binary = items[i].binary;
|
|
686
|
+
}
|
|
687
|
+
returnData.push(result);
|
|
652
688
|
continue;
|
|
653
689
|
}
|
|
654
690
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), errorMessage);
|