@djangocfg/api 2.1.359 → 2.1.361

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 (62) hide show
  1. package/dist/auth-server.cjs +68 -0
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +68 -0
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +75 -67
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +7 -10
  8. package/dist/auth.d.ts +7 -10
  9. package/dist/auth.mjs +75 -67
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +68 -0
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +14 -20
  14. package/dist/clients.d.ts +14 -20
  15. package/dist/clients.mjs +68 -0
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/hooks.cjs +68 -0
  18. package/dist/hooks.cjs.map +1 -1
  19. package/dist/hooks.mjs +68 -0
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +79 -71
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +28 -40
  24. package/dist/index.d.ts +28 -40
  25. package/dist/index.mjs +79 -71
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +1 -1
  29. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +1 -1
  30. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +1 -1
  31. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +1 -1
  32. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +1 -1
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +1 -1
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +1 -1
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +1 -1
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +1 -1
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +1 -1
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +1 -1
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +1 -1
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +1 -1
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +1 -1
  42. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +1 -1
  43. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +1 -1
  44. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +1 -1
  45. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +1 -1
  46. package/src/_api/generated/_cfg_accounts/openapi.json +1811 -0
  47. package/src/_api/generated/_cfg_accounts/schemas/User.ts +7 -7
  48. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +1 -1
  49. package/src/_api/generated/_cfg_centrifugo/openapi.json +132 -0
  50. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +1 -1
  51. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +1 -1
  52. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +1 -1
  53. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +1 -1
  54. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +1 -1
  55. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +1 -1
  56. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +1 -1
  57. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +1 -1
  58. package/src/_api/generated/_cfg_totp/openapi.json +927 -0
  59. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +7 -7
  60. package/src/_api/generated/helpers/auth.ts +27 -2
  61. package/src/_api/generated/openapi.json +2789 -0
  62. package/src/_api/generated/types.gen.ts +28 -40
@@ -7,16 +7,16 @@ import { z } from "zod";
7
7
  export const TotpVerifyUserSchema = z.object({
8
8
  id: z.number().int(),
9
9
  email: z.email(),
10
- first_name: z.string().max(50).optional(),
11
- last_name: z.string().max(50).optional(),
10
+ first_name: z.string().max(50).nullable().optional(),
11
+ last_name: z.string().max(50).nullable().optional(),
12
12
  full_name: z.string(),
13
13
  initials: z.string(),
14
14
  display_username: z.string(),
15
- company: z.string().max(100).optional(),
16
- phone: z.string().max(20).optional(),
17
- position: z.string().max(100).optional(),
18
- language: z.string().max(10).optional(),
19
- timezone: z.string().max(64).optional(),
15
+ company: z.string().max(100).nullable().optional(),
16
+ phone: z.string().max(20).nullable().optional(),
17
+ position: z.string().max(100).nullable().optional(),
18
+ language: z.string().max(10).nullable().optional(),
19
+ timezone: z.string().max(64).nullable().optional(),
20
20
  avatar: z.string().nullable(),
21
21
  is_staff: z.boolean(),
22
22
  is_superuser: z.boolean(),
@@ -4,6 +4,8 @@
4
4
  // post-processed bottom of client.gen.ts. No circular import here.
5
5
  // DO NOT EDIT — re-run `make gen`.
6
6
 
7
+ import { APIError } from './errors';
8
+
7
9
  const ACCESS_KEY = 'cfg.access_token';
8
10
  const REFRESH_KEY = 'cfg.refresh_token';
9
11
  const API_KEY_KEY = 'cfg.api_key';
@@ -77,7 +79,11 @@ function detectLocale(): string | null {
77
79
  return null;
78
80
  }
79
81
 
80
- /** Default baseUrl from `NEXT_PUBLIC_API_URL` (empty for static builds). */
82
+ /** Default baseUrl from `NEXT_PUBLIC_API_URL`.
83
+ *
84
+ * Both browser and server use NEXT_PUBLIC_API_URL — requests go
85
+ * directly to Django without Next.js proxy.
86
+ */
81
87
  function defaultBaseUrl(): string {
82
88
  try {
83
89
  if (typeof process !== 'undefined' && process.env) {
@@ -88,8 +94,15 @@ function defaultBaseUrl(): string {
88
94
  return '';
89
95
  }
90
96
 
91
- /** Default API key fallback from `NEXT_PUBLIC_API_KEY`. */
97
+ /** Default API key fallback from `NEXT_PUBLIC_API_KEY`.
98
+ *
99
+ * In the browser: returns null — requests go through the Next.js rewrite
100
+ * and the key is injected server-side (never exposed in the bundle).
101
+ * On the server: reads NEXT_PUBLIC_API_KEY as a fallback for SSR calls
102
+ * that bypass the rewrite (e.g. server components calling Django directly).
103
+ */
92
104
  function defaultApiKey(): string | null {
105
+ if (isBrowser) return null;
93
106
  try {
94
107
  if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_KEY) {
95
108
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -132,6 +145,7 @@ type HeyClient = {
132
145
  interceptors: {
133
146
  request: { use(fn: (req: Request) => Request | Promise<Request>): void };
134
147
  response: { use(fn: (res: Response, req: Request) => Response | Promise<Response>): void };
148
+ error: { use(fn: (err: unknown, res: Response | undefined, req: Request | undefined, opts: unknown) => unknown): void };
135
149
  };
136
150
  };
137
151
  let _client: HeyClient | null = null;
@@ -301,6 +315,17 @@ export function installAuthOnClient(client: HeyClient): void {
301
315
  return request;
302
316
  });
303
317
 
318
+ // Wrap raw JSON error objects (thrown by hey-api on non-2xx responses) into
319
+ // APIError so callers can do `error instanceof APIError` and read
320
+ // `error.statusCode` / `error.response` consistently.
321
+ client.interceptors.error.use((err, res, req) => {
322
+ if (err instanceof APIError) return err;
323
+ const url = (req as Request | undefined)?.url ?? '';
324
+ const status = (res as Response | undefined)?.status ?? 0;
325
+ const statusText = (res as Response | undefined)?.statusText ?? '';
326
+ return new APIError(status, statusText, err, url);
327
+ });
328
+
304
329
  client.interceptors.response.use(async (response, request) => {
305
330
  if (response.status !== 401) return response;
306
331