@djangocfg/api 2.1.356 → 2.1.358

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +53 -632
  2. package/dist/auth-server.cjs +717 -200
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +717 -200
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +843 -783
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.d.cts +58 -37
  9. package/dist/auth.d.ts +58 -37
  10. package/dist/auth.mjs +846 -784
  11. package/dist/auth.mjs.map +1 -1
  12. package/dist/clients.cjs +1427 -0
  13. package/dist/clients.cjs.map +1 -1
  14. package/dist/clients.d.cts +1686 -0
  15. package/dist/clients.d.ts +1686 -0
  16. package/dist/clients.mjs +1427 -0
  17. package/dist/clients.mjs.map +1 -1
  18. package/dist/hooks.cjs +1277 -1924
  19. package/dist/hooks.cjs.map +1 -1
  20. package/dist/hooks.d.cts +18 -1206
  21. package/dist/hooks.d.ts +18 -1206
  22. package/dist/hooks.mjs +1253 -1900
  23. package/dist/hooks.mjs.map +1 -1
  24. package/dist/index.cjs +545 -1232
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +1389 -1455
  27. package/dist/index.d.ts +1389 -1455
  28. package/dist/index.mjs +545 -1232
  29. package/dist/index.mjs.map +1 -1
  30. package/package.json +7 -2
  31. package/src/_api/generated/_cfg_accounts/api.ts +11 -3
  32. package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
  42. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
  43. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
  44. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
  45. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
  46. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
  47. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
  48. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
  49. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
  50. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
  51. package/src/_api/generated/_cfg_accounts/index.ts +1 -1
  52. package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
  55. package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
  56. package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
  58. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
  59. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
  60. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
  61. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
  62. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  63. package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
  64. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
  65. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
  66. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
  67. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
  68. package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
  69. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
  70. package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
  71. package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
  72. package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
  73. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
  74. package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
  75. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
  76. package/src/_api/generated/_cfg_totp/api.ts +9 -3
  77. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
  78. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
  86. package/src/_api/generated/_cfg_totp/index.ts +1 -1
  87. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
  88. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
  89. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
  90. package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
  91. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
  92. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
  93. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
  94. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
  95. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
  98. package/src/_api/generated/index.ts +3 -1
  99. package/src/_api/generated/sdk.gen.ts +80 -813
  100. package/src/_api/generated/types.gen.ts +320 -159
  101. package/src/auth/context/AccountsContext.tsx +18 -6
  102. package/src/auth/context/AuthContext.tsx +11 -3
  103. package/src/auth/hooks/useDeleteAccount.ts +2 -2
  104. package/src/auth/hooks/useGithubAuth.ts +3 -3
  105. package/src/auth/hooks/useTokenRefresh.ts +2 -2
  106. package/src/auth/hooks/useTwoFactor.ts +3 -3
  107. package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
  108. package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
  109. package/src/auth/middlewares/tokenRefresh.ts +2 -2
  110. package/src/hooks/index.ts +1 -0
  111. package/src/hooks/useApiKey.ts +73 -0
  112. package/src/index.ts +12 -16
  113. package/src/lib/env.ts +10 -0
@@ -5,10 +5,10 @@
5
5
  import { z } from "zod";
6
6
 
7
7
  export const CentrifugoTokenSchema = z.object({
8
+ token: z.string(),
8
9
  centrifugo_url: z.string(),
9
- channels: z.array(z.string()),
10
10
  expires_at: z.string().datetime({ offset: true }),
11
- token: z.string(),
11
+ channels: z.array(z.string()),
12
12
  });
13
13
 
14
14
  export type CentrifugoToken = z.infer<typeof CentrifugoTokenSchema>;
@@ -5,12 +5,13 @@
5
5
  import { z } from "zod";
6
6
 
7
7
  export const CfgUserUpdateRequestSchema = z.object({
8
- company: z.string().max(100).optional(),
9
8
  first_name: z.string().max(50).optional(),
10
- language: z.string().max(10).optional(),
11
9
  last_name: z.string().max(50).optional(),
10
+ company: z.string().max(100).optional(),
12
11
  phone: z.string().max(20).optional(),
13
12
  position: z.string().max(100).optional(),
13
+ language: z.string().max(10).optional(),
14
+ timezone: z.string().max(64).optional(),
14
15
  });
15
16
 
16
17
  export type CfgUserUpdateRequest = z.infer<typeof CfgUserUpdateRequestSchema>;
