@djangocfg/ext-payments 1.0.0
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/README.md +206 -0
- package/dist/chunk-5KY6HVXF.js +2593 -0
- package/dist/hooks.cjs +2666 -0
- package/dist/hooks.d.cts +186 -0
- package/dist/hooks.d.ts +186 -0
- package/dist/hooks.js +1 -0
- package/dist/index.cjs +2590 -0
- package/dist/index.d.cts +1287 -0
- package/dist/index.d.ts +1287 -0
- package/dist/index.js +1 -0
- package/package.json +79 -0
- package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +408 -0
- package/src/api/generated/ext_payments/_utils/fetchers/index.ts +28 -0
- package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +147 -0
- package/src/api/generated/ext_payments/_utils/hooks/index.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +23 -0
- package/src/api/generated/ext_payments/_utils/schemas/Currency.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaginatedPaymentListList.schema.ts +24 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +44 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +28 -0
- package/src/api/generated/ext_payments/_utils/schemas/index.ts +24 -0
- package/src/api/generated/ext_payments/api-instance.ts +131 -0
- package/src/api/generated/ext_payments/client.ts +301 -0
- package/src/api/generated/ext_payments/enums.ts +64 -0
- package/src/api/generated/ext_payments/errors.ts +116 -0
- package/src/api/generated/ext_payments/ext_payments__payments/client.ts +118 -0
- package/src/api/generated/ext_payments/ext_payments__payments/index.ts +2 -0
- package/src/api/generated/ext_payments/ext_payments__payments/models.ts +135 -0
- package/src/api/generated/ext_payments/http.ts +103 -0
- package/src/api/generated/ext_payments/index.ts +273 -0
- package/src/api/generated/ext_payments/logger.ts +259 -0
- package/src/api/generated/ext_payments/retry.ts +175 -0
- package/src/api/generated/ext_payments/schema.json +850 -0
- package/src/api/generated/ext_payments/storage.ts +161 -0
- package/src/api/generated/ext_payments/validation-events.ts +133 -0
- package/src/api/index.ts +9 -0
- package/src/config.ts +20 -0
- package/src/contexts/BalancesContext.tsx +62 -0
- package/src/contexts/CurrenciesContext.tsx +63 -0
- package/src/contexts/OverviewContext.tsx +173 -0
- package/src/contexts/PaymentsContext.tsx +121 -0
- package/src/contexts/PaymentsExtensionProvider.tsx +55 -0
- package/src/contexts/README.md +201 -0
- package/src/contexts/RootPaymentsContext.tsx +65 -0
- package/src/contexts/index.ts +45 -0
- package/src/contexts/types.ts +40 -0
- package/src/hooks/index.ts +20 -0
- package/src/index.ts +36 -0
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +92 -0
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +291 -0
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +290 -0
- package/src/layouts/PaymentsLayout/components/index.ts +2 -0
- package/src/layouts/PaymentsLayout/events.ts +47 -0
- package/src/layouts/PaymentsLayout/index.ts +16 -0
- package/src/layouts/PaymentsLayout/types.ts +6 -0
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +128 -0
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +142 -0
- package/src/layouts/PaymentsLayout/views/overview/components/index.ts +2 -0
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +20 -0
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +277 -0
- package/src/layouts/PaymentsLayout/views/payments/components/index.ts +1 -0
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +17 -0
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +273 -0
- package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +1 -0
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +17 -0
- package/src/utils/logger.ts +9 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { API, APIClient, APIError, APILogger, BalanceSchema, CookieStorageAdapter, CurrencySchema, DEFAULT_RETRY_CONFIG, enums_exports as Enums, models_exports as ExtPaymentsPaymentsTypes, FetchAdapter, fetchers_exports as Fetchers, LocalStorageAdapter, MemoryStorageAdapter, NetworkError, PAYMENT_EVENTS, PaginatedPaymentListListSchema, PaymentDetailSchema, PaymentListSchema, PaymentsLayout, REFRESH_TOKEN_KEY, schemas_exports as Schemas, TOKEN_KEY, TransactionSchema, apiPayments, clearAPITokens, closePaymentsDialog, configureAPI, createPaymentsPaymentsConfirmCreate, createPaymentsPaymentsCreateCreate, dispatchValidationError, formatZodError, getAPIInstance, getPaymentsBalanceRetrieve, getPaymentsCurrenciesList, getPaymentsPaymentsList, getPaymentsPaymentsRetrieve, getPaymentsPaymentsStatusRetrieve, getPaymentsTransactionsList, isAPIConfigured, onValidationError, openCreatePaymentDialog, openPaymentDetailsDialog, reconfigureAPI, resetAPI, shouldRetry, withRetry } from './chunk-5KY6HVXF.js';
|
package/package.json
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@djangocfg/ext-payments",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Payments system extension for DjangoCFG",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"django",
|
|
7
|
+
"djangocfg",
|
|
8
|
+
"extension",
|
|
9
|
+
"payments",
|
|
10
|
+
"stripe",
|
|
11
|
+
"billing",
|
|
12
|
+
"subscription",
|
|
13
|
+
"typescript",
|
|
14
|
+
"react"
|
|
15
|
+
],
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "DjangoCFG",
|
|
18
|
+
"url": "https://djangocfg.com"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://djangocfg.com",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/markolofsen/django-cfg.git",
|
|
24
|
+
"directory": "extensions/payments"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/markolofsen/django-cfg/issues"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/index.cjs",
|
|
32
|
+
"module": "./dist/index.mjs",
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/index.d.ts",
|
|
37
|
+
"import": "./dist/index.mjs",
|
|
38
|
+
"require": "./dist/index.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./hooks": {
|
|
41
|
+
"types": "./dist/hooks.d.ts",
|
|
42
|
+
"import": "./dist/hooks.mjs",
|
|
43
|
+
"require": "./dist/hooks.cjs"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"files": [
|
|
47
|
+
"dist",
|
|
48
|
+
"src"
|
|
49
|
+
],
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsup",
|
|
52
|
+
"dev": "tsup --watch",
|
|
53
|
+
"check": "tsc --noEmit"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"@djangocfg/api": "^2.1.14",
|
|
57
|
+
"@djangocfg/ext-base": "^1.0.0",
|
|
58
|
+
"@djangocfg/ui-nextjs": "^2.1.14",
|
|
59
|
+
"consola": "^3.4.2",
|
|
60
|
+
"lucide-react": "^0.545.0",
|
|
61
|
+
"next": "^15.5.7",
|
|
62
|
+
"p-retry": "^7.0.0",
|
|
63
|
+
"react": "^18 || ^19",
|
|
64
|
+
"swr": "^2.3.7",
|
|
65
|
+
"zod": "^4.1.13"
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@djangocfg/api": "^2.1.14",
|
|
69
|
+
"@djangocfg/ext-base": "^1.0.0",
|
|
70
|
+
"@djangocfg/typescript-config": "^2.1.14",
|
|
71
|
+
"@types/node": "^24.7.2",
|
|
72
|
+
"@types/react": "^19.0.0",
|
|
73
|
+
"consola": "^3.4.2",
|
|
74
|
+
"p-retry": "^7.0.0",
|
|
75
|
+
"swr": "^2.3.7",
|
|
76
|
+
"tsup": "^8.5.0",
|
|
77
|
+
"typescript": "^5.9.3"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed fetchers for Payments
|
|
3
|
+
*
|
|
4
|
+
* Universal functions that work in any environment:
|
|
5
|
+
* - Next.js (App Router / Pages Router / Server Components)
|
|
6
|
+
* - React Native
|
|
7
|
+
* - Node.js backend
|
|
8
|
+
*
|
|
9
|
+
* These fetchers use Zod schemas for runtime validation.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Configure API once (in your app entry point)
|
|
14
|
+
* import { configureAPI } from '../../api-instance'
|
|
15
|
+
* configureAPI({ baseUrl: 'https://api.example.com' })
|
|
16
|
+
*
|
|
17
|
+
* // Then use fetchers anywhere
|
|
18
|
+
* const users = await getUsers({ page: 1 })
|
|
19
|
+
*
|
|
20
|
+
* // With SWR
|
|
21
|
+
* const { data } = useSWR(['users', params], () => getUsers(params))
|
|
22
|
+
*
|
|
23
|
+
* // With React Query
|
|
24
|
+
* const { data } = useQuery(['users', params], () => getUsers(params))
|
|
25
|
+
*
|
|
26
|
+
* // In Server Component or SSR (pass custom client)
|
|
27
|
+
* import { API } from '../../index'
|
|
28
|
+
* const api = new API('https://api.example.com')
|
|
29
|
+
* const users = await getUsers({ page: 1 }, api)
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
import { consola } from 'consola'
|
|
33
|
+
import { BalanceSchema, type Balance } from '../schemas/Balance.schema'
|
|
34
|
+
import { PaginatedPaymentListListSchema, type PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
|
|
35
|
+
import { PaymentDetailSchema, type PaymentDetail } from '../schemas/PaymentDetail.schema'
|
|
36
|
+
import { PaymentListSchema, type PaymentList } from '../schemas/PaymentList.schema'
|
|
37
|
+
import { getAPIInstance } from '../../api-instance'
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get user balance
|
|
41
|
+
*
|
|
42
|
+
* @method GET
|
|
43
|
+
* @path /cfg/payments/balance/
|
|
44
|
+
*/
|
|
45
|
+
export async function getPaymentsBalanceRetrieve( client?: any
|
|
46
|
+
): Promise<Balance> {
|
|
47
|
+
const api = client || getAPIInstance()
|
|
48
|
+
const response = await api.ext_payments_payments.balanceRetrieve()
|
|
49
|
+
try {
|
|
50
|
+
return BalanceSchema.parse(response)
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// Zod validation error - log detailed information
|
|
53
|
+
consola.error('❌ Zod Validation Failed');
|
|
54
|
+
consola.box(`getPaymentsBalanceRetrieve\nPath: /cfg/payments/balance/\nMethod: GET`);
|
|
55
|
+
|
|
56
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
57
|
+
consola.error('Validation Issues:');
|
|
58
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
59
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
60
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
61
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
62
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
consola.error('Response data:', response);
|
|
67
|
+
|
|
68
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
69
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
70
|
+
try {
|
|
71
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
72
|
+
detail: {
|
|
73
|
+
operation: 'getPaymentsBalanceRetrieve',
|
|
74
|
+
path: '/cfg/payments/balance/',
|
|
75
|
+
method: 'GET',
|
|
76
|
+
error: error,
|
|
77
|
+
response: response,
|
|
78
|
+
timestamp: new Date(),
|
|
79
|
+
},
|
|
80
|
+
bubbles: true,
|
|
81
|
+
cancelable: false,
|
|
82
|
+
});
|
|
83
|
+
window.dispatchEvent(event);
|
|
84
|
+
} catch (eventError) {
|
|
85
|
+
// Silently fail - event dispatch should never crash the app
|
|
86
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// Re-throw the error
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Get available currencies
|
|
98
|
+
*
|
|
99
|
+
* @method GET
|
|
100
|
+
* @path /cfg/payments/currencies/
|
|
101
|
+
*/
|
|
102
|
+
export async function getPaymentsCurrenciesList( client?: any
|
|
103
|
+
): Promise<any> {
|
|
104
|
+
const api = client || getAPIInstance()
|
|
105
|
+
const response = await api.ext_payments_payments.currenciesList()
|
|
106
|
+
return response
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* API operation
|
|
112
|
+
*
|
|
113
|
+
* @method GET
|
|
114
|
+
* @path /cfg/payments/payments/
|
|
115
|
+
*/
|
|
116
|
+
export async function getPaymentsPaymentsList( params?: { page?: number; page_size?: number }, client?: any
|
|
117
|
+
): Promise<PaginatedPaymentListList> {
|
|
118
|
+
const api = client || getAPIInstance()
|
|
119
|
+
const response = await api.ext_payments_payments.paymentsList(params?.page, params?.page_size)
|
|
120
|
+
try {
|
|
121
|
+
return PaginatedPaymentListListSchema.parse(response)
|
|
122
|
+
} catch (error) {
|
|
123
|
+
// Zod validation error - log detailed information
|
|
124
|
+
consola.error('❌ Zod Validation Failed');
|
|
125
|
+
consola.box(`getPaymentsPaymentsList\nPath: /cfg/payments/payments/\nMethod: GET`);
|
|
126
|
+
|
|
127
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
128
|
+
consola.error('Validation Issues:');
|
|
129
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
130
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
131
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
132
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
133
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
consola.error('Response data:', response);
|
|
138
|
+
|
|
139
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
140
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
141
|
+
try {
|
|
142
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
143
|
+
detail: {
|
|
144
|
+
operation: 'getPaymentsPaymentsList',
|
|
145
|
+
path: '/cfg/payments/payments/',
|
|
146
|
+
method: 'GET',
|
|
147
|
+
error: error,
|
|
148
|
+
response: response,
|
|
149
|
+
timestamp: new Date(),
|
|
150
|
+
},
|
|
151
|
+
bubbles: true,
|
|
152
|
+
cancelable: false,
|
|
153
|
+
});
|
|
154
|
+
window.dispatchEvent(event);
|
|
155
|
+
} catch (eventError) {
|
|
156
|
+
// Silently fail - event dispatch should never crash the app
|
|
157
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Re-throw the error
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* API operation
|
|
169
|
+
*
|
|
170
|
+
* @method GET
|
|
171
|
+
* @path /cfg/payments/payments/{id}/
|
|
172
|
+
*/
|
|
173
|
+
export async function getPaymentsPaymentsRetrieve( id: string, client?: any
|
|
174
|
+
): Promise<PaymentDetail> {
|
|
175
|
+
const api = client || getAPIInstance()
|
|
176
|
+
const response = await api.ext_payments_payments.paymentsRetrieve(id)
|
|
177
|
+
try {
|
|
178
|
+
return PaymentDetailSchema.parse(response)
|
|
179
|
+
} catch (error) {
|
|
180
|
+
// Zod validation error - log detailed information
|
|
181
|
+
consola.error('❌ Zod Validation Failed');
|
|
182
|
+
consola.box(`getPaymentsPaymentsRetrieve\nPath: /cfg/payments/payments/{id}/\nMethod: GET`);
|
|
183
|
+
|
|
184
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
185
|
+
consola.error('Validation Issues:');
|
|
186
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
187
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
188
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
189
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
190
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
consola.error('Response data:', response);
|
|
195
|
+
|
|
196
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
197
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
198
|
+
try {
|
|
199
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
200
|
+
detail: {
|
|
201
|
+
operation: 'getPaymentsPaymentsRetrieve',
|
|
202
|
+
path: '/cfg/payments/payments/{id}/',
|
|
203
|
+
method: 'GET',
|
|
204
|
+
error: error,
|
|
205
|
+
response: response,
|
|
206
|
+
timestamp: new Date(),
|
|
207
|
+
},
|
|
208
|
+
bubbles: true,
|
|
209
|
+
cancelable: false,
|
|
210
|
+
});
|
|
211
|
+
window.dispatchEvent(event);
|
|
212
|
+
} catch (eventError) {
|
|
213
|
+
// Silently fail - event dispatch should never crash the app
|
|
214
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Re-throw the error
|
|
219
|
+
throw error;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* API operation
|
|
226
|
+
*
|
|
227
|
+
* @method POST
|
|
228
|
+
* @path /cfg/payments/payments/{id}/confirm/
|
|
229
|
+
*/
|
|
230
|
+
export async function createPaymentsPaymentsConfirmCreate( id: string, client?: any
|
|
231
|
+
): Promise<PaymentList> {
|
|
232
|
+
const api = client || getAPIInstance()
|
|
233
|
+
const response = await api.ext_payments_payments.paymentsConfirmCreate(id)
|
|
234
|
+
try {
|
|
235
|
+
return PaymentListSchema.parse(response)
|
|
236
|
+
} catch (error) {
|
|
237
|
+
// Zod validation error - log detailed information
|
|
238
|
+
consola.error('❌ Zod Validation Failed');
|
|
239
|
+
consola.box(`createPaymentsPaymentsConfirmCreate\nPath: /cfg/payments/payments/{id}/confirm/\nMethod: POST`);
|
|
240
|
+
|
|
241
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
242
|
+
consola.error('Validation Issues:');
|
|
243
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
244
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
245
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
246
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
247
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
consola.error('Response data:', response);
|
|
252
|
+
|
|
253
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
254
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
255
|
+
try {
|
|
256
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
257
|
+
detail: {
|
|
258
|
+
operation: 'createPaymentsPaymentsConfirmCreate',
|
|
259
|
+
path: '/cfg/payments/payments/{id}/confirm/',
|
|
260
|
+
method: 'POST',
|
|
261
|
+
error: error,
|
|
262
|
+
response: response,
|
|
263
|
+
timestamp: new Date(),
|
|
264
|
+
},
|
|
265
|
+
bubbles: true,
|
|
266
|
+
cancelable: false,
|
|
267
|
+
});
|
|
268
|
+
window.dispatchEvent(event);
|
|
269
|
+
} catch (eventError) {
|
|
270
|
+
// Silently fail - event dispatch should never crash the app
|
|
271
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// Re-throw the error
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* API operation
|
|
283
|
+
*
|
|
284
|
+
* @method GET
|
|
285
|
+
* @path /cfg/payments/payments/{id}/status/
|
|
286
|
+
*/
|
|
287
|
+
export async function getPaymentsPaymentsStatusRetrieve( id: string, client?: any
|
|
288
|
+
): Promise<PaymentList> {
|
|
289
|
+
const api = client || getAPIInstance()
|
|
290
|
+
const response = await api.ext_payments_payments.paymentsStatusRetrieve(id)
|
|
291
|
+
try {
|
|
292
|
+
return PaymentListSchema.parse(response)
|
|
293
|
+
} catch (error) {
|
|
294
|
+
// Zod validation error - log detailed information
|
|
295
|
+
consola.error('❌ Zod Validation Failed');
|
|
296
|
+
consola.box(`getPaymentsPaymentsStatusRetrieve\nPath: /cfg/payments/payments/{id}/status/\nMethod: GET`);
|
|
297
|
+
|
|
298
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
299
|
+
consola.error('Validation Issues:');
|
|
300
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
301
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
302
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
303
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
304
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
consola.error('Response data:', response);
|
|
309
|
+
|
|
310
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
311
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
312
|
+
try {
|
|
313
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
314
|
+
detail: {
|
|
315
|
+
operation: 'getPaymentsPaymentsStatusRetrieve',
|
|
316
|
+
path: '/cfg/payments/payments/{id}/status/',
|
|
317
|
+
method: 'GET',
|
|
318
|
+
error: error,
|
|
319
|
+
response: response,
|
|
320
|
+
timestamp: new Date(),
|
|
321
|
+
},
|
|
322
|
+
bubbles: true,
|
|
323
|
+
cancelable: false,
|
|
324
|
+
});
|
|
325
|
+
window.dispatchEvent(event);
|
|
326
|
+
} catch (eventError) {
|
|
327
|
+
// Silently fail - event dispatch should never crash the app
|
|
328
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Re-throw the error
|
|
333
|
+
throw error;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* API operation
|
|
340
|
+
*
|
|
341
|
+
* @method POST
|
|
342
|
+
* @path /cfg/payments/payments/create/
|
|
343
|
+
*/
|
|
344
|
+
export async function createPaymentsPaymentsCreateCreate( client?: any
|
|
345
|
+
): Promise<PaymentList> {
|
|
346
|
+
const api = client || getAPIInstance()
|
|
347
|
+
const response = await api.ext_payments_payments.paymentsCreateCreate()
|
|
348
|
+
try {
|
|
349
|
+
return PaymentListSchema.parse(response)
|
|
350
|
+
} catch (error) {
|
|
351
|
+
// Zod validation error - log detailed information
|
|
352
|
+
consola.error('❌ Zod Validation Failed');
|
|
353
|
+
consola.box(`createPaymentsPaymentsCreateCreate\nPath: /cfg/payments/payments/create/\nMethod: POST`);
|
|
354
|
+
|
|
355
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
356
|
+
consola.error('Validation Issues:');
|
|
357
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
358
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
359
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
360
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
361
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
consola.error('Response data:', response);
|
|
366
|
+
|
|
367
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
368
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
369
|
+
try {
|
|
370
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
371
|
+
detail: {
|
|
372
|
+
operation: 'createPaymentsPaymentsCreateCreate',
|
|
373
|
+
path: '/cfg/payments/payments/create/',
|
|
374
|
+
method: 'POST',
|
|
375
|
+
error: error,
|
|
376
|
+
response: response,
|
|
377
|
+
timestamp: new Date(),
|
|
378
|
+
},
|
|
379
|
+
bubbles: true,
|
|
380
|
+
cancelable: false,
|
|
381
|
+
});
|
|
382
|
+
window.dispatchEvent(event);
|
|
383
|
+
} catch (eventError) {
|
|
384
|
+
// Silently fail - event dispatch should never crash the app
|
|
385
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// Re-throw the error
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Get user transactions
|
|
397
|
+
*
|
|
398
|
+
* @method GET
|
|
399
|
+
* @path /cfg/payments/transactions/
|
|
400
|
+
*/
|
|
401
|
+
export async function getPaymentsTransactionsList( params?: { limit?: number; offset?: number; type?: string }, client?: any
|
|
402
|
+
): Promise<any> {
|
|
403
|
+
const api = client || getAPIInstance()
|
|
404
|
+
const response = await api.ext_payments_payments.transactionsList(params?.limit, params?.offset, params?.type)
|
|
405
|
+
return response
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed Fetchers - Universal API functions
|
|
3
|
+
*
|
|
4
|
+
* Auto-generated from OpenAPI specification.
|
|
5
|
+
* These functions work in any JavaScript environment.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Runtime validation with Zod
|
|
9
|
+
* - Type-safe parameters and responses
|
|
10
|
+
* - Works with any data-fetching library (SWR, React Query, etc)
|
|
11
|
+
* - Server Component compatible
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import * as fetchers from './fetchers'
|
|
16
|
+
*
|
|
17
|
+
* // Direct usage
|
|
18
|
+
* const user = await fetchers.getUser(1)
|
|
19
|
+
*
|
|
20
|
+
* // With SWR
|
|
21
|
+
* const { data } = useSWR('user-1', () => fetchers.getUser(1))
|
|
22
|
+
*
|
|
23
|
+
* // With React Query
|
|
24
|
+
* const { data } = useQuery(['user', 1], () => fetchers.getUser(1))
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export * from './ext_payments__payments'
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SWR Hooks for Payments
|
|
5
|
+
*
|
|
6
|
+
* React hooks powered by SWR for data fetching with automatic caching,
|
|
7
|
+
* revalidation, and optimistic updates.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Query hooks (GET)
|
|
12
|
+
* const { data, error, isLoading } = useUsers({ page: 1 })
|
|
13
|
+
*
|
|
14
|
+
* // Mutation hooks (POST/PUT/PATCH/DELETE)
|
|
15
|
+
* const createUser = useCreateUser()
|
|
16
|
+
* await createUser({ name: 'John', email: 'john@example.com' })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import useSWR from 'swr'
|
|
20
|
+
import { useSWRConfig } from 'swr'
|
|
21
|
+
import * as Fetchers from '../fetchers/ext_payments__payments'
|
|
22
|
+
import type { API } from '../../index'
|
|
23
|
+
import type { Balance } from '../schemas/Balance.schema'
|
|
24
|
+
import type { PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
|
|
25
|
+
import type { PaymentDetail } from '../schemas/PaymentDetail.schema'
|
|
26
|
+
import type { PaymentList } from '../schemas/PaymentList.schema'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get user balance
|
|
30
|
+
*
|
|
31
|
+
* @method GET
|
|
32
|
+
* @path /cfg/payments/balance/
|
|
33
|
+
*/
|
|
34
|
+
export function usePaymentsBalanceRetrieve(client?: API): ReturnType<typeof useSWR<Balance>> {
|
|
35
|
+
return useSWR<Balance>(
|
|
36
|
+
'cfg-payments-balance',
|
|
37
|
+
() => Fetchers.getPaymentsBalanceRetrieve(client)
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get available currencies
|
|
44
|
+
*
|
|
45
|
+
* @method GET
|
|
46
|
+
* @path /cfg/payments/currencies/
|
|
47
|
+
*/
|
|
48
|
+
export function usePaymentsCurrenciesList(client?: API): ReturnType<typeof useSWR<any>> {
|
|
49
|
+
return useSWR<any>(
|
|
50
|
+
'cfg-payments-currencies',
|
|
51
|
+
() => Fetchers.getPaymentsCurrenciesList(client)
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* API operation
|
|
58
|
+
*
|
|
59
|
+
* @method GET
|
|
60
|
+
* @path /cfg/payments/payments/
|
|
61
|
+
*/
|
|
62
|
+
export function usePaymentsPaymentsList(params?: { page?: number; page_size?: number }, client?: API): ReturnType<typeof useSWR<PaginatedPaymentListList>> {
|
|
63
|
+
return useSWR<PaginatedPaymentListList>(
|
|
64
|
+
params ? ['cfg-payments-payments', params] : 'cfg-payments-payments',
|
|
65
|
+
() => Fetchers.getPaymentsPaymentsList(params, client)
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* API operation
|
|
72
|
+
*
|
|
73
|
+
* @method GET
|
|
74
|
+
* @path /cfg/payments/payments/{id}/
|
|
75
|
+
*/
|
|
76
|
+
export function usePaymentsPaymentsRetrieve(id: string, client?: API): ReturnType<typeof useSWR<PaymentDetail>> {
|
|
77
|
+
return useSWR<PaymentDetail>(
|
|
78
|
+
['cfg-payments-payment', id],
|
|
79
|
+
() => Fetchers.getPaymentsPaymentsRetrieve(id, client)
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* API operation
|
|
86
|
+
*
|
|
87
|
+
* @method POST
|
|
88
|
+
* @path /cfg/payments/payments/{id}/confirm/
|
|
89
|
+
*/
|
|
90
|
+
export function useCreatePaymentsPaymentsConfirmCreate() {
|
|
91
|
+
const { mutate } = useSWRConfig()
|
|
92
|
+
|
|
93
|
+
return async (id: string, client?: API): Promise<PaymentList> => {
|
|
94
|
+
const result = await Fetchers.createPaymentsPaymentsConfirmCreate(id, client)
|
|
95
|
+
// Revalidate related queries
|
|
96
|
+
mutate('cfg-payments-payments-confirm')
|
|
97
|
+
return result
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* API operation
|
|
104
|
+
*
|
|
105
|
+
* @method GET
|
|
106
|
+
* @path /cfg/payments/payments/{id}/status/
|
|
107
|
+
*/
|
|
108
|
+
export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): ReturnType<typeof useSWR<PaymentList>> {
|
|
109
|
+
return useSWR<PaymentList>(
|
|
110
|
+
['cfg-payments-payments-statu', id],
|
|
111
|
+
() => Fetchers.getPaymentsPaymentsStatusRetrieve(id, client)
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* API operation
|
|
118
|
+
*
|
|
119
|
+
* @method POST
|
|
120
|
+
* @path /cfg/payments/payments/create/
|
|
121
|
+
*/
|
|
122
|
+
export function useCreatePaymentsPaymentsCreateCreate() {
|
|
123
|
+
const { mutate } = useSWRConfig()
|
|
124
|
+
|
|
125
|
+
return async (client?: API): Promise<PaymentList> => {
|
|
126
|
+
const result = await Fetchers.createPaymentsPaymentsCreateCreate(client)
|
|
127
|
+
// Revalidate related queries
|
|
128
|
+
mutate('cfg-payments-payments')
|
|
129
|
+
return result
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get user transactions
|
|
136
|
+
*
|
|
137
|
+
* @method GET
|
|
138
|
+
* @path /cfg/payments/transactions/
|
|
139
|
+
*/
|
|
140
|
+
export function usePaymentsTransactionsList(params?: { limit?: number; offset?: number; type?: string }, client?: API): ReturnType<typeof useSWR<any>> {
|
|
141
|
+
return useSWR<any>(
|
|
142
|
+
params ? ['cfg-payments-transactions', params] : 'cfg-payments-transactions',
|
|
143
|
+
() => Fetchers.getPaymentsTransactionsList(params, client)
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SWR Hooks - React data fetching hooks
|
|
5
|
+
*
|
|
6
|
+
* Auto-generated from OpenAPI specification.
|
|
7
|
+
* Powered by SWR for automatic caching and revalidation.
|
|
8
|
+
*
|
|
9
|
+
* Features:
|
|
10
|
+
* - Automatic caching and deduplication
|
|
11
|
+
* - Revalidation on focus/reconnect
|
|
12
|
+
* - Optimistic updates
|
|
13
|
+
* - Type-safe parameters and responses
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import * as hooks from './hooks'
|
|
18
|
+
*
|
|
19
|
+
* // Query hooks (GET)
|
|
20
|
+
* const { data, error, isLoading } = hooks.useUsers({ page: 1 })
|
|
21
|
+
*
|
|
22
|
+
* // Mutation hooks (POST/PUT/PATCH/DELETE)
|
|
23
|
+
* const createUser = hooks.useCreateUser()
|
|
24
|
+
* await createUser({ name: 'John' })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export * from './ext_payments__payments'
|