@djangocfg/api 1.0.2 → 1.0.4

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.
Files changed (35) hide show
  1. package/dist/index.cjs +1544 -1490
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +314 -256
  4. package/dist/index.d.ts +314 -256
  5. package/dist/index.mjs +1542 -1490
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +2 -2
  8. package/src/cfg/contexts/payments/ApiKeysContext.tsx +2 -2
  9. package/src/cfg/contexts/payments/CurrenciesContext.tsx +0 -26
  10. package/src/cfg/contexts/payments/OverviewContext.tsx +79 -0
  11. package/src/cfg/contexts/payments/RootPaymentsContext.tsx +137 -0
  12. package/src/cfg/contexts/payments/index.ts +13 -0
  13. package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +12 -10
  14. package/src/cfg/generated/_utils/hooks/cfg__payments.ts +12 -10
  15. package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +1 -1
  16. package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +1 -1
  17. package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +1 -1
  18. package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +2 -0
  19. package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +26 -0
  20. package/src/cfg/generated/_utils/schemas/DocumentCreateRequest.schema.ts +1 -1
  21. package/src/cfg/generated/_utils/schemas/Network.schema.ts +1 -1
  22. package/src/cfg/generated/_utils/schemas/PatchedPaymentRequest.schema.ts +0 -2
  23. package/src/cfg/generated/_utils/schemas/Payment.schema.ts +3 -2
  24. package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +1 -3
  25. package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +1 -3
  26. package/src/cfg/generated/_utils/schemas/PaymentRequest.schema.ts +0 -2
  27. package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +1 -1
  28. package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +1 -1
  29. package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +25 -0
  30. package/src/cfg/generated/_utils/schemas/index.ts +2 -0
  31. package/src/cfg/generated/cfg__payments/client.ts +24 -44
  32. package/src/cfg/generated/cfg__payments/models.ts +52 -46
  33. package/src/cfg/generated/enums.ts +34 -66
  34. package/src/cfg/generated/schema.ts +103 -124
  35. package/src/index.ts +20 -1
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Zod schema for SupportedCurrencies
3
+ *
4
+ * This schema provides runtime validation and type inference.
5
+ * * Supported currencies serializer for provider capabilities.
6
+
7
+ Gets supported currencies from providers through CurrencyService.
8
+ * */
9
+ import { z } from 'zod'
10
+ import * as Enums from '../../enums'
11
+
12
+ /**
13
+ * Supported currencies serializer for provider capabilities.
14
+
15
+ Gets supported currencies from providers through CurrencyService.
16
+ */
17
+ export const SupportedCurrenciesSchema = z.object({
18
+ provider: z.nativeEnum(Enums.SupportedCurrenciesProvider).optional(),
19
+ currency_type: z.nativeEnum(Enums.SupportedCurrenciesCurrencyType).optional(),
20
+ })
21
+
22
+ /**
23
+ * Infer TypeScript type from Zod schema
24
+ */
25
+ export type SupportedCurrencies = z.infer<typeof SupportedCurrenciesSchema>
@@ -64,6 +64,7 @@ export * from './ChunkRevectorizationRequestRequest.schema'
64
64
  export * from './Currency.schema'
65
65
  export * from './CurrencyAnalyticsItem.schema'
66
66
  export * from './CurrencyList.schema'
67
+ export * from './CurrencyRates.schema'
67
68
  export * from './Document.schema'
68
69
  export * from './DocumentArchive.schema'
69
70
  export * from './DocumentArchiveDetail.schema'
@@ -181,6 +182,7 @@ export * from './SubscriptionList.schema'
181
182
  export * from './SubscriptionOverview.schema'
182
183
  export * from './SubscriptionRequest.schema'
183
184
  export * from './SuccessResponse.schema'
185
+ export * from './SupportedCurrencies.schema'
184
186
  export * from './SupportedProviders.schema'
185
187
  export * from './Tariff.schema'
186
188
  export * from './TaskStatistics.schema'
@@ -290,8 +290,9 @@ export class CfgPayments {
290
290
  async apiKeysList(params?: { is_active?: boolean; ordering?: string; page?: number; page_size?: number; search?: string; user?: number }): Promise<Models.PaginatedAPIKeyListList>;
291
291
 
292
292
  /**
293
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
294
- * all API keys with filtering and stats.
293
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
294
+ * filtering and stats. - Regular users: can only see/manage their own API
295
+ * keys - Staff/Admin: can see/manage all API keys
295
296
  */
296
297
  async apiKeysList(...args: any[]): Promise<Models.PaginatedAPIKeyListList> {
297
298
  const isParamsObject = args.length === 1 && typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0]);