@@ -6,8 +6,8 @@ import { z } from "zod";
6
6
 
7
7
  export const OAuthCallbackRequestRequestSchema = z.object({
8
8
  code: z.string().min(10).max(500),
9
- redirect_uri: z.string().optional(),
10
9
  state: z.string().min(20).max(100),
10
+ redirect_uri: z.string().optional(),
11
11
  });
12
12
 
13
13
  export type OAuthCallbackRequestRequest = z.infer<typeof OAuthCallbackRequestRequestSchema>;
@@ -3,17 +3,17 @@
3
3
  // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
- import { ProviderEnumSchema } from "./ProviderEnum";
6
+ import { OAuthProviderEnumSchema } from "./OAuthProviderEnum";
7
7
 
8
8
  export const OAuthConnectionSchema = z.object({
9
- connected_at: z.string().datetime({ offset: true }),
10
9
  id: z.number().int(),
11
- last_login_at: z.string().datetime({ offset: true }),
12
- provider: ProviderEnumSchema,
13
- provider_avatar_url: z.string(),
10
+ provider: OAuthProviderEnumSchema,
14
11
  provider_display: z.string(),
15
- provider_email: z.email(),
16
12
  provider_username: z.string(),
13
+ provider_email: z.email(),
14
+ provider_avatar_url: z.string(),
15
+ connected_at: z.string().datetime({ offset: true }),
16
+ last_login_at: z.string().datetime({ offset: true }),
17
17
  });
18
18
 
19
19
  export type OAuthConnection = z.infer<typeof OAuthConnectionSchema>;
@@ -3,10 +3,10 @@
3
3
  // DO NOT EDIT — re-run `make gen-clients`.
4
4
 
5
5
  import { z } from "zod";
6
- import { ProviderEnumSchema } from "./ProviderEnum";
6
+ import { OAuthProviderEnumSchema } from "./OAuthProviderEnum";
7
7
 
8
8
  export const OAuthDisconnectRequestRequestSchema = z.object({
9
- provider: ProviderEnumSchema,
9
+ provider: OAuthProviderEnumSchema,
10
10
  });
11
11
 
12
12
  export type OAuthDisconnectRequestRequest = z.infer<typeof OAuthDisconnectRequestRequestSchema>;
@@ -4,6 +4,6 @@
4
4
 
5
5
  import { z } from "zod";
6
6
 
7
- export const ProviderEnumSchema = z.enum(["github"]);
7
+ export const OAuthProviderEnumSchema = z.enum(["github"]);
8
8
 
9
- export type ProviderEnum = z.infer<typeof ProviderEnumSchema>;
9
+ export type OAuthProviderEnum = z.infer<typeof OAuthProviderEnumSchema>;
@@ -5,14 +5,14 @@
5
5
  import { z } from "zod";
6
6
 
7
7
  export const OAuthTokenResponseSchema = z.object({
8
- access: z.string().nullable().optional(),
9
- is_new_connection: z.boolean(),
10
- is_new_user: z.boolean(),
11
- refresh: z.string().nullable().optional(),
12
8
  requires_2fa: z.boolean().default(false).optional(),
13
9
  session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
14
- should_prompt_2fa: z.boolean().optional(),
10
+ access: z.string().nullable().optional(),
11
+ refresh: z.string().nullable().optional(),
15
12
  user: z.object({}).passthrough().nullable().optional(),
13
+ is_new_user: z.boolean(),
14
+ is_new_connection: z.boolean(),
15
+ should_prompt_2fa: z.boolean().optional(),
16
16
  });
17
17
 
18
18
  export type OAuthTokenResponse = z.infer<typeof OAuthTokenResponseSchema>;
@@ -6,7 +6,7 @@ import { z } from "zod";
6
6
 
7
7
  export const OTPVerifyRequestSchema = z.object({
8
8
  identifier: z.string().min(1),
9
- otp: z.string().min(6).max(6),
9
+ otp: z.string().min(4).max(4),
10
10
  source_url: z.string().optional(),
11
11
  });
12
12
 
@@ -6,12 +6,12 @@ import { z } from "zod";
6
6
  import { UserSchema } from "./User";
7
7
 
