@djangocfg/api 2.1.322 → 2.1.327
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 +4265 -1169
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +4265 -1159
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +4150 -3053
- 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 +4139 -3042
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +3932 -4031
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +2408 -2671
- package/dist/clients.d.ts +2408 -2671
- package/dist/clients.mjs +3945 -4038
- package/dist/clients.mjs.map +1 -1
- package/dist/index.cjs +4214 -2713
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2758 -1828
- package/dist/index.d.ts +2758 -1828
- package/dist/index.mjs +4183 -2676
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -7
- package/src/_api/generated/_shared/errors.ts +70 -0
- package/src/_api/generated/_shared/index.ts +25 -0
- package/src/_api/generated/_shared/logger.ts +123 -0
- package/src/_api/generated/_shared/storage.ts +83 -0
- package/src/_api/generated/_shared/validation-events.ts +52 -0
- package/src/_api/generated/cfg_accounts/api.ts +187 -0
- package/src/_api/generated/cfg_accounts/client/client.gen.ts +280 -0
- package/src/_api/generated/cfg_accounts/client/index.ts +25 -0
- package/src/_api/generated/cfg_accounts/client/types.gen.ts +217 -0
- package/src/_api/generated/cfg_accounts/client/utils.gen.ts +318 -0
- package/src/_api/generated/cfg_accounts/client.gen.ts +16 -0
- package/src/_api/generated/cfg_accounts/core/auth.gen.ts +41 -0
- package/src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/cfg_accounts/core/params.gen.ts +169 -0
- package/src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/cfg_accounts/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/cfg_accounts/core/types.gen.ts +104 -0
- package/src/_api/generated/cfg_accounts/core/utils.gen.ts +140 -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 +26 -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 +26 -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 +26 -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 +26 -335
- 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 → schemas/User.ts} +8 -16
- package/src/_api/generated/cfg_accounts/schemas/index.ts +24 -0
- package/src/_api/generated/cfg_accounts/sdk.gen.ts +796 -0
- package/src/_api/generated/cfg_accounts/types.gen.ts +764 -0
- package/src/_api/generated/cfg_centrifugo/api.ts +164 -0
- package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +280 -0
- package/src/_api/generated/cfg_centrifugo/client/index.ts +25 -0
- package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +217 -0
- package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +318 -0
- package/src/_api/generated/cfg_centrifugo/client.gen.ts +16 -0
- package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +41 -0
- package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +169 -0
- package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +104 -0
- package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +140 -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 +26 -0
- package/src/_api/generated/cfg_centrifugo/index.ts +26 -313
- 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 +64 -0
- package/src/_api/generated/cfg_centrifugo/types.gen.ts +61 -0
- package/src/_api/generated/cfg_totp/api.ts +181 -0
- package/src/_api/generated/cfg_totp/client/client.gen.ts +280 -0
- package/src/_api/generated/cfg_totp/client/index.ts +25 -0
- package/src/_api/generated/cfg_totp/client/types.gen.ts +217 -0
- package/src/_api/generated/cfg_totp/client/utils.gen.ts +318 -0
- package/src/_api/generated/cfg_totp/client.gen.ts +16 -0
- package/src/_api/generated/cfg_totp/core/auth.gen.ts +41 -0
- package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +82 -0
- package/src/_api/generated/cfg_totp/core/params.gen.ts +169 -0
- package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +171 -0
- package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +117 -0
- package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +242 -0
- package/src/_api/generated/cfg_totp/core/types.gen.ts +104 -0
- package/src/_api/generated/cfg_totp/core/utils.gen.ts +140 -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 +26 -0
- package/src/_api/generated/cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +24 -0
- package/src/_api/generated/cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +26 -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 +26 -342
- 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 → schemas/TotpVerifyUser.ts} +7 -15
- 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 +432 -0
- package/src/_api/generated/cfg_totp/types.gen.ts +479 -0
- package/src/_api/generated/index.ts +30 -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 +2 -1
- package/src/auth/hooks/useGithubAuth.ts +12 -11
- package/src/auth/hooks/useTokenRefresh.ts +6 -4
- package/src/auth/hooks/useTwoFactor.ts +14 -8
- package/src/auth/hooks/useTwoFactorSetup.ts +8 -5
- package/src/auth/hooks/useTwoFactorStatus.ts +3 -2
- package/src/auth/middlewares/tokenRefresh.ts +6 -4
- package/src/clients.ts +14 -51
- package/src/index.ts +15 -57
- 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/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/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/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
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Self-contained API wrapper for this group. DO NOT EDIT — re-run `make gen`.
|
|
3
|
+
|
|
4
|
+
import { client } from './client.gen';
|
|
5
|
+
import type { StorageAdapter } from '../_shared/storage';
|
|
6
|
+
import { LocalStorageAdapter } from '../_shared/storage';
|
|
7
|
+
import { APILogger, type LoggerConfig } from '../_shared/logger';
|
|
8
|
+
|
|
9
|
+
import { Cfg } from './sdk.gen';
|
|
10
|
+
import { Centrifugo } from './sdk.gen';
|
|
11
|
+
import { CentrifugoAuth } from './sdk.gen';
|
|
12
|
+
import type { ZodTypeAny } from 'zod';
|
|
13
|
+
import {
|
|
14
|
+
ConnectionTokenResponseSchema,
|
|
15
|
+
} from './schemas';
|
|
16
|
+
import { dispatchValidationError } from '../_shared/validation-events';
|
|
17
|
+
|
|
18
|
+
const ACCESS_KEY = 'cfg.access_token';
|
|
19
|
+
const REFRESH_KEY = 'cfg.refresh_token';
|
|
20
|
+
|
|
21
|
+
interface ValidationRoute {
|
|
22
|
+
method: string;
|
|
23
|
+
re: RegExp;
|
|
24
|
+
schema: ZodTypeAny;
|
|
25
|
+
path: string;
|
|
26
|
+
}
|
|
27
|
+
const VALIDATION_ROUTES: ReadonlyArray<ValidationRoute> = [
|
|
28
|
+
{ method: 'GET', re: new RegExp('^/cfg/centrifugo/auth/token/?$'), schema: ConnectionTokenResponseSchema, path: '/cfg/centrifugo/auth/token/' }
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
/** Auto-detect locale from cookie NEXT_LOCALE or navigator.language. */
|
|
32
|
+
function detectLocale(): string | null {
|
|
33
|
+
try {
|
|
34
|
+
if (typeof document !== 'undefined') {
|
|
35
|
+
const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
36
|
+
if (m) return decodeURIComponent(m[1]);
|
|
37
|
+
}
|
|
38
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
39
|
+
return navigator.language;
|
|
40
|
+
}
|
|
41
|
+
} catch {}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface APIOptions {
|
|
46
|
+
/** Override storage backend (LocalStorage by default; Memory for SSR/tests). */
|
|
47
|
+
storage?: StorageAdapter;
|
|
48
|
+
/** Logger config (defaults to dev-only). */
|
|
49
|
+
logger?: Partial<LoggerConfig>;
|
|
50
|
+
/** Locale for `Accept-Language`. If omitted, auto-detected from cookie/navigator. */
|
|
51
|
+
locale?: string;
|
|
52
|
+
/** API key sent as `X-API-Key`. Falls back to NEXT_PUBLIC_API_KEY. */
|
|
53
|
+
apiKey?: string;
|
|
54
|
+
/** Send Django session/CSRF cookies cross-origin. Defaults to true. */
|
|
55
|
+
withCredentials?: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Self-contained API wrapper for this group.
|
|
60
|
+
*
|
|
61
|
+
* Each group has its own client + interceptor + token store. The interceptor
|
|
62
|
+
* automatically attaches:
|
|
63
|
+
* - `Authorization: Bearer <jwt>` from storage
|
|
64
|
+
* - `Accept-Language` from `opts.locale` or `NEXT_LOCALE` cookie
|
|
65
|
+
* - `X-API-Key` from `opts.apiKey` or `NEXT_PUBLIC_API_KEY`
|
|
66
|
+
* - `credentials: 'include'` for Django session/CSRF cookies (toggle via opts)
|
|
67
|
+
*/
|
|
68
|
+
export class API {
|
|
69
|
+
private baseUrl: string;
|
|
70
|
+
private storage: StorageAdapter;
|
|
71
|
+
private locale: string | null;
|
|
72
|
+
private apiKey: string | null;
|
|
73
|
+
readonly logger: APILogger;
|
|
74
|
+
|
|
75
|
+
readonly cfg = Cfg;
|
|
76
|
+
readonly centrifugo = Centrifugo;
|
|
77
|
+
readonly centrifugoAuth = CentrifugoAuth;
|
|
78
|
+
|
|
79
|
+
constructor(baseUrl: string, opts: APIOptions = {}) {
|
|
80
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
81
|
+
this.storage = opts.storage ?? new LocalStorageAdapter();
|
|
82
|
+
this.logger = new APILogger(opts.logger);
|
|
83
|
+
this.locale = opts.locale ?? null;
|
|
84
|
+
this.apiKey = opts.apiKey ?? (typeof process !== 'undefined' ? (process.env?.NEXT_PUBLIC_API_KEY ?? null) : null);
|
|
85
|
+
|
|
86
|
+
const credentials: RequestCredentials = (opts.withCredentials ?? true) ? 'include' : 'same-origin';
|
|
87
|
+
client.setConfig({ baseUrl: this.baseUrl, credentials });
|
|
88
|
+
|
|
89
|
+
client.interceptors.request.use((request) => {
|
|
90
|
+
const access = this.getToken();
|
|
91
|
+
if (access) request.headers.set('Authorization', `Bearer ${access}`);
|
|
92
|
+
|
|
93
|
+
const locale = this.locale ?? detectLocale();
|
|
94
|
+
if (locale) request.headers.set('Accept-Language', locale);
|
|
95
|
+
|
|
96
|
+
if (this.apiKey) request.headers.set('X-API-Key', this.apiKey);
|
|
97
|
+
|
|
98
|
+
return request;
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
client.interceptors.response.use(async (response, request) => {
|
|
102
|
+
if (!response.ok) return response;
|
|
103
|
+
const ct = response.headers.get('content-type') || '';
|
|
104
|
+
if (!ct.includes('application/json')) return response;
|
|
105
|
+
const url = new URL(request.url);
|
|
106
|
+
const method = request.method.toUpperCase();
|
|
107
|
+
const route = VALIDATION_ROUTES.find(
|
|
108
|
+
(r) => r.method === method && r.re.test(url.pathname),
|
|
109
|
+
);
|
|
110
|
+
if (!route) return response;
|
|
111
|
+
let payload: unknown;
|
|
112
|
+
try {
|
|
113
|
+
payload = await response.clone().json();
|
|
114
|
+
} catch {
|
|
115
|
+
return response;
|
|
116
|
+
}
|
|
117
|
+
const result = route.schema.safeParse(payload);
|
|
118
|
+
if (!result.success) {
|
|
119
|
+
dispatchValidationError({
|
|
120
|
+
operation: `${method} ${route.path}`,
|
|
121
|
+
path: route.path,
|
|
122
|
+
method,
|
|
123
|
+
error: result.error,
|
|
124
|
+
response: payload,
|
|
125
|
+
timestamp: new Date(),
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return response;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ── Base URL ────────────────────────────────────────────────────────────
|
|
133
|
+
getBaseUrl(): string { return this.baseUrl; }
|
|
134
|
+
setBaseUrl(url: string): void {
|
|
135
|
+
this.baseUrl = url.replace(/\/$/, '');
|
|
136
|
+
client.setConfig({ baseUrl: this.baseUrl });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ── Tokens ──────────────────────────────────────────────────────────────
|
|
140
|
+
getToken(): string | null { return this.storage.getItem(ACCESS_KEY); }
|
|
141
|
+
setToken(token: string | null): void {
|
|
142
|
+
if (token) this.storage.setItem(ACCESS_KEY, token);
|
|
143
|
+
else this.storage.removeItem(ACCESS_KEY);
|
|
144
|
+
}
|
|
145
|
+
getRefreshToken(): string | null { return this.storage.getItem(REFRESH_KEY); }
|
|
146
|
+
setRefreshToken(token: string | null): void {
|
|
147
|
+
if (token) this.storage.setItem(REFRESH_KEY, token);
|
|
148
|
+
else this.storage.removeItem(REFRESH_KEY);
|
|
149
|
+
}
|
|
150
|
+
clearToken(): void {
|
|
151
|
+
this.storage.removeItem(ACCESS_KEY);
|
|
152
|
+
this.storage.removeItem(REFRESH_KEY);
|
|
153
|
+
}
|
|
154
|
+
isAuthenticated(): boolean { return this.getToken() !== null; }
|
|
155
|
+
|
|
156
|
+
// ── Locale / API key ────────────────────────────────────────────────────
|
|
157
|
+
getLocale(): string | null { return this.locale ?? detectLocale(); }
|
|
158
|
+
setLocale(locale: string | null): void { this.locale = locale; }
|
|
159
|
+
getApiKey(): string | null { return this.apiKey; }
|
|
160
|
+
setApiKey(key: string | null): void { this.apiKey = key; }
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export { Cfg, Centrifugo, CentrifugoAuth };
|
|
164
|
+
export { client };
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import { createSseClient } from '../core/serverSentEvents.gen';
|
|
4
|
+
import type { HttpMethod } from '../core/types.gen';
|
|
5
|
+
import { getValidRequestBody } from '../core/utils.gen';
|
|
6
|
+
import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types.gen';
|
|
7
|
+
import {
|
|
8
|
+
buildUrl,
|
|
9
|
+
createConfig,
|
|
10
|
+
createInterceptors,
|
|
11
|
+
getParseAs,
|
|
12
|
+
mergeConfigs,
|
|
13
|
+
mergeHeaders,
|
|
14
|
+
setAuthParams,
|
|
15
|
+
} from './utils.gen';
|
|
16
|
+
|
|
17
|
+
type ReqInit = Omit<RequestInit, 'body' | 'headers'> & {
|
|
18
|
+
body?: any;
|
|
19
|
+
headers: ReturnType<typeof mergeHeaders>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const createClient = (config: Config = {}): Client => {
|
|
23
|
+
let _config = mergeConfigs(createConfig(), config);
|
|
24
|
+
|
|
25
|
+
const getConfig = (): Config => ({ ..._config });
|
|
26
|
+
|
|
27
|
+
const setConfig = (config: Config): Config => {
|
|
28
|
+
_config = mergeConfigs(_config, config);
|
|
29
|
+
return getConfig();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const interceptors = createInterceptors<Request, Response, unknown, ResolvedRequestOptions>();
|
|
33
|
+
|
|
34
|
+
const beforeRequest = async <
|
|
35
|
+
TData = unknown,
|
|
36
|
+
TResponseStyle extends 'data' | 'fields' = 'fields',
|
|
37
|
+
ThrowOnError extends boolean = boolean,
|
|
38
|
+
Url extends string = string,
|
|
39
|
+
>(
|
|
40
|
+
options: RequestOptions<TData, TResponseStyle, ThrowOnError, Url>,
|
|
41
|
+
) => {
|
|
42
|
+
const opts = {
|
|
43
|
+
..._config,
|
|
44
|
+
...options,
|
|
45
|
+
fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
|
|
46
|
+
headers: mergeHeaders(_config.headers, options.headers),
|
|
47
|
+
serializedBody: undefined as string | undefined,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
if (opts.security) {
|
|
51
|
+
await setAuthParams({
|
|
52
|
+
...opts,
|
|
53
|
+
security: opts.security,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (opts.requestValidator) {
|
|
58
|
+
await opts.requestValidator(opts);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (opts.body !== undefined && opts.bodySerializer) {
|
|
62
|
+
opts.serializedBody = opts.bodySerializer(opts.body) as string | undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// remove Content-Type header if body is empty to avoid sending invalid requests
|
|
66
|
+
if (opts.body === undefined || opts.serializedBody === '') {
|
|
67
|
+
opts.headers.delete('Content-Type');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const resolvedOpts = opts as typeof opts &
|
|
71
|
+
ResolvedRequestOptions<TResponseStyle, ThrowOnError, Url>;
|
|
72
|
+
const url = buildUrl(resolvedOpts);
|
|
73
|
+
|
|
74
|
+
return { opts: resolvedOpts, url };
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const request: Client['request'] = async (options) => {
|
|
78
|
+
const throwOnError = options.throwOnError ?? _config.throwOnError;
|
|
79
|
+
const responseStyle = options.responseStyle ?? _config.responseStyle;
|
|
80
|
+
|
|
81
|
+
let request: Request | undefined;
|
|
82
|
+
let response: Response | undefined;
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
const { opts, url } = await beforeRequest(options);
|
|
86
|
+
const requestInit: ReqInit = {
|
|
87
|
+
redirect: 'follow',
|
|
88
|
+
...opts,
|
|
89
|
+
body: getValidRequestBody(opts),
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
request = new Request(url, requestInit);
|
|
93
|
+
|
|
94
|
+
for (const fn of interceptors.request.fns) {
|
|
95
|
+
if (fn) {
|
|
96
|
+
request = await fn(request, opts);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// fetch must be assigned here, otherwise it would throw the error:
|
|
101
|
+
// TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
|
|
102
|
+
const _fetch = opts.fetch!;
|
|
103
|
+
|
|
104
|
+
response = await _fetch(request);
|
|
105
|
+
|
|
106
|
+
for (const fn of interceptors.response.fns) {
|
|
107
|
+
if (fn) {
|
|
108
|
+
response = await fn(response, request, opts);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const result = {
|
|
113
|
+
request,
|
|
114
|
+
response,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
if (response.ok) {
|
|
118
|
+
const parseAs =
|
|
119
|
+
(opts.parseAs === 'auto'
|
|
120
|
+
? getParseAs(response.headers.get('Content-Type'))
|
|
121
|
+
: opts.parseAs) ?? 'json';
|
|
122
|
+
|
|
123
|
+
if (response.status === 204 || response.headers.get('Content-Length') === '0') {
|
|
124
|
+
let emptyData: any;
|
|
125
|
+
switch (parseAs) {
|
|
126
|
+
case 'arrayBuffer':
|
|
127
|
+
case 'blob':
|
|
128
|
+
case 'text':
|
|
129
|
+
emptyData = await response[parseAs]();
|
|
130
|
+
break;
|
|
131
|
+
case 'formData':
|
|
132
|
+
emptyData = new FormData();
|
|
133
|
+
break;
|
|
134
|
+
case 'stream':
|
|
135
|
+
emptyData = response.body;
|
|
136
|
+
break;
|
|
137
|
+
case 'json':
|
|
138
|
+
default:
|
|
139
|
+
emptyData = {};
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
return opts.responseStyle === 'data'
|
|
143
|
+
? emptyData
|
|
144
|
+
: {
|
|
145
|
+
data: emptyData,
|
|
146
|
+
...result,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
let data: any;
|
|
151
|
+
switch (parseAs) {
|
|
152
|
+
case 'arrayBuffer':
|
|
153
|
+
case 'blob':
|
|
154
|
+
case 'formData':
|
|
155
|
+
case 'text':
|
|
156
|
+
data = await response[parseAs]();
|
|
157
|
+
break;
|
|
158
|
+
case 'json': {
|
|
159
|
+
// Some servers return 200 with no Content-Length and empty body.
|
|
160
|
+
// response.json() would throw; read as text and parse if non-empty.
|
|
161
|
+
const text = await response.text();
|
|
162
|
+
data = text ? JSON.parse(text) : {};
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case 'stream':
|
|
166
|
+
return opts.responseStyle === 'data'
|
|
167
|
+
? response.body
|
|
168
|
+
: {
|
|
169
|
+
data: response.body,
|
|
170
|
+
...result,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
if (parseAs === 'json') {
|
|
175
|
+
if (opts.responseValidator) {
|
|
176
|
+
await opts.responseValidator(data);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (opts.responseTransformer) {
|
|
180
|
+
data = await opts.responseTransformer(data);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return opts.responseStyle === 'data'
|
|
185
|
+
? data
|
|
186
|
+
: {
|
|
187
|
+
data,
|
|
188
|
+
...result,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const textError = await response.text();
|
|
193
|
+
let jsonError: unknown;
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
jsonError = JSON.parse(textError);
|
|
197
|
+
} catch {
|
|
198
|
+
// noop
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
throw jsonError ?? textError;
|
|
202
|
+
} catch (error) {
|
|
203
|
+
let finalError = error;
|
|
204
|
+
|
|
205
|
+
for (const fn of interceptors.error.fns) {
|
|
206
|
+
if (fn) {
|
|
207
|
+
finalError = await fn(finalError, response, request, options as ResolvedRequestOptions);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
finalError = finalError || {};
|
|
212
|
+
|
|
213
|
+
if (throwOnError) {
|
|
214
|
+
throw finalError;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// TODO: we probably want to return error and improve types
|
|
218
|
+
return responseStyle === 'data'
|
|
219
|
+
? undefined
|
|
220
|
+
: {
|
|
221
|
+
error: finalError,
|
|
222
|
+
request,
|
|
223
|
+
response,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const makeMethodFn = (method: Uppercase<HttpMethod>) => (options: RequestOptions) =>
|
|
229
|
+
request({ ...options, method });
|
|
230
|
+
|
|
231
|
+
const makeSseFn = (method: Uppercase<HttpMethod>) => async (options: RequestOptions) => {
|
|
232
|
+
const { opts, url } = await beforeRequest(options);
|
|
233
|
+
return createSseClient({
|
|
234
|
+
...opts,
|
|
235
|
+
body: opts.body as BodyInit | null | undefined,
|
|
236
|
+
method,
|
|
237
|
+
onRequest: async (url, init) => {
|
|
238
|
+
let request = new Request(url, init);
|
|
239
|
+
for (const fn of interceptors.request.fns) {
|
|
240
|
+
if (fn) {
|
|
241
|
+
request = await fn(request, opts);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return request;
|
|
245
|
+
},
|
|
246
|
+
serializedBody: getValidRequestBody(opts) as BodyInit | null | undefined,
|
|
247
|
+
url,
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
const _buildUrl: Client['buildUrl'] = (options) => buildUrl({ ..._config, ...options });
|
|
252
|
+
|
|
253
|
+
return {
|
|
254
|
+
buildUrl: _buildUrl,
|
|
255
|
+
connect: makeMethodFn('CONNECT'),
|
|
256
|
+
delete: makeMethodFn('DELETE'),
|
|
257
|
+
get: makeMethodFn('GET'),
|
|
258
|
+
getConfig,
|
|
259
|
+
head: makeMethodFn('HEAD'),
|
|
260
|
+
interceptors,
|
|
261
|
+
options: makeMethodFn('OPTIONS'),
|
|
262
|
+
patch: makeMethodFn('PATCH'),
|
|
263
|
+
post: makeMethodFn('POST'),
|
|
264
|
+
put: makeMethodFn('PUT'),
|
|
265
|
+
request,
|
|
266
|
+
setConfig,
|
|
267
|
+
sse: {
|
|
268
|
+
connect: makeSseFn('CONNECT'),
|
|
269
|
+
delete: makeSseFn('DELETE'),
|
|
270
|
+
get: makeSseFn('GET'),
|
|
271
|
+
head: makeSseFn('HEAD'),
|
|
272
|
+
options: makeSseFn('OPTIONS'),
|
|
273
|
+
patch: makeSseFn('PATCH'),
|
|
274
|
+
post: makeSseFn('POST'),
|
|
275
|
+
put: makeSseFn('PUT'),
|
|
276
|
+
trace: makeSseFn('TRACE'),
|
|
277
|
+
},
|
|
278
|
+
trace: makeMethodFn('TRACE'),
|
|
279
|
+
} as Client;
|
|
280
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
export type { Auth } from '../core/auth.gen';
|
|
4
|
+
export type { QuerySerializerOptions } from '../core/bodySerializer.gen';
|
|
5
|
+
export {
|
|
6
|
+
formDataBodySerializer,
|
|
7
|
+
jsonBodySerializer,
|
|
8
|
+
urlSearchParamsBodySerializer,
|
|
9
|
+
} from '../core/bodySerializer.gen';
|
|
10
|
+
export { buildClientParams } from '../core/params.gen';
|
|
11
|
+
export { serializeQueryKeyValue } from '../core/queryKeySerializer.gen';
|
|
12
|
+
export { createClient } from './client.gen';
|
|
13
|
+
export type {
|
|
14
|
+
Client,
|
|
15
|
+
ClientOptions,
|
|
16
|
+
Config,
|
|
17
|
+
CreateClientConfig,
|
|
18
|
+
Options,
|
|
19
|
+
RequestOptions,
|
|
20
|
+
RequestResult,
|
|
21
|
+
ResolvedRequestOptions,
|
|
22
|
+
ResponseStyle,
|
|
23
|
+
TDataShape,
|
|
24
|
+
} from './types.gen';
|
|
25
|
+
export { createConfig, mergeHeaders } from './utils.gen';
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { Auth } from '../core/auth.gen';
|
|
4
|
+
import type {
|
|
5
|
+
ServerSentEventsOptions,
|
|
6
|
+
ServerSentEventsResult,
|
|
7
|
+
} from '../core/serverSentEvents.gen';
|
|
8
|
+
import type { Client as CoreClient, Config as CoreConfig } from '../core/types.gen';
|
|
9
|
+
import type { Middleware } from './utils.gen';
|
|
10
|
+
|
|
11
|
+
export type ResponseStyle = 'data' | 'fields';
|
|
12
|
+
|
|
13
|
+
export interface Config<T extends ClientOptions = ClientOptions>
|
|
14
|
+
extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
|
|
15
|
+
/**
|
|
16
|
+
* Base URL for all requests made by this client.
|
|
17
|
+
*/
|
|
18
|
+
baseUrl?: T['baseUrl'];
|
|
19
|
+
/**
|
|
20
|
+
* Fetch API implementation. You can use this option to provide a custom
|
|
21
|
+
* fetch instance.
|
|
22
|
+
*
|
|
23
|
+
* @default globalThis.fetch
|
|
24
|
+
*/
|
|
25
|
+
fetch?: typeof fetch;
|
|
26
|
+
/**
|
|
27
|
+
* Please don't use the Fetch client for Next.js applications. The `next`
|
|
28
|
+
* options won't have any effect.
|
|
29
|
+
*
|
|
30
|
+
* Install {@link https://www.npmjs.com/package/@hey-api/client-next `@hey-api/client-next`} instead.
|
|
31
|
+
*/
|
|
32
|
+
next?: never;
|
|
33
|
+
/**
|
|
34
|
+
* Return the response data parsed in a specified format. By default, `auto`
|
|
35
|
+
* will infer the appropriate method from the `Content-Type` response header.
|
|
36
|
+
* You can override this behavior with any of the {@link Body} methods.
|
|
37
|
+
* Select `stream` if you don't want to parse response data at all.
|
|
38
|
+
*
|
|
39
|
+
* @default 'auto'
|
|
40
|
+
*/
|
|
41
|
+
parseAs?: 'arrayBuffer' | 'auto' | 'blob' | 'formData' | 'json' | 'stream' | 'text';
|
|
42
|
+
/**
|
|
43
|
+
* Should we return only data or multiple fields (data, error, response, etc.)?
|
|
44
|
+
*
|
|
45
|
+
* @default 'fields'
|
|
46
|
+
*/
|
|
47
|
+
responseStyle?: ResponseStyle;
|
|
48
|
+
/**
|
|
49
|
+
* Throw an error instead of returning it in the response?
|
|
50
|
+
*
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
throwOnError?: T['throwOnError'];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface RequestOptions<
|
|
57
|
+
TData = unknown,
|
|
58
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
59
|
+
ThrowOnError extends boolean = boolean,
|
|
60
|
+
Url extends string = string,
|
|
61
|
+
>
|
|
62
|
+
extends
|
|
63
|
+
Config<{
|
|
64
|
+
responseStyle: TResponseStyle;
|
|
65
|
+
throwOnError: ThrowOnError;
|
|
66
|
+
}>,
|
|
67
|
+
Pick<
|
|
68
|
+
ServerSentEventsOptions<TData>,
|
|
69
|
+
| 'onRequest'
|
|
70
|
+
| 'onSseError'
|
|
71
|
+
| 'onSseEvent'
|
|
72
|
+
| 'sseDefaultRetryDelay'
|
|
73
|
+
| 'sseMaxRetryAttempts'
|
|
74
|
+
| 'sseMaxRetryDelay'
|
|
75
|
+
> {
|
|
76
|
+
/**
|
|
77
|
+
* Any body that you want to add to your request.
|
|
78
|
+
*
|
|
79
|
+
* {@link https://developer.mozilla.org/docs/Web/API/fetch#body}
|
|
80
|
+
*/
|
|
81
|
+
body?: unknown;
|
|
82
|
+
path?: Record<string, unknown>;
|
|
83
|
+
query?: Record<string, unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Security mechanism(s) to use for the request.
|
|
86
|
+
*/
|
|
87
|
+
security?: ReadonlyArray<Auth>;
|
|
88
|
+
url: Url;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ResolvedRequestOptions<
|
|
92
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
93
|
+
ThrowOnError extends boolean = boolean,
|
|
94
|
+
Url extends string = string,
|
|
95
|
+
> extends RequestOptions<unknown, TResponseStyle, ThrowOnError, Url> {
|
|
96
|
+
headers: Headers;
|
|
97
|
+
serializedBody?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type RequestResult<
|
|
101
|
+
TData = unknown,
|
|
102
|
+
TError = unknown,
|
|
103
|
+
ThrowOnError extends boolean = boolean,
|
|
104
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
105
|
+
> = ThrowOnError extends true
|
|
106
|
+
? Promise<
|
|
107
|
+
TResponseStyle extends 'data'
|
|
108
|
+
? TData extends Record<string, unknown>
|
|
109
|
+
? TData[keyof TData]
|
|
110
|
+
: TData
|
|
111
|
+
: {
|
|
112
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
113
|
+
request: Request;
|
|
114
|
+
response: Response;
|
|
115
|
+
}
|
|
116
|
+
>
|
|
117
|
+
: Promise<
|
|
118
|
+
TResponseStyle extends 'data'
|
|
119
|
+
? (TData extends Record<string, unknown> ? TData[keyof TData] : TData) | undefined
|
|
120
|
+
: (
|
|
121
|
+
| {
|
|
122
|
+
data: TData extends Record<string, unknown> ? TData[keyof TData] : TData;
|
|
123
|
+
error: undefined;
|
|
124
|
+
}
|
|
125
|
+
| {
|
|
126
|
+
data: undefined;
|
|
127
|
+
error: TError extends Record<string, unknown> ? TError[keyof TError] : TError;
|
|
128
|
+
}
|
|
129
|
+
) & {
|
|
130
|
+
/** request may be undefined, because error may be from building the request object itself */
|
|
131
|
+
request?: Request;
|
|
132
|
+
/** response may be undefined, because error may be from building the request object itself or from a network error */
|
|
133
|
+
response?: Response;
|
|
134
|
+
}
|
|
135
|
+
>;
|
|
136
|
+
|
|
137
|
+
export interface ClientOptions {
|
|
138
|
+
baseUrl?: string;
|
|
139
|
+
responseStyle?: ResponseStyle;
|
|
140
|
+
throwOnError?: boolean;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
type MethodFn = <
|
|
144
|
+
TData = unknown,
|
|
145
|
+
TError = unknown,
|
|
146
|
+
ThrowOnError extends boolean = false,
|
|
147
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
148
|
+
>(
|
|
149
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'>,
|
|
150
|
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
151
|
+
|
|
152
|
+
type SseFn = <
|
|
153
|
+
TData = unknown,
|
|
154
|
+
TError = unknown,
|
|
155
|
+
ThrowOnError extends boolean = false,
|
|
156
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
157
|
+
>(
|
|
158
|
+
options: Omit<RequestOptions<never, TResponseStyle, ThrowOnError>, 'method'>,
|
|
159
|
+
) => Promise<ServerSentEventsResult<TData, TError>>;
|
|
160
|
+
|
|
161
|
+
type RequestFn = <
|
|
162
|
+
TData = unknown,
|
|
163
|
+
TError = unknown,
|
|
164
|
+
ThrowOnError extends boolean = false,
|
|
165
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
166
|
+
>(
|
|
167
|
+
options: Omit<RequestOptions<TData, TResponseStyle, ThrowOnError>, 'method'> &
|
|
168
|
+
Pick<Required<RequestOptions<TData, TResponseStyle, ThrowOnError>>, 'method'>,
|
|
169
|
+
) => RequestResult<TData, TError, ThrowOnError, TResponseStyle>;
|
|
170
|
+
|
|
171
|
+
type BuildUrlFn = <
|
|
172
|
+
TData extends {
|
|
173
|
+
body?: unknown;
|
|
174
|
+
path?: Record<string, unknown>;
|
|
175
|
+
query?: Record<string, unknown>;
|
|
176
|
+
url: string;
|
|
177
|
+
},
|
|
178
|
+
>(
|
|
179
|
+
options: TData & Options<TData>,
|
|
180
|
+
) => string;
|
|
181
|
+
|
|
182
|
+
export type Client = CoreClient<RequestFn, Config, MethodFn, BuildUrlFn, SseFn> & {
|
|
183
|
+
interceptors: Middleware<Request, Response, unknown, ResolvedRequestOptions>;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The `createClientConfig()` function will be called on client initialization
|
|
188
|
+
* and the returned object will become the client's initial configuration.
|
|
189
|
+
*
|
|
190
|
+
* You may want to initialize your client this way instead of calling
|
|
191
|
+
* `setConfig()`. This is useful for example if you're using Next.js
|
|
192
|
+
* to ensure your client always has the correct values.
|
|
193
|
+
*/
|
|
194
|
+
export type CreateClientConfig<T extends ClientOptions = ClientOptions> = (
|
|
195
|
+
override?: Config<ClientOptions & T>,
|
|
196
|
+
) => Config<Required<ClientOptions> & T>;
|
|
197
|
+
|
|
198
|
+
export interface TDataShape {
|
|
199
|
+
body?: unknown;
|
|
200
|
+
headers?: unknown;
|
|
201
|
+
path?: unknown;
|
|
202
|
+
query?: unknown;
|
|
203
|
+
url: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
207
|
+
|
|
208
|
+
export type Options<
|
|
209
|
+
TData extends TDataShape = TDataShape,
|
|
210
|
+
ThrowOnError extends boolean = boolean,
|
|
211
|
+
TResponse = unknown,
|
|
212
|
+
TResponseStyle extends ResponseStyle = 'fields',
|
|
213
|
+
> = OmitKeys<
|
|
214
|
+
RequestOptions<TResponse, TResponseStyle, ThrowOnError>,
|
|
215
|
+
'body' | 'path' | 'query' | 'url'
|
|
216
|
+
> &
|
|
217
|
+
([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|