@djangocfg/api 2.1.262 → 2.1.264

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 (51) hide show
  1. package/dist/auth-server.cjs +9 -0
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +9 -0
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +76 -72
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.mjs +76 -72
  8. package/dist/auth.mjs.map +1 -1
  9. package/dist/clients.cjs +122 -80
  10. package/dist/clients.cjs.map +1 -1
  11. package/dist/clients.d.cts +129 -172
  12. package/dist/clients.d.ts +129 -172
  13. package/dist/clients.mjs +122 -80
  14. package/dist/clients.mjs.map +1 -1
  15. package/dist/hooks.cjs +47 -1
  16. package/dist/hooks.cjs.map +1 -1
  17. package/dist/hooks.d.cts +80 -57
  18. package/dist/hooks.d.ts +80 -57
  19. package/dist/hooks.mjs +47 -1
  20. package/dist/hooks.mjs.map +1 -1
  21. package/dist/index.cjs +56 -1
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.d.cts +99 -99
  24. package/dist/index.d.ts +99 -99
  25. package/dist/index.mjs +56 -1
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +2 -2
  28. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +46 -2
  29. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +3 -2
  30. package/src/_api/generated/cfg_accounts/accounts/models.ts +34 -34
  31. package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +1 -1
  32. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +54 -54
  33. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +14 -14
  34. package/src/_api/generated/cfg_accounts/client.ts +8 -0
  35. package/src/_api/generated/cfg_accounts/errors.ts +5 -0
  36. package/src/_api/generated/cfg_centrifugo/client.ts +8 -0
  37. package/src/_api/generated/cfg_centrifugo/errors.ts +5 -0
  38. package/src/_api/generated/cfg_totp/CLAUDE.md +3 -3
  39. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +7 -7
  40. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +5 -5
  41. package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -1
  42. package/src/_api/generated/cfg_totp/client.ts +8 -0
  43. package/src/_api/generated/cfg_totp/errors.ts +5 -0
  44. package/src/_api/generated/cfg_totp/schema.json +2 -103
  45. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +10 -10
  46. package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +2 -13
  47. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +9 -34
  48. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +12 -12
  49. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
  50. package/src/auth/hooks/useTwoFactorStatus.ts +5 -11
  51. package/src/_api/generated/cfg_totp/_utils/schemas/PaginatedDeviceListResponseList.schema.ts +0 -24
