@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
@@ -2404,6 +2404,19 @@ export const OPENAPI_SCHEMA = {
2404
2404
  "type_display": {
2405
2405
  "readOnly": true,
2406
2406
  "type": "string"
2407
+ },
2408
+ "usd_rate": {
2409
+ "description": "Current USD exchange rate (1 unit = X USD)",
2410
+ "format": "double",
2411
+ "readOnly": true,
2412
+ "type": "number"
2413
+ },
2414
+ "usd_rate_updated_at": {
2415
+ "description": "When USD rate was last updated",
2416
+ "format": "date-time",
2417
+ "nullable": true,
2418
+ "readOnly": true,
2419
+ "type": "string"
2407
2420
  }
2408
2421
  },
2409
2422
  "required": [
@@ -2413,10 +2426,41 @@ export const OPENAPI_SCHEMA = {
2413
2426
  "is_active",
2414
2427
  "name",
2415
2428
  "symbol",
2416
- "type_display"
2429
+ "type_display",
2430
+ "usd_rate",
2431
+ "usd_rate_updated_at"
2417
2432
  ],
2418
2433
  "type": "object"
2419
2434
  },
2435
+ "CurrencyRates": {
2436
+ "description": "Currency rates serializer for getting exchange rates.\n\nFetches current exchange rates through CurrencyService.",
2437
+ "properties": {
2438
+ "base_currency": {
2439
+ "default": "USD",
2440
+ "description": "Base currency for rates (default: USD)",
2441
+ "maxLength": 10,
2442
+ "type": "string"
2443
+ },
2444
+ "currencies": {
2445
+ "description": "Specific currencies to get rates for (optional)",
2446
+ "items": {
2447
+ "maxLength": 10,
2448
+ "type": "string"
2449
+ },
2450
+ "type": "array"
2451
+ },
2452
+ "provider": {
2453
+ "default": "nowpayments",
2454
+ "description": "Provider for exchange rates\n\n* `nowpayments` - NowPayments",
2455
+ "enum": [
2456
+ "nowpayments"
2457
+ ],
2458
+ "type": "string",
2459
+ "x-spec-enum-id": "47694db6bd068cb3"
2460
+ }
2461
+ },
2462
+ "type": "object"
2463
+ },
2420
2464
  "Document": {
2421
2465
  "description": "Document response serializer.",
2422
2466
  "properties": {
@@ -3805,6 +3849,7 @@ export const OPENAPI_SCHEMA = {
3805
3849
  "$ref": "#/components/schemas/CurrencyList"
3806
3850
  }
3807
3851
  ],
3852
+ "nullable": true,
3808
3853
  "readOnly": true
3809
3854
  },
