@djangocfg/api 2.1.322 → 2.1.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth-server.cjs +1037 -1227
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +1037 -1217
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +2142 -3398
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +158 -209
- package/dist/auth.d.ts +158 -209
- package/dist/auth.mjs +2136 -3392
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1018 -4423
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +151 -2918
- package/dist/clients.d.ts +151 -2918
- package/dist/clients.mjs +1018 -4417
- package/dist/clients.mjs.map +1 -1
- package/dist/index.cjs +2253 -2819
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2408 -1872
- package/dist/index.d.ts +2408 -1872
- package/dist/index.mjs +2235 -2795
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -7
- package/src/_api/generated/_cfg_accounts/api.ts +120 -0
- package/src/_api/generated/_cfg_accounts/events.ts +198 -0
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +18 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +25 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +25 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +25 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +24 -0
- package/src/_api/generated/_cfg_accounts/index.ts +29 -0
- package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +14 -0
- package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +16 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +19 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthError.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts +11 -0
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +18 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +11 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +17 -0
- package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +16 -0
- package/src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts +9 -0
- package/src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts +11 -0
- package/src/_api/generated/{cfg_accounts/_utils/schemas/User.schema.ts → _cfg_accounts/schemas/User.ts} +19 -27
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +24 -0
- package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
- package/src/_api/generated/_cfg_centrifugo/api.ts +120 -0
- package/src/_api/generated/_cfg_centrifugo/events.ts +198 -0
- package/src/_api/generated/_cfg_centrifugo/hooks/index.ts +4 -0
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +25 -0
- package/src/_api/generated/_cfg_centrifugo/index.ts +29 -0
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +14 -0
- package/src/_api/generated/_cfg_centrifugo/schemas/index.ts +4 -0
- package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
- package/src/_api/generated/_cfg_totp/api.ts +120 -0
- package/src/_api/generated/_cfg_totp/events.ts +198 -0
- package/src/_api/generated/_cfg_totp/hooks/index.ts +12 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +25 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +25 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +24 -0
- package/src/_api/generated/_cfg_totp/index.ts +29 -0
- package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateRequest.ts +11 -0
- package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateResponse.ts +12 -0
- package/src/_api/generated/_cfg_totp/schemas/BackupCodesStatus.ts +13 -0
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +12 -0
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +13 -0
- package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +18 -0
- package/src/_api/generated/_cfg_totp/schemas/DeviceListResponse.ts +13 -0
- package/src/_api/generated/_cfg_totp/schemas/DeviceListStatusEnum.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/DisableRequest.ts +11 -0
- package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
- package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +15 -0
- package/src/_api/generated/{cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts → _cfg_totp/schemas/TotpVerifyUser.ts} +17 -25
- package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +12 -0
- package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +12 -0
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +17 -0
- package/src/_api/generated/_cfg_totp/schemas/index.ts +18 -0
- package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
- package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
- package/src/_api/generated/client/client.gen.ts +280 -0
- package/src/_api/generated/client/index.ts +25 -0
- package/src/_api/generated/client/types.gen.ts +217 -0
- package/src/_api/generated/client/utils.gen.ts +318 -0
- package/src/_api/generated/client.gen.ts +16 -0
- package/src/_api/generated/core/auth.gen.ts +41 -0
- package/src/_api/generated/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/core/params.gen.ts +169 -0
- package/src/_api/generated/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/core/types.gen.ts +104 -0
- package/src/_api/generated/core/utils.gen.ts +140 -0
- package/src/_api/generated/helpers/errors.ts +70 -0
- package/src/_api/generated/helpers/index.ts +25 -0
- package/src/_api/generated/helpers/logger.ts +123 -0
- package/src/_api/generated/helpers/storage.ts +83 -0
- package/src/_api/generated/helpers/validation-events.ts +52 -0
- package/src/_api/generated/index.ts +28 -0
- package/src/_api/generated/sdk.gen.ts +1250 -0
- package/src/_api/generated/types.gen.ts +1294 -0
- package/src/_api/index.ts +5 -23
- package/src/auth/context/AccountsContext.tsx +58 -89
- package/src/auth/context/AuthContext.tsx +3 -3
- package/src/auth/context/index.ts +2 -2
- package/src/auth/hooks/useDeleteAccount.ts +3 -1
- package/src/auth/hooks/useGithubAuth.ts +13 -11
- package/src/auth/hooks/useTokenRefresh.ts +7 -4
- package/src/auth/hooks/useTwoFactor.ts +15 -8
- package/src/auth/hooks/useTwoFactorSetup.ts +9 -5
- package/src/auth/hooks/useTwoFactorStatus.ts +5 -3
- package/src/auth/middlewares/tokenRefresh.ts +7 -4
- package/src/clients.ts +14 -51
- package/src/index.ts +35 -60
- package/src/server.ts +25 -23
- package/src/_api/BaseClient.ts +0 -22
- package/src/_api/generated/cfg_accounts/CLAUDE.md +0 -86
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts +0 -154
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +0 -95
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +0 -285
- package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +0 -440
- package/src/_api/generated/cfg_accounts/_utils/fetchers/index.ts +0 -33
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts.ts +0 -64
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +0 -44
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +0 -114
- package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +0 -152
- package/src/_api/generated/cfg_accounts/_utils/hooks/index.ts +0 -33
- package/src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +0 -22
- package/src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +0 -15
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +0 -21
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +0 -27
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +0 -19
- package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +0 -46
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +0 -41
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts +0 -19
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -21
- package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +0 -45
- package/src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +0 -24
- package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts +0 -16
- package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts +0 -15
- package/src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +0 -24
- package/src/_api/generated/cfg_accounts/_utils/schemas/index.ts +0 -41
- package/src/_api/generated/cfg_accounts/accounts/client.ts +0 -34
- package/src/_api/generated/cfg_accounts/accounts/index.ts +0 -4
- package/src/_api/generated/cfg_accounts/accounts/models.ts +0 -127
- package/src/_api/generated/cfg_accounts/accounts__auth/client.ts +0 -23
- package/src/_api/generated/cfg_accounts/accounts__auth/index.ts +0 -4
- package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +0 -19
- package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +0 -67
- package/src/_api/generated/cfg_accounts/accounts__oauth/index.ts +0 -4
- package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +0 -127
- package/src/_api/generated/cfg_accounts/accounts__user_profile/client.ts +0 -94
- package/src/_api/generated/cfg_accounts/accounts__user_profile/index.ts +0 -4
- package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +0 -98
- package/src/_api/generated/cfg_accounts/api-instance.ts +0 -181
- package/src/_api/generated/cfg_accounts/client.ts +0 -339
- package/src/_api/generated/cfg_accounts/enums.ts +0 -10
- package/src/_api/generated/cfg_accounts/errors.ts +0 -123
- package/src/_api/generated/cfg_accounts/http.ts +0 -160
- package/src/_api/generated/cfg_accounts/index.ts +0 -338
- package/src/_api/generated/cfg_accounts/logger.ts +0 -261
- package/src/_api/generated/cfg_accounts/retry.ts +0 -177
- package/src/_api/generated/cfg_accounts/schema.json +0 -1576
- package/src/_api/generated/cfg_accounts/storage.ts +0 -163
- package/src/_api/generated/cfg_accounts/validation-events.ts +0 -135
- package/src/_api/generated/cfg_centrifugo/CLAUDE.md +0 -60
- package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +0 -94
- package/src/_api/generated/cfg_centrifugo/_utils/fetchers/index.ts +0 -30
- package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +0 -39
- package/src/_api/generated/cfg_centrifugo/_utils/hooks/index.ts +0 -30
- package/src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts +0 -22
- package/src/_api/generated/cfg_centrifugo/_utils/schemas/index.ts +0 -21
- package/src/_api/generated/cfg_centrifugo/api-instance.ts +0 -181
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +0 -27
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +0 -4
- package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +0 -18
- package/src/_api/generated/cfg_centrifugo/client.ts +0 -330
- package/src/_api/generated/cfg_centrifugo/errors.ts +0 -123
- package/src/_api/generated/cfg_centrifugo/http.ts +0 -160
- package/src/_api/generated/cfg_centrifugo/index.ts +0 -316
- package/src/_api/generated/cfg_centrifugo/logger.ts +0 -261
- package/src/_api/generated/cfg_centrifugo/retry.ts +0 -177
- package/src/_api/generated/cfg_centrifugo/schema.json +0 -118
- package/src/_api/generated/cfg_centrifugo/storage.ts +0 -163
- package/src/_api/generated/cfg_centrifugo/validation-events.ts +0 -135
- package/src/_api/generated/cfg_totp/CLAUDE.md +0 -83
- package/src/_api/generated/cfg_totp/_utils/fetchers/index.ts +0 -34
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp.ts +0 -50
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +0 -153
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +0 -109
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +0 -154
- package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +0 -153
- package/src/_api/generated/cfg_totp/_utils/hooks/index.ts +0 -34
- package/src/_api/generated/cfg_totp/_utils/hooks/totp.ts +0 -43
- package/src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +0 -60
- package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +0 -59
- package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +0 -64
- package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +0 -63
- package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +0 -19
- package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +0 -20
- package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +0 -21
- package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +0 -21
- package/src/_api/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +0 -26
- package/src/_api/generated/cfg_totp/_utils/schemas/DeviceListResponse.schema.ts +0 -21
- package/src/_api/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +0 -19
- package/src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +0 -19
- package/src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +0 -23
- package/src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +0 -20
- package/src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +0 -25
- package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -34
- package/src/_api/generated/cfg_totp/api-instance.ts +0 -181
- package/src/_api/generated/cfg_totp/client.ts +0 -342
- package/src/_api/generated/cfg_totp/enums.ts +0 -13
- package/src/_api/generated/cfg_totp/errors.ts +0 -123
- package/src/_api/generated/cfg_totp/http.ts +0 -160
- package/src/_api/generated/cfg_totp/index.ts +0 -345
- package/src/_api/generated/cfg_totp/logger.ts +0 -261
- package/src/_api/generated/cfg_totp/retry.ts +0 -177
- package/src/_api/generated/cfg_totp/schema.json +0 -910
- package/src/_api/generated/cfg_totp/storage.ts +0 -163
- package/src/_api/generated/cfg_totp/totp/client.ts +0 -24
- package/src/_api/generated/cfg_totp/totp/index.ts +0 -4
- package/src/_api/generated/cfg_totp/totp/models.ts +0 -4
- package/src/_api/generated/cfg_totp/totp__backup_codes/client.ts +0 -32
- package/src/_api/generated/cfg_totp/totp__backup_codes/index.ts +0 -4
- package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +0 -38
- package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +0 -31
- package/src/_api/generated/cfg_totp/totp__totp_management/index.ts +0 -4
- package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +0 -46
- package/src/_api/generated/cfg_totp/totp__totp_setup/client.ts +0 -33
- package/src/_api/generated/cfg_totp/totp__totp_setup/index.ts +0 -4
- package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +0 -55
- package/src/_api/generated/cfg_totp/totp__totp_verification/client.ts +0 -33
- package/src/_api/generated/cfg_totp/totp__totp_verification/index.ts +0 -4
- package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +0 -74
- package/src/_api/generated/cfg_totp/validation-events.ts +0 -135
- package/src/hooks/accounts.ts +0 -8
- package/src/hooks/index.ts +0 -10
package/src/clients.ts
CHANGED
|
@@ -1,57 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @djangocfg/api
|
|
2
|
+
* @djangocfg/api/clients — pre-configured per-group API singletons.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Singletons (`cfgAccountsApi`, `cfgTotpApi`, `cfgCentrifugoApi`) live in the
|
|
5
|
+
* generated barrel. This file just re-exports them with the legacy-friendly
|
|
6
|
+
* `apiAccounts` / `apiTotp` / `apiCentrifugo` aliases.
|
|
5
7
|
*
|
|
6
8
|
* Usage:
|
|
7
|
-
* import { apiAccounts
|
|
8
|
-
*
|
|
9
|
+
* import { apiAccounts } from '@djangocfg/api/clients';
|
|
10
|
+
* await apiAccounts.accounts.cfgAccountsLogin({ body });
|
|
9
11
|
*/
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const apiUrl = isStaticBuild ? '' : process.env.NEXT_PUBLIC_API_URL || '';
|
|
20
|
-
const storage = new LocalStorageAdapter();
|
|
21
|
-
|
|
22
|
-
export const apiAccounts = new AccountsAPIClass(apiUrl, { storage });
|
|
23
|
-
export const apiTotp = new TotpAPIClass(apiUrl, { storage });
|
|
24
|
-
export const apiCentrifugo = new CentrifugoAPIClass(apiUrl, { storage });
|
|
25
|
-
|
|
26
|
-
// ============================================================================
|
|
27
|
-
// Enums (re-export from accounts)
|
|
28
|
-
// ============================================================================
|
|
29
|
-
export * as Enums from './_api/generated/cfg_accounts/enums';
|
|
30
|
-
|
|
31
|
-
// ============================================================================
|
|
32
|
-
// CFG Accounts (primary exports - includes shared types)
|
|
33
|
-
// ============================================================================
|
|
34
|
-
export * from './_api/generated/cfg_accounts/_utils/hooks';
|
|
35
|
-
export * from './_api/generated/cfg_accounts/_utils/fetchers';
|
|
36
|
-
export * from './_api/generated/cfg_accounts/_utils/schemas';
|
|
37
|
-
|
|
38
|
-
// ============================================================================
|
|
39
|
-
// CFG Centrifugo (namespaced to avoid conflicts)
|
|
40
|
-
// ============================================================================
|
|
41
|
-
export * as CentrifugoHooks from './_api/generated/cfg_centrifugo/_utils/hooks';
|
|
42
|
-
export * as CentrifugoFetchers from './_api/generated/cfg_centrifugo/_utils/fetchers';
|
|
43
|
-
export * as CentrifugoTypes from './_api/generated/cfg_centrifugo/_utils/schemas';
|
|
44
|
-
|
|
45
|
-
// ============================================================================
|
|
46
|
-
// CFG TOTP (namespaced to avoid conflicts)
|
|
47
|
-
// ============================================================================
|
|
48
|
-
export * as TotpHooks from './_api/generated/cfg_totp/_utils/hooks';
|
|
49
|
-
export * as TotpFetchers from './_api/generated/cfg_totp/_utils/fetchers';
|
|
50
|
-
export * as TotpTypes from './_api/generated/cfg_totp/_utils/schemas';
|
|
51
|
-
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// API Classes (for creating custom instances)
|
|
54
|
-
// ============================================================================
|
|
55
|
-
export { API as AccountsAPI } from './_api/generated/cfg_accounts';
|
|
56
|
-
export { API as TotpAPI } from './_api/generated/cfg_totp';
|
|
57
|
-
export { API as CentrifugoAPI } from './_api/generated/cfg_centrifugo';
|
|
13
|
+
export {
|
|
14
|
+
CfgAccountsApi as apiAccounts,
|
|
15
|
+
CfgTotpApi as apiTotp,
|
|
16
|
+
CfgCentrifugoApi as apiCentrifugo,
|
|
17
|
+
CfgAccountsAPI as AccountsAPI,
|
|
18
|
+
CfgTotpAPI as TotpAPI,
|
|
19
|
+
CfgCentrifugoAPI as CentrifugoAPI,
|
|
20
|
+
} from './_api/generated';
|
package/src/index.ts
CHANGED
|
@@ -1,65 +1,40 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @djangocfg/api
|
|
2
|
+
* @djangocfg/api — package entry point.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* - @djangocfg/ext-support
|
|
7
|
-
* - @djangocfg/ext-payments
|
|
8
|
-
* - etc.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
// ============================================================================
|
|
12
|
-
// Main API from cfg_accounts (authentication)
|
|
13
|
-
// ============================================================================
|
|
14
|
-
export * from './_api/generated/cfg_accounts';
|
|
15
|
-
export { API, LocalStorageAdapter, MemoryStorageAdapter } from './_api/generated/cfg_accounts';
|
|
16
|
-
export { Schemas, Fetchers, Enums } from './_api/generated/cfg_accounts';
|
|
17
|
-
|
|
18
|
-
// ============================================================================
|
|
19
|
-
// CFG Accounts Type Namespace
|
|
20
|
-
// ============================================================================
|
|
21
|
-
export * as CfgAccountsTypes from './_api/generated/cfg_accounts';
|
|
22
|
-
|
|
23
|
-
// ============================================================================
|
|
24
|
-
// Centrifugo Fetchers (for WebSocket token refresh)
|
|
25
|
-
// ============================================================================
|
|
26
|
-
export { getCentrifugoAuthTokenRetrieve } from './_api/generated/cfg_centrifugo';
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Base Client for all API services
|
|
4
|
+
* Per-group API singletons (`cfgAccountsApi`, `cfgTotpApi`, `cfgCentrifugoApi`)
|
|
5
|
+
* + API classes + shared utilities (LocalStorageAdapter / APIError / ...).
|
|
30
6
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* - Singleton pattern for API client
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { cfgAccountsApi, AccountsTypes } from '@djangocfg/api';
|
|
9
|
+
* await cfgAccountsApi.accounts.cfgAccountsLogin({ body });
|
|
35
10
|
*/
|
|
36
11
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export { api };
|
|
12
|
+
export * from './_api/generated';
|
|
13
|
+
|
|
14
|
+
// Hey API SDK classes (one per OpenAPI tag) — direct callable static methods,
|
|
15
|
+
// e.g. `CentrifugoAuth.cfgCentrifugoAuthTokenRetrieve(...)`.
|
|
16
|
+
export {
|
|
17
|
+
Cfg,
|
|
18
|
+
Accounts,
|
|
19
|
+
OAuth,
|
|
20
|
+
UserProfile,
|
|
21
|
+
Auth,
|
|
22
|
+
Centrifugo,
|
|
23
|
+
CentrifugoAuth,
|
|
24
|
+
Totp,
|
|
25
|
+
BackupCodes,
|
|
26
|
+
TotpManagement,
|
|
27
|
+
TotpSetup,
|
|
28
|
+
TotpVerification,
|
|
29
|
+
} from './_api/generated/sdk.gen';
|
|
30
|
+
|
|
31
|
+
// Type namespaces (one per group) for code that needs `AccountsTypes.User`.
|
|
32
|
+
export type * as AccountsTypes from './_api/generated/_cfg_accounts/types.gen';
|
|
33
|
+
export type * as TotpTypes from './_api/generated/_cfg_totp/types.gen';
|
|
34
|
+
export type * as CentrifugoTypes from './_api/generated/_cfg_centrifugo/types.gen';
|
|
35
|
+
|
|
36
|
+
// Convenience top-level type re-exports.
|
|
37
|
+
export type { User } from './_api/generated/_cfg_accounts/types.gen';
|
|
38
|
+
|
|
39
|
+
// Legacy alias for code that still imports `api` (= cfg_accounts singleton).
|
|
40
|
+
export { CfgAccountsApi as api } from './_api/generated';
|
package/src/server.ts
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @djangocfg/api/server
|
|
2
|
+
* @djangocfg/api/server — server-side only exports.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```typescript
|
|
9
|
-
* import { API, MemoryStorageAdapter, Fetchers } from '@djangocfg/api/server';
|
|
10
|
-
*
|
|
11
|
-
* const api = new API('https://api.example.com', {
|
|
12
|
-
* storage: new MemoryStorageAdapter(),
|
|
13
|
-
* });
|
|
14
|
-
*
|
|
15
|
-
* const result = await Fetchers.someEndpoint(data, api);
|
|
16
|
-
* ```
|
|
4
|
+
* No React hooks, no client-side code. Use from Next.js API routes / Server
|
|
5
|
+
* Components / Node.js backends.
|
|
17
6
|
*/
|
|
18
7
|
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
export {
|
|
9
|
+
CfgAccountsAPI as AccountsAPI,
|
|
10
|
+
CfgTotpAPI as TotpAPI,
|
|
11
|
+
CfgCentrifugoAPI as CentrifugoAPI,
|
|
12
|
+
MemoryStorageAdapter,
|
|
13
|
+
LocalStorageAdapter,
|
|
14
|
+
type StorageAdapter,
|
|
15
|
+
APIError,
|
|
16
|
+
NetworkError,
|
|
17
|
+
} from './_api/generated';
|
|
21
18
|
|
|
22
|
-
//
|
|
23
|
-
export * as
|
|
19
|
+
// SDK fetchers (Hey API SDK classes — re-export as namespace modules).
|
|
20
|
+
export * as AccountsFetchers from './_api/generated/_cfg_accounts/sdk.gen';
|
|
21
|
+
export * as TotpFetchers from './_api/generated/_cfg_totp/sdk.gen';
|
|
22
|
+
export * as CentrifugoFetchers from './_api/generated/_cfg_centrifugo/sdk.gen';
|
|
24
23
|
|
|
25
|
-
//
|
|
26
|
-
export * as
|
|
27
|
-
export * as
|
|
24
|
+
// Zod schemas.
|
|
25
|
+
export * as AccountsSchemas from './_api/generated/_cfg_accounts/schemas';
|
|
26
|
+
export * as TotpSchemas from './_api/generated/_cfg_totp/schemas';
|
|
27
|
+
export * as CentrifugoSchemas from './_api/generated/_cfg_centrifugo/schemas';
|
|
28
28
|
|
|
29
|
-
//
|
|
30
|
-
export type
|
|
29
|
+
// Types.
|
|
30
|
+
export type * as AccountsTypes from './_api/generated/_cfg_accounts/types.gen';
|
|
31
|
+
export type * as TotpTypes from './_api/generated/_cfg_totp/types.gen';
|
|
32
|
+
export type * as CentrifugoTypes from './_api/generated/_cfg_centrifugo/types.gen';
|
package/src/_api/BaseClient.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { API as AccountsAPIClass, LocalStorageAdapter, MemoryStorageAdapter } from './generated/cfg_accounts';
|
|
2
|
-
import { API as CentrifugoAPIClass } from './generated/cfg_centrifugo';
|
|
3
|
-
import { API as TotpAPIClass } from './generated/cfg_totp';
|
|
4
|
-
|
|
5
|
-
const isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === 'true';
|
|
6
|
-
const apiUrl = isStaticBuild ? '' : process.env.NEXT_PUBLIC_API_URL || '';
|
|
7
|
-
const storage = new LocalStorageAdapter();
|
|
8
|
-
|
|
9
|
-
export const apiAccounts = new AccountsAPIClass(apiUrl, { storage });
|
|
10
|
-
export const apiTotp = new TotpAPIClass(apiUrl, { storage });
|
|
11
|
-
export const apiCentrifugo = new CentrifugoAPIClass(apiUrl, { storage });
|
|
12
|
-
|
|
13
|
-
/** Legacy singleton kept for backwards compatibility */
|
|
14
|
-
export const api = apiAccounts;
|
|
15
|
-
|
|
16
|
-
export class BaseClient {
|
|
17
|
-
protected static api = apiAccounts;
|
|
18
|
-
protected static apiTotp = apiTotp;
|
|
19
|
-
protected static apiCentrifugo = apiCentrifugo;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { LocalStorageAdapter, MemoryStorageAdapter };
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
# Django CFG API - Typescript Client
|
|
2
|
-
|
|
3
|
-
Auto-generated. **Do not edit manually.**
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
python manage.py generate_client --groups cfg_accounts --typescript
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Stats
|
|
10
|
-
|
|
11
|
-
| | |
|
|
12
|
-
|---|---|
|
|
13
|
-
| Version | 3.1.0 |
|
|
14
|
-
| Operations | 15 |
|
|
15
|
-
| Schemas | 21 |
|
|
16
|
-
|
|
17
|
-
## Resources
|
|
18
|
-
|
|
19
|
-
- **Auth** (1 ops)
|
|
20
|
-
- **OAuth** (5 ops)
|
|
21
|
-
- **User Profile** (7 ops)
|
|
22
|
-
- **accounts** (2 ops)
|
|
23
|
-
|
|
24
|
-
## Operations
|
|
25
|
-
|
|
26
|
-
**Auth:**
|
|
27
|
-
- `POST` /cfg/accounts/token/refresh/ → `cfg_accounts_token_refresh_create`
|
|
28
|
-
|
|
29
|
-
**OAuth:**
|
|
30
|
-
- `GET` /cfg/accounts/oauth/connections/ → `cfg_accounts_oauth_connections_list`
|
|
31
|
-
- `POST` /cfg/accounts/oauth/disconnect/ → `cfg_accounts_oauth_disconnect_create`
|
|
32
|
-
- `POST` /cfg/accounts/oauth/github/authorize/ → `cfg_accounts_oauth_github_authorize_create`
|
|
33
|
-
- `POST` /cfg/accounts/oauth/github/callback/ → `cfg_accounts_oauth_github_callback_create`
|
|
34
|
-
- `GET` /cfg/accounts/oauth/providers/ → `cfg_accounts_oauth_providers_retrieve`
|
|
35
|
-
|
|
36
|
-
**User Profile:**
|
|
37
|
-
- `POST` /cfg/accounts/profile/avatar/ → `cfg_accounts_profile_avatar_create`
|
|
38
|
-
- `POST` /cfg/accounts/profile/delete/ → `cfg_accounts_profile_delete_create`
|
|
39
|
-
- `PATCH` /cfg/accounts/profile/partial/ → `cfg_accounts_profile_partial_partial_update`
|
|
40
|
-
- `PUT` /cfg/accounts/profile/partial/ → `cfg_accounts_profile_partial_update`
|
|
41
|
-
- `GET` /cfg/accounts/profile/ → `cfg_accounts_profile_retrieve`
|
|
42
|
-
- `PATCH` /cfg/accounts/profile/update/ → `cfg_accounts_profile_update_partial_update`
|
|
43
|
-
- `PUT` /cfg/accounts/profile/update/ → `cfg_accounts_profile_update_update`
|
|
44
|
-
|
|
45
|
-
**accounts:**
|
|
46
|
-
- `POST` /cfg/accounts/otp/request/ → `cfg_accounts_otp_request_create`
|
|
47
|
-
- `POST` /cfg/accounts/otp/verify/ → `cfg_accounts_otp_verify_create`
|
|
48
|
-
|
|
49
|
-
## Usage
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
import { APIClient } from './';
|
|
53
|
-
|
|
54
|
-
const client = new APIClient({ baseUrl, token });
|
|
55
|
-
|
|
56
|
-
await client.oauth.list();
|
|
57
|
-
await client.oauth.retrieve({ id: 1 });
|
|
58
|
-
await client.oauth.create({ ... });
|
|
59
|
-
await client.accounts.create({ ... });
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**SWR Hooks:**
|
|
63
|
-
```typescript
|
|
64
|
-
import { useOauthList } from './hooks';
|
|
65
|
-
const { data, isLoading } = useOauthList();
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## How It Works
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
DRF ViewSets → drf-spectacular → OpenAPI → IR Parser → Generator → This Client
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
**Configuration** (`api/config.py`):
|
|
75
|
-
```python
|
|
76
|
-
openapi_client = OpenAPIClientConfig(
|
|
77
|
-
enabled=True,
|
|
78
|
-
groups=[OpenAPIGroupConfig(name="cfg_accounts", apps=["..."])],
|
|
79
|
-
generate_zod_schemas=True, # → schemas.ts
|
|
80
|
-
generate_fetchers=True, # → fetchers.ts
|
|
81
|
-
generate_swr_hooks=True, # → hooks.ts
|
|
82
|
-
)
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
@see https://djangocfg.com/docs/features/api-generation
|
|
86
|
-
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
|
-
/**
|
|
4
|
-
* Typed fetchers for Accounts
|
|
5
|
-
*
|
|
6
|
-
* Universal functions that work in any environment:
|
|
7
|
-
* - Next.js (App Router / Pages Router / Server Components)
|
|
8
|
-
* - React Native
|
|
9
|
-
* - Node.js backend
|
|
10
|
-
*
|
|
11
|
-
* These fetchers use Zod schemas for runtime validation.
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Configure API once (in your app entry point)
|
|
16
|
-
* import { configureAPI } from '../../api-instance'
|
|
17
|
-
* configureAPI({ baseUrl: 'https://api.example.com' })
|
|
18
|
-
*
|
|
19
|
-
* // Then use fetchers anywhere
|
|
20
|
-
* const users = await getUsers({ page: 1 })
|
|
21
|
-
*
|
|
22
|
-
* // With SWR
|
|
23
|
-
* const { data } = useSWR(['users', params], () => getUsers(params))
|
|
24
|
-
*
|
|
25
|
-
* // With React Query
|
|
26
|
-
* const { data } = useQuery(['users', params], () => getUsers(params))
|
|
27
|
-
*
|
|
28
|
-
* // In Server Component or SSR (pass custom client)
|
|
29
|
-
* import { API } from '../../index'
|
|
30
|
-
* const api = new API('https://api.example.com')
|
|
31
|
-
* const users = await getUsers({ page: 1 }, api)
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
import { consola } from 'consola'
|
|
35
|
-
import { OTPRequestRequestSchema, type OTPRequestRequest } from '../schemas/OTPRequestRequest.schema'
|
|
36
|
-
import { OTPRequestResponseSchema, type OTPRequestResponse } from '../schemas/OTPRequestResponse.schema'
|
|
37
|
-
import { OTPVerifyRequestSchema, type OTPVerifyRequest } from '../schemas/OTPVerifyRequest.schema'
|
|
38
|
-
import { OTPVerifyResponseSchema, type OTPVerifyResponse } from '../schemas/OTPVerifyResponse.schema'
|
|
39
|
-
import { getAPIInstance } from '../../api-instance'
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* API operation
|
|
43
|
-
*
|
|
44
|
-
* @method POST
|
|
45
|
-
* @path /cfg/accounts/otp/request/
|
|
46
|
-
*/
|
|
47
|
-
export async function createAccountsOtpRequestCreate( data: OTPRequestRequest, client?: any
|
|
48
|
-
): Promise<OTPRequestResponse> {
|
|
49
|
-
const api = client || getAPIInstance()
|
|
50
|
-
const response = await api.accounts.otpRequestCreate(data)
|
|
51
|
-
try {
|
|
52
|
-
return OTPRequestResponseSchema.parse(response)
|
|
53
|
-
} catch (error) {
|
|
54
|
-
// Zod validation error - log detailed information
|
|
55
|
-
consola.error('❌ Zod Validation Failed');
|
|
56
|
-
consola.box(`createAccountsOtpRequestCreate\nPath: /cfg/accounts/otp/request/\nMethod: POST`);
|
|
57
|
-
|
|
58
|
-
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
59
|
-
consola.error('Validation Issues:');
|
|
60
|
-
(error as any).issues.forEach((issue: any, index: number) => {
|
|
61
|
-
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
62
|
-
consola.error(` ├─ Message: ${issue.message}`);
|
|
63
|
-
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
64
|
-
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
consola.error('Response data:', response);
|
|
69
|
-
|
|
70
|
-
// Dispatch browser CustomEvent (only if window is defined)
|
|
71
|
-
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
72
|
-
try {
|
|
73
|
-
const event = new CustomEvent('zod-validation-error', {
|
|
74
|
-
detail: {
|
|
75
|
-
operation: 'createAccountsOtpRequestCreate',
|
|
76
|
-
path: '/cfg/accounts/otp/request/',
|
|
77
|
-
method: 'POST',
|
|
78
|
-
error: error,
|
|
79
|
-
response: response,
|
|
80
|
-
timestamp: new Date(),
|
|
81
|
-
},
|
|
82
|
-
bubbles: true,
|
|
83
|
-
cancelable: false,
|
|
84
|
-
});
|
|
85
|
-
window.dispatchEvent(event);
|
|
86
|
-
} catch (eventError) {
|
|
87
|
-
// Silently fail - event dispatch should never crash the app
|
|
88
|
-
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Re-throw the error
|
|
93
|
-
throw error;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* API operation
|
|
100
|
-
*
|
|
101
|
-
* @method POST
|
|
102
|
-
* @path /cfg/accounts/otp/verify/
|
|
103
|
-
*/
|
|
104
|
-
export async function createAccountsOtpVerifyCreate( data: OTPVerifyRequest, client?: any
|
|
105
|
-
): Promise<OTPVerifyResponse> {
|
|
106
|
-
const api = client || getAPIInstance()
|
|
107
|
-
const response = await api.accounts.otpVerifyCreate(data)
|
|
108
|
-
try {
|
|
109
|
-
return OTPVerifyResponseSchema.parse(response)
|
|
110
|
-
} catch (error) {
|
|
111
|
-
// Zod validation error - log detailed information
|
|
112
|
-
consola.error('❌ Zod Validation Failed');
|
|
113
|
-
consola.box(`createAccountsOtpVerifyCreate\nPath: /cfg/accounts/otp/verify/\nMethod: POST`);
|
|
114
|
-
|
|
115
|
-
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
116
|
-
consola.error('Validation Issues:');
|
|
117
|
-
(error as any).issues.forEach((issue: any, index: number) => {
|
|
118
|
-
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
119
|
-
consola.error(` ├─ Message: ${issue.message}`);
|
|
120
|
-
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
121
|
-
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
consola.error('Response data:', response);
|
|
126
|
-
|
|
127
|
-
// Dispatch browser CustomEvent (only if window is defined)
|
|
128
|
-
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
129
|
-
try {
|
|
130
|
-
const event = new CustomEvent('zod-validation-error', {
|
|
131
|
-
detail: {
|
|
132
|
-
operation: 'createAccountsOtpVerifyCreate',
|
|
133
|
-
path: '/cfg/accounts/otp/verify/',
|
|
134
|
-
method: 'POST',
|
|
135
|
-
error: error,
|
|
136
|
-
response: response,
|
|
137
|
-
timestamp: new Date(),
|
|
138
|
-
},
|
|
139
|
-
bubbles: true,
|
|
140
|
-
cancelable: false,
|
|
141
|
-
});
|
|
142
|
-
window.dispatchEvent(event);
|
|
143
|
-
} catch (eventError) {
|
|
144
|
-
// Silently fail - event dispatch should never crash the app
|
|
145
|
-
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Re-throw the error
|
|
150
|
-
throw error;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
3
|
-
/**
|
|
4
|
-
* Typed fetchers for Auth
|
|
5
|
-
*
|
|
6
|
-
* Universal functions that work in any environment:
|
|
7
|
-
* - Next.js (App Router / Pages Router / Server Components)
|
|
8
|
-
* - React Native
|
|
9
|
-
* - Node.js backend
|
|
10
|
-
*
|
|
11
|
-
* These fetchers use Zod schemas for runtime validation.
|
|
12
|
-
*
|
|
13
|
-
* Usage:
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Configure API once (in your app entry point)
|
|
16
|
-
* import { configureAPI } from '../../api-instance'
|
|
17
|
-
* configureAPI({ baseUrl: 'https://api.example.com' })
|
|
18
|
-
*
|
|
19
|
-
* // Then use fetchers anywhere
|
|
20
|
-
* const users = await getUsers({ page: 1 })
|
|
21
|
-
*
|
|
22
|
-
* // With SWR
|
|
23
|
-
* const { data } = useSWR(['users', params], () => getUsers(params))
|
|
24
|
-
*
|
|
25
|
-
* // With React Query
|
|
26
|
-
* const { data } = useQuery(['users', params], () => getUsers(params))
|
|
27
|
-
*
|
|
28
|
-
* // In Server Component or SSR (pass custom client)
|
|
29
|
-
* import { API } from '../../index'
|
|
30
|
-
* const api = new API('https://api.example.com')
|
|
31
|
-
* const users = await getUsers({ page: 1 }, api)
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
import { consola } from 'consola'
|
|
35
|
-
import { TokenRefreshSchema, type TokenRefresh } from '../schemas/TokenRefresh.schema'
|
|
36
|
-
import { TokenRefreshRequestSchema, type TokenRefreshRequest } from '../schemas/TokenRefreshRequest.schema'
|
|
37
|
-
import { getAPIInstance } from '../../api-instance'
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* API operation
|
|
41
|
-
*
|
|
42
|
-
* @method POST
|
|
43
|
-
* @path /cfg/accounts/token/refresh/
|
|
44
|
-
*/
|
|
45
|
-
export async function createAccountsTokenRefreshCreate( data: TokenRefreshRequest, client?: any
|
|
46
|
-
): Promise<TokenRefresh> {
|
|
47
|
-
const api = client || getAPIInstance()
|
|
48
|
-
const response = await api.auth.accountsTokenRefreshCreate(data)
|
|
49
|
-
try {
|
|
50
|
-
return TokenRefreshSchema.parse(response)
|
|
51
|
-
} catch (error) {
|
|
52
|
-
// Zod validation error - log detailed information
|
|
53
|
-
consola.error('❌ Zod Validation Failed');
|
|
54
|
-
consola.box(`createAccountsTokenRefreshCreate\nPath: /cfg/accounts/token/refresh/\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: 'createAccountsTokenRefreshCreate',
|
|
74
|
-
path: '/cfg/accounts/token/refresh/',
|
|
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
|
-
|