package/dist/clients.cjs CHANGED
@@ -387,6 +387,9 @@ var APIError = class extends Error {
387
387
  if (details.detail) {
388
388
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
389
389
  }
390
+ if (details.error) {
391
+ return String(details.error);
392
+ }
390
393
  if (details.message) {
391
394
  return String(details.message);
392
395
  }
@@ -725,6 +728,12 @@ var APIClient = class {
725
728
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
726
729
  headers["Content-Type"] = "application/json";
727
730
  }
731
+ if (!headers["Authorization"]) {
732
+ const token = this.getToken();
733
+ if (token) {
734
+ headers["Authorization"] = `Bearer ${token}`;
735
+ }
736
+ }
728
737
  if (this.logger) {
729
738
  this.logger.logRequest({
730
739
  method,
@@ -1273,7 +1282,44 @@ var import_consola4 = require("consola");
1273
1282
  async function getAccountsOauthConnectionsList(client) {
1274
1283
  const api = client || getAPIInstance();
1275
1284
  const response = await api.oauth.accountsOauthConnectionsList();
1276
- return response;
1285
+ try {
1286
+ return OAuthConnectionSchema.array().parse(response);
1287
+ } catch (error) {
1288
+ import_consola4.consola.error("\u274C Zod Validation Failed");
1289
+ import_consola4.consola.box(`getAccountsOauthConnectionsList
1290
+ Path: /cfg/accounts/oauth/connections/
1291
+ Method: GET`);
1292
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1293
+ import_consola4.consola.error("Validation Issues:");
1294
+ error.issues.forEach((issue, index) => {
1295
+ import_consola4.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1296
+ import_consola4.consola.error(` \u251C\u2500 Message: ${issue.message}`);
1297
+ if (issue.expected) import_consola4.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1298
+ if (issue.received) import_consola4.consola.error(` \u2514\u2500 Received: ${issue.received}`);
1299
+ });
1300
+ }
1301
+ import_consola4.consola.error("Response data:", response);
1302
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1303
+ try {
1304
+ const event = new CustomEvent("zod-validation-error", {
1305
+ detail: {
1306
+ operation: "getAccountsOauthConnectionsList",
1307
+ path: "/cfg/accounts/oauth/connections/",
1308
+ method: "GET",
1309
+ error,
1310
+ response,
1311
+ timestamp: /* @__PURE__ */ new Date()
1312
+ },
1313
+ bubbles: true,
1314
+ cancelable: false
1315
+ });
1316
+ window.dispatchEvent(event);
1317
+ } catch (eventError) {
1318
+ import_consola4.consola.warn("Failed to dispatch validation error event:", eventError);
1319
+ }
1320
+ }
1321
+ throw error;
1322
+ }
1277
1323
  }
1278
1324
  __name(getAccountsOauthConnectionsList, "getAccountsOauthConnectionsList");
1279
1325
  async function createAccountsOauthDisconnectCreate(data, client) {
@@ -2005,6 +2051,9 @@ var APIError2 = class extends Error {
2005
2051
  if (details.detail) {
2006
2052
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2007
2053
  }
2054
+ if (details.error) {
2055
+ return String(details.error);
2056
+ }
2008
2057
  if (details.message) {
2009
2058
  return String(details.message);
2010
2059
  }
@@ -2340,6 +2389,12 @@ var APIClient2 = class {
2340
2389
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
2341
2390
  headers["Content-Type"] = "application/json";
2342
2391
  }
2392
+ if (!headers["Authorization"]) {
2393
+ const token = this.getToken();
2394
+ if (token) {
2395
+ headers["Authorization"] = `Bearer ${token}`;
2396
+ }
2397
+ }
2343
2398
  if (this.logger) {
2344
2399
  this.logger.logRequest({
2345
2400
  method,
@@ -2808,15 +2863,8 @@ var TotpManagement = class {
2808
2863
  /**
2809
2864
  * List all TOTP devices for user.
2810
2865
  */
2811
- async totpDevicesList(...args) {
2812
- const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2813
- let params;
2814
- if (isParamsObject) {
2815
- params = args[0];
2816
- } else {
2817
- params = { ordering: args[0], page: args[1], page_size: args[2], search: args[3] };
2818
- }
2819
- const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
2866
+ async totpDevicesRetrieve() {
2867
+ const response = await this.client.request("GET", "/cfg/totp/devices/");
2820
2868
  return response;
2821
2869
  }
2822
2870
  /**
@@ -3004,6 +3052,9 @@ var APIError3 = class extends Error {
3004
3052
  if (details.detail) {
3005
3053
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
3006
3054
  }
3055
+ if (details.error) {
3056
+ return String(details.error);
3057
+ }
3007
3058
  if (details.message) {
3008
3059
  return String(details.message);
3009
3060
  }
@@ -3343,6 +3394,12 @@ var APIClient3 = class {
3343
3394
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
3344
3395
  headers["Content-Type"] = "application/json";
3345
3396
  }
3397
+ if (!headers["Authorization"]) {
3398
+ const token = this.getToken();
3399
+ if (token) {
3400
+ headers["Authorization"] = `Bearer ${token}`;
3401
+ }
3402
+ }
3346
3403
  if (this.logger) {
3347
3404
  this.logger.logRequest({
3348
3405
  method,
@@ -3544,7 +3601,6 @@ __export(schemas_exports3, {
3544
3601
  DeviceListResponseSchema: () => DeviceListResponseSchema,
3545
3602
  DeviceListSchema: () => DeviceListSchema,
3546
3603
  DisableRequestSchema: () => DisableRequestSchema,
3547
- PaginatedDeviceListResponseListSchema: () => PaginatedDeviceListResponseListSchema,
3548
3604
  SetupRequestSchema: () => SetupRequestSchema,
3549
3605
  SetupResponseSchema: () => SetupResponseSchema,
3550
3606
  TotpVerifyUserSchema: () => TotpVerifyUserSchema,
@@ -3614,81 +3670,67 @@ var DisableRequestSchema = import_zod30.z.object({
3614
3670
  code: import_zod30.z.string().min(6).max(6)
3615
3671
  });
3616
3672
 
3617
- // src/_api/generated/cfg_totp/_utils/schemas/PaginatedDeviceListResponseList.schema.ts
3673
+ // src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
3618
3674
  var import_zod31 = require("zod");
3619
- var PaginatedDeviceListResponseListSchema = import_zod31.z.object({
3620
- count: import_zod31.z.number().int(),
3621
- page: import_zod31.z.number().int(),
3622
- pages: import_zod31.z.number().int(),
3623
- page_size: import_zod31.z.number().int(),
3624
- has_next: import_zod31.z.boolean(),
3625
- has_previous: import_zod31.z.boolean(),
3626
- next_page: import_zod31.z.number().int().nullable().optional(),
3627
- previous_page: import_zod31.z.number().int().nullable().optional(),
3628
- results: import_zod31.z.array(DeviceListResponseSchema)
3675
+ var SetupRequestSchema = import_zod31.z.object({
3676
+ device_name: import_zod31.z.string().min(1).max(100).optional()
3629
3677
  });
3630
3678
 
3631
- // src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
3679
+ // src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
3632
3680
  var import_zod32 = require("zod");
3633
- var SetupRequestSchema = import_zod32.z.object({
3634
- device_name: import_zod32.z.string().min(1).max(100).optional()
3681
+ var SetupResponseSchema = import_zod32.z.object({
3682
+ device_id: import_zod32.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3683
+ secret: import_zod32.z.string(),
3684
+ provisioning_uri: import_zod32.z.string(),
3685
+ qr_code_base64: import_zod32.z.string(),
3686
+ expires_in: import_zod32.z.number().int()
3635
3687
  });
3636
3688
 
3637
- // src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
3689
+ // src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
3638
3690
  var import_zod33 = require("zod");
3639
- var SetupResponseSchema = import_zod33.z.object({
3640
- device_id: import_zod33.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3641
- secret: import_zod33.z.string(),
3642
- provisioning_uri: import_zod33.z.string(),
3643
- qr_code_base64: import_zod33.z.string(),
3644
- expires_in: import_zod33.z.number().int()
3691
+ var TotpVerifyUserSchema = import_zod33.z.object({
3692
+ id: import_zod33.z.number().int(),
3693
+ email: import_zod33.z.email(),
3694
+ first_name: import_zod33.z.string().max(50).optional(),
3695
+ last_name: import_zod33.z.string().max(50).optional(),
3696
+ full_name: import_zod33.z.string(),
3697
+ initials: import_zod33.z.string(),
3698
+ display_username: import_zod33.z.string(),
3699
+ company: import_zod33.z.string().max(100).optional(),
3700
+ phone: import_zod33.z.string().max(20).optional(),
3701
+ position: import_zod33.z.string().max(100).optional(),
3702
+ language: import_zod33.z.string().max(10).optional(),
3703
+ avatar: import_zod33.z.string().nullable(),
3704
+ is_staff: import_zod33.z.boolean(),
3705
+ is_superuser: import_zod33.z.boolean(),
3706
+ date_joined: import_zod33.z.string().datetime({ offset: true }),
3707
+ last_login: import_zod33.z.string().datetime({ offset: true }).nullable(),
3708
+ unanswered_messages_count: import_zod33.z.number().int()
3645
3709
  });
3646
3710
 
3647
- // src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
3711
+ // src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
3648
3712
  var import_zod34 = require("zod");
3649
- var TotpVerifyUserSchema = import_zod34.z.object({
3650
- id: import_zod34.z.number().int(),
3651
- email: import_zod34.z.email(),
3652
- first_name: import_zod34.z.string().max(50).optional(),
3653
- last_name: import_zod34.z.string().max(50).optional(),
3654
- full_name: import_zod34.z.string(),
3655
- initials: import_zod34.z.string(),
3656
- display_username: import_zod34.z.string(),
3657
- company: import_zod34.z.string().max(100).optional(),
3658
- phone: import_zod34.z.string().max(20).optional(),
3659
- position: import_zod34.z.string().max(100).optional(),
3660
- language: import_zod34.z.string().max(10).optional(),
3661
- avatar: import_zod34.z.string().nullable(),
3662
- is_staff: import_zod34.z.boolean(),
3663
- is_superuser: import_zod34.z.boolean(),
3664
- date_joined: import_zod34.z.string().datetime({ offset: true }),
3665
- last_login: import_zod34.z.string().datetime({ offset: true }).nullable(),
3666
- unanswered_messages_count: import_zod34.z.number().int()
3713
+ var VerifyBackupRequestSchema = import_zod34.z.object({
3714
+ session_id: import_zod34.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3715
+ backup_code: import_zod34.z.string().min(8).max(8)
3667
3716
  });
3668
3717
 
3669
- // src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
3718
+ // src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
3670
3719
  var import_zod35 = require("zod");
3671
- var VerifyBackupRequestSchema = import_zod35.z.object({
3720
+ var VerifyRequestSchema = import_zod35.z.object({
3672
3721
  session_id: import_zod35.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3673
- backup_code: import_zod35.z.string().min(8).max(8)
3674
- });
3675
-
3676
- // src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
3677
- var import_zod36 = require("zod");
3678
- var VerifyRequestSchema = import_zod36.z.object({
3679
- session_id: import_zod36.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3680
- code: import_zod36.z.string().min(6).max(6)
3722
+ code: import_zod35.z.string().min(6).max(6)
3681
3723
  });
3682
3724
 
3683
3725
  // src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
3684
- var import_zod37 = require("zod");
3685
- var VerifyResponseSchema = import_zod37.z.object({
3686
- message: import_zod37.z.string(),
3687
- access_token: import_zod37.z.string(),
3688
- refresh_token: import_zod37.z.string(),
3726
+ var import_zod36 = require("zod");
3727
+ var VerifyResponseSchema = import_zod36.z.object({
3728
+ message: import_zod36.z.string(),
3729
+ access_token: import_zod36.z.string(),
3730
+ refresh_token: import_zod36.z.string(),
3689
3731
  user: TotpVerifyUserSchema,
3690
- remaining_backup_codes: import_zod37.z.number().int().optional(),
3691
- warning: import_zod37.z.string().optional()
3732
+ remaining_backup_codes: import_zod36.z.number().int().optional(),
3733
+ warning: import_zod36.z.string().optional()
3692
3734
  });
3693
3735
 
3694
3736
  // src/_api/generated/cfg_totp/_utils/fetchers/index.ts
@@ -3702,7 +3744,7 @@ __export(fetchers_exports3, {
3702
3744
  createTotpVerifyCreate: () => createTotpVerifyCreate,
3703
3745
  deleteTotpDevicesDestroy: () => deleteTotpDevicesDestroy,
3704
3746
  getTotpBackupCodesRetrieve: () => getTotpBackupCodesRetrieve,
3705
- getTotpDevicesList: () => getTotpDevicesList
3747
+ getTotpDevicesRetrieve: () => getTotpDevicesRetrieve
3706
3748
  });
3707
3749
 
3708
3750
  // src/_api/generated/cfg_totp/api-instance.ts
@@ -3829,14 +3871,14 @@ __name(createTotpBackupCodesRegenerateCreate, "createTotpBackupCodesRegenerateCr
3829
3871
 
3830
3872
  // src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts
3831
3873
  var import_consola10 = require("consola");
3832
- async function getTotpDevicesList(params, client) {
3874
+ async function getTotpDevicesRetrieve(client) {
3833
3875
  const api = client || getAPIInstance3();
3834
- const response = await api.totp_management.totpDevicesList(params?.ordering, params?.page, params?.page_size, params?.search);
3876
+ const response = await api.totp_management.totpDevicesRetrieve();
3835
3877
  try {
3836
- return PaginatedDeviceListResponseListSchema.parse(response);
3878
+ return DeviceListResponseSchema.parse(response);
3837
3879
  } catch (error) {
3838
3880
  import_consola10.consola.error("\u274C Zod Validation Failed");
3839
- import_consola10.consola.box(`getTotpDevicesList
3881
+ import_consola10.consola.box(`getTotpDevicesRetrieve
3840
3882
  Path: /cfg/totp/devices/
3841
3883
  Method: GET`);
3842
3884
  if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
@@ -3853,7 +3895,7 @@ Method: GET`);
3853
3895
  try {
3854
3896
  const event = new CustomEvent("zod-validation-error", {
3855
3897
  detail: {
3856
- operation: "getTotpDevicesList",
3898
+ operation: "getTotpDevicesRetrieve",
3857
3899
  path: "/cfg/totp/devices/",
3858
3900
  method: "GET",
3859
3901
  error,
@@ -3871,7 +3913,7 @@ Method: GET`);
3871
3913
  throw error;
3872
3914
  }
3873
3915
  }
3874
- __name(getTotpDevicesList, "getTotpDevicesList");
3916
+ __name(getTotpDevicesRetrieve, "getTotpDevicesRetrieve");
3875
3917
  async function createTotpDisableCreate(data, client) {
3876
3918
  const api = client || getAPIInstance3();
3877
3919
  const response = await api.totp_management.totpDisableCreate(data);
@@ -4391,7 +4433,7 @@ __export(hooks_exports2, {
4391
4433
  useCreateTotpVerifyCreate: () => useCreateTotpVerifyCreate,
4392
4434
  useDeleteTotpDevicesDestroy: () => useDeleteTotpDevicesDestroy,
4393
4435
  useTotpBackupCodesRetrieve: () => useTotpBackupCodesRetrieve,
4394
- useTotpDevicesList: () => useTotpDevicesList
4436
+ useTotpDevicesRetrieve: () => useTotpDevicesRetrieve
4395
4437
  });
4396
4438
 
4397
4439
  // src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts
@@ -4417,13 +4459,13 @@ __name(useCreateTotpBackupCodesRegenerateCreate, "useCreateTotpBackupCodesRegene
4417
4459
  // src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts
4418
4460
  var import_swr10 = __toESM(require("swr"), 1);
4419
4461
  var import_swr11 = require("swr");
4420
- function useTotpDevicesList(params, client) {
4462
+ function useTotpDevicesRetrieve(client) {
4421
4463
  return (0, import_swr10.default)(
4422
- ["cfg-totp-devices", params],
4423
- () => getTotpDevicesList(params, client)
4464
+ "cfg-totp-device",
4465
+ () => getTotpDevicesRetrieve(client)
4424
4466
  );
4425
4467
  }
4426
- __name(useTotpDevicesList, "useTotpDevicesList");
4468
+ __name(useTotpDevicesRetrieve, "useTotpDevicesRetrieve");
4427
4469
  function useCreateTotpDisableCreate() {
4428
4470
  const { mutate } = (0, import_swr11.useSWRConfig)();
4429
4471
  return async (data, client) => {