@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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
+
|
|
3
|
+
import type { BodySerializer, QuerySerializer } from './bodySerializer.gen';
|
|
4
|
+
import {
|
|
5
|
+
type ArraySeparatorStyle,
|
|
6
|
+
serializeArrayParam,
|
|
7
|
+
serializeObjectParam,
|
|
8
|
+
serializePrimitiveParam,
|
|
9
|
+
} from './pathSerializer.gen';
|
|
10
|
+
|
|
11
|
+
export interface PathSerializer {
|
|
12
|
+
path: Record<string, unknown>;
|
|
13
|
+
url: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const PATH_PARAM_RE = /\{[^{}]+\}/g;
|
|
17
|
+
|
|
18
|
+
export const defaultPathSerializer = ({ path, url: _url }: PathSerializer) => {
|
|
19
|
+
let url = _url;
|
|
20
|
+
const matches = _url.match(PATH_PARAM_RE);
|
|
21
|
+
if (matches) {
|
|
22
|
+
for (const match of matches) {
|
|
23
|
+
let explode = false;
|
|
24
|
+
let name = match.substring(1, match.length - 1);
|
|
25
|
+
let style: ArraySeparatorStyle = 'simple';
|
|
26
|
+
|
|
27
|
+
if (name.endsWith('*')) {
|
|
28
|
+
explode = true;
|
|
29
|
+
name = name.substring(0, name.length - 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (name.startsWith('.')) {
|
|
33
|
+
name = name.substring(1);
|
|
34
|
+
style = 'label';
|
|
35
|
+
} else if (name.startsWith(';')) {
|
|
36
|
+
name = name.substring(1);
|
|
37
|
+
style = 'matrix';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const value = path[name];
|
|
41
|
+
|
|
42
|
+
if (value === undefined || value === null) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (typeof value === 'object') {
|
|
52
|
+
url = url.replace(
|
|
53
|
+
match,
|
|
54
|
+
serializeObjectParam({
|
|
55
|
+
explode,
|
|
56
|
+
name,
|
|
57
|
+
style,
|
|
58
|
+
value: value as Record<string, unknown>,
|
|
59
|
+
valueOnly: true,
|
|
60
|
+
}),
|
|
61
|
+
);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (style === 'matrix') {
|
|
66
|
+
url = url.replace(
|
|
67
|
+
match,
|
|
68
|
+
`;${serializePrimitiveParam({
|
|
69
|
+
name,
|
|
70
|
+
value: value as string,
|
|
71
|
+
})}`,
|
|
72
|
+
);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const replaceValue = encodeURIComponent(
|
|
77
|
+
style === 'label' ? `.${value as string}` : (value as string),
|
|
78
|
+
);
|
|
79
|
+
url = url.replace(match, replaceValue);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return url;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const getUrl = ({
|
|
86
|
+
baseUrl,
|
|
87
|
+
path,
|
|
88
|
+
query,
|
|
89
|
+
querySerializer,
|
|
90
|
+
url: _url,
|
|
91
|
+
}: {
|
|
92
|
+
baseUrl?: string;
|
|
93
|
+
path?: Record<string, unknown>;
|
|
94
|
+
query?: Record<string, unknown>;
|
|
95
|
+
querySerializer: QuerySerializer;
|
|
96
|
+
url: string;
|
|
97
|
+
}) => {
|
|
98
|
+
const pathUrl = _url.startsWith('/') ? _url : `/${_url}`;
|
|
99
|
+
let url = (baseUrl ?? '') + pathUrl;
|
|
100
|
+
if (path) {
|
|
101
|
+
url = defaultPathSerializer({ path, url });
|
|
102
|
+
}
|
|
103
|
+
let search = query ? querySerializer(query) : '';
|
|
104
|
+
if (search.startsWith('?')) {
|
|
105
|
+
search = search.substring(1);
|
|
106
|
+
}
|
|
107
|
+
if (search) {
|
|
108
|
+
url += `?${search}`;
|
|
109
|
+
}
|
|
110
|
+
return url;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export function getValidRequestBody(options: {
|
|
114
|
+
body?: unknown;
|
|
115
|
+
bodySerializer?: BodySerializer | null;
|
|
116
|
+
serializedBody?: unknown;
|
|
117
|
+
}) {
|
|
118
|
+
const hasBody = options.body !== undefined;
|
|
119
|
+
const isSerializedBody = hasBody && options.bodySerializer;
|
|
120
|
+
|
|
121
|
+
if (isSerializedBody) {
|
|
122
|
+
if ('serializedBody' in options) {
|
|
123
|
+
const hasSerializedBody =
|
|
124
|
+
options.serializedBody !== undefined && options.serializedBody !== '';
|
|
125
|
+
|
|
126
|
+
return hasSerializedBody ? options.serializedBody : null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// not all clients implement a serializedBody property (i.e., client-axios)
|
|
130
|
+
return options.body !== '' ? options.body : null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// plain/text body
|
|
134
|
+
if (hasBody) {
|
|
135
|
+
return options.body;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// no body was provided
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Typed error classes with DRF field-error support.
|
|
3
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* HTTP API Error with DRF field-specific validation errors.
|
|
7
|
+
*/
|
|
8
|
+
export class APIError extends Error {
|
|
9
|
+
constructor(
|
|
10
|
+
public statusCode: number,
|
|
11
|
+
public statusText: string,
|
|
12
|
+
public response: any,
|
|
13
|
+
public url: string,
|
|
14
|
+
message?: string,
|
|
15
|
+
) {
|
|
16
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
17
|
+
this.name = "APIError";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get details(): Record<string, any> | null {
|
|
21
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
22
|
+
return this.response;
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get fieldErrors(): Record<string, string[]> | null {
|
|
28
|
+
const details = this.details;
|
|
29
|
+
if (!details) return null;
|
|
30
|
+
const fieldErrors: Record<string, string[]> = {};
|
|
31
|
+
for (const [key, value] of Object.entries(details)) {
|
|
32
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get errorMessage(): string {
|
|
38
|
+
const details = this.details;
|
|
39
|
+
if (!details) return this.message;
|
|
40
|
+
if (details.detail) {
|
|
41
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
42
|
+
}
|
|
43
|
+
if (details.error) return String(details.error);
|
|
44
|
+
if (details.message) return String(details.message);
|
|
45
|
+
const fieldErrors = this.fieldErrors;
|
|
46
|
+
if (fieldErrors) {
|
|
47
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
48
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
49
|
+
}
|
|
50
|
+
return this.message;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get isValidationError(): boolean { return this.statusCode === 400; }
|
|
54
|
+
get isAuthError(): boolean { return this.statusCode === 401; }
|
|
55
|
+
get isPermissionError(): boolean { return this.statusCode === 403; }
|
|
56
|
+
get isNotFoundError(): boolean { return this.statusCode === 404; }
|
|
57
|
+
get isServerError(): boolean { return this.statusCode >= 500 && this.statusCode < 600; }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Network Error (connection failed, timeout, etc.) */
|
|
61
|
+
export class NetworkError extends Error {
|
|
62
|
+
constructor(
|
|
63
|
+
message: string,
|
|
64
|
+
public url: string,
|
|
65
|
+
public originalError?: Error,
|
|
66
|
+
) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "NetworkError";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Shared utilities barrel. DO NOT EDIT — re-run `make gen`.
|
|
3
|
+
|
|
4
|
+
export {
|
|
5
|
+
type StorageAdapter,
|
|
6
|
+
LocalStorageAdapter,
|
|
7
|
+
MemoryStorageAdapter,
|
|
8
|
+
CookieStorageAdapter,
|
|
9
|
+
} from './storage';
|
|
10
|
+
export { APIError, NetworkError } from './errors';
|
|
11
|
+
export {
|
|
12
|
+
APILogger,
|
|
13
|
+
defaultLogger,
|
|
14
|
+
type LoggerConfig,
|
|
15
|
+
type RequestLog,
|
|
16
|
+
type ResponseLog,
|
|
17
|
+
type ErrorLog,
|
|
18
|
+
} from './logger';
|
|
19
|
+
export {
|
|
20
|
+
dispatchValidationError,
|
|
21
|
+
onValidationError,
|
|
22
|
+
formatZodError,
|
|
23
|
+
type ValidationErrorDetail,
|
|
24
|
+
type ValidationErrorEvent,
|
|
25
|
+
} from './validation-events';
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// API logger built on consola. Optional dependency — install if you enable logging:
|
|
3
|
+
// npm install consola
|
|
4
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
5
|
+
|
|
6
|
+
import { type ConsolaInstance, createConsola } from "consola";
|
|
7
|
+
|
|
8
|
+
export interface RequestLog {
|
|
9
|
+
method: string;
|
|
10
|
+
url: string;
|
|
11
|
+
headers?: Record<string, string>;
|
|
12
|
+
body?: any;
|
|
13
|
+
timestamp: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface ResponseLog {
|
|
17
|
+
status: number;
|
|
18
|
+
statusText: string;
|
|
19
|
+
data?: any;
|
|
20
|
+
duration: number;
|
|
21
|
+
timestamp: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ErrorLog {
|
|
25
|
+
message: string;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
fieldErrors?: Record<string, string[]>;
|
|
28
|
+
duration: number;
|
|
29
|
+
timestamp: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface LoggerConfig {
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
logRequests: boolean;
|
|
35
|
+
logResponses: boolean;
|
|
36
|
+
logErrors: boolean;
|
|
37
|
+
logBodies: boolean;
|
|
38
|
+
logHeaders: boolean;
|
|
39
|
+
consola?: ConsolaInstance;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const DEFAULT_CONFIG: LoggerConfig = {
|
|
43
|
+
enabled: typeof process !== "undefined" && process.env?.NODE_ENV !== "production",
|
|
44
|
+
logRequests: true,
|
|
45
|
+
logResponses: true,
|
|
46
|
+
logErrors: true,
|
|
47
|
+
logBodies: true,
|
|
48
|
+
logHeaders: false,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const SENSITIVE_HEADERS = [
|
|
52
|
+
"authorization",
|
|
53
|
+
"cookie",
|
|
54
|
+
"set-cookie",
|
|
55
|
+
"x-api-key",
|
|
56
|
+
"x-csrf-token",
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
export class APILogger {
|
|
60
|
+
private config: LoggerConfig;
|
|
61
|
+
private consola: ConsolaInstance;
|
|
62
|
+
|
|
63
|
+
constructor(config: Partial<LoggerConfig> = {}) {
|
|
64
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
65
|
+
this.consola = config.consola || createConsola({
|
|
66
|
+
level: this.config.enabled ? 4 : 0,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
enable(): void { this.config.enabled = true; }
|
|
71
|
+
disable(): void { this.config.enabled = false; }
|
|
72
|
+
setConfig(config: Partial<LoggerConfig>): void {
|
|
73
|
+
this.config = { ...this.config, ...config };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
private filterHeaders(headers?: Record<string, string>): Record<string, string> {
|
|
77
|
+
if (!headers) return {};
|
|
78
|
+
const filtered: Record<string, string> = {};
|
|
79
|
+
Object.keys(headers).forEach((key) => {
|
|
80
|
+
filtered[key] = SENSITIVE_HEADERS.includes(key.toLowerCase()) ? "***" : (headers[key] || "");
|
|
81
|
+
});
|
|
82
|
+
return filtered;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
logRequest(request: RequestLog): void {
|
|
86
|
+
if (!this.config.enabled || !this.config.logRequests) return;
|
|
87
|
+
const { method, url, headers, body } = request;
|
|
88
|
+
this.consola.start(`${method} ${url}`);
|
|
89
|
+
if (this.config.logHeaders && headers) this.consola.debug("Headers:", this.filterHeaders(headers));
|
|
90
|
+
if (this.config.logBodies && body) this.consola.debug("Body:", body);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
logResponse(request: RequestLog, response: ResponseLog): void {
|
|
94
|
+
if (!this.config.enabled || !this.config.logResponses) return;
|
|
95
|
+
const { method, url } = request;
|
|
96
|
+
const { status, statusText, data, duration } = response;
|
|
97
|
+
this.consola.success(`${method} ${url} ${status} ${statusText} (${duration}ms)`);
|
|
98
|
+
if (this.config.logBodies && data) this.consola.debug("Response:", data);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
logError(request: RequestLog, error: ErrorLog): void {
|
|
102
|
+
if (!this.config.enabled || !this.config.logErrors) return;
|
|
103
|
+
const { method, url } = request;
|
|
104
|
+
const { message, statusCode, fieldErrors, duration } = error;
|
|
105
|
+
this.consola.error(`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`);
|
|
106
|
+
this.consola.error("Message:", message);
|
|
107
|
+
if (fieldErrors && Object.keys(fieldErrors).length > 0) {
|
|
108
|
+
this.consola.error("Field Errors:");
|
|
109
|
+
Object.entries(fieldErrors).forEach(([field, errors]) => {
|
|
110
|
+
errors.forEach((err) => this.consola.error(` • ${field}: ${err}`));
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
info(message: string, ...args: any[]): void { if (this.config.enabled) this.consola.info(message, ...args); }
|
|
116
|
+
warn(message: string, ...args: any[]): void { if (this.config.enabled) this.consola.warn(message, ...args); }
|
|
117
|
+
error(message: string, ...args: any[]): void { if (this.config.enabled) this.consola.error(message, ...args); }
|
|
118
|
+
debug(message: string, ...args: any[]): void { if (this.config.enabled) this.consola.debug(message, ...args); }
|
|
119
|
+
success(message: string, ...args: any[]): void { if (this.config.enabled) this.consola.success(message, ...args); }
|
|
120
|
+
withTag(tag: string): ConsolaInstance { return this.consola.withTag(tag); }
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export const defaultLogger = new APILogger();
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Storage adapters for token persistence.
|
|
3
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
4
|
+
|
|
5
|
+
export interface StorageAdapter {
|
|
6
|
+
getItem(key: string): string | null;
|
|
7
|
+
setItem(key: string, value: string): void;
|
|
8
|
+
removeItem(key: string): void;
|
|
9
|
+
clear?(): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Browser localStorage. Falls back to no-op on SSR / private mode. */
|
|
13
|
+
export class LocalStorageAdapter implements StorageAdapter {
|
|
14
|
+
getItem(key: string): string | null {
|
|
15
|
+
if (typeof window === "undefined") return null;
|
|
16
|
+
try { return window.localStorage.getItem(key); } catch { return null; }
|
|
17
|
+
}
|
|
18
|
+
setItem(key: string, value: string): void {
|
|
19
|
+
if (typeof window === "undefined") return;
|
|
20
|
+
try { window.localStorage.setItem(key, value); } catch { /* quota / private */ }
|
|
21
|
+
}
|
|
22
|
+
removeItem(key: string): void {
|
|
23
|
+
if (typeof window === "undefined") return;
|
|
24
|
+
try { window.localStorage.removeItem(key); } catch { /* ignore */ }
|
|
25
|
+
}
|
|
26
|
+
clear(): void {
|
|
27
|
+
if (typeof window === "undefined") return;
|
|
28
|
+
try { window.localStorage.clear(); } catch { /* ignore */ }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** In-memory store. Use for SSR, Electron main process, or tests. */
|
|
33
|
+
export class MemoryStorageAdapter implements StorageAdapter {
|
|
34
|
+
private store = new Map<string, string>();
|
|
35
|
+
getItem(key: string): string | null { return this.store.get(key) ?? null; }
|
|
36
|
+
setItem(key: string, value: string): void { this.store.set(key, value); }
|
|
37
|
+
removeItem(key: string): void { this.store.delete(key); }
|
|
38
|
+
clear(): void { this.store.clear(); }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Cookie-backed storage (browser only). */
|
|
42
|
+
export class CookieStorageAdapter implements StorageAdapter {
|
|
43
|
+
constructor(
|
|
44
|
+
private opts: {
|
|
45
|
+
domain?: string;
|
|
46
|
+
path?: string;
|
|
47
|
+
secure?: boolean;
|
|
48
|
+
sameSite?: "Strict" | "Lax" | "None";
|
|
49
|
+
maxAgeSeconds?: number;
|
|
50
|
+
} = {},
|
|
51
|
+
) {}
|
|
52
|
+
|
|
53
|
+
getItem(key: string): string | null {
|
|
54
|
+
if (typeof document === "undefined") return null;
|
|
55
|
+
const prefix = `${encodeURIComponent(key)}=`;
|
|
56
|
+
for (const part of document.cookie.split("; ")) {
|
|
57
|
+
if (part.startsWith(prefix)) {
|
|
58
|
+
return decodeURIComponent(part.slice(prefix.length));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
setItem(key: string, value: string): void {
|
|
65
|
+
if (typeof document === "undefined") return;
|
|
66
|
+
const parts = [
|
|
67
|
+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`,
|
|
68
|
+
`Path=${this.opts.path ?? "/"}`,
|
|
69
|
+
];
|
|
70
|
+
if (this.opts.domain) parts.push(`Domain=${this.opts.domain}`);
|
|
71
|
+
if (this.opts.secure) parts.push("Secure");
|
|
72
|
+
if (this.opts.sameSite) parts.push(`SameSite=${this.opts.sameSite}`);
|
|
73
|
+
if (this.opts.maxAgeSeconds != null) {
|
|
74
|
+
parts.push(`Max-Age=${this.opts.maxAgeSeconds}`);
|
|
75
|
+
}
|
|
76
|
+
document.cookie = parts.join("; ");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
removeItem(key: string): void {
|
|
80
|
+
if (typeof document === "undefined") return;
|
|
81
|
+
document.cookie = `${encodeURIComponent(key)}=; Max-Age=0; Path=${this.opts.path ?? "/"}`;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Browser CustomEvent integration for Zod validation errors.
|
|
3
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
4
|
+
|
|
5
|
+
import type { ZodError } from "zod";
|
|
6
|
+
|
|
7
|
+
export interface ValidationErrorDetail {
|
|
8
|
+
operation: string;
|
|
9
|
+
path: string;
|
|
10
|
+
method: string;
|
|
11
|
+
error: ZodError;
|
|
12
|
+
response: any;
|
|
13
|
+
timestamp: Date;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type ValidationErrorEvent = CustomEvent<ValidationErrorDetail>;
|
|
17
|
+
|
|
18
|
+
export function dispatchValidationError(detail: ValidationErrorDetail): void {
|
|
19
|
+
if (typeof window === "undefined") return;
|
|
20
|
+
try {
|
|
21
|
+
const event = new CustomEvent<ValidationErrorDetail>("zod-validation-error", {
|
|
22
|
+
detail,
|
|
23
|
+
bubbles: true,
|
|
24
|
+
cancelable: false,
|
|
25
|
+
});
|
|
26
|
+
window.dispatchEvent(event);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.warn("Failed to dispatch validation error event:", error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function onValidationError(
|
|
33
|
+
callback: (detail: ValidationErrorDetail) => void,
|
|
34
|
+
): () => void {
|
|
35
|
+
if (typeof window === "undefined") return () => {};
|
|
36
|
+
const handler = (event: Event) => {
|
|
37
|
+
if (event instanceof CustomEvent) callback(event.detail);
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener("zod-validation-error", handler);
|
|
40
|
+
return () => window.removeEventListener("zod-validation-error", handler);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function formatZodError(error: ZodError): string {
|
|
44
|
+
const issues = error.issues.map((issue, index) => {
|
|
45
|
+
const path = issue.path.join(".") || "root";
|
|
46
|
+
const parts = [`${index + 1}. ${path}: ${issue.message}`];
|
|
47
|
+
if ("expected" in issue && issue.expected) parts.push(` Expected: ${issue.expected}`);
|
|
48
|
+
if ("received" in issue && issue.received) parts.push(` Received: ${issue.received}`);
|
|
49
|
+
return parts.join("\n");
|
|
50
|
+
});
|
|
51
|
+
return issues.join("\n");
|
|
52
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// AUTO-GENERATED by django_generator / ts_extras.wrapper
|
|
2
|
+
// Top-level barrel — one singleton API per group, baseUrl from Next.js env.
|
|
3
|
+
// DO NOT EDIT — re-run `make gen`.
|
|
4
|
+
|
|
5
|
+
import { API as CfgAccountsAPI, LocalStorageAdapter as CfgAccountsStorage } from './_cfg_accounts';
|
|
6
|
+
import { API as CfgCentrifugoAPI, LocalStorageAdapter as CfgCentrifugoStorage } from './_cfg_centrifugo';
|
|
7
|
+
import { API as CfgTotpAPI, LocalStorageAdapter as CfgTotpStorage } from './_cfg_totp';
|
|
8
|
+
|
|
9
|
+
const isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === 'true';
|
|
10
|
+
const baseUrl = isStaticBuild ? '' : process.env.NEXT_PUBLIC_API_URL || '';
|
|
11
|
+
|
|
12
|
+
export const CfgAccountsApi = new CfgAccountsAPI(baseUrl, { storage: new CfgAccountsStorage() });
|
|
13
|
+
export const CfgCentrifugoApi = new CfgCentrifugoAPI(baseUrl, { storage: new CfgCentrifugoStorage() });
|
|
14
|
+
export const CfgTotpApi = new CfgTotpAPI(baseUrl, { storage: new CfgTotpStorage() });
|
|
15
|
+
|
|
16
|
+
// API wrapper classes — for users who need to construct their own
|
|
17
|
+
// instance (e.g. with MemoryStorageAdapter in SSR/tests).
|
|
18
|
+
export { API as CfgAccountsAPI } from './_cfg_accounts';
|
|
19
|
+
export { API as CfgCentrifugoAPI } from './_cfg_centrifugo';
|
|
20
|
+
export { API as CfgTotpAPI } from './_cfg_totp';
|
|
21
|
+
|
|
22
|
+
// Hey API SDK classes — one per OpenAPI tag. Lets consumers call
|
|
23
|
+
// `Centrifugo.cfgCentrifugoAuthTokenRetrieve({...})` directly without
|
|
24
|
+
// going through the wrapper singleton.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
// Shared utilities (errors, storage adapters, logger).
|
|
28
|
+
export * from './helpers';
|