ecom-documents 1.0.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.
package/dist/index.js ADDED
@@ -0,0 +1,1150 @@
1
+ 'use strict';
2
+
3
+ var axios = require('axios');
4
+ var classTransformer = require('class-transformer');
5
+ var classValidator = require('class-validator');
6
+
7
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
8
+
9
+ var axios__default = /*#__PURE__*/_interopDefault(axios);
10
+
11
+ var __defProp = Object.defineProperty;
12
+ var __decorateClass = (decorators, target, key, kind) => {
13
+ var result = void 0 ;
14
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
15
+ if (decorator = decorators[i])
16
+ result = (decorator(target, key, result) ) || result;
17
+ if (result) __defProp(target, key, result);
18
+ return result;
19
+ };
20
+
21
+ // src/enums/document-type.enum.ts
22
+ var DocumentType = {
23
+ STATEMENTS: "STATEMENTS",
24
+ PAYOUTS: "PAYOUTS",
25
+ SETTLEMENTS: "SETTLEMENTS",
26
+ TRANSACTIONS: "TRANSACTIONS",
27
+ TRANSACTIONS_INTERNAL: "TRANSACTIONS_INTERNAL",
28
+ REFUNDS: "REFUNDS",
29
+ REFUNDS_INTERNAL_GATEWAY: "REFUNDS_INTERNAL_GATEWAY",
30
+ PROFIT_FEES: "PROFIT_FEES",
31
+ PAYMENT_METHODS: "PAYMENT_METHODS",
32
+ VENDOR_LIST: "VENDOR_LIST",
33
+ VENDOR_SALES: "VENDOR_SALES",
34
+ EXCEPTIONS: "EXCEPTIONS",
35
+ REFUNDS_POS: "REFUNDS_POS",
36
+ REFUNDS_INTERNAL_POS: "REFUNDS_INTERNAL_POS"
37
+ // MERCHANT_USERS: 'MERCHANT_USERS',
38
+ // INTERNAL_USERS: 'INTERNAL_USERS',
39
+ // BULK_INVOICE_CUSTOMERS: 'BULK_INVOICE_CUSTOMERS',
40
+ // USERS_AND_AGENTS: 'USERS_AND_AGENTS',
41
+ // CUSTOMERS: 'CUSTOMERS',
42
+ // TERMINAL: 'TERMINAL',
43
+ // INVOICES: 'INVOICES',
44
+ // INVOICE_HISTORY: 'INVOICE_HISTORY',
45
+ // USERS: 'USERS',
46
+ // UNPAID_INVOICES: 'UNPAID_INVOICES',
47
+ // TERMINALS: 'TERMINALS',
48
+ // POS_TRANSACTIONS: 'POS_TRANSACTIONS',
49
+ // POS_MERCHANT_TRANSACTIONS: 'POS_MERCHANT_TRANSACTIONS',
50
+ // POS_TRANSACTIONS_INVALID: 'POS_TRANSACTIONS_INVALID',
51
+ // BULK_INVOICES_INVALID: 'BULK_INVOICES_INVALID',
52
+ // BLACKLIST_INVALID: 'BLACKLIST_INVALID',
53
+ // BLACKLIST: 'BLACKLIST',
54
+ // PARTNERS: 'PARTNERS',
55
+ };
56
+
57
+ // src/enums/fileFormat.enum.ts
58
+ var FileFormat = {
59
+ PDF: "pdf",
60
+ CSV: "csv",
61
+ XLSX: "xlsx"
62
+ };
63
+ var ExceptionDocument = class {
64
+ createdAt;
65
+ merchantName;
66
+ merchantRisk;
67
+ cardNumber;
68
+ cardIssuer;
69
+ cardHolderName;
70
+ payerIpAddress;
71
+ product;
72
+ paymentMethod;
73
+ amount;
74
+ action;
75
+ };
76
+ __decorateClass([
77
+ classValidator.IsString(),
78
+ classValidator.IsNotEmpty()
79
+ ], ExceptionDocument.prototype, "createdAt");
80
+ __decorateClass([
81
+ classValidator.IsString(),
82
+ classValidator.IsNotEmpty()
83
+ ], ExceptionDocument.prototype, "merchantName");
84
+ __decorateClass([
85
+ classValidator.IsString(),
86
+ classValidator.IsNotEmpty()
87
+ ], ExceptionDocument.prototype, "merchantRisk");
88
+ __decorateClass([
89
+ classValidator.IsString(),
90
+ classValidator.IsNotEmpty()
91
+ ], ExceptionDocument.prototype, "cardNumber");
92
+ __decorateClass([
93
+ classValidator.IsString(),
94
+ classValidator.IsNotEmpty()
95
+ ], ExceptionDocument.prototype, "cardIssuer");
96
+ __decorateClass([
97
+ classValidator.IsString(),
98
+ classValidator.IsNotEmpty()
99
+ ], ExceptionDocument.prototype, "cardHolderName");
100
+ __decorateClass([
101
+ classValidator.IsString(),
102
+ classValidator.IsNotEmpty()
103
+ ], ExceptionDocument.prototype, "payerIpAddress");
104
+ __decorateClass([
105
+ classValidator.IsString(),
106
+ classValidator.IsNotEmpty()
107
+ ], ExceptionDocument.prototype, "product");
108
+ __decorateClass([
109
+ classValidator.IsString(),
110
+ classValidator.IsNotEmpty()
111
+ ], ExceptionDocument.prototype, "paymentMethod");
112
+ __decorateClass([
113
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
114
+ classValidator.IsNumber(),
115
+ classValidator.IsNotEmpty()
116
+ ], ExceptionDocument.prototype, "amount");
117
+ __decorateClass([
118
+ classValidator.IsString(),
119
+ classValidator.IsNotEmpty()
120
+ ], ExceptionDocument.prototype, "action");
121
+ var ExceptionExportDto = class {
122
+ data;
123
+ };
124
+ __decorateClass([
125
+ classValidator.IsArray(),
126
+ classValidator.ValidateNested({ each: true }),
127
+ classTransformer.Type(() => ExceptionDocument),
128
+ classValidator.IsNotEmpty(),
129
+ classValidator.IsDefined()
130
+ ], ExceptionExportDto.prototype, "data");
131
+ var PaymentMethodDocument = class {
132
+ paymentMethod;
133
+ totalAmount;
134
+ percentageOfTotal;
135
+ txnCount;
136
+ };
137
+ __decorateClass([
138
+ classValidator.IsString(),
139
+ classValidator.IsNotEmpty()
140
+ ], PaymentMethodDocument.prototype, "paymentMethod");
141
+ __decorateClass([
142
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
143
+ classValidator.IsNumber(),
144
+ classValidator.IsNotEmpty()
145
+ ], PaymentMethodDocument.prototype, "totalAmount");
146
+ __decorateClass([
147
+ classValidator.IsString(),
148
+ classValidator.IsNotEmpty()
149
+ ], PaymentMethodDocument.prototype, "percentageOfTotal");
150
+ __decorateClass([
151
+ classValidator.IsNumber(),
152
+ classValidator.IsNotEmpty()
153
+ ], PaymentMethodDocument.prototype, "txnCount");
154
+ var PaymentMethodsExportDto = class {
155
+ data;
156
+ };
157
+ __decorateClass([
158
+ classValidator.IsArray(),
159
+ classValidator.ValidateNested({ each: true }),
160
+ classTransformer.Type(() => PaymentMethodDocument),
161
+ classValidator.IsNotEmpty(),
162
+ classValidator.IsDefined()
163
+ ], PaymentMethodsExportDto.prototype, "data");
164
+ var PayoutDocument = class {
165
+ id;
166
+ mid;
167
+ iban;
168
+ amount;
169
+ currency;
170
+ numOfTxn;
171
+ notes;
172
+ createdAt;
173
+ };
174
+ __decorateClass([
175
+ classValidator.IsString(),
176
+ classValidator.IsNotEmpty()
177
+ ], PayoutDocument.prototype, "id");
178
+ __decorateClass([
179
+ classValidator.IsString(),
180
+ classValidator.IsNotEmpty()
181
+ ], PayoutDocument.prototype, "mid");
182
+ __decorateClass([
183
+ classValidator.IsString(),
184
+ classValidator.IsNotEmpty()
185
+ ], PayoutDocument.prototype, "iban");
186
+ __decorateClass([
187
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
188
+ classValidator.IsNumber(),
189
+ classValidator.IsNotEmpty()
190
+ ], PayoutDocument.prototype, "amount");
191
+ __decorateClass([
192
+ classValidator.IsString(),
193
+ classValidator.IsNotEmpty()
194
+ ], PayoutDocument.prototype, "currency");
195
+ __decorateClass([
196
+ classValidator.IsNumber(),
197
+ classValidator.IsNotEmpty()
198
+ ], PayoutDocument.prototype, "numOfTxn");
199
+ __decorateClass([
200
+ classValidator.IsString(),
201
+ classValidator.IsNotEmpty()
202
+ ], PayoutDocument.prototype, "notes");
203
+ __decorateClass([
204
+ classValidator.IsString(),
205
+ classValidator.IsNotEmpty()
206
+ ], PayoutDocument.prototype, "createdAt");
207
+ var PayoutsExportDto = class {
208
+ data;
209
+ };
210
+ __decorateClass([
211
+ classValidator.IsArray(),
212
+ classValidator.ValidateNested({ each: true }),
213
+ classTransformer.Type(() => PayoutDocument),
214
+ classValidator.IsNotEmpty(),
215
+ classValidator.IsDefined()
216
+ ], PayoutsExportDto.prototype, "data");
217
+ var ProfitFeesDocument = class {
218
+ mid;
219
+ merchantName;
220
+ numOfTxn;
221
+ totalTxnAmount;
222
+ totalProfitAmount;
223
+ type;
224
+ };
225
+ __decorateClass([
226
+ classValidator.IsString(),
227
+ classValidator.IsNotEmpty()
228
+ ], ProfitFeesDocument.prototype, "mid");
229
+ __decorateClass([
230
+ classValidator.IsString(),
231
+ classValidator.IsNotEmpty()
232
+ ], ProfitFeesDocument.prototype, "merchantName");
233
+ __decorateClass([
234
+ classValidator.IsNumber(),
235
+ classValidator.IsNotEmpty()
236
+ ], ProfitFeesDocument.prototype, "numOfTxn");
237
+ __decorateClass([
238
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
239
+ classValidator.IsNumber(),
240
+ classValidator.IsNotEmpty()
241
+ ], ProfitFeesDocument.prototype, "totalTxnAmount");
242
+ __decorateClass([
243
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
244
+ classValidator.IsNumber(),
245
+ classValidator.IsNotEmpty()
246
+ ], ProfitFeesDocument.prototype, "totalProfitAmount");
247
+ __decorateClass([
248
+ classValidator.IsString(),
249
+ classValidator.IsNotEmpty()
250
+ ], ProfitFeesDocument.prototype, "type");
251
+ var ProfitFeesExportDto = class {
252
+ data;
253
+ };
254
+ __decorateClass([
255
+ classValidator.IsArray(),
256
+ classValidator.ValidateNested({ each: true }),
257
+ classTransformer.Type(() => ProfitFeesDocument),
258
+ classValidator.IsNotEmpty(),
259
+ classValidator.IsDefined()
260
+ ], ProfitFeesExportDto.prototype, "data");
261
+ var RefundBaseDto = class {
262
+ createdAt;
263
+ refundedAt;
264
+ rejectedAt;
265
+ ecomReference;
266
+ merchantReference;
267
+ originalTxnId;
268
+ originalTxnDate;
269
+ originalTxnAmount;
270
+ amount;
271
+ paymentMethod;
272
+ status;
273
+ mid;
274
+ merchantName;
275
+ };
276
+ __decorateClass([
277
+ classValidator.IsNotEmpty()
278
+ ], RefundBaseDto.prototype, "createdAt");
279
+ __decorateClass([
280
+ classValidator.IsOptional()
281
+ ], RefundBaseDto.prototype, "refundedAt");
282
+ __decorateClass([
283
+ classValidator.IsOptional()
284
+ ], RefundBaseDto.prototype, "rejectedAt");
285
+ __decorateClass([
286
+ classValidator.IsString(),
287
+ classValidator.IsOptional()
288
+ ], RefundBaseDto.prototype, "ecomReference");
289
+ __decorateClass([
290
+ classValidator.IsString(),
291
+ classValidator.IsOptional()
292
+ ], RefundBaseDto.prototype, "merchantReference");
293
+ __decorateClass([
294
+ classValidator.IsString(),
295
+ classValidator.IsNotEmpty()
296
+ ], RefundBaseDto.prototype, "originalTxnId");
297
+ __decorateClass([
298
+ classValidator.IsString(),
299
+ classValidator.IsNotEmpty()
300
+ ], RefundBaseDto.prototype, "originalTxnDate");
301
+ __decorateClass([
302
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
303
+ classValidator.IsNumber(),
304
+ classValidator.IsNotEmpty()
305
+ ], RefundBaseDto.prototype, "originalTxnAmount");
306
+ __decorateClass([
307
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
308
+ classValidator.IsNumber(),
309
+ classValidator.IsNotEmpty()
310
+ ], RefundBaseDto.prototype, "amount");
311
+ __decorateClass([
312
+ classValidator.IsString(),
313
+ classValidator.IsNotEmpty()
314
+ ], RefundBaseDto.prototype, "paymentMethod");
315
+ __decorateClass([
316
+ classValidator.IsString(),
317
+ classValidator.IsNotEmpty()
318
+ ], RefundBaseDto.prototype, "status");
319
+ __decorateClass([
320
+ classValidator.IsString(),
321
+ classValidator.IsNotEmpty()
322
+ ], RefundBaseDto.prototype, "mid");
323
+ __decorateClass([
324
+ classValidator.IsString(),
325
+ classValidator.IsNotEmpty()
326
+ ], RefundBaseDto.prototype, "merchantName");
327
+ var RefundDocument = class extends RefundBaseDto {
328
+ customerName;
329
+ customerPhone;
330
+ invoiceNumber;
331
+ product;
332
+ type;
333
+ requestedBy;
334
+ };
335
+ __decorateClass([
336
+ classValidator.IsString(),
337
+ classValidator.IsNotEmpty()
338
+ ], RefundDocument.prototype, "customerName");
339
+ __decorateClass([
340
+ classValidator.IsString(),
341
+ classValidator.IsNotEmpty()
342
+ ], RefundDocument.prototype, "customerPhone");
343
+ __decorateClass([
344
+ classValidator.IsString(),
345
+ classValidator.IsOptional()
346
+ ], RefundDocument.prototype, "invoiceNumber");
347
+ __decorateClass([
348
+ classValidator.IsString(),
349
+ classValidator.IsNotEmpty()
350
+ ], RefundDocument.prototype, "product");
351
+ __decorateClass([
352
+ classValidator.IsString(),
353
+ classValidator.IsNotEmpty()
354
+ ], RefundDocument.prototype, "type");
355
+ __decorateClass([
356
+ classValidator.IsString(),
357
+ classValidator.IsNotEmpty()
358
+ ], RefundDocument.prototype, "requestedBy");
359
+ var RefundPOSDocument = class extends RefundBaseDto {
360
+ authId;
361
+ terminalId;
362
+ terminalName;
363
+ cardNumber;
364
+ };
365
+ __decorateClass([
366
+ classValidator.IsString(),
367
+ classValidator.IsNotEmpty()
368
+ ], RefundPOSDocument.prototype, "authId");
369
+ __decorateClass([
370
+ classValidator.IsString(),
371
+ classValidator.IsNotEmpty()
372
+ ], RefundPOSDocument.prototype, "terminalId");
373
+ __decorateClass([
374
+ classValidator.IsString(),
375
+ classValidator.IsOptional()
376
+ ], RefundPOSDocument.prototype, "terminalName");
377
+ __decorateClass([
378
+ classValidator.IsString(),
379
+ classValidator.IsNotEmpty()
380
+ ], RefundPOSDocument.prototype, "cardNumber");
381
+ var RefundsExportDto = class {
382
+ data;
383
+ };
384
+ __decorateClass([
385
+ classValidator.IsArray(),
386
+ classValidator.ValidateNested({ each: true }),
387
+ classTransformer.Type(() => RefundDocument),
388
+ classValidator.IsNotEmpty(),
389
+ classValidator.IsDefined()
390
+ ], RefundsExportDto.prototype, "data");
391
+ var RefundsPOSExportDto = class {
392
+ data;
393
+ };
394
+ __decorateClass([
395
+ classValidator.IsArray(),
396
+ classValidator.ValidateNested({ each: true }),
397
+ classTransformer.Type(() => RefundPOSDocument),
398
+ classValidator.IsNotEmpty(),
399
+ classValidator.IsDefined()
400
+ ], RefundsPOSExportDto.prototype, "data");
401
+ var SettlementDocument = class {
402
+ mid;
403
+ merchantName;
404
+ bank;
405
+ holderName;
406
+ iban;
407
+ accountNumber;
408
+ totalAmount;
409
+ totalTxnCount;
410
+ settlementDate;
411
+ };
412
+ __decorateClass([
413
+ classValidator.IsString(),
414
+ classValidator.IsNotEmpty()
415
+ ], SettlementDocument.prototype, "mid");
416
+ __decorateClass([
417
+ classValidator.IsString(),
418
+ classValidator.IsNotEmpty()
419
+ ], SettlementDocument.prototype, "merchantName");
420
+ __decorateClass([
421
+ classValidator.IsOptional()
422
+ ], SettlementDocument.prototype, "bank");
423
+ __decorateClass([
424
+ classValidator.IsString(),
425
+ classValidator.IsOptional()
426
+ ], SettlementDocument.prototype, "holderName");
427
+ __decorateClass([
428
+ classValidator.IsString(),
429
+ classValidator.IsOptional()
430
+ ], SettlementDocument.prototype, "iban");
431
+ __decorateClass([
432
+ classValidator.IsString(),
433
+ classValidator.IsOptional()
434
+ ], SettlementDocument.prototype, "accountNumber");
435
+ __decorateClass([
436
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
437
+ classValidator.IsNumber(),
438
+ classValidator.IsNotEmpty()
439
+ ], SettlementDocument.prototype, "totalAmount");
440
+ __decorateClass([
441
+ classValidator.IsNumber(),
442
+ classValidator.IsNotEmpty()
443
+ ], SettlementDocument.prototype, "totalTxnCount");
444
+ __decorateClass([
445
+ classValidator.IsOptional()
446
+ ], SettlementDocument.prototype, "settlementDate");
447
+ var SettlementsExportDto = class {
448
+ data;
449
+ };
450
+ __decorateClass([
451
+ classValidator.IsArray(),
452
+ classValidator.ValidateNested({ each: true }),
453
+ classTransformer.Type(() => SettlementDocument),
454
+ classValidator.IsNotEmpty(),
455
+ classValidator.IsDefined()
456
+ ], SettlementsExportDto.prototype, "data");
457
+ var StatementDocument = class {
458
+ createdAt;
459
+ transactionId;
460
+ merchantReference;
461
+ invoiceId;
462
+ description;
463
+ paymentMethod;
464
+ amount;
465
+ type;
466
+ balanceAfter;
467
+ };
468
+ __decorateClass([
469
+ classValidator.IsNotEmpty()
470
+ ], StatementDocument.prototype, "createdAt");
471
+ __decorateClass([
472
+ classValidator.IsString(),
473
+ classValidator.IsOptional()
474
+ ], StatementDocument.prototype, "transactionId");
475
+ __decorateClass([
476
+ classValidator.IsString(),
477
+ classValidator.IsOptional()
478
+ ], StatementDocument.prototype, "merchantReference");
479
+ __decorateClass([
480
+ classValidator.IsString(),
481
+ classValidator.IsOptional()
482
+ ], StatementDocument.prototype, "invoiceId");
483
+ __decorateClass([
484
+ classValidator.IsString(),
485
+ classValidator.IsOptional()
486
+ ], StatementDocument.prototype, "description");
487
+ __decorateClass([
488
+ classValidator.IsNotEmpty()
489
+ ], StatementDocument.prototype, "paymentMethod");
490
+ __decorateClass([
491
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
492
+ classValidator.IsNumber(),
493
+ classValidator.IsNotEmpty()
494
+ ], StatementDocument.prototype, "amount");
495
+ __decorateClass([
496
+ classValidator.IsNotEmpty()
497
+ ], StatementDocument.prototype, "type");
498
+ __decorateClass([
499
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
500
+ classValidator.IsNumber(),
501
+ classValidator.IsNotEmpty()
502
+ ], StatementDocument.prototype, "balanceAfter");
503
+ var StatementsExportDto = class {
504
+ data;
505
+ };
506
+ __decorateClass([
507
+ classValidator.IsArray(),
508
+ classValidator.ValidateNested({ each: true }),
509
+ classTransformer.Type(() => StatementDocument),
510
+ classValidator.IsNotEmpty(),
511
+ classValidator.IsDefined()
512
+ ], StatementsExportDto.prototype, "data");
513
+ var TransactionDocument = class {
514
+ createdAt;
515
+ id;
516
+ ecomReference;
517
+ merchantReference;
518
+ merchantName;
519
+ invoiceNumber;
520
+ customerName;
521
+ customerPhone;
522
+ amount;
523
+ product;
524
+ paymentMethod;
525
+ status;
526
+ authCode;
527
+ terminalId;
528
+ terminalName;
529
+ cardNumber;
530
+ };
531
+ __decorateClass([
532
+ classValidator.IsNotEmpty()
533
+ ], TransactionDocument.prototype, "createdAt");
534
+ __decorateClass([
535
+ classValidator.IsNotEmpty()
536
+ ], TransactionDocument.prototype, "id");
537
+ __decorateClass([
538
+ classValidator.IsNotEmpty(),
539
+ classValidator.IsString()
540
+ ], TransactionDocument.prototype, "ecomReference");
541
+ __decorateClass([
542
+ classValidator.IsString(),
543
+ classValidator.IsOptional()
544
+ ], TransactionDocument.prototype, "merchantReference");
545
+ __decorateClass([
546
+ classValidator.IsString(),
547
+ classValidator.IsOptional()
548
+ ], TransactionDocument.prototype, "merchantName");
549
+ __decorateClass([
550
+ classValidator.IsString(),
551
+ classValidator.IsOptional()
552
+ ], TransactionDocument.prototype, "invoiceNumber");
553
+ __decorateClass([
554
+ classValidator.IsNotEmpty(),
555
+ classValidator.IsString()
556
+ ], TransactionDocument.prototype, "customerName");
557
+ __decorateClass([
558
+ classValidator.IsNotEmpty(),
559
+ classValidator.IsString()
560
+ ], TransactionDocument.prototype, "customerPhone");
561
+ __decorateClass([
562
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
563
+ classValidator.IsNotEmpty(),
564
+ classValidator.IsNumber()
565
+ ], TransactionDocument.prototype, "amount");
566
+ __decorateClass([
567
+ classValidator.IsNotEmpty()
568
+ ], TransactionDocument.prototype, "product");
569
+ __decorateClass([
570
+ classValidator.IsNotEmpty(),
571
+ classValidator.IsString()
572
+ ], TransactionDocument.prototype, "paymentMethod");
573
+ __decorateClass([
574
+ classValidator.IsNotEmpty(),
575
+ classValidator.IsString()
576
+ ], TransactionDocument.prototype, "status");
577
+ __decorateClass([
578
+ classValidator.IsString(),
579
+ classValidator.IsOptional()
580
+ ], TransactionDocument.prototype, "authCode");
581
+ __decorateClass([
582
+ classValidator.IsString(),
583
+ classValidator.IsOptional()
584
+ ], TransactionDocument.prototype, "terminalId");
585
+ __decorateClass([
586
+ classValidator.IsString(),
587
+ classValidator.IsOptional()
588
+ ], TransactionDocument.prototype, "terminalName");
589
+ __decorateClass([
590
+ classValidator.IsString(),
591
+ classValidator.IsOptional()
592
+ ], TransactionDocument.prototype, "cardNumber");
593
+ var TransactionsExportDto = class {
594
+ data;
595
+ };
596
+ __decorateClass([
597
+ classValidator.IsArray(),
598
+ classValidator.IsNotEmpty(),
599
+ classValidator.IsDefined()
600
+ ], TransactionsExportDto.prototype, "data");
601
+ var VendorSalesDocument = class {
602
+ mid;
603
+ vendorNumber;
604
+ vendorName;
605
+ totalTxnAmount;
606
+ };
607
+ __decorateClass([
608
+ classValidator.IsString(),
609
+ classValidator.IsNotEmpty()
610
+ ], VendorSalesDocument.prototype, "mid");
611
+ __decorateClass([
612
+ classValidator.IsString(),
613
+ classValidator.IsNotEmpty()
614
+ ], VendorSalesDocument.prototype, "vendorNumber");
615
+ __decorateClass([
616
+ classValidator.IsString(),
617
+ classValidator.IsNotEmpty()
618
+ ], VendorSalesDocument.prototype, "vendorName");
619
+ __decorateClass([
620
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
621
+ classValidator.IsNumber(),
622
+ classValidator.IsNotEmpty()
623
+ ], VendorSalesDocument.prototype, "totalTxnAmount");
624
+ var VendorListDocument = class {
625
+ mid;
626
+ vendorNumber;
627
+ vendorName;
628
+ email;
629
+ bank;
630
+ iban;
631
+ commission;
632
+ };
633
+ __decorateClass([
634
+ classValidator.IsString(),
635
+ classValidator.IsNotEmpty()
636
+ ], VendorListDocument.prototype, "mid");
637
+ __decorateClass([
638
+ classValidator.IsString(),
639
+ classValidator.IsNotEmpty()
640
+ ], VendorListDocument.prototype, "vendorNumber");
641
+ __decorateClass([
642
+ classValidator.IsString(),
643
+ classValidator.IsNotEmpty()
644
+ ], VendorListDocument.prototype, "vendorName");
645
+ __decorateClass([
646
+ classValidator.IsString(),
647
+ classValidator.IsNotEmpty()
648
+ ], VendorListDocument.prototype, "email");
649
+ __decorateClass([
650
+ classValidator.IsString(),
651
+ classValidator.IsNotEmpty()
652
+ ], VendorListDocument.prototype, "bank");
653
+ __decorateClass([
654
+ classValidator.IsString(),
655
+ classValidator.IsNotEmpty()
656
+ ], VendorListDocument.prototype, "iban");
657
+ __decorateClass([
658
+ classValidator.IsNotEmpty()
659
+ ], VendorListDocument.prototype, "commission");
660
+ var VendorSalesExportDto = class {
661
+ data;
662
+ };
663
+ __decorateClass([
664
+ classValidator.IsArray(),
665
+ classValidator.ValidateNested({ each: true }),
666
+ classTransformer.Type(() => VendorSalesDocument),
667
+ classValidator.IsNotEmpty(),
668
+ classValidator.IsDefined()
669
+ ], VendorSalesExportDto.prototype, "data");
670
+ var VendorListExportDto = class {
671
+ data;
672
+ };
673
+ __decorateClass([
674
+ classValidator.IsArray(),
675
+ classValidator.ValidateNested({ each: true }),
676
+ classTransformer.Type(() => VendorListDocument),
677
+ classValidator.IsNotEmpty(),
678
+ classValidator.IsDefined()
679
+ ], VendorListExportDto.prototype, "data");
680
+
681
+ // src/dtos/dto-map.ts
682
+ var DocumentPayloadMap = {
683
+ // transactions microservice dtos
684
+ [DocumentType.STATEMENTS]: StatementsExportDto,
685
+ [DocumentType.PAYOUTS]: PayoutsExportDto,
686
+ [DocumentType.SETTLEMENTS]: SettlementsExportDto,
687
+ [DocumentType.TRANSACTIONS]: TransactionsExportDto,
688
+ [DocumentType.TRANSACTIONS_INTERNAL]: TransactionsExportDto,
689
+ [DocumentType.REFUNDS]: RefundsExportDto,
690
+ [DocumentType.REFUNDS_INTERNAL_GATEWAY]: RefundsExportDto,
691
+ [DocumentType.PROFIT_FEES]: ProfitFeesExportDto,
692
+ [DocumentType.PAYMENT_METHODS]: PaymentMethodsExportDto,
693
+ [DocumentType.VENDOR_LIST]: VendorListExportDto,
694
+ [DocumentType.VENDOR_SALES]: VendorSalesExportDto,
695
+ [DocumentType.EXCEPTIONS]: ExceptionExportDto,
696
+ // pos microservice dtos
697
+ [DocumentType.REFUNDS_POS]: RefundsPOSExportDto,
698
+ [DocumentType.REFUNDS_INTERNAL_POS]: RefundsPOSExportDto
699
+ // elinks microservice dtos
700
+ };
701
+
702
+ // src/validators/document-validator.ts
703
+ var DocumentValidator = class {
704
+ /**
705
+ * Validate a document payload based on its type
706
+ * @param type - Document type
707
+ * @param payload - Raw payload data
708
+ * @returns Validation result with typed payload or errors
709
+ */
710
+ static async validatePayload(type, payload) {
711
+ const DtoClass = DocumentPayloadMap[type];
712
+ if (!DtoClass) {
713
+ return {
714
+ isValid: false,
715
+ errorMessage: `Unknown document type: ${type}`,
716
+ errors: [
717
+ {
718
+ property: "type",
719
+ constraints: { invalid: `Unknown document type: ${type}` }
720
+ }
721
+ ]
722
+ };
723
+ }
724
+ const instance = classTransformer.plainToInstance(DtoClass, payload);
725
+ const errors = await classValidator.validate(instance, {
726
+ whitelist: true,
727
+ validationError: {
728
+ target: false,
729
+ value: true
730
+ }
731
+ });
732
+ if (errors.length > 0) {
733
+ return {
734
+ isValid: false,
735
+ errors,
736
+ errorMessage: "Payload validation failed"
737
+ };
738
+ }
739
+ return {
740
+ isValid: true,
741
+ validatedPayload: instance
742
+ };
743
+ }
744
+ /**
745
+ * Format validation errors into human-readable messages
746
+ * @param errors - Array of validation errors
747
+ * @returns Formatted error messages
748
+ */
749
+ static formatErrors(errors) {
750
+ const messages = [];
751
+ const formatError = (error, path = "") => {
752
+ const currentPath = path ? `${path}.${error.property}` : error.property;
753
+ if (error.constraints) {
754
+ Object.values(error.constraints).forEach((message) => {
755
+ messages.push(`${currentPath}: ${message}`);
756
+ });
757
+ }
758
+ if (error.children && error.children.length > 0) {
759
+ error.children.forEach((child) => formatError(child, currentPath));
760
+ }
761
+ };
762
+ errors.forEach((error) => formatError(error));
763
+ return messages;
764
+ }
765
+ };
766
+
767
+ // src/client/document-client.ts
768
+ var DocumentExportClient = class {
769
+ client;
770
+ constructor(documentMsBaseUrl, documentMSCommunicationKey) {
771
+ this.client = axios__default.default.create({
772
+ baseURL: documentMsBaseUrl,
773
+ headers: {
774
+ "Content-Type": "application/json",
775
+ "x-communication-key": documentMSCommunicationKey || ""
776
+ }
777
+ });
778
+ }
779
+ /**
780
+ * Generate a document with type-safe payload
781
+ * @param type - Document type
782
+ * @param payload - Typed payload for the document
783
+ * @returns Document generation response
784
+ */
785
+ async generateDocument(documentFormat, documentType, dateRange, payload, merchantInfo, presignedURL = false) {
786
+ try {
787
+ const validation = await DocumentValidator.validatePayload(documentType, payload);
788
+ if (!validation.isValid) {
789
+ const messages = DocumentValidator.formatErrors(validation.errors || []);
790
+ throw new Error(`Document payload validation failed: ${messages.join("; ")}`);
791
+ }
792
+ const request = {
793
+ documentFormat,
794
+ documentType,
795
+ dateRange,
796
+ merchantInfo,
797
+ data: payload.data,
798
+ presignedURL
799
+ };
800
+ const response = await this.client.post("/v2/document-generation", request);
801
+ return response.data;
802
+ } catch (error) {
803
+ return Promise.reject(error);
804
+ }
805
+ }
806
+ };
807
+
808
+ // src/client/errors/document-error.ts
809
+ var DocumentError = class extends Error {
810
+ constructor(message, code, statusCode, details) {
811
+ super(message);
812
+ this.code = code;
813
+ this.statusCode = statusCode;
814
+ this.details = details;
815
+ this.name = "DocumentError";
816
+ Error.captureStackTrace(this, this.constructor);
817
+ }
818
+ };
819
+ var DocumentGenerationError = class extends DocumentError {
820
+ constructor(message, details) {
821
+ super(message, "DOCUMENT_GENERATION_ERROR", 500, details);
822
+ this.name = "DocumentGenerationError";
823
+ }
824
+ };
825
+ var DocumentNetworkError = class extends DocumentError {
826
+ constructor(message, statusCode, details) {
827
+ super(message, "NETWORK_ERROR", statusCode, details);
828
+ this.name = "DocumentNetworkError";
829
+ }
830
+ };
831
+
832
+ // src/client/errors/validation-error.ts
833
+ var DocumentValidationError = class extends DocumentError {
834
+ constructor(message, validationErrors) {
835
+ super(message, "VALIDATION_ERROR", 400, { validationErrors });
836
+ this.validationErrors = validationErrors;
837
+ this.name = "DocumentValidationError";
838
+ }
839
+ /**
840
+ * Get formatted validation error messages
841
+ */
842
+ getMessages() {
843
+ const messages = [];
844
+ const formatError = (error, path = "") => {
845
+ const currentPath = path ? `${path}.${error.property}` : error.property;
846
+ if (error.constraints) {
847
+ Object.values(error.constraints).forEach((msg) => {
848
+ messages.push(`${currentPath}: ${msg}`);
849
+ });
850
+ }
851
+ if (error.children && error.children.length > 0) {
852
+ error.children.forEach((child) => formatError(child, currentPath));
853
+ }
854
+ };
855
+ this.validationErrors.forEach((error) => formatError(error));
856
+ return messages;
857
+ }
858
+ };
859
+ var DateRangeExportDto = class {
860
+ from;
861
+ to;
862
+ };
863
+ __decorateClass([
864
+ classValidator.IsDateString(),
865
+ classValidator.IsNotEmpty()
866
+ ], DateRangeExportDto.prototype, "from");
867
+ __decorateClass([
868
+ classValidator.IsDateString(),
869
+ classValidator.IsNotEmpty()
870
+ ], DateRangeExportDto.prototype, "to");
871
+
872
+ // src/utils/chunked-fetcher.util.ts
873
+ async function fetchDBQueryInChunks(config) {
874
+ const { queryFn, pageOptions, chunkSize = 200 } = config;
875
+ const firstPageOptions = {
876
+ ...pageOptions,
877
+ take: chunkSize,
878
+ skip: 0
879
+ };
880
+ const [firstRecords, totalRecords] = await queryFn(firstPageOptions);
881
+ if (firstRecords.length >= totalRecords || firstRecords.length < chunkSize) {
882
+ return firstRecords;
883
+ }
884
+ const allRecords = new Array(totalRecords);
885
+ for (let i = 0; i < firstRecords.length; i++) {
886
+ allRecords[i] = firstRecords[i];
887
+ }
888
+ let currentIndex = firstRecords.length;
889
+ let skip = chunkSize;
890
+ while (currentIndex < totalRecords) {
891
+ const chunkPageOptions = {
892
+ ...pageOptions,
893
+ take: chunkSize,
894
+ skip
895
+ };
896
+ const [records] = await queryFn(chunkPageOptions);
897
+ if (records.length === 0) {
898
+ break;
899
+ }
900
+ for (let i = 0; i < records.length; i++) {
901
+ allRecords[currentIndex++] = records[i];
902
+ }
903
+ if (records.length < chunkSize) {
904
+ break;
905
+ }
906
+ skip += chunkSize;
907
+ }
908
+ if (currentIndex < totalRecords) {
909
+ allRecords.length = currentIndex;
910
+ }
911
+ return allRecords;
912
+ }
913
+
914
+ // src/utils/mask-account-number.ts
915
+ function maskAccountNumber(str) {
916
+ if (!str) return "";
917
+ const lastFourDigits = str.slice(-4);
918
+ const maskedPart = str.slice(0, -4).replace(/\d/g, "x");
919
+ return maskedPart + lastFourDigits || "";
920
+ }
921
+
922
+ // src/dtos/base/merchant-headers.ts
923
+ var MerchantDetailsHeaderExportDto = class {
924
+ name;
925
+ profile;
926
+ accountNumber;
927
+ totalBalance;
928
+ availableBalance;
929
+ pendingBalance;
930
+ currency;
931
+ };
932
+ __decorateClass([
933
+ classValidator.IsString(),
934
+ classValidator.IsNotEmpty()
935
+ ], MerchantDetailsHeaderExportDto.prototype, "name");
936
+ __decorateClass([
937
+ classValidator.IsUrl({ protocols: ["https"] }),
938
+ classValidator.IsOptional()
939
+ ], MerchantDetailsHeaderExportDto.prototype, "profile");
940
+ __decorateClass([
941
+ classTransformer.Transform(({ value }) => maskAccountNumber(value)),
942
+ classValidator.IsString(),
943
+ classValidator.IsNotEmpty()
944
+ ], MerchantDetailsHeaderExportDto.prototype, "accountNumber");
945
+ __decorateClass([
946
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
947
+ classValidator.IsNumber(),
948
+ classValidator.IsNotEmpty()
949
+ ], MerchantDetailsHeaderExportDto.prototype, "totalBalance");
950
+ __decorateClass([
951
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
952
+ classValidator.IsNumber(),
953
+ classValidator.IsNotEmpty()
954
+ ], MerchantDetailsHeaderExportDto.prototype, "availableBalance");
955
+ __decorateClass([
956
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
957
+ classValidator.IsNumber(),
958
+ classValidator.IsNotEmpty()
959
+ ], MerchantDetailsHeaderExportDto.prototype, "pendingBalance");
960
+ __decorateClass([
961
+ classValidator.IsString(),
962
+ classValidator.IsNotEmpty()
963
+ ], MerchantDetailsHeaderExportDto.prototype, "currency");
964
+
965
+ // src/dtos/base/document-generation.request.dto.ts
966
+ var DocumentGenerationRequestDto = class {
967
+ documentFormat;
968
+ documentType;
969
+ merchantInfo;
970
+ dateRange;
971
+ data;
972
+ presignedURL = false;
973
+ };
974
+ __decorateClass([
975
+ classValidator.IsEnum(FileFormat, { message: "document format must be one of: pdf, csv, xlsx" }),
976
+ classValidator.IsNotEmpty()
977
+ ], DocumentGenerationRequestDto.prototype, "documentFormat");
978
+ __decorateClass([
979
+ classValidator.IsString(),
980
+ classValidator.IsNotEmpty()
981
+ ], DocumentGenerationRequestDto.prototype, "documentType");
982
+ __decorateClass([
983
+ classTransformer.Type(() => MerchantDetailsHeaderExportDto),
984
+ classValidator.ValidateNested(),
985
+ classValidator.IsOptional()
986
+ ], DocumentGenerationRequestDto.prototype, "merchantInfo");
987
+ __decorateClass([
988
+ classTransformer.Type(() => DateRangeExportDto),
989
+ classValidator.ValidateNested(),
990
+ classValidator.IsNotEmpty()
991
+ ], DocumentGenerationRequestDto.prototype, "dateRange");
992
+ __decorateClass([
993
+ classValidator.IsNotEmpty()
994
+ ], DocumentGenerationRequestDto.prototype, "data");
995
+ __decorateClass([
996
+ classValidator.IsNotEmpty()
997
+ ], DocumentGenerationRequestDto.prototype, "presignedURL");
998
+
999
+ // src/dtos/base/document-path.response.dto.ts
1000
+ var DocumentPathResponseDto = class {
1001
+ name;
1002
+ path;
1003
+ s3Result;
1004
+ constructor(name, path, commandResult) {
1005
+ this.name = name;
1006
+ this.path = path;
1007
+ this.s3Result = commandResult;
1008
+ }
1009
+ };
1010
+ var InvoiceDocument = class {
1011
+ createdAt;
1012
+ paidAt;
1013
+ customerName;
1014
+ customerPhone;
1015
+ id;
1016
+ merchantReference;
1017
+ createdBy;
1018
+ transactionId = "";
1019
+ status;
1020
+ amount;
1021
+ paymentMethod;
1022
+ };
1023
+ __decorateClass([
1024
+ classValidator.IsString(),
1025
+ classValidator.IsNotEmpty()
1026
+ ], InvoiceDocument.prototype, "createdAt");
1027
+ __decorateClass([
1028
+ classValidator.IsString(),
1029
+ classValidator.IsNotEmpty()
1030
+ ], InvoiceDocument.prototype, "paidAt");
1031
+ __decorateClass([
1032
+ classValidator.IsString(),
1033
+ classValidator.IsNotEmpty()
1034
+ ], InvoiceDocument.prototype, "customerName");
1035
+ __decorateClass([
1036
+ classValidator.IsString(),
1037
+ classValidator.IsNotEmpty()
1038
+ ], InvoiceDocument.prototype, "customerPhone");
1039
+ __decorateClass([
1040
+ classValidator.IsString(),
1041
+ classValidator.IsNotEmpty()
1042
+ ], InvoiceDocument.prototype, "id");
1043
+ __decorateClass([
1044
+ classValidator.IsString(),
1045
+ classValidator.IsNotEmpty()
1046
+ ], InvoiceDocument.prototype, "merchantReference");
1047
+ __decorateClass([
1048
+ classValidator.IsString(),
1049
+ classValidator.IsNotEmpty()
1050
+ ], InvoiceDocument.prototype, "createdBy");
1051
+ __decorateClass([
1052
+ classValidator.IsString(),
1053
+ classValidator.IsOptional()
1054
+ ], InvoiceDocument.prototype, "transactionId");
1055
+ __decorateClass([
1056
+ classValidator.IsString(),
1057
+ classValidator.IsNotEmpty()
1058
+ ], InvoiceDocument.prototype, "status");
1059
+ __decorateClass([
1060
+ classTransformer.Transform(({ value }) => Number(value).toFixed(3)),
1061
+ classValidator.IsNumber(),
1062
+ classValidator.IsNotEmpty()
1063
+ ], InvoiceDocument.prototype, "amount");
1064
+ __decorateClass([
1065
+ classValidator.IsString(),
1066
+ classValidator.IsNotEmpty()
1067
+ ], InvoiceDocument.prototype, "paymentMethod");
1068
+ var InvoiceHistoryDocument = class {
1069
+ createdAt;
1070
+ action;
1071
+ createdBy;
1072
+ invoiceId;
1073
+ paymentMethod;
1074
+ paymentMethodBrand;
1075
+ };
1076
+ __decorateClass([
1077
+ classValidator.IsString(),
1078
+ classValidator.IsNotEmpty()
1079
+ ], InvoiceHistoryDocument.prototype, "createdAt");
1080
+ __decorateClass([
1081
+ classValidator.IsString(),
1082
+ classValidator.IsNotEmpty()
1083
+ ], InvoiceHistoryDocument.prototype, "action");
1084
+ __decorateClass([
1085
+ classValidator.IsString(),
1086
+ classValidator.IsNotEmpty()
1087
+ ], InvoiceHistoryDocument.prototype, "createdBy");
1088
+ __decorateClass([
1089
+ classValidator.IsString(),
1090
+ classValidator.IsNotEmpty()
1091
+ ], InvoiceHistoryDocument.prototype, "invoiceId");
1092
+ __decorateClass([
1093
+ classValidator.IsString(),
1094
+ classValidator.IsNotEmpty()
1095
+ ], InvoiceHistoryDocument.prototype, "paymentMethod");
1096
+ __decorateClass([
1097
+ classValidator.IsString(),
1098
+ classValidator.IsOptional()
1099
+ ], InvoiceHistoryDocument.prototype, "paymentMethodBrand");
1100
+ var InvoiceExportDto = class {
1101
+ data;
1102
+ };
1103
+ __decorateClass([
1104
+ classValidator.IsArray(),
1105
+ classValidator.ValidateNested({ each: true }),
1106
+ classTransformer.Type(() => InvoiceDocument),
1107
+ classValidator.IsNotEmpty(),
1108
+ classValidator.IsDefined()
1109
+ ], InvoiceExportDto.prototype, "data");
1110
+ var InvoiceHistoryExportDto = class {
1111
+ data;
1112
+ };
1113
+ __decorateClass([
1114
+ classValidator.IsArray(),
1115
+ classValidator.ValidateNested({ each: true }),
1116
+ classTransformer.Type(() => InvoiceHistoryDocument),
1117
+ classValidator.IsNotEmpty(),
1118
+ classValidator.IsDefined()
1119
+ ], InvoiceHistoryExportDto.prototype, "data");
1120
+
1121
+ exports.DateRangeExportDto = DateRangeExportDto;
1122
+ exports.DocumentError = DocumentError;
1123
+ exports.DocumentExportClient = DocumentExportClient;
1124
+ exports.DocumentGenerationError = DocumentGenerationError;
1125
+ exports.DocumentGenerationRequestDto = DocumentGenerationRequestDto;
1126
+ exports.DocumentNetworkError = DocumentNetworkError;
1127
+ exports.DocumentPathResponseDto = DocumentPathResponseDto;
1128
+ exports.DocumentPayloadMap = DocumentPayloadMap;
1129
+ exports.DocumentType = DocumentType;
1130
+ exports.DocumentValidationError = DocumentValidationError;
1131
+ exports.DocumentValidator = DocumentValidator;
1132
+ exports.ExceptionExportDto = ExceptionExportDto;
1133
+ exports.FileFormat = FileFormat;
1134
+ exports.InvoiceExportDto = InvoiceExportDto;
1135
+ exports.InvoiceHistoryExportDto = InvoiceHistoryExportDto;
1136
+ exports.MerchantDetailsHeaderExportDto = MerchantDetailsHeaderExportDto;
1137
+ exports.PaymentMethodsExportDto = PaymentMethodsExportDto;
1138
+ exports.PayoutsExportDto = PayoutsExportDto;
1139
+ exports.ProfitFeesExportDto = ProfitFeesExportDto;
1140
+ exports.RefundsExportDto = RefundsExportDto;
1141
+ exports.RefundsPOSExportDto = RefundsPOSExportDto;
1142
+ exports.SettlementsExportDto = SettlementsExportDto;
1143
+ exports.StatementsExportDto = StatementsExportDto;
1144
+ exports.TransactionsExportDto = TransactionsExportDto;
1145
+ exports.VendorListExportDto = VendorListExportDto;
1146
+ exports.VendorSalesExportDto = VendorSalesExportDto;
1147
+ exports.fetchDBQueryInChunks = fetchDBQueryInChunks;
1148
+ exports.maskAccountNumber = maskAccountNumber;
1149
+ //# sourceMappingURL=index.js.map
1150
+ //# sourceMappingURL=index.js.map