@djangocfg/api 1.0.2 → 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 +1572 -2035
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +299 -144
- package/dist/index.d.ts +299 -144
- package/dist/index.mjs +1570 -1744
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- 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__payments.ts +12 -10
- package/src/cfg/generated/_utils/hooks/cfg__payments.ts +12 -10
- 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/CurrencyList.schema.ts +2 -0
- package/src/cfg/generated/_utils/schemas/CurrencyRates.schema.ts +26 -0
- package/src/cfg/generated/_utils/schemas/DocumentCreateRequest.schema.ts +1 -1
- package/src/cfg/generated/_utils/schemas/Network.schema.ts +1 -1
- 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/SupportedCurrencies.schema.ts +25 -0
- package/src/cfg/generated/_utils/schemas/index.ts +2 -0
- package/src/cfg/generated/cfg__payments/client.ts +24 -44
- package/src/cfg/generated/cfg__payments/models.ts +46 -12
- package/src/cfg/generated/enums.ts +34 -22
- package/src/cfg/generated/index.ts +2 -3
- package/src/cfg/generated/schema.ts +90 -74
- package/src/index.ts +20 -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"
|
|
@@ -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
|
+
|
|
@@ -46,6 +46,7 @@ import { AdminPaymentUpdateRequestSchema, type AdminPaymentUpdateRequest } from
|
|
|
46
46
|
import { AdminUserSchema, type AdminUser } from '../schemas/AdminUser.schema'
|
|
47
47
|
import { BalanceOverviewSchema, type BalanceOverview } from '../schemas/BalanceOverview.schema'
|
|
48
48
|
import { CurrencySchema, type Currency } from '../schemas/Currency.schema'
|
|
49
|
+
import { CurrencyRatesSchema, type CurrencyRates } from '../schemas/CurrencyRates.schema'
|
|
49
50
|
import { EndpointGroupSchema, type EndpointGroup } from '../schemas/EndpointGroup.schema'
|
|
50
51
|
import { NetworkSchema, type Network } from '../schemas/Network.schema'
|
|
51
52
|
import { PaginatedAPIKeyListListSchema, type PaginatedAPIKeyListList } from '../schemas/PaginatedAPIKeyListList.schema'
|
|
@@ -83,6 +84,7 @@ import { SubscriptionCreateSchema, type SubscriptionCreate } from '../schemas/Su
|
|
|
83
84
|
import { SubscriptionCreateRequestSchema, type SubscriptionCreateRequest } from '../schemas/SubscriptionCreateRequest.schema'
|
|
84
85
|
import { SubscriptionOverviewSchema, type SubscriptionOverview } from '../schemas/SubscriptionOverview.schema'
|
|
85
86
|
import { SubscriptionRequestSchema, type SubscriptionRequest } from '../schemas/SubscriptionRequest.schema'
|
|
87
|
+
import { SupportedCurrenciesSchema, type SupportedCurrencies } from '../schemas/SupportedCurrencies.schema'
|
|
86
88
|
import { TariffSchema, type Tariff } from '../schemas/Tariff.schema'
|
|
87
89
|
import { TransactionSchema, type Transaction } from '../schemas/Transaction.schema'
|
|
88
90
|
import { UserBalanceSchema, type UserBalance } from '../schemas/UserBalance.schema'
|
|
@@ -878,16 +880,16 @@ export async function getPaymentsCurrenciesHealthRetrieve( client?
|
|
|
878
880
|
|
|
879
881
|
|
|
880
882
|
/**
|
|
881
|
-
*
|
|
883
|
+
* API operation
|
|
882
884
|
*
|
|
883
885
|
* @method GET
|
|
884
886
|
* @path /cfg/payments/currencies/rates/
|
|
885
887
|
*/
|
|
886
|
-
export async function getPaymentsCurrenciesRatesRetrieve(
|
|
887
|
-
): Promise<
|
|
888
|
+
export async function getPaymentsCurrenciesRatesRetrieve( client?
|
|
889
|
+
): Promise<CurrencyRates> {
|
|
888
890
|
const api = client || getAPIInstance()
|
|
889
|
-
const response = await api.cfg_payments.currenciesRatesRetrieve(
|
|
890
|
-
return
|
|
891
|
+
const response = await api.cfg_payments.currenciesRatesRetrieve()
|
|
892
|
+
return CurrencyRatesSchema.parse(response)
|
|
891
893
|
}
|
|
892
894
|
|
|
893
895
|
|
|
@@ -920,16 +922,16 @@ export async function getPaymentsCurrenciesStatsRetrieve( client?
|
|
|
920
922
|
|
|
921
923
|
|
|
922
924
|
/**
|
|
923
|
-
*
|
|
925
|
+
* API operation
|
|
924
926
|
*
|
|
925
927
|
* @method GET
|
|
926
928
|
* @path /cfg/payments/currencies/supported/
|
|
927
929
|
*/
|
|
928
|
-
export async function getPaymentsCurrenciesSupportedRetrieve(
|
|
929
|
-
): Promise<
|
|
930
|
+
export async function getPaymentsCurrenciesSupportedRetrieve( client?
|
|
931
|
+
): Promise<SupportedCurrencies> {
|
|
930
932
|
const api = client || getAPIInstance()
|
|
931
|
-
const response = await api.cfg_payments.currenciesSupportedRetrieve(
|
|
932
|
-
return
|
|
933
|
+
const response = await api.cfg_payments.currenciesSupportedRetrieve()
|
|
934
|
+
return SupportedCurrenciesSchema.parse(response)
|
|
933
935
|
}
|
|
934
936
|
|
|
935
937
|
|
|
@@ -35,6 +35,7 @@ import type { AdminPaymentUpdateRequest } from '../schemas/AdminPaymentUpdateReq
|
|
|
35
35
|
import type { AdminUser } from '../schemas/AdminUser.schema'
|
|
36
36
|
import type { BalanceOverview } from '../schemas/BalanceOverview.schema'
|
|
37
37
|
import type { Currency } from '../schemas/Currency.schema'
|
|
38
|
+
import type { CurrencyRates } from '../schemas/CurrencyRates.schema'
|
|
38
39
|
import type { EndpointGroup } from '../schemas/EndpointGroup.schema'
|
|
39
40
|
import type { Network } from '../schemas/Network.schema'
|
|
40
41
|
import type { PaginatedAPIKeyListList } from '../schemas/PaginatedAPIKeyListList.schema'
|
|
@@ -72,6 +73,7 @@ import type { SubscriptionCreate } from '../schemas/SubscriptionCreate.schema'
|
|
|
72
73
|
import type { SubscriptionCreateRequest } from '../schemas/SubscriptionCreateRequest.schema'
|
|
73
74
|
import type { SubscriptionOverview } from '../schemas/SubscriptionOverview.schema'
|
|
74
75
|
import type { SubscriptionRequest } from '../schemas/SubscriptionRequest.schema'
|
|
76
|
+
import type { SupportedCurrencies } from '../schemas/SupportedCurrencies.schema'
|
|
75
77
|
import type { Tariff } from '../schemas/Tariff.schema'
|
|
76
78
|
import type { Transaction } from '../schemas/Transaction.schema'
|
|
77
79
|
import type { UserBalance } from '../schemas/UserBalance.schema'
|
|
@@ -953,15 +955,15 @@ export function usePaymentsCurrenciesHealthRetrieve(client?: API): ReturnType<ty
|
|
|
953
955
|
|
|
954
956
|
|
|
955
957
|
/**
|
|
956
|
-
*
|
|
958
|
+
* API operation
|
|
957
959
|
*
|
|
958
960
|
* @method GET
|
|
959
961
|
* @path /cfg/payments/currencies/rates/
|
|
960
962
|
*/
|
|
961
|
-
export function usePaymentsCurrenciesRatesRetrieve(
|
|
962
|
-
return useSWR<
|
|
963
|
-
|
|
964
|
-
() => Fetchers.getPaymentsCurrenciesRatesRetrieve(
|
|
963
|
+
export function usePaymentsCurrenciesRatesRetrieve(client?: API): ReturnType<typeof useSWR<CurrencyRates>> {
|
|
964
|
+
return useSWR<CurrencyRates>(
|
|
965
|
+
'cfg-payments-currencies-rate',
|
|
966
|
+
() => Fetchers.getPaymentsCurrenciesRatesRetrieve(client)
|
|
965
967
|
)
|
|
966
968
|
}
|
|
967
969
|
|
|
@@ -995,15 +997,15 @@ export function usePaymentsCurrenciesStatsRetrieve(client?: API): ReturnType<typ
|
|
|
995
997
|
|
|
996
998
|
|
|
997
999
|
/**
|
|
998
|
-
*
|
|
1000
|
+
* API operation
|
|
999
1001
|
*
|
|
1000
1002
|
* @method GET
|
|
1001
1003
|
* @path /cfg/payments/currencies/supported/
|
|
1002
1004
|
*/
|
|
1003
|
-
export function usePaymentsCurrenciesSupportedRetrieve(
|
|
1004
|
-
return useSWR<
|
|
1005
|
-
|
|
1006
|
-
() => Fetchers.getPaymentsCurrenciesSupportedRetrieve(
|
|
1005
|
+
export function usePaymentsCurrenciesSupportedRetrieve(client?: API): ReturnType<typeof useSWR<SupportedCurrencies>> {
|
|
1006
|
+
return useSWR<SupportedCurrencies>(
|
|
1007
|
+
'cfg-payments-currencies-supported',
|
|
1008
|
+
() => Fetchers.getPaymentsCurrenciesSupportedRetrieve(client)
|
|
1007
1009
|
)
|
|
1008
1010
|
}
|
|
1009
1011
|
|
|
@@ -17,7 +17,7 @@ Defines the structure of API key validation response for OpenAPI schema.
|
|
|
17
17
|
export const APIKeyValidationResponseSchema = z.object({
|
|
18
18
|
success: z.boolean(),
|
|
19
19
|
valid: z.boolean(),
|
|
20
|
-
api_key: APIKeyDetailSchema,
|
|
20
|
+
api_key: APIKeyDetailSchema.nullable(),
|
|
21
21
|
message: z.string(),
|
|
22
22
|
error: z.string().optional(),
|
|
23
23
|
error_code: z.string().optional(),
|
|
@@ -25,7 +25,7 @@ export const AdminPaymentDetailSchema = z.object({
|
|
|
25
25
|
provider_display: z.string(),
|
|
26
26
|
status: z.string(),
|
|
27
27
|
status_display: z.string(),
|
|
28
|
-
pay_amount: z.string()
|
|
28
|
+
pay_amount: z.string(),
|
|
29
29
|
pay_address: z.string(),
|
|
30
30
|
payment_url: z.url(),
|
|
31
31
|
transaction_hash: z.string(),
|
|
@@ -23,7 +23,7 @@ export const AdminPaymentListSchema = z.object({
|
|
|
23
23
|
provider_display: z.string(),
|
|
24
24
|
status: z.string(),
|
|
25
25
|
status_display: z.string(),
|
|
26
|
-
pay_amount: z.string()
|
|
26
|
+
pay_amount: z.string(),
|
|
27
27
|
pay_address: z.string(),
|
|
28
28
|
transaction_hash: z.string(),
|
|
29
29
|
created_at: z.iso.datetime(),
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for CurrencyRates
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Currency rates serializer for getting exchange rates.
|
|
6
|
+
|
|
7
|
+
Fetches current exchange rates through CurrencyService.
|
|
8
|
+
* */
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
import * as Enums from '../../enums'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Currency rates serializer for getting exchange rates.
|
|
14
|
+
|
|
15
|
+
Fetches current exchange rates through CurrencyService.
|
|
16
|
+
*/
|
|
17
|
+
export const CurrencyRatesSchema = z.object({
|
|
18
|
+
base_currency: z.string().max(10).optional(),
|
|
19
|
+
currencies: z.array(z.string().max(10)).optional(),
|
|
20
|
+
provider: z.nativeEnum(Enums.CurrencyRatesProvider).optional(),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Infer TypeScript type from Zod schema
|
|
25
|
+
*/
|
|
26
|
+
export type CurrencyRates = z.infer<typeof CurrencyRatesSchema>
|
|
@@ -12,7 +12,7 @@ import { z } from 'zod'
|
|
|
12
12
|
export const DocumentCreateRequestSchema = z.object({
|
|
13
13
|
title: z.string().min(1).max(512),
|
|
14
14
|
content: z.string().min(10).max(1000000),
|
|
15
|
-
file_type: z.string().min(1).
|
|
15
|
+
file_type: z.string().min(1).optional(),
|
|
16
16
|
metadata: z.string().optional(),
|
|
17
17
|
})
|
|
18
18
|
|
|
@@ -18,6 +18,7 @@ export const PaymentSchema = z.object({
|
|
|
18
18
|
id: z.uuid(),
|
|
19
19
|
user: z.string(),
|
|
20
20
|
amount_usd: z.number().min(1.0).max(50000.0),
|
|
21
|
+
amount_crypto: z.number(),
|
|
21
22
|
currency: z.int(),
|
|
22
23
|
network: z.int().nullable().optional(),
|
|
23
24
|
provider: z.nativeEnum(Enums.PaymentProvider).optional(),
|
|
@@ -17,7 +17,6 @@ Validates input and delegates to PaymentService.
|
|
|
17
17
|
export const PaymentCreateSchema = z.object({
|
|
18
18
|
amount_usd: z.number().min(1.0).max(50000.0),
|
|
19
19
|
currency_code: z.nativeEnum(Enums.PaymentCreateCurrencyCode),
|
|
20
|
-
provider: z.nativeEnum(Enums.PaymentCreateProvider).optional(),
|
|
21
20
|
callback_url: z.url().optional(),
|
|
22
21
|
cancel_url: z.url().optional(),
|
|
23
22
|
description: z.string().max(500).optional(),
|
|
@@ -17,7 +17,6 @@ Validates input and delegates to PaymentService.
|
|
|
17
17
|
export const PaymentCreateRequestSchema = z.object({
|
|
18
18
|
amount_usd: z.number().min(1.0).max(50000.0),
|
|
19
19
|
currency_code: z.nativeEnum(Enums.PaymentCreateRequestCurrencyCode),
|
|
20
|
-
provider: z.nativeEnum(Enums.PaymentCreateRequestProvider).optional(),
|
|
21
20
|
callback_url: z.url().optional(),
|
|
22
21
|
cancel_url: z.url().optional(),
|
|
23
22
|
description: z.string().max(500).optional(),
|
|
@@ -15,7 +15,7 @@ import { SubscriptionOverviewSchema } from './SubscriptionOverview.schema'
|
|
|
15
15
|
*/
|
|
16
16
|
export const PaymentsMetricsSchema = z.object({
|
|
17
17
|
balance: BalanceOverviewSchema,
|
|
18
|
-
subscription: SubscriptionOverviewSchema,
|
|
18
|
+
subscription: SubscriptionOverviewSchema.nullable(),
|
|
19
19
|
api_keys: APIKeysOverviewSchema,
|
|
20
20
|
payments: PaymentOverviewSchema,
|
|
21
21
|
})
|
|
@@ -18,7 +18,7 @@ Used for provider currency management and rates.
|
|
|
18
18
|
export const ProviderCurrencySchema = z.object({
|
|
19
19
|
id: z.int(),
|
|
20
20
|
currency: CurrencyListSchema,
|
|
21
|
-
network: NetworkSchema,
|
|
21
|
+
network: NetworkSchema.nullable(),
|
|
22
22
|
provider: z.string(),
|
|
23
23
|
provider_currency_code: z.string(),
|
|
24
24
|
provider_min_amount_usd: z.number(),
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for SupportedCurrencies
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Supported currencies serializer for provider capabilities.
|
|
6
|
+
|
|
7
|
+
Gets supported currencies from providers through CurrencyService.
|
|
8
|
+
* */
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
import * as Enums from '../../enums'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Supported currencies serializer for provider capabilities.
|
|
14
|
+
|
|
15
|
+
Gets supported currencies from providers through CurrencyService.
|
|
16
|
+
*/
|
|
17
|
+
export const SupportedCurrenciesSchema = z.object({
|
|
18
|
+
provider: z.nativeEnum(Enums.SupportedCurrenciesProvider).optional(),
|
|
19
|
+
currency_type: z.nativeEnum(Enums.SupportedCurrenciesCurrencyType).optional(),
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Infer TypeScript type from Zod schema
|
|
24
|
+
*/
|
|
25
|
+
export type SupportedCurrencies = z.infer<typeof SupportedCurrenciesSchema>
|
|
@@ -64,6 +64,7 @@ export * from './ChunkRevectorizationRequestRequest.schema'
|
|
|
64
64
|
export * from './Currency.schema'
|
|
65
65
|
export * from './CurrencyAnalyticsItem.schema'
|
|
66
66
|
export * from './CurrencyList.schema'
|
|
67
|
+
export * from './CurrencyRates.schema'
|
|
67
68
|
export * from './Document.schema'
|
|
68
69
|
export * from './DocumentArchive.schema'
|
|
69
70
|
export * from './DocumentArchiveDetail.schema'
|
|
@@ -181,6 +182,7 @@ export * from './SubscriptionList.schema'
|
|
|
181
182
|
export * from './SubscriptionOverview.schema'
|
|
182
183
|
export * from './SubscriptionRequest.schema'
|
|
183
184
|
export * from './SuccessResponse.schema'
|
|
185
|
+
export * from './SupportedCurrencies.schema'
|
|
184
186
|
export * from './SupportedProviders.schema'
|
|
185
187
|
export * from './Tariff.schema'
|
|
186
188
|
export * from './TaskStatistics.schema'
|