@djangocfg/api 2.1.359 → 2.1.360

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 (58) hide show
  1. package/dist/auth-server.cjs +67 -0
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +67 -0
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +74 -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 +74 -67
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +67 -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 +67 -0
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/hooks.cjs +67 -0
  18. package/dist/hooks.cjs.map +1 -1
  19. package/dist/hooks.mjs +67 -0
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +78 -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 +78 -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/schemas/User.ts +7 -7
  47. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +1 -1
  48. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +1 -1
  49. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +1 -1
  50. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +1 -1
  51. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +1 -1
  52. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +1 -1
  53. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +1 -1
  54. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +1 -1
  55. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +1 -1
  56. package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +7 -7
  57. package/src/_api/generated/helpers/auth.ts +14 -0
  58. package/src/_api/generated/types.gen.ts +28 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "2.1.359",
3
+ "version": "2.1.360",
4
4
  "description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
5
5
  "keywords": [
6
6
  "django",
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@types/node": "^24.7.2",
86
86
  "@types/react": "^19.1.0",
87
- "@djangocfg/typescript-config": "^2.1.359",
87
+ "@djangocfg/typescript-config": "^2.1.360",
88
88
  "next": "^16.2.2",
89
89
  "react": "^19.1.0",
90
90
  "tsup": "^8.5.0",
@@ -57,7 +57,7 @@ export function useCfgAccountsApiKeyRegenerateCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -58,7 +58,7 @@ export function useCfgAccountsApiKeyRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsApiKeyTestCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -58,7 +58,7 @@ export function useCfgAccountsOauthConnectionsList(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsOauthDisconnectCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsOauthGithubAuthorizeCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsOauthGithubCallbackCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -58,7 +58,7 @@ export function useCfgAccountsOauthProvidersRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsOtpRequestCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsOtpVerifyCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfileAvatarCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfileDeleteCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfilePartialPartialUpdate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfilePartialUpdate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -58,7 +58,7 @@ export function useCfgAccountsProfileRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfileUpdatePartialUpdate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsProfileUpdateUpdate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgAccountsTokenRefreshCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -8,16 +8,16 @@ import { CentrifugoTokenSchema } from "./CentrifugoToken";
8
8
  export const UserSchema = z.object({
9
9
  id: z.number().int(),
10
10
  email: z.email(),
11
- first_name: z.string().max(50).optional(),
12
- last_name: z.string().max(50).optional(),
11
+ first_name: z.string().max(50).nullable().optional(),
12
+ last_name: z.string().max(50).nullable().optional(),
13
13
  full_name: z.string(),
14
14
  initials: z.string(),
15
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(),
16
+ company: z.string().max(100).nullable().optional(),
17
+ phone: z.string().max(20).nullable().optional(),
18
+ position: z.string().max(100).nullable().optional(),
19
+ language: z.string().max(10).nullable().optional(),
20
+ timezone: z.string().max(64).nullable().optional(),
21
21
  avatar: z.string().nullable(),
22
22
  is_staff: z.boolean(),
23
23
  is_superuser: z.boolean(),
@@ -58,7 +58,7 @@ export function useCfgCentrifugoAuthTokenRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgTotpBackupCodesRegenerateCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -58,7 +58,7 @@ export function useCfgTotpBackupCodesRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -58,7 +58,7 @@ export function useCfgTotpDevicesRetrieve(
58
58
  }
59
59
  return data;
60
60
  }
61
- return parsed.data as Result;
61
+ return parsed.data as unknown as Result;
62
62
  },
63
63
  config,
64
64
  );
@@ -57,7 +57,7 @@ export function useCfgTotpDisableCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgTotpSetupConfirmCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgTotpSetupCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgTotpVerifyBackupCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -57,7 +57,7 @@ export function useCfgTotpVerifyCreate(
57
57
  }
58
58
  return data;
59
59
  }
60
- return parsed.data as Result;
60
+ return parsed.data as unknown as Result;
61
61
  },
62
62
  config,
63
63
  );
@@ -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';
@@ -132,6 +134,7 @@ type HeyClient = {
132
134
  interceptors: {
133
135
  request: { use(fn: (req: Request) => Request | Promise<Request>): void };
134
136
  response: { use(fn: (res: Response, req: Request) => Response | Promise<Response>): void };
137
+ error: { use(fn: (err: unknown, res: Response | undefined, req: Request | undefined, opts: unknown) => unknown): void };
135
138
  };
136
139
  };