3810
3855
  "id": {
@@ -6653,10 +6698,6 @@ export const OPENAPI_SCHEMA = {
6653
6698
  "nullable": true,
6654
6699
  "type": "string"
6655
6700
  },
6656
- "currency": {
6657
- "description": "Payment currency",
6658
- "type": "integer"
6659
- },
6660
6701
  "description": {
6661
6702
  "description": "Payment description",
6662
6703
  "type": "string"
@@ -6667,11 +6708,6 @@ export const OPENAPI_SCHEMA = {
6667
6708
  "nullable": true,
6668
6709
  "type": "string"
6669
6710
  },
6670
- "network": {
6671
- "description": "Blockchain network (for crypto payments)",
6672
- "nullable": true,
6673
- "type": "integer"
6674
- },
6675
6711
  "provider": {
6676
6712
  "description": "Payment provider\n\n* `nowpayments` - NowPayments",
6677
6713
  "enum": [
@@ -6795,6 +6831,12 @@ export const OPENAPI_SCHEMA = {
6795
6831
  "Payment": {
6796
6832
  "description": "Complete payment serializer with full details.\n\nUsed for detail views and updates.",
6797
6833
  "properties": {
6834
+ "amount_crypto": {
6835
+ "description": "Calculate crypto amount from USD amount and currency rate.",
6836
+ "format": "double",
6837
+ "readOnly": true,
6838
+ "type": "number"
6839
+ },
6798
6840
  "amount_display": {
6799
6841
  "description": "Get formatted amount display.",
6800
6842
  "readOnly": true,
@@ -6840,8 +6882,8 @@ export const OPENAPI_SCHEMA = {
6840
6882
  "type": "string"
6841
6883
  },
6842
6884
  "currency": {
6843
- "description": "Payment currency",
6844
- "type": "integer"
6885
+ "readOnly": true,
6886
+ "type": "string"
6845
6887
  },
6846
6888
  "description": {
6847
6889
  "description": "Payment description",
@@ -6880,9 +6922,9 @@ export const OPENAPI_SCHEMA = {
6880
6922
  "type": "boolean"
6881
6923
  },
6882
6924
  "network": {
6883
- "description": "Blockchain network (for crypto payments)",
6884
6925
  "nullable": true,
6885
- "type": "integer"
6926
+ "readOnly": true,
6927
+ "type": "string"
6886
6928
  },
6887
6929
  "pay_address": {
6888
6930
  "description": "Cryptocurrency payment address",
@@ -6948,6 +6990,7 @@ export const OPENAPI_SCHEMA = {
6948
6990
  }
6949
6991
  },
6950
6992
  "required": [
6993
+ "amount_crypto",
6951
6994
  "amount_display",
6952
6995
  "amount_usd",
6953
6996
  "completed_at",
@@ -6959,6 +7002,7 @@ export const OPENAPI_SCHEMA = {
6959
7002
  "is_expired",
6960
7003
  "is_failed",
6961
7004
  "is_pending",
7005
+ "network",
6962
7006
  "pay_address",
6963
7007
  "payment_url",
6964
7008
  "provider_payment_id",
@@ -7014,19 +7058,9 @@ export const OPENAPI_SCHEMA = {
7014
7058
  "type": "string"
7015
7059
  },
7016
7060
  "currency_code": {
7017
- "description": "Cryptocurrency to receive\n\n* `BTC` - Bitcoin\n* `ETH` - Ethereum\n* `LTC` - Litecoin\n* `XMR` - Monero\n* `USDT` - Tether\n* `USDC` - USD Coin\n* `ADA` - Cardano\n* `DOT` - Polkadot",
7018
- "enum": [
7019
- "BTC",
7020
- "ETH",
7021
- "LTC",
7022
- "XMR",
7023
- "USDT",
7024
- "USDC",
7025
- "ADA",
7026
- "DOT"
7027
- ],
7028
- "type": "string",
7029
- "x-spec-enum-id": "a26a773d0d4fed5c"
7061
+ "description": "Cryptocurrency code (validated against active currencies)",
7062
+ "maxLength": 10,
7063
+ "type": "string"
7030
7064
  },
7031
7065
  "description": {
7032
7066
  "description": "Payment description",
@@ -7035,15 +7069,6 @@ export const OPENAPI_SCHEMA = {
7035
7069
  },
7036
7070
  "metadata": {
7037
7071
  "description": "Additional metadata"
7038
- },
7039
- "provider": {
7040
- "default": "nowpayments",
7041
- "description": "Payment provider\n\n* `nowpayments` - NowPayments",
7042
- "enum": [
7043
- "nowpayments"
7044
- ],
7045
- "type": "string",
7046
- "x-spec-enum-id": "47694db6bd068cb3"
7047
7072
  }
7048
7073
  },
7049
7074
  "required": [
@@ -7073,19 +7098,10 @@ export const OPENAPI_SCHEMA = {
7073
7098
  "type": "string"
7074
7099
  },
7075
7100
  "currency_code": {
7076
- "description": "Cryptocurrency to receive\n\n* `BTC` - Bitcoin\n* `ETH` - Ethereum\n* `LTC` - Litecoin\n* `XMR` - Monero\n* `USDT` - Tether\n* `USDC` - USD Coin\n* `ADA` - Cardano\n* `DOT` - Polkadot",
7077
- "enum": [
7078
- "BTC",
7079
- "ETH",
7080
- "LTC",
7081
- "XMR",
7082
- "USDT",
7083
- "USDC",
7084
- "ADA",
7085
- "DOT"
7086
- ],
7087
- "type": "string",
7088
- "x-spec-enum-id": "a26a773d0d4fed5c"
7101
+ "description": "Cryptocurrency code (validated against active currencies)",
7102
+ "maxLength": 10,
7103
+ "minLength": 1,
7104
+ "type": "string"
7089
7105
  },
7090
7106
  "description": {
7091
7107
  "description": "Payment description",
@@ -7094,15 +7110,6 @@ export const OPENAPI_SCHEMA = {
7094
7110
  },
7095
7111
  "metadata": {
7096
7112
  "description": "Additional metadata"
7097
- },
7098
- "provider": {
7099
- "default": "nowpayments",
7100
- "description": "Payment provider\n\n* `nowpayments` - NowPayments",
7101
- "enum": [
7102
- "nowpayments"
7103
- ],
7104
- "type": "string",
7105
- "x-spec-enum-id": "47694db6bd068cb3"
7106
7113
  }
7107
7114
  },
7108
7115
  "required": [
@@ -7297,10 +7304,6 @@ export const OPENAPI_SCHEMA = {
7297
7304
  "nullable": true,
7298
7305
  "type": "string"
7299
7306
  },
7300
- "currency": {
7301
- "description": "Payment currency",
7302
- "type": "integer"
7303
- },
7304
7307
  "description": {
7305
7308
  "description": "Payment description",
7306
7309
  "type": "string"
@@ -7311,11 +7314,6 @@ export const OPENAPI_SCHEMA = {
7311
7314
  "nullable": true,
7312
7315
  "type": "string"
7313
7316
  },
7314
- "network": {
7315
- "description": "Blockchain network (for crypto payments)",
7316
- "nullable": true,
7317
- "type": "integer"
7318
- },
7319
7317
  "provider": {
7320
7318
  "description": "Payment provider\n\n* `nowpayments` - NowPayments",
7321
7319
  "enum": [
@@ -7341,8 +7339,7 @@ export const OPENAPI_SCHEMA = {
7341
7339
  }
7342
7340
  },
7343
7341
  "required": [
7344
- "amount_usd",
7345
- "currency"
7342
+ "amount_usd"
7346
7343
  ],
7347
7344
  "type": "object"
7348
7345
  },
@@ -7543,6 +7540,7 @@ export const OPENAPI_SCHEMA = {
7543
7540
  "$ref": "#/components/schemas/Network"
7544
7541
  }
7545
7542
  ],
7543
+ "nullable": true,
7546
7544
  "readOnly": true
7547
7545
  },
7548
7546
  "provider": {
@@ -8516,6 +8514,32 @@ export const OPENAPI_SCHEMA = {
8516
8514
  ],
8517
8515
  "type": "object"
8518
8516
  },
8517
+ "SupportedCurrencies": {
8518
+ "description": "Supported currencies serializer for provider capabilities.\n\nGets supported currencies from providers through CurrencyService.",
8519
+ "properties": {
8520
+ "currency_type": {
8521
+ "default": "all",
8522
+ "description": "Filter by currency type\n\n* `all` - All\n* `crypto` - Cryptocurrency\n* `fiat` - Fiat Currency",
8523
+ "enum": [
8524
+ "all",
8525
+ "crypto",
8526
+ "fiat"
8527
+ ],
8528
+ "type": "string",
8529
+ "x-spec-enum-id": "aaea9f89fe6374a5"
8530
+ },
8531
+ "provider": {
8532
+ "default": "nowpayments",
8533
+ "description": "Provider to get supported currencies from\n\n* `nowpayments` - NowPayments",
8534
+ "enum": [
8535
+ "nowpayments"
8536
+ ],
8537
+ "type": "string",
8538
+ "x-spec-enum-id": "47694db6bd068cb3"
8539
+ }
8540
+ },
8541
+ "type": "object"
8542
+ },
8519
8543
  "SupportedProviders": {
8520
8544
  "description": "Serializer for supported providers response.",
8521
8545
  "properties": {
@@ -16073,7 +16097,7 @@ export const OPENAPI_SCHEMA = {
16073
16097
  },
16074
16098
  "/cfg/payments/api-keys/": {
16075
16099
  "get": {
16076
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16100
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16077
16101
  "operationId": "cfg_payments_api_keys_list",
16078
16102
  "parameters": [
16079
16103
  {
@@ -16153,7 +16177,7 @@ export const OPENAPI_SCHEMA = {
16153
16177
  "x-async-capable": false
16154
16178
  },
16155
16179
  "post": {
16156
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16180
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16157
16181
  "operationId": "cfg_payments_api_keys_create",
16158
16182
  "requestBody": {
16159
16183
  "content": {
@@ -16505,7 +16529,7 @@ export const OPENAPI_SCHEMA = {
16505
16529
  },
16506
16530
  "/cfg/payments/api-keys/{id}/": {
16507
16531
  "delete": {
16508
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16532
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16509
16533
  "operationId": "cfg_payments_api_keys_destroy",
16510
16534
  "parameters": [
16511
16535
  {
@@ -16538,7 +16562,7 @@ export const OPENAPI_SCHEMA = {
16538
16562
  "x-async-capable": false
16539
16563
  },
16540
16564
  "get": {
16541
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16565
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16542
16566
  "operationId": "cfg_payments_api_keys_retrieve",
16543
16567
  "parameters": [
16544
16568
  {
@@ -16578,7 +16602,7 @@ export const OPENAPI_SCHEMA = {
16578
16602
  "x-async-capable": false
16579
16603
  },
16580
16604
  "patch": {
16581
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16605
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16582
16606
  "operationId": "cfg_payments_api_keys_partial_update",
16583
16607
  "parameters": [
16584
16608
  {
@@ -16637,7 +16661,7 @@ export const OPENAPI_SCHEMA = {
16637
16661
  "x-async-capable": false
16638
16662
  },
16639
16663
  "put": {
16640
- "description": "Global API Key ViewSet: /api/api-keys/\n\nProvides admin-level access to all API keys with filtering and stats.",
16664
+ "description": "API Key ViewSet: /api/api-keys/\n\nUser-specific access to API keys with filtering and stats.\n- Regular users: can only see/manage their own API keys\n- Staff/Admin: can see/manage all API keys",
16641
16665
  "operationId": "cfg_payments_api_keys_update",
16642
16666
  "parameters": [
16643
16667
  {
@@ -17213,34 +17237,14 @@ export const OPENAPI_SCHEMA = {
17213
17237
  },
17214
17238
  "/cfg/payments/currencies/rates/": {
17215
17239
  "get": {
17216
- "description": "Get current exchange rates for specified currencies",
17240
+ "description": "Get current exchange rates.",
17217
17241
  "operationId": "cfg_payments_currencies_rates_retrieve",
17218
- "parameters": [
17219
- {
17220
- "description": "Base currency code (e.g., USD)",
17221
- "in": "query",
17222
- "name": "base_currency",
17223
- "required": true,
17224
- "schema": {
17225
- "type": "string"
17226
- }
17227
- },
17228
- {
17229
- "description": "Comma-separated list of target currency codes (e.g., BTC,ETH,USDT)",
17230
- "in": "query",
17231
- "name": "currencies",
17232
- "required": true,
17233
- "schema": {
17234
- "type": "string"
17235
- }
17236
- }
17237
- ],
17238
17242
  "responses": {
17239
17243
  "200": {
17240
17244
  "content": {
17241
17245
  "application/json": {
17242
17246
  "schema": {
17243
- "$ref": "#/components/schemas/Currency"
17247
+ "$ref": "#/components/schemas/CurrencyRates"
17244
17248
  }
17245
17249
  }
17246
17250
  },
@@ -17255,7 +17259,6 @@ export const OPENAPI_SCHEMA = {
17255
17259
  "cookieAuth": []
17256
17260
  }
17257
17261
  ],
17258
- "summary": "Get exchange rates",
17259
17262
  "tags": [
17260
17263
  "payments"
17261
17264
  ],
@@ -17324,37 +17327,14 @@ export const OPENAPI_SCHEMA = {
17324
17327
  },
17325
17328
  "/cfg/payments/currencies/supported/": {
17326
17329
  "get": {
17327
- "description": "Get list of supported currencies from payment providers",
17330
+ "description": "Get supported currencies from providers.",
17328
17331
  "operationId": "cfg_payments_currencies_supported_retrieve",
17329
- "parameters": [
17330
- {
17331
- "description": "Currency type filter: crypto, fiat, or stablecoin",
17332
- "in": "query",
17333
- "name": "currency_type",
17334
- "schema": {
17335
- "enum": [
17336
- "crypto",
17337
- "fiat",
17338
- "stablecoin"
17339
- ],
17340
- "type": "string"
17341
- }
17342
- },
17343
- {
17344
- "description": "Payment provider name (e.g., nowpayments)",
17345
- "in": "query",
17346
- "name": "provider",
17347
- "schema": {
17348
- "type": "string"
17349
- }
17350
- }
17351
- ],
17352
17332
  "responses": {
17353
17333
  "200": {
17354
17334
  "content": {
17355
17335
  "application/json": {
17356
17336
  "schema": {
17357
- "$ref": "#/components/schemas/Currency"
17337
+ "$ref": "#/components/schemas/SupportedCurrencies"
17358
17338
  }
17359
17339
  }
17360
17340
  },
@@ -17369,7 +17349,6 @@ export const OPENAPI_SCHEMA = {
17369
17349
  "cookieAuth": []
17370
17350
  }
17371
17351
  ],
17372
- "summary": "Get supported currencies",
17373
17352
  "tags": [
17374
17353
  "payments"
17375
17354
  ],
package/src/index.ts CHANGED
@@ -35,4 +35,23 @@ export { api as default } from './cfg/BaseClient';
35
35
  export * from './cfg/services';
36
36
 
37
37
  // Export all contexts (React contexts for data management)
38
- export * from './cfg/contexts';
38
+ export * from './cfg/contexts';
39
+
40
+ // Re-export all types and fetchers for convenience
41
+ // Usage: import { Schemas, Fetchers } from '@djangocfg/api'
42
+ export { Schemas, Fetchers } from './cfg/generated';
43
+
44
+ // Re-export commonly used types directly for convenience
45
+ // Usage: import type { APIKeyList } from '@djangocfg/api'
46
+ export type {
47
+ // API Keys
48
+ APIKeyList,
49
+ APIKeyDetail,
50
+ APIKeyCreate,
51
+ PaginatedAPIKeyListList,
52
+ // Auth
53
+ OTPRequestResponse,
54
+ OTPVerifyResponse,
55
+ User,
56
+ // Add more types as needed
57
+ } from './cfg/generated/_utils/schemas';