@djangocfg/api 1.0.1 → 1.0.3
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 +17641 -8457
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14654 -5066
- package/dist/index.d.ts +14654 -5066
- package/dist/index.mjs +17885 -8728
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
- package/src/cfg/contexts/payments/ApiKeysContext.tsx +2 -2
- package/src/cfg/contexts/payments/CurrenciesContext.tsx +0 -26
- package/src/cfg/contexts/payments/OverviewContext.tsx +79 -0
- package/src/cfg/contexts/payments/RootPaymentsContext.tsx +137 -0
- package/src/cfg/contexts/payments/index.ts +13 -0
- package/src/cfg/generated/_utils/fetchers/cfg__accounts.ts +2 -2
- package/src/cfg/generated/_utils/fetchers/cfg__accounts__auth.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__accounts__user_profile.ts +6 -6
- package/src/cfg/generated/_utils/fetchers/cfg__endpoints.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__health.ts +2 -2
- package/src/cfg/generated/_utils/fetchers/cfg__knowbase.ts +876 -0
- package/src/cfg/generated/_utils/fetchers/cfg__leads.ts +6 -6
- package/src/cfg/generated/_utils/fetchers/cfg__leads__lead_submission.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter.ts +3 -3
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__bulk_email.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__campaigns.ts +6 -6
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__logs.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__newsletters.ts +2 -2
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__subscriptions.ts +3 -3
- package/src/cfg/generated/_utils/fetchers/cfg__newsletter__testing.ts +1 -1
- package/src/cfg/generated/_utils/fetchers/cfg__payments.ts +181 -179
- package/src/cfg/generated/_utils/fetchers/cfg__payments__webhooks.ts +5 -5
- package/src/cfg/generated/_utils/fetchers/cfg__support.ts +12 -12
- package/src/cfg/generated/_utils/fetchers/cfg__tasks.ts +10 -10
- package/src/cfg/generated/_utils/fetchers/index.ts +1 -0
- package/src/cfg/generated/_utils/hooks/cfg__knowbase.ts +997 -0
- package/src/cfg/generated/_utils/hooks/cfg__payments.ts +12 -10
- package/src/cfg/generated/_utils/hooks/index.ts +1 -0
- package/src/cfg/generated/_utils/schemas/APIKeyValidationResponse.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/AdminPaymentDetail.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/AdminPaymentList.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ArchiveItem.schema.ts +33 -0
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunk.schema.ts +29 -0
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkDetail.schema.ts +30 -0
- package/src/cfg/generated/_utils/schemas/ArchiveItemChunkRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/ArchiveItemDetail.schema.ts +35 -0
- package/src/cfg/generated/_utils/schemas/ArchiveItemRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/ArchiveProcessingResult.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/ArchiveSearchRequestRequest.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/ArchiveSearchResult.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/ArchiveStatistics.schema.ts +28 -0
- package/src/cfg/generated/_utils/schemas/ChatHistory.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/ChatMessage.schema.ts +27 -0
- package/src/cfg/generated/_utils/schemas/ChatQueryRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/ChatResponse.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/ChatResponseRequest.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/ChatSession.schema.ts +29 -0
- package/src/cfg/generated/_utils/schemas/ChatSessionCreateRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/ChatSessionRequest.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/ChatSource.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/ChatSourceRequest.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/ChunkRevectorizationRequestRequest.schema.ts +20 -0
- package/src/cfg/generated/_utils/schemas/CurrencyList.schema.ts +2 -0
- package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/Document.schema.ts +32 -0
- package/src/cfg/generated/_utils/schemas/DocumentArchive.schema.ts +44 -0
- package/src/cfg/generated/_utils/schemas/DocumentArchiveDetail.schema.ts +48 -0
- package/src/cfg/generated/_utils/schemas/DocumentArchiveList.schema.ts +35 -0
- package/src/cfg/generated/_utils/schemas/DocumentArchiveRequest.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/DocumentCategory.schema.ts +23 -0
- package/src/cfg/generated/_utils/schemas/DocumentCategoryRequest.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/DocumentCreateRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/DocumentProcessingStatus.schema.ts +23 -0
- package/src/cfg/generated/_utils/schemas/DocumentRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/DocumentStats.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/Network.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PaginatedArchiveItemChunkList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedArchiveItemList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedArchiveSearchResultList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedChatResponseList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedChatSessionList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedDocumentArchiveListList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedDocumentList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedPublicCategoryList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PaginatedPublicDocumentListList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemChunkRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/PatchedArchiveItemRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/PatchedChatResponseRequest.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/PatchedChatSessionRequest.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/PatchedDocumentArchiveRequest.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/PatchedDocumentRequest.schema.ts +22 -0
- package/src/cfg/generated/_utils/schemas/Payment.schema.ts +1 -0
- package/src/cfg/generated/_utils/schemas/PaymentCreate.schema.ts +0 -1
- package/src/cfg/generated/_utils/schemas/PaymentCreateRequest.schema.ts +0 -1
- package/src/cfg/generated/_utils/schemas/PaymentsMetrics.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/ProviderCurrency.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/PublicCategory.schema.ts +21 -0
- package/src/cfg/generated/_utils/schemas/PublicDocument.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/PublicDocumentList.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/SupportedCurrencies.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/VectorizationResult.schema.ts +24 -0
- package/src/cfg/generated/_utils/schemas/VectorizationStatistics.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/index.ts +54 -0
- package/src/cfg/generated/cfg__accounts/client.ts +1 -1
- package/src/cfg/generated/cfg__accounts__auth/client.ts +1 -1
- package/src/cfg/generated/cfg__accounts__user_profile/client.ts +1 -1
- package/src/cfg/generated/cfg__endpoints/client.ts +1 -1
- package/src/cfg/generated/cfg__health/client.ts +1 -1
- package/src/cfg/generated/cfg__knowbase/client.ts +666 -0
- package/src/cfg/generated/cfg__knowbase/index.ts +2 -0
- package/src/cfg/generated/cfg__knowbase/models.ts +1120 -0
- package/src/cfg/generated/cfg__leads/client.ts +1 -1
- package/src/cfg/generated/cfg__leads__lead_submission/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__bulk_email/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__campaigns/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__logs/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__newsletters/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__subscriptions/client.ts +1 -1
- package/src/cfg/generated/cfg__newsletter__testing/client.ts +1 -1
- package/src/cfg/generated/cfg__payments/client.ts +25 -45
- package/src/cfg/generated/cfg__payments/models.ts +46 -12
- package/src/cfg/generated/cfg__payments__webhooks/client.ts +1 -1
- package/src/cfg/generated/cfg__support/client.ts +1 -1
- package/src/cfg/generated/cfg__tasks/client.ts +1 -1
- package/src/cfg/generated/client.ts +57 -54
- package/src/cfg/generated/enums.ts +269 -16
- package/src/cfg/generated/index.ts +82 -29
- package/src/cfg/generated/schema.ts +10238 -4386
- package/src/index.ts +23 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "DjangoCFG",
|
|
6
6
|
"url": "https://djangocfg.com"
|
|
@@ -18,29 +18,29 @@
|
|
|
18
18
|
"require": "./dist/index.cjs"
|
|
19
19
|
},
|
|
20
20
|
"./cfg/contexts": {
|
|
21
|
-
"types": "./
|
|
22
|
-
"import": "./
|
|
23
|
-
"
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs"
|
|
24
24
|
},
|
|
25
25
|
"./cfg/generated": {
|
|
26
|
-
"types": "./
|
|
27
|
-
"import": "./
|
|
28
|
-
"
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs",
|
|
28
|
+
"require": "./dist/index.cjs"
|
|
29
29
|
},
|
|
30
30
|
"./cfg/generated/hooks": {
|
|
31
|
-
"types": "./
|
|
32
|
-
"import": "./
|
|
33
|
-
"
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.mjs",
|
|
33
|
+
"require": "./dist/index.cjs"
|
|
34
34
|
},
|
|
35
35
|
"./cfg/generated/fetchers": {
|
|
36
|
-
"types": "./
|
|
37
|
-
"import": "./
|
|
38
|
-
"
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.mjs",
|
|
38
|
+
"require": "./dist/index.cjs"
|
|
39
39
|
},
|
|
40
40
|
"./cfg/generated/schemas": {
|
|
41
|
-
"types": "./
|
|
42
|
-
"import": "./
|
|
43
|
-
"
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.mjs",
|
|
43
|
+
"require": "./dist/index.cjs"
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
@@ -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.3",
|
|
72
72
|
"react": "^19.1.0",
|
|
73
73
|
"react-dom": "^19.1.0",
|
|
74
74
|
"tsup": "^8.5.0",
|
|
@@ -5,7 +5,7 @@ import { api } from '../../BaseClient';
|
|
|
5
5
|
import {
|
|
6
6
|
usePaymentsApiKeysList,
|
|
7
7
|
usePaymentsApiKeysRetrieve,
|
|
8
|
-
|
|
8
|
+
useCreatePaymentsApiKeysCreateCreate,
|
|
9
9
|
useDeletePaymentsApiKeysDestroy,
|
|
10
10
|
} from '../../generated/_utils/hooks';
|
|
11
11
|
import type { API } from '../../generated';
|
|
@@ -56,7 +56,7 @@ export function ApiKeysProvider({ children }: { children: ReactNode }) {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
// Mutations
|
|
59
|
-
const createApiKeyMutation =
|
|
59
|
+
const createApiKeyMutation = useCreatePaymentsApiKeysCreateCreate();
|
|
60
60
|
const deleteApiKeyMutation = useDeletePaymentsApiKeysDestroy();
|
|
61
61
|
|
|
62
62
|
// Get API key
|
|
@@ -4,8 +4,6 @@ import React, { createContext, useContext, type ReactNode } from 'react';
|
|
|
4
4
|
import { api } from '../../BaseClient';
|
|
5
5
|
import {
|
|
6
6
|
usePaymentsCurrenciesList,
|
|
7
|
-
usePaymentsCurrenciesRetrieve,
|
|
8
|
-
usePaymentsCurrenciesRatesRetrieve,
|
|
9
7
|
} from '../../generated/_utils/hooks';
|
|
10
8
|
import type { API } from '../../generated';
|
|
11
9
|
import type {
|
|
@@ -23,10 +21,6 @@ export interface CurrenciesContextValue {
|
|
|
23
21
|
isLoadingCurrencies: boolean;
|
|
24
22
|
currenciesError: Error | undefined;
|
|
25
23
|
refreshCurrencies: () => Promise<void>;
|
|
26
|
-
|
|
27
|
-
// Operations
|
|
28
|
-
getCurrency: (id: number) => Promise<Currency | undefined>;
|
|
29
|
-
getCurrencyRates: (baseCurrency: string, currencies: string) => Promise<Currency | undefined>;
|
|
30
24
|
}
|
|
31
25
|
|
|
32
26
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -52,31 +46,11 @@ export function CurrenciesProvider({ children }: { children: ReactNode }) {
|
|
|
52
46
|
await mutateCurrencies();
|
|
53
47
|
};
|
|
54
48
|
|
|
55
|
-
// Get currency
|
|
56
|
-
const getCurrency = async (id: number): Promise<Currency | undefined> => {
|
|
57
|
-
const { data } = usePaymentsCurrenciesRetrieve(id, api as unknown as API);
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
// Get currency rates
|
|
62
|
-
const getCurrencyRates = async (
|
|
63
|
-
baseCurrency: string,
|
|
64
|
-
currencies: string
|
|
65
|
-
): Promise<Currency | undefined> => {
|
|
66
|
-
const { data } = usePaymentsCurrenciesRatesRetrieve(
|
|
67
|
-
{ base_currency: baseCurrency, currencies },
|
|
68
|
-
api as unknown as API
|
|
69
|
-
);
|
|
70
|
-
return data;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
49
|
const value: CurrenciesContextValue = {
|
|
74
50
|
currencies,
|
|
75
51
|
isLoadingCurrencies,
|
|
76
52
|
currenciesError,
|
|
77
53
|
refreshCurrencies,
|
|
78
|
-
getCurrency,
|
|
79
|
-
getCurrencyRates,
|
|
80
54
|
};
|
|
81
55
|
|
|
82
56
|
return <CurrenciesContext.Provider value={value}>{children}</CurrenciesContext.Provider>;
|
|
@@ -12,7 +12,12 @@ import {
|
|
|
12
12
|
usePaymentsOverviewDashboardRecentPaymentsList,
|
|
13
13
|
usePaymentsOverviewDashboardRecentTransactionsList,
|
|
14
14
|
usePaymentsOverviewDashboardSubscriptionOverviewRetrieve,
|
|
15
|
+
usePaymentsBalancesList,
|
|
16
|
+
usePaymentsBalancesSummaryRetrieve,
|
|
17
|
+
useCreatePaymentsPaymentCreate,
|
|
15
18
|
} from '../../generated/_utils/hooks';
|
|
19
|
+
import { getPaymentsBalancesRetrieve } from '../../generated/_utils/fetchers';
|
|
20
|
+
import { defaultLogger } from '../../generated/logger';
|
|
16
21
|
import type { API } from '../../generated';
|
|
17
22
|
import type {
|
|
18
23
|
PaymentsDashboardOverview,
|
|
@@ -23,6 +28,10 @@ import type {
|
|
|
23
28
|
PaginatedRecentPaymentList,
|
|
24
29
|
PaginatedRecentTransactionList,
|
|
25
30
|
SubscriptionOverview,
|
|
31
|
+
UserBalance,
|
|
32
|
+
PaginatedUserBalanceList,
|
|
33
|
+
PaymentCreate,
|
|
34
|
+
PaymentCreateRequest,
|
|
26
35
|
} from '../../generated/_utils/schemas';
|
|
27
36
|
|
|
28
37
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -40,6 +49,20 @@ export interface OverviewContextValue {
|
|
|
40
49
|
recentPayments: PaginatedRecentPaymentList | undefined;
|
|
41
50
|
recentTransactions: PaginatedRecentTransactionList | undefined;
|
|
42
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>;
|
|
65
|
+
|
|
43
66
|
// Loading states
|
|
44
67
|
isLoadingOverview: boolean;
|
|
45
68
|
overviewError: Error | undefined;
|
|
@@ -76,6 +99,24 @@ export function OverviewProvider({ children }: { children: ReactNode }) {
|
|
|
76
99
|
const { data: recentPayments, mutate: mutateRecentPayments } = usePaymentsOverviewDashboardRecentPaymentsList({}, api as unknown as API);
|
|
77
100
|
const { data: recentTransactions, mutate: mutateRecentTransactions } = usePaymentsOverviewDashboardRecentTransactionsList({}, api as unknown as API);
|
|
78
101
|
|
|
102
|
+
// Balances data
|
|
103
|
+
const {
|
|
104
|
+
data: balances,
|
|
105
|
+
error: balancesError,
|
|
106
|
+
isLoading: isLoadingBalances,
|
|
107
|
+
mutate: mutateBalances,
|
|
108
|
+
} = usePaymentsBalancesList({}, api as unknown as API);
|
|
109
|
+
|
|
110
|
+
const {
|
|
111
|
+
data: balanceSummary,
|
|
112
|
+
error: summaryError,
|
|
113
|
+
isLoading: isLoadingSummary,
|
|
114
|
+
mutate: mutateSummary,
|
|
115
|
+
} = usePaymentsBalancesSummaryRetrieve(api as unknown as API);
|
|
116
|
+
|
|
117
|
+
// Payment mutations
|
|
118
|
+
const createPaymentMutation = useCreatePaymentsPaymentCreate();
|
|
119
|
+
|
|
79
120
|
const isLoadingOverview = isLoadingOverview1;
|
|
80
121
|
|
|
81
122
|
const refreshOverview = async () => {
|
|
@@ -91,6 +132,32 @@ export function OverviewProvider({ children }: { children: ReactNode }) {
|
|
|
91
132
|
]);
|
|
92
133
|
};
|
|
93
134
|
|
|
135
|
+
const refreshBalances = async () => {
|
|
136
|
+
await mutateBalances();
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const refreshSummary = async () => {
|
|
140
|
+
await mutateSummary();
|
|
141
|
+
};
|
|
142
|
+
|
|
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
|
+
}
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Create payment
|
|
154
|
+
const createPayment = async (data: PaymentCreateRequest): Promise<PaymentCreate> => {
|
|
155
|
+
const result = await createPaymentMutation(data, api as unknown as API);
|
|
156
|
+
// Refresh overview data to show new payment
|
|
157
|
+
await refreshOverview();
|
|
158
|
+
return result as PaymentCreate;
|
|
159
|
+
};
|
|
160
|
+
|
|
94
161
|
const value: OverviewContextValue = {
|
|
95
162
|
overview,
|
|
96
163
|
metrics,
|
|
@@ -100,6 +167,16 @@ export function OverviewProvider({ children }: { children: ReactNode }) {
|
|
|
100
167
|
chartData,
|
|
101
168
|
recentPayments,
|
|
102
169
|
recentTransactions,
|
|
170
|
+
balances,
|
|
171
|
+
isLoadingBalances,
|
|
172
|
+
balancesError,
|
|
173
|
+
refreshBalances,
|
|
174
|
+
balanceSummary,
|
|
175
|
+
isLoadingSummary,
|
|
176
|
+
summaryError,
|
|
177
|
+
refreshSummary,
|
|
178
|
+
retrieveBalance,
|
|
179
|
+
createPayment,
|
|
103
180
|
isLoadingOverview,
|
|
104
181
|
overviewError,
|
|
105
182
|
refreshOverview,
|
|
@@ -137,5 +214,7 @@ export type {
|
|
|
137
214
|
PaymentsChartResponse,
|
|
138
215
|
PaginatedRecentPaymentList,
|
|
139
216
|
PaginatedRecentTransactionList,
|
|
217
|
+
UserBalance,
|
|
218
|
+
PaginatedUserBalanceList,
|
|
140
219
|
};
|
|
141
220
|
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import React, { createContext, useContext, useEffect, type ReactNode } from 'react';
|
|
4
|
+
import { api } from '../../BaseClient';
|
|
5
|
+
import {
|
|
6
|
+
usePaymentsCurrenciesList,
|
|
7
|
+
usePaymentsCurrenciesSupportedRetrieve,
|
|
8
|
+
usePaymentsProviderCurrenciesList,
|
|
9
|
+
usePaymentsProviderCurrenciesByProviderRetrieve,
|
|
10
|
+
usePaymentsProviderCurrenciesLimitsRetrieve,
|
|
11
|
+
usePaymentsNetworksList,
|
|
12
|
+
} from '../../generated/_utils/hooks';
|
|
13
|
+
import type { API } from '../../generated';
|
|
14
|
+
import type {
|
|
15
|
+
Currency,
|
|
16
|
+
PaginatedCurrencyListList,
|
|
17
|
+
ProviderCurrency,
|
|
18
|
+
PaginatedProviderCurrencyList,
|
|
19
|
+
Network,
|
|
20
|
+
PaginatedNetworkList,
|
|
21
|
+
} from '../../generated/_utils/schemas';
|
|
22
|
+
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
24
|
+
// Context Type
|
|
25
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
26
|
+
|
|
27
|
+
export interface RootPaymentsContextValue {
|
|
28
|
+
// Currencies
|
|
29
|
+
currencies: PaginatedCurrencyListList | undefined;
|
|
30
|
+
isLoadingCurrencies: boolean;
|
|
31
|
+
currenciesError: Error | undefined;
|
|
32
|
+
refreshCurrencies: () => Promise<void>;
|
|
33
|
+
|
|
34
|
+
// Provider Currencies
|
|
35
|
+
providerCurrencies: PaginatedProviderCurrencyList | undefined;
|
|
36
|
+
isLoadingProviderCurrencies: boolean;
|
|
37
|
+
providerCurrenciesError: Error | undefined;
|
|
38
|
+
refreshProviderCurrencies: () => Promise<void>;
|
|
39
|
+
|
|
40
|
+
// Networks
|
|
41
|
+
networks: PaginatedNetworkList | undefined;
|
|
42
|
+
isLoadingNetworks: boolean;
|
|
43
|
+
networksError: Error | undefined;
|
|
44
|
+
refreshNetworks: () => Promise<void>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
48
|
+
// Context
|
|
49
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
const RootPaymentsContext = createContext<RootPaymentsContextValue | undefined>(undefined);
|
|
52
|
+
|
|
53
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
54
|
+
// Provider
|
|
55
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
export function RootPaymentsProvider({ children }: { children: ReactNode }) {
|
|
58
|
+
// List all currencies
|
|
59
|
+
const {
|
|
60
|
+
data: currencies,
|
|
61
|
+
error: currenciesError,
|
|
62
|
+
isLoading: isLoadingCurrencies,
|
|
63
|
+
mutate: mutateCurrencies,
|
|
64
|
+
} = usePaymentsCurrenciesList({ page_size: 1000 }, api as unknown as API);
|
|
65
|
+
|
|
66
|
+
// List all provider currencies
|
|
67
|
+
const {
|
|
68
|
+
data: providerCurrencies,
|
|
69
|
+
error: providerCurrenciesError,
|
|
70
|
+
isLoading: isLoadingProviderCurrencies,
|
|
71
|
+
mutate: mutateProviderCurrencies,
|
|
72
|
+
} = usePaymentsProviderCurrenciesList({ page_size: 1000 }, api as unknown as API);
|
|
73
|
+
|
|
74
|
+
// List all networks
|
|
75
|
+
const {
|
|
76
|
+
data: networks,
|
|
77
|
+
error: networksError,
|
|
78
|
+
isLoading: isLoadingNetworks,
|
|
79
|
+
mutate: mutateNetworks,
|
|
80
|
+
} = usePaymentsNetworksList({ page_size: 1000 }, api as unknown as API);
|
|
81
|
+
|
|
82
|
+
const refreshCurrencies = async () => {
|
|
83
|
+
await mutateCurrencies();
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const refreshProviderCurrencies = async () => {
|
|
87
|
+
await mutateProviderCurrencies();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const refreshNetworks = async () => {
|
|
91
|
+
await mutateNetworks();
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const value: RootPaymentsContextValue = {
|
|
95
|
+
currencies,
|
|
96
|
+
isLoadingCurrencies,
|
|
97
|
+
currenciesError,
|
|
98
|
+
refreshCurrencies,
|
|
99
|
+
providerCurrencies,
|
|
100
|
+
isLoadingProviderCurrencies,
|
|
101
|
+
providerCurrenciesError,
|
|
102
|
+
refreshProviderCurrencies,
|
|
103
|
+
networks,
|
|
104
|
+
isLoadingNetworks,
|
|
105
|
+
networksError,
|
|
106
|
+
refreshNetworks,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<RootPaymentsContext.Provider value={value}>{children}</RootPaymentsContext.Provider>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
115
|
+
// Hook
|
|
116
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
117
|
+
|
|
118
|
+
export function useRootPaymentsContext(): RootPaymentsContextValue {
|
|
119
|
+
const context = useContext(RootPaymentsContext);
|
|
120
|
+
if (!context) {
|
|
121
|
+
throw new Error('useRootPaymentsContext must be used within RootPaymentsProvider');
|
|
122
|
+
}
|
|
123
|
+
return context;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
127
|
+
// Re-export types
|
|
128
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
129
|
+
|
|
130
|
+
export type {
|
|
131
|
+
Currency,
|
|
132
|
+
PaginatedCurrencyListList,
|
|
133
|
+
ProviderCurrency,
|
|
134
|
+
PaginatedProviderCurrencyList,
|
|
135
|
+
Network,
|
|
136
|
+
PaginatedNetworkList,
|
|
137
|
+
};
|
|
@@ -63,3 +63,16 @@ export type {
|
|
|
63
63
|
PaginatedRecentTransactionList,
|
|
64
64
|
} from './OverviewContext';
|
|
65
65
|
|
|
66
|
+
// Root Payments (Global)
|
|
67
|
+
export {
|
|
68
|
+
RootPaymentsProvider,
|
|
69
|
+
useRootPaymentsContext
|
|
70
|
+
} from './RootPaymentsContext';
|
|
71
|
+
export type {
|
|
72
|
+
RootPaymentsContextValue,
|
|
73
|
+
ProviderCurrency,
|
|
74
|
+
PaginatedProviderCurrencyList,
|
|
75
|
+
Network,
|
|
76
|
+
PaginatedNetworkList,
|
|
77
|
+
} from './RootPaymentsContext';
|
|
78
|
+
|
|
@@ -42,7 +42,7 @@ import type { API } from '../../index'
|
|
|
42
42
|
* @method POST
|
|
43
43
|
* @path /cfg/accounts/otp/request/
|
|
44
44
|
*/
|
|
45
|
-
export async function createAccountsOtpRequestCreate( data: OTPRequestRequest, client
|
|
45
|
+
export async function createAccountsOtpRequestCreate( data: OTPRequestRequest, client?
|
|
46
46
|
): Promise<OTPRequestResponse> {
|
|
47
47
|
const api = client || getAPIInstance()
|
|
48
48
|
const response = await api.cfg_accounts.otpRequestCreate(data)
|
|
@@ -56,7 +56,7 @@ export async function createAccountsOtpRequestCreate( data: OTPRequestRequest,
|
|
|
56
56
|
* @method POST
|
|
57
57
|
* @path /cfg/accounts/otp/verify/
|
|
58
58
|
*/
|
|
59
|
-
export async function createAccountsOtpVerifyCreate( data: OTPVerifyRequest, client
|
|
59
|
+
export async function createAccountsOtpVerifyCreate( data: OTPVerifyRequest, client?
|
|
60
60
|
): Promise<OTPVerifyResponse> {
|
|
61
61
|
const api = client || getAPIInstance()
|
|
62
62
|
const response = await api.cfg_accounts.otpVerifyCreate(data)
|
|
@@ -40,7 +40,7 @@ import type { API } from '../../index'
|
|
|
40
40
|
* @method POST
|
|
41
41
|
* @path /cfg/accounts/token/refresh/
|
|
42
42
|
*/
|
|
43
|
-
export async function createAccountsTokenRefreshCreate( data: TokenRefreshRequest, client
|
|
43
|
+
export async function createAccountsTokenRefreshCreate( data: TokenRefreshRequest, client?
|
|
44
44
|
): Promise<TokenRefresh> {
|
|
45
45
|
const api = client || getAPIInstance()
|
|
46
46
|
const response = await api.cfg_auth.accountsTokenRefreshCreate(data)
|
|
@@ -41,7 +41,7 @@ import type { API } from '../../index'
|
|
|
41
41
|
* @method GET
|
|
42
42
|
* @path /cfg/accounts/profile/
|
|
43
43
|
*/
|
|
44
|
-
export async function getAccountsProfileRetrieve( client
|
|
44
|
+
export async function getAccountsProfileRetrieve( client?
|
|
45
45
|
): Promise<User> {
|
|
46
46
|
const api = client || getAPIInstance()
|
|
47
47
|
const response = await api.cfg_user_profile.accountsProfileRetrieve()
|
|
@@ -55,7 +55,7 @@ export async function getAccountsProfileRetrieve( client?: API
|
|
|
55
55
|
* @method POST
|
|
56
56
|
* @path /cfg/accounts/profile/avatar/
|
|
57
57
|
*/
|
|
58
|
-
export async function createAccountsProfileAvatarCreate( data: any, client
|
|
58
|
+
export async function createAccountsProfileAvatarCreate( data: any, client?
|
|
59
59
|
): Promise<User> {
|
|
60
60
|
const api = client || getAPIInstance()
|
|
61
61
|
const response = await api.cfg_user_profile.accountsProfileAvatarCreate(data)
|
|
@@ -69,7 +69,7 @@ export async function createAccountsProfileAvatarCreate( data: any, client?: A
|
|
|
69
69
|
* @method PUT
|
|
70
70
|
* @path /cfg/accounts/profile/partial/
|
|
71
71
|
*/
|
|
72
|
-
export async function partialUpdateAccountsProfilePartialUpdate( data: UserProfileUpdateRequest, client
|
|
72
|
+
export async function partialUpdateAccountsProfilePartialUpdate( data: UserProfileUpdateRequest, client?
|
|
73
73
|
): Promise<User> {
|
|
74
74
|
const api = client || getAPIInstance()
|
|
75
75
|
const response = await api.cfg_user_profile.accountsProfilePartialUpdate(data)
|
|
@@ -83,7 +83,7 @@ export async function partialUpdateAccountsProfilePartialUpdate( data: UserProf
|
|
|
83
83
|
* @method PATCH
|
|
84
84
|
* @path /cfg/accounts/profile/partial/
|
|
85
85
|
*/
|
|
86
|
-
export async function partialUpdateAccountsProfilePartialPartialUpdate( data?: PatchedUserProfileUpdateRequest, client
|
|
86
|
+
export async function partialUpdateAccountsProfilePartialPartialUpdate( data?: PatchedUserProfileUpdateRequest, client?
|
|
87
87
|
): Promise<User> {
|
|
88
88
|
const api = client || getAPIInstance()
|
|
89
89
|
const response = await api.cfg_user_profile.accountsProfilePartialPartialUpdate(data)
|
|
@@ -97,7 +97,7 @@ export async function partialUpdateAccountsProfilePartialPartialUpdate( data?:
|
|
|
97
97
|
* @method PUT
|
|
98
98
|
* @path /cfg/accounts/profile/update/
|
|
99
99
|
*/
|
|
100
|
-
export async function updateAccountsProfileUpdateUpdate( data: UserProfileUpdateRequest, client
|
|
100
|
+
export async function updateAccountsProfileUpdateUpdate( data: UserProfileUpdateRequest, client?
|
|
101
101
|
): Promise<User> {
|
|
102
102
|
const api = client || getAPIInstance()
|
|
103
103
|
const response = await api.cfg_user_profile.accountsProfileUpdateUpdate(data)
|
|
@@ -111,7 +111,7 @@ export async function updateAccountsProfileUpdateUpdate( data: UserProfileUpdat
|
|
|
111
111
|
* @method PATCH
|
|
112
112
|
* @path /cfg/accounts/profile/update/
|
|
113
113
|
*/
|
|
114
|
-
export async function partialUpdateAccountsProfileUpdatePartialUpdate( data?: PatchedUserProfileUpdateRequest, client
|
|
114
|
+
export async function partialUpdateAccountsProfileUpdatePartialUpdate( data?: PatchedUserProfileUpdateRequest, client?
|
|
115
115
|
): Promise<User> {
|
|
116
116
|
const api = client || getAPIInstance()
|
|
117
117
|
const response = await api.cfg_user_profile.accountsProfileUpdatePartialUpdate(data)
|
|
@@ -39,7 +39,7 @@ import type { API } from '../../index'
|
|
|
39
39
|
* @method GET
|
|
40
40
|
* @path /cfg/endpoints/drf/
|
|
41
41
|
*/
|
|
42
|
-
export async function getEndpointsDrfRetrieve( client
|
|
42
|
+
export async function getEndpointsDrfRetrieve( client?
|
|
43
43
|
): Promise<EndpointsStatus> {
|
|
44
44
|
const api = client || getAPIInstance()
|
|
45
45
|
const response = await api.cfg_endpoints.drfRetrieve()
|
|
@@ -40,7 +40,7 @@ import type { API } from '../../index'
|
|
|
40
40
|
* @method GET
|
|
41
41
|
* @path /cfg/health/drf/
|
|
42
42
|
*/
|
|
43
|
-
export async function getHealthDrfRetrieve( client
|
|
43
|
+
export async function getHealthDrfRetrieve( client?
|
|
44
44
|
): Promise<HealthCheck> {
|
|
45
45
|
const api = client || getAPIInstance()
|
|
46
46
|
const response = await api.cfg_health.drfRetrieve()
|
|
@@ -54,7 +54,7 @@ export async function getHealthDrfRetrieve( client?: API
|
|
|
54
54
|
* @method GET
|
|
55
55
|
* @path /cfg/health/drf/quick/
|
|
56
56
|
*/
|
|
57
|
-
export async function getHealthDrfQuickRetrieve( client
|
|
57
|
+
export async function getHealthDrfQuickRetrieve( client?
|
|
58
58
|
): Promise<QuickHealth> {
|
|
59
59
|
const api = client || getAPIInstance()
|
|
60
60
|
const response = await api.cfg_health.drfQuickRetrieve()
|