@djangocfg/api 2.1.55 → 2.1.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/auth.cjs +28 -15
  2. package/dist/auth.cjs.map +1 -1
  3. package/dist/auth.d.cts +6 -6
  4. package/dist/auth.d.ts +6 -6
  5. package/dist/auth.mjs +28 -15
  6. package/dist/auth.mjs.map +1 -1
  7. package/dist/clients.cjs +56 -17
  8. package/dist/clients.cjs.map +1 -1
  9. package/dist/clients.d.cts +17 -17
  10. package/dist/clients.d.ts +17 -17
  11. package/dist/clients.mjs +56 -17
  12. package/dist/clients.mjs.map +1 -1
  13. package/dist/hooks.cjs +763 -12
  14. package/dist/hooks.cjs.map +1 -1
  15. package/dist/hooks.d.cts +11 -11
  16. package/dist/hooks.d.ts +11 -11
  17. package/dist/hooks.mjs +763 -12
  18. package/dist/hooks.mjs.map +1 -1
  19. package/dist/index.cjs +893 -69
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +59 -41
  22. package/dist/index.d.ts +59 -41
  23. package/dist/index.mjs +893 -69
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +3 -3
  26. package/src/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +1 -1
  27. package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +2 -2
  28. package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +1 -1
  29. package/src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +1 -1
  30. package/src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +1 -1
  31. package/src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +1 -1
  32. package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +1 -1
  33. package/src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +1 -1
  34. package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +1 -1
  35. package/src/generated/cfg_accounts/_utils/schemas/User.schema.ts +1 -1
  36. package/src/generated/cfg_accounts/api-instance.ts +61 -13
  37. package/src/generated/cfg_centrifugo/api-instance.ts +61 -13
  38. package/src/generated/cfg_totp/CLAUDE.md +90 -0
  39. package/src/generated/cfg_totp/_utils/fetchers/index.ts +33 -0
  40. package/src/generated/cfg_totp/_utils/fetchers/totp.ts +49 -0
  41. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_management.ts +108 -0
  42. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_setup.ts +153 -0
  43. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_verification.ts +152 -0
  44. package/src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +152 -0
  45. package/src/generated/cfg_totp/_utils/hooks/index.ts +33 -0
  46. package/src/generated/cfg_totp/_utils/hooks/totp.ts +42 -0
  47. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_management.ts +58 -0
  48. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_setup.ts +63 -0
  49. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_verification.ts +62 -0
  50. package/src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +59 -0
  51. package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +19 -0
  52. package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +20 -0
  53. package/src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +21 -0
  54. package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +20 -0
  55. package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +21 -0
  56. package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +26 -0
  57. package/src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +19 -0
  58. package/src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts +24 -0
  59. package/src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +19 -0
  60. package/src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +23 -0
  61. package/src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +20 -0
  62. package/src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +20 -0
  63. package/src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +24 -0
  64. package/src/generated/cfg_totp/_utils/schemas/index.ts +32 -0
  65. package/src/generated/cfg_totp/api-instance.ts +180 -0
  66. package/src/generated/cfg_totp/client.ts +313 -0
  67. package/src/generated/cfg_totp/enums.ts +12 -0
  68. package/src/generated/cfg_totp/errors.ts +117 -0
  69. package/src/generated/cfg_totp/http.ts +104 -0
  70. package/src/generated/cfg_totp/index.ts +302 -0
  71. package/src/generated/cfg_totp/logger.ts +260 -0
  72. package/src/generated/cfg_totp/retry.ts +176 -0
  73. package/src/generated/cfg_totp/schema.json +859 -0
  74. package/src/generated/cfg_totp/storage.ts +162 -0
  75. package/src/generated/cfg_totp/totp/client.ts +23 -0
  76. package/src/generated/cfg_totp/totp/index.ts +3 -0
  77. package/src/generated/cfg_totp/totp/models.ts +1 -0
  78. package/src/generated/cfg_totp/totp__2fa_management/client.ts +41 -0
  79. package/src/generated/cfg_totp/totp__2fa_management/index.ts +3 -0
  80. package/src/generated/cfg_totp/totp__2fa_management/models.ts +60 -0
  81. package/src/generated/cfg_totp/totp__2fa_setup/client.ts +32 -0
  82. package/src/generated/cfg_totp/totp__2fa_setup/index.ts +3 -0
  83. package/src/generated/cfg_totp/totp__2fa_setup/models.ts +54 -0
  84. package/src/generated/cfg_totp/totp__2fa_verification/client.ts +32 -0
  85. package/src/generated/cfg_totp/totp__2fa_verification/index.ts +3 -0
  86. package/src/generated/cfg_totp/totp__2fa_verification/models.ts +44 -0
  87. package/src/generated/cfg_totp/totp__backup_codes/client.ts +31 -0
  88. package/src/generated/cfg_totp/totp__backup_codes/index.ts +3 -0
  89. package/src/generated/cfg_totp/totp__backup_codes/models.ts +37 -0
  90. package/src/generated/cfg_totp/validation-events.ts +134 -0
  91. package/src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts +2 -2
  92. package/src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts +1 -1
  93. package/src/generated/cfg_webpush/api-instance.ts +61 -13