8
8
  export const OTPVerifyResponseSchema = z.object({
9
- access: z.string().nullable().optional(),
10
- refresh: z.string().nullable().optional(),
11
9
  requires_2fa: z.boolean().default(false).optional(),
12
10
  session_id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
13
- should_prompt_2fa: z.boolean().optional(),
11
+ refresh: z.string().nullable().optional(),
12
+ access: z.string().nullable().optional(),
14
13
  user: UserSchema.nullable().optional(),
14
+ should_prompt_2fa: z.boolean().optional(),
15
15
  });
16
16
 
17
17
  export type OTPVerifyResponse = z.infer<typeof OTPVerifyResponseSchema>;
@@ -5,12 +5,13 @@
5
5
  import { z } from "zod";
6
6
 
7
7
  export const PatchedCfgUserUpdateRequestSchema = z.object({
8
- company: z.string().max(100).optional(),
9
8
  first_name: z.string().max(50).optional(),
10
- language: z.string().max(10).optional(),
11
9
  last_name: z.string().max(50).optional(),
10
+ company: z.string().max(100).optional(),
12
11
  phone: z.string().max(20).optional(),
13
12
  position: z.string().max(100).optional(),
13
+ language: z.string().max(10).optional(),
14
+ timezone: z.string().max(64).optional(),
14
15
  });
15
16
 
16
17
  export type PatchedCfgUserUpdateRequest = z.infer<typeof PatchedCfgUserUpdateRequestSchema>;
@@ -6,24 +6,26 @@ import { z } from "zod";
6
6
  import { CentrifugoTokenSchema } from "./CentrifugoToken";
7
7
 
8
8
  export const UserSchema = z.object({
9
- avatar: z.string().nullable(),
10
- centrifugo: CentrifugoTokenSchema.nullable(),
11
- company: z.string().max(100).optional(),
12
- date_joined: z.string().datetime({ offset: true }),
13
- display_username: z.string(),
9
+ id: z.number().int(),
14
10
  email: z.email(),
15
11
  first_name: z.string().max(50).optional(),
12
+ last_name: z.string().max(50).optional(),
16
13
  full_name: z.string(),
17
- id: z.number().int(),
18
14
  initials: z.string(),
15
+ display_username: z.string(),
16
+ company: z.string().max(100).optional(),
17
+ phone: z.string().max(20).optional(),
18
+ position: z.string().max(100).optional(),
19
+ language: z.string().max(10).optional(),
20
+ timezone: z.string().max(64).optional(),
21
+ avatar: z.string().nullable(),
19
22
  is_staff: z.boolean(),
20
23
  is_superuser: z.boolean(),
21
- language: z.string().max(10).optional(),
24
+ date_joined: z.string().datetime({ offset: true }),
22
25
  last_login: z.string().datetime({ offset: true }).nullable(),
23
- last_name: z.string().max(50).optional(),
24
- phone: z.string().max(20).optional(),
25
- position: z.string().max(100).optional(),
26
26
  unanswered_messages_count: z.number().int().default(0),
27
+ centrifugo: CentrifugoTokenSchema.nullable(),
28
+ api_key: z.string().nullable(),
27
29
  });
28
30
 
29
31
  export type User = z.infer<typeof UserSchema>;
@@ -0,0 +1,10 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
+ // Source: OpenAPI 3.1 components.schemas
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+
5
+ import { z } from "zod";
6
+ import { OAuthConnectionSchema } from "./OAuthConnection";
7
+
8
+ export const cfg_accounts_oauth_connections_response_200_AutoRefSchema = z.array(OAuthConnectionSchema);
9
+
10
+ export type cfg_accounts_oauth_connections_response_200_AutoRef = z.infer<typeof cfg_accounts_oauth_connections_response_200_AutoRefSchema>;
@@ -0,0 +1,11 @@
1
+ // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
+ // Source: OpenAPI 3.1 components.schemas
3
+ // DO NOT EDIT — re-run `make gen-clients`.
4
+
5
+ import { z } from "zod";
6
+
7
+ export const cfg_accounts_oauth_disconnect_response_200_AutoRefSchema = z.object({
8
+ message: z.string().optional(),
9
+ });
10
+
11
+ export type cfg_accounts_oauth_disconnect_response_200_AutoRef = z.infer<typeof cfg_accounts_oauth_disconnect_response_200_AutoRefSchema>;
@@ -1,6 +1,11 @@
1
1
  // AUTO-GENERATED — barrel for zod schemas.
2
2
  // DO NOT EDIT.
3
3
 
