@djangocfg/api 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +15856 -34128
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15274 -34396
- package/dist/index.d.ts +15274 -34396
- package/dist/index.mjs +15853 -33956
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/cfg/contexts/payments/ApiKeysContext.tsx +21 -58
- package/src/cfg/contexts/payments/BalancesContext.tsx +19 -72
- package/src/cfg/contexts/payments/CurrenciesContext.tsx +5 -18
- package/src/cfg/contexts/payments/OverviewContext.tsx +78 -124
- package/src/cfg/contexts/payments/PaymentsContext.tsx +37 -36
- package/src/cfg/contexts/payments/RootPaymentsContext.tsx +7 -76
- package/src/cfg/contexts/payments/index.ts +5 -24
- package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +38 -2380
- package/src/cfg/generated/_utils/fetchers/index.ts +0 -1
- package/src/cfg/generated/_utils/hooks/cfg__payments.ts +41 -2615
- package/src/cfg/generated/_utils/hooks/index.ts +0 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItem.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunk.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkDetail.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemDetail.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItemRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ChatMessage.schema.ts +2 -2
- package/src/cfg/generated/_utils/schemas/ChatSession.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/ChatSessionRequest.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/Document.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/DocumentRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemChunkRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PatchedChatSessionRequest.schema.ts +3 -3
- package/src/cfg/generated/_utils/schemas/PatchedDocumentRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PaymentDetail.schema.ts +44 -0
- package/src/cfg/generated/_utils/schemas/PaymentList.schema.ts +7 -11
- package/src/cfg/generated/_utils/schemas/index.ts +1 -81
- package/src/cfg/generated/cfg__payments/client.ts +40 -1732
- package/src/cfg/generated/cfg__payments/models.ts +50 -1795
- package/src/cfg/generated/client.ts +0 -3
- package/src/cfg/generated/enums.ts +5 -347
- package/src/cfg/generated/index.ts +0 -5
- package/src/cfg/generated/schema.ts +5918 -18352
- package/src/cfg/services/payments/ApiKeysService.ts +34 -116
- package/src/cfg/services/payments/DashboardService.ts +37 -122
- package/src/cfg/services/payments/PaymentsService.ts +36 -69
- package/src/cfg/services/payments/SubscriptionsService.ts +35 -136
- package/src/cfg/services/webhooks/WebhooksService.ts +24 -66
- package/src/index.ts +1 -6
- package/src/cfg/generated/_utils/fetchers/cfg__payments__webhooks.ts +0 -109
- package/src/cfg/generated/_utils/hooks/cfg__payments__webhooks.ts +0 -100
- package/src/cfg/generated/_utils/schemas/APIKeyCreate.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyCreateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyDetail.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/APIKeyList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/APIKeyUpdate.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyUpdateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/APIKeyValidationRequest.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/APIKeysOverview.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/AdminPaymentCreate.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/AdminPaymentCreateRequest.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +0 -50
- package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +0 -38
- package/src/cfg/generated/_utils/schemas/AdminPaymentStats.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/AdminPaymentUpdate.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/AdminPaymentUpdateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/AdminUser.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/BalanceOverview.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/ChartDataPoint.schema.ts +0 -20
- package/src/cfg/generated/_utils/schemas/ChartSeries.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/Currency.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/CurrencyAnalyticsItem.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/EndpointGroup.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/Network.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PaginatedAPIKeyListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminPaymentStatsList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedAdminUserList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedCurrencyListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedEndpointGroupList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedNetworkList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedProviderCurrencyList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedRecentPaymentList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedRecentTransactionList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedSubscriptionListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedTariffList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedTransactionList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedUserBalanceList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedWebhookEventListList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaginatedWebhookStatsList.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PatchedAPIKeyUpdateRequest.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PatchedAdminPaymentUpdateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/PatchedPaymentRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PatchedSubscriptionRequest.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/Payment.schema.ts +0 -49
- package/src/cfg/generated/_utils/schemas/PaymentAnalyticsResponse.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +0 -28
- package/src/cfg/generated/_utils/schemas/PaymentOverview.schema.ts +0 -31
- package/src/cfg/generated/_utils/schemas/PaymentRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/PaymentsChartResponse.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/PaymentsDashboardOverview.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/ProviderAnalyticsItem.schema.ts +0 -24
- package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +0 -36
- package/src/cfg/generated/_utils/schemas/RecentPayment.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/RecentTransaction.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/Subscription.schema.ts +0 -41
- package/src/cfg/generated/_utils/schemas/SubscriptionCreate.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SubscriptionCreateRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SubscriptionList.schema.ts +0 -32
- package/src/cfg/generated/_utils/schemas/SubscriptionOverview.schema.ts +0 -37
- package/src/cfg/generated/_utils/schemas/SubscriptionRequest.schema.ts +0 -26
- package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/SupportedProviders.schema.ts +0 -22
- package/src/cfg/generated/_utils/schemas/Tariff.schema.ts +0 -34
- package/src/cfg/generated/_utils/schemas/Transaction.schema.ts +0 -35
- package/src/cfg/generated/_utils/schemas/UserBalance.schema.ts +0 -29
- package/src/cfg/generated/_utils/schemas/WebhookEvent.schema.ts +0 -31
- package/src/cfg/generated/_utils/schemas/WebhookEventList.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/WebhookEventListRequest.schema.ts +0 -25
- package/src/cfg/generated/_utils/schemas/WebhookEventRequest.schema.ts +0 -30
- package/src/cfg/generated/_utils/schemas/WebhookHealth.schema.ts +0 -21
- package/src/cfg/generated/_utils/schemas/WebhookProviderStats.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/WebhookProviderStatsRequest.schema.ts +0 -23
- package/src/cfg/generated/_utils/schemas/WebhookResponse.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookResponseRequest.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookStats.schema.ts +0 -27
- package/src/cfg/generated/_utils/schemas/WebhookStatsRequest.schema.ts +0 -27
- package/src/cfg/generated/cfg__payments__webhooks/client.ts +0 -75
- package/src/cfg/generated/cfg__payments__webhooks/index.ts +0 -2
- 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
|
+
"version": "1.0.6",
|
|
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.
|
|
71
|
+
"@djangocfg/typescript-config": "^1.0.6",
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
//
|
|
24
|
-
apiKeys:
|
|
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
|
-
//
|
|
30
|
-
getApiKey: (id: string) => Promise<
|
|
31
|
-
createApiKey: (data:
|
|
32
|
-
deleteApiKey: (id: string) => Promise<
|
|
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
|
-
|
|
39
|
+
// No-op - feature deprecated
|
|
56
40
|
};
|
|
57
41
|
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
//
|
|
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:
|
|
60
|
-
error:
|
|
61
|
-
isLoading:
|
|
62
|
-
mutate:
|
|
63
|
-
} =
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
await
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
20
|
-
currencies:
|
|
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
|
-
//
|
|
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
|
-
} =
|
|
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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
//
|
|
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:
|
|
105
|
-
error:
|
|
106
|
-
isLoading:
|
|
107
|
-
mutate:
|
|
108
|
-
} =
|
|
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:
|
|
112
|
-
error:
|
|
113
|
-
isLoading:
|
|
114
|
-
mutate:
|
|
115
|
-
} =
|
|
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 =
|
|
95
|
+
const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
|
|
119
96
|
|
|
120
|
-
const isLoadingOverview =
|
|
97
|
+
const isLoadingOverview = isLoadingBalance || isLoadingPayments || isLoadingTransactions;
|
|
98
|
+
const overviewError = balanceError || paymentsError || transactionsError;
|
|
121
99
|
|
|
122
|
-
const
|
|
123
|
-
await
|
|
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
|
|
136
|
-
await
|
|
104
|
+
const refreshPayments = async () => {
|
|
105
|
+
await mutatePayments();
|
|
137
106
|
};
|
|
138
107
|
|
|
139
|
-
const
|
|
140
|
-
await
|
|
108
|
+
const refreshTransactions = async () => {
|
|
109
|
+
await mutateTransactions();
|
|
141
110
|
};
|
|
142
111
|
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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 (
|
|
155
|
-
const result = await createPaymentMutation(
|
|
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
|
|
125
|
+
return result as PaymentList;
|
|
159
126
|
};
|
|
160
127
|
|
|
161
128
|
const value: OverviewContextValue = {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
BalanceOverview,
|
|
212
|
-
APIKeysOverview,
|
|
213
|
-
SubscriptionOverview,
|
|
214
|
-
PaymentsChartResponse,
|
|
215
|
-
PaginatedRecentPaymentList,
|
|
216
|
-
PaginatedRecentTransactionList,
|
|
217
|
-
UserBalance,
|
|
218
|
-
PaginatedUserBalanceList,
|
|
171
|
+
PaginatedPaymentListList,
|
|
172
|
+
PaymentList,
|
|
219
173
|
};
|
|
220
174
|
|