@@ -0,0 +1,153 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ /**
3
+ * Typed fetchers for 2fa Setup
4
+ *
5
+ * Universal functions that work in any environment:
6
+ * - Next.js (App Router / Pages Router / Server Components)
7
+ * - React Native
8
+ * - Node.js backend
9
+ *
10
+ * These fetchers use Zod schemas for runtime validation.
11
+ *
12
+ * Usage:
13
+ * ```typescript
14
+ * // Configure API once (in your app entry point)
15
+ * import { configureAPI } from '../../api-instance'
16
+ * configureAPI({ baseUrl: 'https://api.example.com' })
17
+ *
18
+ * // Then use fetchers anywhere
19
+ * const users = await getUsers({ page: 1 })
20
+ *
21
+ * // With SWR
22
+ * const { data } = useSWR(['users', params], () => getUsers(params))
23
+ *
24
+ * // With React Query
25
+ * const { data } = useQuery(['users', params], () => getUsers(params))
26
+ *
27
+ * // In Server Component or SSR (pass custom client)
28
+ * import { API } from '../../index'
29
+ * const api = new API('https://api.example.com')
30
+ * const users = await getUsers({ page: 1 }, api)
31
+ * ```
32
+ */
33
+ import { consola } from 'consola'
34
+ import { ConfirmSetupRequestSchema, type ConfirmSetupRequest } from '../schemas/ConfirmSetupRequest.schema'
35
+ import { ConfirmSetupResponseSchema, type ConfirmSetupResponse } from '../schemas/ConfirmSetupResponse.schema'
36
+ import { SetupRequestSchema, type SetupRequest } from '../schemas/SetupRequest.schema'
37
+ import { SetupResponseSchema, type SetupResponse } from '../schemas/SetupResponse.schema'
38
+ import { getAPIInstance } from '../../api-instance'
39
+
40
+ /**
41
+ * API operation
42
+ *
43
+ * @method POST
44
+ * @path /cfg/totp/setup/
45
+ */
46
+ export async function createTotpSetupCreate( data: SetupRequest, client?: any
47
+ ): Promise<SetupResponse> {
48
+ const api = client || getAPIInstance()
49
+ const response = await api.2fa_setup.totpSetupCreate(data)
50
+ try {
51
+ return SetupResponseSchema.parse(response)
52
+ } catch (error) {
53
+ // Zod validation error - log detailed information
54
+ consola.error('❌ Zod Validation Failed');
55
+ consola.box(`createTotpSetupCreate\nPath: /cfg/totp/setup/\nMethod: POST`);
56
+
57
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
58
+ consola.error('Validation Issues:');
59
+ (error as any).issues.forEach((issue: any, index: number) => {
60
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
61
+ consola.error(` ├─ Message: ${issue.message}`);
62
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
63
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
64
+ });
65
+ }
66
+
67
+ consola.error('Response data:', response);
68
+
69
+ // Dispatch browser CustomEvent (only if window is defined)
70
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
71
+ try {
72
+ const event = new CustomEvent('zod-validation-error', {
73
+ detail: {
74
+ operation: 'createTotpSetupCreate',
75
+ path: '/cfg/totp/setup/',
76
+ method: 'POST',
77
+ error: error,
78
+ response: response,
79
+ timestamp: new Date(),
80
+ },
81
+ bubbles: true,
82
+ cancelable: false,
83
+ });
84
+ window.dispatchEvent(event);
85
+ } catch (eventError) {
86
+ // Silently fail - event dispatch should never crash the app
87
+ consola.warn('Failed to dispatch validation error event:', eventError);
88
+ }
89
+ }
90
+
91
+ // Re-throw the error
92
+ throw error;
93
+ }
94
+ }
95
+
96
+
97
+ /**
98
+ * API operation
99
+ *
100
+ * @method POST
101
+ * @path /cfg/totp/setup/confirm/
102
+ */
103
+ export async function createTotpSetupConfirmCreate( data: ConfirmSetupRequest, client?: any
104
+ ): Promise<ConfirmSetupResponse> {
105
+ const api = client || getAPIInstance()
106
+ const response = await api.2fa_setup.totpSetupConfirmCreate(data)
107
+ try {
108
+ return ConfirmSetupResponseSchema.parse(response)
109
+ } catch (error) {
110
+ // Zod validation error - log detailed information
111
+ consola.error('❌ Zod Validation Failed');
112
+ consola.box(`createTotpSetupConfirmCreate\nPath: /cfg/totp/setup/confirm/\nMethod: POST`);
113
+
114
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
115
+ consola.error('Validation Issues:');
116
+ (error as any).issues.forEach((issue: any, index: number) => {
117
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
118
+ consola.error(` ├─ Message: ${issue.message}`);
119
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
120
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
121
+ });
122
+ }
123
+
124
+ consola.error('Response data:', response);
125
+
126
+ // Dispatch browser CustomEvent (only if window is defined)
127
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
128
+ try {
129
+ const event = new CustomEvent('zod-validation-error', {
130
+ detail: {
131
+ operation: 'createTotpSetupConfirmCreate',
132
+ path: '/cfg/totp/setup/confirm/',
133
+ method: 'POST',
134
+ error: error,
135
+ response: response,
136
+ timestamp: new Date(),
137
+ },
138
+ bubbles: true,
139
+ cancelable: false,
140
+ });
141
+ window.dispatchEvent(event);
142
+ } catch (eventError) {
143
+ // Silently fail - event dispatch should never crash the app
144
+ consola.warn('Failed to dispatch validation error event:', eventError);
145
+ }
146
+ }
147
+
148
+ // Re-throw the error
149
+ throw error;
150
+ }
151
+ }
152
+
153
+
@@ -0,0 +1,152 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ /**
3
+ * Typed fetchers for 2fa Verification
4
+ *
5
+ * Universal functions that work in any environment:
6
+ * - Next.js (App Router / Pages Router / Server Components)
7
+ * - React Native
8
+ * - Node.js backend
9
+ *
10
+ * These fetchers use Zod schemas for runtime validation.
11
+ *
12
+ * Usage:
13
+ * ```typescript
14
+ * // Configure API once (in your app entry point)
15
+ * import { configureAPI } from '../../api-instance'
16
+ * configureAPI({ baseUrl: 'https://api.example.com' })
17
+ *
18
+ * // Then use fetchers anywhere
19
+ * const users = await getUsers({ page: 1 })
20
+ *
21
+ * // With SWR
22
+ * const { data } = useSWR(['users', params], () => getUsers(params))
23
+ *
24
+ * // With React Query
25
+ * const { data } = useQuery(['users', params], () => getUsers(params))
26
+ *
27
+ * // In Server Component or SSR (pass custom client)
28
+ * import { API } from '../../index'
29
+ * const api = new API('https://api.example.com')
30
+ * const users = await getUsers({ page: 1 }, api)
31
+ * ```
32
+ */
33
+ import { consola } from 'consola'
34
+ import { VerifyBackupRequestSchema, type VerifyBackupRequest } from '../schemas/VerifyBackupRequest.schema'
35
+ import { VerifyRequestSchema, type VerifyRequest } from '../schemas/VerifyRequest.schema'
36
+ import { VerifyResponseSchema, type VerifyResponse } from '../schemas/VerifyResponse.schema'
37
+ import { getAPIInstance } from '../../api-instance'
38
+
39
+ /**
40
+ * API operation
41
+ *
42
+ * @method POST
43
+ * @path /cfg/totp/verify/
44
+ */
45
+ export async function createTotpVerifyCreate( data: VerifyRequest, client?: any
46
+ ): Promise<VerifyResponse> {
47
+ const api = client || getAPIInstance()
48
+ const response = await api.2fa_verification.totpVerifyCreate(data)
49
+ try {
50
+ return VerifyResponseSchema.parse(response)
51
+ } catch (error) {
52
+ // Zod validation error - log detailed information
53
+ consola.error('❌ Zod Validation Failed');
54
+ consola.box(`createTotpVerifyCreate\nPath: /cfg/totp/verify/\nMethod: POST`);
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: 'createTotpVerifyCreate',
74
+ path: '/cfg/totp/verify/',
75
+ method: 'POST',
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
+ * API operation
98
+ *
99
+ * @method POST
100
+ * @path /cfg/totp/verify/backup/
101
+ */
102
+ export async function createTotpVerifyBackupCreate( data: VerifyBackupRequest, client?: any
103
+ ): Promise<VerifyResponse> {
104
+ const api = client || getAPIInstance()
105
+ const response = await api.2fa_verification.totpVerifyBackupCreate(data)
106
+ try {
107
+ return VerifyResponseSchema.parse(response)
108
+ } catch (error) {
109
+ // Zod validation error - log detailed information
110
+ consola.error('❌ Zod Validation Failed');
111
+ consola.box(`createTotpVerifyBackupCreate\nPath: /cfg/totp/verify/backup/\nMethod: POST`);
112
+
113
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
114
+ consola.error('Validation Issues:');
115
+ (error as any).issues.forEach((issue: any, index: number) => {
116
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
117
+ consola.error(` ├─ Message: ${issue.message}`);
118
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
119
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
120
+ });
121
+ }
122
+
123
+ consola.error('Response data:', response);
124
+
125
+ // Dispatch browser CustomEvent (only if window is defined)
126
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
127
+ try {
128
+ const event = new CustomEvent('zod-validation-error', {
129
+ detail: {
130
+ operation: 'createTotpVerifyBackupCreate',
131
+ path: '/cfg/totp/verify/backup/',
132
+ method: 'POST',
133
+ error: error,
134
+ response: response,
135
+ timestamp: new Date(),
136
+ },
137
+ bubbles: true,
138
+ cancelable: false,
139
+ });
140
+ window.dispatchEvent(event);
141
+ } catch (eventError) {
142
+ // Silently fail - event dispatch should never crash the app
143
+ consola.warn('Failed to dispatch validation error event:', eventError);
144
+ }
145
+ }
146
+
147
+ // Re-throw the error
148
+ throw error;
149
+ }
150
+ }
151
+
152
+
@@ -0,0 +1,152 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ /**
3
+ * Typed fetchers for Backup Codes
4
+ *
5
+ * Universal functions that work in any environment:
6
+ * - Next.js (App Router / Pages Router / Server Components)
7
+ * - React Native
8
+ * - Node.js backend
9
+ *
10
+ * These fetchers use Zod schemas for runtime validation.
11
+ *
12
+ * Usage:
13
+ * ```typescript
14
+ * // Configure API once (in your app entry point)
15
+ * import { configureAPI } from '../../api-instance'
16
+ * configureAPI({ baseUrl: 'https://api.example.com' })
17
+ *
18
+ * // Then use fetchers anywhere
19
+ * const users = await getUsers({ page: 1 })
20
+ *
21
+ * // With SWR
22
+ * const { data } = useSWR(['users', params], () => getUsers(params))
23
+ *
24
+ * // With React Query
25
+ * const { data } = useQuery(['users', params], () => getUsers(params))
26
+ *
27
+ * // In Server Component or SSR (pass custom client)
28
+ * import { API } from '../../index'
29
+ * const api = new API('https://api.example.com')
30
+ * const users = await getUsers({ page: 1 }, api)
31
+ * ```
32
+ */
33
+ import { consola } from 'consola'
34
+ import { BackupCodesRegenerateRequestSchema, type BackupCodesRegenerateRequest } from '../schemas/BackupCodesRegenerateRequest.schema'
35
+ import { BackupCodesRegenerateResponseSchema, type BackupCodesRegenerateResponse } from '../schemas/BackupCodesRegenerateResponse.schema'
36
+ import { BackupCodesStatusSchema, type BackupCodesStatus } from '../schemas/BackupCodesStatus.schema'
37
+ import { getAPIInstance } from '../../api-instance'
38
+
39
+ /**
40
+ * API operation
41
+ *
42
+ * @method GET
43
+ * @path /cfg/totp/backup-codes/
44
+ */
45
+ export async function getTotpBackupCodesRetrieve( client?: any
46
+ ): Promise<BackupCodesStatus> {
47
+ const api = client || getAPIInstance()
48
+ const response = await api.backup_codes.totpBackupCodesRetrieve()
49
+ try {
50
+ return BackupCodesStatusSchema.parse(response)
51
+ } catch (error) {
52
+ // Zod validation error - log detailed information
53
+ consola.error('❌ Zod Validation Failed');
54
+ consola.box(`getTotpBackupCodesRetrieve\nPath: /cfg/totp/backup-codes/\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: 'getTotpBackupCodesRetrieve',
74
+ path: '/cfg/totp/backup-codes/',
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
+ * API operation
98
+ *
99
+ * @method POST
100
+ * @path /cfg/totp/backup-codes/regenerate/
101
+ */
102
+ export async function createTotpBackupCodesRegenerateCreate( data: BackupCodesRegenerateRequest, client?: any
103
+ ): Promise<BackupCodesRegenerateResponse> {
104
+ const api = client || getAPIInstance()
105
+ const response = await api.backup_codes.totpBackupCodesRegenerateCreate(data)
106
+ try {
107
+ return BackupCodesRegenerateResponseSchema.parse(response)
108
+ } catch (error) {
109
+ // Zod validation error - log detailed information
110
+ consola.error('❌ Zod Validation Failed');
111
+ consola.box(`createTotpBackupCodesRegenerateCreate\nPath: /cfg/totp/backup-codes/regenerate/\nMethod: POST`);
112
+
113
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
114
+ consola.error('Validation Issues:');
115
+ (error as any).issues.forEach((issue: any, index: number) => {
116
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
117
+ consola.error(` ├─ Message: ${issue.message}`);
118
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
119
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
120
+ });
121
+ }
122
+
123
+ consola.error('Response data:', response);
124
+
125
+ // Dispatch browser CustomEvent (only if window is defined)
126
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
127
+ try {
128
+ const event = new CustomEvent('zod-validation-error', {
129
+ detail: {
130
+ operation: 'createTotpBackupCodesRegenerateCreate',
131
+ path: '/cfg/totp/backup-codes/regenerate/',
132
+ method: 'POST',
133
+ error: error,
134
+ response: response,
135
+ timestamp: new Date(),
136
+ },
137
+ bubbles: true,
138
+ cancelable: false,
139
+ });
140
+ window.dispatchEvent(event);
141
+ } catch (eventError) {
142
+ // Silently fail - event dispatch should never crash the app
143
+ consola.warn('Failed to dispatch validation error event:', eventError);
144
+ }
145
+ }
146
+
147
+ // Re-throw the error
148
+ throw error;
149
+ }
150
+ }
151
+
152
+
@@ -0,0 +1,33 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ 'use client';
3
+
4
+ /**
5
+ * SWR Hooks - React data fetching hooks
6
+ *
7
+ * Auto-generated from OpenAPI specification.
8
+ * Powered by SWR for automatic caching and revalidation.
9
+ *
10
+ * Features:
11
+ * - Automatic caching and deduplication
12
+ * - Revalidation on focus/reconnect
13
+ * - Optimistic updates
14
+ * - Type-safe parameters and responses
15
+ *
16
+ * Usage:
17
+ * ```typescript
18
+ * import * as hooks from './hooks'
19
+ *
20
+ * // Query hooks (GET)
21
+ * const { data, error, isLoading } = hooks.useUsers({ page: 1 })
22
+ *
23
+ * // Mutation hooks (POST/PUT/PATCH/DELETE)
24
+ * const createUser = hooks.useCreateUser()
25
+ * await createUser({ name: 'John' })
26
+ * ```
27
+ */
28
+
29
+ export * from './totp__2fa_management'
30
+ export * from './totp__2fa_setup'
31
+ export * from './totp__2fa_verification'
32
+ export * from './totp__backup_codes'
33
+ export * from './totp'
@@ -0,0 +1,42 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ 'use client';
3
+
4
+ /**
5
+ * SWR Hooks for Totp
6
+ *
7
+ * React hooks powered by SWR for data fetching with automatic caching,
8
+ * revalidation, and optimistic updates.
9
+ *
10
+ * Usage:
11
+ * ```typescript
12
+ * // Query hooks (GET)
13
+ * const { data, error, isLoading } = useUsers({ page: 1 })
14
+ *
15
+ * // Mutation hooks (POST/PUT/PATCH/DELETE)
16
+ * const createUser = useCreateUser()
17
+ * await createUser({ name: 'John', email: 'john@example.com' })
18
+ * ```
19
+ */
20
+ import { useSWRConfig } from 'swr'
21
+ import * as Fetchers from '../fetchers/totp'
22
+ import type { API } from '../../index'
23
+
24
+ /**
25
+ * API operation
26
+ *
27
+ * @method DELETE
28
+ * @path /cfg/totp/devices/{id}/
29
+ */
30
+ export function useDeleteTotpDevicesDestroy() {
31
+ const { mutate } = useSWRConfig()
32
+
33
+ return async (id: string, client?: API): Promise<void> => {
34
+ const result = await Fetchers.deleteTotpDevicesDestroy(id, client)
35
+ // Revalidate related queries
36
+ mutate('cfg-totp-devices')
37
+ mutate('cfg-totp-device')
38
+ return result
39
+ }
40
+ }
41
+
42
+
@@ -0,0 +1,58 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ 'use client';
3
+
4
+ /**
5
+ * SWR Hooks for 2fa Management
6
+ *
7
+ * React hooks powered by SWR for data fetching with automatic caching,
8
+ * revalidation, and optimistic updates.
9
+ *
10
+ * Usage:
11
+ * ```typescript
12
+ * // Query hooks (GET)
13
+ * const { data, error, isLoading } = useUsers({ page: 1 })
14
+ *
15
+ * // Mutation hooks (POST/PUT/PATCH/DELETE)
16
+ * const createUser = useCreateUser()
17
+ * await createUser({ name: 'John', email: 'john@example.com' })
18
+ * ```
19
+ */
20
+ import useSWR from 'swr'
21
+ import { useSWRConfig } from 'swr'
22
+ import * as Fetchers from '../fetchers/totp__2fa_management'
23
+ import type { API } from '../../index'
24
+ import type { DisableRequest } from '../schemas/DisableRequest.schema'
25
+ import type { PaginatedDeviceListList } from '../schemas/PaginatedDeviceListList.schema'
26
+
27
+ /**
28
+ * API operation
29
+ *
30
+ * @method GET
31
+ * @path /cfg/totp/devices/
32
+ */
33
+ export function useTotpDevicesList(params?: { page?: number; page_size?: number }, client?: API): ReturnType<typeof useSWR<PaginatedDeviceListList>> {
34
+ return useSWR<PaginatedDeviceListList>(
35
+ params ? ['cfg-totp-devices', params] : 'cfg-totp-devices',
36
+ () => Fetchers.getTotpDevicesList(params, client)
37
+ )
38
+ }
39
+
40
+
41
+ /**
42
+ * API operation
43
+ *
44
+ * @method POST
45
+ * @path /cfg/totp/disable/
46
+ */
47
+ export function useCreateTotpDisableCreate() {
48
+ const { mutate } = useSWRConfig()
49
+
50
+ return async (data: DisableRequest, client?: API): Promise<any> => {
51
+ const result = await Fetchers.createTotpDisableCreate(data, client)
52
+ // Revalidate related queries
53
+ mutate('cfg-totp-disable')
54
+ return result
55
+ }
56
+ }
57
+
58
+
@@ -0,0 +1,63 @@
1
+ // Auto-generated by DjangoCFG - see CLAUDE.md
2
+ 'use client';
3
+
4
+ /**
5
+ * SWR Hooks for 2fa Setup
6
+ *
7
+ * React hooks powered by SWR for data fetching with automatic caching,
8
+ * revalidation, and optimistic updates.
9
+ *
10
+ * Usage:
11
+ * ```typescript
12
+ * // Query hooks (GET)
13
+ * const { data, error, isLoading } = useUsers({ page: 1 })
14
+ *
15
+ * // Mutation hooks (POST/PUT/PATCH/DELETE)
16
+ * const createUser = useCreateUser()
17
+ * await createUser({ name: 'John', email: 'john@example.com' })
18
+ * ```
19
+ */
20
+ import { useSWRConfig } from 'swr'
21
+ import * as Fetchers from '../fetchers/totp__2fa_setup'
22
+ import type { API } from '../../index'
23
+ import type { ConfirmSetupRequest } from '../schemas/ConfirmSetupRequest.schema'
24
+ import type { ConfirmSetupResponse } from '../schemas/ConfirmSetupResponse.schema'
25
+ import type { SetupRequest } from '../schemas/SetupRequest.schema'
26
+ import type { SetupResponse } from '../schemas/SetupResponse.schema'
27
+
28
+ /**
29
+ * API operation
30
+ *
31
+ * @method POST
32
+ * @path /cfg/totp/setup/
33
+ */
34
+ export function useCreateTotpSetupCreate() {
35
+ const { mutate } = useSWRConfig()
36
+
37
+ return async (data: SetupRequest, client?: API): Promise<SetupResponse> => {
38
+ const result = await Fetchers.createTotpSetupCreate(data, client)
39
+ // Revalidate related queries
40
+ mutate('cfg-totp-setup')
41
+ return result
42
+ }
43
+ }
44
+
45
+
46
+ /**
47
+ * API operation
48
+ *
49
+ * @method POST
50
+ * @path /cfg/totp/setup/confirm/
51
+ */
52
+ export function useCreateTotpSetupConfirmCreate() {
53
+ const { mutate } = useSWRConfig()
54
+
55
+ return async (data: ConfirmSetupRequest, client?: API): Promise<ConfirmSetupResponse> => {
56
+ const result = await Fetchers.createTotpSetupConfirmCreate(data, client)
57
+ // Revalidate related queries
58
+ mutate('cfg-totp-setup-confirm')
59
+ return result
60
+ }
61
+ }
62
+
63
+