@@ -307,8 +308,9 @@ export class CfgPayments {
307
308
  }
308
309
 
309
310
  /**
310
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
311
- * all API keys with filtering and stats.
311
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
312
+ * filtering and stats. - Regular users: can only see/manage their own API
313
+ * keys - Staff/Admin: can see/manage all API keys
312
314
  */
313
315
  async apiKeysCreate(data: Models.APIKeyCreateRequest): Promise<Models.APIKeyCreate> {
314
316
  const response = await this.client.request('POST', "/cfg/payments/api-keys/", { body: data });
@@ -316,8 +318,9 @@ export class CfgPayments {
316
318
  }
317
319
 
318
320
  /**
319
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
320
- * all API keys with filtering and stats.
321
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
322
+ * filtering and stats. - Regular users: can only see/manage their own API
323
+ * keys - Staff/Admin: can see/manage all API keys
321
324
  */
322
325
  async apiKeysRetrieve(id: string): Promise<Models.APIKeyDetail> {
323
326
  const response = await this.client.request('GET', `/cfg/payments/api-keys/${id}/`);
@@ -325,8 +328,9 @@ export class CfgPayments {
325
328
  }
326
329
 
327
330
  /**
328
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
329
- * all API keys with filtering and stats.
331
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
332
+ * filtering and stats. - Regular users: can only see/manage their own API
333
+ * keys - Staff/Admin: can see/manage all API keys
330
334
  */
331
335
  async apiKeysUpdate(id: string, data: Models.APIKeyUpdateRequest): Promise<Models.APIKeyUpdate> {
332
336
  const response = await this.client.request('PUT', `/cfg/payments/api-keys/${id}/`, { body: data });
@@ -334,8 +338,9 @@ export class CfgPayments {
334
338
  }
335
339
 
336
340
  /**
337
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
338
- * all API keys with filtering and stats.
341
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
342
+ * filtering and stats. - Regular users: can only see/manage their own API
343
+ * keys - Staff/Admin: can see/manage all API keys
339
344
  */
340
345
  async apiKeysPartialUpdate(id: string, data?: Models.PatchedAPIKeyUpdateRequest): Promise<Models.APIKeyUpdate> {
341
346
  const response = await this.client.request('PATCH', `/cfg/payments/api-keys/${id}/`, { body: data });
@@ -343,8 +348,9 @@ export class CfgPayments {
343
348
  }
344
349
 
345
350
  /**
346
- * Global API Key ViewSet: /api/api-keys/ Provides admin-level access to
347
- * all API keys with filtering and stats.
351
+ * API Key ViewSet: /api/api-keys/ User-specific access to API keys with
352
+ * filtering and stats. - Regular users: can only see/manage their own API
353
+ * keys - Staff/Admin: can see/manage all API keys
348
354
  */
349
355
  async apiKeysDestroy(id: string): Promise<void> {
350
356
  const response = await this.client.request('DELETE', `/cfg/payments/api-keys/${id}/`);
@@ -580,24 +586,11 @@ export class CfgPayments {
580
586
  return response;
581
587
  }
582
588
 
583
- async currenciesRatesRetrieve(base_currency: string, currencies: string): Promise<Models.Currency>;
584
- async currenciesRatesRetrieve(params: { base_currency: string; currencies: string }): Promise<Models.Currency>;
585
-
586
589
  /**
587
- * Get exchange rates
588
- *
589
- * Get current exchange rates for specified currencies
590
+ * Get current exchange rates.
590
591
  */
591
- async currenciesRatesRetrieve(...args: any[]): Promise<Models.Currency> {
592
- const isParamsObject = args.length === 1 && typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0]);
593
-
594
- let params;
595
- if (isParamsObject) {
596
- params = args[0];
597
- } else {
598
- params = { base_currency: args[0], currencies: args[1] };
599
- }
600
- const response = await this.client.request('GET', "/cfg/payments/currencies/rates/", { params });
592
+ async currenciesRatesRetrieve(): Promise<Models.CurrencyRates> {
593
+ const response = await this.client.request('GET', "/cfg/payments/currencies/rates/");
601
594
  return response;
602
595
  }
603
596
 
@@ -618,24 +611,11 @@ export class CfgPayments {
618
611
  return response;
619
612
  }
620
613
 
621
- async currenciesSupportedRetrieve(currency_type?: string, provider?: string): Promise<Models.Currency>;
622
- async currenciesSupportedRetrieve(params?: { currency_type?: string; provider?: string }): Promise<Models.Currency>;
623
-
624
614
  /**
625
- * Get supported currencies
626
- *
627
- * Get list of supported currencies from payment providers
615
+ * Get supported currencies from providers.
628
616
  */
629
- async currenciesSupportedRetrieve(...args: any[]): Promise<Models.Currency> {
630
- const isParamsObject = args.length === 1 && typeof args[0] === 'object' && args[0] !== null && !Array.isArray(args[0]);
631
-
632
- let params;
633
- if (isParamsObject) {
634
- params = args[0];
635
- } else {
636
- params = { currency_type: args[0], provider: args[1] };
637
- }
638
- const response = await this.client.request('GET', "/cfg/payments/currencies/supported/", { params });
617
+ async currenciesSupportedRetrieve(): Promise<Models.SupportedCurrencies> {
618
+ const response = await this.client.request('GET', "/cfg/payments/currencies/supported/");
639
619
  return response;
640
620
  }
641
621
 
@@ -530,7 +530,7 @@ export interface APIKeyValidationResponse {
530
530
  success: boolean;
531
531
  /** Whether the API key is valid */
532
532
  valid: boolean;
533
- api_key: Record<string, any>;
533
+ api_key: Record<string, any> | null;
534
534
  /** Validation message */
535
535
  message: string;
536
536
  /** Error message if validation failed */
@@ -643,6 +643,42 @@ export interface Currency {
643
643
  updated_at: string;
644
644
  }
645
645
 
646
+ /**
647
+ * Currency rates serializer for getting exchange rates. Fetches current
648
+ * exchange rates through CurrencyService.
649
+ *
650
+ * Response model (includes read-only fields).
651
+ */
652
+ export interface CurrencyRates {
653
+ /** Base currency for rates (default: USD) */
654
+ base_currency?: string;
655
+ /** Specific currencies to get rates for (optional) */
656
+ currencies?: Array<string>;
657
+ /** Provider for exchange rates
658
+
659
+ * `nowpayments` - NowPayments */
660
+ provider?: Enums.CurrencyRatesProvider;
661
+ }
662
+
663
+ /**
664
+ * Supported currencies serializer for provider capabilities. Gets supported
665
+ * currencies from providers through CurrencyService.
666
+ *
667
+ * Response model (includes read-only fields).
668
+ */
669
+ export interface SupportedCurrencies {
670
+ /** Provider to get supported currencies from
671
+
672
+ * `nowpayments` - NowPayments */
673
+ provider?: Enums.SupportedCurrenciesProvider;
674
+ /** Filter by currency type
675
+
676
+ * `all` - All
677
+ * `crypto` - Cryptocurrency
678
+ * `fiat` - Fiat Currency */
679
+ currency_type?: Enums.SupportedCurrenciesCurrencyType;
680
+ }
681
+
646
682
  /**
647
683
  *
648
684
  * Response model (includes read-only fields).
@@ -698,10 +734,10 @@ export interface Payment {
698
734
  user: string;
699
735
  /** Payment amount in USD (float for performance) */
700
736
  amount_usd: number;
701
- /** Payment currency */
702
- currency: number;
703
- /** Blockchain network (for crypto payments) */
704
- network?: number | null;
737
+ /** Calculate crypto amount from USD amount and currency rate. */
738
+ amount_crypto: number;
739
+ currency: string;
740
+ network: string | null;
705
741
  /** Payment provider
706
742
 
707
743
  * `nowpayments` - NowPayments */
@@ -787,7 +823,7 @@ export interface PaginatedNetworkList {
787
823
  */
788
824
  export interface Network {
789
825
  id: number;
790
- currency: Record<string, any>;
826
+ currency: Record<string, any> | null;
791
827
  /** Network name (e.g., Ethereum, Bitcoin, Polygon) */
792
828
  name: string;
793
829
  /** Network code (e.g., ETH, BTC, MATIC) */
@@ -871,7 +907,7 @@ export interface PaymentsChartResponse {
871
907
  */
872
908
  export interface PaymentsMetrics {
873
909
  balance: Record<string, any>;
874
- subscription: Record<string, any>;
910
+ subscription: Record<string, any> | null;
875
911
  api_keys: Record<string, any>;
876
912
  payments: Record<string, any>;
877
913
  }
@@ -1032,21 +1068,8 @@ export interface PaginatedPaymentListList {
1032
1068
  export interface PaymentCreateRequest {
1033
1069
  /** Amount in USD (1.00 - 50,000.00) */
1034
1070
  amount_usd: number;
1035
- /** Cryptocurrency to receive
1036
-
1037
- * `BTC` - Bitcoin
1038
- * `ETH` - Ethereum
1039
- * `LTC` - Litecoin
1040
- * `XMR` - Monero
1041
- * `USDT` - Tether
1042
- * `USDC` - USD Coin
1043
- * `ADA` - Cardano
1044
- * `DOT` - Polkadot */
1045
- currency_code: Enums.PaymentCreateRequestCurrencyCode;
1046
- /** Payment provider
1047
-
1048
- * `nowpayments` - NowPayments */
1049
- provider?: Enums.PaymentCreateRequestProvider;
1071
+ /** Cryptocurrency code (validated against active currencies) */
1072
+ currency_code: string;
1050
1073
  /** Success callback URL */
1051
1074
  callback_url?: string;
1052
1075
  /** Cancellation URL */
@@ -1066,21 +1089,8 @@ export interface PaymentCreateRequest {
1066
1089
  export interface PaymentCreate {
1067
1090
  /** Amount in USD (1.00 - 50,000.00) */
1068
1091
  amount_usd: number;
1069
- /** Cryptocurrency to receive
1070
-
1071
- * `BTC` - Bitcoin
1072
- * `ETH` - Ethereum
1073
- * `LTC` - Litecoin
1074
- * `XMR` - Monero
1075
- * `USDT` - Tether
1076
- * `USDC` - USD Coin
1077
- * `ADA` - Cardano
1078
- * `DOT` - Polkadot */
1079
- currency_code: Enums.PaymentCreateCurrencyCode;
1080
- /** Payment provider
1081
-
1082
- * `nowpayments` - NowPayments */
1083
- provider?: Enums.PaymentCreateProvider;
1092
+ /** Cryptocurrency code (validated against active currencies) */
1093
+ currency_code: string;
1084
1094
  /** Success callback URL */
1085
1095
  callback_url?: string;
1086
1096
  /** Cancellation URL */
@@ -1100,10 +1110,6 @@ export interface PaymentCreate {
1100
1110
  export interface PaymentRequest {
1101
1111
  /** Payment amount in USD (float for performance) */
1102
1112
  amount_usd: number;
1103
- /** Payment currency */
1104
- currency: number;
1105
- /** Blockchain network (for crypto payments) */
1106
- network?: number | null;
1107
1113
  /** Payment provider
1108
1114
 
1109
1115
  * `nowpayments` - NowPayments */
@@ -1138,10 +1144,6 @@ export interface PaymentRequest {
1138
1144
  export interface PatchedPaymentRequest {
1139
1145
  /** Payment amount in USD (float for performance) */
1140
1146
  amount_usd?: number;
1141
- /** Payment currency */
1142
- currency?: number;
1143
- /** Blockchain network (for crypto payments) */
1144
- network?: number | null;
1145
1147
  /** Payment provider
1146
1148
 
1147
1149
  * `nowpayments` - NowPayments */
@@ -1201,7 +1203,7 @@ export interface PaginatedProviderCurrencyList {
1201
1203
  export interface ProviderCurrency {
1202
1204
  id: number;
1203
1205
  currency: Record<string, any>;
1204
- network: Record<string, any>;
1206
+ network: Record<string, any> | null;
1205
1207
  /** Payment provider name (e.g., nowpayments) */
1206
1208
  provider: string;
1207
1209
  /** Currency code as used by the provider */
@@ -1616,6 +1618,10 @@ export interface CurrencyList {
1616
1618
  type_display: string;
1617
1619
  /** Whether this currency is available for payments */
1618
1620
  is_active: boolean;
1621
+ /** Current USD exchange rate (1 unit = X USD) */
1622
+ usd_rate: number;
1623
+ /** When USD rate was last updated */
1624
+ usd_rate_updated_at: string | null;
1619
1625
  }
1620
1626
 
1621
1627
  /**
@@ -198,6 +198,14 @@ export enum CurrencyListCurrencyType {
198
198
  CRYPTO = "crypto",
199
199
  }
200
200
 
201
+ /**
202
+ * Provider for exchange rates
203
+ * * `nowpayments` - NowPayments
204
+ */
205
+ export enum CurrencyRatesProvider {
206
+ NOWPAYMENTS = "nowpayments",
207
+ }
208
+
201
209
  /**
202
210
  * Archive format
203
211
  * * `zip` - ZIP
@@ -208,8 +216,8 @@ export enum CurrencyListCurrencyType {
208
216
  export enum DocumentArchiveArchiveType {
209
217
  ZIP = "zip",
210
218
  TAR = "tar",
211
- TAR_GZ = "tar.gz",
212
- TAR_BZ2 = "tar.bz2",
219
+ TAR_DOT_GZ = "tar.gz",
220
+ TAR_DOT_BZ2 = "tar.bz2",
213
221
  }
214
222
 
215
223
  /**
@@ -237,8 +245,8 @@ export enum DocumentArchiveProcessingStatus {
237
245
  export enum DocumentArchiveDetailArchiveType {
238
246
  ZIP = "zip",
239
247
  TAR = "tar",
240
- TAR_GZ = "tar.gz",
241
- TAR_BZ2 = "tar.bz2",
248
+ TAR_DOT_GZ = "tar.gz",
249
+ TAR_DOT_BZ2 = "tar.bz2",
242
250
  }
243
251
 
244
252
  /**
@@ -266,8 +274,8 @@ export enum DocumentArchiveDetailProcessingStatus {
266
274
  export enum DocumentArchiveListArchiveType {
267
275
  ZIP = "zip",
268
276
  TAR = "tar",
269
- TAR_GZ = "tar.gz",
270
- TAR_BZ2 = "tar.bz2",
277
+ TAR_DOT_GZ = "tar.gz",
278
+ TAR_DOT_BZ2 = "tar.bz2",
271
279
  }
272
280
 
273
281
  /**
@@ -519,66 +527,6 @@ export enum PaymentStatus {
519
527
  REFUNDED = "refunded",
520
528
  }
521
529
 
522
- /**
523
- * Cryptocurrency to receive
524
- * * `BTC` - Bitcoin
525
- * * `ETH` - Ethereum
526
- * * `LTC` - Litecoin
527
- * * `XMR` - Monero
528
- * * `USDT` - Tether
529
- * * `USDC` - USD Coin
530
- * * `ADA` - Cardano
531
- * * `DOT` - Polkadot
532
- */
533
- export enum PaymentCreateCurrencyCode {
534
- BTC = "BTC",
535
- ETH = "ETH",
536
- LTC = "LTC",
537
- XMR = "XMR",
538
- USDT = "USDT",
539
- USDC = "USDC",
540
- ADA = "ADA",
541
- DOT = "DOT",
542
- }
543
-
544
- /**
545
- * Payment provider
546
- * * `nowpayments` - NowPayments
547
- */
548
- export enum PaymentCreateProvider {
549
- NOWPAYMENTS = "nowpayments",
550
- }
551
-
552
- /**
553
- * Cryptocurrency to receive
554
- * * `BTC` - Bitcoin
555
- * * `ETH` - Ethereum
556
- * * `LTC` - Litecoin
557
- * * `XMR` - Monero
558
- * * `USDT` - Tether
559
- * * `USDC` - USD Coin
560
- * * `ADA` - Cardano
561
- * * `DOT` - Polkadot
562
- */
563
- export enum PaymentCreateRequestCurrencyCode {
564
- BTC = "BTC",
565
- ETH = "ETH",
566
- LTC = "LTC",
567
- XMR = "XMR",
568
- USDT = "USDT",
569
- USDC = "USDC",
570
- ADA = "ADA",
571
- DOT = "DOT",
572
- }
573
-
574
- /**
575
- * Payment provider
576
- * * `nowpayments` - NowPayments
577
- */
578
- export enum PaymentCreateRequestProvider {
579
- NOWPAYMENTS = "nowpayments",
580
- }
581
-
582
530
  /**
583
531
  * Payment provider
584
532
  * * `nowpayments` - NowPayments
@@ -747,6 +695,26 @@ export enum SubscriptionRequestTier {
747
695
  ENTERPRISE = "enterprise",
748
696
  }
749
697
 
698
+ /**
699
+ * Provider to get supported currencies from
700
+ * * `nowpayments` - NowPayments
701
+ */
702
+ export enum SupportedCurrenciesProvider {
703
+ NOWPAYMENTS = "nowpayments",
704
+ }
705
+
706
+ /**
707
+ * Filter by currency type
708
+ * * `all` - All
709
+ * * `crypto` - Cryptocurrency
710
+ * * `fiat` - Fiat Currency
711
+ */
712
+ export enum SupportedCurrenciesCurrencyType {
713
+ ALL = "all",
714
+ CRYPTO = "crypto",
715
+ FIAT = "fiat",
716
+ }
717
+
750
718
  /**
751
719
  * * `open` - Open
752
720
  * * `waiting_for_user` - Waiting for User