@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.mjs CHANGED
@@ -295,6 +295,9 @@ var APIError = class extends Error {
295
295
  if (details.detail) {
296
296
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
297
297
  }
298
+ if (details.error) {
299
+ return String(details.error);
300
+ }
298
301
  if (details.message) {
299
302
  return String(details.message);
300
303
  }
@@ -633,6 +636,12 @@ var APIClient = class {
633
636
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
634
637
  headers["Content-Type"] = "application/json";
635
638
  }
639
+ if (!headers["Authorization"]) {
640
+ const token = this.getToken();
641
+ if (token) {
642
+ headers["Authorization"] = `Bearer ${token}`;
643
+ }
644
+ }
636
645
  if (this.logger) {
637
646
  this.logger.logRequest({
638
647
  method,
@@ -1181,7 +1190,44 @@ import { consola as consola3 } from "consola";
1181
1190
  async function getAccountsOauthConnectionsList(client) {
1182
1191
  const api = client || getAPIInstance();
1183
1192
  const response = await api.oauth.accountsOauthConnectionsList();
1184
- return response;
1193
+ try {
1194
+ return OAuthConnectionSchema.array().parse(response);
1195
+ } catch (error) {
1196
+ consola3.error("\u274C Zod Validation Failed");
1197
+ consola3.box(`getAccountsOauthConnectionsList
1198
+ Path: /cfg/accounts/oauth/connections/
1199
+ Method: GET`);
1200
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1201
+ consola3.error("Validation Issues:");
1202
+ error.issues.forEach((issue, index) => {
1203
+ consola3.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1204
+ consola3.error(` \u251C\u2500 Message: ${issue.message}`);
1205
+ if (issue.expected) consola3.error(` \u251C\u2500 Expected: ${issue.expected}`);
1206
+ if (issue.received) consola3.error(` \u2514\u2500 Received: ${issue.received}`);
1207
+ });
1208
+ }
1209
+ consola3.error("Response data:", response);
1210
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1211
+ try {
1212
+ const event = new CustomEvent("zod-validation-error", {
1213
+ detail: {
1214
+ operation: "getAccountsOauthConnectionsList",
1215
+ path: "/cfg/accounts/oauth/connections/",
1216
+ method: "GET",
1217
+ error,
1218
+ response,
1219
+ timestamp: /* @__PURE__ */ new Date()
1220
+ },
1221
+ bubbles: true,
1222
+ cancelable: false
1223
+ });
1224
+ window.dispatchEvent(event);
1225
+ } catch (eventError) {
1226
+ consola3.warn("Failed to dispatch validation error event:", eventError);
1227
+ }
1228
+ }
1229
+ throw error;
1230
+ }
1185
1231
  }
1186
1232
  __name(getAccountsOauthConnectionsList, "getAccountsOauthConnectionsList");
1187
1233
  async function createAccountsOauthDisconnectCreate(data, client) {
@@ -1913,6 +1959,9 @@ var APIError2 = class extends Error {
1913
1959
  if (details.detail) {
1914
1960
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
1915
1961
  }
1962
+ if (details.error) {
1963
+ return String(details.error);
1964
+ }
1916
1965
  if (details.message) {
1917
1966
  return String(details.message);
1918
1967
  }
@@ -2248,6 +2297,12 @@ var APIClient2 = class {
2248
2297
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
2249
2298
  headers["Content-Type"] = "application/json";
2250
2299
  }
2300
+ if (!headers["Authorization"]) {
2301
+ const token = this.getToken();
2302
+ if (token) {
2303
+ headers["Authorization"] = `Bearer ${token}`;
2304
+ }
2305
+ }
2251
2306
  if (this.logger) {
2252
2307
  this.logger.logRequest({
2253
2308
  method,
@@ -2716,15 +2771,8 @@ var TotpManagement = class {
2716
2771
  /**
2717
2772
  * List all TOTP devices for user.
2718
2773
  */
2719
- async totpDevicesList(...args) {
2720
- const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2721
- let params;
2722
- if (isParamsObject) {
2723
- params = args[0];
2724
- } else {
2725
- params = { ordering: args[0], page: args[1], page_size: args[2], search: args[3] };
2726
- }
2727
- const response = await this.client.request("GET", "/cfg/totp/devices/", { params });
2774
+ async totpDevicesRetrieve() {
2775
+ const response = await this.client.request("GET", "/cfg/totp/devices/");
2728
2776
  return response;
2729
2777
  }
2730
2778
  /**
@@ -2912,6 +2960,9 @@ var APIError3 = class extends Error {
2912
2960
  if (details.detail) {
2913
2961
  return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2914
2962
  }
2963
+ if (details.error) {
2964
+ return String(details.error);
2965
+ }
2915
2966
  if (details.message) {
2916
2967
  return String(details.message);
2917
2968
  }
@@ -3251,6 +3302,12 @@ var APIClient3 = class {
3251
3302
  if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
3252
3303
  headers["Content-Type"] = "application/json";
3253
3304
  }
3305
+ if (!headers["Authorization"]) {
3306
+ const token = this.getToken();
3307
+ if (token) {
3308
+ headers["Authorization"] = `Bearer ${token}`;
3309
+ }
3310
+ }
3254
3311
  if (this.logger) {
3255
3312
  this.logger.logRequest({
3256
3313
  method,
@@ -3452,7 +3509,6 @@ __export(schemas_exports3, {
3452
3509
  DeviceListResponseSchema: () => DeviceListResponseSchema,
3453
3510
  DeviceListSchema: () => DeviceListSchema,
3454
3511
  DisableRequestSchema: () => DisableRequestSchema,
3455
- PaginatedDeviceListResponseListSchema: () => PaginatedDeviceListResponseListSchema,
3456
3512
  SetupRequestSchema: () => SetupRequestSchema,
3457
3513
  SetupResponseSchema: () => SetupResponseSchema,
3458
3514
  TotpVerifyUserSchema: () => TotpVerifyUserSchema,
@@ -3522,81 +3578,67 @@ var DisableRequestSchema = z30.object({
3522
3578
  code: z30.string().min(6).max(6)
3523
3579
  });
3524
3580
 
3525
- // src/_api/generated/cfg_totp/_utils/schemas/PaginatedDeviceListResponseList.schema.ts
3581
+ // src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
3526
3582
  import { z as z31 } from "zod";
3527
- var PaginatedDeviceListResponseListSchema = z31.object({
3528
- count: z31.number().int(),
3529
- page: z31.number().int(),
3530
- pages: z31.number().int(),
3531
- page_size: z31.number().int(),
3532
- has_next: z31.boolean(),
3533
- has_previous: z31.boolean(),
3534
- next_page: z31.number().int().nullable().optional(),
3535
- previous_page: z31.number().int().nullable().optional(),
3536
- results: z31.array(DeviceListResponseSchema)
3583
+ var SetupRequestSchema = z31.object({
3584
+ device_name: z31.string().min(1).max(100).optional()
3537
3585
  });
3538
3586
 
3539
- // src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts
3587
+ // src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
3540
3588
  import { z as z32 } from "zod";
3541
- var SetupRequestSchema = z32.object({
3542
- device_name: z32.string().min(1).max(100).optional()
3589
+ var SetupResponseSchema = z32.object({
3590
+ device_id: z32.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3591
+ secret: z32.string(),
3592
+ provisioning_uri: z32.string(),
3593
+ qr_code_base64: z32.string(),
3594
+ expires_in: z32.number().int()
3543
3595
  });
3544
3596
 
3545
- // src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts
3597
+ // src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
3546
3598
  import { z as z33 } from "zod";
3547
- var SetupResponseSchema = z33.object({
3548
- device_id: z33.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3549
- secret: z33.string(),
3550
- provisioning_uri: z33.string(),
3551
- qr_code_base64: z33.string(),
3552
- expires_in: z33.number().int()
3599
+ var TotpVerifyUserSchema = z33.object({
3600
+ id: z33.number().int(),
3601
+ email: z33.email(),
3602
+ first_name: z33.string().max(50).optional(),
3603
+ last_name: z33.string().max(50).optional(),
3604
+ full_name: z33.string(),
3605
+ initials: z33.string(),
3606
+ display_username: z33.string(),
3607
+ company: z33.string().max(100).optional(),
3608
+ phone: z33.string().max(20).optional(),
3609
+ position: z33.string().max(100).optional(),
3610
+ language: z33.string().max(10).optional(),
3611
+ avatar: z33.string().nullable(),
3612
+ is_staff: z33.boolean(),
3613
+ is_superuser: z33.boolean(),
3614
+ date_joined: z33.string().datetime({ offset: true }),
3615
+ last_login: z33.string().datetime({ offset: true }).nullable(),
3616
+ unanswered_messages_count: z33.number().int()
3553
3617
  });
3554
3618
 
3555
- // src/_api/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts
3619
+ // src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
3556
3620
  import { z as z34 } from "zod";
3557
- var TotpVerifyUserSchema = z34.object({
3558
- id: z34.number().int(),
3559
- email: z34.email(),
3560
- first_name: z34.string().max(50).optional(),
3561
- last_name: z34.string().max(50).optional(),
3562
- full_name: z34.string(),
3563
- initials: z34.string(),
3564
- display_username: z34.string(),
3565
- company: z34.string().max(100).optional(),
3566
- phone: z34.string().max(20).optional(),
3567
- position: z34.string().max(100).optional(),
3568
- language: z34.string().max(10).optional(),
3569
- avatar: z34.string().nullable(),
3570
- is_staff: z34.boolean(),
3571
- is_superuser: z34.boolean(),
3572
- date_joined: z34.string().datetime({ offset: true }),
3573
- last_login: z34.string().datetime({ offset: true }).nullable(),
3574
- unanswered_messages_count: z34.number().int()
3621
+ var VerifyBackupRequestSchema = z34.object({
3622
+ session_id: z34.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3623
+ backup_code: z34.string().min(8).max(8)
3575
3624
  });
3576
3625
 
3577
- // src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts
3626
+ // src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
3578
3627
  import { z as z35 } from "zod";
3579
- var VerifyBackupRequestSchema = z35.object({
3628
+ var VerifyRequestSchema = z35.object({
3580
3629
  session_id: z35.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3581
- backup_code: z35.string().min(8).max(8)
3582
- });
3583
-
3584
- // src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts
3585
- import { z as z36 } from "zod";
3586
- var VerifyRequestSchema = z36.object({
3587
- session_id: z36.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
3588
- code: z36.string().min(6).max(6)
3630
+ code: z35.string().min(6).max(6)
3589
3631
  });
3590
3632
 
3591
3633
  // src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts
3592
- import { z as z37 } from "zod";
3593
- var VerifyResponseSchema = z37.object({
3594
- message: z37.string(),
3595
- access_token: z37.string(),
3596
- refresh_token: z37.string(),
3634
+ import { z as z36 } from "zod";
3635
+ var VerifyResponseSchema = z36.object({
3636
+ message: z36.string(),
3637
+ access_token: z36.string(),
3638
+ refresh_token: z36.string(),
3597
3639
  user: TotpVerifyUserSchema,
3598
- remaining_backup_codes: z37.number().int().optional(),
3599
- warning: z37.string().optional()
3640
+ remaining_backup_codes: z36.number().int().optional(),
3641
+ warning: z36.string().optional()
3600
3642
  });
3601
3643
 
3602
3644
  // src/_api/generated/cfg_totp/_utils/fetchers/index.ts
@@ -3610,7 +3652,7 @@ __export(fetchers_exports3, {
3610
3652
  createTotpVerifyCreate: () => createTotpVerifyCreate,
3611
3653
  deleteTotpDevicesDestroy: () => deleteTotpDevicesDestroy,
3612
3654
  getTotpBackupCodesRetrieve: () => getTotpBackupCodesRetrieve,
3613
- getTotpDevicesList: () => getTotpDevicesList
3655
+ getTotpDevicesRetrieve: () => getTotpDevicesRetrieve
3614
3656
  });
3615
3657
 
3616
3658
  // src/_api/generated/cfg_totp/api-instance.ts
@@ -3737,14 +3779,14 @@ __name(createTotpBackupCodesRegenerateCreate, "createTotpBackupCodesRegenerateCr
3737
3779
 
3738
3780
  // src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts
3739
3781
  import { consola as consola7 } from "consola";
3740
- async function getTotpDevicesList(params, client) {
3782
+ async function getTotpDevicesRetrieve(client) {
3741
3783
  const api = client || getAPIInstance3();
3742
- const response = await api.totp_management.totpDevicesList(params?.ordering, params?.page, params?.page_size, params?.search);
3784
+ const response = await api.totp_management.totpDevicesRetrieve();
3743
3785
  try {
3744
- return PaginatedDeviceListResponseListSchema.parse(response);
3786
+ return DeviceListResponseSchema.parse(response);
3745
3787
  } catch (error) {
3746
3788
  consola7.error("\u274C Zod Validation Failed");
3747
- consola7.box(`getTotpDevicesList
3789
+ consola7.box(`getTotpDevicesRetrieve
3748
3790
  Path: /cfg/totp/devices/
3749
3791
  Method: GET`);
3750
3792
  if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
@@ -3761,7 +3803,7 @@ Method: GET`);
3761
3803
  try {
3762
3804
  const event = new CustomEvent("zod-validation-error", {
3763
3805
  detail: {
3764
- operation: "getTotpDevicesList",
3806
+ operation: "getTotpDevicesRetrieve",
3765
3807
  path: "/cfg/totp/devices/",
3766
3808
  method: "GET",
3767
3809
  error,
@@ -3779,7 +3821,7 @@ Method: GET`);
3779
3821
  throw error;
3780
3822
  }
3781
3823
  }
3782
- __name(getTotpDevicesList, "getTotpDevicesList");
3824
+ __name(getTotpDevicesRetrieve, "getTotpDevicesRetrieve");
3783
3825
  async function createTotpDisableCreate(data, client) {
3784
3826
  const api = client || getAPIInstance3();
3785
3827
  const response = await api.totp_management.totpDisableCreate(data);
@@ -4299,7 +4341,7 @@ __export(hooks_exports2, {
4299
4341
  useCreateTotpVerifyCreate: () => useCreateTotpVerifyCreate,
4300
4342
  useDeleteTotpDevicesDestroy: () => useDeleteTotpDevicesDestroy,
4301
4343
  useTotpBackupCodesRetrieve: () => useTotpBackupCodesRetrieve,
4302
- useTotpDevicesList: () => useTotpDevicesList
4344
+ useTotpDevicesRetrieve: () => useTotpDevicesRetrieve
4303
4345
  });
4304
4346
 
4305
4347
  // src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts
@@ -4325,13 +4367,13 @@ __name(useCreateTotpBackupCodesRegenerateCreate, "useCreateTotpBackupCodesRegene
4325
4367
  // src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts
4326
4368
  import useSWR5 from "swr";
4327
4369
  import { useSWRConfig as useSWRConfig6 } from "swr";
4328
- function useTotpDevicesList(params, client) {
4370
+ function useTotpDevicesRetrieve(client) {
4329
4371
  return useSWR5(
4330
- ["cfg-totp-devices", params],
4331
- () => getTotpDevicesList(params, client)
4372
+ "cfg-totp-device",
4373
+ () => getTotpDevicesRetrieve(client)
4332
4374
  );
4333
4375
  }
4334
- __name(useTotpDevicesList, "useTotpDevicesList");
4376
+ __name(useTotpDevicesRetrieve, "useTotpDevicesRetrieve");
4335
4377
  function useCreateTotpDisableCreate() {
4336
4378
  const { mutate } = useSWRConfig6();
4337
4379
  return async (data, client) => {