@djangocfg/api 2.1.356 → 2.1.357

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 (112) hide show
  1. package/README.md +53 -632
  2. package/dist/auth-server.cjs +717 -200
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +717 -200
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +843 -783
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.d.cts +58 -37
  9. package/dist/auth.d.ts +58 -37
  10. package/dist/auth.mjs +846 -784
  11. package/dist/auth.mjs.map +1 -1
  12. package/dist/clients.cjs +1427 -0
  13. package/dist/clients.cjs.map +1 -1
  14. package/dist/clients.d.cts +1686 -0
  15. package/dist/clients.d.ts +1686 -0
  16. package/dist/clients.mjs +1427 -0
  17. package/dist/clients.mjs.map +1 -1
  18. package/dist/hooks.cjs +1277 -1924
  19. package/dist/hooks.cjs.map +1 -1
  20. package/dist/hooks.d.cts +18 -1206
  21. package/dist/hooks.d.ts +18 -1206
  22. package/dist/hooks.mjs +1253 -1900
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +545 -1232
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1389 -1455
  27. package/dist/index.d.ts +1389 -1455
  28. package/dist/index.mjs +545 -1232
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +7 -2
  31. package/src/_api/generated/_cfg_accounts/api.ts +11 -3
  32. package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
  42. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
  43. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
  44. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
  45. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
  46. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
  47. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
  48. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
  49. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
  50. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
  51. package/src/_api/generated/_cfg_accounts/index.ts +1 -1
  52. package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
  55. package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
  56. package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
  58. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
  59. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
  60. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
  61. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
  62. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  63. package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
  64. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
  65. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
  66. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
  67. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
  68. package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
  69. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
  70. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
  71. package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
  72. package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
  73. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
  74. package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
  75. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
  76. package/src/_api/generated/_cfg_totp/api.ts +9 -3
  77. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
  78. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
  86. package/src/_api/generated/_cfg_totp/index.ts +1 -1
  87. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
  88. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
  89. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
  90. package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
  91. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
  92. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
  93. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
  94. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
  95. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
  98. package/src/_api/generated/index.ts +3 -1
  99. package/src/_api/generated/sdk.gen.ts +80 -813
  100. package/src/_api/generated/types.gen.ts +320 -159
  101. package/src/auth/context/AccountsContext.tsx +18 -6
  102. package/src/auth/context/AuthContext.tsx +11 -3
  103. package/src/auth/hooks/useDeleteAccount.ts +2 -2
  104. package/src/auth/hooks/useGithubAuth.ts +3 -3
  105. package/src/auth/hooks/useTokenRefresh.ts +2 -2
  106. package/src/auth/hooks/useTwoFactor.ts +3 -3
  107. package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
  108. package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
  109. package/src/auth/middlewares/tokenRefresh.ts +2 -2
  110. package/src/hooks/index.ts +1 -0
  111. package/src/hooks/useApiKey.ts +73 -0
  112. package/src/index.ts +12 -16