4
+ export * from "./APIKey";
5
+ export * from "./APIKeyRegenerate";
6
+ export * from "./APIKeyRequest";
7
+ export * from "./APIKeyTestRequest";
8
+ export * from "./APIKeyTestResult";
4
9
  export * from "./AccountDeleteResponse";
5
10
  export * from "./CentrifugoToken";
6
11
  export * from "./CfgUserUpdateRequest";
@@ -10,6 +15,7 @@ export * from "./OAuthCallbackRequestRequest";
10
15
  export * from "./OAuthConnection";
11
16
  export * from "./OAuthDisconnectRequestRequest";
12
17
  export * from "./OAuthError";
18
+ export * from "./OAuthProviderEnum";
13
19
  export * from "./OAuthProvidersResponse";
14
20
  export * from "./OAuthTokenResponse";
15
21
  export * from "./OTPErrorResponse";
@@ -18,7 +24,8 @@ export * from "./OTPRequestResponse";
18
24
  export * from "./OTPVerifyRequest";
19
25
  export * from "./OTPVerifyResponse";
20
26
  export * from "./PatchedCfgUserUpdateRequest";
21
- export * from "./ProviderEnum";
22
27
  export * from "./TokenRefresh";
23
28
  export * from "./TokenRefreshRequest";
24
29
  export * from "./User";
30
+ export * from "./cfg_accounts_oauth_connections_response_200_AutoRef";
31
+ export * from "./cfg_accounts_oauth_disconnect_response_200_AutoRef";
@@ -6,7 +6,7 @@
6
6
  import { auth } from '../helpers/auth';
7
7
  import { APILogger, type LoggerConfig } from '../helpers/logger';
8
8
 
9
-
9
+ import { CfgCentrifugo } from '../sdk.gen';
10
10
 
11
11
 
12
12
 
