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