@djangocfg/api 1.0.3 → 1.0.5

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 (134) hide show
  1. package/dist/index.cjs +16105 -33860
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +15267 -34486
  4. package/dist/index.d.ts +15267 -34486
  5. package/dist/index.mjs +15970 -33847
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +2 -2
  8. package/src/cfg/contexts/payments/ApiKeysContext.tsx +21 -58
  9. package/src/cfg/contexts/payments/BalancesContext.tsx +19 -72
  10. package/src/cfg/contexts/payments/CurrenciesContext.tsx +5 -18
  11. package/src/cfg/contexts/payments/OverviewContext.tsx +78 -124
  12. package/src/cfg/contexts/payments/PaymentsContext.tsx +37 -36
  13. package/src/cfg/contexts/payments/RootPaymentsContext.tsx +7 -76
  14. package/src/cfg/contexts/payments/index.ts +5 -24
  15. package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +38 -2380
  16. package/src/cfg/generated/_utils/fetchers/index.ts +0 -1
  17. package/src/cfg/generated/_utils/hooks/cfg__payments.ts +41 -2615
  18. package/src/cfg/generated/_utils/hooks/index.ts +0 -1
  19. package/src/cfg/generated/_utils/schemas/ArchiveItem.schema.ts +1 -1
  20. package/src/cfg/generated/_utils/schemas/ArchiveItemChunk.schema.ts +1 -1
  21. package/src/cfg/generated/_utils/schemas/ArchiveItemChunkDetail.schema.ts +1 -1
  22. package/src/cfg/generated/_utils/schemas/ArchiveItemChunkRequest.schema.ts +1 -1
  23. package/src/cfg/generated/_utils/schemas/ArchiveItemDetail.schema.ts +1 -1
  24. package/src/cfg/generated/_utils/schemas/ArchiveItemRequest.schema.ts +1 -1
  25. package/src/cfg/generated/_utils/schemas/ChatMessage.schema.ts +2 -2
  26. package/src/cfg/generated/_utils/schemas/ChatSession.schema.ts +3 -3
  27. package/src/cfg/generated/_utils/schemas/ChatSessionRequest.schema.ts +3 -3
  28. package/src/cfg/generated/_utils/schemas/Document.schema.ts +1 -1
  29. package/src/cfg/generated/_utils/schemas/DocumentRequest.schema.ts +1 -1
  30. package/src/cfg/generated/_utils/schemas/PatchedArchiveItemChunkRequest.schema.ts +1 -1
  31. package/src/cfg/generated/_utils/schemas/PatchedArchiveItemRequest.schema.ts +1 -1
  32. package/src/cfg/generated/_utils/schemas/PatchedChatSessionRequest.schema.ts +3 -3
  33. package/src/cfg/generated/_utils/schemas/PatchedDocumentRequest.schema.ts +1 -1
  34. package/src/cfg/generated/_utils/schemas/PaymentDetail.schema.ts +44 -0
  35. package/src/cfg/generated/_utils/schemas/PaymentList.schema.ts +7 -11
  36. package/src/cfg/generated/_utils/schemas/index.ts +1 -81
  37. package/src/cfg/generated/cfg__payments/client.ts +40 -1732
  38. package/src/cfg/generated/cfg__payments/models.ts +50 -1823
  39. package/src/cfg/generated/client.ts +0 -3
  40. package/src/cfg/generated/enums.ts +5 -391
  41. package/src/cfg/generated/index.ts +3 -7
  42. package/src/cfg/generated/schema.ts +5918 -18389
  43. package/src/cfg/services/payments/ApiKeysService.ts +34 -116
  44. package/src/cfg/services/payments/DashboardService.ts +37 -122
  45. package/src/cfg/services/payments/PaymentsService.ts +36 -69
  46. package/src/cfg/services/payments/SubscriptionsService.ts +35 -136
  47. package/src/cfg/services/webhooks/WebhooksService.ts +24 -66
  48. package/src/index.ts +1 -6
  49. package/src/cfg/generated/_utils/fetchers/cfg__payments__webhooks.ts +0 -109
  50. package/src/cfg/generated/_utils/hooks/cfg__payments__webhooks.ts +0 -100
  51. package/src/cfg/generated/_utils/schemas/APIKeyCreate.schema.ts +0 -24
  52. package/src/cfg/generated/_utils/schemas/APIKeyCreateRequest.schema.ts +0 -24
  53. package/src/cfg/generated/_utils/schemas/APIKeyDetail.schema.ts +0 -35
  54. package/src/cfg/generated/_utils/schemas/APIKeyList.schema.ts +0 -32
  55. package/src/cfg/generated/_utils/schemas/APIKeyUpdate.schema.ts +0 -24
  56. package/src/cfg/generated/_utils/schemas/APIKeyUpdateRequest.schema.ts +0 -24
  57. package/src/cfg/generated/_utils/schemas/APIKeyValidationRequest.schema.ts +0 -23
  58. package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +0 -29
  59. package/src/cfg/generated/_utils/schemas/APIKeysOverview.schema.ts +0 -26
  60. package/src/cfg/generated/_utils/schemas/AdminPaymentCreate.schema.ts +0 -26
  61. package/src/cfg/generated/_utils/schemas/AdminPaymentCreateRequest.schema.ts +0 -27
  62. package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +0 -50
  63. package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +0 -38
  64. package/src/cfg/generated/_utils/schemas/AdminPaymentStats.schema.ts +0 -29
  65. package/src/cfg/generated/_utils/schemas/AdminPaymentUpdate.schema.ts +0 -25
  66. package/src/cfg/generated/_utils/schemas/AdminPaymentUpdateRequest.schema.ts +0 -25
  67. package/src/cfg/generated/_utils/schemas/AdminUser.schema.ts +0 -24
  68. package/src/cfg/generated/_utils/schemas/BalanceOverview.schema.ts +0 -25
  69. package/src/cfg/generated/_utils/schemas/ChartDataPoint.schema.ts +0 -20
  70. package/src/cfg/generated/_utils/schemas/ChartSeries.schema.ts +0 -22
  71. package/src/cfg/generated/_utils/schemas/Currency.schema.ts +0 -35
  72. package/src/cfg/generated/_utils/schemas/CurrencyAnalyticsItem.schema.ts +0 -25
  73. package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +0 -32
  74. package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +0 -26
  75. package/src/cfg/generated/_utils/schemas/EndpointGroup.schema.ts +0 -28
  76. package/src/cfg/generated/_utils/schemas/Network.schema.ts +0 -30
  77. package/src/cfg/generated/_utils/schemas/PaginatedAPIKeyListList.schema.ts +0 -24
  78. package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentListList.schema.ts +0 -24
  79. package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentStatsList.schema.ts +0 -24
  80. package/src/cfg/generated/_utils/schemas/PaginatedAdminUserList.schema.ts +0 -24
  81. package/src/cfg/generated/_utils/schemas/PaginatedCurrencyListList.schema.ts +0 -24
  82. package/src/cfg/generated/_utils/schemas/PaginatedEndpointGroupList.schema.ts +0 -24
  83. package/src/cfg/generated/_utils/schemas/PaginatedNetworkList.schema.ts +0 -24
  84. package/src/cfg/generated/_utils/schemas/PaginatedProviderCurrencyList.schema.ts +0 -24
  85. package/src/cfg/generated/_utils/schemas/PaginatedRecentPaymentList.schema.ts +0 -24
  86. package/src/cfg/generated/_utils/schemas/PaginatedRecentTransactionList.schema.ts +0 -24
  87. package/src/cfg/generated/_utils/schemas/PaginatedSubscriptionListList.schema.ts +0 -24
  88. package/src/cfg/generated/_utils/schemas/PaginatedTariffList.schema.ts +0 -24
  89. package/src/cfg/generated/_utils/schemas/PaginatedTransactionList.schema.ts +0 -24
  90. package/src/cfg/generated/_utils/schemas/PaginatedUserBalanceList.schema.ts +0 -24
  91. package/src/cfg/generated/_utils/schemas/PaginatedWebhookEventListList.schema.ts +0 -24
  92. package/src/cfg/generated/_utils/schemas/PaginatedWebhookStatsList.schema.ts +0 -24
  93. package/src/cfg/generated/_utils/schemas/PatchedAPIKeyUpdateRequest.schema.ts +0 -24
  94. package/src/cfg/generated/_utils/schemas/PatchedAdminPaymentUpdateRequest.schema.ts +0 -25
  95. package/src/cfg/generated/_utils/schemas/PatchedPaymentRequest.schema.ts +0 -32
  96. package/src/cfg/generated/_utils/schemas/PatchedSubscriptionRequest.schema.ts +0 -26
  97. package/src/cfg/generated/_utils/schemas/Payment.schema.ts +0 -49
  98. package/src/cfg/generated/_utils/schemas/PaymentAnalyticsResponse.schema.ts +0 -22
  99. package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +0 -29
  100. package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +0 -29
  101. package/src/cfg/generated/_utils/schemas/PaymentOverview.schema.ts +0 -31
  102. package/src/cfg/generated/_utils/schemas/PaymentRequest.schema.ts +0 -32
  103. package/src/cfg/generated/_utils/schemas/PaymentsChartResponse.schema.ts +0 -24
  104. package/src/cfg/generated/_utils/schemas/PaymentsDashboardOverview.schema.ts +0 -26
  105. package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +0 -26
  106. package/src/cfg/generated/_utils/schemas/ProviderAnalyticsItem.schema.ts +0 -24
  107. package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +0 -36
  108. package/src/cfg/generated/_utils/schemas/RecentPayment.schema.ts +0 -32
  109. package/src/cfg/generated/_utils/schemas/RecentTransaction.schema.ts +0 -29
  110. package/src/cfg/generated/_utils/schemas/Subscription.schema.ts +0 -41
  111. package/src/cfg/generated/_utils/schemas/SubscriptionCreate.schema.ts +0 -25
  112. package/src/cfg/generated/_utils/schemas/SubscriptionCreateRequest.schema.ts +0 -25
  113. package/src/cfg/generated/_utils/schemas/SubscriptionList.schema.ts +0 -32
  114. package/src/cfg/generated/_utils/schemas/SubscriptionOverview.schema.ts +0 -37
  115. package/src/cfg/generated/_utils/schemas/SubscriptionRequest.schema.ts +0 -26
  116. package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +0 -25
  117. package/src/cfg/generated/_utils/schemas/SupportedProviders.schema.ts +0 -22
  118. package/src/cfg/generated/_utils/schemas/Tariff.schema.ts +0 -34
  119. package/src/cfg/generated/_utils/schemas/Transaction.schema.ts +0 -35
  120. package/src/cfg/generated/_utils/schemas/UserBalance.schema.ts +0 -29
  121. package/src/cfg/generated/_utils/schemas/WebhookEvent.schema.ts +0 -31
  122. package/src/cfg/generated/_utils/schemas/WebhookEventList.schema.ts +0 -25
  123. package/src/cfg/generated/_utils/schemas/WebhookEventListRequest.schema.ts +0 -25
  124. package/src/cfg/generated/_utils/schemas/WebhookEventRequest.schema.ts +0 -30
  125. package/src/cfg/generated/_utils/schemas/WebhookHealth.schema.ts +0 -21
  126. package/src/cfg/generated/_utils/schemas/WebhookProviderStats.schema.ts +0 -23
  127. package/src/cfg/generated/_utils/schemas/WebhookProviderStatsRequest.schema.ts +0 -23
  128. package/src/cfg/generated/_utils/schemas/WebhookResponse.schema.ts +0 -27
  129. package/src/cfg/generated/_utils/schemas/WebhookResponseRequest.schema.ts +0 -27
  130. package/src/cfg/generated/_utils/schemas/WebhookStats.schema.ts +0 -27
  131. package/src/cfg/generated/_utils/schemas/WebhookStatsRequest.schema.ts +0 -27
  132. package/src/cfg/generated/cfg__payments__webhooks/client.ts +0 -75
  133. package/src/cfg/generated/cfg__payments__webhooks/index.ts +0 -2
  134. package/src/cfg/generated/cfg__payments__webhooks/models.ts +0 -87
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "author": {
5
5
  "name": "DjangoCFG",
6
6
  "url": "https://djangocfg.com"
@@ -68,7 +68,7 @@
68
68
  "@types/node": "^22.15.3",
69
69
  "@types/react": "19.2.2",
70
70
  "@types/react-dom": "19.2.1",
71
- "@djangocfg/typescript-config": "^1.0.3",
71
+ "@djangocfg/typescript-config": "^1.0.5",
72
72
  "react": "^19.1.0",
73
73
  "react-dom": "^19.1.0",
74
74
  "tsup": "^8.5.0",
@@ -1,35 +1,27 @@
1
1
  'use client';
2
2
 
3
3
  import React, { createContext, useContext, type ReactNode } from 'react';
4
- import { api } from '../../BaseClient';
5
- import {
6
- usePaymentsApiKeysList,
7
- usePaymentsApiKeysRetrieve,
8
- useCreatePaymentsApiKeysCreateCreate,
9
- useDeletePaymentsApiKeysDestroy,
10
- } from '../../generated/_utils/hooks';
11
- import type { API } from '../../generated';
12
- import type {
13
- APIKeyDetail,
14
- APIKeyCreateRequest,
15
- PaginatedAPIKeyListList,
16
- } from '../../generated/_utils/schemas';
4
+
5
+ // ─────────────────────────────────────────────────────────────────────────
6
+ // NOTE: API Keys feature has been removed in Payments v2.0
7
+ // This context is kept as a stub for backward compatibility
8
+ // ─────────────────────────────────────────────────────────────────────────
17
9
 
18
10
  // ─────────────────────────────────────────────────────────────────────────
19
11
  // Context Type
20
12
  // ─────────────────────────────────────────────────────────────────────────
21
13
 
22
14
  export interface ApiKeysContextValue {
23
- // List
24
- apiKeys: PaginatedAPIKeyListList | undefined;
15
+ // Deprecated - returns empty data
16
+ apiKeys: undefined;
25
17
  isLoadingApiKeys: boolean;
26
18
  apiKeysError: Error | undefined;
27
19
  refreshApiKeys: () => Promise<void>;
28
20
 
29
- // Operations
30
- getApiKey: (id: string) => Promise<APIKeyDetail | undefined>;
31
- createApiKey: (data: APIKeyCreateRequest) => Promise<APIKeyDetail>;
32
- deleteApiKey: (id: string) => Promise<void>;
21
+ // Deprecated operations - throw errors
22
+ getApiKey: (id: string) => Promise<never>;
23
+ createApiKey: (data: any) => Promise<never>;
24
+ deleteApiKey: (id: string) => Promise<never>;
33
25
  }
34
26
 
35
27
  // ─────────────────────────────────────────────────────────────────────────
@@ -43,45 +35,26 @@ const ApiKeysContext = createContext<ApiKeysContextValue | undefined>(undefined)
43
35
  // ─────────────────────────────────────────────────────────────────────────
44
36
 
45
37
  export function ApiKeysProvider({ children }: { children: ReactNode }) {
46
- // List API keys
47
- const {
48
- data: apiKeys,
49
- error: apiKeysError,
50
- isLoading: isLoadingApiKeys,
51
- mutate: mutateApiKeys,
52
- } = usePaymentsApiKeysList({}, api as unknown as API);
53
-
54
38
  const refreshApiKeys = async () => {
55
- await mutateApiKeys();
39
+ // No-op - feature deprecated
56
40
  };
57
41
 
58
- // Mutations
59
- const createApiKeyMutation = useCreatePaymentsApiKeysCreateCreate();
60
- const deleteApiKeyMutation = useDeletePaymentsApiKeysDestroy();
61
-
62
- // Get API key
63
- const getApiKey = async (id: string): Promise<APIKeyDetail | undefined> => {
64
- const { data } = usePaymentsApiKeysRetrieve(id, api as unknown as API);
65
- return data;
42
+ const getApiKey = async (id: string): Promise<never> => {
43
+ throw new Error('API Keys feature has been removed in Payments v2.0');
66
44
  };
67
45
 
68
- // Create API key
69
- const createApiKey = async (data: APIKeyCreateRequest): Promise<APIKeyDetail> => {
70
- const result = await createApiKeyMutation(data, api as unknown as API);
71
- await refreshApiKeys();
72
- return result as APIKeyDetail;
46
+ const createApiKey = async (data: any): Promise<never> => {
47
+ throw new Error('API Keys feature has been removed in Payments v2.0');
73
48
  };
74
49
 
75
- // Delete API key
76
- const deleteApiKey = async (id: string): Promise<void> => {
77
- await deleteApiKeyMutation(id, api as unknown as API);
78
- await refreshApiKeys();
50
+ const deleteApiKey = async (id: string): Promise<never> => {
51
+ throw new Error('API Keys feature has been removed in Payments v2.0');
79
52
  };
80
53
 
81
54
  const value: ApiKeysContextValue = {
82
- apiKeys,
83
- isLoadingApiKeys,
84
- apiKeysError,
55
+ apiKeys: undefined,
56
+ isLoadingApiKeys: false,
57
+ apiKeysError: undefined,
85
58
  refreshApiKeys,
86
59
  getApiKey,
87
60
  createApiKey,
@@ -103,13 +76,3 @@ export function useApiKeysContext(): ApiKeysContextValue {
103
76
  return context;
104
77
  }
105
78
 
106
- // ─────────────────────────────────────────────────────────────────────────
107
- // Re-export types
108
- // ─────────────────────────────────────────────────────────────────────────
109
-
110
- export type {
111
- APIKeyDetail,
112
- APIKeyCreateRequest,
113
- PaginatedAPIKeyListList,
114
- };
115
-
@@ -3,36 +3,20 @@
3
3
  import React, { createContext, useContext, type ReactNode } from 'react';
4
4
  import { api } from '../../BaseClient';
5
5
  import {
6
- usePaymentsBalancesList,
7
- usePaymentsBalancesSummaryRetrieve,
6
+ usePaymentsBalanceRetrieve,
8
7
  } from '../../generated/_utils/hooks';
9
- import { getPaymentsBalancesRetrieve } from '../../generated/_utils/fetchers';
10
- import { defaultLogger } from '../../generated/logger';
11
8
  import type { API } from '../../generated';
12
- import type {
13
- UserBalance,
14
- PaginatedUserBalanceList,
15
- } from '../../generated/_utils/schemas';
16
9
 
17
10
  // ─────────────────────────────────────────────────────────────────────────
18
11
  // Context Type
19
12
  // ─────────────────────────────────────────────────────────────────────────
20
13
 
21
14
  export interface BalancesContextValue {
22
- // List
23
- balances: PaginatedUserBalanceList | undefined;
24
- isLoadingBalances: boolean;
25
- balancesError: Error | undefined;
26
- refreshBalances: () => Promise<void>;
27
-
28
- // Summary
29
- balanceSummary: UserBalance | undefined;
30
- isLoadingSummary: boolean;
31
- summaryError: Error | undefined;
32
- refreshSummary: () => Promise<void>;
33
-
34
- // Retrieve balance by ID mutation
35
- retrieveBalance: (id: number) => Promise<UserBalance | undefined>;
15
+ // Balance data - single endpoint returns balance info
16
+ balance: any | undefined;
17
+ isLoadingBalance: boolean;
18
+ balanceError: Error | undefined;
19
+ refreshBalance: () => Promise<void>;
36
20
  }
37
21
 
38
22
  // ─────────────────────────────────────────────────────────────────────────
@@ -46,51 +30,23 @@ const BalancesContext = createContext<BalancesContextValue | undefined>(undefine
46
30
  // ─────────────────────────────────────────────────────────────────────────
47
31
 
48
32
  export function BalancesProvider({ children }: { children: ReactNode }) {
49
- // List balances
50
- const {
51
- data: balances,
52
- error: balancesError,
53
- isLoading: isLoadingBalances,
54
- mutate: mutateBalances,
55
- } = usePaymentsBalancesList({}, api as unknown as API);
56
-
57
- // Balance summary
33
+ // Get balance from /cfg/payments/balance/
58
34
  const {
59
- data: balanceSummary,
60
- error: summaryError,
61
- isLoading: isLoadingSummary,
62
- mutate: mutateSummary,
63
- } = usePaymentsBalancesSummaryRetrieve(api as unknown as API);
64
-
65
- const refreshBalances = async () => {
66
- await mutateBalances();
67
- };
68
-
69
- const refreshSummary = async () => {
70
- await mutateSummary();
71
- };
72
-
73
- // Retrieve balance by ID
74
- const retrieveBalance = async (id: number): Promise<UserBalance | undefined> => {
75
- try {
76
- const result = await getPaymentsBalancesRetrieve(id, api as unknown as API);
77
- return result;
78
- } catch (error) {
79
- defaultLogger.error('Failed to retrieve balance:', error);
80
- return undefined;
81
- }
35
+ data: balance,
36
+ error: balanceError,
37
+ isLoading: isLoadingBalance,
38
+ mutate: mutateBalance,
39
+ } = usePaymentsBalanceRetrieve(api as unknown as API);
40
+
41
+ const refreshBalance = async () => {
42
+ await mutateBalance();
82
43
  };
83
44
 
84
45
  const value: BalancesContextValue = {
85
- balances,
86
- isLoadingBalances,
87
- balancesError,
88
- refreshBalances,
89
- balanceSummary,
90
- isLoadingSummary,
91
- summaryError,
92
- refreshSummary,
93
- retrieveBalance,
46
+ balance,
47
+ isLoadingBalance,
48
+ balanceError,
49
+ refreshBalance,
94
50
  };
95
51
 
96
52
  return <BalancesContext.Provider value={value}>{children}</BalancesContext.Provider>;
@@ -107,12 +63,3 @@ export function useBalancesContext(): BalancesContextValue {
107
63
  }
108
64
  return context;
109
65
  }
110
-
111
- // ─────────────────────────────────────────────────────────────────────────
112
- // Re-export types
113
- // ─────────────────────────────────────────────────────────────────────────
114
-
115
- export type {
116
- UserBalance,
117
- PaginatedUserBalanceList,
118
- };
@@ -3,21 +3,17 @@
3
3
  import React, { createContext, useContext, type ReactNode } from 'react';
4
4
  import { api } from '../../BaseClient';
5
5
  import {
6
- usePaymentsCurrenciesList,
6
+ usePaymentsCurrenciesRetrieve,
7
7
  } from '../../generated/_utils/hooks';
8
8
  import type { API } from '../../generated';
9
- import type {
10
- Currency,
11
- PaginatedCurrencyListList,
12
- } from '../../generated/_utils/schemas';
13
9
 
14
10
  // ─────────────────────────────────────────────────────────────────────────
15
11
  // Context Type
16
12
  // ─────────────────────────────────────────────────────────────────────────
17
13
 
18
14
  export interface CurrenciesContextValue {
19
- // List
20
- currencies: PaginatedCurrencyListList | undefined;
15
+ // Currencies data - returns raw response with currencies array
16
+ currencies: any | undefined;
21
17
  isLoadingCurrencies: boolean;
22
18
  currenciesError: Error | undefined;
23
19
  refreshCurrencies: () => Promise<void>;
@@ -34,13 +30,13 @@ const CurrenciesContext = createContext<CurrenciesContextValue | undefined>(unde
34
30
  // ─────────────────────────────────────────────────────────────────────────
35
31
 
36
32
  export function CurrenciesProvider({ children }: { children: ReactNode }) {
37
- // List currencies
33
+ // Get currencies list from /cfg/payments/currencies/
38
34
  const {
39
35
  data: currencies,
40
36
  error: currenciesError,
41
37
  isLoading: isLoadingCurrencies,
42
38
  mutate: mutateCurrencies,
43
- } = usePaymentsCurrenciesList({}, api as unknown as API);
39
+ } = usePaymentsCurrenciesRetrieve(api as unknown as API);
44
40
 
45
41
  const refreshCurrencies = async () => {
46
42
  await mutateCurrencies();
@@ -68,12 +64,3 @@ export function useCurrenciesContext(): CurrenciesContextValue {
68
64
  return context;
69
65
  }
70
66
 
71
- // ─────────────────────────────────────────────────────────────────────────
72
- // Re-export types
73
- // ─────────────────────────────────────────────────────────────────────────
74
-
75
- export type {
76
- Currency,
77
- PaginatedCurrencyListList,
78
- };
79
-
@@ -4,34 +4,15 @@ import React, { createContext, useContext, type ReactNode } from 'react';
4
4
  import { SWRConfig } from 'swr';
5
5
  import { api } from '../../BaseClient';
6
6
  import {
7
- usePaymentsOverviewDashboardOverviewRetrieve,
8
- usePaymentsOverviewDashboardMetricsRetrieve,
9
- usePaymentsOverviewDashboardBalanceOverviewRetrieve,
10
- usePaymentsOverviewDashboardApiKeysOverviewRetrieve,
11
- usePaymentsOverviewDashboardChartDataRetrieve,
12
- usePaymentsOverviewDashboardRecentPaymentsList,
13
- usePaymentsOverviewDashboardRecentTransactionsList,
14
- usePaymentsOverviewDashboardSubscriptionOverviewRetrieve,
15
- usePaymentsBalancesList,
16
- usePaymentsBalancesSummaryRetrieve,
17
- useCreatePaymentsPaymentCreate,
7
+ usePaymentsBalanceRetrieve,
8
+ usePaymentsPaymentsList,
9
+ usePaymentsTransactionsRetrieve,
10
+ useCreatePaymentsPaymentsCreateCreate,
18
11
  } from '../../generated/_utils/hooks';
19
- import { getPaymentsBalancesRetrieve } from '../../generated/_utils/fetchers';
20
- import { defaultLogger } from '../../generated/logger';
21
12
  import type { API } from '../../generated';
22
13
  import type {
23
- PaymentsDashboardOverview,
24
- PaymentsMetrics,
25
- BalanceOverview,
26
- APIKeysOverview,
27
- PaymentsChartResponse,
28
- PaginatedRecentPaymentList,
29
- PaginatedRecentTransactionList,
30
- SubscriptionOverview,
31
- UserBalance,
32
- PaginatedUserBalanceList,
33
- PaymentCreate,
34
- PaymentCreateRequest,
14
+ PaginatedPaymentListList,
15
+ PaymentList,
35
16
  } from '../../generated/_utils/schemas';
36
17
 
37
18
  // ─────────────────────────────────────────────────────────────────────────
@@ -39,29 +20,26 @@ import type {
39
20
  // ─────────────────────────────────────────────────────────────────────────
40
21
 
41
22
  export interface OverviewContextValue {
42
- // Dashboard data
43
- overview: PaymentsDashboardOverview | undefined;
44
- metrics: PaymentsMetrics | undefined;
45
- balanceOverview: BalanceOverview | undefined;
46
- apiKeysOverview: APIKeysOverview | undefined;
47
- subscriptionOverview: SubscriptionOverview | undefined;
48
- chartData: PaymentsChartResponse | undefined;
49
- recentPayments: PaginatedRecentPaymentList | undefined;
50
- recentTransactions: PaginatedRecentTransactionList | undefined;
51
-
52
- // Balances data (from BalancesContext)
53
- balances: PaginatedUserBalanceList | undefined;
54
- isLoadingBalances: boolean;
55
- balancesError: Error | undefined;
56
- refreshBalances: () => Promise<void>;
57
- balanceSummary: UserBalance | undefined;
58
- isLoadingSummary: boolean;
59
- summaryError: Error | undefined;
60
- refreshSummary: () => Promise<void>;
61
- retrieveBalance: (id: number) => Promise<UserBalance | undefined>;
62
-
63
- // Payment operations (from PaymentsContext)
64
- createPayment: (data: PaymentCreateRequest) => Promise<PaymentCreate>;
23
+ // Balance data
24
+ balance: any | undefined;
25
+ isLoadingBalance: boolean;
26
+ balanceError: Error | undefined;
27
+ refreshBalance: () => Promise<void>;
28
+
29
+ // Payments data
30
+ payments: PaginatedPaymentListList | undefined;
31
+ isLoadingPayments: boolean;
32
+ paymentsError: Error | undefined;
33
+ refreshPayments: () => Promise<void>;
34
+
35
+ // Transactions data
36
+ transactions: any | undefined;
37
+ isLoadingTransactions: boolean;
38
+ transactionsError: Error | undefined;
39
+ refreshTransactions: () => Promise<void>;
40
+
41
+ // Payment operations
42
+ createPayment: () => Promise<PaymentList>;
65
43
 
66
44
  // Loading states
67
45
  isLoadingOverview: boolean;
@@ -89,93 +67,77 @@ export function OverviewProvider({ children }: { children: ReactNode }) {
89
67
  revalidateIfStale: false,
90
68
  };
91
69
 
92
- // Dashboard overview
93
- const { data: overview, error: overviewError, isLoading: isLoadingOverview1, mutate: mutateOverview } = usePaymentsOverviewDashboardOverviewRetrieve(api as unknown as API);
94
- const { data: metrics, mutate: mutateMetrics } = usePaymentsOverviewDashboardMetricsRetrieve(api as unknown as API);
95
- const { data: balanceOverview, mutate: mutateBalanceOverview } = usePaymentsOverviewDashboardBalanceOverviewRetrieve(api as unknown as API);
96
- const { data: apiKeysOverview, mutate: mutateApiKeysOverview } = usePaymentsOverviewDashboardApiKeysOverviewRetrieve(api as unknown as API);
97
- const { data: subscriptionOverview, mutate: mutateSubscriptionOverview } = usePaymentsOverviewDashboardSubscriptionOverviewRetrieve(api as unknown as API);
98
- const { data: chartData, mutate: mutateChartData } = usePaymentsOverviewDashboardChartDataRetrieve({}, api as unknown as API);
99
- const { data: recentPayments, mutate: mutateRecentPayments } = usePaymentsOverviewDashboardRecentPaymentsList({}, api as unknown as API);
100
- const { data: recentTransactions, mutate: mutateRecentTransactions } = usePaymentsOverviewDashboardRecentTransactionsList({}, api as unknown as API);
101
-
102
- // Balances data
70
+ // Balance
103
71
  const {
104
- data: balances,
105
- error: balancesError,
106
- isLoading: isLoadingBalances,
107
- mutate: mutateBalances,
108
- } = usePaymentsBalancesList({}, api as unknown as API);
72
+ data: balance,
73
+ error: balanceError,
74
+ isLoading: isLoadingBalance,
75
+ mutate: mutateBalance,
76
+ } = usePaymentsBalanceRetrieve(api as unknown as API);
109
77
 
78
+ // Payments list
110
79
  const {
111
- data: balanceSummary,
112
- error: summaryError,
113
- isLoading: isLoadingSummary,
114
- mutate: mutateSummary,
115
- } = usePaymentsBalancesSummaryRetrieve(api as unknown as API);
80
+ data: payments,
81
+ error: paymentsError,
82
+ isLoading: isLoadingPayments,
83
+ mutate: mutatePayments,
84
+ } = usePaymentsPaymentsList({}, api as unknown as API);
85
+
86
+ // Transactions
87
+ const {
88
+ data: transactions,
89
+ error: transactionsError,
90
+ isLoading: isLoadingTransactions,
91
+ mutate: mutateTransactions,
92
+ } = usePaymentsTransactionsRetrieve(api as unknown as API);
116
93
 
117
94
  // Payment mutations
118
- const createPaymentMutation = useCreatePaymentsPaymentCreate();
95
+ const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
119
96
 
120
- const isLoadingOverview = isLoadingOverview1;
97
+ const isLoadingOverview = isLoadingBalance || isLoadingPayments || isLoadingTransactions;
98
+ const overviewError = balanceError || paymentsError || transactionsError;
121
99
 
122
- const refreshOverview = async () => {
123
- await Promise.all([
124
- mutateOverview(),
125
- mutateMetrics(),
126
- mutateBalanceOverview(),
127
- mutateApiKeysOverview(),
128
- mutateSubscriptionOverview(),
129
- mutateChartData(),
130
- mutateRecentPayments(),
131
- mutateRecentTransactions(),
132
- ]);
100
+ const refreshBalance = async () => {
101
+ await mutateBalance();
133
102
  };
134
103
 
135
- const refreshBalances = async () => {
136
- await mutateBalances();
104
+ const refreshPayments = async () => {
105
+ await mutatePayments();
137
106
  };
138
107
 
139
- const refreshSummary = async () => {
140
- await mutateSummary();
108
+ const refreshTransactions = async () => {
109
+ await mutateTransactions();
141
110
  };
142
111
 
143
- const retrieveBalance = async (id: number): Promise<UserBalance | undefined> => {
144
- try {
145
- const result = await getPaymentsBalancesRetrieve(id, api as unknown as API);
146
- return result;
147
- } catch (error) {
148
- defaultLogger.error('Failed to retrieve balance:', error);
149
- return undefined;
150
- }
112
+ const refreshOverview = async () => {
113
+ await Promise.all([
114
+ mutateBalance(),
115
+ mutatePayments(),
116
+ mutateTransactions(),
117
+ ]);
151
118
  };
152
119
 
153
120
  // Create payment
154
- const createPayment = async (data: PaymentCreateRequest): Promise<PaymentCreate> => {
155
- const result = await createPaymentMutation(data, api as unknown as API);
121
+ const createPayment = async (): Promise<PaymentList> => {
122
+ const result = await createPaymentMutation(api as unknown as API);
156
123
  // Refresh overview data to show new payment
157
124
  await refreshOverview();
158
- return result as PaymentCreate;
125
+ return result as PaymentList;
159
126
  };
160
127
 
161
128
  const value: OverviewContextValue = {
162
- overview,
163
- metrics,
164
- balanceOverview,
165
- apiKeysOverview,
166
- subscriptionOverview,
167
- chartData,
168
- recentPayments,
169
- recentTransactions,
170
- balances,
171
- isLoadingBalances,
172
- balancesError,
173
- refreshBalances,
174
- balanceSummary,
175
- isLoadingSummary,
176
- summaryError,
177
- refreshSummary,
178
- retrieveBalance,
129
+ balance,
130
+ isLoadingBalance,
131
+ balanceError,
132
+ refreshBalance,
133
+ payments,
134
+ isLoadingPayments,
135
+ paymentsError,
136
+ refreshPayments,
137
+ transactions,
138
+ isLoadingTransactions,
139
+ transactionsError,
140
+ refreshTransactions,
179
141
  createPayment,
180
142
  isLoadingOverview,
181
143
  overviewError,
@@ -206,15 +168,7 @@ export function useOverviewContext(): OverviewContextValue {
206
168
  // ─────────────────────────────────────────────────────────────────────────
207
169
 
208
170
  export type {
209
- PaymentsDashboardOverview,
210
- PaymentsMetrics,
211
- BalanceOverview,
212
- APIKeysOverview,
213
- SubscriptionOverview,
214
- PaymentsChartResponse,
215
- PaginatedRecentPaymentList,
216
- PaginatedRecentTransactionList,
217
- UserBalance,
218
- PaginatedUserBalanceList,
171
+ PaginatedPaymentListList,
172
+ PaymentList,
219
173
  };
220
174