n8n-nodes-pdfvector 0.8.3 → 2.0.2

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.
Files changed (34) hide show
  1. package/README.md +68 -237
  2. package/dist/assets/credentials.png +0 -0
  3. package/dist/assets/install.png +0 -0
  4. package/dist/credentials/PDFVectorApi.credentials.d.ts +2 -2
  5. package/dist/credentials/PDFVectorApi.credentials.js +18 -12
  6. package/dist/credentials/PDFVectorApi.credentials.js.map +1 -1
  7. package/dist/credentials/icon.svg +4 -0
  8. package/dist/nodes/PdfVector/PdfVector.node.js +50 -1206
  9. package/dist/nodes/PdfVector/PdfVector.node.js.map +1 -1
  10. package/dist/nodes/PdfVector/academic/index.d.ts +3 -0
  11. package/dist/nodes/PdfVector/academic/index.js +185 -0
  12. package/dist/nodes/PdfVector/academic/index.js.map +1 -0
  13. package/dist/nodes/PdfVector/bankStatement/index.d.ts +3 -0
  14. package/dist/nodes/PdfVector/bankStatement/index.js +27 -0
  15. package/dist/nodes/PdfVector/bankStatement/index.js.map +1 -0
  16. package/dist/nodes/PdfVector/document/index.d.ts +3 -0
  17. package/dist/nodes/PdfVector/document/index.js +27 -0
  18. package/dist/nodes/PdfVector/document/index.js.map +1 -0
  19. package/dist/nodes/PdfVector/identity/index.d.ts +3 -0
  20. package/dist/nodes/PdfVector/identity/index.js +27 -0
  21. package/dist/nodes/PdfVector/identity/index.js.map +1 -0
  22. package/dist/nodes/PdfVector/invoice/index.d.ts +3 -0
  23. package/dist/nodes/PdfVector/invoice/index.js +27 -0
  24. package/dist/nodes/PdfVector/invoice/index.js.map +1 -0
  25. package/dist/nodes/PdfVector/shared/helpers.d.ts +8 -0
  26. package/dist/nodes/PdfVector/shared/helpers.js +41 -0
  27. package/dist/nodes/PdfVector/shared/helpers.js.map +1 -0
  28. package/dist/nodes/PdfVector/shared/options.d.ts +12 -0
  29. package/dist/nodes/PdfVector/shared/options.js +160 -0
  30. package/dist/nodes/PdfVector/shared/options.js.map +1 -0
  31. package/dist/package.json +17 -22
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +59 -64
  34. package/index.js +0 -0
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PdfVector = void 0;
4
- const n8n_workflow_1 = require("n8n-workflow");
4
+ const index_js_1 = require("./academic/index.js");
5
+ const index_js_2 = require("./bankStatement/index.js");
6
+ const index_js_3 = require("./document/index.js");
7
+ const index_js_4 = require("./identity/index.js");
8
+ const index_js_5 = require("./invoice/index.js");
5
9
  class PdfVector {
6
10
  constructor() {
7
11
  this.description = {
@@ -9,22 +13,14 @@ class PdfVector {
9
13
  name: 'pdfVector',
10
14
  icon: 'file:icon.svg',
11
15
  group: ['transform'],
12
- version: 1,
16
+ usableAsTool: true,
17
+ version: 2,
13
18
  subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
14
19
  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
- defaults: {
16
- name: 'PDF Vector',
17
- },
18
- documentationUrl: 'https://www.pdfvector.com/v1/api/scalar',
19
- inputs: ["main"],
20
- outputs: ["main"],
21
- credentials: [
22
- {
23
- name: 'pdfVectorApi',
24
- required: true,
25
- testedBy: 'pdfVectorApiTest',
26
- },
27
- ],
20
+ defaults: { name: 'PDF Vector' },
21
+ inputs: ['main'],
22
+ outputs: ['main'],
23
+ credentials: [{ name: 'pdfVectorApi', required: true }],
28
24
  properties: [
29
25
  {
30
26
  displayName: 'Resource',
@@ -32,1218 +28,66 @@ class PdfVector {
32
28
  type: 'options',
33
29
  noDataExpression: true,
34
30
  options: [
35
- {
36
- name: 'Academic',
37
- value: 'academic',
38
- },
39
- {
40
- name: 'Document',
41
- value: 'document',
42
- },
43
- {
44
- name: 'Invoice',
45
- value: 'invoice',
46
- },
47
- ],
48
- default: 'academic',
49
- },
50
- {
51
- displayName: 'Operation',
52
- name: 'operation',
53
- type: 'options',
54
- noDataExpression: true,
55
- displayOptions: {
56
- show: {
57
- resource: ['academic'],
58
- },
59
- },
60
- options: [
61
- {
62
- name: 'Search',
63
- value: 'search',
64
- description: 'Search across PubMed, ArXiv, Google Scholar, and more',
65
- action: 'Search academic publications',
66
- },
67
- {
68
- name: 'Fetch',
69
- value: 'fetch',
70
- description: 'Fetch publications by DOI, PubMed ID, ArXiv ID, etc',
71
- action: 'Fetch a specific publication',
72
- },
73
- ],
74
- default: 'search',
75
- },
76
- {
77
- displayName: 'Operation',
78
- name: 'operation',
79
- type: 'options',
80
- noDataExpression: true,
81
- displayOptions: {
82
- show: {
83
- resource: ['document'],
84
- },
85
- },
86
- options: [
87
- {
88
- name: 'Parse',
89
- value: 'parse',
90
- description: 'Convert PDFs, Word, Excel, or images to markdown',
91
- action: 'Parse a document',
92
- },
93
- {
94
- name: 'Ask',
95
- value: 'ask',
96
- description: 'Ask questions about PDF, Word, Excel, or image',
97
- action: 'Ask questions about a document',
98
- },
99
- {
100
- name: 'Extract',
101
- value: 'extract',
102
- description: 'Extract structured data from PDF, Word, Excel, or image using JSON Schema',
103
- action: 'Extract structured data from a document',
104
- },
105
- ],
106
- default: 'parse',
107
- },
108
- {
109
- displayName: 'Operation',
110
- name: 'operation',
111
- type: 'options',
112
- noDataExpression: true,
113
- displayOptions: {
114
- show: {
115
- resource: ['invoice'],
116
- },
117
- },
118
- options: [
119
- {
120
- name: 'Parse',
121
- value: 'parse',
122
- description: 'Parse invoice, expense, bank statement or financial document',
123
- action: 'Parse an invoice',
124
- },
125
- {
126
- name: 'Ask',
127
- value: 'ask',
128
- description: 'Ask questions about invoice, expense, bank statement or financial document',
129
- action: 'Ask questions about an invoice',
130
- },
131
- {
132
- name: 'Extract',
133
- value: 'extract',
134
- description: 'Extract invoice, expense, bank statement or financial document structured data',
135
- action: 'Extract structured data from an invoice',
136
- },
137
- ],
138
- default: 'parse',
139
- },
140
- {
141
- displayName: 'Query',
142
- name: 'query',
143
- type: 'string',
144
- required: true,
145
- displayOptions: {
146
- show: {
147
- resource: ['academic'],
148
- operation: ['search'],
149
- },
150
- },
151
- default: '',
152
- description: 'Search query for academic publications (1-400 characters)',
153
- placeholder: 'machine learning in healthcare',
154
- },
155
- {
156
- displayName: 'Providers',
157
- name: 'providers',
158
- type: 'multiOptions',
159
- displayOptions: {
160
- show: {
161
- resource: ['academic'],
162
- operation: ['search'],
163
- },
164
- },
165
- options: [
166
- {
167
- name: 'ArXiv',
168
- value: 'arxiv',
169
- },
170
- {
171
- name: 'ERIC',
172
- value: 'eric',
173
- },
174
- {
175
- name: 'Europe PMC',
176
- value: 'europe-pmc',
177
- },
178
- {
179
- name: 'Google Scholar',
180
- value: 'google-scholar',
181
- },
182
- {
183
- name: 'OpenAlex',
184
- value: 'openalex',
185
- },
186
- {
187
- name: 'PubMed',
188
- value: 'pubmed',
189
- },
190
- {
191
- name: 'Semantic Scholar',
192
- value: 'semantic-scholar',
193
- },
194
- ],
195
- default: ['semantic-scholar'],
196
- description: 'Academic database providers to search. Select multiple to search across databases.',
197
- },
198
- {
199
- displayName: 'Limit',
200
- name: 'limit',
201
- type: 'number',
202
- displayOptions: {
203
- show: {
204
- resource: ['academic'],
205
- operation: ['search'],
206
- },
207
- },
208
- typeOptions: {
209
- minValue: 1,
210
- },
211
- default: 50,
212
- description: 'Max number of results to return',
213
- },
214
- {
215
- displayName: 'Offset',
216
- name: 'offset',
217
- type: 'number',
218
- displayOptions: {
219
- show: {
220
- resource: ['academic'],
221
- operation: ['search'],
222
- },
223
- },
224
- typeOptions: {
225
- minValue: 0,
226
- },
227
- default: 0,
228
- description: 'Number of results to skip per provider',
229
- },
230
- {
231
- displayName: 'Year From',
232
- name: 'yearFrom',
233
- type: 'number',
234
- displayOptions: {
235
- show: {
236
- resource: ['academic'],
237
- operation: ['search'],
238
- },
239
- },
240
- typeOptions: {
241
- minValue: 1900,
242
- },
243
- default: 1900,
244
- description: 'Filter results published after this year (inclusive)',
245
- },
246
- {
247
- displayName: 'Year To',
248
- name: 'yearTo',
249
- type: 'number',
250
- displayOptions: {
251
- show: {
252
- resource: ['academic'],
253
- operation: ['search'],
254
- },
255
- },
256
- typeOptions: {
257
- maxValue: 2100,
258
- },
259
- default: 2050,
260
- description: 'Filter results published before this year (inclusive)',
261
- },
262
- {
263
- displayName: 'Additional Fields',
264
- name: 'additionalFields',
265
- type: 'collection',
266
- placeholder: 'Add Field',
267
- displayOptions: {
268
- show: {
269
- resource: ['academic'],
270
- operation: ['search'],
271
- },
272
- },
273
- default: {},
274
- options: [
275
- {
276
- displayName: 'Fields',
277
- name: 'fields',
278
- type: 'multiOptions',
279
- options: [
280
- {
281
- name: 'Abstract',
282
- value: 'abstract',
283
- },
284
- {
285
- name: 'Authors',
286
- value: 'authors',
287
- },
288
- {
289
- name: 'Date',
290
- value: 'date',
291
- },
292
- {
293
- name: 'DOI',
294
- value: 'doi',
295
- },
296
- {
297
- name: 'PDF URL',
298
- value: 'pdfURL',
299
- },
300
- {
301
- name: 'Provider',
302
- value: 'provider',
303
- },
304
- {
305
- name: 'Provider Data',
306
- value: 'providerData',
307
- },
308
- {
309
- name: 'Provider URL',
310
- value: 'providerURL',
311
- },
312
- {
313
- name: 'Title',
314
- value: 'title',
315
- },
316
- {
317
- name: 'Total Citations',
318
- value: 'totalCitations',
319
- },
320
- {
321
- name: 'Total References',
322
- value: 'totalReferences',
323
- },
324
- {
325
- name: 'URL',
326
- value: 'url',
327
- },
328
- {
329
- name: 'Year',
330
- value: 'year',
331
- },
332
- ],
333
- default: [],
334
- description: 'Fields to include in the response',
335
- },
31
+ { name: 'Academic', value: 'academic' },
32
+ { name: 'Bank Statement', value: 'bankStatement' },
33
+ { name: 'Document', value: 'document' },
34
+ { name: 'Identity Document', value: 'identity' },
35
+ { name: 'Invoice', value: 'invoice' },
336
36
  ],
37
+ default: 'document',
337
38
  },
338
- {
339
- displayName: 'IDs',
340
- name: 'ids',
341
- type: 'string',
342
- required: true,
343
- displayOptions: {
344
- show: {
345
- resource: ['academic'],
346
- operation: ['fetch'],
347
- },
348
- },
349
- default: '',
350
- 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).',
351
- placeholder: '10.1038/nature12373, PMC3883140, arXiv:1234.5678, ED123456',
352
- },
353
- {
354
- displayName: 'Fields',
355
- name: 'fields',
356
- type: 'multiOptions',
357
- displayOptions: {
358
- show: {
359
- resource: ['academic'],
360
- operation: ['fetch'],
361
- },
362
- },
363
- options: [
364
- {
365
- name: 'Abstract',
366
- value: 'abstract',
367
- },
368
- {
369
- name: 'Authors',
370
- value: 'authors',
371
- },
372
- {
373
- name: 'Date',
374
- value: 'date',
375
- },
376
- {
377
- name: 'DOI',
378
- value: 'doi',
379
- },
380
- {
381
- name: 'PDF URL',
382
- value: 'pdfURL',
383
- },
384
- {
385
- name: 'Provider',
386
- value: 'provider',
387
- },
388
- {
389
- name: 'Provider Data',
390
- value: 'providerData',
391
- },
392
- {
393
- name: 'Provider URL',
394
- value: 'providerURL',
395
- },
396
- {
397
- name: 'Title',
398
- value: 'title',
399
- },
400
- {
401
- name: 'Total Citations',
402
- value: 'totalCitations',
403
- },
404
- {
405
- name: 'Total References',
406
- value: 'totalReferences',
407
- },
408
- {
409
- name: 'URL',
410
- value: 'url',
411
- },
412
- {
413
- name: 'Year',
414
- value: 'year',
415
- },
416
- ],
417
- default: [],
418
- description: 'Fields to include in the response',
419
- },
420
- {
421
- displayName: 'Input Type',
422
- name: 'inputType',
423
- type: 'options',
424
- displayOptions: {
425
- show: {
426
- resource: ['document'],
427
- operation: ['parse'],
428
- },
429
- },
430
- options: [
431
- {
432
- name: 'URL',
433
- value: 'url',
434
- description: 'Provide a public URL to the document',
435
- },
436
- {
437
- name: 'File',
438
- value: 'file',
439
- description: 'Upload a PDF, Word, Excel, or image file',
440
- },
441
- ],
442
- default: 'url',
443
- description: 'Choose how to provide the document',
444
- },
445
- {
446
- displayName: 'Document URL',
447
- name: 'url',
448
- type: 'string',
449
- required: true,
450
- displayOptions: {
451
- show: {
452
- resource: ['document'],
453
- operation: ['parse'],
454
- inputType: ['url'],
455
- },
456
- },
457
- default: '',
458
- description: 'URL of the document to parse (PDF, Word, Excel, Image)',
459
- },
460
- {
461
- displayName: 'Binary Property',
462
- name: 'binaryPropertyName',
463
- type: 'string',
464
- default: 'data',
465
- required: true,
466
- displayOptions: {
467
- show: {
468
- resource: ['document'],
469
- operation: ['parse'],
470
- inputType: ['file'],
471
- },
472
- },
473
- description: 'Name of the binary property containing the file',
474
- hint: 'The name of the property that holds the binary data from the previous node',
475
- },
476
- {
477
- displayName: 'Use LLM',
478
- name: 'useLLM',
479
- type: 'options',
480
- displayOptions: {
481
- show: {
482
- resource: ['document'],
483
- operation: ['parse'],
484
- },
485
- },
486
- options: [
487
- {
488
- name: 'Auto',
489
- value: 'auto',
490
- description: 'Automatically decide if LLM parsing is needed (1-2 credits per page)',
491
- },
492
- {
493
- name: 'Always',
494
- value: 'always',
495
- description: 'Always use LLM parsing (2 credits per page)',
496
- },
497
- {
498
- name: 'Never',
499
- value: 'never',
500
- description: 'Never use LLM parsing (1 credit per page)',
501
- },
502
- ],
503
- default: 'auto',
504
- description: 'Determines LLM parsing approach',
505
- },
506
- {
507
- displayName: 'Input Type',
508
- name: 'inputType',
509
- type: 'options',
510
- displayOptions: {
511
- show: {
512
- resource: ['document'],
513
- operation: ['ask'],
514
- },
515
- },
516
- options: [
517
- {
518
- name: 'URL',
519
- value: 'url',
520
- description: 'Provide a public URL to the document',
521
- },
522
- {
523
- name: 'File',
524
- value: 'file',
525
- description: 'Upload a PDF, Word, Excel, or image file',
526
- },
527
- ],
528
- default: 'url',
529
- description: 'Choose how to provide the document',
530
- },
531
- {
532
- displayName: 'Document URL',
533
- name: 'url',
534
- type: 'string',
535
- required: true,
536
- displayOptions: {
537
- show: {
538
- resource: ['document'],
539
- operation: ['ask'],
540
- inputType: ['url'],
541
- },
542
- },
543
- default: '',
544
- description: 'URL of the document to ask questions about (PDF, Word, Excel, Image)',
545
- },
546
- {
547
- displayName: 'Binary Property',
548
- name: 'binaryPropertyName',
549
- type: 'string',
550
- default: 'data',
551
- required: true,
552
- displayOptions: {
553
- show: {
554
- resource: ['document'],
555
- operation: ['ask'],
556
- inputType: ['file'],
557
- },
558
- },
559
- description: 'Name of the binary property containing the file',
560
- hint: 'The name of the property that holds the binary data from the previous node',
561
- },
562
- {
563
- displayName: 'Prompt',
564
- name: 'prompt',
565
- type: 'string',
566
- required: true,
567
- displayOptions: {
568
- show: {
569
- resource: ['document'],
570
- operation: ['ask'],
571
- },
572
- },
573
- default: '',
574
- description: 'Question about the document (1-2000 characters)',
575
- typeOptions: {
576
- rows: 4,
577
- },
578
- },
579
- {
580
- displayName: 'Input Type',
581
- name: 'inputType',
582
- type: 'options',
583
- displayOptions: {
584
- show: {
585
- resource: ['document'],
586
- operation: ['extract'],
587
- },
588
- },
589
- options: [
590
- {
591
- name: 'URL',
592
- value: 'url',
593
- description: 'Provide a public URL to the document',
594
- },
595
- {
596
- name: 'File',
597
- value: 'file',
598
- description: 'Upload a PDF, Word, Excel, or image file',
599
- },
600
- ],
601
- default: 'url',
602
- description: 'Choose how to provide the document',
603
- },
604
- {
605
- displayName: 'Document URL',
606
- name: 'url',
607
- type: 'string',
608
- required: true,
609
- displayOptions: {
610
- show: {
611
- resource: ['document'],
612
- operation: ['extract'],
613
- inputType: ['url'],
614
- },
615
- },
616
- default: '',
617
- description: 'URL of the document to extract data from (PDF, Word, Excel, Image)',
618
- },
619
- {
620
- displayName: 'Binary Property',
621
- name: 'binaryPropertyName',
622
- type: 'string',
623
- default: 'data',
624
- required: true,
625
- displayOptions: {
626
- show: {
627
- resource: ['document'],
628
- operation: ['extract'],
629
- inputType: ['file'],
630
- },
631
- },
632
- description: 'Name of the binary property containing the file',
633
- hint: 'The name of the property that holds the binary data from the previous node',
634
- },
635
- {
636
- displayName: 'Prompt',
637
- name: 'prompt',
638
- type: 'string',
639
- required: true,
640
- displayOptions: {
641
- show: {
642
- resource: ['document'],
643
- operation: ['extract'],
644
- },
645
- },
646
- default: '',
647
- description: 'Instructions for data extraction (1-2000 characters)',
648
- typeOptions: {
649
- rows: 4,
650
- },
651
- placeholder: 'Extract all invoice details including line items, totals, and dates',
652
- },
653
- {
654
- displayName: 'JSON Schema',
655
- name: 'schema',
656
- type: 'json',
657
- required: true,
658
- displayOptions: {
659
- show: {
660
- resource: ['document'],
661
- operation: ['extract'],
662
- },
663
- },
664
- default: '{\n "type": "object",\n "properties": {\n "invoiceNumber": { "type": "string" },\n "date": { "type": "string" },\n "total": { "type": "number" },\n "items": {\n "type": "array",\n "items": {\n "type": "object",\n "properties": {\n "description": { "type": "string" },\n "quantity": { "type": "number" },\n "price": { "type": "number" }\n }\n }\n }\n },\n "required": ["invoiceNumber"],\n "additionalProperties": false\n}',
665
- description: 'JSON schema that defines the structure of data to extract',
666
- typeOptions: {
667
- rows: 10,
668
- },
669
- hint: 'Use our free [JSON Schema Editor](https://www.pdfvector.com/json-schema-editor) to create and validate your schema.',
670
- },
671
- {
672
- displayName: 'Input Type',
673
- name: 'inputType',
674
- type: 'options',
675
- displayOptions: {
676
- show: {
677
- resource: ['invoice'],
678
- operation: ['parse'],
679
- },
680
- },
681
- options: [
682
- {
683
- name: 'URL',
684
- value: 'url',
685
- description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
686
- },
687
- {
688
- name: 'File',
689
- value: 'file',
690
- description: 'Upload an invoice, expense, bank statement or financial document file',
691
- },
692
- ],
693
- default: 'url',
694
- description: 'Choose how to provide the invoice',
695
- },
696
- {
697
- displayName: 'Invoice URL',
698
- name: 'url',
699
- type: 'string',
700
- required: true,
701
- displayOptions: {
702
- show: {
703
- resource: ['invoice'],
704
- operation: ['parse'],
705
- inputType: ['url'],
706
- },
707
- },
708
- default: '',
709
- description: 'URL of the invoice, expense, bank statement or financial document to parse (PDF, Word, Image)',
710
- },
711
- {
712
- displayName: 'Binary Property',
713
- name: 'binaryPropertyName',
714
- type: 'string',
715
- default: 'data',
716
- required: true,
717
- displayOptions: {
718
- show: {
719
- resource: ['invoice'],
720
- operation: ['parse'],
721
- inputType: ['file'],
722
- },
723
- },
724
- description: 'Name of the binary property containing the invoice file',
725
- hint: 'The name of the property that holds the binary data from the previous node',
726
- },
727
- {
728
- displayName: 'Input Type',
729
- name: 'inputType',
730
- type: 'options',
731
- displayOptions: {
732
- show: {
733
- resource: ['invoice'],
734
- operation: ['ask'],
735
- },
736
- },
737
- options: [
738
- {
739
- name: 'URL',
740
- value: 'url',
741
- description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
742
- },
743
- {
744
- name: 'File',
745
- value: 'file',
746
- description: 'Upload an invoice, expense, bank statement or financial document file',
747
- },
748
- ],
749
- default: 'url',
750
- description: 'Choose how to provide the invoice',
751
- },
752
- {
753
- displayName: 'Invoice URL',
754
- name: 'url',
755
- type: 'string',
756
- required: true,
757
- displayOptions: {
758
- show: {
759
- resource: ['invoice'],
760
- operation: ['ask'],
761
- inputType: ['url'],
762
- },
763
- },
764
- default: '',
765
- description: 'URL of the invoice, expense, bank statement or financial document to ask questions about (PDF, Word, Image)',
766
- },
767
- {
768
- displayName: 'Binary Property',
769
- name: 'binaryPropertyName',
770
- type: 'string',
771
- default: 'data',
772
- required: true,
773
- displayOptions: {
774
- show: {
775
- resource: ['invoice'],
776
- operation: ['ask'],
777
- inputType: ['file'],
778
- },
779
- },
780
- description: 'Name of the binary property containing the invoice file',
781
- hint: 'The name of the property that holds the binary data from the previous node',
782
- },
783
- {
784
- displayName: 'Prompt',
785
- name: 'prompt',
786
- type: 'string',
787
- required: true,
788
- displayOptions: {
789
- show: {
790
- resource: ['invoice'],
791
- operation: ['ask'],
792
- },
793
- },
794
- default: '',
795
- description: 'Question about the invoice (1-2000 characters)',
796
- typeOptions: {
797
- rows: 4,
798
- },
799
- placeholder: 'What is the total amount and due date?',
800
- },
801
- {
802
- displayName: 'Input Type',
803
- name: 'inputType',
804
- type: 'options',
805
- displayOptions: {
806
- show: {
807
- resource: ['invoice'],
808
- operation: ['extract'],
809
- },
810
- },
811
- options: [
812
- {
813
- name: 'URL',
814
- value: 'url',
815
- description: 'Provide a public URL to the invoice, expense, bank statement or financial document',
816
- },
817
- {
818
- name: 'File',
819
- value: 'file',
820
- description: 'Upload an invoice, expense, bank statement or financial document file',
821
- },
822
- ],
823
- default: 'url',
824
- description: 'Choose how to provide the invoice',
825
- },
826
- {
827
- displayName: 'Invoice URL',
828
- name: 'url',
829
- type: 'string',
830
- required: true,
831
- displayOptions: {
832
- show: {
833
- resource: ['invoice'],
834
- operation: ['extract'],
835
- inputType: ['url'],
836
- },
837
- },
838
- default: '',
839
- description: 'URL of the invoice, expense, bank statement or financial document to extract data from (PDF, Word, Image)',
840
- },
841
- {
842
- displayName: 'Binary Property',
843
- name: 'binaryPropertyName',
844
- type: 'string',
845
- default: 'data',
846
- required: true,
847
- displayOptions: {
848
- show: {
849
- resource: ['invoice'],
850
- operation: ['extract'],
851
- inputType: ['file'],
852
- },
853
- },
854
- description: 'Name of the binary property containing the invoice file',
855
- hint: 'The name of the property that holds the binary data from the previous node',
856
- },
857
- {
858
- displayName: 'Prompt',
859
- name: 'prompt',
860
- type: 'string',
861
- required: true,
862
- displayOptions: {
863
- show: {
864
- resource: ['invoice'],
865
- operation: ['extract'],
866
- },
867
- },
868
- default: '',
869
- description: 'Instructions for data extraction from the invoice (1-2000 characters)',
870
- typeOptions: {
871
- rows: 4,
872
- },
873
- placeholder: 'Extract vendor details, line items, totals, taxes, and payment terms',
874
- },
875
- {
876
- displayName: 'JSON Schema',
877
- name: 'schema',
878
- type: 'json',
879
- required: true,
880
- displayOptions: {
881
- show: {
882
- resource: ['invoice'],
883
- operation: ['extract'],
884
- },
885
- },
886
- 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}',
887
- description: 'JSON schema that defines the structure of invoice data to extract',
888
- typeOptions: {
889
- rows: 10,
890
- },
891
- hint: 'Use our free [JSON Schema Editor](https://www.pdfvector.com/json-schema-editor) to create and validate your schema.',
892
- },
39
+ ...index_js_3.documentProperties,
40
+ ...index_js_4.identityProperties,
41
+ ...index_js_5.invoiceProperties,
42
+ ...index_js_2.bankStatementProperties,
43
+ ...index_js_1.academicProperties,
893
44
  ],
894
45
  };
895
46
  }
896
47
  async execute() {
897
- var _a, _b, _c, _d, _e, _f;
898
48
  const items = this.getInputData();
899
49
  const returnData = [];
50
+ const credentials = await this.getCredentials('pdfVectorApi');
51
+ const domain = credentials.domain || 'global.pdfvector.com';
52
+ const apiKey = credentials.apiKey;
900
53
  const resource = this.getNodeParameter('resource', 0);
901
54
  const operation = this.getNodeParameter('operation', 0);
902
55
  for (let i = 0; i < items.length; i++) {
903
56
  try {
904
- let responseData = {};
905
- const baseURL = 'https://www.pdfvector.com/v1/api';
57
+ let result = {};
906
58
  switch (resource) {
907
- case 'academic': {
908
- if (operation === 'search') {
909
- const query = this.getNodeParameter('query', i);
910
- const providers = this.getNodeParameter('providers', i);
911
- const limit = this.getNodeParameter('limit', i);
912
- const offset = this.getNodeParameter('offset', i);
913
- const yearFrom = this.getNodeParameter('yearFrom', i);
914
- const yearTo = this.getNodeParameter('yearTo', i);
915
- const additionalFields = this.getNodeParameter('additionalFields', i);
916
- const body = {
917
- query,
918
- providers,
919
- limit,
920
- offset,
921
- yearFrom,
922
- yearTo,
923
- };
924
- if (additionalFields.fields &&
925
- Array.isArray(additionalFields.fields) &&
926
- additionalFields.fields.length > 0)
927
- body.fields = additionalFields.fields;
928
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
929
- method: 'POST',
930
- url: `${baseURL}/academic-search`,
931
- body,
932
- json: true,
933
- }));
934
- }
935
- else if (operation === 'fetch') {
936
- const idsString = this.getNodeParameter('ids', i);
937
- const fields = this.getNodeParameter('fields', i);
938
- const ids = String(idsString)
939
- .split(',')
940
- .map((id) => id.trim())
941
- .filter(Boolean);
942
- const body = {
943
- ids,
944
- };
945
- if (fields.length > 0)
946
- body.fields = fields;
947
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
948
- method: 'POST',
949
- url: `${baseURL}/academic-fetch`,
950
- body,
951
- json: true,
952
- }));
953
- }
59
+ case 'document':
60
+ result = await (0, index_js_3.executeDocument)(this, domain, apiKey, operation, i);
954
61
  break;
