n8n-nodes-timizer 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1040 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Timizer = void 0;
4
+ const CONTACT_FIELDS = [
5
+ { displayName: 'First Name', name: 'firstname', type: 'string', default: '' },
6
+ { displayName: 'Last Name', name: 'lastname', type: 'string', default: '' },
7
+ { displayName: 'Email', name: 'email', type: 'string', default: '' },
8
+ { displayName: 'Occupation', name: 'occupation', type: 'string', default: '' },
9
+ ];
10
+ const BASE_URL = 'https://api.timizer.io';
11
+ class Timizer {
12
+ constructor() {
13
+ this.description = {
14
+ displayName: 'Timizer',
15
+ name: 'timizer',
16
+ icon: 'file:timizer.svg',
17
+ group: ['transform'],
18
+ version: 1,
19
+ subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
20
+ description: 'Interact with the Timizer API',
21
+ defaults: {
22
+ name: 'Timizer',
23
+ },
24
+ inputs: ['main'],
25
+ outputs: ['main'],
26
+ credentials: [
27
+ {
28
+ name: 'timizerApi',
29
+ required: true,
30
+ },
31
+ ],
32
+ properties: [
33
+ // ------ Resource ------
34
+ {
35
+ displayName: 'Resource',
36
+ name: 'resource',
37
+ type: 'options',
38
+ noDataExpression: true,
39
+ default: 'activityReport',
40
+ options: [
41
+ { name: 'Activity Report', value: 'activityReport' },
42
+ { name: 'Client', value: 'client' },
43
+ { name: 'Client Contact', value: 'clientContact' },
44
+ { name: 'Contracted', value: 'contracted' },
45
+ { name: 'Contracted Contact', value: 'contractedContact' },
46
+ { name: 'Mission', value: 'mission' },
47
+ { name: 'Tag', value: 'tag' },
48
+ { name: 'Team', value: 'team' },
49
+ { name: 'Team Member', value: 'teamMember' },
50
+ ],
51
+ },
52
+ // ====== OPERATIONS ======
53
+ // --- Activity Report ---
54
+ {
55
+ displayName: 'Operation',
56
+ name: 'operation',
57
+ type: 'options',
58
+ noDataExpression: true,
59
+ displayOptions: { show: { resource: ['activityReport'] } },
60
+ default: 'getMany',
61
+ options: [
62
+ { name: 'Create', value: 'create', action: 'Create an activity report' },
63
+ { name: 'Delete', value: 'delete', action: 'Delete an activity report' },
64
+ { name: 'Get', value: 'get', action: 'Get an activity report' },
65
+ { name: 'Get Many', value: 'getMany', action: 'Get many activity reports' },
66
+ { name: 'Get PDF', value: 'getPdf', action: 'Get activity report PDF' },
67
+ { name: 'Mark as Processed', value: 'markProcessed', action: 'Mark an activity report as processed' },
68
+ { name: 'Mark as Unprocessed', value: 'markUnprocessed', action: 'Mark an activity report as unprocessed' },
69
+ { name: 'Refuse', value: 'refuse', action: 'Refuse an activity report' },
70
+ { name: 'Share', value: 'share', action: 'Share an activity report' },
71
+ { name: 'Share by Email', value: 'shareByEmail', action: 'Share an activity report by email' },
72
+ { name: 'Update', value: 'update', action: 'Update an activity report' },
73
+ ],
74
+ },
75
+ // --- Client ---
76
+ {
77
+ displayName: 'Operation',
78
+ name: 'operation',
79
+ type: 'options',
80
+ noDataExpression: true,
81
+ displayOptions: { show: { resource: ['client'] } },
82
+ default: 'getMany',
83
+ options: [
84
+ { name: 'Create', value: 'create', action: 'Create a client' },
85
+ { name: 'Delete', value: 'delete', action: 'Delete a client' },
86
+ { name: 'Get', value: 'get', action: 'Get a client' },
87
+ { name: 'Get Many', value: 'getMany', action: 'Get many clients' },
88
+ { name: 'Update', value: 'update', action: 'Update a client' },
89
+ ],
90
+ },
91
+ // --- Client Contact ---
92
+ {
93
+ displayName: 'Operation',
94
+ name: 'operation',
95
+ type: 'options',
96
+ noDataExpression: true,
97
+ displayOptions: { show: { resource: ['clientContact'] } },
98
+ default: 'getMany',
99
+ options: [
100
+ { name: 'Create', value: 'create', action: 'Create a client contact' },
101
+ { name: 'Delete', value: 'delete', action: 'Delete a client contact' },
102
+ { name: 'Get Many', value: 'getMany', action: 'Get many client contacts' },
103
+ { name: 'Update', value: 'update', action: 'Update a client contact' },
104
+ ],
105
+ },
106
+ // --- Contracted ---
107
+ {
108
+ displayName: 'Operation',
109
+ name: 'operation',
110
+ type: 'options',
111
+ noDataExpression: true,
112
+ displayOptions: { show: { resource: ['contracted'] } },
113
+ default: 'getMany',
114
+ options: [
115
+ { name: 'Create', value: 'create', action: 'Create a contracted' },
116
+ { name: 'Delete', value: 'delete', action: 'Delete a contracted' },
117
+ { name: 'Get', value: 'get', action: 'Get a contracted' },
118
+ { name: 'Get Many', value: 'getMany', action: 'Get many contracted' },
119
+ { name: 'Update', value: 'update', action: 'Update a contracted' },
120
+ ],
121
+ },
122
+ // --- Contracted Contact ---
123
+ {
124
+ displayName: 'Operation',
125
+ name: 'operation',
126
+ type: 'options',
127
+ noDataExpression: true,
128
+ displayOptions: { show: { resource: ['contractedContact'] } },
129
+ default: 'getMany',
130
+ options: [
131
+ { name: 'Create', value: 'create', action: 'Create a contracted contact' },
132
+ { name: 'Delete', value: 'delete', action: 'Delete a contracted contact' },
133
+ { name: 'Get Many', value: 'getMany', action: 'Get many contracted contacts' },
134
+ { name: 'Update', value: 'update', action: 'Update a contracted contact' },
135
+ ],
136
+ },
137
+ // --- Mission ---
138
+ {
139
+ displayName: 'Operation',
140
+ name: 'operation',
141
+ type: 'options',
142
+ noDataExpression: true,
143
+ displayOptions: { show: { resource: ['mission'] } },
144
+ default: 'getMany',
145
+ options: [
146
+ { name: 'Create', value: 'create', action: 'Create a mission' },
147
+ { name: 'Delete', value: 'delete', action: 'Delete a mission' },
148
+ { name: 'Get Many', value: 'getMany', action: 'Get many missions' },
149
+ { name: 'Update', value: 'update', action: 'Update a mission' },
150
+ ],
151
+ },
152
+ // --- Tag ---
153
+ {
154
+ displayName: 'Operation',
155
+ name: 'operation',
156
+ type: 'options',
157
+ noDataExpression: true,
158
+ displayOptions: { show: { resource: ['tag'] } },
159
+ default: 'getMany',
160
+ options: [
161
+ { name: 'Create', value: 'create', action: 'Create a tag' },
162
+ { name: 'Delete', value: 'delete', action: 'Delete a tag' },
163
+ { name: 'Get Many', value: 'getMany', action: 'Get many tags' },
164
+ { name: 'Update', value: 'update', action: 'Update a tag' },
165
+ ],
166
+ },
167
+ // --- Team ---
168
+ {
169
+ displayName: 'Operation',
170
+ name: 'operation',
171
+ type: 'options',
172
+ noDataExpression: true,
173
+ displayOptions: { show: { resource: ['team'] } },
174
+ default: 'getMany',
175
+ options: [
176
+ { name: 'Create', value: 'create', action: 'Create a team' },
177
+ { name: 'Delete', value: 'delete', action: 'Delete a team' },
178
+ { name: 'Get Many', value: 'getMany', action: 'Get many teams' },
179
+ { name: 'Update', value: 'update', action: 'Update a team' },
180
+ ],
181
+ },
182
+ // --- Team Member ---
183
+ {
184
+ displayName: 'Operation',
185
+ name: 'operation',
186
+ type: 'options',
187
+ noDataExpression: true,
188
+ displayOptions: { show: { resource: ['teamMember'] } },
189
+ default: 'getMany',
190
+ options: [
191
+ { name: 'Delete', value: 'delete', action: 'Delete a team member' },
192
+ { name: 'Get Many', value: 'getMany', action: 'Get many team members' },
193
+ { name: 'Invite', value: 'invite', action: 'Invite a team member' },
194
+ { name: 'Update', value: 'update', action: 'Update a team member' },
195
+ ],
196
+ },
197
+ // ====== FIELDS ======
198
+ // --- Activity Report ID (for single operations) ---
199
+ {
200
+ displayName: 'Activity Report ID',
201
+ name: 'activityReportId',
202
+ type: 'string',
203
+ required: true,
204
+ default: '',
205
+ displayOptions: {
206
+ show: {
207
+ resource: ['activityReport'],
208
+ operation: ['get', 'update', 'delete', 'share', 'shareByEmail', 'refuse', 'markProcessed', 'markUnprocessed', 'getPdf'],
209
+ },
210
+ },
211
+ description: 'The ID of the activity report',
212
+ },
213
+ // --- Activity Report Create fields ---
214
+ {
215
+ displayName: 'Member ID',
216
+ name: 'memberId',
217
+ type: 'string',
218
+ required: true,
219
+ default: '',
220
+ displayOptions: {
221
+ show: { resource: ['activityReport'], operation: ['create'] },
222
+ },
223
+ description: 'The ID of the member for this activity report',
224
+ },
225
+ {
226
+ displayName: 'Month',
227
+ name: 'month',
228
+ type: 'number',
229
+ required: true,
230
+ default: 1,
231
+ typeOptions: { minValue: 1, maxValue: 12 },
232
+ displayOptions: {
233
+ show: { resource: ['activityReport'], operation: ['create'] },
234
+ },
235
+ description: 'Month of the activity report (1-12)',
236
+ },
237
+ {
238
+ displayName: 'Year',
239
+ name: 'year',
240
+ type: 'number',
241
+ required: true,
242
+ default: new Date().getFullYear(),
243
+ displayOptions: {
244
+ show: { resource: ['activityReport'], operation: ['create'] },
245
+ },
246
+ description: 'Year of the activity report',
247
+ },
248
+ // --- Activity Report Update fields ---
249
+ {
250
+ displayName: 'Update Fields',
251
+ name: 'updateFields',
252
+ type: 'collection',
253
+ placeholder: 'Add Field',
254
+ default: {},
255
+ displayOptions: {
256
+ show: { resource: ['activityReport'], operation: ['update'] },
257
+ },
258
+ options: [
259
+ {
260
+ displayName: 'Comment',
261
+ name: 'comment',
262
+ type: 'string',
263
+ default: '',
264
+ },
265
+ ],
266
+ },
267
+ // --- Activity Report Share by Email ---
268
+ {
269
+ displayName: 'Email',
270
+ name: 'email',
271
+ type: 'string',
272
+ placeholder: 'name@email.com',
273
+ required: true,
274
+ default: '',
275
+ displayOptions: {
276
+ show: { resource: ['activityReport'], operation: ['shareByEmail'] },
277
+ },
278
+ description: 'The email to share the activity report with',
279
+ },
280
+ // --- Activity Report Get Many filters ---
281
+ {
282
+ displayName: 'Filters',
283
+ name: 'filters',
284
+ type: 'collection',
285
+ placeholder: 'Add Filter',
286
+ default: {},
287
+ displayOptions: {
288
+ show: { resource: ['activityReport'], operation: ['getMany'] },
289
+ },
290
+ options: [
291
+ {
292
+ displayName: 'Member ID',
293
+ name: 'memberId',
294
+ type: 'string',
295
+ default: '',
296
+ },
297
+ {
298
+ displayName: 'Month',
299
+ name: 'month',
300
+ type: 'number',
301
+ default: 0,
302
+ typeOptions: { minValue: 1, maxValue: 12 },
303
+ },
304
+ {
305
+ displayName: 'Status',
306
+ name: 'status',
307
+ type: 'options',
308
+ default: '',
309
+ options: [
310
+ { name: 'Draft', value: 'draft' },
311
+ { name: 'Processed', value: 'processed' },
312
+ { name: 'Refused', value: 'refused' },
313
+ { name: 'Shared', value: 'shared' },
314
+ { name: 'Signed', value: 'signed' },
315
+ ],
316
+ },
317
+ {
318
+ displayName: 'Year',
319
+ name: 'year',
320
+ type: 'number',
321
+ default: 0,
322
+ },
323
+ ],
324
+ },
325
+ // --- Client ID ---
326
+ {
327
+ displayName: 'Client ID',
328
+ name: 'clientId',
329
+ type: 'string',
330
+ required: true,
331
+ default: '',
332
+ displayOptions: {
333
+ show: {
334
+ resource: ['client'],
335
+ operation: ['get', 'update', 'delete'],
336
+ },
337
+ },
338
+ },
339
+ // Client ID for contacts
340
+ {
341
+ displayName: 'Client ID',
342
+ name: 'clientId',
343
+ type: 'string',
344
+ required: true,
345
+ default: '',
346
+ displayOptions: {
347
+ show: {
348
+ resource: ['clientContact'],
349
+ operation: ['create', 'getMany', 'update', 'delete'],
350
+ },
351
+ },
352
+ description: 'The ID of the client',
353
+ },
354
+ // --- Client Create/Update fields ---
355
+ {
356
+ displayName: 'Name',
357
+ name: 'name',
358
+ type: 'string',
359
+ required: true,
360
+ default: '',
361
+ displayOptions: {
362
+ show: { resource: ['client'], operation: ['create'] },
363
+ },
364
+ },
365
+ {
366
+ displayName: 'Update Fields',
367
+ name: 'updateFields',
368
+ type: 'collection',
369
+ placeholder: 'Add Field',
370
+ default: {},
371
+ displayOptions: {
372
+ show: { resource: ['client'], operation: ['update'] },
373
+ },
374
+ options: [
375
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
376
+ { displayName: 'Address', name: 'address', type: 'string', default: '' },
377
+ { displayName: 'City', name: 'city', type: 'string', default: '' },
378
+ { displayName: 'Zip Code', name: 'zipCode', type: 'string', default: '' },
379
+ { displayName: 'Country', name: 'country', type: 'string', default: '' },
380
+ { displayName: 'SIRET', name: 'siret', type: 'string', default: '' },
381
+ ],
382
+ },
383
+ {
384
+ displayName: 'Additional Fields',
385
+ name: 'additionalFields',
386
+ type: 'collection',
387
+ placeholder: 'Add Field',
388
+ default: {},
389
+ displayOptions: {
390
+ show: { resource: ['client'], operation: ['create'] },
391
+ },
392
+ options: [
393
+ { displayName: 'Address', name: 'address', type: 'string', default: '' },
394
+ { displayName: 'City', name: 'city', type: 'string', default: '' },
395
+ { displayName: 'Zip Code', name: 'zipCode', type: 'string', default: '' },
396
+ { displayName: 'Country', name: 'country', type: 'string', default: '' },
397
+ { displayName: 'SIRET', name: 'siret', type: 'string', default: '' },
398
+ ],
399
+ },
400
+ // --- Client Contact fields ---
401
+ {
402
+ displayName: 'Contact ID',
403
+ name: 'contactId',
404
+ type: 'string',
405
+ required: true,
406
+ default: '',
407
+ displayOptions: {
408
+ show: {
409
+ resource: ['clientContact'],
410
+ operation: ['update', 'delete'],
411
+ },
412
+ },
413
+ },
414
+ {
415
+ displayName: 'Contact Fields',
416
+ name: 'contactFields',
417
+ type: 'collection',
418
+ placeholder: 'Add Field',
419
+ default: {},
420
+ displayOptions: {
421
+ show: { resource: ['clientContact'], operation: ['create'] },
422
+ },
423
+ options: CONTACT_FIELDS,
424
+ },
425
+ {
426
+ displayName: 'Update Fields',
427
+ name: 'updateFields',
428
+ type: 'collection',
429
+ placeholder: 'Add Field',
430
+ default: {},
431
+ displayOptions: {
432
+ show: { resource: ['clientContact'], operation: ['update'] },
433
+ },
434
+ options: CONTACT_FIELDS,
435
+ },
436
+ // --- Contracted ID ---
437
+ {
438
+ displayName: 'Contracted ID',
439
+ name: 'contractedId',
440
+ type: 'string',
441
+ required: true,
442
+ default: '',
443
+ displayOptions: {
444
+ show: {
445
+ resource: ['contracted'],
446
+ operation: ['get', 'update', 'delete'],
447
+ },
448
+ },
449
+ },
450
+ // Contracted ID for contacts
451
+ {
452
+ displayName: 'Contracted ID',
453
+ name: 'contractedId',
454
+ type: 'string',
455
+ required: true,
456
+ default: '',
457
+ displayOptions: {
458
+ show: {
459
+ resource: ['contractedContact'],
460
+ operation: ['create', 'getMany', 'update', 'delete'],
461
+ },
462
+ },
463
+ },
464
+ // --- Contracted Create/Update ---
465
+ {
466
+ displayName: 'Name',
467
+ name: 'name',
468
+ type: 'string',
469
+ required: true,
470
+ default: '',
471
+ displayOptions: {
472
+ show: { resource: ['contracted'], operation: ['create'] },
473
+ },
474
+ },
475
+ {
476
+ displayName: 'Update Fields',
477
+ name: 'updateFields',
478
+ type: 'collection',
479
+ placeholder: 'Add Field',
480
+ default: {},
481
+ displayOptions: {
482
+ show: { resource: ['contracted'], operation: ['update'] },
483
+ },
484
+ options: [
485
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
486
+ { displayName: 'Address', name: 'address', type: 'string', default: '' },
487
+ { displayName: 'City', name: 'city', type: 'string', default: '' },
488
+ { displayName: 'Zip Code', name: 'zipCode', type: 'string', default: '' },
489
+ { displayName: 'Country', name: 'country', type: 'string', default: '' },
490
+ { displayName: 'SIRET', name: 'siret', type: 'string', default: '' },
491
+ ],
492
+ },
493
+ {
494
+ displayName: 'Additional Fields',
495
+ name: 'additionalFields',
496
+ type: 'collection',
497
+ placeholder: 'Add Field',
498
+ default: {},
499
+ displayOptions: {
500
+ show: { resource: ['contracted'], operation: ['create'] },
501
+ },
502
+ options: [
503
+ { displayName: 'Address', name: 'address', type: 'string', default: '' },
504
+ { displayName: 'City', name: 'city', type: 'string', default: '' },
505
+ { displayName: 'Zip Code', name: 'zipCode', type: 'string', default: '' },
506
+ { displayName: 'Country', name: 'country', type: 'string', default: '' },
507
+ { displayName: 'SIRET', name: 'siret', type: 'string', default: '' },
508
+ ],
509
+ },
510
+ // --- Contracted Contact fields ---
511
+ {
512
+ displayName: 'Contact ID',
513
+ name: 'contactId',
514
+ type: 'string',
515
+ required: true,
516
+ default: '',
517
+ displayOptions: {
518
+ show: {
519
+ resource: ['contractedContact'],
520
+ operation: ['update', 'delete'],
521
+ },
522
+ },
523
+ },
524
+ {
525
+ displayName: 'Contact Fields',
526
+ name: 'contactFields',
527
+ type: 'collection',
528
+ placeholder: 'Add Field',
529
+ default: {},
530
+ displayOptions: {
531
+ show: { resource: ['contractedContact'], operation: ['create'] },
532
+ },
533
+ options: CONTACT_FIELDS,
534
+ },
535
+ {
536
+ displayName: 'Update Fields',
537
+ name: 'updateFields',
538
+ type: 'collection',
539
+ placeholder: 'Add Field',
540
+ default: {},
541
+ displayOptions: {
542
+ show: { resource: ['contractedContact'], operation: ['update'] },
543
+ },
544
+ options: CONTACT_FIELDS,
545
+ },
546
+ // --- Mission ---
547
+ {
548
+ displayName: 'Mission ID',
549
+ name: 'missionId',
550
+ type: 'string',
551
+ required: true,
552
+ default: '',
553
+ displayOptions: {
554
+ show: {
555
+ resource: ['mission'],
556
+ operation: ['update', 'delete'],
557
+ },
558
+ },
559
+ },
560
+ {
561
+ displayName: 'Mission Fields',
562
+ name: 'missionFields',
563
+ type: 'collection',
564
+ placeholder: 'Add Field',
565
+ default: {},
566
+ displayOptions: {
567
+ show: { resource: ['mission'], operation: ['create'] },
568
+ },
569
+ options: [
570
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
571
+ { displayName: 'Client ID', name: 'clientId', type: 'string', default: '' },
572
+ { displayName: 'Contracted ID', name: 'contractedId', type: 'string', default: '' },
573
+ { displayName: 'Start Date', name: 'startDate', type: 'string', default: '', description: 'ISO 8601 date' },
574
+ { displayName: 'End Date', name: 'endDate', type: 'string', default: '', description: 'ISO 8601 date' },
575
+ ],
576
+ },
577
+ {
578
+ displayName: 'Update Fields',
579
+ name: 'updateFields',
580
+ type: 'collection',
581
+ placeholder: 'Add Field',
582
+ default: {},
583
+ displayOptions: {
584
+ show: { resource: ['mission'], operation: ['update'] },
585
+ },
586
+ options: [
587
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
588
+ { displayName: 'Client ID', name: 'clientId', type: 'string', default: '' },
589
+ { displayName: 'Contracted ID', name: 'contractedId', type: 'string', default: '' },
590
+ { displayName: 'Start Date', name: 'startDate', type: 'string', default: '' },
591
+ { displayName: 'End Date', name: 'endDate', type: 'string', default: '' },
592
+ ],
593
+ },
594
+ // --- Tag ---
595
+ {
596
+ displayName: 'Tag ID',
597
+ name: 'tagId',
598
+ type: 'string',
599
+ required: true,
600
+ default: '',
601
+ displayOptions: {
602
+ show: { resource: ['tag'], operation: ['update', 'delete'] },
603
+ },
604
+ },
605
+ {
606
+ displayName: 'Name',
607
+ name: 'name',
608
+ type: 'string',
609
+ required: true,
610
+ default: '',
611
+ displayOptions: {
612
+ show: { resource: ['tag'], operation: ['create'] },
613
+ },
614
+ },
615
+ {
616
+ displayName: 'Additional Fields',
617
+ name: 'additionalFields',
618
+ type: 'collection',
619
+ placeholder: 'Add Field',
620
+ default: {},
621
+ displayOptions: {
622
+ show: { resource: ['tag'], operation: ['create'] },
623
+ },
624
+ options: [
625
+ { displayName: 'Color', name: 'color', type: 'string', default: '' },
626
+ ],
627
+ },
628
+ {
629
+ displayName: 'Update Fields',
630
+ name: 'updateFields',
631
+ type: 'collection',
632
+ placeholder: 'Add Field',
633
+ default: {},
634
+ displayOptions: {
635
+ show: { resource: ['tag'], operation: ['update'] },
636
+ },
637
+ options: [
638
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
639
+ { displayName: 'Color', name: 'color', type: 'string', default: '' },
640
+ ],
641
+ },
642
+ // --- Team ---
643
+ {
644
+ displayName: 'Team ID',
645
+ name: 'teamIdParam',
646
+ type: 'string',
647
+ required: true,
648
+ default: '',
649
+ displayOptions: {
650
+ show: { resource: ['team'], operation: ['update', 'delete'] },
651
+ },
652
+ description: 'The ID of the team',
653
+ },
654
+ {
655
+ displayName: 'Name',
656
+ name: 'name',
657
+ type: 'string',
658
+ required: true,
659
+ default: '',
660
+ displayOptions: {
661
+ show: { resource: ['team'], operation: ['create'] },
662
+ },
663
+ },
664
+ {
665
+ displayName: 'Update Fields',
666
+ name: 'updateFields',
667
+ type: 'collection',
668
+ placeholder: 'Add Field',
669
+ default: {},
670
+ displayOptions: {
671
+ show: { resource: ['team'], operation: ['update'] },
672
+ },
673
+ options: [
674
+ { displayName: 'Name', name: 'name', type: 'string', default: '' },
675
+ ],
676
+ },
677
+ // --- Team Member ---
678
+ {
679
+ displayName: 'Member ID',
680
+ name: 'memberId',
681
+ type: 'string',
682
+ required: true,
683
+ default: '',
684
+ displayOptions: {
685
+ show: { resource: ['teamMember'], operation: ['update', 'delete'] },
686
+ },
687
+ },
688
+ {
689
+ displayName: 'Email',
690
+ name: 'email',
691
+ type: 'string',
692
+ placeholder: 'name@email.com',
693
+ required: true,
694
+ default: '',
695
+ displayOptions: {
696
+ show: { resource: ['teamMember'], operation: ['invite'] },
697
+ },
698
+ description: 'Email of the member to invite',
699
+ },
700
+ {
701
+ displayName: 'Update Fields',
702
+ name: 'updateFields',
703
+ type: 'collection',
704
+ placeholder: 'Add Field',
705
+ default: {},
706
+ displayOptions: {
707
+ show: { resource: ['teamMember'], operation: ['update'] },
708
+ },
709
+ options: [
710
+ {
711
+ displayName: 'Role',
712
+ name: 'role',
713
+ type: 'options',
714
+ default: 'member',
715
+ options: [
716
+ { name: 'Admin', value: 'admin' },
717
+ { name: 'Manager', value: 'manager' },
718
+ { name: 'Member', value: 'member' },
719
+ ],
720
+ },
721
+ ],
722
+ },
723
+ // --- Return All / Limit (for getMany operations) ---
724
+ {
725
+ displayName: 'Return All',
726
+ name: 'returnAll',
727
+ type: 'boolean',
728
+ default: false,
729
+ displayOptions: {
730
+ show: { operation: ['getMany'] },
731
+ },
732
+ description: 'Whether to return all results or only up to a given limit',
733
+ },
734
+ {
735
+ displayName: 'Limit',
736
+ name: 'limit',
737
+ type: 'number',
738
+ default: 50,
739
+ typeOptions: { minValue: 1 },
740
+ displayOptions: {
741
+ show: { operation: ['getMany'], returnAll: [false] },
742
+ },
743
+ description: 'Max number of results to return',
744
+ },
745
+ ],
746
+ };
747
+ }
748
+ async execute() {
749
+ const items = this.getInputData();
750
+ const returnData = [];
751
+ const resource = this.getNodeParameter('resource', 0);
752
+ const operation = this.getNodeParameter('operation', 0);
753
+ const credentials = await this.getCredentials('timizerApi');
754
+ const teamId = credentials.teamId;
755
+ for (let i = 0; i < items.length; i++) {
756
+ try {
757
+ let responseData;
758
+ const method = getHttpMethod(operation);
759
+ const endpoint = buildEndpoint(resource, operation, teamId, this, i);
760
+ const body = buildBody(resource, operation, this, i);
761
+ if (operation === 'getPdf') {
762
+ const response = await this.helpers.httpRequestWithAuthentication.call(this, 'timizerApi', {
763
+ method: 'GET',
764
+ url: `${BASE_URL}${endpoint}`,
765
+ encoding: 'arraybuffer',
766
+ returnFullResponse: true,
767
+ });
768
+ const binaryData = await this.helpers.prepareBinaryData(Buffer.from(response.body), 'activity-report.pdf', 'application/pdf');
769
+ returnData.push({
770
+ json: {},
771
+ binary: { data: binaryData },
772
+ });
773
+ continue;
774
+ }
775
+ const requestOptions = {
776
+ method,
777
+ url: `${BASE_URL}${endpoint}`,
778
+ json: true,
779
+ };
780
+ if (body && Object.keys(body).length > 0) {
781
+ requestOptions.body = body;
782
+ }
783
+ if (operation === 'getMany') {
784
+ const qs = buildQueryString(resource, this, i);
785
+ if (Object.keys(qs).length > 0) {
786
+ requestOptions.qs = qs;
787
+ }
788
+ }
789
+ responseData = await this.helpers.httpRequestWithAuthentication.call(this, 'timizerApi', requestOptions);
790
+ if (operation === 'getMany') {
791
+ const results = Array.isArray(responseData) ? responseData : [responseData];
792
+ const returnAll = this.getNodeParameter('returnAll', i);
793
+ if (!returnAll) {
794
+ const limit = this.getNodeParameter('limit', i);
795
+ responseData = results.slice(0, limit);
796
+ }
797
+ else {
798
+ responseData = results;
799
+ }
800
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
801
+ returnData.push(...executionData);
802
+ }
803
+ else {
804
+ const executionData = this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { itemData: { item: i } });
805
+ returnData.push(...executionData);
806
+ }
807
+ }
808
+ catch (error) {
809
+ if (this.continueOnFail()) {
810
+ returnData.push({ json: { error: error.message } });
811
+ continue;
812
+ }
813
+ throw error;
814
+ }
815
+ }
816
+ return [returnData];
817
+ }
818
+ }
819
+ exports.Timizer = Timizer;
820
+ function getHttpMethod(operation) {
821
+ switch (operation) {
822
+ case 'create':
823
+ case 'share':
824
+ case 'shareByEmail':
825
+ case 'refuse':
826
+ case 'markProcessed':
827
+ case 'markUnprocessed':
828
+ case 'invite':
829
+ return 'POST';
830
+ case 'update':
831
+ return 'PUT';
832
+ case 'delete':
833
+ return 'DELETE';
834
+ default:
835
+ return 'GET';
836
+ }
837
+ }
838
+ function buildEndpoint(resource, operation, teamId, ctx, i) {
839
+ const base = `/app/admin-teams/${teamId}`;
840
+ switch (resource) {
841
+ case 'activityReport': {
842
+ const basePath = `${base}/activity-reports`;
843
+ if (operation === 'getMany')
844
+ return basePath;
845
+ if (operation === 'create')
846
+ return basePath;
847
+ const id = ctx.getNodeParameter('activityReportId', i);
848
+ switch (operation) {
849
+ case 'get': return `${basePath}/${id}`;
850
+ case 'update': return `${basePath}/${id}`;
851
+ case 'delete': return `${basePath}/${id}`;
852
+ case 'share': return `${basePath}/${id}/share`;
853
+ case 'shareByEmail': return `${basePath}/${id}/share-by-email`;
854
+ case 'refuse': return `${basePath}/${id}/refuse`;
855
+ case 'markProcessed': return `${basePath}/${id}/processed`;
856
+ case 'markUnprocessed': return `${basePath}/${id}/unprocessed`;
857
+ case 'getPdf': return `${basePath}/${id}/pdf`;
858
+ default: return basePath;
859
+ }
860
+ }
861
+ case 'client': {
862
+ const basePath = `${base}/clients`;
863
+ if (operation === 'getMany' || operation === 'create')
864
+ return basePath;
865
+ const id = ctx.getNodeParameter('clientId', i);
866
+ return `${basePath}/${id}`;
867
+ }
868
+ case 'clientContact': {
869
+ const clientId = ctx.getNodeParameter('clientId', i);
870
+ const basePath = `${base}/clients/${clientId}/contacts`;
871
+ if (operation === 'getMany' || operation === 'create')
872
+ return basePath;
873
+ const contactId = ctx.getNodeParameter('contactId', i);
874
+ return `${basePath}/${contactId}`;
875
+ }
876
+ case 'contracted': {
877
+ const basePath = `${base}/contracted`;
878
+ if (operation === 'getMany' || operation === 'create')
879
+ return basePath;
880
+ const id = ctx.getNodeParameter('contractedId', i);
881
+ return `${basePath}/${id}`;
882
+ }
883
+ case 'contractedContact': {
884
+ const contractedId = ctx.getNodeParameter('contractedId', i);
885
+ const basePath = `${base}/contracted/${contractedId}/contacts`;
886
+ if (operation === 'getMany' || operation === 'create')
887
+ return basePath;
888
+ const contactId = ctx.getNodeParameter('contactId', i);
889
+ return `${basePath}/${contactId}`;
890
+ }
891
+ case 'mission': {
892
+ const basePath = `${base}/missions`;
893
+ if (operation === 'getMany' || operation === 'create')
894
+ return basePath;
895
+ const id = ctx.getNodeParameter('missionId', i);
896
+ return `${basePath}/${id}`;
897
+ }
898
+ case 'tag': {
899
+ const basePath = `${base}/tags`;
900
+ if (operation === 'getMany' || operation === 'create')
901
+ return basePath;
902
+ const id = ctx.getNodeParameter('tagId', i);
903
+ return `${basePath}/${id}`;
904
+ }
905
+ case 'team': {
906
+ const basePath = '/app/admin-teams';
907
+ if (operation === 'getMany')
908
+ return basePath;
909
+ if (operation === 'create')
910
+ return basePath;
911
+ const id = ctx.getNodeParameter('teamIdParam', i);
912
+ return `${basePath}/${id}`;
913
+ }
914
+ case 'teamMember': {
915
+ const basePath = `${base}/members`;
916
+ if (operation === 'getMany')
917
+ return basePath;
918
+ if (operation === 'invite')
919
+ return `${basePath}/invite`;
920
+ const id = ctx.getNodeParameter('memberId', i);
921
+ return `${basePath}/${id}`;
922
+ }
923
+ default:
924
+ return base;
925
+ }
926
+ }
927
+ function buildBody(resource, operation, ctx, i) {
928
+ const body = {};
929
+ if (operation === 'get' || operation === 'getMany' || operation === 'delete' || operation === 'getPdf') {
930
+ return body;
931
+ }
932
+ switch (resource) {
933
+ case 'activityReport': {
934
+ if (operation === 'create') {
935
+ body.memberId = ctx.getNodeParameter('memberId', i);
936
+ body.month = ctx.getNodeParameter('month', i);
937
+ body.year = ctx.getNodeParameter('year', i);
938
+ }
939
+ if (operation === 'update') {
940
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
941
+ }
942
+ if (operation === 'shareByEmail') {
943
+ body.email = ctx.getNodeParameter('email', i);
944
+ }
945
+ break;
946
+ }
947
+ case 'client': {
948
+ if (operation === 'create') {
949
+ body.name = ctx.getNodeParameter('name', i);
950
+ Object.assign(body, ctx.getNodeParameter('additionalFields', i));
951
+ }
952
+ if (operation === 'update') {
953
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
954
+ }
955
+ break;
956
+ }
957
+ case 'clientContact': {
958
+ if (operation === 'create') {
959
+ Object.assign(body, ctx.getNodeParameter('contactFields', i));
960
+ }
961
+ if (operation === 'update') {
962
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
963
+ }
964
+ break;
965
+ }
966
+ case 'contracted': {
967
+ if (operation === 'create') {
968
+ body.name = ctx.getNodeParameter('name', i);
969
+ Object.assign(body, ctx.getNodeParameter('additionalFields', i));
970
+ }
971
+ if (operation === 'update') {
972
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
973
+ }
974
+ break;
975
+ }
976
+ case 'contractedContact': {
977
+ if (operation === 'create') {
978
+ Object.assign(body, ctx.getNodeParameter('contactFields', i));
979
+ }
980
+ if (operation === 'update') {
981
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
982
+ }
983
+ break;
984
+ }
985
+ case 'mission': {
986
+ if (operation === 'create') {
987
+ Object.assign(body, ctx.getNodeParameter('missionFields', i));
988
+ }
989
+ if (operation === 'update') {
990
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
991
+ }
992
+ break;
993
+ }
994
+ case 'tag': {
995
+ if (operation === 'create') {
996
+ body.name = ctx.getNodeParameter('name', i);
997
+ Object.assign(body, ctx.getNodeParameter('additionalFields', i));
998
+ }
999
+ if (operation === 'update') {
1000
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
1001
+ }
1002
+ break;
1003
+ }
1004
+ case 'team': {
1005
+ if (operation === 'create') {
1006
+ body.name = ctx.getNodeParameter('name', i);
1007
+ }
1008
+ if (operation === 'update') {
1009
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
1010
+ }
1011
+ break;
1012
+ }
1013
+ case 'teamMember': {
1014
+ if (operation === 'invite') {
1015
+ body.email = ctx.getNodeParameter('email', i);
1016
+ }
1017
+ if (operation === 'update') {
1018
+ Object.assign(body, ctx.getNodeParameter('updateFields', i));
1019
+ }
1020
+ break;
1021
+ }
1022
+ }
1023
+ return body;
1024
+ }
1025
+ function buildQueryString(resource, ctx, i) {
1026
+ const qs = {};
1027
+ if (resource === 'activityReport') {
1028
+ const filters = ctx.getNodeParameter('filters', i, {});
1029
+ if (filters.memberId)
1030
+ qs.memberId = filters.memberId;
1031
+ if (filters.month)
1032
+ qs.month = filters.month;
1033
+ if (filters.year)
1034
+ qs.year = filters.year;
1035
+ if (filters.status)
1036
+ qs.status = filters.status;
1037
+ }
1038
+ return qs;
1039
+ }
1040
+ //# sourceMappingURL=Timizer.node.js.map