@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
@@ -958,8 +958,8 @@ type TokenRefreshRequest = {
958
958
  type TotpVerifyUser = {
959
959
  readonly id: number;
960
960
  readonly email: string;
961
- first_name?: string;
962
- last_name?: string;
961
+ first_name?: string | null;
962
+ last_name?: string | null;
963
963
  /**
964
964
  * Get user's full name.
965
965
  */
@@ -972,14 +972,11 @@ type TotpVerifyUser = {
972
972
  * Get formatted username for display.
973
973
  */
974
974
  readonly display_username: string;
975
- company?: string;
976
- phone?: string;
977
- position?: string;
978
- language?: string;
979
- /**
980
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
981
- */
982
- timezone?: string;
975
+ company?: string | null;
976
+ phone?: string | null;
977
+ position?: string | null;
978
+ language?: string | null;
979
+ timezone?: string | null;
983
980
  readonly avatar: string | null;
984
981
  /**
985
982
  * Staff status
@@ -1004,8 +1001,8 @@ type TotpVerifyUser = {
1004
1001
  type User = {
1005
1002
  readonly id: number;
1006
1003
  readonly email: string;
1007
- first_name?: string;
1008
- last_name?: string;
1004
+ first_name?: string | null;
1005
+ last_name?: string | null;
1009
1006
  /**
1010
1007
  * Get user's full name.
1011
1008
  */
@@ -1018,14 +1015,11 @@ type User = {
1018
1015
  * Get formatted username for display.
1019
1016
  */
1020
1017
  readonly display_username: string;
1021
- company?: string;
1022
- phone?: string;
1023
- position?: string;
1024
- language?: string;
1025
- /**
1026
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
1027
- */
1028
- timezone?: string;
1018
+ company?: string | null;
1019
+ phone?: string | null;
1020
+ position?: string | null;
1021
+ language?: string | null;
1022
+ timezone?: string | null;
1029
1023
  readonly avatar: string | null;
1030
1024
  /**
1031
1025
  * Staff status
package/dist/clients.d.ts CHANGED
@@ -958,8 +958,8 @@ type TokenRefreshRequest = {
958
958
  type TotpVerifyUser = {
959
959
  readonly id: number;
960
960
  readonly email: string;
961
- first_name?: string;
962
- last_name?: string;
961
+ first_name?: string | null;
962
+ last_name?: string | null;
963
963
  /**
964
964
  * Get user's full name.
965
965
  */
@@ -972,14 +972,11 @@ type TotpVerifyUser = {
972
972
  * Get formatted username for display.
973
973
  */
974
974
  readonly display_username: string;
975
- company?: string;
976
- phone?: string;
977
- position?: string;
978
- language?: string;
979
- /**
980
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
981
- */
982
- timezone?: string;
975
+ company?: string | null;
976
+ phone?: string | null;
977
+ position?: string | null;
978
+ language?: string | null;
979
+ timezone?: string | null;
983
980
  readonly avatar: string | null;
984
981
  /**
985
982
  * Staff status
@@ -1004,8 +1001,8 @@ type TotpVerifyUser = {
1004
1001
  type User = {
1005
1002
  readonly id: number;
1006
1003
  readonly email: string;
1007
- first_name?: string;
1008
- last_name?: string;
1004
+ first_name?: string | null;
1005
+ last_name?: string | null;
1009
1006
  /**
1010
1007
  * Get user's full name.
1011
1008
  */
@@ -1018,14 +1015,11 @@ type User = {
1018
1015
  * Get formatted username for display.
1019
1016
  */
1020
1017
  readonly display_username: string;
1021
- company?: string;
1022
- phone?: string;
1023
- position?: string;
1024
- language?: string;
1025
- /**
1026
- * IANA timezone name (e.g. 'Asia/Seoul'). Auto-detected from browser via X-Timezone header.
1027
- */
1028
- timezone?: string;
1018
+ company?: string | null;
1019
+ phone?: string | null;
1020
+ position?: string | null;
1021
+ language?: string | null;
1022
+ timezone?: string | null;
1029
1023
  readonly avatar: string | null;
1030
1024
  /**
1031
1025
  * Staff status
package/dist/clients.mjs CHANGED
@@ -2,6 +2,66 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
 
5
+ // src/_api/generated/helpers/errors.ts
6
+ var APIError = class extends Error {
7
+ constructor(statusCode, statusText, response, url, message) {
8
+ super(message || `HTTP ${statusCode}: ${statusText}`);
9
+ this.statusCode = statusCode;
10
+ this.statusText = statusText;
11
+ this.response = response;
12
+ this.url = url;
13
+ this.name = "APIError";
14
+ }
15
+ static {
16
+ __name(this, "APIError");
17
+ }
18
+ get details() {
19
+ if (typeof this.response === "object" && this.response !== null) {
20
+ return this.response;
21
+ }
22
+ return null;
23
+ }
24
+ get fieldErrors() {
25
+ const details = this.details;
26
+ if (!details) return null;
27
+ const fieldErrors = {};
28
+ for (const [key, value] of Object.entries(details)) {
29
+ if (Array.isArray(value)) fieldErrors[key] = value;
30
+ }
31
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
32
+ }
33
+ get errorMessage() {
34
+ const details = this.details;
35
+ if (!details) return this.message;
36
+ if (details.detail) {
37
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
38
+ }
39
+ if (details.error) return String(details.error);
40
+ if (details.message) return String(details.message);
41
+ const fieldErrors = this.fieldErrors;
42
+ if (fieldErrors) {
43
+ const firstField = Object.keys(fieldErrors)[0];
44
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
45
+ }
46
+ return this.message;
47
+ }
48
+ get isValidationError() {
49
+ return this.statusCode === 400;
50
+ }
51
+ get isAuthError() {
52
+ return this.statusCode === 401;
53
+ }
54
+ get isPermissionError() {
55
+ return this.statusCode === 403;
56
+ }
57
+ get isNotFoundError() {
58
+ return this.statusCode === 404;
59
+ }
60
+ get isServerError() {
61
+ return this.statusCode >= 500 && this.statusCode < 600;
62
+ }
63
+ };
64
+
5
65
  // src/_api/generated/helpers/auth.ts
6
66
  var ACCESS_KEY = "cfg.access_token";
7
67
  var REFRESH_KEY = "cfg.refresh_token";
@@ -80,6 +140,7 @@ function defaultBaseUrl() {
80
140
  }
81
141
  __name(defaultBaseUrl, "defaultBaseUrl");
82
142
  function defaultApiKey() {
143
+ if (isBrowser) return null;
83
144
  try {
84
145
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
85
146
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -244,6 +305,13 @@ function installAuthOnClient(client2) {
244
305
  request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
245
306
  return request;
246
307
  });
308
+ client2.interceptors.error.use((err, res, req) => {
309
+ if (err instanceof APIError) return err;
310
+ const url = req?.url ?? "";
311
+ const status = res?.status ?? 0;
312
+ const statusText = res?.statusText ?? "";
313
+ return new APIError(status, statusText, err, url);
314
+ });
247
315
  client2.interceptors.response.use(async (response, request) => {
248
316
  if (response.status !== 401) return response;
249
317
  if (request.headers.get(RETRY_MARKER)) {