@sdkrouter/payments 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,950 @@
1
+ import { ConsolaInstance } from 'consola';
2
+
3
+ /**
4
+ * * `created` - Created
5
+ * * `waiting` - Waiting for payment
6
+ * * `paid` - Paid
7
+ * * `expired` - Expired
8
+ * * `underpaid` - Underpaid
9
+ * * `overpaid` - Overpaid
10
+ * * `cancelled` - Cancelled
11
+ */
12
+ declare enum CustomerInvoiceDetailStatus {
13
+ CREATED = "created",
14
+ WAITING = "waiting",
15
+ PAID = "paid",
16
+ EXPIRED = "expired",
17
+ UNDERPAID = "underpaid",
18
+ OVERPAID = "overpaid",
19
+ CANCELLED = "cancelled"
20
+ }
21
+ /**
22
+ * * `deposit` - Deposit
23
+ * * `withdrawal` - Withdrawal
24
+ * * `refund` - Refund
25
+ * * `fee` - Fee
26
+ * * `adjustment` - Adjustment
27
+ */
28
+ declare enum CustomerTransactionResponseTransactionType {
29
+ DEPOSIT = "deposit",
30
+ WITHDRAWAL = "withdrawal",
31
+ REFUND = "refund",
32
+ FEE = "fee",
33
+ ADJUSTMENT = "adjustment"
34
+ }
35
+ /**
36
+ * * `pending` - Pending
37
+ * * `approved` - Approved
38
+ * * `processing` - Processing
39
+ * * `completed` - Completed
40
+ * * `rejected` - Rejected
41
+ * * `cancelled` - Cancelled
42
+ */
43
+ declare enum CustomerWithdrawalResponseStatus {
44
+ PENDING = "pending",
45
+ APPROVED = "approved",
46
+ PROCESSING = "processing",
47
+ COMPLETED = "completed",
48
+ REJECTED = "rejected",
49
+ CANCELLED = "cancelled"
50
+ }
51
+
52
+ type enums_CustomerInvoiceDetailStatus = CustomerInvoiceDetailStatus;
53
+ declare const enums_CustomerInvoiceDetailStatus: typeof CustomerInvoiceDetailStatus;
54
+ type enums_CustomerTransactionResponseTransactionType = CustomerTransactionResponseTransactionType;
55
+ declare const enums_CustomerTransactionResponseTransactionType: typeof CustomerTransactionResponseTransactionType;
56
+ type enums_CustomerWithdrawalResponseStatus = CustomerWithdrawalResponseStatus;
57
+ declare const enums_CustomerWithdrawalResponseStatus: typeof CustomerWithdrawalResponseStatus;
58
+ declare namespace enums {
59
+ export { enums_CustomerInvoiceDetailStatus as CustomerInvoiceDetailStatus, enums_CustomerTransactionResponseTransactionType as CustomerTransactionResponseTransactionType, enums_CustomerWithdrawalResponseStatus as CustomerWithdrawalResponseStatus };
60
+ }
61
+
62
+ /**
63
+ *
64
+ * Response model (includes read-only fields).
65
+ */
66
+ interface PaginatedCustomerInvoiceDetailList {
67
+ /** Total number of items across all pages */
68
+ count: number;
69
+ /** Current page number (1-based) */
70
+ page: number;
71
+ /** Total number of pages */
72
+ pages: number;
73
+ /** Number of items per page */
74
+ page_size: number;
75
+ /** Whether there is a next page */
76
+ has_next: boolean;
77
+ /** Whether there is a previous page */
78
+ has_previous: boolean;
79
+ /** Next page number (null if no next page) */
80
+ next_page?: number | null;
81
+ /** Previous page number (null if no previous page) */
82
+ previous_page?: number | null;
83
+ /** Array of items for current page */
84
+ results: Array<CustomerInvoiceDetail>;
85
+ }
86
+ /**
87
+ *
88
+ * Response model (includes read-only fields).
89
+ */
90
+ interface Balance {
91
+ balance_usd: any;
92
+ total_deposited: any;
93
+ total_withdrawn: any;
94
+ last_transaction_at?: string | null;
95
+ }
96
+ /**
97
+ *
98
+ * Response model (includes read-only fields).
99
+ */
100
+ interface PaginatedTransactionList {
101
+ /** Total number of items across all pages */
102
+ count: number;
103
+ /** Current page number (1-based) */
104
+ page: number;
105
+ /** Total number of pages */
106
+ pages: number;
107
+ /** Number of items per page */
108
+ page_size: number;
109
+ /** Whether there is a next page */
110
+ has_next: boolean;
111
+ /** Whether there is a previous page */
112
+ has_previous: boolean;
113
+ /** Next page number (null if no next page) */
114
+ next_page?: number | null;
115
+ /** Previous page number (null if no previous page) */
116
+ previous_page?: number | null;
117
+ /** Array of items for current page */
118
+ results: Array<Transaction>;
119
+ }
120
+ /**
121
+ * Public view — no ownership data.
122
+ *
123
+ * Response model (includes read-only fields).
124
+ */
125
+ interface PaymentLinkPublic {
126
+ id: string;
127
+ title: string;
128
+ description: string;
129
+ /** Fixed amount. Null = buyer chooses. */
130
+ amount_usd?: any | null;
131
+ network: string;
132
+ exchange: string;
133
+ success_url: string;
134
+ }
135
+ /**
136
+ *
137
+ * Response model (includes read-only fields).
138
+ */
139
+ interface PaymentLink {
140
+ id: string;
141
+ project: string;
142
+ title: string;
143
+ description?: string;
144
+ /** Fixed amount. Null = buyer chooses. */
145
+ amount_usd?: any | null;
146
+ network?: string;
147
+ exchange?: string;
148
+ is_active?: boolean;
149
+ success_url?: string;
150
+ metadata?: Record<string, any>;
151
+ total_payments: number;
152
+ total_collected_usd: any;
153
+ pay_url: string;
154
+ created_at: string;
155
+ }
156
+ /**
157
+ *
158
+ * Response model (includes read-only fields).
159
+ */
160
+ interface PaginatedPaymentLinkList {
161
+ /** Total number of items across all pages */
162
+ count: number;
163
+ /** Current page number (1-based) */
164
+ page: number;
165
+ /** Total number of pages */
166
+ pages: number;
167
+ /** Number of items per page */
168
+ page_size: number;
169
+ /** Whether there is a next page */
170
+ has_next: boolean;
171
+ /** Whether there is a previous page */
172
+ has_previous: boolean;
173
+ /** Next page number (null if no next page) */
174
+ next_page?: number | null;
175
+ /** Previous page number (null if no previous page) */
176
+ previous_page?: number | null;
177
+ /** Array of items for current page */
178
+ results: Array<PaymentLink>;
179
+ }
180
+ /**
181
+ * Compact response after creating an invoice.
182
+ *
183
+ * Response model (includes read-only fields).
184
+ */
185
+ interface CustomerInvoiceResponse {
186
+ invoice_id: string;
187
+ amount_usd: any;
188
+ pay_amount: any;
189
+ pay_address: string;
190
+ coin: string;
191
+ network: string;
192
+ exchange: string;
193
+ status: string;
194
+ expires_at: string;
195
+ }
196
+ /**
197
+ * Full invoice details for customer.
198
+ *
199
+ * Response model (includes read-only fields).
200
+ */
201
+ interface CustomerInvoiceDetail {
202
+ id: string;
203
+ amount_usd: any;
204
+ /** Unique amount with fractional suffix shown to customer */
205
+ pay_amount: any;
206
+ /** Actual amount received from exchange deposit */
207
+ actual_amount?: any | null;
208
+ pay_address: string;
209
+ coin: string;
210
+ network: string;
211
+ exchange: string;
212
+ /** * `created` - Created
213
+ * `waiting` - Waiting for payment
214
+ * `paid` - Paid
215
+ * `expired` - Expired
216
+ * `underpaid` - Underpaid
217
+ * `overpaid` - Overpaid
218
+ * `cancelled` - Cancelled */
219
+ status: CustomerInvoiceDetailStatus;
220
+ tx_id?: string | null;
221
+ /** Confirmation progress, e.g. "3/12" */
222
+ confirm_times: string;
223
+ description: string;
224
+ expires_at: string;
225
+ completed_at?: string | null;
226
+ created_at: string;
227
+ }
228
+ /**
229
+ *
230
+ * Response model (includes read-only fields).
231
+ */
232
+ interface Withdrawal {
233
+ id: string;
234
+ project: string;
235
+ customer: string;
236
+ amount_usd: any;
237
+ fee_usd: any;
238
+ final_amount_usd: any;
239
+ network: string;
240
+ wallet_address: string;
241
+ /** * `pending` - Pending
242
+ * `approved` - Approved
243
+ * `processing` - Processing
244
+ * `completed` - Completed
245
+ * `rejected` - Rejected
246
+ * `cancelled` - Cancelled */
247
+ status: CustomerWithdrawalResponseStatus;
248
+ tx_id?: string | null;
249
+ created_at: string;
250
+ }
251
+ /**
252
+ * Public invoice status — minimal info for polling.
253
+ *
254
+ * Response model (includes read-only fields).
255
+ */
256
+ interface PublicInvoiceStatus {
257
+ invoice_id: string;
258
+ status: string;
259
+ confirm_times: string | null;
260
+ tx_id: string | null;
261
+ completed_at: string | null;
262
+ }
263
+ /**
264
+ * Input for customer creating a withdrawal.
265
+ *
266
+ * Request model (no read-only fields).
267
+ */
268
+ interface CustomerWithdrawalCreateRequest {
269
+ amount_usd: any;
270
+ network: string;
271
+ wallet_address: string;
272
+ }
273
+ /**
274
+ *
275
+ * Response model (includes read-only fields).
276
+ */
277
+ interface PaginatedInvoiceDetailList {
278
+ /** Total number of items across all pages */
279
+ count: number;
280
+ /** Current page number (1-based) */
281
+ page: number;
282
+ /** Total number of pages */
283
+ pages: number;
284
+ /** Number of items per page */
285
+ page_size: number;
286
+ /** Whether there is a next page */
287
+ has_next: boolean;
288
+ /** Whether there is a previous page */
289
+ has_previous: boolean;
290
+ /** Next page number (null if no next page) */
291
+ next_page?: number | null;
292
+ /** Previous page number (null if no previous page) */
293
+ previous_page?: number | null;
294
+ /** Array of items for current page */
295
+ results: Array<InvoiceDetail>;
296
+ }
297
+ /**
298
+ *
299
+ * Response model (includes read-only fields).
300
+ */
301
+ interface InvoiceDetail {
302
+ id: string;
303
+ project: string;
304
+ customer: string;
305
+ amount_usd: any;
306
+ /** Unique amount with fractional suffix shown to customer */
307
+ pay_amount: any;
308
+ /** Actual amount received from exchange deposit */
309
+ actual_amount?: any | null;
310
+ pay_address: string;
311
+ coin: string;
312
+ network: string;
313
+ exchange: string;
314
+ /** * `created` - Created
315
+ * `waiting` - Waiting for payment
316
+ * `paid` - Paid
317
+ * `expired` - Expired
318
+ * `underpaid` - Underpaid
319
+ * `overpaid` - Overpaid
320
+ * `cancelled` - Cancelled */
321
+ status: CustomerInvoiceDetailStatus;
322
+ tx_id?: string | null;
323
+ /** Confirmation progress, e.g. "3/12" */
324
+ confirm_times: string;
325
+ description: string;
326
+ expires_at: string;
327
+ completed_at?: string | null;
328
+ created_at: string;
329
+ }
330
+ /**
331
+ *
332
+ * Request model (no read-only fields).
333
+ */
334
+ interface PaymentLinkCreateRequest {
335
+ title: string;
336
+ description?: string;
337
+ amount_usd?: any | null;
338
+ network?: string;
339
+ exchange?: string;
340
+ success_url?: string;
341
+ project_slug: string;
342
+ metadata?: Record<string, any>;
343
+ }
344
+ /**
345
+ *
346
+ * Response model (includes read-only fields).
347
+ */
348
+ interface CustomerWithdrawalResponse {
349
+ id: string;
350
+ amount_usd: any;
351
+ fee_usd: any;
352
+ final_amount_usd: any;
353
+ network: string;
354
+ wallet_address: string;
355
+ /** * `pending` - Pending
356
+ * `approved` - Approved
357
+ * `processing` - Processing
358
+ * `completed` - Completed
359
+ * `rejected` - Rejected
360
+ * `cancelled` - Cancelled */
361
+ status: CustomerWithdrawalResponseStatus;
362
+ tx_id?: string | null;
363
+ created_at: string;
364
+ }
365
+ /**
366
+ *
367
+ * Request model (no read-only fields).
368
+ */
369
+ interface WithdrawalCreateRequest {
370
+ amount_usd: any;
371
+ network: string;
372
+ wallet_address: string;
373
+ customer_id: string;
374
+ project_slug: string;
375
+ }
376
+ /**
377
+ * Input for paying via a payment link.
378
+ *
379
+ * Request model (no read-only fields).
380
+ */
381
+ interface PaymentLinkPayInputRequest {
382
+ email?: string | null;
383
+ name?: string;
384
+ amount_usd?: any | null;
385
+ external_id?: string | null;
386
+ }
387
+ /**
388
+ *
389
+ * Response model (includes read-only fields).
390
+ */
391
+ interface CustomerBalanceResponse {
392
+ balance_usd: any;
393
+ total_deposited: any;
394
+ total_withdrawn: any;
395
+ last_transaction_at?: string | null;
396
+ }
397
+ /**
398
+ *
399
+ * Response model (includes read-only fields).
400
+ */
401
+ interface InvoiceResponse {
402
+ invoice_id: string;
403
+ amount_usd: any;
404
+ pay_amount: any;
405
+ pay_address: string;
406
+ coin: string;
407
+ network: string;
408
+ exchange: string;
409
+ status: string;
410
+ expires_at: string;
411
+ }
412
+ /**
413
+ * Response for invoice status polling.
414
+ *
415
+ * Response model (includes read-only fields).
416
+ */
417
+ interface InvoiceStatusResponse {
418
+ invoice_id: string;
419
+ status: string;
420
+ confirm_times: number;
421
+ actual_amount: string | null;
422
+ tx_id: string | null;
423
+ completed_at: string | null;
424
+ }
425
+ /**
426
+ *
427
+ * Response model (includes read-only fields).
428
+ */
429
+ interface PaginatedCustomerWithdrawalResponseList {
430
+ /** Total number of items across all pages */
431
+ count: number;
432
+ /** Current page number (1-based) */
433
+ page: number;
434
+ /** Total number of pages */
435
+ pages: number;
436
+ /** Number of items per page */
437
+ page_size: number;
438
+ /** Whether there is a next page */
439
+ has_next: boolean;
440
+ /** Whether there is a previous page */
441
+ has_previous: boolean;
442
+ /** Next page number (null if no next page) */
443
+ next_page?: number | null;
444
+ /** Previous page number (null if no previous page) */
445
+ previous_page?: number | null;
446
+ /** Array of items for current page */
447
+ results: Array<CustomerWithdrawalResponse>;
448
+ }
449
+ /**
450
+ *
451
+ * Response model (includes read-only fields).
452
+ */
453
+ interface PaginatedCustomerTransactionResponseList {
454
+ /** Total number of items across all pages */
455
+ count: number;
456
+ /** Current page number (1-based) */
457
+ page: number;
458
+ /** Total number of pages */
459
+ pages: number;
460
+ /** Number of items per page */
461
+ page_size: number;
462
+ /** Whether there is a next page */
463
+ has_next: boolean;
464
+ /** Whether there is a previous page */
465
+ has_previous: boolean;
466
+ /** Next page number (null if no next page) */
467
+ next_page?: number | null;
468
+ /** Previous page number (null if no previous page) */
469
+ previous_page?: number | null;
470
+ /** Array of items for current page */
471
+ results: Array<CustomerTransactionResponse>;
472
+ }
473
+ /**
474
+ *
475
+ * Request model (no read-only fields).
476
+ */
477
+ interface InvoiceCreateRequest {
478
+ amount_usd: any;
479
+ network?: string;
480
+ exchange?: string | null;
481
+ description?: string;
482
+ customer_id: string;
483
+ project_slug: string;
484
+ }
485
+ /**
486
+ *
487
+ * Response model (includes read-only fields).
488
+ */
489
+ interface Transaction {
490
+ id: string;
491
+ /** * `deposit` - Deposit
492
+ * `withdrawal` - Withdrawal
493
+ * `refund` - Refund
494
+ * `fee` - Fee
495
+ * `adjustment` - Adjustment */
496
+ transaction_type: CustomerTransactionResponseTransactionType;
497
+ amount_usd: any;
498
+ balance_after: any;
499
+ invoice?: string | null;
500
+ withdrawal?: string | null;
501
+ description: string;
502
+ created_at: string;
503
+ }
504
+ /**
505
+ *
506
+ * Response model (includes read-only fields).
507
+ */
508
+ interface CustomerTransactionResponse {
509
+ id: string;
510
+ /** * `deposit` - Deposit
511
+ * `withdrawal` - Withdrawal
512
+ * `refund` - Refund
513
+ * `fee` - Fee
514
+ * `adjustment` - Adjustment */
515
+ transaction_type: CustomerTransactionResponseTransactionType;
516
+ amount_usd: any;
517
+ balance_after: any;
518
+ invoice?: string | null;
519
+ withdrawal?: string | null;
520
+ description: string;
521
+ created_at: string;
522
+ }
523
+
524
+ /**
525
+ * API endpoints for Payments.
526
+ */
527
+ declare class PaymentsPayments {
528
+ private client;
529
+ constructor(client: any);
530
+ /**
531
+ * Mixin for views that need owner-scoped queries. Supports both API key
532
+ * auth and JWT auth. Use in payment admin views to get projects/keys for
533
+ * the current owner.
534
+ */
535
+ balanceRetrieve(): Promise<Balance>;
536
+ /**
537
+ * GET /customer/balance/ — customer balance (always 200).
538
+ */
539
+ customerBalanceRetrieve(): Promise<CustomerBalanceResponse>;
540
+ customerInvoicesList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedCustomerInvoiceDetailList>;
541
+ customerInvoicesList(params?: {
542
+ ordering?: string;
543
+ page?: number;
544
+ page_size?: number;
545
+ search?: string;
546
+ }): Promise<PaginatedCustomerInvoiceDetailList>;
547
+ /**
548
+ * GET /customer/invoices/{id}/ — invoice detail.
549
+ */
550
+ customerInvoicesRetrieve(id: string): Promise<CustomerInvoiceDetail>;
551
+ /**
552
+ * GET /customer/profile/ — customer profile (always 200).
553
+ */
554
+ customerProfileRetrieve(): Promise<any>;
555
+ customerTransactionsList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedCustomerTransactionResponseList>;
556
+ customerTransactionsList(params?: {
557
+ ordering?: string;
558
+ page?: number;
559
+ page_size?: number;
560
+ search?: string;
561
+ }): Promise<PaginatedCustomerTransactionResponseList>;
562
+ customerWithdrawalsList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedCustomerWithdrawalResponseList>;
563
+ customerWithdrawalsList(params?: {
564
+ ordering?: string;
565
+ page?: number;
566
+ page_size?: number;
567
+ search?: string;
568
+ }): Promise<PaginatedCustomerWithdrawalResponseList>;
569
+ /**
570
+ * POST /customer/withdrawals/create/ — create withdrawal.
571
+ */
572
+ customerWithdrawalsCreateCreate(data: CustomerWithdrawalCreateRequest): Promise<CustomerWithdrawalResponse>;
573
+ invoicesList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedInvoiceDetailList>;
574
+ invoicesList(params?: {
575
+ ordering?: string;
576
+ page?: number;
577
+ page_size?: number;
578
+ search?: string;
579
+ }): Promise<PaginatedInvoiceDetailList>;
580
+ invoicesRetrieve(id: string): Promise<InvoiceDetail>;
581
+ invoicesCancelCreate(id: string): Promise<InvoiceDetail>;
582
+ invoicesStatusRetrieve(id: string): Promise<InvoiceStatusResponse>;
583
+ /**
584
+ * Mixin for views that need owner-scoped queries. Supports both API key
585
+ * auth and JWT auth. Use in payment admin views to get projects/keys for
586
+ * the current owner.
587
+ */
588
+ invoicesCreateCreate(data: InvoiceCreateRequest): Promise<InvoiceResponse>;
589
+ linksList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedPaymentLinkList>;
590
+ linksList(params?: {
591
+ ordering?: string;
592
+ page?: number;
593
+ page_size?: number;
594
+ search?: string;
595
+ }): Promise<PaginatedPaymentLinkList>;
596
+ /**
597
+ * Mixin for views that need owner-scoped queries. Supports both API key
598
+ * auth and JWT auth. Use in payment admin views to get projects/keys for
599
+ * the current owner.
600
+ */
601
+ linksCreateCreate(data: PaymentLinkCreateRequest): Promise<PaymentLink>;
602
+ /**
603
+ * GET /invoices/{id}/status/ — public polling endpoint.
604
+ */
605
+ publicInvoicesStatusRetrieve(id: string): Promise<PublicInvoiceStatus>;
606
+ /**
607
+ * GET /links/{id}/ — public.
608
+ */
609
+ publicLinksRetrieve(id: string): Promise<PaymentLinkPublic>;
610
+ /**
611
+ * POST /links/{id}/pay/ — public.
612
+ */
613
+ publicLinksPayCreate(id: string, data: PaymentLinkPayInputRequest): Promise<CustomerInvoiceResponse>;
614
+ transactionsList(ordering?: string, page?: number, page_size?: number, search?: string): Promise<PaginatedTransactionList>;
615
+ transactionsList(params?: {
616
+ ordering?: string;
617
+ page?: number;
618
+ page_size?: number;
619
+ search?: string;
620
+ }): Promise<PaginatedTransactionList>;
621
+ /**
622
+ * Mixin for views that need owner-scoped queries. Supports both API key
623
+ * auth and JWT auth. Use in payment admin views to get projects/keys for
624
+ * the current owner.
625
+ */
626
+ withdrawalsCreate(data: WithdrawalCreateRequest): Promise<Withdrawal>;
627
+ withdrawalsRetrieve(id: string): Promise<Withdrawal>;
628
+ withdrawalsCancelCreate(id: string): Promise<Withdrawal>;
629
+ }
630
+
631
+ /**
632
+ * API Logger with Consola
633
+ * Beautiful console logging for API requests and responses
634
+ *
635
+ * Installation:
636
+ * npm install consola
637
+ */
638
+
639
+ /**
640
+ * Request log data
641
+ */
642
+ interface RequestLog {
643
+ method: string;
644
+ url: string;
645
+ headers?: Record<string, string>;
646
+ body?: any;
647
+ timestamp: number;
648
+ }
649
+ /**
650
+ * Response log data
651
+ */
652
+ interface ResponseLog {
653
+ status: number;
654
+ statusText: string;
655
+ data?: any;
656
+ duration: number;
657
+ timestamp: number;
658
+ }
659
+ /**
660
+ * Error log data
661
+ */
662
+ interface ErrorLog {
663
+ message: string;
664
+ statusCode?: number;
665
+ fieldErrors?: Record<string, string[]>;
666
+ duration: number;
667
+ timestamp: number;
668
+ }
669
+ /**
670
+ * Logger configuration
671
+ */
672
+ interface LoggerConfig {
673
+ /** Enable logging */
674
+ enabled: boolean;
675
+ /** Log requests */
676
+ logRequests: boolean;
677
+ /** Log responses */
678
+ logResponses: boolean;
679
+ /** Log errors */
680
+ logErrors: boolean;
681
+ /** Log request/response bodies */
682
+ logBodies: boolean;
683
+ /** Log headers (excluding sensitive ones) */
684
+ logHeaders: boolean;
685
+ /** Custom consola instance */
686
+ consola?: ConsolaInstance;
687
+ }
688
+ /**
689
+ * API Logger class
690
+ */
691
+ declare class APILogger {
692
+ private config;
693
+ private consola;
694
+ constructor(config?: Partial<LoggerConfig>);
695
+ /**
696
+ * Enable logging
697
+ */
698
+ enable(): void;
699
+ /**
700
+ * Disable logging
701
+ */
702
+ disable(): void;
703
+ /**
704
+ * Update configuration
705
+ */
706
+ setConfig(config: Partial<LoggerConfig>): void;
707
+ /**
708
+ * Filter sensitive headers
709
+ */
710
+ private filterHeaders;
711
+ /**
712
+ * Log request
713
+ */
714
+ logRequest(request: RequestLog): void;
715
+ /**
716
+ * Log response
717
+ */
718
+ logResponse(request: RequestLog, response: ResponseLog): void;
719
+ /**
720
+ * Log error
721
+ */
722
+ logError(request: RequestLog, error: ErrorLog): void;
723
+ /**
724
+ * Log general info
725
+ */
726
+ info(message: string, ...args: any[]): void;
727
+ /**
728
+ * Log warning
729
+ */
730
+ warn(message: string, ...args: any[]): void;
731
+ /**
732
+ * Log error
733
+ */
734
+ error(message: string, ...args: any[]): void;
735
+ /**
736
+ * Log debug
737
+ */
738
+ debug(message: string, ...args: any[]): void;
739
+ /**
740
+ * Log success
741
+ */
742
+ success(message: string, ...args: any[]): void;
743
+ /**
744
+ * Create a sub-logger with prefix
745
+ */
746
+ withTag(tag: string): ConsolaInstance;
747
+ }
748
+
749
+ /**
750
+ * Retry Configuration and Utilities
751
+ *
752
+ * Provides automatic retry logic for failed HTTP requests using p-retry.
753
+ * Retries only on network errors and server errors (5xx), not client errors (4xx).
754
+ */
755
+ /**
756
+ * Information about a failed retry attempt.
757
+ */
758
+ interface FailedAttemptInfo {
759
+ /** The error that caused the failure */
760
+ error: Error;
761
+ /** The attempt number (1-indexed) */
762
+ attemptNumber: number;
763
+ /** Number of retries left */
764
+ retriesLeft: number;
765
+ }
766
+ /**
767
+ * Retry configuration options.
768
+ *
769
+ * Uses exponential backoff with jitter by default to avoid thundering herd.
770
+ */
771
+ interface RetryConfig {
772
+ /**
773
+ * Maximum number of retry attempts.
774
+ * @default 3
775
+ */
776
+ retries?: number;
777
+ /**
778
+ * Exponential backoff factor.
779
+ * @default 2
780
+ */
781
+ factor?: number;
782
+ /**
783
+ * Minimum wait time between retries (ms).
784
+ * @default 1000
785
+ */
786
+ minTimeout?: number;
787
+ /**
788
+ * Maximum wait time between retries (ms).
789
+ * @default 60000
790
+ */
791
+ maxTimeout?: number;
792
+ /**
793
+ * Add randomness to wait times (jitter).
794
+ * Helps avoid thundering herd problem.
795
+ * @default true
796
+ */
797
+ randomize?: boolean;
798
+ /**
799
+ * Callback called on each failed attempt.
800
+ */
801
+ onFailedAttempt?: (info: FailedAttemptInfo) => void;
802
+ }
803
+
804
+ /**
805
+ * Storage adapters for cross-platform token storage.
806
+ *
807
+ * Supports:
808
+ * - LocalStorage (browser)
809
+ * - Cookies (SSR/browser)
810
+ * - Memory (Node.js/Electron/testing)
811
+ */
812
+
813
+ /**
814
+ * Storage adapter interface for cross-platform token storage.
815
+ */
816
+ interface StorageAdapter {
817
+ getItem(key: string): string | null;
818
+ setItem(key: string, value: string): void;
819
+ removeItem(key: string): void;
820
+ }
821
+ /**
822
+ * In-memory storage adapter for Node.js, Electron, and testing environments.
823
+ * Data is stored in RAM and cleared when process exits.
824
+ */
825
+ declare class MemoryStorageAdapter implements StorageAdapter {
826
+ private storage;
827
+ private logger?;
828
+ constructor(logger?: APILogger);
829
+ getItem(key: string): string | null;
830
+ setItem(key: string, value: string): void;
831
+ removeItem(key: string): void;
832
+ }
833
+
834
+ /**
835
+ * SDKRouter API - API Client with JWT Management
836
+ *
837
+ * Usage:
838
+ * ```typescript
839
+ * import { API } from './api';
840
+ *
841
+ * const api = new API('https://api.example.com');
842
+ *
843
+ * // Set JWT token
844
+ * api.setToken('your-jwt-token', 'refresh-token');
845
+ *
846
+ * // Use API
847
+ * const posts = await api.posts.list();
848
+ * const user = await api.users.retrieve(1);
849
+ *
850
+ * // Check authentication
851
+ * if (api.isAuthenticated()) {
852
+ * // ...
853
+ * }
854
+ *
855
+ * // Custom storage with logging (for Electron/Node.js)
856
+ * import { MemoryStorageAdapter, APILogger } from './storage';
857
+ * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
858
+ * const api = new API('https://api.example.com', {
859
+ * storage: new MemoryStorageAdapter(logger),
860
+ * loggerConfig: { enabled: true, logLevel: 'debug' }
861
+ * });
862
+ *
863
+ * // Get OpenAPI schema
864
+ * const schema = api.getSchema();
865
+ * ```
866
+ */
867
+
868
+ interface APIOptions {
869
+ /** Custom storage adapter (defaults to LocalStorageAdapter) */
870
+ storage?: StorageAdapter;
871
+ /** Custom HTTP client adapter (defaults to FetchAdapter) */
872
+ httpClient?: HttpClientAdapter;
873
+ /** Retry configuration for failed requests */
874
+ retryConfig?: RetryConfig;
875
+ /** Logger configuration */
876
+ loggerConfig?: Partial<LoggerConfig>;
877
+ /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
878
+ locale?: string;
879
+ }
880
+ declare class API {
881
+ private baseUrl;
882
+ private _client;
883
+ private _token;
884
+ private _refreshToken;
885
+ private _locale;
886
+ private storage;
887
+ private options?;
888
+ payments_payments: PaymentsPayments;
889
+ constructor(baseUrl: string, options?: APIOptions);
890
+ private _loadTokensFromStorage;
891
+ private _reinitClients;
892
+ private _injectAuthHeader;
893
+ /**
894
+ * Get current JWT token
895
+ */
896
+ getToken(): string | null;
897
+ /**
898
+ * Get current refresh token
899
+ */
900
+ getRefreshToken(): string | null;
901
+ /**
902
+ * Set JWT token and refresh token
903
+ * @param token - JWT access token
904
+ * @param refreshToken - JWT refresh token (optional)
905
+ */
906
+ setToken(token: string, refreshToken?: string): void;
907
+ /**
908
+ * Clear all tokens
909
+ */
910
+ clearTokens(): void;
911
+ /**
912
+ * Check if user is authenticated
913
+ */
914
+ isAuthenticated(): boolean;
915
+ /**
916
+ * Update base URL and reinitialize clients
917
+ * @param url - New base URL
918
+ */
919
+ setBaseUrl(url: string): void;
920
+ /**
921
+ * Get current base URL
922
+ */
923
+ getBaseUrl(): string;
924
+ /**
925
+ * Set locale for Accept-Language header
926
+ * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
927
+ */
928
+ setLocale(locale: string | null): void;
929
+ /**
930
+ * Get current locale
931
+ */
932
+ getLocale(): string | null;
933
+ /**
934
+ * Get OpenAPI schema path
935
+ * @returns Path to the OpenAPI schema JSON file
936
+ *
937
+ * Note: The OpenAPI schema is available in the schema.json file.
938
+ * You can load it dynamically using:
939
+ * ```typescript
940
+ * const schema = await fetch('./schema.json').then(r => r.json());
941
+ * // or using fs in Node.js:
942
+ * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
943
+ * ```
944
+ */
945
+ getSchemaPath(): string;
946
+ }
947
+
948
+ declare function createPaymentsApi(baseUrl: string): API;
949
+
950
+ export { API, type Balance, type CustomerBalanceResponse, type CustomerInvoiceDetail, type CustomerInvoiceResponse, type CustomerTransactionResponse, type CustomerWithdrawalCreateRequest, type CustomerWithdrawalResponse, enums as Enums, type InvoiceCreateRequest, type InvoiceDetail, type InvoiceResponse, MemoryStorageAdapter, type PaginatedCustomerInvoiceDetailList, type PaginatedCustomerTransactionResponseList, type PaginatedCustomerWithdrawalResponseList, type PaginatedInvoiceDetailList, type PaginatedPaymentLinkList, type PaginatedTransactionList, type PaymentLink, type PaymentLinkCreateRequest, type PaymentLinkPayInputRequest, type PaymentLinkPublic, API as PaymentsAPI, type Transaction, type Withdrawal, type WithdrawalCreateRequest, createPaymentsApi };