137
140
  let _client: HeyClient | null = null;
@@ -301,6 +304,17 @@ export function installAuthOnClient(client: HeyClient): void {
301
304
  return request;
302
305
  });
303
306
 
307
+ // Wrap raw JSON error objects (thrown by hey-api on non-2xx responses) into
308
+ // APIError so callers can do `error instanceof APIError` and read
309
+ // `error.statusCode` / `error.response` consistently.
310
+ client.interceptors.error.use((err, res, req) => {
311
+ if (err instanceof APIError) return err;
312
+ const url = (req as Request | undefined)?.url ?? '';
313
+ const status = (res as Response | undefined)?.status ?? 0;
314
+ const statusText = (res as Response | undefined)?.statusText ?? '';
315
+ return new APIError(status, statusText, err, url);
316
+ });
317
+
304
318
  client.interceptors.response.use(async (response, request) => {
305
319
  if (response.status !== 401) return response;
306
320
 
@@ -636,8 +636,8 @@ export type TokenRefreshRequest = {
636
636
  export type TotpVerifyUser = {
637
637
  readonly id: number;
638
638
  readonly email: string;
639
- first_name?: string;
640
- last_name?: string;
639
+ first_name?: string | null;
640
+ last_name?: string | null;
641
641
  /**
642
642
  * Get user's full name.
643
643
  */
@@ -650,14 +650,11 @@ export type TotpVerifyUser = {
650
650
  * Get formatted username for display.
651
651
  */
652
652
  readonly display_username: string;
653
- company?: string;
654
- phone?: string;
655
- position?: string;
656
- language?: string;
657
- /**
658
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
659
- */
660
- timezone?: string;
653
+ company?: string | null;
654
+ phone?: string | null;
655
+ position?: string | null;
656
+ language?: string | null;
657
+ timezone?: string | null;
661
658
  readonly avatar: string | null;
662
659
  /**
663
660
  * Staff status
@@ -683,8 +680,8 @@ export type TotpVerifyUser = {
683
680
  export type User = {
684
681
  readonly id: number;
685
682
  readonly email: string;
686
- first_name?: string;
687
- last_name?: string;
683
+ first_name?: string | null;
684
+ last_name?: string | null;
688
685
  /**
689
686
  * Get user's full name.
690
687
  */
@@ -697,14 +694,11 @@ export type User = {
697
694
  * Get formatted username for display.
698
695
  */
699
696
  readonly display_username: string;
700
- company?: string;
701
- phone?: string;
702
- position?: string;
703
- language?: string;
704
- /**
705
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
706
- */
707
- timezone?: string;
697
+ company?: string | null;
698
+ phone?: string | null;
699
+ position?: string | null;
700
+ language?: string | null;
701
+ timezone?: string | null;
708
702
  readonly avatar: string | null;
709
703
  /**
710
704
  * Staff status
@@ -847,32 +841,26 @@ export type TokenRefreshWritable = {
847
841
  * User data returned after 2FA verification.
848
842
  */
849
843
  export type TotpVerifyUserWritable = {
850
- first_name?: string;
851
- last_name?: string;
852
- company?: string;
853
- phone?: string;
854
- position?: string;
855
- language?: string;
856
- /**
857
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
858
- */
859
- timezone?: string;
844
+ first_name?: string | null;
845
+ last_name?: string | null;
846
+ company?: string | null;
847
+ phone?: string | null;
848
+ position?: string | null;
849
+ language?: string | null;
850
+ timezone?: string | null;
860
851
  };
861
852
 
862
853
  /**
863
854
  * Serializer for user details.
864
855
  */
865
856
  export type UserWritable = {
866
- first_name?: string;
867
- last_name?: string;
868
- company?: string;
869
- phone?: string;
870
- position?: string;
871
- language?: string;
872
- /**
873
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
874
- */
875
- timezone?: string;
857
+ first_name?: string | null;
858
+ last_name?: string | null;
859
+ company?: string | null;
860
+ phone?: string | null;
861
+ position?: string | null;
862
+ language?: string | null;
863
+ timezone?: string | null;
876
864
  };
877
865
 
878
866
  /**