@pdfgeneratorapi/n8n-nodes-pdf-generator-api 0.3.0 → 0.5.0
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.
|
@@ -37,6 +37,11 @@ class PdfGeneratorApi {
|
|
|
37
37
|
type: 'options',
|
|
38
38
|
noDataExpression: true,
|
|
39
39
|
options: [
|
|
40
|
+
{
|
|
41
|
+
name: 'Asset',
|
|
42
|
+
value: 'asset',
|
|
43
|
+
description: 'Generate QR codes and other assets for use in documents',
|
|
44
|
+
},
|
|
40
45
|
{
|
|
41
46
|
name: 'Conversion',
|
|
42
47
|
value: 'conversion',
|
|
@@ -47,6 +52,11 @@ class PdfGeneratorApi {
|
|
|
47
52
|
value: 'document',
|
|
48
53
|
description: 'Generate PDFs from templates with data, manage document storage',
|
|
49
54
|
},
|
|
55
|
+
{
|
|
56
|
+
name: 'E-Invoice',
|
|
57
|
+
value: 'einvoice',
|
|
58
|
+
description: 'Create EN 16931 e-invoices as UBL or CII XML, XRechnung 3.0, or Factur-X PDF',
|
|
59
|
+
},
|
|
50
60
|
{
|
|
51
61
|
name: 'PDF Service',
|
|
52
62
|
value: 'pdfServices',
|
|
@@ -66,6 +76,26 @@ class PdfGeneratorApi {
|
|
|
66
76
|
default: 'document',
|
|
67
77
|
description: 'Choose the type of PDF operation: generate documents from templates, convert HTML/URLs, process existing PDFs, or manage templates and workspaces',
|
|
68
78
|
},
|
|
79
|
+
{
|
|
80
|
+
displayName: 'Asset Operations',
|
|
81
|
+
name: 'operation',
|
|
82
|
+
type: 'options',
|
|
83
|
+
noDataExpression: true,
|
|
84
|
+
displayOptions: {
|
|
85
|
+
show: {
|
|
86
|
+
resource: ['asset'],
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
options: [
|
|
90
|
+
{
|
|
91
|
+
name: 'Generate QR Code',
|
|
92
|
+
value: 'generateQRCode',
|
|
93
|
+
description: 'Generate a QR code image',
|
|
94
|
+
action: 'Generate a QR code image',
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
default: 'generateQRCode',
|
|
98
|
+
},
|
|
69
99
|
{
|
|
70
100
|
displayName: 'Conversion Operations',
|
|
71
101
|
name: 'operation',
|
|
@@ -148,6 +178,44 @@ class PdfGeneratorApi {
|
|
|
148
178
|
],
|
|
149
179
|
default: 'generate',
|
|
150
180
|
},
|
|
181
|
+
{
|
|
182
|
+
displayName: 'E-Invoice Operations',
|
|
183
|
+
name: 'operation',
|
|
184
|
+
type: 'options',
|
|
185
|
+
noDataExpression: true,
|
|
186
|
+
displayOptions: {
|
|
187
|
+
show: {
|
|
188
|
+
resource: ['einvoice'],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
options: [
|
|
192
|
+
{
|
|
193
|
+
name: 'Create E-Invoice',
|
|
194
|
+
value: 'createEInvoice',
|
|
195
|
+
description: 'Create an EN 16931 e-invoice as UBL or CII XML',
|
|
196
|
+
action: 'Create an EN 16931 e invoice',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'Create Factur-X E-Invoice',
|
|
200
|
+
value: 'createFacturX',
|
|
201
|
+
description: 'Create a Factur-X PDF with the CII XML embedded',
|
|
202
|
+
action: 'Create a FACTUR-X e invoice',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
name: 'Create XRechnung E-Invoice',
|
|
206
|
+
value: 'createXRechnung',
|
|
207
|
+
description: 'Create an XRechnung 3.0 e-invoice, validated against the German BR-DE rules',
|
|
208
|
+
action: 'Create an XRECHNUNG e invoice',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
name: 'Get Schema',
|
|
212
|
+
value: 'getEInvoiceSchema',
|
|
213
|
+
description: 'Get the JSON schema of the accepted e-invoice payload',
|
|
214
|
+
action: 'Get the e invoice payload schema',
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
default: 'createEInvoice',
|
|
218
|
+
},
|
|
151
219
|
{
|
|
152
220
|
displayName: 'Services Operations',
|
|
153
221
|
name: 'operation',
|
|
@@ -801,6 +869,12 @@ class PdfGeneratorApi {
|
|
|
801
869
|
description: 'Get template data fields',
|
|
802
870
|
action: 'Get template data fields',
|
|
803
871
|
},
|
|
872
|
+
{
|
|
873
|
+
name: 'Get Template Schema',
|
|
874
|
+
value: 'getTemplateSchema',
|
|
875
|
+
description: 'Get template JSON schema',
|
|
876
|
+
action: 'Get template JSON schema',
|
|
877
|
+
},
|
|
804
878
|
{
|
|
805
879
|
name: 'List',
|
|
806
880
|
value: 'list',
|
|
@@ -986,9 +1060,13 @@ class PdfGeneratorApi {
|
|
|
986
1060
|
name: 'URL',
|
|
987
1061
|
value: 'url',
|
|
988
1062
|
},
|
|
1063
|
+
{
|
|
1064
|
+
name: 'Viewer',
|
|
1065
|
+
value: 'viewer',
|
|
1066
|
+
},
|
|
989
1067
|
],
|
|
990
1068
|
default: 'base64',
|
|
991
|
-
description: 'Response format. File
|
|
1069
|
+
description: 'Response format. File returns inline. URL and Viewer store document for 30 days.',
|
|
992
1070
|
},
|
|
993
1071
|
{
|
|
994
1072
|
displayName: 'Output',
|
|
@@ -1009,9 +1087,13 @@ class PdfGeneratorApi {
|
|
|
1009
1087
|
name: 'URL',
|
|
1010
1088
|
value: 'url',
|
|
1011
1089
|
},
|
|
1090
|
+
{
|
|
1091
|
+
name: 'Viewer',
|
|
1092
|
+
value: 'viewer',
|
|
1093
|
+
},
|
|
1012
1094
|
],
|
|
1013
1095
|
default: 'base64',
|
|
1014
|
-
description: 'Response format. URL
|
|
1096
|
+
description: 'Response format. File returns inline. URL and Viewer store document for 30 days.',
|
|
1015
1097
|
},
|
|
1016
1098
|
{
|
|
1017
1099
|
displayName: 'Additional Fields',
|
|
@@ -1277,6 +1359,129 @@ class PdfGeneratorApi {
|
|
|
1277
1359
|
default: '',
|
|
1278
1360
|
description: 'A unique identifier for the new workspace',
|
|
1279
1361
|
},
|
|
1362
|
+
{
|
|
1363
|
+
displayName: 'Content',
|
|
1364
|
+
name: 'qrContent',
|
|
1365
|
+
type: 'string',
|
|
1366
|
+
required: true,
|
|
1367
|
+
displayOptions: {
|
|
1368
|
+
show: {
|
|
1369
|
+
resource: ['asset'],
|
|
1370
|
+
operation: ['generateQRCode'],
|
|
1371
|
+
},
|
|
1372
|
+
},
|
|
1373
|
+
default: '',
|
|
1374
|
+
description: 'The content to encode in the QR code (URL, text, etc.)',
|
|
1375
|
+
placeholder: 'https://example.com',
|
|
1376
|
+
},
|
|
1377
|
+
{
|
|
1378
|
+
displayName: 'Output Format',
|
|
1379
|
+
name: 'qrOutputFormat',
|
|
1380
|
+
type: 'options',
|
|
1381
|
+
options: [
|
|
1382
|
+
{
|
|
1383
|
+
name: 'Base64 (JSON)',
|
|
1384
|
+
value: 'base64',
|
|
1385
|
+
description: 'Returns JSON response with base64 encoded PNG image',
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
name: 'File (Binary)',
|
|
1389
|
+
value: 'file',
|
|
1390
|
+
description: 'Returns binary PNG image file data',
|
|
1391
|
+
},
|
|
1392
|
+
],
|
|
1393
|
+
default: 'base64',
|
|
1394
|
+
displayOptions: {
|
|
1395
|
+
show: {
|
|
1396
|
+
resource: ['asset'],
|
|
1397
|
+
operation: ['generateQRCode'],
|
|
1398
|
+
},
|
|
1399
|
+
},
|
|
1400
|
+
description: 'Choose output format for the QR code',
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
displayName: 'Logo Source',
|
|
1404
|
+
name: 'logoSource',
|
|
1405
|
+
type: 'options',
|
|
1406
|
+
options: [
|
|
1407
|
+
{
|
|
1408
|
+
name: 'None',
|
|
1409
|
+
value: 'none',
|
|
1410
|
+
},
|
|
1411
|
+
{
|
|
1412
|
+
name: 'From URL',
|
|
1413
|
+
value: 'url',
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
name: 'From Base64',
|
|
1417
|
+
value: 'base64',
|
|
1418
|
+
},
|
|
1419
|
+
],
|
|
1420
|
+
default: 'none',
|
|
1421
|
+
displayOptions: {
|
|
1422
|
+
show: {
|
|
1423
|
+
resource: ['asset'],
|
|
1424
|
+
operation: ['generateQRCode'],
|
|
1425
|
+
},
|
|
1426
|
+
},
|
|
1427
|
+
description: 'Add a logo to the QR code',
|
|
1428
|
+
},
|
|
1429
|
+
{
|
|
1430
|
+
displayName: 'Logo URL',
|
|
1431
|
+
name: 'logo_url',
|
|
1432
|
+
type: 'string',
|
|
1433
|
+
displayOptions: {
|
|
1434
|
+
show: {
|
|
1435
|
+
resource: ['asset'],
|
|
1436
|
+
operation: ['generateQRCode'],
|
|
1437
|
+
logoSource: ['url'],
|
|
1438
|
+
},
|
|
1439
|
+
},
|
|
1440
|
+
default: '',
|
|
1441
|
+
description: 'Logo URL to an image to add on the QR code',
|
|
1442
|
+
placeholder: 'https://example.com/logo.png',
|
|
1443
|
+
},
|
|
1444
|
+
{
|
|
1445
|
+
displayName: 'Logo Base64',
|
|
1446
|
+
name: 'logo_base64',
|
|
1447
|
+
type: 'string',
|
|
1448
|
+
typeOptions: {
|
|
1449
|
+
rows: 4,
|
|
1450
|
+
},
|
|
1451
|
+
displayOptions: {
|
|
1452
|
+
show: {
|
|
1453
|
+
resource: ['asset'],
|
|
1454
|
+
operation: ['generateQRCode'],
|
|
1455
|
+
logoSource: ['base64'],
|
|
1456
|
+
},
|
|
1457
|
+
},
|
|
1458
|
+
default: '',
|
|
1459
|
+
description: 'Logo as a base64 image string to add on the QR code',
|
|
1460
|
+
placeholder: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB...',
|
|
1461
|
+
},
|
|
1462
|
+
{
|
|
1463
|
+
displayName: 'Additional Options',
|
|
1464
|
+
name: 'qrCodeOptions',
|
|
1465
|
+
type: 'collection',
|
|
1466
|
+
placeholder: 'Add Option',
|
|
1467
|
+
default: {},
|
|
1468
|
+
displayOptions: {
|
|
1469
|
+
show: {
|
|
1470
|
+
resource: ['asset'],
|
|
1471
|
+
operation: ['generateQRCode'],
|
|
1472
|
+
},
|
|
1473
|
+
},
|
|
1474
|
+
description: 'Additional options for QR code generation',
|
|
1475
|
+
options: [
|
|
1476
|
+
{
|
|
1477
|
+
displayName: 'Color',
|
|
1478
|
+
name: 'color',
|
|
1479
|
+
type: 'color',
|
|
1480
|
+
default: '#000000',
|
|
1481
|
+
description: 'QR code color in hexadecimal format',
|
|
1482
|
+
},
|
|
1483
|
+
],
|
|
1484
|
+
},
|
|
1280
1485
|
{
|
|
1281
1486
|
displayName: 'HTML Content',
|
|
1282
1487
|
name: 'htmlContent',
|
|
@@ -1536,6 +1741,260 @@ class PdfGeneratorApi {
|
|
|
1536
1741
|
},
|
|
1537
1742
|
],
|
|
1538
1743
|
},
|
|
1744
|
+
{
|
|
1745
|
+
displayName: 'Template',
|
|
1746
|
+
name: 'templateId',
|
|
1747
|
+
type: 'resourceLocator',
|
|
1748
|
+
default: { mode: 'list', value: '' },
|
|
1749
|
+
required: true,
|
|
1750
|
+
displayOptions: {
|
|
1751
|
+
show: {
|
|
1752
|
+
resource: ['einvoice'],
|
|
1753
|
+
operation: ['createFacturX'],
|
|
1754
|
+
},
|
|
1755
|
+
},
|
|
1756
|
+
modes: [
|
|
1757
|
+
{
|
|
1758
|
+
displayName: 'From List',
|
|
1759
|
+
name: 'list',
|
|
1760
|
+
type: 'list',
|
|
1761
|
+
hint: 'Select a template from the list',
|
|
1762
|
+
typeOptions: {
|
|
1763
|
+
searchListMethod: 'searchTemplates',
|
|
1764
|
+
searchable: true,
|
|
1765
|
+
searchFilterRequired: false,
|
|
1766
|
+
},
|
|
1767
|
+
},
|
|
1768
|
+
{
|
|
1769
|
+
displayName: 'By ID',
|
|
1770
|
+
name: 'id',
|
|
1771
|
+
type: 'string',
|
|
1772
|
+
hint: 'Enter the template ID directly',
|
|
1773
|
+
validation: [
|
|
1774
|
+
{
|
|
1775
|
+
type: 'regex',
|
|
1776
|
+
properties: {
|
|
1777
|
+
regex: '^[0-9]+$',
|
|
1778
|
+
errorMessage: 'Template ID must be a number',
|
|
1779
|
+
},
|
|
1780
|
+
},
|
|
1781
|
+
],
|
|
1782
|
+
},
|
|
1783
|
+
],
|
|
1784
|
+
description: 'Template used to render the PDF half of the Factur-X file. Use a template whose fields are mapped to UBL element names, because a friendly-name stock template renders blank here.',
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
displayName: 'Invoice Data',
|
|
1788
|
+
name: 'einvoiceData',
|
|
1789
|
+
type: 'json',
|
|
1790
|
+
required: true,
|
|
1791
|
+
default: '{}',
|
|
1792
|
+
displayOptions: {
|
|
1793
|
+
show: {
|
|
1794
|
+
resource: ['einvoice'],
|
|
1795
|
+
operation: ['createEInvoice', 'createXRechnung', 'createFacturX'],
|
|
1796
|
+
},
|
|
1797
|
+
},
|
|
1798
|
+
description: 'Peppol BIS Billing 3.0 UBL invoice payload. Run Get Schema for the full structure. For Factur-X it is used both to render the template and to build the embedded CII XML.',
|
|
1799
|
+
},
|
|
1800
|
+
{
|
|
1801
|
+
displayName: 'Formatting Type',
|
|
1802
|
+
name: 'einvoiceType',
|
|
1803
|
+
type: 'options',
|
|
1804
|
+
options: [
|
|
1805
|
+
{
|
|
1806
|
+
name: 'CII',
|
|
1807
|
+
value: 'CII',
|
|
1808
|
+
description: 'Cross Industry Invoice XML',
|
|
1809
|
+
},
|
|
1810
|
+
{
|
|
1811
|
+
name: 'UBL',
|
|
1812
|
+
value: 'UBL',
|
|
1813
|
+
description: 'Universal Business Language XML',
|
|
1814
|
+
},
|
|
1815
|
+
],
|
|
1816
|
+
default: 'UBL',
|
|
1817
|
+
displayOptions: {
|
|
1818
|
+
show: {
|
|
1819
|
+
resource: ['einvoice'],
|
|
1820
|
+
operation: ['createEInvoice', 'createXRechnung'],
|
|
1821
|
+
},
|
|
1822
|
+
},
|
|
1823
|
+
description: 'XML syntax of the generated e-invoice',
|
|
1824
|
+
},
|
|
1825
|
+
{
|
|
1826
|
+
displayName: 'Output',
|
|
1827
|
+
name: 'einvoiceOutput',
|
|
1828
|
+
type: 'options',
|
|
1829
|
+
options: [
|
|
1830
|
+
{
|
|
1831
|
+
name: 'Base64 (JSON)',
|
|
1832
|
+
value: 'base64',
|
|
1833
|
+
description: 'The API returns the XML as base64. The node attaches it decoded as binary and returns the metadata as JSON.',
|
|
1834
|
+
},
|
|
1835
|
+
{
|
|
1836
|
+
name: 'File (Binary)',
|
|
1837
|
+
value: 'file',
|
|
1838
|
+
description: 'Returns the XML inline as binary data',
|
|
1839
|
+
},
|
|
1840
|
+
],
|
|
1841
|
+
default: 'base64',
|
|
1842
|
+
displayOptions: {
|
|
1843
|
+
show: {
|
|
1844
|
+
resource: ['einvoice'],
|
|
1845
|
+
operation: ['createEInvoice', 'createXRechnung'],
|
|
1846
|
+
},
|
|
1847
|
+
},
|
|
1848
|
+
description: 'Response format. Either way the XML is attached as a binary item named "data".',
|
|
1849
|
+
},
|
|
1850
|
+
{
|
|
1851
|
+
displayName: 'Additional Fields',
|
|
1852
|
+
name: 'einvoiceAdditionalFields',
|
|
1853
|
+
type: 'collection',
|
|
1854
|
+
placeholder: 'Add Field',
|
|
1855
|
+
default: {},
|
|
1856
|
+
displayOptions: {
|
|
1857
|
+
show: {
|
|
1858
|
+
resource: ['einvoice'],
|
|
1859
|
+
operation: ['createEInvoice', 'createXRechnung'],
|
|
1860
|
+
},
|
|
1861
|
+
},
|
|
1862
|
+
options: [
|
|
1863
|
+
{
|
|
1864
|
+
displayName: 'File Name',
|
|
1865
|
+
name: 'outputName',
|
|
1866
|
+
type: 'string',
|
|
1867
|
+
default: '',
|
|
1868
|
+
placeholder: 'e.g. Invoice 123',
|
|
1869
|
+
description: 'Name of the attached XML file, without the extension. Defaults to the operation and syntax, e.g. einvoice-ubl, so set it when a workflow stores many invoices in one place.',
|
|
1870
|
+
},
|
|
1871
|
+
],
|
|
1872
|
+
},
|
|
1873
|
+
{
|
|
1874
|
+
displayName: 'Profile',
|
|
1875
|
+
name: 'facturxProfile',
|
|
1876
|
+
type: 'options',
|
|
1877
|
+
options: [
|
|
1878
|
+
{
|
|
1879
|
+
name: 'Basic',
|
|
1880
|
+
value: 'basic',
|
|
1881
|
+
description: 'Core invoice data. Drops item level attributes such as AdditionalItemProperty.',
|
|
1882
|
+
},
|
|
1883
|
+
{
|
|
1884
|
+
name: 'Basic WL',
|
|
1885
|
+
value: 'basicwl',
|
|
1886
|
+
description: 'Basic without lines, for accounting entry only',
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
name: 'EN 16931',
|
|
1890
|
+
value: 'en16931',
|
|
1891
|
+
description: 'Full EN 16931 semantic model. Keeps item level attributes.',
|
|
1892
|
+
},
|
|
1893
|
+
{
|
|
1894
|
+
name: 'Extended',
|
|
1895
|
+
value: 'extended',
|
|
1896
|
+
description: 'EN 16931 plus extensions. Keeps item level attributes.',
|
|
1897
|
+
},
|
|
1898
|
+
{
|
|
1899
|
+
name: 'Minimum',
|
|
1900
|
+
value: 'minimum',
|
|
1901
|
+
description: 'Header data only, not a compliant invoice in most jurisdictions',
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
name: 'XRechnung',
|
|
1905
|
+
value: 'xrechnung',
|
|
1906
|
+
description: 'German XRechnung CIUS on top of EN 16931',
|
|
1907
|
+
},
|
|
1908
|
+
],
|
|
1909
|
+
default: 'en16931',
|
|
1910
|
+
displayOptions: {
|
|
1911
|
+
show: {
|
|
1912
|
+
resource: ['einvoice'],
|
|
1913
|
+
operation: ['createFacturX'],
|
|
1914
|
+
},
|
|
1915
|
+
},
|
|
1916
|
+
description: 'Factur-X conformance level. Defaults to EN 16931, which keeps per-line attributes. Basic and the lower levels carry less of the invoice in the embedded XML.',
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
displayName: 'Output',
|
|
1920
|
+
name: 'facturxOutput',
|
|
1921
|
+
type: 'options',
|
|
1922
|
+
options: [
|
|
1923
|
+
{
|
|
1924
|
+
name: 'Base64 (JSON)',
|
|
1925
|
+
value: 'base64',
|
|
1926
|
+
description: 'The API returns the PDF as base64. The node attaches it decoded as binary and returns the metadata as JSON.',
|
|
1927
|
+
},
|
|
1928
|
+
{
|
|
1929
|
+
name: 'File (Binary)',
|
|
1930
|
+
value: 'file',
|
|
1931
|
+
description: 'Returns the PDF inline as binary data',
|
|
1932
|
+
},
|
|
1933
|
+
{
|
|
1934
|
+
name: 'URL',
|
|
1935
|
+
value: 'url',
|
|
1936
|
+
description: 'Stores the document for 30 days and returns a link',
|
|
1937
|
+
},
|
|
1938
|
+
{
|
|
1939
|
+
name: 'Viewer URL',
|
|
1940
|
+
value: 'viewer',
|
|
1941
|
+
description: 'Stores the document for 30 days and returns a viewer link',
|
|
1942
|
+
},
|
|
1943
|
+
],
|
|
1944
|
+
default: 'base64',
|
|
1945
|
+
displayOptions: {
|
|
1946
|
+
show: {
|
|
1947
|
+
resource: ['einvoice'],
|
|
1948
|
+
operation: ['createFacturX'],
|
|
1949
|
+
},
|
|
1950
|
+
},
|
|
1951
|
+
description: 'Response format. Base64 and File both attach the PDF as a binary item named "data".',
|
|
1952
|
+
},
|
|
1953
|
+
{
|
|
1954
|
+
displayName: 'Additional Fields',
|
|
1955
|
+
name: 'facturxAdditionalFields',
|
|
1956
|
+
type: 'collection',
|
|
1957
|
+
placeholder: 'Add Field',
|
|
1958
|
+
default: {},
|
|
1959
|
+
displayOptions: {
|
|
1960
|
+
show: {
|
|
1961
|
+
resource: ['einvoice'],
|
|
1962
|
+
operation: ['createFacturX'],
|
|
1963
|
+
},
|
|
1964
|
+
},
|
|
1965
|
+
options: [
|
|
1966
|
+
{
|
|
1967
|
+
displayName: 'Author',
|
|
1968
|
+
name: 'author',
|
|
1969
|
+
type: 'string',
|
|
1970
|
+
default: '',
|
|
1971
|
+
description: 'Document author written into the PDF metadata',
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
displayName: 'Document Name',
|
|
1975
|
+
name: 'outputName',
|
|
1976
|
+
type: 'string',
|
|
1977
|
+
default: '',
|
|
1978
|
+
placeholder: 'e.g. Invoice 123',
|
|
1979
|
+
description: 'Name of the generated document. The API generates one when this is empty.',
|
|
1980
|
+
},
|
|
1981
|
+
{
|
|
1982
|
+
displayName: 'Language',
|
|
1983
|
+
name: 'language',
|
|
1984
|
+
type: 'string',
|
|
1985
|
+
default: '',
|
|
1986
|
+
placeholder: 'e.g. en',
|
|
1987
|
+
description: 'Document language written into the PDF metadata',
|
|
1988
|
+
},
|
|
1989
|
+
{
|
|
1990
|
+
displayName: 'Template Version ID',
|
|
1991
|
+
name: 'versionId',
|
|
1992
|
+
type: 'number',
|
|
1993
|
+
default: 0,
|
|
1994
|
+
description: 'Pin generation to a specific template version instead of the current one',
|
|
1995
|
+
},
|
|
1996
|
+
],
|
|
1997
|
+
},
|
|
1539
1998
|
],
|
|
1540
1999
|
};
|
|
1541
2000
|
this.methods = {
|
|
@@ -1596,6 +2055,29 @@ class PdfGeneratorApi {
|
|
|
1596
2055
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `${field} must be valid JSON`);
|
|
1597
2056
|
}
|
|
1598
2057
|
};
|
|
2058
|
+
const validationDetails = (messages, message) => {
|
|
2059
|
+
if (!Array.isArray(messages))
|
|
2060
|
+
return '';
|
|
2061
|
+
for (const entry of messages) {
|
|
2062
|
+
if (typeof entry !== 'string' || entry.indexOf('{') === -1)
|
|
2063
|
+
continue;
|
|
2064
|
+
try {
|
|
2065
|
+
const body = JSON.parse(entry.slice(entry.indexOf('{')));
|
|
2066
|
+
const errors = body && body.errors;
|
|
2067
|
+
if (!errors || typeof errors !== 'object')
|
|
2068
|
+
continue;
|
|
2069
|
+
const parts = (Array.isArray(errors) ? errors.map((e) => ['', e]) : Object.entries(errors))
|
|
2070
|
+
.map(([field, e]) => [field, [].concat(e).map(String).filter((t) => !message.includes(t)).join(' ')])
|
|
2071
|
+
.filter(([, text]) => text)
|
|
2072
|
+
.map(([field, text]) => (field ? `${field}: ${text}` : text));
|
|
2073
|
+
if (parts.length)
|
|
2074
|
+
return ` (${parts.join('; ')})`;
|
|
2075
|
+
}
|
|
2076
|
+
catch (error) {
|
|
2077
|
+
}
|
|
2078
|
+
}
|
|
2079
|
+
return '';
|
|
2080
|
+
};
|
|
1599
2081
|
const getMimeType = (format) => {
|
|
1600
2082
|
switch (format) {
|
|
1601
2083
|
case 'pdf':
|
|
@@ -1609,7 +2091,203 @@ class PdfGeneratorApi {
|
|
|
1609
2091
|
for (let i = 0; i < items.length; i++) {
|
|
1610
2092
|
try {
|
|
1611
2093
|
let responseData;
|
|
1612
|
-
if (resource === '
|
|
2094
|
+
if (resource === 'asset') {
|
|
2095
|
+
if (operation === 'generateQRCode') {
|
|
2096
|
+
const qrContent = this.getNodeParameter('qrContent', i);
|
|
2097
|
+
const qrOutputFormat = this.getNodeParameter('qrOutputFormat', i, 'base64');
|
|
2098
|
+
const logoSource = this.getNodeParameter('logoSource', i, 'none');
|
|
2099
|
+
const qrCodeOptions = this.getNodeParameter('qrCodeOptions', i, {});
|
|
2100
|
+
if (!qrContent || qrContent.trim() === '') {
|
|
2101
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Content is required for QR code generation', { itemIndex: i });
|
|
2102
|
+
}
|
|
2103
|
+
const body = {
|
|
2104
|
+
content: qrContent,
|
|
2105
|
+
output: qrOutputFormat,
|
|
2106
|
+
};
|
|
2107
|
+
if (qrCodeOptions.color)
|
|
2108
|
+
body.color = qrCodeOptions.color;
|
|
2109
|
+
if (logoSource === 'base64') {
|
|
2110
|
+
const logoBase64 = this.getNodeParameter('logo_base64', i, '');
|
|
2111
|
+
if (logoBase64)
|
|
2112
|
+
body.logo_base64 = logoBase64;
|
|
2113
|
+
}
|
|
2114
|
+
else if (logoSource === 'url') {
|
|
2115
|
+
const logoUrl = this.getNodeParameter('logo_url', i, '');
|
|
2116
|
+
if (logoUrl)
|
|
2117
|
+
body.logo_url = logoUrl;
|
|
2118
|
+
}
|
|
2119
|
+
const options = {
|
|
2120
|
+
method: 'POST',
|
|
2121
|
+
baseURL,
|
|
2122
|
+
url: '/assets/qrcode',
|
|
2123
|
+
body,
|
|
2124
|
+
json: qrOutputFormat !== 'file',
|
|
2125
|
+
encoding: qrOutputFormat === 'file' ? null : 'utf8',
|
|
2126
|
+
};
|
|
2127
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
|
|
2128
|
+
if (responseData) {
|
|
2129
|
+
if (qrOutputFormat === 'file') {
|
|
2130
|
+
const binaryData = {};
|
|
2131
|
+
const fileName = 'qrcode.png';
|
|
2132
|
+
binaryData[fileName] = await this.helpers.prepareBinaryData(responseData, fileName, 'image/png');
|
|
2133
|
+
returnData.push({
|
|
2134
|
+
json: {
|
|
2135
|
+
success: true,
|
|
2136
|
+
filename: fileName,
|
|
2137
|
+
format: qrOutputFormat,
|
|
2138
|
+
fileSize: responseData.length,
|
|
2139
|
+
},
|
|
2140
|
+
binary: binaryData,
|
|
2141
|
+
});
|
|
2142
|
+
}
|
|
2143
|
+
else {
|
|
2144
|
+
returnData.push({
|
|
2145
|
+
json: {
|
|
2146
|
+
success: true,
|
|
2147
|
+
format: qrOutputFormat,
|
|
2148
|
+
...responseData,
|
|
2149
|
+
},
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
else if (resource === 'einvoice') {
|
|
2157
|
+
const callEInvoice = async (requestOptions) => {
|
|
2158
|
+
try {
|
|
2159
|
+
return await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', requestOptions);
|
|
2160
|
+
}
|
|
2161
|
+
catch (error) {
|
|
2162
|
+
if (error.httpCode !== undefined) {
|
|
2163
|
+
const description = typeof error.description === 'string' ? error.description : '';
|
|
2164
|
+
if (description && !description.trimStart().startsWith('<')) {
|
|
2165
|
+
error.message = `PDF Generator API e-invoice request failed: ${description}${validationDetails(error.messages, description)}`;
|
|
2166
|
+
}
|
|
2167
|
+
error.context = { ...(error.context || {}), itemIndex: i };
|
|
2168
|
+
}
|
|
2169
|
+
throw error;
|
|
2170
|
+
}
|
|
2171
|
+
};
|
|
2172
|
+
const pushDocument = async (payload, output, fallbackName, fallbackMimeType) => {
|
|
2173
|
+
if (output === 'file') {
|
|
2174
|
+
const binary = {};
|
|
2175
|
+
binary.data = await this.helpers.prepareBinaryData(payload, fallbackName, fallbackMimeType);
|
|
2176
|
+
returnData.push({
|
|
2177
|
+
json: {
|
|
2178
|
+
success: true,
|
|
2179
|
+
filename: fallbackName,
|
|
2180
|
+
format: output,
|
|
2181
|
+
fileSize: payload.length,
|
|
2182
|
+
},
|
|
2183
|
+
binary,
|
|
2184
|
+
});
|
|
2185
|
+
return;
|
|
2186
|
+
}
|
|
2187
|
+
const { response, ...rest } = payload;
|
|
2188
|
+
const meta = payload.meta || {};
|
|
2189
|
+
const fileName = meta.name || fallbackName;
|
|
2190
|
+
const mimeType = meta['content-type'] || fallbackMimeType;
|
|
2191
|
+
const binary = {};
|
|
2192
|
+
binary.data = await this.helpers.prepareBinaryData(Buffer.from(response, 'base64'), fileName, mimeType);
|
|
2193
|
+
returnData.push({
|
|
2194
|
+
json: {
|
|
2195
|
+
success: true,
|
|
2196
|
+
filename: fileName,
|
|
2197
|
+
format: output,
|
|
2198
|
+
...rest,
|
|
2199
|
+
},
|
|
2200
|
+
binary,
|
|
2201
|
+
});
|
|
2202
|
+
};
|
|
2203
|
+
if (operation === 'createEInvoice' || operation === 'createXRechnung') {
|
|
2204
|
+
const data = this.getNodeParameter('einvoiceData', i);
|
|
2205
|
+
const output = this.getNodeParameter('einvoiceOutput', i, 'base64');
|
|
2206
|
+
const additionalFields = this.getNodeParameter('einvoiceAdditionalFields', i, {});
|
|
2207
|
+
const type = String(this.getNodeParameter('einvoiceType', i, 'UBL') || 'UBL').toUpperCase();
|
|
2208
|
+
if (!['UBL', 'CII'].includes(type)) {
|
|
2209
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Formatting Type must be UBL or CII, got "${type}"`, {
|
|
2210
|
+
itemIndex: i,
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
const body = {
|
|
2214
|
+
data: parseJSON(data, 'Invoice Data'),
|
|
2215
|
+
type,
|
|
2216
|
+
output,
|
|
2217
|
+
};
|
|
2218
|
+
const options = {
|
|
2219
|
+
method: 'POST',
|
|
2220
|
+
baseURL,
|
|
2221
|
+
url: operation === 'createXRechnung' ? '/einvoice/xrechnung' : '/einvoice',
|
|
2222
|
+
body,
|
|
2223
|
+
json: output !== 'file',
|
|
2224
|
+
encoding: output === 'file' ? null : 'utf8',
|
|
2225
|
+
};
|
|
2226
|
+
responseData = await callEInvoice(options);
|
|
2227
|
+
if (responseData) {
|
|
2228
|
+
const prefix = operation === 'createXRechnung' ? 'xrechnung' : 'einvoice';
|
|
2229
|
+
const baseName = String(additionalFields.outputName || `${prefix}-${type.toLowerCase()}`).replace(/\.xml$/i, '');
|
|
2230
|
+
await pushDocument(responseData, output, `${baseName}.xml`, 'application/xml');
|
|
2231
|
+
continue;
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
else if (operation === 'createFacturX') {
|
|
2235
|
+
const templateIdParam = this.getNodeParameter('templateId', i);
|
|
2236
|
+
const templateId = typeof templateIdParam === 'string' ? templateIdParam : templateIdParam.value;
|
|
2237
|
+
const data = this.getNodeParameter('einvoiceData', i);
|
|
2238
|
+
const profile = this.getNodeParameter('facturxProfile', i, 'en16931');
|
|
2239
|
+
const output = this.getNodeParameter('facturxOutput', i, 'base64');
|
|
2240
|
+
const additionalFields = this.getNodeParameter('facturxAdditionalFields', i, {});
|
|
2241
|
+
const id = Number(templateId);
|
|
2242
|
+
if (!templateId || !Number.isInteger(id) || id <= 0) {
|
|
2243
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Template is required for Factur-X and must be a numeric ID', { itemIndex: i });
|
|
2244
|
+
}
|
|
2245
|
+
const template = {
|
|
2246
|
+
id,
|
|
2247
|
+
data: parseJSON(data, 'Invoice Data'),
|
|
2248
|
+
};
|
|
2249
|
+
if (additionalFields.versionId)
|
|
2250
|
+
template.version_id = Number(additionalFields.versionId);
|
|
2251
|
+
const body = {
|
|
2252
|
+
template,
|
|
2253
|
+
profile,
|
|
2254
|
+
output,
|
|
2255
|
+
};
|
|
2256
|
+
if (additionalFields.outputName)
|
|
2257
|
+
body.name = additionalFields.outputName;
|
|
2258
|
+
if (additionalFields.author || additionalFields.language) {
|
|
2259
|
+
body.metadata = {};
|
|
2260
|
+
if (additionalFields.author)
|
|
2261
|
+
body.metadata.author = additionalFields.author;
|
|
2262
|
+
if (additionalFields.language)
|
|
2263
|
+
body.metadata.language = additionalFields.language;
|
|
2264
|
+
}
|
|
2265
|
+
const options = {
|
|
2266
|
+
method: 'POST',
|
|
2267
|
+
baseURL,
|
|
2268
|
+
url: '/einvoice/facturx',
|
|
2269
|
+
body,
|
|
2270
|
+
json: output !== 'file',
|
|
2271
|
+
encoding: output === 'file' ? null : 'utf8',
|
|
2272
|
+
};
|
|
2273
|
+
responseData = await callEInvoice(options);
|
|
2274
|
+
if (responseData && (output === 'base64' || output === 'file')) {
|
|
2275
|
+
const fallbackName = `${additionalFields.outputName || 'facturx-invoice'}.pdf`;
|
|
2276
|
+
await pushDocument(responseData, output, fallbackName, 'application/pdf');
|
|
2277
|
+
continue;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
else if (operation === 'getEInvoiceSchema') {
|
|
2281
|
+
const options = {
|
|
2282
|
+
method: 'GET',
|
|
2283
|
+
baseURL,
|
|
2284
|
+
url: '/einvoice/schema',
|
|
2285
|
+
json: true,
|
|
2286
|
+
};
|
|
2287
|
+
responseData = await callEInvoice(options);
|
|
2288
|
+
}
|
|
2289
|
+
}
|
|
2290
|
+
else if (resource === 'conversion') {
|
|
1613
2291
|
const conversionOptions = this.getNodeParameter('conversionOptions', i, {});
|
|
1614
2292
|
const filename = this.getNodeParameter('filename', i);
|
|
1615
2293
|
if (!filename || filename.trim() === '') {
|
|
@@ -1770,7 +2448,7 @@ class PdfGeneratorApi {
|
|
|
1770
2448
|
encoding: output === 'file' ? null : 'utf8',
|
|
1771
2449
|
};
|
|
1772
2450
|
responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
|
|
1773
|
-
if (responseData && output !== 'url') {
|
|
2451
|
+
if (responseData && output !== 'url' && output !== 'viewer') {
|
|
1774
2452
|
if (output === 'file') {
|
|
1775
2453
|
const binaryData = {};
|
|
1776
2454
|
const fileName = `${additionalFields.outputName || 'document'}.${format}`;
|
|
@@ -1866,7 +2544,7 @@ class PdfGeneratorApi {
|
|
|
1866
2544
|
encoding: output === 'file' ? null : 'utf8',
|
|
1867
2545
|
};
|
|
1868
2546
|
responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
|
|
1869
|
-
if (responseData && output !== 'url') {
|
|
2547
|
+
if (responseData && output !== 'url' && output !== 'viewer') {
|
|
1870
2548
|
if (output === 'file') {
|
|
1871
2549
|
const binaryData = {};
|
|
1872
2550
|
const fileName = `${additionalFields.outputName || 'batch-documents'}.${format}`;
|
|
@@ -2037,6 +2715,15 @@ class PdfGeneratorApi {
|
|
|
2037
2715
|
};
|
|
2038
2716
|
responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
|
|
2039
2717
|
}
|
|
2718
|
+
else if (operation === 'getTemplateSchema') {
|
|
2719
|
+
const options = {
|
|
2720
|
+
method: 'GET',
|
|
2721
|
+
baseURL,
|
|
2722
|
+
url: '/templates/schema',
|
|
2723
|
+
json: true,
|
|
2724
|
+
};
|
|
2725
|
+
responseData = await this.helpers.requestWithAuthentication.call(this, 'pdfGeneratorApi', options);
|
|
2726
|
+
}
|
|
2040
2727
|
else if (operation === 'copy') {
|
|
2041
2728
|
const templateIdParam = this.getNodeParameter('templateId', i);
|
|
2042
2729
|
const templateId = typeof templateIdParam === 'string' ? templateIdParam : templateIdParam.value;
|