@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
package/dist/index.cjs CHANGED
@@ -51,6 +51,77 @@ __export(index_exports, {
51
51
  });
52
52
  module.exports = __toCommonJS(index_exports);
53
53
 
54
+ // src/_api/generated/helpers/errors.ts
55
+ var APIError = class extends Error {
56
+ constructor(statusCode, statusText, response, url, message) {
57
+ super(message || `HTTP ${statusCode}: ${statusText}`);
58
+ this.statusCode = statusCode;
59
+ this.statusText = statusText;
60
+ this.response = response;
61
+ this.url = url;
62
+ this.name = "APIError";
63
+ }
64
+ static {
65
+ __name(this, "APIError");
66
+ }
67
+ get details() {
68
+ if (typeof this.response === "object" && this.response !== null) {
69
+ return this.response;
70
+ }
71
+ return null;
72
+ }
73
+ get fieldErrors() {
74
+ const details = this.details;
75
+ if (!details) return null;
76
+ const fieldErrors = {};
77
+ for (const [key, value] of Object.entries(details)) {
78
+ if (Array.isArray(value)) fieldErrors[key] = value;
79
+ }
80
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
81
+ }
82
+ get errorMessage() {
83
+ const details = this.details;
84
+ if (!details) return this.message;
85
+ if (details.detail) {
86
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
87
+ }
88
+ if (details.error) return String(details.error);
89
+ if (details.message) return String(details.message);
90
+ const fieldErrors = this.fieldErrors;
91
+ if (fieldErrors) {
92
+ const firstField = Object.keys(fieldErrors)[0];
93
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
94
+ }
95
+ return this.message;
96
+ }
97
+ get isValidationError() {
98
+ return this.statusCode === 400;
99
+ }
100
+ get isAuthError() {
101
+ return this.statusCode === 401;
102
+ }
103
+ get isPermissionError() {
104
+ return this.statusCode === 403;
105
+ }
106
+ get isNotFoundError() {
107
+ return this.statusCode === 404;
108
+ }
109
+ get isServerError() {
110
+ return this.statusCode >= 500 && this.statusCode < 600;
111
+ }
112
+ };
113
+ var NetworkError = class extends Error {
114
+ constructor(message, url, originalError) {
115
+ super(message);
116
+ this.url = url;
117
+ this.originalError = originalError;
118
+ this.name = "NetworkError";
119
+ }
120
+ static {
121
+ __name(this, "NetworkError");
122
+ }
123
+ };
124
+
54
125
  // src/_api/generated/helpers/auth.ts
55
126
  var ACCESS_KEY = "cfg.access_token";
56
127
  var REFRESH_KEY = "cfg.refresh_token";
@@ -129,6 +200,7 @@ function defaultBaseUrl() {
129
200
  }
130
201
  __name(defaultBaseUrl, "defaultBaseUrl");
131
202
  function defaultApiKey() {
203
+ if (isBrowser) return null;
132
204
  try {
133
205
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
134
206
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -293,6 +365,13 @@ function installAuthOnClient(client2) {
293
365
  request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
294
366
  return request;
295
367
  });
368
+ client2.interceptors.error.use((err, res, req) => {
369
+ if (err instanceof APIError) return err;
370
+ const url = req?.url ?? "";
371
+ const status = res?.status ?? 0;
372
+ const statusText = res?.statusText ?? "";
373
+ return new APIError(status, statusText, err, url);
374
+ });
296
375
  client2.interceptors.response.use(async (response, request) => {
297
376
  if (response.status !== 401) return response;
298
377
  if (request.headers.get(RETRY_MARKER)) {
@@ -1918,77 +1997,6 @@ var CookieStorageAdapter = class {
1918
1997
  }
1919
1998
  };
1920
1999
 
1921
- // src/_api/generated/helpers/errors.ts
1922
- var APIError = class extends Error {
1923
- constructor(statusCode, statusText, response, url, message) {
1924
- super(message || `HTTP ${statusCode}: ${statusText}`);
1925
- this.statusCode = statusCode;
1926
- this.statusText = statusText;
1927
- this.response = response;
1928
- this.url = url;
1929
- this.name = "APIError";
1930
- }
1931
- static {
1932
- __name(this, "APIError");
1933
- }
1934
- get details() {
1935
- if (typeof this.response === "object" && this.response !== null) {
1936
- return this.response;
1937
- }
1938
- return null;
1939
- }
1940
- get fieldErrors() {
1941
- const details = this.details;
1942
- if (!details) return null;
1943
- const fieldErrors = {};
1944
- for (const [key, value] of Object.entries(details)) {
1945
- if (Array.isArray(value)) fieldErrors[key] = value;
1946
- }
1947
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
1948
- }
1949
- get errorMessage() {
1950
- const details = this.details;
1951
- if (!details) return this.message;
1952
- if (details.detail) {
1953
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
1954
- }
1955
- if (details.error) return String(details.error);
1956
- if (details.message) return String(details.message);
1957
- const fieldErrors = this.fieldErrors;
1958
- if (fieldErrors) {
1959
- const firstField = Object.keys(fieldErrors)[0];
1960
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
1961
- }
1962
- return this.message;
1963
- }
1964
- get isValidationError() {
1965
- return this.statusCode === 400;
1966
- }
1967
- get isAuthError() {
1968
- return this.statusCode === 401;
1969
- }
1970
- get isPermissionError() {
1971
- return this.statusCode === 403;
1972
- }
1973
- get isNotFoundError() {
1974
- return this.statusCode === 404;
1975
- }
1976
- get isServerError() {
1977
- return this.statusCode >= 500 && this.statusCode < 600;
1978
- }
1979
- };
1980
- var NetworkError = class extends Error {
1981
- constructor(message, url, originalError) {
1982
- super(message);
1983
- this.url = url;
1984
- this.originalError = originalError;
1985
- this.name = "NetworkError";
1986
- }
1987
- static {
1988
- __name(this, "NetworkError");
1989
- }
1990
- };
1991
-
1992
2000
  // src/_api/generated/helpers/validation-events.ts
1993
2001
  function dispatchValidationError(detail) {
1994
2002
  if (typeof window === "undefined") return;