@aiteza/n8n-nodes-aiteza 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Aiteza = void 0;
4
+ const GenericFunctions_1 = require("./GenericFunctions");
5
+ class Aiteza {
6
+ description = {
7
+ displayName: 'AITEZA',
8
+ name: 'aiteza',
9
+ icon: 'file:aiteza.svg',
10
+ group: ['transform'],
11
+ version: [1],
12
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
13
+ description: 'Interact with the AITEZA REST API',
14
+ defaults: { name: 'AITEZA' },
15
+ inputs: ['main'],
16
+ outputs: ['main'],
17
+ credentials: [
18
+ {
19
+ name: 'aitezaOAuth2Api',
20
+ required: true,
21
+ },
22
+ ],
23
+ properties: [
24
+ // ------------------------------------------------------------------
25
+ // Resource
26
+ // ------------------------------------------------------------------
27
+ {
28
+ displayName: 'Resource',
29
+ name: 'resource',
30
+ type: 'options',
31
+ noDataExpression: true,
32
+ options: [
33
+ { name: 'Chat', value: 'chat' },
34
+ { name: 'Dataroom', value: 'dataroom' },
35
+ { name: 'File', value: 'file' },
36
+ { name: 'Image', value: 'image' },
37
+ { name: 'Model', value: 'model' },
38
+ { name: 'Web Source', value: 'webSource' },
39
+ ],
40
+ default: 'dataroom',
41
+ },
42
+ // ==================================================================
43
+ // DATAROOM
44
+ // ==================================================================
45
+ {
46
+ displayName: 'Operation',
47
+ name: 'operation',
48
+ type: 'options',
49
+ noDataExpression: true,
50
+ displayOptions: { show: { resource: ['dataroom'] } },
51
+ options: [
52
+ { name: 'Create', value: 'create', action: 'Create a dataroom' },
53
+ { name: 'Delete', value: 'delete', action: 'Delete datarooms' },
54
+ { name: 'Get', value: 'get', action: 'Get a dataroom' },
55
+ { name: 'Get Children', value: 'getChildren', action: 'Get children of a dataroom' },
56
+ { name: 'Search', value: 'search', action: 'Search datarooms by name' },
57
+ { name: 'Update', value: 'update', action: 'Update a dataroom' },
58
+ ],
59
+ default: 'get',
60
+ },
61
+ // Dataroom → Get / Update
62
+ {
63
+ displayName: 'Dataroom Name or ID',
64
+ name: 'dataroomId',
65
+ type: 'options',
66
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
67
+ required: true,
68
+ default: '',
69
+ displayOptions: { show: { resource: ['dataroom'], operation: ['get', 'update'] } },
70
+ description: 'The dataroom to operate on. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
71
+ },
72
+ // Dataroom → Get Children
73
+ {
74
+ displayName: 'Parent Dataroom Name or ID',
75
+ name: 'dataroomId',
76
+ type: 'options',
77
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
78
+ required: true,
79
+ default: '',
80
+ displayOptions: { show: { resource: ['dataroom'], operation: ['getChildren'] } },
81
+ description: 'The parent dataroom. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>. Use "all" for root level.',
82
+ },
83
+ {
84
+ displayName: 'Name Filter',
85
+ name: 'nameFilter',
86
+ type: 'string',
87
+ default: '',
88
+ displayOptions: { show: { resource: ['dataroom'], operation: ['getChildren'] } },
89
+ description: 'Filter children by name (case-insensitive)',
90
+ },
91
+ {
92
+ displayName: 'Additional Fields',
93
+ name: 'additionalFields',
94
+ type: 'collection',
95
+ placeholder: 'Add Field',
96
+ default: {},
97
+ displayOptions: { show: { resource: ['dataroom'], operation: ['getChildren'] } },
98
+ options: [
99
+ {
100
+ displayName: 'Sort By',
101
+ name: 'sortBy',
102
+ type: 'string',
103
+ default: 'name',
104
+ description: 'Field name to sort by',
105
+ },
106
+ {
107
+ displayName: 'Sort Order',
108
+ name: 'sortOrder',
109
+ type: 'options',
110
+ options: [
111
+ { name: 'Ascending', value: 'ASC' },
112
+ { name: 'Descending', value: 'DESC' },
113
+ ],
114
+ default: 'ASC',
115
+ description: 'Sort direction',
116
+ },
117
+ ],
118
+ },
119
+ // Dataroom → Search
120
+ {
121
+ displayName: 'Search Name',
122
+ name: 'name',
123
+ type: 'string',
124
+ required: true,
125
+ default: '',
126
+ displayOptions: { show: { resource: ['dataroom'], operation: ['search'] } },
127
+ description: 'Name to search for (case-insensitive)',
128
+ },
129
+ // Dataroom → Create
130
+ {
131
+ displayName: 'Name',
132
+ name: 'name',
133
+ type: 'string',
134
+ required: true,
135
+ default: '',
136
+ displayOptions: { show: { resource: ['dataroom'], operation: ['create'] } },
137
+ description: 'Name of the new dataroom',
138
+ },
139
+ {
140
+ displayName: 'Access',
141
+ name: 'access',
142
+ type: 'options',
143
+ required: true,
144
+ default: 'private',
145
+ displayOptions: { show: { resource: ['dataroom'], operation: ['create'] } },
146
+ options: [
147
+ { name: 'Private', value: 'private' },
148
+ { name: 'Inherit', value: 'inherit' },
149
+ { name: 'Custom', value: 'custom' },
150
+ ],
151
+ description: 'Access control type for the dataroom',
152
+ },
153
+ {
154
+ displayName: 'Parent Dataroom Name or ID',
155
+ name: 'parentId',
156
+ type: 'options',
157
+ typeOptions: { loadOptionsMethod: 'getDataroomsOptional' },
158
+ default: '',
159
+ displayOptions: { show: { resource: ['dataroom'], operation: ['create'] } },
160
+ description: 'Optional parent dataroom. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
161
+ },
162
+ // Dataroom → Update
163
+ {
164
+ displayName: 'Update Fields',
165
+ name: 'updateFields',
166
+ type: 'collection',
167
+ placeholder: 'Add Field',
168
+ default: {},
169
+ displayOptions: { show: { resource: ['dataroom'], operation: ['update'] } },
170
+ options: [
171
+ {
172
+ displayName: 'Name',
173
+ name: 'name',
174
+ type: 'string',
175
+ default: '',
176
+ description: 'New name for the dataroom',
177
+ },
178
+ {
179
+ displayName: 'Description',
180
+ name: 'description',
181
+ type: 'string',
182
+ default: '',
183
+ description: 'Description of the dataroom',
184
+ },
185
+ {
186
+ displayName: 'Custom Instructions',
187
+ name: 'customInstructions',
188
+ type: 'string',
189
+ typeOptions: { rows: 3 },
190
+ default: '',
191
+ description: 'Custom instructions for the AI assistant in this dataroom',
192
+ },
193
+ {
194
+ displayName: 'Category',
195
+ name: 'category',
196
+ type: 'string',
197
+ default: '',
198
+ description: 'Category of the dataroom',
199
+ },
200
+ ],
201
+ },
202
+ // Dataroom → Delete
203
+ {
204
+ displayName: 'Dataroom IDs',
205
+ name: 'dataroomIds',
206
+ type: 'string',
207
+ required: true,
208
+ default: '',
209
+ displayOptions: { show: { resource: ['dataroom'], operation: ['delete'] } },
210
+ description: 'Comma-separated list of dataroom IDs to delete',
211
+ },
212
+ // ==================================================================
213
+ // FILE
214
+ // ==================================================================
215
+ {
216
+ displayName: 'Operation',
217
+ name: 'operation',
218
+ type: 'options',
219
+ noDataExpression: true,
220
+ displayOptions: { show: { resource: ['file'] } },
221
+ options: [
222
+ { name: 'Assign to Dataroom', value: 'assign', action: 'Assign a standalone file to a dataroom' },
223
+ { name: 'Delete', value: 'delete', action: 'Delete a file from a dataroom' },
224
+ { name: 'Delete Standalone', value: 'deleteStandalone', action: 'Delete a standalone file' },
225
+ { name: 'Get', value: 'get', action: 'Get a file from a dataroom' },
226
+ { name: 'Get Content', value: 'getContent', action: 'Get processed text content of a standalone file' },
227
+ { name: 'Get Many', value: 'getMany', action: 'Get files in a dataroom' },
228
+ { name: 'Get Many Standalone', value: 'getManyStandalone', action: 'Get standalone files' },
229
+ { name: 'Get Metadata', value: 'getMetadata', action: 'Get metadata of a standalone file' },
230
+ { name: 'Get Status', value: 'getStatus', action: 'Get file processing status' },
231
+ { name: 'Upload', value: 'upload', action: 'Upload a file to a dataroom' },
232
+ { name: 'Upload Standalone', value: 'uploadStandalone', action: 'Upload a standalone file' },
233
+ ],
234
+ default: 'getMany',
235
+ },
236
+ // File → Dataroom ID (for dataroom-scoped operations)
237
+ {
238
+ displayName: 'Dataroom Name or ID',
239
+ name: 'dataroomId',
240
+ type: 'options',
241
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
242
+ required: true,
243
+ default: '',
244
+ displayOptions: {
245
+ show: { resource: ['file'], operation: ['getMany', 'get', 'delete', 'upload'] },
246
+ },
247
+ description: 'The dataroom. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
248
+ },
249
+ // File → File ID (dataroom-scoped)
250
+ {
251
+ displayName: 'File Name or ID',
252
+ name: 'fileId',
253
+ type: 'options',
254
+ typeOptions: { loadOptionsMethod: 'getFilesInDataroom', loadOptionsDependsOn: ['dataroomId'] },
255
+ required: true,
256
+ default: '',
257
+ displayOptions: { show: { resource: ['file'], operation: ['get', 'delete'] } },
258
+ description: 'The file. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
259
+ },
260
+ // File → File ID (standalone operations)
261
+ {
262
+ displayName: 'File Name or ID',
263
+ name: 'fileId',
264
+ type: 'options',
265
+ typeOptions: { loadOptionsMethod: 'getStandaloneFiles' },
266
+ required: true,
267
+ default: '',
268
+ displayOptions: {
269
+ show: { resource: ['file'], operation: ['getStatus', 'getMetadata', 'getContent', 'deleteStandalone', 'assign'] },
270
+ },
271
+ description: 'The standalone file. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
272
+ },
273
+ // File → Assign: target dataroom
274
+ {
275
+ displayName: 'Target Dataroom Name or ID',
276
+ name: 'targetDataroomId',
277
+ type: 'options',
278
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
279
+ required: true,
280
+ default: '',
281
+ displayOptions: { show: { resource: ['file'], operation: ['assign'] } },
282
+ description: 'The dataroom to assign the file to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
283
+ },
284
+ // File → Get Many (pagination)
285
+ {
286
+ displayName: 'Additional Fields',
287
+ name: 'additionalFields',
288
+ type: 'collection',
289
+ placeholder: 'Add Field',
290
+ default: {},
291
+ displayOptions: { show: { resource: ['file'], operation: ['getMany', 'getManyStandalone'] } },
292
+ options: [
293
+ {
294
+ displayName: 'Page',
295
+ name: 'page',
296
+ type: 'number',
297
+ default: 0,
298
+ description: 'Page number (0-based)',
299
+ },
300
+ {
301
+ displayName: 'Size',
302
+ name: 'size',
303
+ type: 'number',
304
+ default: 20,
305
+ description: 'Number of items per page',
306
+ },
307
+ {
308
+ displayName: 'Search Term',
309
+ name: 'search_term',
310
+ type: 'string',
311
+ default: '',
312
+ description: 'Filter by name',
313
+ },
314
+ {
315
+ displayName: 'Sort By',
316
+ name: 'sortBy',
317
+ type: 'string',
318
+ default: '',
319
+ description: 'Field name to sort by',
320
+ },
321
+ {
322
+ displayName: 'Sort Order',
323
+ name: 'sortOrder',
324
+ type: 'options',
325
+ options: [
326
+ { name: 'Ascending', value: 'ASC' },
327
+ { name: 'Descending', value: 'DESC' },
328
+ ],
329
+ default: 'ASC',
330
+ },
331
+ ],
332
+ },
333
+ // File → Upload / Upload Standalone
334
+ {
335
+ displayName: 'Binary Property',
336
+ name: 'binaryPropertyName',
337
+ type: 'string',
338
+ required: true,
339
+ default: 'data',
340
+ displayOptions: { show: { resource: ['file'], operation: ['upload', 'uploadStandalone'] } },
341
+ description: 'Name of the binary property containing the file to upload',
342
+ },
343
+ {
344
+ displayName: 'Processing Pipeline',
345
+ name: 'processingPipeline',
346
+ type: 'options',
347
+ required: true,
348
+ default: 'DOCLING',
349
+ displayOptions: { show: { resource: ['file'], operation: ['upload', 'uploadStandalone'] } },
350
+ options: [
351
+ { name: 'TIKA', value: 'TIKA' },
352
+ { name: 'DOCLING', value: 'DOCLING' },
353
+ { name: 'DOCLING Force OCR', value: 'DOCLING_FORCE_OCR' },
354
+ { name: 'VLM', value: 'VLM' },
355
+ ],
356
+ description: 'The processing pipeline to use for document processing',
357
+ },
358
+ {
359
+ displayName: 'VLM Model',
360
+ name: 'vlmModel',
361
+ type: 'string',
362
+ default: '',
363
+ displayOptions: { show: { resource: ['file'], operation: ['upload', 'uploadStandalone'], processingPipeline: ['VLM'] } },
364
+ description: 'VLM model name to use (required when pipeline is VLM)',
365
+ },
366
+ // ==================================================================
367
+ // IMAGE
368
+ // ==================================================================
369
+ {
370
+ displayName: 'Operation',
371
+ name: 'operation',
372
+ type: 'options',
373
+ noDataExpression: true,
374
+ displayOptions: { show: { resource: ['image'] } },
375
+ options: [
376
+ { name: 'Assign to Dataroom', value: 'assign', action: 'Assign a standalone image to a dataroom' },
377
+ { name: 'Delete (Dataroom)', value: 'deleteDataroom', action: 'Delete an image from a dataroom' },
378
+ { name: 'Delete Standalone', value: 'deleteStandalone', action: 'Delete a standalone image' },
379
+ { name: 'Get (Dataroom)', value: 'getDataroom', action: 'Get an image from a dataroom' },
380
+ { name: 'Get Many (Dataroom)', value: 'getManyDataroom', action: 'Get images in a dataroom' },
381
+ { name: 'Get Many Standalone', value: 'getManyStandalone', action: 'Get standalone images' },
382
+ { name: 'Get Metadata', value: 'getMetadata', action: 'Get metadata of a standalone image' },
383
+ { name: 'Get Status', value: 'getStatus', action: 'Get image processing status' },
384
+ { name: 'Upload (Dataroom)', value: 'uploadDataroom', action: 'Upload an image to a dataroom' },
385
+ { name: 'Upload Standalone', value: 'uploadStandalone', action: 'Upload a standalone image' },
386
+ ],
387
+ default: 'getManyDataroom',
388
+ },
389
+ // Image → Dataroom ID
390
+ {
391
+ displayName: 'Dataroom Name or ID',
392
+ name: 'dataroomId',
393
+ type: 'options',
394
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
395
+ required: true,
396
+ default: '',
397
+ displayOptions: {
398
+ show: { resource: ['image'], operation: ['getManyDataroom', 'getDataroom', 'deleteDataroom', 'uploadDataroom'] },
399
+ },
400
+ description: 'The dataroom. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
401
+ },
402
+ // Image → Image ID (dataroom)
403
+ {
404
+ displayName: 'Image Name or ID',
405
+ name: 'imageId',
406
+ type: 'options',
407
+ typeOptions: { loadOptionsMethod: 'getImagesInDataroom', loadOptionsDependsOn: ['dataroomId'] },
408
+ required: true,
409
+ default: '',
410
+ displayOptions: { show: { resource: ['image'], operation: ['getDataroom', 'deleteDataroom'] } },
411
+ description: 'The image. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
412
+ },
413
+ // Image → Image ID (standalone)
414
+ {
415
+ displayName: 'Image Name or ID',
416
+ name: 'imageId',
417
+ type: 'options',
418
+ typeOptions: { loadOptionsMethod: 'getStandaloneImages' },
419
+ required: true,
420
+ default: '',
421
+ displayOptions: {
422
+ show: { resource: ['image'], operation: ['getMetadata', 'getStatus', 'deleteStandalone', 'assign'] },
423
+ },
424
+ description: 'The standalone image. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
425
+ },
426
+ // Image → Assign target
427
+ {
428
+ displayName: 'Target Dataroom Name or ID',
429
+ name: 'targetDataroomId',
430
+ type: 'options',
431
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
432
+ required: true,
433
+ default: '',
434
+ displayOptions: { show: { resource: ['image'], operation: ['assign'] } },
435
+ description: 'The dataroom to assign the image to. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
436
+ },
437
+ // Image → Get Many pagination
438
+ {
439
+ displayName: 'Additional Fields',
440
+ name: 'additionalFields',
441
+ type: 'collection',
442
+ placeholder: 'Add Field',
443
+ default: {},
444
+ displayOptions: { show: { resource: ['image'], operation: ['getManyDataroom', 'getManyStandalone'] } },
445
+ options: [
446
+ {
447
+ displayName: 'Page',
448
+ name: 'page',
449
+ type: 'number',
450
+ default: 0,
451
+ description: 'Page number (0-based)',
452
+ },
453
+ {
454
+ displayName: 'Size',
455
+ name: 'size',
456
+ type: 'number',
457
+ default: 20,
458
+ description: 'Number of items per page',
459
+ },
460
+ {
461
+ displayName: 'Search Term',
462
+ name: 'search_term',
463
+ type: 'string',
464
+ default: '',
465
+ description: 'Filter by image name',
466
+ },
467
+ {
468
+ displayName: 'Sort By',
469
+ name: 'sortBy',
470
+ type: 'string',
471
+ default: '',
472
+ },
473
+ {
474
+ displayName: 'Sort Order',
475
+ name: 'sortOrder',
476
+ type: 'options',
477
+ options: [
478
+ { name: 'Ascending', value: 'ASC' },
479
+ { name: 'Descending', value: 'DESC' },
480
+ ],
481
+ default: 'ASC',
482
+ },
483
+ ],
484
+ },
485
+ // Image → Upload binary
486
+ {
487
+ displayName: 'Binary Property',
488
+ name: 'binaryPropertyName',
489
+ type: 'string',
490
+ required: true,
491
+ default: 'data',
492
+ displayOptions: { show: { resource: ['image'], operation: ['uploadDataroom', 'uploadStandalone'] } },
493
+ description: 'Name of the binary property containing the image to upload',
494
+ },
495
+ // ==================================================================
496
+ // WEB SOURCE
497
+ // ==================================================================
498
+ {
499
+ displayName: 'Operation',
500
+ name: 'operation',
501
+ type: 'options',
502
+ noDataExpression: true,
503
+ displayOptions: { show: { resource: ['webSource'] } },
504
+ options: [
505
+ { name: 'Add', value: 'add', action: 'Add a web source to a dataroom' },
506
+ { name: 'Delete', value: 'delete', action: 'Delete a web source' },
507
+ { name: 'Get', value: 'get', action: 'Get a web source' },
508
+ { name: 'Get Many', value: 'getMany', action: 'Get web sources in a dataroom' },
509
+ ],
510
+ default: 'getMany',
511
+ },
512
+ {
513
+ displayName: 'Dataroom Name or ID',
514
+ name: 'dataroomId',
515
+ type: 'options',
516
+ typeOptions: { loadOptionsMethod: 'getDatarooms' },
517
+ required: true,
518
+ default: '',
519
+ displayOptions: { show: { resource: ['webSource'] } },
520
+ description: 'The dataroom. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
521
+ },
522
+ // Web Source → Get / Delete
523
+ {
524
+ displayName: 'Web Source Name or ID',
525
+ name: 'webSourceId',
526
+ type: 'options',
527
+ typeOptions: { loadOptionsMethod: 'getWebSourcesInDataroom', loadOptionsDependsOn: ['dataroomId'] },
528
+ required: true,
529
+ default: '',
530
+ displayOptions: { show: { resource: ['webSource'], operation: ['get', 'delete'] } },
531
+ description: 'The web source. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
532
+ },
533
+ // Web Source → Add
534
+ {
535
+ displayName: 'URL',
536
+ name: 'url',
537
+ type: 'string',
538
+ required: true,
539
+ default: '',
540
+ displayOptions: { show: { resource: ['webSource'], operation: ['add'] } },
541
+ description: 'The URL to crawl',
542
+ },
543
+ {
544
+ displayName: 'Additional Fields',
545
+ name: 'additionalFields',
546
+ type: 'collection',
547
+ placeholder: 'Add Field',
548
+ default: {},
549
+ displayOptions: { show: { resource: ['webSource'], operation: ['add'] } },
550
+ options: [
551
+ {
552
+ displayName: 'Name',
553
+ name: 'name',
554
+ type: 'string',
555
+ default: '',
556
+ description: 'Display name for the web source',
557
+ },
558
+ {
559
+ displayName: 'Include Subpages',
560
+ name: 'includeSubpages',
561
+ type: 'boolean',
562
+ default: false,
563
+ description: 'Whether to crawl subpages',
564
+ },
565
+ {
566
+ displayName: 'Max Subpages',
567
+ name: 'maxSubpages',
568
+ type: 'number',
569
+ default: 10,
570
+ description: 'Maximum number of subpages to crawl',
571
+ },
572
+ {
573
+ displayName: 'Max Depth',
574
+ name: 'maxDepth',
575
+ type: 'number',
576
+ default: 1,
577
+ description: 'Maximum crawl depth',
578
+ },
579
+ ],
580
+ },
581
+ // Web Source → Get Many pagination
582
+ {
583
+ displayName: 'Additional Fields',
584
+ name: 'additionalFields',
585
+ type: 'collection',
586
+ placeholder: 'Add Field',
587
+ default: {},
588
+ displayOptions: { show: { resource: ['webSource'], operation: ['getMany'] } },
589
+ options: [
590
+ {
591
+ displayName: 'Page',
592
+ name: 'page',
593
+ type: 'number',
594
+ default: 0,
595
+ },
596
+ {
597
+ displayName: 'Size',
598
+ name: 'size',
599
+ type: 'number',
600
+ default: 20,
601
+ },
602
+ {
603
+ displayName: 'Search Term',
604
+ name: 'search_term',
605
+ type: 'string',
606
+ default: '',
607
+ },
608
+ ],
609
+ },
610
+ // ==================================================================
611
+ // CHAT
612
+ // ==================================================================
613
+ {
614
+ displayName: 'Operation',
615
+ name: 'operation',
616
+ type: 'options',
617
+ noDataExpression: true,
618
+ displayOptions: { show: { resource: ['chat'] } },
619
+ options: [
620
+ { name: 'Create', value: 'create', action: 'Create a chat' },
621
+ { name: 'Delete', value: 'delete', action: 'Delete a chat' },
622
+ { name: 'Generate', value: 'generate', action: 'Generate a response in a chat' },
623
+ { name: 'Get', value: 'get', action: 'Get a chat' },
624
+ { name: 'Get Many', value: 'getMany', action: 'Get all chats (paginated)' },
625
+ { name: 'Get Messages', value: 'getMessages', action: 'Get chat messages' },
626
+ { name: 'Rename', value: 'rename', action: 'Rename a chat' },
627
+ ],
628
+ default: 'generate',
629
+ },
630
+ // Chat → Create
631
+ {
632
+ displayName: 'Chat Name',
633
+ name: 'chatName',
634
+ type: 'string',
635
+ default: '',
636
+ displayOptions: { show: { resource: ['chat'], operation: ['create'] } },
637
+ description: 'Optional name for the chat',
638
+ },
639
+ // Chat → Get / Get Messages / Delete / Generate / Rename
640
+ {
641
+ displayName: 'Chat Name or ID',
642
+ name: 'chatId',
643
+ type: 'options',
644
+ typeOptions: { loadOptionsMethod: 'getChats' },
645
+ required: true,
646
+ default: '',
647
+ displayOptions: {
648
+ show: { resource: ['chat'], operation: ['get', 'getMessages', 'delete', 'generate', 'rename'] },
649
+ },
650
+ description: 'The chat. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>. Use "new" to auto-create a chat for generate.',
651
+ },
652
+ // Chat → Rename
653
+ {
654
+ displayName: 'New Name',
655
+ name: 'newName',
656
+ type: 'string',
657
+ required: true,
658
+ default: '',
659
+ displayOptions: { show: { resource: ['chat'], operation: ['rename'] } },
660
+ description: 'The new name for the chat',
661
+ },
662
+ // Chat → Get Many pagination
663
+ {
664
+ displayName: 'Additional Fields',
665
+ name: 'additionalFields',
666
+ type: 'collection',
667
+ placeholder: 'Add Field',
668
+ default: {},
669
+ displayOptions: { show: { resource: ['chat'], operation: ['getMany'] } },
670
+ options: [
671
+ {
672
+ displayName: 'Page',
673
+ name: 'page',
674
+ type: 'number',
675
+ default: 0,
676
+ },
677
+ {
678
+ displayName: 'Size',
679
+ name: 'size',
680
+ type: 'number',
681
+ default: 20,
682
+ },
683
+ {
684
+ displayName: 'Query',
685
+ name: 'query',
686
+ type: 'string',
687
+ default: '',
688
+ description: 'Filter chats by name (case-insensitive)',
689
+ },
690
+ ],
691
+ },
692
+ // Chat → Generate
693
+ {
694
+ displayName: 'Prompt',
695
+ name: 'prompt',
696
+ type: 'string',
697
+ required: true,
698
+ typeOptions: { rows: 4 },
699
+ default: '',
700
+ displayOptions: { show: { resource: ['chat'], operation: ['generate'] } },
701
+ description: 'The prompt / question to send to the model',
702
+ },
703
+ {
704
+ displayName: 'Model Name or ID',
705
+ name: 'model',
706
+ type: 'options',
707
+ typeOptions: { loadOptionsMethod: 'getModels' },
708
+ required: true,
709
+ default: '',
710
+ displayOptions: { show: { resource: ['chat'], operation: ['generate'] } },
711
+ description: 'AI model to use. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
712
+ },
713
+ {
714
+ displayName: 'Additional Fields',
715
+ name: 'additionalFields',
716
+ type: 'collection',
717
+ placeholder: 'Add Field',
718
+ default: {},
719
+ displayOptions: { show: { resource: ['chat'], operation: ['generate'] } },
720
+ options: [
721
+ {
722
+ displayName: 'Connected Dataroom IDs',
723
+ name: 'connectedDatarooms',
724
+ type: 'string',
725
+ default: '',
726
+ description: 'Comma-separated dataroom IDs for context',
727
+ },
728
+ {
729
+ displayName: 'File IDs',
730
+ name: 'fileIds',
731
+ type: 'string',
732
+ default: '',
733
+ description: 'Comma-separated previously uploaded file IDs',
734
+ },
735
+ {
736
+ displayName: 'Image IDs',
737
+ name: 'imageIds',
738
+ type: 'string',
739
+ default: '',
740
+ description: 'Comma-separated previously uploaded image IDs',
741
+ },
742
+ {
743
+ displayName: 'Include Parent Datarooms',
744
+ name: 'parentDatarooms',
745
+ type: 'boolean',
746
+ default: false,
747
+ },
748
+ {
749
+ displayName: 'Include Sub-Datarooms',
750
+ name: 'subDatarooms',
751
+ type: 'boolean',
752
+ default: false,
753
+ },
754
+ {
755
+ displayName: 'Web Search Enabled',
756
+ name: 'webSearchEnabled',
757
+ type: 'boolean',
758
+ default: true,
759
+ },
760
+ {
761
+ displayName: 'Agentic Mode',
762
+ name: 'agenticMode',
763
+ type: 'boolean',
764
+ default: false,
765
+ description: 'Whether the LLM autonomously decides which datarooms and files to search',
766
+ },
767
+ ],
768
+ },
769
+ // ==================================================================
770
+ // MODEL
771
+ // ==================================================================
772
+ {
773
+ displayName: 'Operation',
774
+ name: 'operation',
775
+ type: 'options',
776
+ noDataExpression: true,
777
+ displayOptions: { show: { resource: ['model'] } },
778
+ options: [
779
+ { name: 'Get', value: 'get', action: 'Get a model by ID' },
780
+ { name: 'Get Many', value: 'getMany', action: 'Get all models' },
781
+ { name: 'Get Processing Models', value: 'getProcessing', action: 'Get available processing pipelines' },
782
+ { name: 'Get VLM Models', value: 'getVlm', action: 'Get available VLM models' },
783
+ ],
784
+ default: 'getMany',
785
+ },
786
+ {
787
+ displayName: 'Model Name or ID',
788
+ name: 'modelId',
789
+ type: 'options',
790
+ typeOptions: { loadOptionsMethod: 'getModels' },
791
+ required: true,
792
+ default: '',
793
+ displayOptions: { show: { resource: ['model'], operation: ['get'] } },
794
+ description: 'The model. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
795
+ },
796
+ ],
797
+ };
798
+ methods = {
799
+ loadOptions: {
800
+ getDatarooms: GenericFunctions_1.loadDatarooms,
801
+ getDataroomsOptional: GenericFunctions_1.loadDataroomsOptional,
802
+ getModels: GenericFunctions_1.loadModels,
803
+ getChats: GenericFunctions_1.loadChats,
804
+ getFilesInDataroom: GenericFunctions_1.loadFilesInDataroom,
805
+ getImagesInDataroom: GenericFunctions_1.loadImagesInDataroom,
806
+ getWebSourcesInDataroom: GenericFunctions_1.loadWebSourcesInDataroom,
807
+ getStandaloneFiles: GenericFunctions_1.loadStandaloneFiles,
808
+ getStandaloneImages: GenericFunctions_1.loadStandaloneImages,
809
+ },
810
+ };
811
+ async execute() {
812
+ const items = this.getInputData();
813
+ const returnData = [];
814
+ const resource = this.getNodeParameter('resource', 0);
815
+ const operation = this.getNodeParameter('operation', 0);
816
+ for (let i = 0; i < items.length; i++) {
817
+ try {
818
+ let responseData;
819
+ // =============================================================
820
+ // DATAROOM
821
+ // =============================================================
822
+ if (resource === 'dataroom') {
823
+ if (operation === 'get') {
824
+ const id = this.getNodeParameter('dataroomId', i);
825
+ (0, GenericFunctions_1.validateRequiredField)(this, id, 'Dataroom ID');
826
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${id}`);
827
+ }
828
+ if (operation === 'getChildren') {
829
+ const id = this.getNodeParameter('dataroomId', i);
830
+ const nameFilter = this.getNodeParameter('nameFilter', i, '');
831
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
832
+ const qs = { name: nameFilter };
833
+ if (additionalFields.sortBy)
834
+ qs.sortBy = additionalFields.sortBy;
835
+ if (additionalFields.sortOrder)
836
+ qs.sortOrder = additionalFields.sortOrder;
837
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${id}/children`, {}, qs);
838
+ }
839
+ if (operation === 'search') {
840
+ const name = this.getNodeParameter('name', i);
841
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/dataroom/search', {}, { name });
842
+ }
843
+ if (operation === 'create') {
844
+ const name = this.getNodeParameter('name', i);
845
+ const access = this.getNodeParameter('access', i);
846
+ const parentId = this.getNodeParameter('parentId', i, '');
847
+ (0, GenericFunctions_1.validateRequiredField)(this, name, 'Name');
848
+ const body = { name, access };
849
+ if (parentId)
850
+ body.parent = parentId;
851
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'POST', '/api/dataroom', body);
852
+ }
853
+ if (operation === 'update') {
854
+ const id = this.getNodeParameter('dataroomId', i);
855
+ const updateFields = this.getNodeParameter('updateFields', i, {});
856
+ (0, GenericFunctions_1.validateRequiredField)(this, id, 'Dataroom ID');
857
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'PATCH', `/api/dataroom/${id}`, updateFields);
858
+ }
859
+ if (operation === 'delete') {
860
+ const idsRaw = this.getNodeParameter('dataroomIds', i);
861
+ const dataroomIds = idsRaw.split(',').map((s) => s.trim()).filter(Boolean);
862
+ (0, GenericFunctions_1.validateRequiredField)(this, dataroomIds.length > 0 ? 'ok' : '', 'Dataroom IDs');
863
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', '/api/dataroom/delete', { dataroomIds });
864
+ }
865
+ }
866
+ // =============================================================
867
+ // FILE
868
+ // =============================================================
869
+ if (resource === 'file') {
870
+ if (operation === 'getMany') {
871
+ const dataroomId = this.getNodeParameter('dataroomId', i);
872
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
873
+ const qs = {};
874
+ if (additionalFields.page !== undefined)
875
+ qs.page = additionalFields.page;
876
+ if (additionalFields.size !== undefined)
877
+ qs.size = additionalFields.size;
878
+ if (additionalFields.search_term)
879
+ qs.search_term = additionalFields.search_term;
880
+ if (additionalFields.sortBy)
881
+ qs.sortBy = additionalFields.sortBy;
882
+ if (additionalFields.sortOrder)
883
+ qs.sortOrder = additionalFields.sortOrder;
884
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/files`, {}, qs);
885
+ }
886
+ if (operation === 'getManyStandalone') {
887
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
888
+ const qs = {};
889
+ if (additionalFields.page !== undefined)
890
+ qs.page = additionalFields.page;
891
+ if (additionalFields.size !== undefined)
892
+ qs.size = additionalFields.size;
893
+ if (additionalFields.search_term)
894
+ qs.search_term = additionalFields.search_term;
895
+ if (additionalFields.sortBy)
896
+ qs.sortBy = additionalFields.sortBy;
897
+ if (additionalFields.sortOrder)
898
+ qs.sortOrder = additionalFields.sortOrder;
899
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/files', {}, qs);
900
+ }
901
+ if (operation === 'get') {
902
+ const dataroomId = this.getNodeParameter('dataroomId', i);
903
+ const fileId = this.getNodeParameter('fileId', i);
904
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/files/${fileId}`);
905
+ }
906
+ if (operation === 'getMetadata') {
907
+ const fileId = this.getNodeParameter('fileId', i);
908
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/files/${fileId}`);
909
+ }
910
+ if (operation === 'getContent') {
911
+ const fileId = this.getNodeParameter('fileId', i);
912
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/files/${fileId}/content`, {}, {}, { json: false });
913
+ if (typeof responseData === 'string') {
914
+ responseData = { content: responseData };
915
+ }
916
+ }
917
+ if (operation === 'getStatus') {
918
+ const fileId = this.getNodeParameter('fileId', i);
919
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/files/${fileId}/status`);
920
+ }
921
+ if (operation === 'delete') {
922
+ const dataroomId = this.getNodeParameter('dataroomId', i);
923
+ const fileId = this.getNodeParameter('fileId', i);
924
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/dataroom/${dataroomId}/files/${fileId}`);
925
+ }
926
+ if (operation === 'deleteStandalone') {
927
+ const fileId = this.getNodeParameter('fileId', i);
928
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/files/${fileId}`);
929
+ }
930
+ if (operation === 'assign') {
931
+ const fileId = this.getNodeParameter('fileId', i);
932
+ const targetDataroomId = this.getNodeParameter('targetDataroomId', i);
933
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'PATCH', `/api/files/${fileId}/assign`, { dataroomId: targetDataroomId });
934
+ }
935
+ if (operation === 'upload') {
936
+ const dataroomId = this.getNodeParameter('dataroomId', i);
937
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
938
+ const processingPipeline = this.getNodeParameter('processingPipeline', i);
939
+ const vlmModel = this.getNodeParameter('vlmModel', i, '');
940
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
941
+ const credentials = await this.getCredentials('aitezaOAuth2Api');
942
+ const baseUrl = credentials.baseUrl.replace(/\/+$/, '');
943
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
944
+ let url = `${baseUrl}/api/dataroom/${dataroomId}/files?processingPipeline=${encodeURIComponent(processingPipeline)}`;
945
+ if (vlmModel)
946
+ url += `&vlmModel=${encodeURIComponent(vlmModel)}`;
947
+ responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'aitezaOAuth2Api', {
948
+ method: 'POST',
949
+ url,
950
+ formData: {
951
+ files: {
952
+ value: buffer,
953
+ options: {
954
+ filename: binaryData.fileName ?? 'file',
955
+ contentType: binaryData.mimeType,
956
+ },
957
+ },
958
+ },
959
+ });
960
+ }
961
+ if (operation === 'uploadStandalone') {
962
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
963
+ const processingPipeline = this.getNodeParameter('processingPipeline', i);
964
+ const vlmModel = this.getNodeParameter('vlmModel', i, '');
965
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
966
+ const credentials = await this.getCredentials('aitezaOAuth2Api');
967
+ const baseUrl = credentials.baseUrl.replace(/\/+$/, '');
968
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
969
+ let url = `${baseUrl}/api/files?processingPipeline=${encodeURIComponent(processingPipeline)}`;
970
+ if (vlmModel)
971
+ url += `&vlmModel=${encodeURIComponent(vlmModel)}`;
972
+ responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'aitezaOAuth2Api', {
973
+ method: 'POST',
974
+ url,
975
+ formData: {
976
+ files: {
977
+ value: buffer,
978
+ options: {
979
+ filename: binaryData.fileName ?? 'file',
980
+ contentType: binaryData.mimeType,
981
+ },
982
+ },
983
+ },
984
+ });
985
+ }
986
+ }
987
+ // =============================================================
988
+ // IMAGE
989
+ // =============================================================
990
+ if (resource === 'image') {
991
+ if (operation === 'getManyDataroom') {
992
+ const dataroomId = this.getNodeParameter('dataroomId', i);
993
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
994
+ const qs = {};
995
+ if (additionalFields.page !== undefined)
996
+ qs.page = additionalFields.page;
997
+ if (additionalFields.size !== undefined)
998
+ qs.size = additionalFields.size;
999
+ if (additionalFields.search_term)
1000
+ qs.search_term = additionalFields.search_term;
1001
+ if (additionalFields.sortBy)
1002
+ qs.sortBy = additionalFields.sortBy;
1003
+ if (additionalFields.sortOrder)
1004
+ qs.sortOrder = additionalFields.sortOrder;
1005
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/images`, {}, qs);
1006
+ }
1007
+ if (operation === 'getManyStandalone') {
1008
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1009
+ const qs = {};
1010
+ if (additionalFields.page !== undefined)
1011
+ qs.page = additionalFields.page;
1012
+ if (additionalFields.size !== undefined)
1013
+ qs.size = additionalFields.size;
1014
+ if (additionalFields.search_term)
1015
+ qs.search_term = additionalFields.search_term;
1016
+ if (additionalFields.sortBy)
1017
+ qs.sortBy = additionalFields.sortBy;
1018
+ if (additionalFields.sortOrder)
1019
+ qs.sortOrder = additionalFields.sortOrder;
1020
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/images', {}, qs);
1021
+ }
1022
+ if (operation === 'getDataroom') {
1023
+ const dataroomId = this.getNodeParameter('dataroomId', i);
1024
+ const imageId = this.getNodeParameter('imageId', i);
1025
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/images/${imageId}`);
1026
+ }
1027
+ if (operation === 'getMetadata') {
1028
+ const imageId = this.getNodeParameter('imageId', i);
1029
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/images/${imageId}`);
1030
+ }
1031
+ if (operation === 'getStatus') {
1032
+ const imageId = this.getNodeParameter('imageId', i);
1033
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/images/${imageId}/status`);
1034
+ }
1035
+ if (operation === 'deleteDataroom') {
1036
+ const dataroomId = this.getNodeParameter('dataroomId', i);
1037
+ const imageId = this.getNodeParameter('imageId', i);
1038
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/dataroom/${dataroomId}/images/${imageId}`);
1039
+ }
1040
+ if (operation === 'deleteStandalone') {
1041
+ const imageId = this.getNodeParameter('imageId', i);
1042
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/images/${imageId}`);
1043
+ }
1044
+ if (operation === 'assign') {
1045
+ const imageId = this.getNodeParameter('imageId', i);
1046
+ const targetDataroomId = this.getNodeParameter('targetDataroomId', i);
1047
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'PATCH', `/api/images/${imageId}/assign`, { dataroomId: targetDataroomId });
1048
+ }
1049
+ if (operation === 'uploadDataroom') {
1050
+ const dataroomId = this.getNodeParameter('dataroomId', i);
1051
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1052
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
1053
+ const credentials = await this.getCredentials('aitezaOAuth2Api');
1054
+ const baseUrl = credentials.baseUrl.replace(/\/+$/, '');
1055
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1056
+ responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'aitezaOAuth2Api', {
1057
+ method: 'POST',
1058
+ url: `${baseUrl}/api/dataroom/${dataroomId}/images`,
1059
+ formData: {
1060
+ images: {
1061
+ value: buffer,
1062
+ options: {
1063
+ filename: binaryData.fileName ?? 'image',
1064
+ contentType: binaryData.mimeType,
1065
+ },
1066
+ },
1067
+ },
1068
+ });
1069
+ }
1070
+ if (operation === 'uploadStandalone') {
1071
+ const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i);
1072
+ const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
1073
+ const credentials = await this.getCredentials('aitezaOAuth2Api');
1074
+ const baseUrl = credentials.baseUrl.replace(/\/+$/, '');
1075
+ const buffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
1076
+ responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'aitezaOAuth2Api', {
1077
+ method: 'POST',
1078
+ url: `${baseUrl}/api/images`,
1079
+ formData: {
1080
+ images: {
1081
+ value: buffer,
1082
+ options: {
1083
+ filename: binaryData.fileName ?? 'image',
1084
+ contentType: binaryData.mimeType,
1085
+ },
1086
+ },
1087
+ },
1088
+ });
1089
+ }
1090
+ }
1091
+ // =============================================================
1092
+ // WEB SOURCE
1093
+ // =============================================================
1094
+ if (resource === 'webSource') {
1095
+ const dataroomId = this.getNodeParameter('dataroomId', i);
1096
+ if (operation === 'getMany') {
1097
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1098
+ const qs = {};
1099
+ if (additionalFields.page !== undefined)
1100
+ qs.page = additionalFields.page;
1101
+ if (additionalFields.size !== undefined)
1102
+ qs.size = additionalFields.size;
1103
+ if (additionalFields.search_term)
1104
+ qs.search_term = additionalFields.search_term;
1105
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/websites`, {}, qs);
1106
+ }
1107
+ if (operation === 'get') {
1108
+ const webSourceId = this.getNodeParameter('webSourceId', i);
1109
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/dataroom/${dataroomId}/websites/${webSourceId}`);
1110
+ }
1111
+ if (operation === 'add') {
1112
+ const url = this.getNodeParameter('url', i);
1113
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1114
+ const body = { url };
1115
+ if (additionalFields.name)
1116
+ body.name = additionalFields.name;
1117
+ if (additionalFields.includeSubpages !== undefined)
1118
+ body.includeSubpages = additionalFields.includeSubpages;
1119
+ if (additionalFields.maxSubpages !== undefined)
1120
+ body.maxSubpages = additionalFields.maxSubpages;
1121
+ if (additionalFields.maxDepth !== undefined)
1122
+ body.maxDepth = additionalFields.maxDepth;
1123
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'POST', `/api/dataroom/${dataroomId}/websites`, body);
1124
+ }
1125
+ if (operation === 'delete') {
1126
+ const webSourceId = this.getNodeParameter('webSourceId', i);
1127
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/dataroom/${dataroomId}/websites/${webSourceId}`);
1128
+ }
1129
+ }
1130
+ // =============================================================
1131
+ // CHAT
1132
+ // =============================================================
1133
+ if (resource === 'chat') {
1134
+ if (operation === 'create') {
1135
+ const chatName = this.getNodeParameter('chatName', i, '');
1136
+ const body = {};
1137
+ if (chatName)
1138
+ body.name = chatName;
1139
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'POST', '/api/chat', body);
1140
+ }
1141
+ if (operation === 'get') {
1142
+ const chatId = this.getNodeParameter('chatId', i);
1143
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/chat/${chatId}`);
1144
+ }
1145
+ if (operation === 'getMany') {
1146
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1147
+ const qs = {};
1148
+ if (additionalFields.page !== undefined)
1149
+ qs.page = additionalFields.page;
1150
+ if (additionalFields.size !== undefined)
1151
+ qs.size = additionalFields.size;
1152
+ if (additionalFields.query)
1153
+ qs.query = additionalFields.query;
1154
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/chat', {}, qs);
1155
+ }
1156
+ if (operation === 'getMessages') {
1157
+ const chatId = this.getNodeParameter('chatId', i);
1158
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/chat/${chatId}/messages`);
1159
+ }
1160
+ if (operation === 'delete') {
1161
+ const chatId = this.getNodeParameter('chatId', i);
1162
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'DELETE', `/api/chat/${chatId}`);
1163
+ }
1164
+ if (operation === 'rename') {
1165
+ const chatId = this.getNodeParameter('chatId', i);
1166
+ const newName = this.getNodeParameter('newName', i);
1167
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'PATCH', `/api/chat/${chatId}`, { name: newName });
1168
+ }
1169
+ if (operation === 'generate') {
1170
+ const chatId = this.getNodeParameter('chatId', i);
1171
+ const prompt = this.getNodeParameter('prompt', i);
1172
+ const model = this.getNodeParameter('model', i);
1173
+ const additionalFields = this.getNodeParameter('additionalFields', i, {});
1174
+ // Build multipart form data matching GenerateChatRequest
1175
+ const formData = { prompt, model };
1176
+ if (additionalFields.connectedDatarooms) {
1177
+ formData.connectedDatarooms = additionalFields.connectedDatarooms
1178
+ .split(',').map((s) => s.trim()).filter(Boolean);
1179
+ }
1180
+ if (additionalFields.fileIds) {
1181
+ formData.fileIds = additionalFields.fileIds
1182
+ .split(',').map((s) => s.trim()).filter(Boolean);
1183
+ }
1184
+ if (additionalFields.imageIds) {
1185
+ formData.imageIds = additionalFields.imageIds
1186
+ .split(',').map((s) => s.trim()).filter(Boolean);
1187
+ }
1188
+ if (additionalFields.parentDatarooms !== undefined)
1189
+ formData.parentDatarooms = additionalFields.parentDatarooms;
1190
+ if (additionalFields.subDatarooms !== undefined)
1191
+ formData.subDatarooms = additionalFields.subDatarooms;
1192
+ if (additionalFields.webSearchEnabled !== undefined)
1193
+ formData.webSearchEnabled = additionalFields.webSearchEnabled;
1194
+ if (additionalFields.agenticMode !== undefined)
1195
+ formData.agenticMode = additionalFields.agenticMode;
1196
+ const response = await GenericFunctions_1.aitezaApiRequestFullResponse.call(this, 'POST', `/api/chat/${chatId}/generate`, {}, {}, { formData });
1197
+ responseData = response.body;
1198
+ // Expose X-Chat-Id header if present (when using 'new' as chatId)
1199
+ const xChatId = response.headers?.['x-chat-id'];
1200
+ if (xChatId) {
1201
+ if (typeof responseData === 'object' && responseData !== null) {
1202
+ responseData._chatId = xChatId;
1203
+ }
1204
+ }
1205
+ }
1206
+ }
1207
+ // =============================================================
1208
+ // MODEL
1209
+ // =============================================================
1210
+ if (resource === 'model') {
1211
+ if (operation === 'getMany') {
1212
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/models');
1213
+ }
1214
+ if (operation === 'get') {
1215
+ const modelId = this.getNodeParameter('modelId', i);
1216
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', `/api/models/${modelId}`);
1217
+ }
1218
+ if (operation === 'getProcessing') {
1219
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/models/processing');
1220
+ }
1221
+ if (operation === 'getVlm') {
1222
+ responseData = await GenericFunctions_1.aitezaApiRequest.call(this, 'GET', '/api/models/vlm');
1223
+ }
1224
+ }
1225
+ // Normalize output
1226
+ if (responseData !== undefined) {
1227
+ const items2 = Array.isArray(responseData)
1228
+ ? responseData.map((item) => ({ json: item }))
1229
+ : [{ json: typeof responseData === 'object' ? responseData : { result: responseData } }];
1230
+ returnData.push(...items2);
1231
+ }
1232
+ }
1233
+ catch (error) {
1234
+ if (this.continueOnFail()) {
1235
+ returnData.push({ json: { error: error.message }, pairedItem: { item: i } });
1236
+ continue;
1237
+ }
1238
+ throw error;
1239
+ }
1240
+ }
1241
+ return [returnData];
1242
+ }
1243
+ }
1244
+ exports.Aiteza = Aiteza;