955
- }
956
- case 'document': {
957
- if (operation === 'parse') {
958
- const inputType = this.getNodeParameter('inputType', i);
959
- const useLLM = this.getNodeParameter('useLLM', i);
960
- const body = {};
961
- body.useLLM = useLLM;
962
- if (inputType === 'file') {
963
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
964
- if (!((_a = items[i].binary) === null || _a === void 0 ? void 0 : _a[binaryPropertyName])) {
965
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
966
- }
967
- const binaryData = items[i].binary[binaryPropertyName];
968
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
969
- if (!buffer || buffer.length === 0) {
970
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
971
- }
972
- const base64File = buffer.toString('base64');
973
- body.file = base64File;
974
- if (binaryData.fileName) {
975
- body.fileName = binaryData.fileName;
976
- }
977
- }
978
- else if (inputType === 'url') {
979
- const documentUrl = this.getNodeParameter('url', i);
980
- body.url = documentUrl;
981
- }
982
- else {
983
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
984
- }
985
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
986
- method: 'POST',
987
- url: `${baseURL}/parse`,
988
- body,
989
- json: true,
990
- }));
991
- }
992
- else if (operation === 'ask') {
993
- const inputType = this.getNodeParameter('inputType', i);
994
- const prompt = this.getNodeParameter('prompt', i);
995
- const body = {};
996
- body.prompt = prompt;
997
- if (inputType === 'file') {
998
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
999
- if (!((_b = items[i].binary) === null || _b === void 0 ? void 0 : _b[binaryPropertyName])) {
1000
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
1001
- }
1002
- const binaryData = items[i].binary[binaryPropertyName];
1003
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1004
- if (!buffer || buffer.length === 0) {
1005
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
1006
- }
1007
- const base64File = buffer.toString('base64');
1008
- body.file = base64File;
1009
- if (binaryData.fileName) {
1010
- body.fileName = binaryData.fileName;
1011
- }
1012
- }
1013
- else if (inputType === 'url') {
1014
- const documentUrl = this.getNodeParameter('url', i);
1015
- body.url = documentUrl;
1016
- }
1017
- else {
1018
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
1019
- }
1020
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
1021
- method: 'POST',
1022
- url: `${baseURL}/ask`,
1023
- body,
1024
- json: true,
1025
- }));
1026
- }
1027
- else if (operation === 'extract') {
1028
- const inputType = this.getNodeParameter('inputType', i);
1029
- const prompt = this.getNodeParameter('prompt', i);
1030
- const schemaString = this.getNodeParameter('schema', i);
1031
- const body = {};
1032
- body.prompt = prompt;
1033
- try {
1034
- const schema = JSON.parse(schemaString);
1035
- if (schema.type !== 'object') {
1036
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must have type "object"', {
1037
- itemIndex: i,
1038
- });
1039
- }
1040
- if (schema.additionalProperties !== false) {
1041
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must include "additionalProperties": false', { itemIndex: i });
1042
- }
1043
- body.schema = schema;
1044
- }
1045
- catch (error) {
1046
- if (error instanceof n8n_workflow_1.NodeOperationError) {
1047
- throw error;
1048
- }
1049
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON schema: ${error.message}`, { itemIndex: i });
1050
- }
1051
- if (inputType === 'file') {
1052
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1053
- if (!((_c = items[i].binary) === null || _c === void 0 ? void 0 : _c[binaryPropertyName])) {
1054
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
1055
- }
1056
- const binaryData = items[i].binary[binaryPropertyName];
1057
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1058
- if (!buffer || buffer.length === 0) {
1059
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
1060
- }
1061
- const base64File = buffer.toString('base64');
1062
- body.file = base64File;
1063
- if (binaryData.fileName) {
1064
- body.fileName = binaryData.fileName;
1065
- }
1066
- }
1067
- else if (inputType === 'url') {
1068
- const documentUrl = this.getNodeParameter('url', i);
1069
- body.url = documentUrl;
1070
- }
1071
- else {
1072
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
1073
- }
1074
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
1075
- method: 'POST',
1076
- url: `${baseURL}/extract`,
1077
- body,
1078
- json: true,
1079
- }));
1080
- }
62
+ case 'identity':
63
+ result = await (0, index_js_4.executeIdentity)(this, domain, apiKey, operation, i);
1081
64
  break;
1082
- }
1083
- case 'invoice': {
1084
- if (operation === 'parse') {
1085
- const inputType = this.getNodeParameter('inputType', i);
1086
- const body = {};
1087
- if (inputType === 'file') {
1088
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1089
- if (!((_d = items[i].binary) === null || _d === void 0 ? void 0 : _d[binaryPropertyName])) {
1090
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
1091
- }
1092
- const binaryData = items[i].binary[binaryPropertyName];
1093
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1094
- if (!buffer || buffer.length === 0) {
1095
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
1096
- }
1097
- const base64File = buffer.toString('base64');
1098
- body.file = base64File;
1099
- if (binaryData.fileName) {
1100
- body.fileName = binaryData.fileName;
1101
- }
1102
- }
1103
- else if (inputType === 'url') {
1104
- const invoiceUrl = this.getNodeParameter('url', i);
1105
- body.url = invoiceUrl;
1106
- }
1107
- else {
1108
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
1109
- }
1110
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
1111
- method: 'POST',
1112
- url: `${baseURL}/invoice-parse`,
1113
- body,
1114
- json: true,
1115
- }));
1116
- }
1117
- else if (operation === 'ask') {
1118
- const inputType = this.getNodeParameter('inputType', i);
1119
- const prompt = this.getNodeParameter('prompt', i);
1120
- const body = {};
1121
- body.prompt = prompt;
1122
- if (inputType === 'file') {
1123
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1124
- if (!((_e = items[i].binary) === null || _e === void 0 ? void 0 : _e[binaryPropertyName])) {
1125
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
1126
- }
1127
- const binaryData = items[i].binary[binaryPropertyName];
1128
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1129
- if (!buffer || buffer.length === 0) {
1130
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
1131
- }
1132
- const base64File = buffer.toString('base64');
1133
- body.file = base64File;
1134
- if (binaryData.fileName) {
1135
- body.fileName = binaryData.fileName;
1136
- }
1137
- }
1138
- else if (inputType === 'url') {
1139
- const invoiceUrl = this.getNodeParameter('url', i);
1140
- body.url = invoiceUrl;
1141
- }
1142
- else {
1143
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
1144
- }
1145
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
1146
- method: 'POST',
1147
- url: `${baseURL}/invoice-ask`,
1148
- body,
1149
- json: true,
1150
- }));
1151
- }
1152
- else if (operation === 'extract') {
1153
- const inputType = this.getNodeParameter('inputType', i);
1154
- const prompt = this.getNodeParameter('prompt', i);
1155
- const schemaString = this.getNodeParameter('schema', i);
1156
- const body = {};
1157
- body.prompt = prompt;
1158
- try {
1159
- const schema = JSON.parse(schemaString);
1160
- if (schema.type !== 'object') {
1161
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must have type "object"', {
1162
- itemIndex: i,
1163
- });
1164
- }
1165
- if (schema.additionalProperties !== false) {
1166
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Schema must include "additionalProperties": false', { itemIndex: i });
1167
- }
1168
- body.schema = schema;
1169
- }
1170
- catch (error) {
1171
- if (error instanceof n8n_workflow_1.NodeOperationError) {
1172
- throw error;
1173
- }
1174
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON schema: ${error.message}`, { itemIndex: i });
1175
- }
1176
- if (inputType === 'file') {
1177
- const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1178
- if (!((_f = items[i].binary) === null || _f === void 0 ? void 0 : _f[binaryPropertyName])) {
1179
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `No binary data found in property "${binaryPropertyName}"`, { itemIndex: i });
1180
- }
1181
- const binaryData = items[i].binary[binaryPropertyName];
1182
- const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1183
- if (!buffer || buffer.length === 0) {
1184
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Binary data in property "${binaryPropertyName}" is empty or invalid`, { itemIndex: i });
1185
- }
1186
- const base64File = buffer.toString('base64');
1187
- body.file = base64File;
1188
- if (binaryData.fileName) {
1189
- body.fileName = binaryData.fileName;
1190
- }
1191
- }
1192
- else if (inputType === 'url') {
1193
- const invoiceUrl = this.getNodeParameter('url', i);
1194
- body.url = invoiceUrl;
1195
- }
1196
- else {
1197
- throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid input type: ${inputType}. Must be either 'file' or 'url'`, { itemIndex: i });
1198
- }
1199
- responseData = (await this.helpers.httpRequestWithAuthentication.call(this, 'pdfVectorApi', {
1200
- method: 'POST',
1201
- url: `${baseURL}/invoice-extract`,
1202
- body,
1203
- json: true,
1204
- }));
1205
- }
65
+ case 'invoice':
66
+ result = await (0, index_js_5.executeInvoice)(this, domain, apiKey, operation, i);
67
+ break;
68
+ case 'bankStatement':
69
+ result = await (0, index_js_2.executeBankStatement)(this, domain, apiKey, operation, i);
70
+ break;
71
+ case 'academic':
72
+ result = await (0, index_js_1.executeAcademic)(this, domain, apiKey, operation, i);
1206
73
  break;