package/dist/hooks.d.ts CHANGED
@@ -1,1206 +1,18 @@
1
- import { ConsolaInstance } from 'consola';
2
- import { z } from 'zod';
3
- import useSWR from 'swr';
4
-
5
- /**
6
- *
7
- * Request model (no read-only fields).
8
- */
9
- interface TokenRefreshRequest$1 {
10
- refresh: string;
11
- }
12
- /**
13
- *
14
- * Response model (includes read-only fields).
15
- */
16
- interface TokenRefresh$1 {
17
- access: string;
18
- refresh: string;
19
- }
20
-
21
- /**
22
- * API endpoints for Auth.
23
- */
24
- declare class Auth {
25
- private client;
26
- constructor(client: any);
27
- /**
28
- * Refresh JWT token.
29
- */
30
- accountsTokenRefreshCreate(data: TokenRefreshRequest$1): Promise<TokenRefresh$1>;
31
- }
32
-
33
- /**
34
- * OAuth provider to disconnect
35
- * * `github` - GitHub
36
- */
37
- declare enum OAuthConnectionProvider {
38
- GITHUB = "github"
39
- }
40
-
41
- /**
42
- * Request to start OAuth flow.
43
- *
44
- * Request model (no read-only fields).
45
- */
46
- interface OAuthAuthorizeRequestRequest$1 {
47
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
48
- redirect_uri?: string;
49
- /** Optional source URL for registration tracking */
50
- source_url?: string;
51
- }
52
- /**
53
- * Request to complete OAuth flow (callback handler).
54
- *
55
- * Request model (no read-only fields).
56
- */
57
- interface OAuthCallbackRequestRequest$1 {
58
- /** Authorization code from OAuth provider callback */
59
- code: string;
60
- /** State token for CSRF verification (from authorize response) */
61
- state: string;
62
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
63
- redirect_uri?: string;
64
- }
65
- /**
66
- * Response with JWT tokens after OAuth authentication. When 2FA is required: -
67
- * requires_2fa: True - session_id: UUID of 2FA verification session -
68
- * access/refresh/user: null When 2FA is not required: - requires_2fa: False -
69
- * session_id: null - access/refresh/user: populated
70
- *
71
- * Response model (includes read-only fields).
72
- */
73
- interface OAuthTokenResponse$1 {
74
- /** True if 2FA verification is required */
75
- requires_2fa?: boolean;
76
- /** 2FA session ID (only when requires_2fa=True) */
77
- session_id?: string | null;
78
- /** JWT access token (null when requires_2fa=True) */
79
- access?: string | null;
80
- /** JWT refresh token (null when requires_2fa=True) */
81
- refresh?: string | null;
82
- /** Authenticated user info (null when requires_2fa=True) */
83
- user?: Record<string, any> | null;
84
- /** True if a new user was created during this OAuth flow */
85
- is_new_user: boolean;
86
- /** True if a new OAuth connection was created */
87
- is_new_connection: boolean;
88
- /** True if user should be prompted to enable 2FA */
89
- should_prompt_2fa?: boolean;
90
- }
91
- /**
92
- * Serializer for OAuth connection info (user-facing).
93
- *
94
- * Response model (includes read-only fields).
95
- */
96
- interface OAuthConnection {
97
- id: number;
98
- /** OAuth provider name (github, google, etc.)
99
-
100
- * `github` - GitHub */
101
- provider: OAuthConnectionProvider;
102
- provider_display: string;
103
- /** Username on the OAuth provider platform */
104
- provider_username: string;
105
- /** Email from OAuth provider (may differ from user.email) */
106
- provider_email: string;
107
- /** Avatar URL from OAuth provider */
108
- provider_avatar_url: string;
109
- /** When this OAuth connection was created */
110
- connected_at: string;
111
- /** Last time this OAuth connection was used for login */
112
- last_login_at: string;
113
- }
114
- /**
115
- * Response with OAuth authorization URL.
116
- *
117
- * Response model (includes read-only fields).
118
- */
119
- interface OAuthAuthorizeResponse$1 {
120
- /** Full URL to redirect user to OAuth provider */
121
- authorization_url: string;
122
- /** State token for CSRF protection. Store this and verify on callback. */
123
- state: string;
124
- }
125
- /**
126
- * Request to disconnect OAuth provider.
127
- *
128
- * Request model (no read-only fields).
129
- */
130
- interface OAuthDisconnectRequestRequest$1 {
131
- /** OAuth provider to disconnect
132
-
133
- * `github` - GitHub */
134
- provider: OAuthConnectionProvider;
135
- }
136
- /**
137
- * Response with available OAuth providers.
138
- *
139
- * Response model (includes read-only fields).
140
- */
141
- interface OAuthProvidersResponse {
142
- /** List of available OAuth providers */
143
- providers: Array<Record<string, any>>;
144
- }
145
-
146
- /**
147
- * API endpoints for Oauth.
148
- */
149
- declare class Oauth {
150
- private client;
151
- constructor(client: any);
152
- /**
153
- * List OAuth connections
154
- *
155
- * Get all OAuth connections for the current user.
156
- */
157
- accountsOauthConnectionsList(): Promise<OAuthConnection[]>;
158
- /**
159
- * Disconnect OAuth provider
160
- *
161
- * Remove OAuth connection for the specified provider.
162
- */
163
- accountsOauthDisconnectCreate(data: OAuthDisconnectRequestRequest$1): Promise<any>;
164
- /**
165
- * Start GitHub OAuth
166
- *
167
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to
168
- * start authentication.
169
- */
170
- accountsOauthGithubAuthorizeCreate(data: OAuthAuthorizeRequestRequest$1): Promise<OAuthAuthorizeResponse$1>;
171
- /**
172
- * Complete GitHub OAuth
173
- *
174
- * Exchange authorization code for JWT tokens. Call this after GitHub
175
- * redirects back with code.
176
- */
177
- accountsOauthGithubCallbackCreate(data: OAuthCallbackRequestRequest$1): Promise<OAuthTokenResponse$1>;
178
- /**
179
- * List OAuth providers
180
- *
181
- * Get list of available OAuth providers for authentication.
182
- */
183
- accountsOauthProvidersRetrieve(): Promise<OAuthProvidersResponse>;
184
- }
185
-
186
- /**
187
- * Serializer for updating user profile.
188
- *
189
- * Request model (no read-only fields).
190
- */
191
- interface PatchedUserProfileUpdateRequest$1 {
192
- first_name?: string;
193
- last_name?: string;
194
- company?: string;
195
- phone?: string;
196
- position?: string;
197
- language?: string;
198
- }
199
- /**
200
- *
201
- * Request model (no read-only fields).
202
- */
203
- interface CfgAccountsProfileAvatarCreateRequest$1 {
204
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
205
- avatar: File | Blob;
206
- }
207
- /**
208
- * Response serializer for account deletion.
209
- *
210
- * Response model (includes read-only fields).
211
- */
212
- interface AccountDeleteResponse$1 {
213
- /** Whether the account was successfully deleted */
214
- success: boolean;
215
- /** Human-readable message about the deletion */
216
- message: string;
217
- }
218
- /**
219
- * Serializer for user details.
220
- *
221
- * Response model (includes read-only fields).
222
- */
223
- interface User$2 {
224
- id: number;
225
- email: string;
226
- first_name?: string;
227
- last_name?: string;
228
- /** Get user's full name. */
229
- full_name: string;
230
- /** Get user's initials for avatar fallback. */
231
- initials: string;
232
- /** Get formatted username for display. */
233
- display_username: string;
234
- company?: string;
235
- phone?: string;
236
- position?: string;
237
- language?: string;
238
- avatar?: string | null;
239
- /** Designates whether the user can log into this admin site. */
240
- is_staff: boolean;
241
- /** Designates that this user has all permissions without explicitly assigning them. */
242
- is_superuser: boolean;
243
- date_joined: string;
244
- last_login?: string | null;
245
- unanswered_messages_count: number;
246
- centrifugo: CentrifugoToken$1 | null;
247
- }
248
- /**
249
- * Serializer for updating user profile.
250
- *
251
- * Request model (no read-only fields).
252
- */
253
- interface UserProfileUpdateRequest$1 {
254
- first_name?: string;
255
- last_name?: string;
256
- company?: string;
257
- phone?: string;
258
- position?: string;
259
- language?: string;
260
- }
261
- /**
262
- * Nested serializer for Centrifugo WebSocket connection token.
263
- *
264
- * Response model (includes read-only fields).
265
- */
266
- interface CentrifugoToken$1 {
267
- /** JWT token for Centrifugo WebSocket connection */
268
- token: string;
269
- /** Centrifugo WebSocket URL */
270
- centrifugo_url: string;
271
- /** Token expiration time (ISO 8601) */
272
- expires_at: string;
273
- /** List of allowed channels for this user */
274
- channels: Array<string>;
275
- }
276
-
277
- /**
278
- * API endpoints for User Profile.
279
- */
280
- declare class UserProfile {
281
- private client;
282
- constructor(client: any);
283
- /**
284
- * Get current user profile
285
- *
286
- * Retrieve the current authenticated user's profile information.
287
- */
288
- accountsProfileRetrieve(): Promise<User$2>;
289
- /**
290
- * Upload user avatar
291
- *
292
- * Upload avatar image for the current authenticated user. Accepts
293
- * multipart/form-data with 'avatar' field.
294
- */
295
- accountsProfileAvatarCreate(data: CfgAccountsProfileAvatarCreateRequest$1): Promise<User$2>;
296
- /**
297
- * Delete user account
298
- *
299
- * Permanently delete the current user's account. This operation: -
300
- * Deactivates the account (user cannot log in) - Anonymizes personal data
301
- * (GDPR compliance) - Frees up the email address for re-registration -
302
- * Preserves audit trail The account can be restored by an administrator if
303
- * needed.
304
- */
305
- accountsProfileDeleteCreate(): Promise<AccountDeleteResponse$1>;
306
- /**
307
- * Partial update user profile
308
- *
309
- * Partially update the current authenticated user's profile information.
310
- * Supports avatar upload.
311
- */
312
- accountsProfilePartialUpdate(data: UserProfileUpdateRequest$1): Promise<User$2>;
313
- /**
314
- * Partial update user profile
315
- *
316
- * Partially update the current authenticated user's profile information.
317
- * Supports avatar upload.
318
- */
319
- accountsProfilePartialPartialUpdate(data?: PatchedUserProfileUpdateRequest$1): Promise<User$2>;
320
- /**
321
- * Update user profile
322
- *
323
- * Update the current authenticated user's profile information.
324
- */
325
- accountsProfileUpdateUpdate(data: UserProfileUpdateRequest$1): Promise<User$2>;
326
- /**
327
- * Update user profile
328
- *
329
- * Update the current authenticated user's profile information.
330
- */
331
- accountsProfileUpdatePartialUpdate(data?: PatchedUserProfileUpdateRequest$1): Promise<User$2>;
332
- }
333
-
334
- /**
335
- * OTP verification response. When 2FA is required: - requires_2fa: True -
336
- * session_id: UUID of 2FA verification session - refresh/access/user: null
337
- * When 2FA is not required: - requires_2fa: False - session_id: null -
338
- * refresh/access/user: populated
339
- *
340
- * Response model (includes read-only fields).
341
- */
342
- interface OTPVerifyResponse$1 {
343
- /** Whether 2FA verification is required */
344
- requires_2fa?: boolean;
345
- /** 2FA session ID (if requires_2fa is True) */
346
- session_id?: string | null;
347
- /** JWT refresh token (if requires_2fa is False) */
348
- refresh?: string | null;
349
- /** JWT access token (if requires_2fa is False) */
350
- access?: string | null;
351
- user?: User$1 | null;
352
- /** Whether user should be prompted to enable 2FA */
353
- should_prompt_2fa?: boolean;
354
- }
355
- /**
356
- * OTP request response.
357
- *
358
- * Response model (includes read-only fields).
359
- */
360
- interface OTPRequestResponse$1 {
361
- /** Success message */
362
- message: string;
363
- }
364
- /**
365
- * Serializer for OTP verification.
366
- *
367
- * Request model (no read-only fields).
368
- */
369
- interface OTPVerifyRequest$1 {
370
- /** Email address used for OTP request */
371
- identifier: string;
372
- otp: string;
373
- /** Source URL for tracking login (e.g., https://my.djangocfg.com) */
374
- source_url?: string;
375
- }
376
- /**
377
- * Serializer for OTP request.
378
- *
379
- * Request model (no read-only fields).
380
- */
381
- interface OTPRequestRequest$1 {
382
- /** Email address for OTP delivery */
383
- identifier: string;
384
- /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
385
- source_url?: string;
386
- }
387
- /**
388
- * Serializer for user details.
389
- *
390
- * Response model (includes read-only fields).
391
- */
392
- interface User$1 {
393
- id: number;
394
- email: string;
395
- first_name?: string;
396
- last_name?: string;
397
- /** Get user's full name. */
398
- full_name: string;
399
- /** Get user's initials for avatar fallback. */
400
- initials: string;
401
- /** Get formatted username for display. */
402
- display_username: string;
403
- company?: string;
404
- phone?: string;
405
- position?: string;
406
- language?: string;
407
- avatar?: string | null;
408
- /** Designates whether the user can log into this admin site. */
409
- is_staff: boolean;
410
- /** Designates that this user has all permissions without explicitly assigning them. */
411
- is_superuser: boolean;
412
- date_joined: string;
413
- last_login?: string | null;
414
- unanswered_messages_count: number;
415
- centrifugo: CentrifugoToken | null;
416
- }
417
- /**
418
- * Nested serializer for Centrifugo WebSocket connection token.
419
- *
420
- * Response model (includes read-only fields).
421
- */
422
- interface CentrifugoToken {
423
- /** JWT token for Centrifugo WebSocket connection */
424
- token: string;
425
- /** Centrifugo WebSocket URL */
426
- centrifugo_url: string;
427
- /** Token expiration time (ISO 8601) */
428
- expires_at: string;
429
- /** List of allowed channels for this user */
430
- channels: Array<string>;
431
- }
432
-
433
- /**
434
- * API endpoints for Accounts.
435
- */
436
- declare class Accounts {
437
- private client;
438
- constructor(client: any);
439
- /**
440
- * Request OTP code to email.
441
- */
442
- otpRequestCreate(data: OTPRequestRequest$1): Promise<OTPRequestResponse$1>;
443
- /**
444
- * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
445
- * enabled: - Returns requires_2fa=True with session_id - Client must
446
- * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
447
- * Returns JWT tokens and user data directly
448
- */
449
- otpVerifyCreate(data: OTPVerifyRequest$1): Promise<OTPVerifyResponse$1>;
450
- }
451
-
452
- /**
453
- * API Logger with Consola
454
- * Beautiful console logging for API requests and responses
455
- *
456
- * Installation:
457
- * npm install consola
458
- */
459
-
460
- /**
461
- * Logger configuration
462
- */
463
- interface LoggerConfig {
464
- /** Enable logging */
465
- enabled: boolean;
466
- /** Log requests */
467
- logRequests: boolean;
468
- /** Log responses */
469
- logResponses: boolean;
470
- /** Log errors */
471
- logErrors: boolean;
472
- /** Log request/response bodies */
473
- logBodies: boolean;
474
- /** Log headers (excluding sensitive ones) */
475
- logHeaders: boolean;
476
- /** Custom consola instance */
477
- consola?: ConsolaInstance;
478
- }
479
-
480
- /**
481
- * Retry Configuration and Utilities
482
- *
483
- * Provides automatic retry logic for failed HTTP requests using p-retry.
484
- * Retries only on network errors and server errors (5xx), not client errors (4xx).
485
- */
486
- /**
487
- * Information about a failed retry attempt.
488
- */
489
- interface FailedAttemptInfo {
490
- /** The error that caused the failure */
491
- error: Error;
492
- /** The attempt number (1-indexed) */
493
- attemptNumber: number;
494
- /** Number of retries left */
495
- retriesLeft: number;
496
- }
497
- /**
498
- * Retry configuration options.
499
- *
500
- * Uses exponential backoff with jitter by default to avoid thundering herd.
501
- */
502
- interface RetryConfig {
503
- /**
504
- * Maximum number of retry attempts.
505
- * @default 3
506
- */
507
- retries?: number;
508
- /**
509
- * Exponential backoff factor.
510
- * @default 2
511
- */
512
- factor?: number;
513
- /**
514
- * Minimum wait time between retries (ms).
515
- * @default 1000
516
- */
517
- minTimeout?: number;
518
- /**
519
- * Maximum wait time between retries (ms).
520
- * @default 60000
521
- */
522
- maxTimeout?: number;
523
- /**
524
- * Add randomness to wait times (jitter).
525
- * Helps avoid thundering herd problem.
526
- * @default true
527
- */
528
- randomize?: boolean;
529
- /**
530
- * Callback called on each failed attempt.
531
- */
532
- onFailedAttempt?: (info: FailedAttemptInfo) => void;
533
- }
534
-
535
- /**
536
- * Storage adapters for cross-platform token storage.
537
- *
538
- * Supports:
539
- * - LocalStorage (browser)
540
- * - Cookies (SSR/browser)
541
- * - Memory (Node.js/Electron/testing)
542
- */
543
-
544
- /**
545
- * Storage adapter interface for cross-platform token storage.
546
- */
547
- interface StorageAdapter {
548
- getItem(key: string): string | null;
549
- setItem(key: string, value: string): void;
550
- removeItem(key: string): void;
551
- }
552
-
553
- /**
554
- * Zod schema for AccountDeleteResponse
555
- *
556
- * This schema provides runtime validation and type inference.
557
- * * Response serializer for account deletion.
558
- * */
559
-
560
- /**
561
- * Response serializer for account deletion.
562
- */
563
- declare const AccountDeleteResponseSchema: z.ZodObject<{
564
- success: z.ZodBoolean;
565
- message: z.ZodString;
566
- }, z.core.$strip>;
567
- /**
568
- * Infer TypeScript type from Zod schema
569
- */
570
- type AccountDeleteResponse = z.infer<typeof AccountDeleteResponseSchema>;
571
-
572
- /**
573
- * Zod schema for CfgAccountsProfileAvatarCreateRequest
574
- *
575
- * This schema provides runtime validation and type inference.
576
- * */
577
-
578
- declare const CfgAccountsProfileAvatarCreateRequestSchema: z.ZodObject<{
579
- avatar: z.ZodUnion<readonly [z.ZodCustom<File, File>, z.ZodCustom<Blob, Blob>]>;
580
- }, z.core.$strip>;
581
- /**
582
- * Infer TypeScript type from Zod schema
583
- */
584
- type CfgAccountsProfileAvatarCreateRequest = z.infer<typeof CfgAccountsProfileAvatarCreateRequestSchema>;
585
-
586
- /**
587
- * Zod schema for OAuthAuthorizeRequestRequest
588
- *
589
- * This schema provides runtime validation and type inference.
590
- * * Request to start OAuth flow.
591
- * */
592
-
593
- /**
594
- * Request to start OAuth flow.
595
- */
596
- declare const OAuthAuthorizeRequestRequestSchema: z.ZodObject<{
597
- redirect_uri: z.ZodOptional<z.ZodString>;
598
- source_url: z.ZodOptional<z.ZodString>;
599
- }, z.core.$strip>;
600
- /**
601
- * Infer TypeScript type from Zod schema
602
- */
603
- type OAuthAuthorizeRequestRequest = z.infer<typeof OAuthAuthorizeRequestRequestSchema>;
604
-
605
- /**
606
- * Zod schema for OAuthAuthorizeResponse
607
- *
608
- * This schema provides runtime validation and type inference.
609
- * * Response with OAuth authorization URL.
610
- * */
611
-
612
- /**
613
- * Response with OAuth authorization URL.
614
- */
615
- declare const OAuthAuthorizeResponseSchema: z.ZodObject<{
616
- authorization_url: z.ZodString;
617
- state: z.ZodString;
618
- }, z.core.$strip>;
619
- /**
620
- * Infer TypeScript type from Zod schema
621
- */
622
- type OAuthAuthorizeResponse = z.infer<typeof OAuthAuthorizeResponseSchema>;
623
-
624
- /**
625
- * Zod schema for OAuthCallbackRequestRequest
626
- *
627
- * This schema provides runtime validation and type inference.
628
- * * Request to complete OAuth flow (callback handler).
629
- * */
630
-
631
- /**
632
- * Request to complete OAuth flow (callback handler).
633
- */
634
- declare const OAuthCallbackRequestRequestSchema: z.ZodObject<{
635
- code: z.ZodString;
636
- state: z.ZodString;
637
- redirect_uri: z.ZodOptional<z.ZodString>;
638
- }, z.core.$strip>;
639
- /**
640
- * Infer TypeScript type from Zod schema
641
- */
642
- type OAuthCallbackRequestRequest = z.infer<typeof OAuthCallbackRequestRequestSchema>;
643
-
644
- /**
645
- * Zod schema for OAuthDisconnectRequestRequest
646
- *
647
- * This schema provides runtime validation and type inference.
648
- * * Request to disconnect OAuth provider.
649
- * */
650
-
651
- /**
652
- * Request to disconnect OAuth provider.
653
- */
654
- declare const OAuthDisconnectRequestRequestSchema: z.ZodObject<{
655
- provider: z.ZodEnum<typeof OAuthConnectionProvider>;
656
- }, z.core.$strip>;
657
- /**
658
- * Infer TypeScript type from Zod schema
659
- */
660
- type OAuthDisconnectRequestRequest = z.infer<typeof OAuthDisconnectRequestRequestSchema>;
661
-
662
- /**
663
- * Zod schema for OAuthTokenResponse
664
- *
665
- * This schema provides runtime validation and type inference.
666
- * * Response with JWT tokens after OAuth authentication.
667
-
668
- When 2FA is required:
669
- - requires_2fa: True
670
- - session_id: UUID of 2FA verification session
671
- - access/refresh/user: null
672
-
673
- When 2FA is not required:
674
- - requires_2fa: False
675
- - session_id: null
676
- - access/refresh/user: populated
677
- * */
678
-
679
- /**
680
- * Response with JWT tokens after OAuth authentication.
681
-
682
- When 2FA is required:
683
- - requires_2fa: True
684
- - session_id: UUID of 2FA verification session
685
- - access/refresh/user: null
686
-
687
- When 2FA is not required:
688
- - requires_2fa: False
689
- - session_id: null
690
- - access/refresh/user: populated
691
- */
692
- declare const OAuthTokenResponseSchema: z.ZodObject<{
693
- requires_2fa: z.ZodOptional<z.ZodBoolean>;
694
- session_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
695
- access: z.ZodOptional<z.ZodNullable<z.ZodString>>;
696
- refresh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
697
- user: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodAny>>>;
698
- is_new_user: z.ZodBoolean;
699
- is_new_connection: z.ZodBoolean;
700
- should_prompt_2fa: z.ZodOptional<z.ZodBoolean>;
701
- }, z.core.$strip>;
702
- /**
703
- * Infer TypeScript type from Zod schema
704
- */
705
- type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
706
-
707
- /**
708
- * Zod schema for OTPRequestRequest
709
- *
710
- * This schema provides runtime validation and type inference.
711
- * * Serializer for OTP request.
712
- * */
713
-
714
- /**
715
- * Serializer for OTP request.
716
- */
717
- declare const OTPRequestRequestSchema: z.ZodObject<{
718
- identifier: z.ZodString;
719
- source_url: z.ZodOptional<z.ZodString>;
720
- }, z.core.$strip>;
721
- /**
722
- * Infer TypeScript type from Zod schema
723
- */
724
- type OTPRequestRequest = z.infer<typeof OTPRequestRequestSchema>;
725
-
726
- /**
727
- * Zod schema for OTPRequestResponse
728
- *
729
- * This schema provides runtime validation and type inference.
730
- * * OTP request response.
731
- * */
732
-
733
- /**
734
- * OTP request response.
735
- */
736
- declare const OTPRequestResponseSchema: z.ZodObject<{
737
- message: z.ZodString;
738
- }, z.core.$strip>;
739
- /**
740
- * Infer TypeScript type from Zod schema
741
- */
742
- type OTPRequestResponse = z.infer<typeof OTPRequestResponseSchema>;
743
-
744
- /**
745
- * Zod schema for OTPVerifyRequest
746
- *
747
- * This schema provides runtime validation and type inference.
748
- * * Serializer for OTP verification.
749
- * */
750
-
751
- /**
752
- * Serializer for OTP verification.
753
- */
754
- declare const OTPVerifyRequestSchema: z.ZodObject<{
755
- identifier: z.ZodString;
756
- otp: z.ZodString;
757
- source_url: z.ZodOptional<z.ZodString>;
758
- }, z.core.$strip>;
759
- /**
760
- * Infer TypeScript type from Zod schema
761
- */
762
- type OTPVerifyRequest = z.infer<typeof OTPVerifyRequestSchema>;
763
-
764
- /**
765
- * Zod schema for OTPVerifyResponse
766
- *
767
- * This schema provides runtime validation and type inference.
768
- * * OTP verification response.
769
-
770
- When 2FA is required:
771
- - requires_2fa: True
772
- - session_id: UUID of 2FA verification session
773
- - refresh/access/user: null
774
-
775
- When 2FA is not required:
776
- - requires_2fa: False
777
- - session_id: null
778
- - refresh/access/user: populated
779
- * */
780
-
781
- /**
782
- * OTP verification response.
783
-
784
- When 2FA is required:
785
- - requires_2fa: True
786
- - session_id: UUID of 2FA verification session
787
- - refresh/access/user: null
788
-
789
- When 2FA is not required:
790
- - requires_2fa: False
791
- - session_id: null
792
- - refresh/access/user: populated
793
- */
794
- declare const OTPVerifyResponseSchema: z.ZodObject<{
795
- requires_2fa: z.ZodOptional<z.ZodBoolean>;
796
- session_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
797
- refresh: z.ZodOptional<z.ZodNullable<z.ZodString>>;
798
- access: z.ZodOptional<z.ZodNullable<z.ZodString>>;
799
- user: z.ZodOptional<z.ZodNullable<z.ZodObject<{
800
- id: z.ZodNumber;
801
- email: z.ZodEmail;
802
- first_name: z.ZodOptional<z.ZodString>;
803
- last_name: z.ZodOptional<z.ZodString>;
804
- full_name: z.ZodString;
805
- initials: z.ZodString;
806
- display_username: z.ZodString;
807
- company: z.ZodOptional<z.ZodString>;
808
- phone: z.ZodOptional<z.ZodString>;
809
- position: z.ZodOptional<z.ZodString>;
810
- language: z.ZodOptional<z.ZodString>;
811
- avatar: z.ZodNullable<z.ZodString>;
812
- is_staff: z.ZodBoolean;
813
- is_superuser: z.ZodBoolean;
814
- date_joined: z.ZodString;
815
- last_login: z.ZodNullable<z.ZodString>;
816
- unanswered_messages_count: z.ZodNumber;
817
- centrifugo: z.ZodNullable<z.ZodObject<{
818
- token: z.ZodString;
819
- centrifugo_url: z.ZodString;
820
- expires_at: z.ZodString;
821
- channels: z.ZodArray<z.ZodString>;
822
- }, z.core.$strip>>;
823
- }, z.core.$strip>>>;
824
- should_prompt_2fa: z.ZodOptional<z.ZodBoolean>;
825
- }, z.core.$strip>;
826
- /**
827
- * Infer TypeScript type from Zod schema
828
- */
829
- type OTPVerifyResponse = z.infer<typeof OTPVerifyResponseSchema>;
830
-
831
- /**
832
- * Zod schema for PatchedUserProfileUpdateRequest
833
- *
834
- * This schema provides runtime validation and type inference.
835
- * * Serializer for updating user profile.
836
- * */
837
-
838
- /**
839
- * Serializer for updating user profile.
840
- */
841
- declare const PatchedUserProfileUpdateRequestSchema: z.ZodObject<{
842
- first_name: z.ZodOptional<z.ZodString>;
843
- last_name: z.ZodOptional<z.ZodString>;
844
- company: z.ZodOptional<z.ZodString>;
845
- phone: z.ZodOptional<z.ZodString>;
846
- position: z.ZodOptional<z.ZodString>;
847
- language: z.ZodOptional<z.ZodString>;
848
- }, z.core.$strip>;
849
- /**
850
- * Infer TypeScript type from Zod schema
851
- */
852
- type PatchedUserProfileUpdateRequest = z.infer<typeof PatchedUserProfileUpdateRequestSchema>;
853
-
854
- /**
855
- * Zod schema for TokenRefresh
856
- *
857
- * This schema provides runtime validation and type inference.
858
- * */
859
-
860
- declare const TokenRefreshSchema: z.ZodObject<{
861
- access: z.ZodString;
862
- refresh: z.ZodString;
863
- }, z.core.$strip>;
864
- /**
865
- * Infer TypeScript type from Zod schema
866
- */
867
- type TokenRefresh = z.infer<typeof TokenRefreshSchema>;
868
-
869
- /**
870
- * Zod schema for TokenRefreshRequest
871
- *
872
- * This schema provides runtime validation and type inference.
873
- * */
874
-
875
- declare const TokenRefreshRequestSchema: z.ZodObject<{
876
- refresh: z.ZodString;
877
- }, z.core.$strip>;
878
- /**
879
- * Infer TypeScript type from Zod schema
880
- */
881
- type TokenRefreshRequest = z.infer<typeof TokenRefreshRequestSchema>;
882
-
883
- /**
884
- * Zod schema for User
885
- *
886
- * This schema provides runtime validation and type inference.
887
- * * Serializer for user details.
888
- * */
889
-
890
- /**
891
- * Serializer for user details.
892
- */
893
- declare const UserSchema: z.ZodObject<{
894
- id: z.ZodNumber;
895
- email: z.ZodEmail;
896
- first_name: z.ZodOptional<z.ZodString>;
897
- last_name: z.ZodOptional<z.ZodString>;
898
- full_name: z.ZodString;
899
- initials: z.ZodString;
900
- display_username: z.ZodString;
901
- company: z.ZodOptional<z.ZodString>;
902
- phone: z.ZodOptional<z.ZodString>;
903
- position: z.ZodOptional<z.ZodString>;
904
- language: z.ZodOptional<z.ZodString>;
905
- avatar: z.ZodNullable<z.ZodString>;
906
- is_staff: z.ZodBoolean;
907
- is_superuser: z.ZodBoolean;
908
- date_joined: z.ZodString;
909
- last_login: z.ZodNullable<z.ZodString>;
910
- unanswered_messages_count: z.ZodNumber;
911
- centrifugo: z.ZodNullable<z.ZodObject<{
912
- token: z.ZodString;
913
- centrifugo_url: z.ZodString;
914
- expires_at: z.ZodString;
915
- channels: z.ZodArray<z.ZodString>;
916
- }, z.core.$strip>>;
917
- }, z.core.$strip>;
918
- /**
919
- * Infer TypeScript type from Zod schema
920
- */
921
- type User = z.infer<typeof UserSchema>;
922
-
923
- /**
924
- * Zod schema for UserProfileUpdateRequest
925
- *
926
- * This schema provides runtime validation and type inference.
927
- * * Serializer for updating user profile.
928
- * */
929
-
930
- /**
931
- * Serializer for updating user profile.
932
- */
933
- declare const UserProfileUpdateRequestSchema: z.ZodObject<{
934
- first_name: z.ZodOptional<z.ZodString>;
935
- last_name: z.ZodOptional<z.ZodString>;
936
- company: z.ZodOptional<z.ZodString>;
937
- phone: z.ZodOptional<z.ZodString>;
938
- position: z.ZodOptional<z.ZodString>;
939
- language: z.ZodOptional<z.ZodString>;
940
- }, z.core.$strip>;
941
- /**
942
- * Infer TypeScript type from Zod schema
943
- */
944
- type UserProfileUpdateRequest = z.infer<typeof UserProfileUpdateRequestSchema>;
945
-
946
- /**
947
- * Django CFG API - API Client with JWT Management
948
- *
949
- * Usage:
950
- * ```typescript
951
- * import { API } from './api';
952
- *
953
- * const api = new API('https://api.example.com');
954
- *
955
- * // Set JWT token
956
- * api.setToken('your-jwt-token', 'refresh-token');
957
- *
958
- * // Use API
959
- * const posts = await api.posts.list();
960
- * const user = await api.users.retrieve(1);
961
- *
962
- * // Check authentication
963
- * if (api.isAuthenticated()) {
964
- * // ...
965
- * }
966
- *
967
- * // Custom storage with logging (for Electron/Node.js)
968
- * import { MemoryStorageAdapter, APILogger } from './storage';
969
- * const logger = new APILogger({ enabled: true, logLevel: 'debug' });
970
- * const api = new API('https://api.example.com', {
971
- * storage: new MemoryStorageAdapter(logger),
972
- * loggerConfig: { enabled: true, logLevel: 'debug' }
973
- * });
974
- *
975
- * // Get OpenAPI schema
976
- * const schema = api.getSchema();
977
- * ```
978
- */
979
-
980
- interface APIOptions {
981
- /** Custom storage adapter (defaults to LocalStorageAdapter) */
982
- storage?: StorageAdapter;
983
- /** Custom HTTP client adapter (defaults to FetchAdapter) */
984
- httpClient?: HttpClientAdapter;
985
- /** Retry configuration for failed requests */
986
- retryConfig?: RetryConfig;
987
- /** Logger configuration */
988
- loggerConfig?: Partial<LoggerConfig>;
989
- /** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
990
- locale?: string;
991
- }
992
- declare class API {
993
- private baseUrl;
994
- private _client;
995
- private _token;
996
- private _refreshToken;
997
- private _locale;
998
- private storage;
999
- private options?;
1000
- auth: Auth;
1001
- oauth: Oauth;
1002
- user_profile: UserProfile;
1003
- accounts: Accounts;
1004
- constructor(baseUrl: string, options?: APIOptions);
1005
- private _loadTokensFromStorage;
1006
- private _reinitClients;
1007
- private _injectAuthHeader;
1008
- /**
1009
- * Get current JWT token
1010
- */
1011
- getToken(): string | null;
1012
- /**
1013
- * Get current refresh token
1014
- */
1015
- getRefreshToken(): string | null;
1016
- /**
1017
- * Set JWT token and refresh token
1018
- * @param token - JWT access token
1019
- * @param refreshToken - JWT refresh token (optional)
1020
- */
1021
- setToken(token: string, refreshToken?: string): void;
1022
- /**
1023
- * Clear all tokens
1024
- */
1025
- clearTokens(): void;
1026
- /**
1027
- * Check if user is authenticated
1028
- */
1029
- isAuthenticated(): boolean;
1030
- /**
1031
- * Update base URL and reinitialize clients
1032
- * @param url - New base URL
1033
- */
1034
- setBaseUrl(url: string): void;
1035
- /**
1036
- * Get current base URL
1037
- */
1038
- getBaseUrl(): string;
1039
- /**
1040
- * Set locale for Accept-Language header
1041
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
1042
- */
1043
- setLocale(locale: string | null): void;
1044
- /**
1045
- * Get current locale
1046
- */
1047
- getLocale(): string | null;
1048
- /**
1049
- * Get OpenAPI schema path
1050
- * @returns Path to the OpenAPI schema JSON file
1051
- *
1052
- * Note: The OpenAPI schema is available in the schema.json file.
1053
- * You can load it dynamically using:
1054
- * ```typescript
1055
- * const schema = await fetch('./schema.json').then(r => r.json());
1056
- * // or using fs in Node.js:
1057
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1058
- * ```
1059
- */
1060
- getSchemaPath(): string;
1061
- }
1062
-
1063
- /**
1064
- * API operation
1065
- *
1066
- * @method POST
1067
- * @path /cfg/accounts/token/refresh/
1068
- */
1069
- declare function useCreateAccountsTokenRefreshCreate(): (data: TokenRefreshRequest, client?: API) => Promise<TokenRefresh>;
1070
-
1071
- /**
1072
- * SWR Hooks for Oauth
1073
- *
1074
- * React hooks powered by SWR for data fetching with automatic caching,
1075
- * revalidation, and optimistic updates.
1076
- *
1077
- * Usage:
1078
- * ```typescript
1079
- * // Query hooks (GET)
1080
- * const { data, error, isLoading } = useUsers({ page: 1 })
1081
- *
1082
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
1083
- * const createUser = useCreateUser()
1084
- * await createUser({ name: 'John', email: 'john@example.com' })
1085
- * ```
1086
- */
1087
-
1088
- /**
1089
- * List OAuth connections
1090
- *
1091
- * @method GET
1092
- * @path /cfg/accounts/oauth/connections/
1093
- */
1094
- declare function useAccountsOauthConnectionsList(client?: API): ReturnType<typeof useSWR<OAuthConnection[]>>;
1095
- /**
1096
- * Disconnect OAuth provider
1097
- *
1098
- * @method POST
1099
- * @path /cfg/accounts/oauth/disconnect/
1100
- */
1101
- declare function useCreateAccountsOauthDisconnectCreate(): (data: OAuthDisconnectRequestRequest, client?: API) => Promise<any>;
1102
- /**
1103
- * Start GitHub OAuth
1104
- *
1105
- * @method POST
1106
- * @path /cfg/accounts/oauth/github/authorize/
1107
- */
1108
- declare function useCreateAccountsOauthGithubAuthorizeCreate(): (data: OAuthAuthorizeRequestRequest, client?: API) => Promise<OAuthAuthorizeResponse>;
1109
- /**
1110
- * Complete GitHub OAuth
1111
- *
1112
- * @method POST
1113
- * @path /cfg/accounts/oauth/github/callback/
1114
- */
1115
- declare function useCreateAccountsOauthGithubCallbackCreate(): (data: OAuthCallbackRequestRequest, client?: API) => Promise<OAuthTokenResponse>;
1116
- /**
1117
- * List OAuth providers
1118
- *
1119
- * @method GET
1120
- * @path /cfg/accounts/oauth/providers/
1121
- */
1122
- declare function useAccountsOauthProvidersRetrieve(client?: API): ReturnType<typeof useSWR<OAuthProvidersResponse>>;
1123
-
1124
- /**
1125
- * SWR Hooks for User Profile
1126
- *
1127
- * React hooks powered by SWR for data fetching with automatic caching,
1128
- * revalidation, and optimistic updates.
1129
- *
1130
- * Usage:
1131
- * ```typescript
1132
- * // Query hooks (GET)
1133
- * const { data, error, isLoading } = useUsers({ page: 1 })
1134
- *
1135
- * // Mutation hooks (POST/PUT/PATCH/DELETE)
1136
- * const createUser = useCreateUser()
1137
- * await createUser({ name: 'John', email: 'john@example.com' })
1138
- * ```
1139
- */
1140
-
1141
- /**
1142
- * Get current user profile
1143
- *
1144
- * @method GET
1145
- * @path /cfg/accounts/profile/
1146
- */
1147
- declare function useAccountsProfileRetrieve(client?: API): ReturnType<typeof useSWR<User>>;
1148
- /**
1149
- * Upload user avatar
1150
- *
1151
- * @method POST
1152
- * @path /cfg/accounts/profile/avatar/
1153
- */
1154
- declare function useCreateAccountsProfileAvatarCreate(): (data: CfgAccountsProfileAvatarCreateRequest, client?: API) => Promise<User>;
1155
- /**
1156
- * Delete user account
1157
- *
1158
- * @method POST
1159
- * @path /cfg/accounts/profile/delete/
1160
- */
1161
- declare function useCreateAccountsProfileDeleteCreate(): (client?: API) => Promise<AccountDeleteResponse>;
1162
- /**
1163
- * Partial update user profile
1164
- *
1165
- * @method PUT
1166
- * @path /cfg/accounts/profile/partial/
1167
- */
1168
- declare function usePartialUpdateAccountsProfilePartialUpdate(): (data: UserProfileUpdateRequest, client?: API) => Promise<User>;
1169
- /**
1170
- * Partial update user profile
1171
- *
1172
- * @method PATCH
1173
- * @path /cfg/accounts/profile/partial/
1174
- */
1175
- declare function usePartialUpdateAccountsProfilePartialPartialUpdate(): (data?: PatchedUserProfileUpdateRequest, client?: API) => Promise<User>;
1176
- /**
1177
- * Update user profile
1178
- *
1179
- * @method PUT
1180
- * @path /cfg/accounts/profile/update/
1181
- */
1182
- declare function useUpdateAccountsProfileUpdateUpdate(): (data: UserProfileUpdateRequest, client?: API) => Promise<User>;
1183
- /**
1184
- * Update user profile
1185
- *
1186
- * @method PATCH
1187
- * @path /cfg/accounts/profile/update/
1188
- */
1189
- declare function usePartialUpdateAccountsProfileUpdatePartialUpdate(): (data?: PatchedUserProfileUpdateRequest, client?: API) => Promise<User>;
1190
-
1191
- /**
1192
- * API operation
1193
- *
1194
- * @method POST
1195
- * @path /cfg/accounts/otp/request/
1196
- */
1197
- declare function useCreateAccountsOtpRequestCreate(): (data: OTPRequestRequest, client?: API) => Promise<OTPRequestResponse>;
1198
- /**
1199
- * API operation
1200
- *
1201
- * @method POST
1202
- * @path /cfg/accounts/otp/verify/
1203
- */
1204
- declare function useCreateAccountsOtpVerifyCreate(): (data: OTPVerifyRequest, client?: API) => Promise<OTPVerifyResponse>;
1205
-
1206
- export { useAccountsOauthConnectionsList, useAccountsOauthProvidersRetrieve, useAccountsProfileRetrieve, useCreateAccountsOauthDisconnectCreate, useCreateAccountsOauthGithubAuthorizeCreate, useCreateAccountsOauthGithubCallbackCreate, useCreateAccountsOtpRequestCreate, useCreateAccountsOtpVerifyCreate, useCreateAccountsProfileAvatarCreate, useCreateAccountsProfileDeleteCreate, useCreateAccountsTokenRefreshCreate, usePartialUpdateAccountsProfilePartialPartialUpdate, usePartialUpdateAccountsProfilePartialUpdate, usePartialUpdateAccountsProfileUpdatePartialUpdate, useUpdateAccountsProfileUpdateUpdate };
1
+ interface ApiKeyTestResult {
2
+ valid: boolean;
3
+ userId: string | null;
4
+ }
5
+ interface UseApiKeyReturn {
6
+ apiKey: string | null;
7
+ reissuedAt: string | null;
8
+ createdAt: string | null;
9
+ isLoading: boolean;
10
+ isRegenerating: boolean;
11
+ isTesting: boolean;
12
+ regenerate: () => Promise<void>;
13
+ testKey: (key: string) => Promise<ApiKeyTestResult>;
14
+ refresh: () => void;
15
+ }
16
+ declare function useApiKey(): UseApiKeyReturn;
17
+
18
+ export { type UseApiKeyReturn, useApiKey };