@@ -34,7 +34,7 @@ export interface APIOptions {
34
34
  export class API {
35
35
  readonly logger: APILogger;
36
36
 
37
-
37
+ readonly cfgCentrifugo = CfgCentrifugo;
38
38
 
39
39
  constructor(_baseUrl?: string, opts: APIOptions = {}) {
40
40
  this.logger = new APILogger(opts.logger);
@@ -75,5 +75,5 @@ export class API {
75
75
  }
76
76
  }
77
77
 
78
- export { };
78
+ export { CfgCentrifugo };
79
79
  export { auth };
@@ -1,11 +1,14 @@
1
+ 'use client';
2
+
1
3
  // AUTO-GENERATED by openapi_processor / ts.hooks
2
4
  // Get Centrifugo connection token
3
5
  // DO NOT EDIT — re-run `make gen`.
4
6
 
5
7
  import useSWR from "swr";
6
8
  import type { SWRConfiguration } from "swr";
7
- import { Cfg } from "../../sdk.gen";
9
+ import { CfgCentrifugo } from "../../sdk.gen";
8
10
  import type { CfgCentrifugoAuthTokenRetrieveData, CfgCentrifugoAuthTokenRetrieveResponses } from "../../types.gen";
11
+ import { ConnectionTokenResponseSchema } from "../schemas/ConnectionTokenResponse";
9
12
 
10
13
  type Result = CfgCentrifugoAuthTokenRetrieveResponses[keyof CfgCentrifugoAuthTokenRetrieveResponses];
11
14
 
@@ -17,8 +20,45 @@ export function useCfgCentrifugoAuthTokenRetrieve(
17
20
  return useSWR<Result>(
18
21
  key,
19
22
  async () => {
20
- const res = await Cfg.cfgCentrifugoAuthTokenRetrieve({ ...(args ?? {}), throwOnError: true } as never);
21
- return res.data as Result;
23
+ const res = await CfgCentrifugo.cfgCentrifugoAuthTokenRetrieve({ ...(args ?? {}), throwOnError: true } as never);
24
+ const data = res.data as Result;
25
+ const parsed = ConnectionTokenResponseSchema.safeParse(data);
26
+ if (!parsed.success) {
27
+ // Log first so the failure is always visible, even if the
28
+ // event handler swallows it.
29
+ console.warn(
30
+ "[zod] response did not match schema",
31
+ {
32
+ operation: "cfg_centrifugo_auth_token_retrieve",
33
+ method: "GET",
34
+ path: "/cfg/centrifugo/auth/token/",
35
+ issues: parsed.error.issues,
36
+ data,
37
+ },
38
+ );
39
+ if (typeof window !== "undefined") {
40
+ try {
41
+ window.dispatchEvent(
42
+ new CustomEvent("zod-validation-error", {
43
+ detail: {
44
+ operation: "cfg_centrifugo_auth_token_retrieve",
45
+ method: "GET",
46
+ path: "/cfg/centrifugo/auth/token/",
47
+ issues: parsed.error.issues,
48
+ data,
49
+ timestamp: new Date(),
50
+ },
51
+ bubbles: true,
52
+ cancelable: false,
53
+ }),
54
+ );
55
+ } catch {
56
+ // Event dispatch is best-effort.
57
+ }
58
+ }
59
+ return data;
60
+ }
61
+ return parsed.data as Result;
22
62
  },
23
63
  config,
24
64
  );
@@ -2,7 +2,7 @@
2
2
  // Group barrel. DO NOT EDIT — re-run `make gen`.
3
3
 
4
4
  // Wrapper class + per-group SDK re-exports + global auth.
5
- export { API, type APIOptions, auth, } from './api';
5
+ export { API, type APIOptions, auth, CfgCentrifugo } from './api';
6
6
 
7
7
  // Shared utilities.
8
8
  export {
@@ -5,10 +5,10 @@
5
5
  import { z } from "zod";
6
6
 
7
7
  export const ConnectionTokenResponseSchema = z.object({
8
+ token: z.string(),
8
9
  centrifugo_url: z.string(),
9
- channels: z.array(z.string()),
10
10
  expires_at: z.string(),
11
- token: z.string(),
11
+ channels: z.array(z.string()),
12
12
  });
13
13
 
14
14
  export type ConnectionTokenResponse = z.infer<typeof ConnectionTokenResponseSchema>;
@@ -6,7 +6,10 @@
6
6
  import { auth } from '../helpers/auth';
7
7
  import { APILogger, type LoggerConfig } from '../helpers/logger';
8
8
 
9
-
9
+ import { CfgTotpBackupCodes } from '../sdk.gen';
10
+ import { CfgTotp } from '../sdk.gen';
11
+ import { CfgTotpSetup } from '../sdk.gen';
12
+ import { CfgTotpVerify } from '../sdk.gen';
10
13
 
11
14
 
12
15
 
@@ -34,7 +37,10 @@ export interface APIOptions {
34
37
  export class API {
35
38
  readonly logger: APILogger;
36
39
 
37
-
40
+ readonly cfgTotpBackupCodes = CfgTotpBackupCodes;
41
+ readonly cfgTotp = CfgTotp;
42
+ readonly cfgTotpSetup = CfgTotpSetup;
43
+ readonly cfgTotpVerify = CfgTotpVerify;
38
44
 
39
45
  constructor(_baseUrl?: string, opts: APIOptions = {}) {
40
46
  this.logger = new APILogger(opts.logger);
@@ -75,5 +81,5 @@ export class API {
75
81
  }
76
82
  }
77
83
 
78
- export { };
84
+ export { CfgTotpBackupCodes, CfgTotp, CfgTotpSetup, CfgTotpVerify };
79
85
  export { auth };
@@ -1,11 +1,14 @@
1
+ 'use client';
2
+
1
3
  // AUTO-GENERATED by openapi_processor / ts.hooks
2
4
  // POST /cfg/totp/backup-codes/regenerate/
3
5
  // DO NOT EDIT — re-run `make gen`.
4
6
 
5
7
  import useSWRMutation from "swr/mutation";
6
8
  import type { SWRMutationConfiguration } from "swr/mutation";
7
- import { Cfg } from "../../sdk.gen";
9
+ import { CfgTotpBackupCodes } from "../../sdk.gen";
8
10
  import type { CfgTotpBackupCodesRegenerateCreateData, CfgTotpBackupCodesRegenerateCreateResponses } from "../../types.gen";
11
+ import { BackupCodesRegenerateResponseSchema } from "../schemas/BackupCodesRegenerateResponse";
9
12
 
10
13
  type Args = Omit<CfgTotpBackupCodesRegenerateCreateData, "url">;
11
14
  type Result = CfgTotpBackupCodesRegenerateCreateResponses[keyof CfgTotpBackupCodesRegenerateCreateResponses];
@@ -16,8 +19,45 @@ export function useCfgTotpBackupCodesRegenerateCreate(
16
19
  return useSWRMutation<Result, Error, readonly ["cfg_totp_backup_codes_regenerate_create"], Args>(
17
20
  ["cfg_totp_backup_codes_regenerate_create"] as const,
18
21
  async (_key, { arg }: { arg: Args }) => {
19
- const res = await Cfg.cfgTotpBackupCodesRegenerateCreate({ ...arg, throwOnError: true } as never);
20
- return res.data as Result;
22
+ const res = await CfgTotpBackupCodes.cfgTotpBackupCodesRegenerateCreate({ ...arg, throwOnError: true } as never);
23
+ const data = res.data as Result;
24
+ const parsed = BackupCodesRegenerateResponseSchema.safeParse(data);
25
+ if (!parsed.success) {
26
+ // Log first so the failure is always visible, even if the
27
+ // event handler swallows it.
28
+ console.warn(
29
+ "[zod] response did not match schema",
30
+ {
31
+ operation: "cfg_totp_backup_codes_regenerate_create",
32
+ method: "POST",
33
+ path: "/cfg/totp/backup-codes/regenerate/",
34
+ issues: parsed.error.issues,
35
+ data,
36
+ },
37
+ );
38
+ if (typeof window !== "undefined") {
39
+ try {
40
+ window.dispatchEvent(
41
+ new CustomEvent("zod-validation-error", {
42
+ detail: {
43
+ operation: "cfg_totp_backup_codes_regenerate_create",
44
+ method: "POST",
45
+ path: "/cfg/totp/backup-codes/regenerate/",
46
+ issues: parsed.error.issues,
47
+ data,
48
+ timestamp: new Date(),
49
+ },
50
+ bubbles: true,
51
+ cancelable: false,
52
+ }),
53
+ );
54
+ } catch {
55
+ // Event dispatch is best-effort.
56
+ }
57
+ }
58
+ return data;
59
+ }
60
+ return parsed.data as Result;
21
61
  },
22
62
  config,
23
63
  );
@@ -1,11 +1,14 @@
1
+ 'use client';
2
+
1
3
  // AUTO-GENERATED by openapi_processor / ts.hooks
2
4
  // GET /cfg/totp/backup-codes/
3
5
  // DO NOT EDIT — re-run `make gen`.
4
6
 
5
7
  import useSWR from "swr";
6
8
  import type { SWRConfiguration } from "swr";
7
- import { Cfg } from "../../sdk.gen";
9
+ import { CfgTotpBackupCodes } from "../../sdk.gen";
8
10
  import type { CfgTotpBackupCodesRetrieveData, CfgTotpBackupCodesRetrieveResponses } from "../../types.gen";
11
+ import { BackupCodesStatusSchema } from "../schemas/BackupCodesStatus";
9
12
 
10
13
  type Result = CfgTotpBackupCodesRetrieveResponses[keyof CfgTotpBackupCodesRetrieveResponses];
11
14
 
@@ -17,8 +20,45 @@ export function useCfgTotpBackupCodesRetrieve(
17
20
  return useSWR<Result>(
18
21
  key,
19
22
  async () => {
20
- const res = await Cfg.cfgTotpBackupCodesRetrieve({ ...(args ?? {}), throwOnError: true } as never);
21
- return res.data as Result;
23
+ const res = await CfgTotpBackupCodes.cfgTotpBackupCodesRetrieve({ ...(args ?? {}), throwOnError: true } as never);
24
+ const data = res.data as Result;
25
+ const parsed = BackupCodesStatusSchema.safeParse(data);
26
+ if (!parsed.success) {
27
+ // Log first so the failure is always visible, even if the
28
+ // event handler swallows it.
29
+ console.warn(
30
+ "[zod] response did not match schema",
31
+ {
32
+ operation: "cfg_totp_backup_codes_retrieve",
33
+ method: "GET",
34
+ path: "/cfg/totp/backup-codes/",
35
+ issues: parsed.error.issues,
36
+ data,
37
+ },
38
+ );
39
+ if (typeof window !== "undefined") {
40
+ try {
41
+ window.dispatchEvent(
42
+ new CustomEvent("zod-validation-error", {
43
+ detail: {
44
+ operation: "cfg_totp_backup_codes_retrieve",
45
+ method: "GET",
46
+ path: "/cfg/totp/backup-codes/",
47
+ issues: parsed.error.issues,
48
+ data,
49
+ timestamp: new Date(),
50
+ },
51
+ bubbles: true,
52
+ cancelable: false,
53
+ }),
54
+ );
55
+ } catch {
56
+ // Event dispatch is best-effort.
57
+ }
58
+ }
59
+ return data;
60
+ }
61
+ return parsed.data as Result;
22
62
  },
23
63
  config,
24
64
  );
@@ -1,12 +1,15 @@
1
+ 'use client';
2
+
1
3
  // AUTO-GENERATED by openapi_processor / ts.hooks
2
4
  // DELETE /cfg/totp/devices/{id}/
3
5
  // DO NOT EDIT — re-run `make gen`.
4
6
 
5
7
  import useSWRMutation from "swr/mutation";
6
8
  import type { SWRMutationConfiguration } from "swr/mutation";
7
- import { Cfg } from "../../sdk.gen";
9
+ import { CfgTotp } from "../../sdk.gen";
8
10
  import type { CfgTotpDevicesDestroyData, CfgTotpDevicesDestroyResponses } from "../../types.gen";
9
11
 
12
+
10
13
  type Args = Omit<CfgTotpDevicesDestroyData, "url">;
11
14
  type Result = CfgTotpDevicesDestroyResponses[keyof CfgTotpDevicesDestroyResponses];
12
15
 
@@ -16,8 +19,9 @@ export function useCfgTotpDevicesDestroy(
16
19
  return useSWRMutation<Result, Error, readonly ["cfg_totp_devices_destroy"], Args>(
17
20
  ["cfg_totp_devices_destroy"] as const,
18
21
  async (_key, { arg }: { arg: Args }) => {
19
- const res = await Cfg.cfgTotpDevicesDestroy({ ...arg, throwOnError: true } as never);
20
- return res.data as Result;
22
+ const res = await CfgTotp.cfgTotpDevicesDestroy({ ...arg, throwOnError: true } as never);
23
+ const data = res.data as Result;
24
+ return data;
21
25
  },
22
26
  config,
23
27
  );
@@ -1,11 +1,14 @@
1
+ 'use client';
2
+
1
3
  // AUTO-GENERATED by openapi_processor / ts.hooks
2
4
  // GET /cfg/totp/devices/
3
5
  // DO NOT EDIT — re-run `make gen`.
4
6
 
5
7
  import useSWR from "swr";
6
8
  import type { SWRConfiguration } from "swr";
7
- import { Cfg } from "../../sdk.gen";
9
+ import { CfgTotp } from "../../sdk.gen";
8
10
  import type { CfgTotpDevicesRetrieveData, CfgTotpDevicesRetrieveResponses } from "../../types.gen";
11
+ import { DeviceListResponseSchema } from "../schemas/DeviceListResponse";
9
12
 
10
13
  type Result = CfgTotpDevicesRetrieveResponses[keyof CfgTotpDevicesRetrieveResponses];
11
14
 
@@ -17,8 +20,45 @@ export function useCfgTotpDevicesRetrieve(
17
20
  return useSWR<Result>(
18
21
  key,
19
22
  async () => {
20
- const res = await Cfg.cfgTotpDevicesRetrieve({ ...(args ?? {}), throwOnError: true } as never);
21
- return res.data as Result;
23
+ const res = await CfgTotp.cfgTotpDevicesRetrieve({ ...(args ?? {}), throwOnError: true } as never);
24
+ const data = res.data as Result;
25
+ const parsed = DeviceListResponseSchema.safeParse(data);
26
+ if (!parsed.success) {
27
+ // Log first so the failure is always visible, even if the
28
+ // event handler swallows it.
29
+ console.warn(
30
+ "[zod] response did not match schema",
31
+ {
32
+ operation: "cfg_totp_devices_retrieve",
33
+ method: "GET",
34
+ path: "/cfg/totp/devices/",
35
+ issues: parsed.error.issues,
36
+ data,
37
+ },
38
+ );
39
+ if (typeof window !== "undefined") {
40
+ try {
41
+ window.dispatchEvent(
42
+ new CustomEvent("zod-validation-error", {
43
+ detail: {
44
+ operation: "cfg_totp_devices_retrieve",
45
+ method: "GET",
46
+ path: "/cfg/totp/devices/",
47
+ issues: parsed.error.issues,
48
+ data,
49
+ timestamp: new Date(),
50
+ },
51
+ bubbles: true,
52
+ cancelable: false,
53
+ }),
54
+ );
55
+ } catch {
56
+ // Event dispatch is best-effort.
57
+ }
58
+ }
59
+ return data;
60
+ }
61
+ return parsed.data as Result;
22
62
  },
23
63
  config,
24
64
  );