@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/auth.cjs CHANGED
@@ -323,6 +323,66 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
323
323
  // src/auth/hooks/useTwoFactor.ts
324
324
  var import_react6 = require("react");
325
325
 
326
+ // src/_api/generated/helpers/errors.ts
327
+ var APIError = class extends Error {
328
+ constructor(statusCode, statusText, response, url, message) {
329
+ super(message || `HTTP ${statusCode}: ${statusText}`);
330
+ this.statusCode = statusCode;
331
+ this.statusText = statusText;
332
+ this.response = response;
333
+ this.url = url;
334
+ this.name = "APIError";
335
+ }
336
+ static {
337
+ __name(this, "APIError");
338
+ }
339
+ get details() {
340
+ if (typeof this.response === "object" && this.response !== null) {
341
+ return this.response;
342
+ }
343
+ return null;
344
+ }
345
+ get fieldErrors() {
346
+ const details = this.details;
347
+ if (!details) return null;
348
+ const fieldErrors = {};
349
+ for (const [key, value] of Object.entries(details)) {
350
+ if (Array.isArray(value)) fieldErrors[key] = value;
351
+ }
352
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
353
+ }
354
+ get errorMessage() {
355
+ const details = this.details;
356
+ if (!details) return this.message;
357
+ if (details.detail) {
358
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
359
+ }
360
+ if (details.error) return String(details.error);
361
+ if (details.message) return String(details.message);
362
+ const fieldErrors = this.fieldErrors;
363
+ if (fieldErrors) {
364
+ const firstField = Object.keys(fieldErrors)[0];
365
+ if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
366
+ }
367
+ return this.message;
368
+ }
369
+ get isValidationError() {
370
+ return this.statusCode === 400;
371
+ }
372
+ get isAuthError() {
373
+ return this.statusCode === 401;
374
+ }
375
+ get isPermissionError() {
376
+ return this.statusCode === 403;
377
+ }
378
+ get isNotFoundError() {
379
+ return this.statusCode === 404;
380
+ }
381
+ get isServerError() {
382
+ return this.statusCode >= 500 && this.statusCode < 600;
383
+ }
384
+ };
385
+
326
386
  // src/_api/generated/helpers/auth.ts
327
387
  var ACCESS_KEY = "cfg.access_token";
328
388
  var REFRESH_KEY = "cfg.refresh_token";
@@ -401,6 +461,7 @@ function defaultBaseUrl() {
401
461
  }
402
462
  __name(defaultBaseUrl, "defaultBaseUrl");
403
463
  function defaultApiKey() {
464
+ if (isBrowser2) return null;
404
465
  try {
405
466
  if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
406
467
  return process.env.NEXT_PUBLIC_API_KEY;
@@ -565,6 +626,13 @@ function installAuthOnClient(client2) {
565
626
  request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
566
627
  return request;
567
628
  });
629
+ client2.interceptors.error.use((err, res, req) => {
630
+ if (err instanceof APIError) return err;
631
+ const url = req?.url ?? "";
632
+ const status = res?.status ?? 0;
633
+ const statusText = res?.statusText ?? "";
634
+ return new APIError(status, statusText, err, url);
635
+ });
568
636
  client2.interceptors.response.use(async (response, request) => {
569
637
  if (response.status !== 401) return response;
570
638
  if (request.headers.get(RETRY_MARKER)) {
@@ -2100,66 +2168,6 @@ var API = class {
2100
2168
  }
2101
2169
  };
2102
2170
 
2103
- // src/_api/generated/helpers/errors.ts
2104
- var APIError = class extends Error {
2105
- constructor(statusCode, statusText, response, url, message) {
2106
- super(message || `HTTP ${statusCode}: ${statusText}`);
2107
- this.statusCode = statusCode;
2108
- this.statusText = statusText;
2109
- this.response = response;
2110
- this.url = url;
2111
- this.name = "APIError";
2112
- }
2113
- static {
2114
- __name(this, "APIError");
2115
- }
2116
- get details() {
2117
- if (typeof this.response === "object" && this.response !== null) {
2118
- return this.response;
2119
- }
2120
- return null;
2121
- }
2122
- get fieldErrors() {
2123
- const details = this.details;
2124
- if (!details) return null;
2125
- const fieldErrors = {};
2126
- for (const [key, value] of Object.entries(details)) {
2127
- if (Array.isArray(value)) fieldErrors[key] = value;
2128
- }
2129
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
2130
- }
2131
- get errorMessage() {
2132
- const details = this.details;
2133
- if (!details) return this.message;
2134
- if (details.detail) {
2135
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2136
- }
2137
- if (details.error) return String(details.error);
2138
- if (details.message) return String(details.message);
2139
- const fieldErrors = this.fieldErrors;
2140
- if (fieldErrors) {
2141
- const firstField = Object.keys(fieldErrors)[0];
2142
- if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
2143
- }
2144
- return this.message;
2145
- }
2146
- get isValidationError() {
2147
- return this.statusCode === 400;
2148
- }
2149
- get isAuthError() {
2150
- return this.statusCode === 401;
2151
- }
2152
- get isPermissionError() {
2153
- return this.statusCode === 403;
2154
- }
2155
- get isNotFoundError() {
2156
- return this.statusCode === 404;
2157
- }
2158
- get isServerError() {
2159
- return this.statusCode >= 500 && this.statusCode < 600;
2160
- }
2161
- };
2162
-
2163
2171
  // src/_api/generated/_cfg_centrifugo/api.ts
2164
2172
  var API2 = class {
2165
2173
  static {
@@ -3890,16 +3898,16 @@ var CentrifugoTokenSchema = import_zod12.z.object({
3890
3898
  var UserSchema = import_zod13.z.object({
3891
3899
  id: import_zod13.z.number().int(),
3892
3900
  email: import_zod13.z.email(),
3893
- first_name: import_zod13.z.string().max(50).optional(),
3894
- last_name: import_zod13.z.string().max(50).optional(),
3901
+ first_name: import_zod13.z.string().max(50).nullable().optional(),
3902
+ last_name: import_zod13.z.string().max(50).nullable().optional(),
3895
3903
  full_name: import_zod13.z.string(),
3896
3904
  initials: import_zod13.z.string(),
3897
3905
  display_username: import_zod13.z.string(),
3898
- company: import_zod13.z.string().max(100).optional(),
3899
- phone: import_zod13.z.string().max(20).optional(),
3900
- position: import_zod13.z.string().max(100).optional(),
3901
- language: import_zod13.z.string().max(10).optional(),
3902
- timezone: import_zod13.z.string().max(64).optional(),
3906
+ company: import_zod13.z.string().max(100).nullable().optional(),
3907
+ phone: import_zod13.z.string().max(20).nullable().optional(),
3908
+ position: import_zod13.z.string().max(100).nullable().optional(),
3909
+ language: import_zod13.z.string().max(10).nullable().optional(),
3910
+ timezone: import_zod13.z.string().max(64).nullable().optional(),
3903
3911
  avatar: import_zod13.z.string().nullable(),
3904
3912
  is_staff: import_zod13.z.boolean(),
3905
3913
  is_superuser: import_zod13.z.boolean(),