@pokash/n8n-nodes-optima-rest-api 1.2.1 → 1.3.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.
@@ -486,36 +486,94 @@ class OptimaRestApi {
486
486
  ],
487
487
  default: 'printDocument',
488
488
  },
489
+ // Print Format ID
490
+ {
491
+ displayName: 'Format ID',
492
+ name: 'formatId',
493
+ type: 'number',
494
+ required: true,
495
+ displayOptions: {
496
+ show: {
497
+ resource: ['print'],
498
+ operation: ['printDocument'],
499
+ },
500
+ },
501
+ default: 1,
502
+ description: 'ID of the print format from Optima',
503
+ },
489
504
  // Print SQL Filter
490
505
  {
491
506
  displayName: 'SQL Filter',
492
507
  name: 'filtrSQL',
493
- type: 'string',
494
- required: true,
508
+ type: 'fixedCollection',
509
+ typeOptions: {
510
+ multipleValues: false,
511
+ multipleValueButtonText: 'Add Filter',
512
+ },
495
513
  displayOptions: {
496
514
  show: {
497
515
  resource: ['print'],
498
516
  operation: ['printDocument'],
499
517
  },
500
518
  },
501
- default: '',
502
- placeholder: 'TrN_TrnId = 123',
519
+ default: {},
503
520
  description: 'SQL filter to select documents',
521
+ options: [
522
+ {
523
+ name: 'filter',
524
+ displayName: 'Filter',
525
+ values: [
526
+ {
527
+ displayName: 'Expression',
528
+ name: 'expression',
529
+ type: 'string',
530
+ default: '',
531
+ placeholder: 'TrN_TrNID = 123',
532
+ description: 'SQL filter expression (e.g. "EDN_EDNId = 1002")',
533
+ },
534
+ ],
535
+ },
536
+ ],
504
537
  },
505
- // Print Format ID
538
+ // Print Dynamic Parameters
506
539
  {
507
- displayName: 'Format ID',
508
- name: 'formatId',
509
- type: 'number',
510
- required: true,
540
+ displayName: 'Dynamic Parameters',
541
+ name: 'dynamicParameters',
542
+ type: 'fixedCollection',
543
+ typeOptions: {
544
+ multipleValues: true,
545
+ multipleValueButtonText: 'Add Parameter',
546
+ },
511
547
  displayOptions: {
512
548
  show: {
513
549
  resource: ['print'],
514
550
  operation: ['printDocument'],
515
551
  },
516
552
  },
517
- default: 1,
518
- description: 'ID of the print format from Optima',
553
+ default: {},
554
+ description: 'Dynamic parameters passed to the print template',
555
+ options: [
556
+ {
557
+ name: 'parameter',
558
+ displayName: 'Parameter',
559
+ values: [
560
+ {
561
+ displayName: 'Name',
562
+ name: 'name',
563
+ type: 'string',
564
+ default: '',
565
+ placeholder: 'Parameter name',
566
+ },
567
+ {
568
+ displayName: 'Value',
569
+ name: 'value',
570
+ type: 'string',
571
+ default: '',
572
+ placeholder: 'Parameter value',
573
+ },
574
+ ],
575
+ },
576
+ ],
519
577
  },
520
578
  ],
521
579
  };
@@ -934,12 +992,26 @@ class OptimaRestApi {
934
992
  }
935
993
  else if (resource === 'print') {
936
994
  if (operation === 'printDocument') {
937
- const filtrSQL = this.getNodeParameter('filtrSQL', i);
938
995
  const formatId = this.getNodeParameter('formatId', i);
996
+ const filtrSQLRaw = this.getNodeParameter('filtrSQL', i, {});
997
+ const dynamicParamsRaw = this.getNodeParameter('dynamicParameters', i, {});
939
998
  const requestBody = {
940
999
  FormatId: formatId,
941
- FiltrSQL: filtrSQL,
942
1000
  };
1001
+ if (filtrSQLRaw.filter) {
1002
+ const filter = filtrSQLRaw.filter;
1003
+ if (filter.expression) {
1004
+ requestBody.FiltrSQL = filter.expression;
1005
+ }
1006
+ }
1007
+ if (dynamicParamsRaw.parameter) {
1008
+ const params = dynamicParamsRaw.parameter;
1009
+ const dynamicParameters = {};
1010
+ for (const p of params) {
1011
+ dynamicParameters[p.name] = p.value;
1012
+ }
1013
+ requestBody.DynamicParameters = dynamicParameters;
1014
+ }
943
1015
  const response = await makeAuthenticatedRequest({
944
1016
  method: 'POST',
945
1017
  url: `${gatewayUrl}/api/Documents/Print`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pokash/n8n-nodes-optima-rest-api",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "n8n node for Comarch Optima REST API integration",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",