1207
- }
1208
74
  }
1209
- const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
1210
- returnData.push(...executionData);
75
+ returnData.push({ json: result, pairedItem: { item: i } });
1211
76
  }
1212
77
  catch (error) {
1213
78
  if (this.continueOnFail()) {
1214
- let errorMessage = error.message;
1215
- let errorDetails = { error: errorMessage };
1216
- if (error.response) {
1217
- const response = error.response;
1218
- if (response.body) {
1219
- errorDetails = {
1220
- error: response.body.error || response.body.message || errorMessage,
1221
- statusCode: response.statusCode,
1222
- details: response.body,
1223
- };
1224
- }
1225
- else {
1226
- errorDetails = {
1227
- error: errorMessage,
1228
- statusCode: response.statusCode,
1229
- };
1230
- }
1231
- if (response.statusCode === 401) {
1232
- errorDetails.error = 'Invalid API key. Please check your PDFVector API credentials.';
1233
- }
1234
- else if (response.statusCode === 402) {
1235
- errorDetails.error =
1236
- 'Insufficient credits. Please add more credits to your PDFVector account.';
1237
- }
1238
- else if (response.statusCode === 429) {
1239
- errorDetails.error = 'Rate limit exceeded. Please wait before making more requests.';
1240
- }
1241
- else if (response.statusCode === 400) {
1242
- errorDetails.error = `Bad request: ${errorDetails.error}`;
1243
- }
79
+ let message;
80
+ if (error instanceof Error && 'code' in error) {
81
+ const err = error;
82
+ message = `[${err.code}] ${err.message}`;
83
+ }
84
+ else if (error instanceof Error) {
85
+ message = error.message;
86
+ }
87
+ else {
88
+ message = String(error);
1244
89
  }
1245
- const executionErrorData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(errorDetails), { itemData: { item: i } });
1246
- returnData.push(...executionErrorData);
90
+ returnData.push({ json: { error: message }, pairedItem: { item: i } });
1247
91
  continue;
1248
92
  }
1249
93
  throw error;