n8n-nodes-pdfvector 0.8.2 → 0.8.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.
|
@@ -11,7 +11,7 @@ class PdfVector {
|
|
|
11
11
|
group: ['transform'],
|
|
12
12
|
version: 1,
|
|
13
13
|
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
|
14
|
-
description: '
|
|
14
|
+
description: 'Convert PDFs, Word, Excel documents, and images to clean markdown, extract structured data with AI, process invoices with specialized parsing, and search millions of academic papers across PubMed, ArXiv, Google Scholar, and more.',
|
|
15
15
|
defaults: {
|
|
16
16
|
name: 'PDF Vector',
|
|
17
17
|
},
|
|
@@ -40,6 +40,14 @@ class PdfVector {
|
|
|
40
40
|
name: 'Document',
|
|
41
41
|
value: 'document',
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
name: 'Identity Document',
|
|
45
|
+
value: 'identityDocument',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'Invoice',
|
|
49
|
+
value: 'invoice',
|
|
50
|
+
},
|
|
43
51
|
],
|
|
44
52
|
default: 'academic',
|
|
45
53
|
},
|
|
@@ -57,13 +65,13 @@ class PdfVector {
|
|
|
57
65
|
{
|
|
58
66
|
name: 'Search',
|
|
59
67
|
value: 'search',
|
|
60
|
-
description: 'Search
|
|
68
|
+
description: 'Search across PubMed, ArXiv, Google Scholar, and more',
|
|
61
69
|
action: 'Search academic publications',
|
|
62
70
|
},
|
|
63
71
|
{
|
|
64
72
|
name: 'Fetch',
|
|
65
73
|
value: 'fetch',
|
|
66
|
-
description: 'Fetch
|
|
74
|
+
description: 'Fetch publications by DOI, PubMed ID, ArXiv ID, etc',
|
|
67
75
|
action: 'Fetch a specific publication',
|
|
68
76
|
},
|
|
69
77
|
],
|
|
@@ -83,24 +91,88 @@ class PdfVector {
|
|
|
83
91
|
{
|
|
84
92
|
name: 'Parse',
|
|
85
93
|
value: 'parse',
|
|
86
|
-
description: '
|
|
94
|
+
description: 'Convert PDFs, Word, Excel, or images to markdown',
|
|
87
95
|
action: 'Parse a document',
|
|
88
96
|
},
|
|
89
97
|
{
|
|
90
98
|
name: 'Ask',
|
|
91
99
|
value: 'ask',
|
|
92
|
-
description: 'Ask questions about
|
|
100
|
+
description: 'Ask questions about PDF, Word, Excel, or image',
|
|
93
101
|
action: 'Ask questions about a document',
|
|
94
102
|
},
|
|
95
103
|
{
|
|
96
104
|
name: 'Extract',
|
|
97
105
|
value: 'extract',
|
|
98
|
-
description: 'Extract structured data from
|
|
106
|
+
description: 'Extract structured data from PDF, Word, Excel, or image using JSON Schema',
|
|
99
107
|
action: 'Extract structured data from a document',
|
|
100
108
|
},
|
|
101
109
|
],
|
|
102
110
|
default: 'parse',
|
|
103
111
|
},
|
|
112
|
+
{
|
|
113
|
+
displayName: 'Operation',
|
|
114
|
+
name: 'operation',
|
|
115
|
+
type: 'options',
|
|
116
|
+
noDataExpression: true,
|
|
117
|
+
displayOptions: {
|
|
118
|
+
show: {
|
|
119
|
+
resource: ['invoice'],
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
options: [
|
|
123
|
+
{
|
|
124
|
+
name: 'Parse',
|
|
125
|
+
value: 'parse',
|
|
126
|
+
description: 'Parse invoice, expense, bank statement or financial document',
|
|
127
|
+
action: 'Parse an invoice',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
name: 'Ask',
|
|
131
|
+
value: 'ask',
|
|
132
|
+
description: 'Ask questions about invoice, expense, bank statement or financial document',
|
|
133
|
+
action: 'Ask questions about an invoice',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'Extract',
|
|
137
|
+
value: 'extract',
|
|
138
|
+
description: 'Extract invoice, expense, bank statement or financial document structured data',
|
|
139
|
+
action: 'Extract structured data from an invoice',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
default: 'parse',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
displayName: 'Operation',
|
|
146
|
+
name: 'operation',
|
|
147
|
+
type: 'options',
|
|
148
|
+
noDataExpression: true,
|
|
149
|
+
displayOptions: {
|
|
150
|
+
show: {
|
|
151
|
+
resource: ['identityDocument'],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
options: [
|
|
155
|
+
{
|
|
156
|
+
name: 'Parse',
|
|
157
|
+
value: 'parse',
|
|
158
|
+
description: 'Parse identity documents (passports, driver licenses, ID cards, national IDs) to markdown',
|
|
159
|
+
action: 'Parse an identity document',
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: 'Ask',
|
|
163
|
+
value: 'ask',
|
|
164
|
+
description: 'Ask questions about identity document content',
|
|
165
|
+
action: 'Ask questions about an identity document',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'Extract',
|
|
169
|
+
value: 'extract',
|
|
170
|
+
description: 'Extract structured data from identity documents using JSON Schema',
|
|
171
|
+
action: 'Extract structured data from an identity document',
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
default: 'parse',
|
|
175
|
+
},
|
|
104
176
|
{
|
|
105
177
|
displayName: 'Query',
|
|
106
178
|
name: 'query',
|
|
@@ -113,7 +185,8 @@ class PdfVector {
|
|
|
113
185
|
},
|
|
114
186
|
},
|
|
115
187
|
default: '',
|
|
116
|
-
description: 'Search query for academic publications',
|
|
188
|
+
description: 'Search query for academic publications (1-400 characters)',
|
|
189
|
+
placeholder: 'machine learning in healthcare',
|
|
117
190
|
},
|
|
118
191
|
{
|
|
119
192
|
displayName: 'Providers',
|
|
@@ -134,10 +207,18 @@ class PdfVector {
|
|
|
134
207
|
name: 'ERIC',
|
|
135
208
|
value: 'eric',
|
|
136
209
|
},
|
|
210
|
+
{
|
|
211
|
+
name: 'Europe PMC',
|
|
212
|
+
value: 'europe-pmc',
|
|
213
|
+
},
|
|
137
214
|
{
|
|
138
215
|
name: 'Google Scholar',
|
|
139
216
|
value: 'google-scholar',
|
|
140
217
|
},
|
|
218
|
+
{
|
|
219
|
+
name: 'OpenAlex',
|
|
220
|
+
value: 'openalex',
|
|
221
|
+
},
|
|
141
222
|
{
|
|
142
223
|
name: 'PubMed',
|
|
143
224
|
value: 'pubmed',
|
|
@@ -148,7 +229,7 @@ class PdfVector {
|
|
|
148
229
|
},
|
|
149
230
|
],
|
|
150
231
|
default: ['semantic-scholar'],
|
|
151
|
-
description: '
|
|
232
|
+
description: 'Academic database providers to search. Select multiple to search across databases.',
|
|
152
233
|
},
|
|
153
234
|
{
|
|
154
235
|
displayName: 'Limit',
|
|
@@ -302,8 +383,8 @@ class PdfVector {
|
|
|
302
383
|
},
|
|
303
384
|
},
|
|
304
385
|
default: '',
|
|
305
|
-
description: 'Publication IDs
|
|
306
|
-
placeholder: '10.1038/nature12373, PMC3883140, arXiv:1234.5678',
|
|
386
|
+
description: 'Publication IDs with auto-detection. Supports DOI, PubMed ID, ArXiv ID, Semantic Scholar ID, ERIC ID, Europe PMC ID, and OpenAlex ID. Separate multiple IDs with commas (max 100).',
|
|
387
|
+
placeholder: '10.1038/nature12373, PMC3883140, arXiv:1234.5678, ED123456',
|
|
307
388
|
},
|
|
308
389
|
{
|
|
309
390
|
displayName: 'Fields',
|
|
@@ -386,12 +467,12 @@ class PdfVector {
|
|
|
386
467
|
{
|
|
387
468
|
name: 'URL',
|
|
388
469
|
value: 'url',
|
|
389
|
-
description: 'Provide a URL to the document',
|
|
470
|
+
description: 'Provide a public URL to the document',
|
|
390
471
|
},
|
|
391
472
|
{
|
|
392
473
|
name: 'File',
|
|
393
474
|
value: 'file',
|
|
394
|
-
description: 'Upload a PDF, Word
|
|
475
|
+
description: 'Upload a PDF, Word, Excel, or image file',
|
|
395
476
|
},
|
|
396
477
|
],
|
|
397
478
|
default: 'url',
|
|
@@ -410,7 +491,7 @@ class PdfVector {
|
|
|
410
491
|
},
|
|
411
492
|
},
|
|
412
493
|
default: '',
|
|
413
|
-
description: 'URL of the document
|
|
494
|
+
description: 'URL of the document to parse (PDF, Word, Excel, Image)',
|
|
414
495
|
},
|
|
415
496
|
{
|
|
416
497
|
displayName: 'Binary Property',
|
|
@@ -472,12 +553,12 @@ class PdfVector {
|
|
|
472
553
|
{
|
|
473
554
|
name: 'URL',
|
|
474
555
|
value: 'url',
|
|
475
|
-
description: 'Provide a URL to the document',
|
|
556
|
+
description: 'Provide a public URL to the document',
|
|
476
557
|
},
|
|
477
558
|
{
|
|
478
559
|
name: 'File',
|
|
479
560
|
value: 'file',
|
|
480
|
-
description: 'Upload a PDF, Word
|
|
561
|
+
description: 'Upload a PDF, Word, Excel, or image file',
|
|
481
562
|
},
|
|
482
563
|
],
|
|
483
564
|
default: 'url',
|
|
@@ -496,7 +577,7 @@ class PdfVector {
|
|
|
496
577
|
},
|
|
497
578
|
},
|
|
498
579
|
default: '',
|
|
499
|
-
description: 'URL of the document
|
|
580
|
+
description: 'URL of the document to ask questions about (PDF, Word, Excel, Image)',
|
|
500
581
|
},
|
|
501
582
|
{
|
|
502
583
|
displayName: 'Binary Property',
|
|
@@ -545,12 +626,12 @@ class PdfVector {
|
|
|
545
626
|
{
|
|
546
627
|
name: 'URL',
|
|
547
628
|
value: 'url',
|
|
548
|
-
description: 'Provide a URL to the document',
|
|
629
|
+
description: 'Provide a public URL to the document',
|
|
549
630
|
},
|
|
550
631
|
{
|
|
551
632
|
name: 'File',
|
|
552
633
|
value: 'file',
|
|
553
|
-
description: 'Upload a PDF, Word
|
|
634
|
+
description: 'Upload a PDF, Word, Excel, or image file',
|
|
554
635
|
},
|
|
555
636
|
],
|
|
556
637
|
default: 'url',
|
|
@@ -569,7 +650,7 @@ class PdfVector {
|
|
|
569
650
|
},
|
|
570
651
|
},
|
|
571
652
|
default: '',
|
|
572
|
-
description: 'URL of the document to extract data from',
|
|
653
|
+
description: 'URL of the document to extract data from (PDF, Word, Excel, Image)',
|
|
573
654
|
},
|
|
574
655
|
{
|
|
575
656
|
displayName: 'Binary Property',
|
|
@@ -623,188 +704,884 @@ class PdfVector {
|
|
|
623
704
|
},
|
|
624
705
|
hint: 'Use our free [JSON Schema Editor](https://www.pdfvector.com/json-schema-editor) to create and validate your schema.',
|
|
625
706
|
},
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
707
|
+
{
|
|
708
|
+
displayName: 'Input Type',
|
|
709
|
+
name: 'inputType',
|
|
710
|
+
type: 'options',
|
|
711
|
+
displayOptions: {
|
|
712
|
+
show: {
|
|
713
|
+
resource: ['invoice'],
|
|
714
|
+
operation: ['parse'],
|
|
715
|
+
},
|
|
716
|
+
},
|
|
717
|
+
options: [
|
|
718
|
+
{
|
|
719
|
+
name: 'URL',
|
|
720
|
+
value: 'url',
|
|
721
|
+
description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
name: 'File',
|
|
725
|
+
value: 'file',
|
|
726
|
+
description: 'Upload an invoice, expense, bank statement or financial document file',
|
|
727
|
+
},
|
|
728
|
+
],
|
|
729
|
+
default: 'url',
|
|
730
|
+
description: 'Choose how to provide the invoice',
|
|
731
|
+
},
|
|
732
|
+
{
|
|
733
|
+
displayName: 'Invoice URL',
|
|
734
|
+
name: 'url',
|
|
735
|
+
type: 'string',
|
|
736
|
+
required: true,
|
|
737
|
+
displayOptions: {
|
|
738
|
+
show: {
|
|
739
|
+
resource: ['invoice'],
|
|
740
|
+
operation: ['parse'],
|
|
741
|
+
inputType: ['url'],
|
|
742
|
+
},
|
|
743
|
+
},
|
|
744
|
+
default: '',
|
|
745
|
+
description: 'URL of the invoice, expense, bank statement or financial document to parse (PDF, Word, Image)',
|
|
746
|
+
},
|
|
747
|
+
{
|
|
748
|
+
displayName: 'Binary Property',
|
|
749
|
+
name: 'binaryPropertyName',
|
|
750
|
+
type: 'string',
|
|
751
|
+
default: 'data',
|
|
752
|
+
required: true,
|
|
753
|
+
displayOptions: {
|
|
754
|
+
show: {
|
|
755
|
+
resource: ['invoice'],
|
|
756
|
+
operation: ['parse'],
|
|
757
|
+
inputType: ['file'],
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
description: 'Name of the binary property containing the invoice file',
|
|
761
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
displayName: 'Input Type',
|
|
765
|
+
name: 'inputType',
|
|
766
|
+
type: 'options',
|
|
767
|
+
displayOptions: {
|
|
768
|
+
show: {
|
|
769
|
+
resource: ['invoice'],
|
|
770
|
+
operation: ['ask'],
|
|
771
|
+
},
|
|
772
|
+
},
|
|
773
|
+
options: [
|
|
774
|
+
{
|
|
775
|
+
name: 'URL',
|
|
776
|
+
value: 'url',
|
|
777
|
+
description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
|
|
778
|
+
},
|
|
779
|
+
{
|
|
780
|
+
name: 'File',
|
|
781
|
+
value: 'file',
|
|
782
|
+
description: 'Upload an invoice, expense, bank statement or financial document file',
|
|
783
|
+
},
|
|
784
|
+
],
|
|
785
|
+
default: 'url',
|
|
786
|
+
description: 'Choose how to provide the invoice',
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
displayName: 'Invoice URL',
|
|
790
|
+
name: 'url',
|
|
791
|
+
type: 'string',
|
|
792
|
+
required: true,
|
|
793
|
+
displayOptions: {
|
|
794
|
+
show: {
|
|
795
|
+
resource: ['invoice'],
|
|
796
|
+
operation: ['ask'],
|
|
797
|
+
inputType: ['url'],
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
default: '',
|
|
801
|
+
description: 'URL of the invoice, expense, bank statement or financial document to ask questions about (PDF, Word, Image)',
|
|
802
|
+
},
|
|
803
|
+
{
|
|
804
|
+
displayName: 'Binary Property',
|
|
805
|
+
name: 'binaryPropertyName',
|
|
806
|
+
type: 'string',
|
|
807
|
+
default: 'data',
|
|
808
|
+
required: true,
|
|
809
|
+
displayOptions: {
|
|
810
|
+
show: {
|
|
811
|
+
resource: ['invoice'],
|
|
812
|
+
operation: ['ask'],
|
|
813
|
+
inputType: ['file'],
|
|
814
|
+
},
|
|
815
|
+
},
|
|
816
|
+
description: 'Name of the binary property containing the invoice file',
|
|
817
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
displayName: 'Prompt',
|
|
821
|
+
name: 'prompt',
|
|
822
|
+
type: 'string',
|
|
823
|
+
required: true,
|
|
824
|
+
displayOptions: {
|
|
825
|
+
show: {
|
|
826
|
+
resource: ['invoice'],
|
|
827
|
+
operation: ['ask'],
|
|
828
|
+
},
|
|
829
|
+
},
|
|
830
|
+
default: '',
|
|
831
|
+
description: 'Question about the invoice (1-2000 characters)',
|
|
832
|
+
typeOptions: {
|
|
833
|
+
rows: 4,
|
|
834
|
+
},
|
|
835
|
+
placeholder: 'What is the total amount and due date?',
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
displayName: 'Input Type',
|
|
839
|
+
name: 'inputType',
|
|
840
|
+
type: 'options',
|
|
841
|
+
displayOptions: {
|
|
842
|
+
show: {
|
|
843
|
+
resource: ['invoice'],
|
|
844
|
+
operation: ['extract'],
|
|
845
|
+
},
|
|
846
|
+
},
|
|
847
|
+
options: [
|
|
848
|
+
{
|
|
849
|
+
name: 'URL',
|
|
850
|
+
value: 'url',
|
|
851
|
+
description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
name: 'File',
|
|
855
|
+
value: 'file',
|
|
856
|
+
description: 'Upload an invoice, expense, bank statement or financial document file',
|
|
857
|
+
},
|
|
858
|
+
],
|
|
859
|
+
default: 'url',
|
|
860
|
+
description: 'Choose how to provide the invoice',
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
displayName: 'Invoice URL',
|
|
864
|
+
name: 'url',
|
|
865
|
+
type: 'string',
|
|
866
|
+
required: true,
|
|
867
|
+
displayOptions: {
|
|
868
|
+
show: {
|
|
869
|
+
resource: ['invoice'],
|
|
870
|
+
operation: ['extract'],
|
|
871
|
+
inputType: ['url'],
|
|
872
|
+
},
|
|
873
|
+
},
|
|
874
|
+
default: '',
|
|
875
|
+
description: 'URL of the invoice, expense, bank statement or financial document to extract data from (PDF, Word, Image)',
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
displayName: 'Binary Property',
|
|
879
|
+
name: 'binaryPropertyName',
|
|
880
|
+
type: 'string',
|
|
881
|
+
default: 'data',
|
|
882
|
+
required: true,
|
|
883
|
+
displayOptions: {
|
|
884
|
+
show: {
|
|
885
|
+
resource: ['invoice'],
|
|
886
|
+
operation: ['extract'],
|
|
887
|
+
inputType: ['file'],
|
|
888
|
+
},
|
|
889
|
+
},
|
|
890
|
+
description: 'Name of the binary property containing the invoice file',
|
|
891
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
displayName: 'Prompt',
|
|
895
|
+
name: 'prompt',
|
|
896
|
+
type: 'string',
|
|
897
|
+
required: true,
|
|
898
|
+
displayOptions: {
|
|
899
|
+
show: {
|
|
900
|
+
resource: ['invoice'],
|
|
901
|
+
operation: ['extract'],
|
|
902
|
+
},
|
|
903
|
+
},
|
|
904
|
+
default: '',
|
|
905
|
+
description: 'Instructions for data extraction from the invoice (1-2000 characters)',
|
|
906
|
+
typeOptions: {
|
|
907
|
+
rows: 4,
|
|
908
|
+
},
|
|
909
|
+
placeholder: 'Extract vendor details, line items, totals, taxes, and payment terms',
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
displayName: 'JSON Schema',
|
|
913
|
+
name: 'schema',
|
|
914
|
+
type: 'json',
|
|
915
|
+
required: true,
|
|
916
|
+
displayOptions: {
|
|
917
|
+
show: {
|
|
918
|
+
resource: ['invoice'],
|
|
919
|
+
operation: ['extract'],
|
|
920
|
+
},
|
|
921
|
+
},
|
|
922
|
+
default: '{\n "type": "object",\n "properties": {\n "invoiceNumber": { "type": "string" },\n "vendorName": { "type": "string" },\n "date": { "type": "string" },\n "dueDate": { "type": "string" },\n "subtotal": { "type": "number" },\n "tax": { "type": "number" },\n "total": { "type": "number" },\n "lineItems": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "description": { "type": "string" },\n "quantity": { "type": "number" },\n "unitPrice": { "type": "number" },\n "amount": { "type": "number" }\n }\n }\n }\n },\n "required": ["invoiceNumber", "total"],\n "additionalProperties": false\n}',
|
|
923
|
+
description: 'JSON schema that defines the structure of invoice data to extract',
|
|
924
|
+
typeOptions: {
|
|
925
|
+
rows: 10,
|
|
926
|
+
},
|
|
927
|
+
hint: 'Use our free [JSON Schema Editor](https://www.pdfvector.com/json-schema-editor) to create and validate your schema.',
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
displayName: 'Input Type',
|
|
931
|
+
name: 'inputType',
|
|
932
|
+
type: 'options',
|
|
933
|
+
displayOptions: {
|
|
934
|
+
show: {
|
|
935
|
+
resource: ['identityDocument'],
|
|
936
|
+
operation: ['parse'],
|
|
937
|
+
},
|
|
938
|
+
},
|
|
939
|
+
options: [
|
|
940
|
+
{
|
|
941
|
+
name: 'URL',
|
|
942
|
+
value: 'url',
|
|
943
|
+
description: 'Provide a public URL to the identity document',
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
name: 'File',
|
|
947
|
+
value: 'file',
|
|
948
|
+
description: 'Upload a PDF or image file of the identity document',
|
|
949
|
+
},
|
|
950
|
+
],
|
|
951
|
+
default: 'url',
|
|
952
|
+
description: 'Choose how to provide the identity document',
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
displayName: 'Identity Document URL',
|
|
956
|
+
name: 'url',
|
|
957
|
+
type: 'string',
|
|
958
|
+
required: true,
|
|
959
|
+
displayOptions: {
|
|
960
|
+
show: {
|
|
961
|
+
resource: ['identityDocument'],
|
|
962
|
+
operation: ['parse'],
|
|
963
|
+
inputType: ['url'],
|
|
964
|
+
},
|
|
965
|
+
},
|
|
966
|
+
default: '',
|
|
967
|
+
description: 'URL of the identity document to parse (passport, driver license, ID card, national ID)',
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
displayName: 'Binary Property',
|
|
971
|
+
name: 'binaryPropertyName',
|
|
972
|
+
type: 'string',
|
|
973
|
+
default: 'data',
|
|
974
|
+
required: true,
|
|
975
|
+
displayOptions: {
|
|
976
|
+
show: {
|
|
977
|
+
resource: ['identityDocument'],
|
|
978
|
+
operation: ['parse'],
|
|
979
|
+
inputType: ['file'],
|
|
980
|
+
},
|
|
981
|
+
},
|
|
982
|
+
description: 'Name of the binary property containing the identity document file',
|
|
983
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
984
|
+
},
|
|
985
|
+
{
|
|
986
|
+
displayName: 'Input Type',
|
|
987
|
+
name: 'inputType',
|
|
988
|
+
type: 'options',
|
|
989
|
+
displayOptions: {
|
|
990
|
+
show: {
|
|
991
|
+
resource: ['identityDocument'],
|
|
992
|
+
operation: ['ask'],
|
|
993
|
+
},
|
|
994
|
+
},
|
|
995
|
+
options: [
|
|
996
|
+
{
|
|
997
|
+
name: 'URL',
|
|
998
|
+
value: 'url',
|
|
999
|
+
description: 'Provide a public URL to the identity document',
|
|
1000
|
+
},
|
|
1001
|
+
{
|
|
1002
|
+
name: 'File',
|
|
1003
|
+
value: 'file',
|
|
1004
|
+
description: 'Upload a PDF or image file of the identity document',
|
|
1005
|
+
},
|
|
1006
|
+
],
|
|
1007
|
+
default: 'url',
|
|
1008
|
+
description: 'Choose how to provide the identity document',
|
|
1009
|
+
},
|
|
1010
|
+
{
|
|
1011
|
+
displayName: 'Identity Document URL',
|
|
1012
|
+
name: 'url',
|
|
1013
|
+
type: 'string',
|
|
1014
|
+
required: true,
|
|
1015
|
+
displayOptions: {
|
|
1016
|
+
show: {
|
|
1017
|
+
resource: ['identityDocument'],
|
|
1018
|
+
operation: ['ask'],
|
|
1019
|
+
inputType: ['url'],
|
|
1020
|
+
},
|
|
1021
|
+
},
|
|
1022
|
+
default: '',
|
|
1023
|
+
description: 'URL of the identity document to ask questions about (passport, driver license, ID card, national ID)',
|
|
1024
|
+
},
|
|
1025
|
+
{
|
|
1026
|
+
displayName: 'Binary Property',
|
|
1027
|
+
name: 'binaryPropertyName',
|
|
1028
|
+
type: 'string',
|
|
1029
|
+
default: 'data',
|
|
1030
|
+
required: true,
|
|
1031
|
+
displayOptions: {
|
|
1032
|
+
show: {
|
|
1033
|
+
resource: ['identityDocument'],
|
|
1034
|
+
operation: ['ask'],
|
|
1035
|
+
inputType: ['file'],
|
|
1036
|
+
},
|
|
1037
|
+
},
|
|
1038
|
+
description: 'Name of the binary property containing the identity document file',
|
|
1039
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
1040
|
+
},
|
|
1041
|
+
{
|
|
1042
|
+
displayName: 'Prompt',
|
|
1043
|
+
name: 'prompt',
|
|
1044
|
+
type: 'string',
|
|
1045
|
+
required: true,
|
|
1046
|
+
displayOptions: {
|
|
1047
|
+
show: {
|
|
1048
|
+
resource: ['identityDocument'],
|
|
1049
|
+
operation: ['ask'],
|
|
1050
|
+
},
|
|
1051
|
+
},
|
|
1052
|
+
default: '',
|
|
1053
|
+
description: 'Question about the identity document (1-2000 characters)',
|
|
1054
|
+
typeOptions: {
|
|
1055
|
+
rows: 4,
|
|
1056
|
+
},
|
|
1057
|
+
placeholder: 'What is the full name, date of birth, and expiry date on this ID?',
|
|
1058
|
+
},
|
|
1059
|
+
{
|
|
1060
|
+
displayName: 'Input Type',
|
|
1061
|
+
name: 'inputType',
|
|
1062
|
+
type: 'options',
|
|
1063
|
+
displayOptions: {
|
|
1064
|
+
show: {
|
|
1065
|
+
resource: ['identityDocument'],
|
|
1066
|
+
operation: ['extract'],
|
|
1067
|
+
},
|
|
1068
|
+
},
|
|
1069
|
+
options: [
|
|
1070
|
+
{
|
|
1071
|
+
name: 'URL',
|
|
1072
|
+
value: 'url',
|
|
1073
|
+
description: 'Provide a public URL to the identity document',
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: 'File',
|
|
1077
|
+
value: 'file',
|
|
1078
|
+
description: 'Upload a PDF or image file of the identity document',
|
|
1079
|
+
},
|
|
1080
|
+
],
|
|
1081
|
+
default: 'url',
|
|
1082
|
+
description: 'Choose how to provide the identity document',
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
displayName: 'Identity Document URL',
|
|
1086
|
+
name: 'url',
|
|
1087
|
+
type: 'string',
|
|
1088
|
+
required: true,
|
|
1089
|
+
displayOptions: {
|
|
1090
|
+
show: {
|
|
1091
|
+
resource: ['identityDocument'],
|
|
1092
|
+
operation: ['extract'],
|
|
1093
|
+
inputType: ['url'],
|
|
1094
|
+
},
|
|
1095
|
+
},
|
|
1096
|
+
default: '',
|
|
1097
|
+
description: 'URL of the identity document to extract data from (passport, driver license, ID card, national ID)',
|
|
1098
|
+
},
|
|
1099
|
+
{
|
|
1100
|
+
displayName: 'Binary Property',
|
|
1101
|
+
name: 'binaryPropertyName',
|
|
1102
|
+
type: 'string',
|
|
1103
|
+
default: 'data',
|
|
1104
|
+
required: true,
|
|
1105
|
+
displayOptions: {
|
|
1106
|
+
show: {
|
|
1107
|
+
resource: ['identityDocument'],
|
|
1108
|
+
operation: ['extract'],
|
|
1109
|
+
inputType: ['file'],
|
|
1110
|
+
},
|
|
1111
|
+
},
|
|
1112
|
+
description: 'Name of the binary property containing the identity document file',
|
|
1113
|
+
hint: 'The name of the property that holds the binary data from the previous node',
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
displayName: 'Prompt',
|
|
1117
|
+
name: 'prompt',
|
|
1118
|
+
type: 'string',
|
|
1119
|
+
required: true,
|
|
1120
|
+
displayOptions: {
|
|
1121
|
+
show: {
|
|
1122
|
+
resource: ['identityDocument'],
|
|
1123
|
+
operation: ['extract'],
|
|
1124
|
+
},
|
|
1125
|
+
},
|
|
1126
|
+
default: '',
|
|
1127
|
+
description: 'Instructions for data extraction from the identity document (1-2000 characters)',
|
|
1128
|
+
typeOptions: {
|
|
1129
|
+
rows: 4,
|
|
1130
|
+
},
|
|
1131
|
+
placeholder: 'Extract all personal and document information from this identity document',
|
|
1132
|
+
},
|
|
1133
|
+
{
|
|
1134
|
+
displayName: 'JSON Schema',
|
|
1135
|
+
name: 'schema',
|
|
1136
|
+
type: 'json',
|
|
1137
|
+
required: true,
|
|
1138
|
+
displayOptions: {
|
|
1139
|
+
show: {
|
|
1140
|
+
resource: ['identityDocument'],
|
|
1141
|
+
operation: ['extract'],
|
|
1142
|
+
},
|
|
1143
|
+
},
|
|
1144
|
+
default: '{\n "type": "object",\n "properties": {\n "documentType": { "type": "string" },\n "documentNumber": { "type": "string" },\n "issuingCountry": { "type": "string" },\n "fullName": { "type": "string" },\n "firstName": { "type": "string" },\n "lastName": { "type": "string" },\n "dateOfBirth": { "type": "string" },\n "gender": { "type": "string" },\n "nationality": { "type": "string" },\n "address": { "type": "string" },\n "issueDate": { "type": "string" },\n "expiryDate": { "type": "string" }\n },\n "required": ["documentType", "documentNumber", "fullName"],\n "additionalProperties": false\n}',
|
|
1145
|
+
description: 'JSON schema that defines the structure of identity document data to extract',
|
|
1146
|
+
typeOptions: {
|
|
1147
|
+
rows: 10,
|
|
1148
|
+
},
|
|
1149
|
+
hint: 'Use our free [JSON Schema Editor](https://www.pdfvector.com/json-schema-editor) to create and validate your schema.',
|
|
1150
|
+
},
|
|
1151
|
+
],
|
|
1152
|
+
};
|
|
1153
|
+
}
|
|
1154
|
+
async execute() {
|
|
1155
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1156
|
+
const items = this.getInputData();
|
|
1157
|
+
const returnData = [];
|
|
1158
|
+
const resource = this.getNodeParameter('resource', 0);
|
|
1159
|
+
const operation = this.getNodeParameter('operation', 0);
|
|
1160
|
+
for (let i = 0; i < items.length; i++) {
|
|
1161
|
+
try {
|
|
1162
|
+
let responseData = {};
|
|
1163
|
+
const baseURL = 'https://www.pdfvector.com/v1/api';
|
|
1164
|
+
switch (resource) {
|
|
1165
|
+
case 'academic': {
|
|
1166
|
+
if (operation === 'search') {
|
|
1167
|
+
const query = this.getNodeParameter('query', i);
|
|
1168
|
+
const providers = this.getNodeParameter('providers', i);
|
|
1169
|
+
const limit = this.getNodeParameter('limit', i);
|
|
1170
|
+
const offset = this.getNodeParameter('offset', i);
|
|
1171
|
+
const yearFrom = this.getNodeParameter('yearFrom', i);
|
|
1172
|
+
const yearTo = this.getNodeParameter('yearTo', i);
|
|
1173
|
+
const additionalFields = this.getNodeParameter('additionalFields', i);
|
|
1174
|
+
const body = {
|
|
1175
|
+
query,
|
|
1176
|
+
providers,
|
|
1177
|
+
limit,
|
|
1178
|
+
offset,
|
|
1179
|
+
yearFrom,
|
|
1180
|
+
yearTo,
|
|
1181
|
+
};
|
|
1182
|
+
if (additionalFields.fields &&
|
|
1183
|
+
Array.isArray(additionalFields.fields) &&
|
|
1184
|
+
additionalFields.fields.length > 0)
|
|
1185
|
+
body.fields = additionalFields.fields;
|
|
1186
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1187
|
+
method: 'POST',
|
|
1188
|
+
url: `${baseURL}/academic-search`,
|
|
1189
|
+
body,
|
|
1190
|
+
json: true,
|
|
1191
|
+
}));
|
|
1192
|
+
}
|
|
1193
|
+
else if (operation === 'fetch') {
|
|
1194
|
+
const idsString = this.getNodeParameter('ids', i);
|
|
1195
|
+
const fields = this.getNodeParameter('fields', i);
|
|
1196
|
+
const ids = String(idsString)
|
|
1197
|
+
.split(',')
|
|
1198
|
+
.map((id) => id.trim())
|
|
1199
|
+
.filter(Boolean);
|
|
1200
|
+
const body = {
|
|
1201
|
+
ids,
|
|
1202
|
+
};
|
|
1203
|
+
if (fields.length > 0)
|
|
1204
|
+
body.fields = fields;
|
|
1205
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1206
|
+
method: 'POST',
|
|
1207
|
+
url: `${baseURL}/academic-fetch`,
|
|
1208
|
+
body,
|
|
1209
|
+
json: true,
|
|
1210
|
+
}));
|
|
1211
|
+
}
|
|
1212
|
+
break;
|
|
1213
|
+
}
|
|
1214
|
+
case 'document': {
|
|
1215
|
+
if (operation === 'parse') {
|
|
1216
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1217
|
+
const useLLM = this.getNodeParameter('useLLM', i);
|
|
1218
|
+
const body = {};
|
|
1219
|
+
body.useLLM = useLLM;
|
|
1220
|
+
if (inputType === 'file') {
|
|
1221
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1222
|
+
if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName])) {
|
|
1223
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1224
|
+
}
|
|
1225
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1226
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1227
|
+
if (!buffer || buffer.length === 0) {
|
|
1228
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1229
|
+
}
|
|
1230
|
+
const base64File = buffer.toString('base64');
|
|
1231
|
+
body.file = base64File;
|
|
1232
|
+
if (binaryData.fileName) {
|
|
1233
|
+
body.fileName = binaryData.fileName;
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
else if (inputType === 'url') {
|
|
1237
|
+
const documentUrl = this.getNodeParameter('url', i);
|
|
1238
|
+
body.url = documentUrl;
|
|
1239
|
+
}
|
|
1240
|
+
else {
|
|
1241
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1242
|
+
}
|
|
1243
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1244
|
+
method: 'POST',
|
|
1245
|
+
url: `${baseURL}/parse`,
|
|
1246
|
+
body,
|
|
1247
|
+
json: true,
|
|
1248
|
+
}));
|
|
1249
|
+
}
|
|
1250
|
+
else if (operation === 'ask') {
|
|
1251
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1252
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1253
|
+
const body = {};
|
|
1254
|
+
body.prompt = prompt;
|
|
1255
|
+
if (inputType === 'file') {
|
|
1256
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1257
|
+
if (!((_b = items[i].binary) === null || _b === void 0 ? void 0 : _b[binaryPropertyName])) {
|
|
1258
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1259
|
+
}
|
|
1260
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1261
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1262
|
+
if (!buffer || buffer.length === 0) {
|
|
1263
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1264
|
+
}
|
|
1265
|
+
const base64File = buffer.toString('base64');
|
|
1266
|
+
body.file = base64File;
|
|
1267
|
+
if (binaryData.fileName) {
|
|
1268
|
+
body.fileName = binaryData.fileName;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
else if (inputType === 'url') {
|
|
1272
|
+
const documentUrl = this.getNodeParameter('url', i);
|
|
1273
|
+
body.url = documentUrl;
|
|
1274
|
+
}
|
|
1275
|
+
else {
|
|
1276
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1277
|
+
}
|
|
1278
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1279
|
+
method: 'POST',
|
|
1280
|
+
url: `${baseURL}/ask`,
|
|
1281
|
+
body,
|
|
1282
|
+
json: true,
|
|
1283
|
+
}));
|
|
1284
|
+
}
|
|
1285
|
+
else if (operation === 'extract') {
|
|
1286
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1287
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1288
|
+
const schemaString = this.getNodeParameter('schema', i);
|
|
1289
|
+
const body = {};
|
|
1290
|
+
body.prompt = prompt;
|
|
1291
|
+
try {
|
|
1292
|
+
const schema = JSON.parse(schemaString);
|
|
1293
|
+
if (schema.type !== 'object') {
|
|
1294
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must have type "object"', {
|
|
1295
|
+
itemIndex: i,
|
|
1296
|
+
});
|
|
1297
|
+
}
|
|
1298
|
+
if (schema.additionalProperties !== false) {
|
|
1299
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must include "additionalProperties": false', { itemIndex: i });
|
|
1300
|
+
}
|
|
1301
|
+
body.schema = schema;
|
|
1302
|
+
}
|
|
1303
|
+
catch (error) {
|
|
1304
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
1305
|
+
throw error;
|
|
1306
|
+
}
|
|
1307
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON schema: ${error.message}`, { itemIndex: i });
|
|
1308
|
+
}
|
|
1309
|
+
if (inputType === 'file') {
|
|
1310
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1311
|
+
if (!((_c = items[i].binary) === null || _c === void 0 ? void 0 : _c[binaryPropertyName])) {
|
|
1312
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1313
|
+
}
|
|
1314
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1315
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1316
|
+
if (!buffer || buffer.length === 0) {
|
|
1317
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1318
|
+
}
|
|
1319
|
+
const base64File = buffer.toString('base64');
|
|
1320
|
+
body.file = base64File;
|
|
1321
|
+
if (binaryData.fileName) {
|
|
1322
|
+
body.fileName = binaryData.fileName;
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
else if (inputType === 'url') {
|
|
1326
|
+
const documentUrl = this.getNodeParameter('url', i);
|
|
1327
|
+
body.url = documentUrl;
|
|
1328
|
+
}
|
|
1329
|
+
else {
|
|
1330
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1331
|
+
}
|
|
1332
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1333
|
+
method: 'POST',
|
|
1334
|
+
url: `${baseURL}/extract`,
|
|
1335
|
+
body,
|
|
1336
|
+
json: true,
|
|
1337
|
+
}));
|
|
1338
|
+
}
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
case 'invoice': {
|
|
1342
|
+
if (operation === 'parse') {
|
|
1343
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1344
|
+
const body = {};
|
|
1345
|
+
if (inputType === 'file') {
|
|
1346
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1347
|
+
if (!((_d = items[i].binary) === null || _d === void 0 ? void 0 : _d[binaryPropertyName])) {
|
|
1348
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1349
|
+
}
|
|
1350
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1351
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1352
|
+
if (!buffer || buffer.length === 0) {
|
|
1353
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1354
|
+
}
|
|
1355
|
+
const base64File = buffer.toString('base64');
|
|
1356
|
+
body.file = base64File;
|
|
1357
|
+
if (binaryData.fileName) {
|
|
1358
|
+
body.fileName = binaryData.fileName;
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
else if (inputType === 'url') {
|
|
1362
|
+
const invoiceUrl = this.getNodeParameter('url', i);
|
|
1363
|
+
body.url = invoiceUrl;
|
|
1364
|
+
}
|
|
1365
|
+
else {
|
|
1366
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1367
|
+
}
|
|
1368
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1369
|
+
method: 'POST',
|
|
1370
|
+
url: `${baseURL}/invoice-parse`,
|
|
1371
|
+
body,
|
|
1372
|
+
json: true,
|
|
1373
|
+
}));
|
|
1374
|
+
}
|
|
1375
|
+
else if (operation === 'ask') {
|
|
1376
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1377
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1378
|
+
const body = {};
|
|
1379
|
+
body.prompt = prompt;
|
|
1380
|
+
if (inputType === 'file') {
|
|
1381
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1382
|
+
if (!((_e = items[i].binary) === null || _e === void 0 ? void 0 : _e[binaryPropertyName])) {
|
|
1383
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1384
|
+
}
|
|
1385
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1386
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1387
|
+
if (!buffer || buffer.length === 0) {
|
|
1388
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1389
|
+
}
|
|
1390
|
+
const base64File = buffer.toString('base64');
|
|
1391
|
+
body.file = base64File;
|
|
1392
|
+
if (binaryData.fileName) {
|
|
1393
|
+
body.fileName = binaryData.fileName;
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
else if (inputType === 'url') {
|
|
1397
|
+
const invoiceUrl = this.getNodeParameter('url', i);
|
|
1398
|
+
body.url = invoiceUrl;
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1402
|
+
}
|
|
1403
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1404
|
+
method: 'POST',
|
|
1405
|
+
url: `${baseURL}/invoice-ask`,
|
|
1406
|
+
body,
|
|
1407
|
+
json: true,
|
|
1408
|
+
}));
|
|
1409
|
+
}
|
|
1410
|
+
else if (operation === 'extract') {
|
|
1411
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1412
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1413
|
+
const schemaString = this.getNodeParameter('schema', i);
|
|
1414
|
+
const body = {};
|
|
1415
|
+
body.prompt = prompt;
|
|
1416
|
+
try {
|
|
1417
|
+
const schema = JSON.parse(schemaString);
|
|
1418
|
+
if (schema.type !== 'object') {
|
|
1419
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must have type "object"', {
|
|
1420
|
+
itemIndex: i,
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
if (schema.additionalProperties !== false) {
|
|
1424
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must include "additionalProperties": false', { itemIndex: i });
|
|
1425
|
+
}
|
|
1426
|
+
body.schema = schema;
|
|
1427
|
+
}
|
|
1428
|
+
catch (error) {
|
|
1429
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
1430
|
+
throw error;
|
|
1431
|
+
}
|
|
1432
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON schema: ${error.message}`, { itemIndex: i });
|
|
1433
|
+
}
|
|
1434
|
+
if (inputType === 'file') {
|
|
1435
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1436
|
+
if (!((_f = items[i].binary) === null || _f === void 0 ? void 0 : _f[binaryPropertyName])) {
|
|
1437
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1438
|
+
}
|
|
1439
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1440
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1441
|
+
if (!buffer || buffer.length === 0) {
|
|
1442
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1443
|
+
}
|
|
1444
|
+
const base64File = buffer.toString('base64');
|
|
1445
|
+
body.file = base64File;
|
|
1446
|
+
if (binaryData.fileName) {
|
|
1447
|
+
body.fileName = binaryData.fileName;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
else if (inputType === 'url') {
|
|
1451
|
+
const invoiceUrl = this.getNodeParameter('url', i);
|
|
1452
|
+
body.url = invoiceUrl;
|
|
1453
|
+
}
|
|
1454
|
+
else {
|
|
1455
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1456
|
+
}
|
|
1457
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1458
|
+
method: 'POST',
|
|
1459
|
+
url: `${baseURL}/invoice-extract`,
|
|
1460
|
+
body,
|
|
1461
|
+
json: true,
|
|
1462
|
+
}));
|
|
1463
|
+
}
|
|
1464
|
+
break;
|
|
1465
|
+
}
|
|
1466
|
+
case 'identityDocument': {
|
|
1467
|
+
if (operation === 'parse') {
|
|
1468
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1469
|
+
const body = {};
|
|
1470
|
+
if (inputType === 'file') {
|
|
1471
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1472
|
+
if (!((_g = items[i].binary) === null || _g === void 0 ? void 0 : _g[binaryPropertyName])) {
|
|
1473
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1474
|
+
}
|
|
1475
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1476
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1477
|
+
if (!buffer || buffer.length === 0) {
|
|
1478
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1479
|
+
}
|
|
1480
|
+
const base64File = buffer.toString('base64');
|
|
1481
|
+
body.file = base64File;
|
|
1482
|
+
if (binaryData.fileName) {
|
|
1483
|
+
body.fileName = binaryData.fileName;
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
else if (inputType === 'url') {
|
|
1487
|
+
const idDocumentUrl = this.getNodeParameter('url', i);
|
|
1488
|
+
body.url = idDocumentUrl;
|
|
1489
|
+
}
|
|
1490
|
+
else {
|
|
1491
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1492
|
+
}
|
|
1493
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1494
|
+
method: 'POST',
|
|
1495
|
+
url: `${baseURL}/id-parse`,
|
|
1496
|
+
body,
|
|
1497
|
+
json: true,
|
|
1498
|
+
}));
|
|
1499
|
+
}
|
|
1500
|
+
else if (operation === 'ask') {
|
|
1501
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1502
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1503
|
+
const body = {};
|
|
1504
|
+
body.prompt = prompt;
|
|
1505
|
+
if (inputType === 'file') {
|
|
1506
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1507
|
+
if (!((_h = items[i].binary) === null || _h === void 0 ? void 0 : _h[binaryPropertyName])) {
|
|
1508
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1509
|
+
}
|
|
1510
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1511
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1512
|
+
if (!buffer || buffer.length === 0) {
|
|
1513
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1514
|
+
}
|
|
1515
|
+
const base64File = buffer.toString('base64');
|
|
1516
|
+
body.file = base64File;
|
|
1517
|
+
if (binaryData.fileName) {
|
|
1518
|
+
body.fileName = binaryData.fileName;
|
|
1519
|
+
}
|
|
1520
|
+
}
|
|
1521
|
+
else if (inputType === 'url') {
|
|
1522
|
+
const idDocumentUrl = this.getNodeParameter('url', i);
|
|
1523
|
+
body.url = idDocumentUrl;
|
|
1524
|
+
}
|
|
1525
|
+
else {
|
|
1526
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1527
|
+
}
|
|
1528
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1529
|
+
method: 'POST',
|
|
1530
|
+
url: `${baseURL}/id-ask`,
|
|
1531
|
+
body,
|
|
1532
|
+
json: true,
|
|
1533
|
+
}));
|
|
1534
|
+
}
|
|
1535
|
+
else if (operation === 'extract') {
|
|
1536
|
+
const inputType = this.getNodeParameter('inputType', i);
|
|
1537
|
+
const prompt = this.getNodeParameter('prompt', i);
|
|
1538
|
+
const schemaString = this.getNodeParameter('schema', i);
|
|
1539
|
+
const body = {};
|
|
1540
|
+
body.prompt = prompt;
|
|
1541
|
+
try {
|
|
1542
|
+
const schema = JSON.parse(schemaString);
|
|
1543
|
+
if (schema.type !== 'object') {
|
|
1544
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must have type "object"', {
|
|
1545
|
+
itemIndex: i,
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
if (schema.additionalProperties !== false) {
|
|
1549
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must include "additionalProperties": false', { itemIndex: i });
|
|
1550
|
+
}
|
|
1551
|
+
body.schema = schema;
|
|
1552
|
+
}
|
|
1553
|
+
catch (error) {
|
|
1554
|
+
if (error instanceof n8n_workflow_1.NodeOperationError) {
|
|
1555
|
+
throw error;
|
|
1556
|
+
}
|
|
1557
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON schema: ${error.message}`, { itemIndex: i });
|
|
1558
|
+
}
|
|
1559
|
+
if (inputType === 'file') {
|
|
1560
|
+
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
|
|
1561
|
+
if (!((_j = items[i].binary) === null || _j === void 0 ? void 0 : _j[binaryPropertyName])) {
|
|
1562
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
|
|
1563
|
+
}
|
|
1564
|
+
const binaryData = items[i].binary[binaryPropertyName];
|
|
1565
|
+
const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
|
1566
|
+
if (!buffer || buffer.length === 0) {
|
|
1567
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
|
|
1568
|
+
}
|
|
1569
|
+
const base64File = buffer.toString('base64');
|
|
1570
|
+
body.file = base64File;
|
|
1571
|
+
if (binaryData.fileName) {
|
|
1572
|
+
body.fileName = binaryData.fileName;
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
else if (inputType === 'url') {
|
|
1576
|
+
const idDocumentUrl = this.getNodeParameter('url', i);
|
|
1577
|
+
body.url = idDocumentUrl;
|
|
1578
|
+
}
|
|
1579
|
+
else {
|
|
1580
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
|
|
1581
|
+
}
|
|
1582
|
+
responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
|
|
1583
|
+
method: 'POST',
|
|
1584
|
+
url: `${baseURL}/id-extract`,
|
|
808
1585
|
body,
|
|
809
1586
|
json: true,
|
|
810
1587
|
}));
|