@djangocfg/api 2.1.322 → 2.1.331

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 (272) hide show
  1. package/dist/auth-server.cjs +1037 -1227
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +1037 -1217
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +2142 -3398
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +158 -209
  8. package/dist/auth.d.ts +158 -209
  9. package/dist/auth.mjs +2136 -3392
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +1018 -4423
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +151 -2918
  14. package/dist/clients.d.ts +151 -2918
  15. package/dist/clients.mjs +1018 -4417
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +2253 -2819
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +2408 -1872
  20. package/dist/index.d.ts +2408 -1872
  21. package/dist/index.mjs +2235 -2795
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -7
  24. package/src/_api/generated/_cfg_accounts/api.ts +120 -0
  25. package/src/_api/generated/_cfg_accounts/events.ts +198 -0
  26. package/src/_api/generated/_cfg_accounts/hooks/index.ts +18 -0
  27. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +25 -0
  28. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +24 -0
  29. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +24 -0
  30. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +24 -0
  31. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +25 -0
  32. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +24 -0
  33. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +24 -0
  34. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +24 -0
  35. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +24 -0
  36. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +24 -0
  37. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +24 -0
  38. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +25 -0
  39. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +24 -0
  40. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +24 -0
  41. package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +24 -0
  42. package/src/_api/generated/_cfg_accounts/index.ts +29 -0
  43. package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +12 -0
  44. package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +14 -0
  45. package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +16 -0
  46. package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts +12 -0
  47. package/src/_api/generated/_cfg_accounts/schemas/OAuthAuthorizeResponse.ts +12 -0
  48. package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +13 -0
  49. package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +19 -0
  50. package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +12 -0
  51. package/src/_api/generated/_cfg_accounts/schemas/OAuthError.ts +12 -0
  52. package/src/_api/generated/_cfg_accounts/schemas/OAuthProvidersResponse.ts +11 -0
  53. package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +18 -0
  54. package/src/_api/generated/_cfg_accounts/schemas/OTPErrorResponse.ts +13 -0
  55. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestRequest.ts +12 -0
  56. package/src/_api/generated/_cfg_accounts/schemas/OTPRequestResponse.ts +11 -0
  57. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +13 -0
  58. package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +17 -0
  59. package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +16 -0
  60. package/src/_api/generated/_cfg_accounts/schemas/ProviderEnum.ts +9 -0
  61. package/src/_api/generated/_cfg_accounts/schemas/TokenRefresh.ts +12 -0
  62. package/src/_api/generated/_cfg_accounts/schemas/TokenRefreshRequest.ts +11 -0
  63. package/src/_api/generated/{cfg_accounts/_utils/schemas/User.schema.ts → _cfg_accounts/schemas/User.ts} +19 -27
  64. package/src/_api/generated/_cfg_accounts/schemas/index.ts +24 -0
  65. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  66. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  67. package/src/_api/generated/_cfg_centrifugo/api.ts +120 -0
  68. package/src/_api/generated/_cfg_centrifugo/events.ts +198 -0
  69. package/src/_api/generated/_cfg_centrifugo/hooks/index.ts +4 -0
  70. package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +25 -0
  71. package/src/_api/generated/_cfg_centrifugo/index.ts +29 -0
  72. package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +14 -0
  73. package/src/_api/generated/_cfg_centrifugo/schemas/index.ts +4 -0
  74. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  75. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  76. package/src/_api/generated/_cfg_totp/api.ts +120 -0
  77. package/src/_api/generated/_cfg_totp/events.ts +198 -0
  78. package/src/_api/generated/_cfg_totp/hooks/index.ts +12 -0
  79. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +24 -0
  80. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +25 -0
  81. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +24 -0
  82. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +25 -0
  83. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +24 -0
  84. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +24 -0
  85. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +24 -0
  86. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +24 -0
  87. package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +24 -0
  88. package/src/_api/generated/_cfg_totp/index.ts +29 -0
  89. package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateRequest.ts +11 -0
  90. package/src/_api/generated/_cfg_totp/schemas/BackupCodesRegenerateResponse.ts +12 -0
  91. package/src/_api/generated/_cfg_totp/schemas/BackupCodesStatus.ts +13 -0
  92. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +12 -0
  93. package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +13 -0
  94. package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +18 -0
  95. package/src/_api/generated/_cfg_totp/schemas/DeviceListResponse.ts +13 -0
  96. package/src/_api/generated/_cfg_totp/schemas/DeviceListStatusEnum.ts +9 -0
  97. package/src/_api/generated/_cfg_totp/schemas/DisableRequest.ts +11 -0
  98. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  99. package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +15 -0
  100. package/src/_api/generated/{cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts → _cfg_totp/schemas/TotpVerifyUser.ts} +17 -25
  101. package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +12 -0
  102. package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +12 -0
  103. package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +17 -0
  104. package/src/_api/generated/_cfg_totp/schemas/index.ts +18 -0
  105. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  106. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  107. package/src/_api/generated/client/client.gen.ts +280 -0
  108. package/src/_api/generated/client/index.ts +25 -0
  109. package/src/_api/generated/client/types.gen.ts +217 -0
  110. package/src/_api/generated/client/utils.gen.ts +318 -0
  111. package/src/_api/generated/client.gen.ts +16 -0
  112. package/src/_api/generated/core/auth.gen.ts +41 -0
  113. package/src/_api/generated/core/bodySerializer.gen.ts +82 -0
  114. package/src/_api/generated/core/params.gen.ts +169 -0
  115. package/src/_api/generated/core/pathSerializer.gen.ts +171 -0
  116. package/src/_api/generated/core/queryKeySerializer.gen.ts +117 -0
  117. package/src/_api/generated/core/serverSentEvents.gen.ts +242 -0
  118. package/src/_api/generated/core/types.gen.ts +104 -0
  119. package/src/_api/generated/core/utils.gen.ts +140 -0
  120. package/src/_api/generated/helpers/errors.ts +70 -0
  121. package/src/_api/generated/helpers/index.ts +25 -0
  122. package/src/_api/generated/helpers/logger.ts +123 -0
  123. package/src/_api/generated/helpers/storage.ts +83 -0
  124. package/src/_api/generated/helpers/validation-events.ts +52 -0
  125. package/src/_api/generated/index.ts +28 -0
  126. package/src/_api/generated/sdk.gen.ts +1250 -0
  127. package/src/_api/generated/types.gen.ts +1294 -0
  128. package/src/_api/index.ts +5 -23
  129. package/src/auth/context/AccountsContext.tsx +58 -89
  130. package/src/auth/context/AuthContext.tsx +3 -3
  131. package/src/auth/context/index.ts +2 -2
  132. package/src/auth/hooks/useDeleteAccount.ts +3 -1
  133. package/src/auth/hooks/useGithubAuth.ts +13 -11
  134. package/src/auth/hooks/useTokenRefresh.ts +7 -4
  135. package/src/auth/hooks/useTwoFactor.ts +15 -8
  136. package/src/auth/hooks/useTwoFactorSetup.ts +9 -5
  137. package/src/auth/hooks/useTwoFactorStatus.ts +5 -3
  138. package/src/auth/middlewares/tokenRefresh.ts +7 -4
  139. package/src/clients.ts +14 -51
  140. package/src/index.ts +35 -60
  141. package/src/server.ts +25 -23
  142. package/src/_api/BaseClient.ts +0 -22
  143. package/src/_api/generated/cfg_accounts/CLAUDE.md +0 -86
  144. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts +0 -154
  145. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +0 -95
  146. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +0 -285
  147. package/src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +0 -440
  148. package/src/_api/generated/cfg_accounts/_utils/fetchers/index.ts +0 -33
  149. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts.ts +0 -64
  150. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +0 -44
  151. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +0 -114
  152. package/src/_api/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +0 -152
  153. package/src/_api/generated/cfg_accounts/_utils/hooks/index.ts +0 -33
  154. package/src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts +0 -20
  155. package/src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +0 -22
  156. package/src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts +0 -15
  157. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +0 -20
  158. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +0 -20
  159. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +0 -21
  160. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +0 -27
  161. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts +0 -20
  162. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts +0 -20
  163. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +0 -19
  164. package/src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +0 -46
  165. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts +0 -41
  166. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +0 -20
  167. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts +0 -19
  168. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +0 -21
  169. package/src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts +0 -45
  170. package/src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +0 -24
  171. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts +0 -16
  172. package/src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts +0 -15
  173. package/src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +0 -24
  174. package/src/_api/generated/cfg_accounts/_utils/schemas/index.ts +0 -41
  175. package/src/_api/generated/cfg_accounts/accounts/client.ts +0 -34
  176. package/src/_api/generated/cfg_accounts/accounts/index.ts +0 -4
  177. package/src/_api/generated/cfg_accounts/accounts/models.ts +0 -127
  178. package/src/_api/generated/cfg_accounts/accounts__auth/client.ts +0 -23
  179. package/src/_api/generated/cfg_accounts/accounts__auth/index.ts +0 -4
  180. package/src/_api/generated/cfg_accounts/accounts__auth/models.ts +0 -19
  181. package/src/_api/generated/cfg_accounts/accounts__oauth/client.ts +0 -67
  182. package/src/_api/generated/cfg_accounts/accounts__oauth/index.ts +0 -4
  183. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +0 -127
  184. package/src/_api/generated/cfg_accounts/accounts__user_profile/client.ts +0 -94
  185. package/src/_api/generated/cfg_accounts/accounts__user_profile/index.ts +0 -4
  186. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +0 -98
  187. package/src/_api/generated/cfg_accounts/api-instance.ts +0 -181
  188. package/src/_api/generated/cfg_accounts/client.ts +0 -339
  189. package/src/_api/generated/cfg_accounts/enums.ts +0 -10
  190. package/src/_api/generated/cfg_accounts/errors.ts +0 -123
  191. package/src/_api/generated/cfg_accounts/http.ts +0 -160
  192. package/src/_api/generated/cfg_accounts/index.ts +0 -338
  193. package/src/_api/generated/cfg_accounts/logger.ts +0 -261
  194. package/src/_api/generated/cfg_accounts/retry.ts +0 -177
  195. package/src/_api/generated/cfg_accounts/schema.json +0 -1576
  196. package/src/_api/generated/cfg_accounts/storage.ts +0 -163
  197. package/src/_api/generated/cfg_accounts/validation-events.ts +0 -135
  198. package/src/_api/generated/cfg_centrifugo/CLAUDE.md +0 -60
  199. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +0 -94
  200. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/index.ts +0 -30
  201. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +0 -39
  202. package/src/_api/generated/cfg_centrifugo/_utils/hooks/index.ts +0 -30
  203. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts +0 -22
  204. package/src/_api/generated/cfg_centrifugo/_utils/schemas/index.ts +0 -21
  205. package/src/_api/generated/cfg_centrifugo/api-instance.ts +0 -181
  206. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +0 -27
  207. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +0 -4
  208. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +0 -18
  209. package/src/_api/generated/cfg_centrifugo/client.ts +0 -330
  210. package/src/_api/generated/cfg_centrifugo/errors.ts +0 -123
  211. package/src/_api/generated/cfg_centrifugo/http.ts +0 -160
  212. package/src/_api/generated/cfg_centrifugo/index.ts +0 -316
  213. package/src/_api/generated/cfg_centrifugo/logger.ts +0 -261
  214. package/src/_api/generated/cfg_centrifugo/retry.ts +0 -177
  215. package/src/_api/generated/cfg_centrifugo/schema.json +0 -118
  216. package/src/_api/generated/cfg_centrifugo/storage.ts +0 -163
  217. package/src/_api/generated/cfg_centrifugo/validation-events.ts +0 -135
  218. package/src/_api/generated/cfg_totp/CLAUDE.md +0 -83
  219. package/src/_api/generated/cfg_totp/_utils/fetchers/index.ts +0 -34
  220. package/src/_api/generated/cfg_totp/_utils/fetchers/totp.ts +0 -50
  221. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +0 -153
  222. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +0 -109
  223. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +0 -154
  224. package/src/_api/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +0 -153
  225. package/src/_api/generated/cfg_totp/_utils/hooks/index.ts +0 -34
  226. package/src/_api/generated/cfg_totp/_utils/hooks/totp.ts +0 -43
  227. package/src/_api/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +0 -60
  228. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +0 -59
  229. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +0 -64
  230. package/src/_api/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +0 -63
  231. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +0 -19
  232. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +0 -20
  233. package/src/_api/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +0 -21
  234. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +0 -20
  235. package/src/_api/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +0 -21
  236. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +0 -26
  237. package/src/_api/generated/cfg_totp/_utils/schemas/DeviceListResponse.schema.ts +0 -21
  238. package/src/_api/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +0 -19
  239. package/src/_api/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +0 -19
  240. package/src/_api/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +0 -23
  241. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +0 -20
  242. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +0 -20
  243. package/src/_api/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +0 -25
  244. package/src/_api/generated/cfg_totp/_utils/schemas/index.ts +0 -34
  245. package/src/_api/generated/cfg_totp/api-instance.ts +0 -181
  246. package/src/_api/generated/cfg_totp/client.ts +0 -342
  247. package/src/_api/generated/cfg_totp/enums.ts +0 -13
  248. package/src/_api/generated/cfg_totp/errors.ts +0 -123
  249. package/src/_api/generated/cfg_totp/http.ts +0 -160
  250. package/src/_api/generated/cfg_totp/index.ts +0 -345
  251. package/src/_api/generated/cfg_totp/logger.ts +0 -261
  252. package/src/_api/generated/cfg_totp/retry.ts +0 -177
  253. package/src/_api/generated/cfg_totp/schema.json +0 -910
  254. package/src/_api/generated/cfg_totp/storage.ts +0 -163
  255. package/src/_api/generated/cfg_totp/totp/client.ts +0 -24
  256. package/src/_api/generated/cfg_totp/totp/index.ts +0 -4
  257. package/src/_api/generated/cfg_totp/totp/models.ts +0 -4
  258. package/src/_api/generated/cfg_totp/totp__backup_codes/client.ts +0 -32
  259. package/src/_api/generated/cfg_totp/totp__backup_codes/index.ts +0 -4
  260. package/src/_api/generated/cfg_totp/totp__backup_codes/models.ts +0 -38
  261. package/src/_api/generated/cfg_totp/totp__totp_management/client.ts +0 -31
  262. package/src/_api/generated/cfg_totp/totp__totp_management/index.ts +0 -4
  263. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +0 -46
  264. package/src/_api/generated/cfg_totp/totp__totp_setup/client.ts +0 -33
  265. package/src/_api/generated/cfg_totp/totp__totp_setup/index.ts +0 -4
  266. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +0 -55
  267. package/src/_api/generated/cfg_totp/totp__totp_verification/client.ts +0 -33
  268. package/src/_api/generated/cfg_totp/totp__totp_verification/index.ts +0 -4
  269. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +0 -74
  270. package/src/_api/generated/cfg_totp/validation-events.ts +0 -135
  271. package/src/hooks/accounts.ts +0 -8
  272. package/src/hooks/index.ts +0 -10
@@ -1,8 +1,6 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
5
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
6
  var __export = (target, all) => {
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/auth/server.ts
@@ -44,13 +34,13 @@ module.exports = __toCommonJS(server_exports);
44
34
  var import_server = require("next/server");
45
35
  function proxyMiddleware(request) {
46
36
  const { pathname, search } = request.nextUrl;
47
- const apiUrl2 = process.env.NEXT_PUBLIC_API_URL;
37
+ const apiUrl = process.env.NEXT_PUBLIC_API_URL;
48
38
  if (pathname.startsWith("/media/")) {
49
- const targetUrl = `${apiUrl2}${pathname}${search}`;
39
+ const targetUrl = `${apiUrl}${pathname}${search}`;
50
40
  return import_server.NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });
51
41
  }
52
42
  if (pathname.startsWith("/api/")) {
53
- const targetUrl = `${apiUrl2}${pathname}${search}`;
43
+ const targetUrl = `${apiUrl}${pathname}${search}`;
54
44
  return import_server.NextResponse.rewrite(targetUrl, { request: { headers: request.headers } });
55
45
  }
56
46
  return import_server.NextResponse.next();
@@ -60,357 +50,845 @@ var proxyMiddlewareConfig = {
60
50
  matcher: ["/media/:path*", "/api/:path*"]
61
51
  };
62
52
 
63
- // src/_api/generated/cfg_accounts/accounts__auth/client.ts
64
- var Auth = class {
65
- static {
66
- __name(this, "Auth");
53
+ // src/_api/generated/core/bodySerializer.gen.ts
54
+ var jsonBodySerializer = {
55
+ bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
56
+ };
57
+
58
+ // src/_api/generated/core/params.gen.ts
59
+ var extraPrefixesMap = {
60
+ $body_: "body",
61
+ $headers_: "headers",
62
+ $path_: "path",
63
+ $query_: "query"
64
+ };
65
+ var extraPrefixes = Object.entries(extraPrefixesMap);
66
+
67
+ // src/_api/generated/core/serverSentEvents.gen.ts
68
+ function createSseClient({
69
+ onRequest,
70
+ onSseError,
71
+ onSseEvent,
72
+ responseTransformer,
73
+ responseValidator,
74
+ sseDefaultRetryDelay,
75
+ sseMaxRetryAttempts,
76
+ sseMaxRetryDelay,
77
+ sseSleepFn,
78
+ url,
79
+ ...options
80
+ }) {
81
+ let lastEventId;
82
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
83
+ const createStream = /* @__PURE__ */ __name(async function* () {
84
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
85
+ let attempt = 0;
86
+ const signal = options.signal ?? new AbortController().signal;
87
+ while (true) {
88
+ if (signal.aborted) break;
89
+ attempt++;
90
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
91
+ if (lastEventId !== void 0) {
92
+ headers.set("Last-Event-ID", lastEventId);
93
+ }
94
+ try {
95
+ const requestInit = {
96
+ redirect: "follow",
97
+ ...options,
98
+ body: options.serializedBody,
99
+ headers,
100
+ signal
101
+ };
102
+ let request = new Request(url, requestInit);
103
+ if (onRequest) {
104
+ request = await onRequest(url, requestInit);
105
+ }
106
+ const _fetch = options.fetch ?? globalThis.fetch;
107
+ const response = await _fetch(request);
108
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
109
+ if (!response.body) throw new Error("No body in SSE response");
110
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
111
+ let buffer = "";
112
+ const abortHandler = /* @__PURE__ */ __name(() => {
113
+ try {
114
+ reader.cancel();
115
+ } catch {
116
+ }
117
+ }, "abortHandler");
118
+ signal.addEventListener("abort", abortHandler);
119
+ try {
120
+ while (true) {
121
+ const { done, value } = await reader.read();
122
+ if (done) break;
123
+ buffer += value;
124
+ buffer = buffer.replace(/\r\n?/g, "\n");
125
+ const chunks = buffer.split("\n\n");
126
+ buffer = chunks.pop() ?? "";
127
+ for (const chunk of chunks) {
128
+ const lines = chunk.split("\n");
129
+ const dataLines = [];
130
+ let eventName;
131
+ for (const line of lines) {
132
+ if (line.startsWith("data:")) {
133
+ dataLines.push(line.replace(/^data:\s*/, ""));
134
+ } else if (line.startsWith("event:")) {
135
+ eventName = line.replace(/^event:\s*/, "");
136
+ } else if (line.startsWith("id:")) {
137
+ lastEventId = line.replace(/^id:\s*/, "");
138
+ } else if (line.startsWith("retry:")) {
139
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
140
+ if (!Number.isNaN(parsed)) {
141
+ retryDelay = parsed;
142
+ }
143
+ }
144
+ }
145
+ let data;
146
+ let parsedJson = false;
147
+ if (dataLines.length) {
148
+ const rawData = dataLines.join("\n");
149
+ try {
150
+ data = JSON.parse(rawData);
151
+ parsedJson = true;
152
+ } catch {
153
+ data = rawData;
154
+ }
155
+ }
156
+ if (parsedJson) {
157
+ if (responseValidator) {
158
+ await responseValidator(data);
159
+ }
160
+ if (responseTransformer) {
161
+ data = await responseTransformer(data);
162
+ }
163
+ }
164
+ onSseEvent?.({
165
+ data,
166
+ event: eventName,
167
+ id: lastEventId,
168
+ retry: retryDelay
169
+ });
170
+ if (dataLines.length) {
171
+ yield data;
172
+ }
173
+ }
174
+ }
175
+ } finally {
176
+ signal.removeEventListener("abort", abortHandler);
177
+ reader.releaseLock();
178
+ }
179
+ break;
180
+ } catch (error) {
181
+ onSseError?.(error);
182
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
183
+ break;
184
+ }
185
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
186
+ await sleep(backoff);
187
+ }
188
+ }
189
+ }, "createStream");
190
+ const stream = createStream();
191
+ return { stream };
192
+ }
193
+ __name(createSseClient, "createSseClient");
194
+
195
+ // src/_api/generated/core/pathSerializer.gen.ts
196
+ var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
197
+ switch (style) {
198
+ case "label":
199
+ return ".";
200
+ case "matrix":
201
+ return ";";
202
+ case "simple":
203
+ return ",";
204
+ default:
205
+ return "&";
206
+ }
207
+ }, "separatorArrayExplode");
208
+ var separatorArrayNoExplode = /* @__PURE__ */ __name((style) => {
209
+ switch (style) {
210
+ case "form":
211
+ return ",";
212
+ case "pipeDelimited":
213
+ return "|";
214
+ case "spaceDelimited":
215
+ return "%20";
216
+ default:
217
+ return ",";
218
+ }
219
+ }, "separatorArrayNoExplode");
220
+ var separatorObjectExplode = /* @__PURE__ */ __name((style) => {
221
+ switch (style) {
222
+ case "label":
223
+ return ".";
224
+ case "matrix":
225
+ return ";";
226
+ case "simple":
227
+ return ",";
228
+ default:
229
+ return "&";
230
+ }
231
+ }, "separatorObjectExplode");
232
+ var serializeArrayParam = /* @__PURE__ */ __name(({
233
+ allowReserved,
234
+ explode,
235
+ name,
236
+ style,
237
+ value
238
+ }) => {
239
+ if (!explode) {
240
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
241
+ switch (style) {
242
+ case "label":
243
+ return `.${joinedValues2}`;
244
+ case "matrix":
245
+ return `;${name}=${joinedValues2}`;
246
+ case "simple":
247
+ return joinedValues2;
248
+ default:
249
+ return `${name}=${joinedValues2}`;
250
+ }
67
251
  }
68
- client;
69
- constructor(client) {
70
- this.client = client;
252
+ const separator = separatorArrayExplode(style);
253
+ const joinedValues = value.map((v) => {
254
+ if (style === "label" || style === "simple") {
255
+ return allowReserved ? v : encodeURIComponent(v);
256
+ }
257
+ return serializePrimitiveParam({
258
+ allowReserved,
259
+ name,
260
+ value: v
261
+ });
262
+ }).join(separator);
263
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
264
+ }, "serializeArrayParam");
265
+ var serializePrimitiveParam = /* @__PURE__ */ __name(({
266
+ allowReserved,
267
+ name,
268
+ value
269
+ }) => {
270
+ if (value === void 0 || value === null) {
271
+ return "";
272
+ }
273
+ if (typeof value === "object") {
274
+ throw new Error(
275
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
276
+ );
71
277
  }
72
- /**
73
- * Refresh JWT token.
74
- */
75
- async accountsTokenRefreshCreate(data) {
76
- const response = await this.client.request("POST", "/cfg/accounts/token/refresh/", { body: data });
77
- return response;
278
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
279
+ }, "serializePrimitiveParam");
280
+ var serializeObjectParam = /* @__PURE__ */ __name(({
281
+ allowReserved,
282
+ explode,
283
+ name,
284
+ style,
285
+ value,
286
+ valueOnly
287
+ }) => {
288
+ if (value instanceof Date) {
289
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
290
+ }
291
+ if (style !== "deepObject" && !explode) {
292
+ let values = [];
293
+ Object.entries(value).forEach(([key, v]) => {
294
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
295
+ });
296
+ const joinedValues2 = values.join(",");
297
+ switch (style) {
298
+ case "form":
299
+ return `${name}=${joinedValues2}`;
300
+ case "label":
301
+ return `.${joinedValues2}`;
302
+ case "matrix":
303
+ return `;${name}=${joinedValues2}`;
304
+ default:
305
+ return joinedValues2;
306
+ }
78
307
  }
79
- };
308
+ const separator = separatorObjectExplode(style);
309
+ const joinedValues = Object.entries(value).map(
310
+ ([key, v]) => serializePrimitiveParam({
311
+ allowReserved,
312
+ name: style === "deepObject" ? `${name}[${key}]` : key,
313
+ value: v
314
+ })
315
+ ).join(separator);
316
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
317
+ }, "serializeObjectParam");
80
318
 
81
- // src/_api/generated/cfg_accounts/accounts__oauth/client.ts
82
- var Oauth = class {
83
- static {
84
- __name(this, "Oauth");
85
- }
86
- client;
87
- constructor(client) {
88
- this.client = client;
319
+ // src/_api/generated/core/utils.gen.ts
320
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
321
+ var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
322
+ let url = _url;
323
+ const matches = _url.match(PATH_PARAM_RE);
324
+ if (matches) {
325
+ for (const match of matches) {
326
+ let explode = false;
327
+ let name = match.substring(1, match.length - 1);
328
+ let style = "simple";
329
+ if (name.endsWith("*")) {
330
+ explode = true;
331
+ name = name.substring(0, name.length - 1);
332
+ }
333
+ if (name.startsWith(".")) {
334
+ name = name.substring(1);
335
+ style = "label";
336
+ } else if (name.startsWith(";")) {
337
+ name = name.substring(1);
338
+ style = "matrix";
339
+ }
340
+ const value = path[name];
341
+ if (value === void 0 || value === null) {
342
+ continue;
343
+ }
344
+ if (Array.isArray(value)) {
345
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
346
+ continue;
347
+ }
348
+ if (typeof value === "object") {
349
+ url = url.replace(
350
+ match,
351
+ serializeObjectParam({
352
+ explode,
353
+ name,
354
+ style,
355
+ value,
356
+ valueOnly: true
357
+ })
358
+ );
359
+ continue;
360
+ }
361
+ if (style === "matrix") {
362
+ url = url.replace(
363
+ match,
364
+ `;${serializePrimitiveParam({
365
+ name,
366
+ value
367
+ })}`
368
+ );
369
+ continue;
370
+ }
371
+ const replaceValue = encodeURIComponent(
372
+ style === "label" ? `.${value}` : value
373
+ );
374
+ url = url.replace(match, replaceValue);
375
+ }
89
376
  }
90
- /**
91
- * List OAuth connections
92
- *
93
- * Get all OAuth connections for the current user.
94
- */
95
- async accountsOauthConnectionsList() {
96
- const response = await this.client.request("GET", "/cfg/accounts/oauth/connections/");
97
- return response.results || response;
377
+ return url;
378
+ }, "defaultPathSerializer");
379
+ var getUrl = /* @__PURE__ */ __name(({
380
+ baseUrl: baseUrl2,
381
+ path,
382
+ query,
383
+ querySerializer,
384
+ url: _url
385
+ }) => {
386
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
387
+ let url = (baseUrl2 ?? "") + pathUrl;
388
+ if (path) {
389
+ url = defaultPathSerializer({ path, url });
390
+ }
391
+ let search = query ? querySerializer(query) : "";
392
+ if (search.startsWith("?")) {
393
+ search = search.substring(1);
394
+ }
395
+ if (search) {
396
+ url += `?${search}`;
397
+ }
398
+ return url;
399
+ }, "getUrl");
400
+ function getValidRequestBody(options) {
401
+ const hasBody = options.body !== void 0;
402
+ const isSerializedBody = hasBody && options.bodySerializer;
403
+ if (isSerializedBody) {
404
+ if ("serializedBody" in options) {
405
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
406
+ return hasSerializedBody ? options.serializedBody : null;
407
+ }
408
+ return options.body !== "" ? options.body : null;
98
409
  }
99
- /**
100
- * Disconnect OAuth provider
101
- *
102
- * Remove OAuth connection for the specified provider.
103
- */
104
- async accountsOauthDisconnectCreate(data) {
105
- const response = await this.client.request("POST", "/cfg/accounts/oauth/disconnect/", { body: data });
106
- return response;
410
+ if (hasBody) {
411
+ return options.body;
107
412
  }
108
- /**
109
- * Start GitHub OAuth
110
- *
111
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to
112
- * start authentication.
113
- */
114
- async accountsOauthGithubAuthorizeCreate(data) {
115
- const response = await this.client.request("POST", "/cfg/accounts/oauth/github/authorize/", { body: data });
116
- return response;
413
+ return void 0;
414
+ }
415
+ __name(getValidRequestBody, "getValidRequestBody");
416
+
417
+ // src/_api/generated/core/auth.gen.ts
418
+ var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
419
+ const token = typeof callback === "function" ? await callback(auth) : callback;
420
+ if (!token) {
421
+ return;
117
422
  }
118
- /**
119
- * Complete GitHub OAuth
120
- *
121
- * Exchange authorization code for JWT tokens. Call this after GitHub
122
- * redirects back with code.
123
- */
124
- async accountsOauthGithubCallbackCreate(data) {
125
- const response = await this.client.request("POST", "/cfg/accounts/oauth/github/callback/", { body: data });
126
- return response;
423
+ if (auth.scheme === "bearer") {
424
+ return `Bearer ${token}`;
127
425
  }
128
- /**
129
- * List OAuth providers
130
- *
131
- * Get list of available OAuth providers for authentication.
132
- */
133
- async accountsOauthProvidersRetrieve() {
134
- const response = await this.client.request("GET", "/cfg/accounts/oauth/providers/");
135
- return response;
426
+ if (auth.scheme === "basic") {
427
+ return `Basic ${btoa(token)}`;
136
428
  }
137
- };
429
+ return token;
430
+ }, "getAuthToken");
138
431
 
139
- // src/_api/generated/cfg_accounts/accounts__user_profile/client.ts
140
- var UserProfile = class {
141
- static {
142
- __name(this, "UserProfile");
143
- }
144
- client;
145
- constructor(client) {
146
- this.client = client;
432
+ // src/_api/generated/client/utils.gen.ts
433
+ var createQuerySerializer = /* @__PURE__ */ __name(({
434
+ parameters = {},
435
+ ...args
436
+ } = {}) => {
437
+ const querySerializer = /* @__PURE__ */ __name((queryParams) => {
438
+ const search = [];
439
+ if (queryParams && typeof queryParams === "object") {
440
+ for (const name in queryParams) {
441
+ const value = queryParams[name];
442
+ if (value === void 0 || value === null) {
443
+ continue;
444
+ }
445
+ const options = parameters[name] || args;
446
+ if (Array.isArray(value)) {
447
+ const serializedArray = serializeArrayParam({
448
+ allowReserved: options.allowReserved,
449
+ explode: true,
450
+ name,
451
+ style: "form",
452
+ value,
453
+ ...options.array
454
+ });
455
+ if (serializedArray) search.push(serializedArray);
456
+ } else if (typeof value === "object") {
457
+ const serializedObject = serializeObjectParam({
458
+ allowReserved: options.allowReserved,
459
+ explode: true,
460
+ name,
461
+ style: "deepObject",
462
+ value,
463
+ ...options.object
464
+ });
465
+ if (serializedObject) search.push(serializedObject);
466
+ } else {
467
+ const serializedPrimitive = serializePrimitiveParam({
468
+ allowReserved: options.allowReserved,
469
+ name,
470
+ value
471
+ });
472
+ if (serializedPrimitive) search.push(serializedPrimitive);
473
+ }
474
+ }
475
+ }
476
+ return search.join("&");
477
+ }, "querySerializer");
478
+ return querySerializer;
479
+ }, "createQuerySerializer");
480
+ var getParseAs = /* @__PURE__ */ __name((contentType) => {
481
+ if (!contentType) {
482
+ return "stream";
483
+ }
484
+ const cleanContent = contentType.split(";")[0]?.trim();
485
+ if (!cleanContent) {
486
+ return;
487
+ }
488
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
489
+ return "json";
490
+ }
491
+ if (cleanContent === "multipart/form-data") {
492
+ return "formData";
493
+ }
494
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
495
+ return "blob";
496
+ }
497
+ if (cleanContent.startsWith("text/")) {
498
+ return "text";
499
+ }
500
+ return;
501
+ }, "getParseAs");
502
+ var checkForExistence = /* @__PURE__ */ __name((options, name) => {
503
+ if (!name) {
504
+ return false;
147
505
  }
148
- /**
149
- * Get current user profile
150
- *
151
- * Retrieve the current authenticated user's profile information.
152
- */
153
- async accountsProfileRetrieve() {
154
- const response = await this.client.request("GET", "/cfg/accounts/profile/");
155
- return response;
506
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
507
+ return true;
156
508
  }
157
- /**
158
- * Upload user avatar
159
- *
160
- * Upload avatar image for the current authenticated user. Accepts
161
- * multipart/form-data with 'avatar' field.
162
- */
163
- async accountsProfileAvatarCreate(data) {
164
- const formData = new FormData();
165
- formData.append("avatar", data.avatar);
166
- const response = await this.client.request("POST", "/cfg/accounts/profile/avatar/", { formData });
167
- return response;
509
+ return false;
510
+ }, "checkForExistence");
511
+ var setAuthParams = /* @__PURE__ */ __name(async ({
512
+ security,
513
+ ...options
514
+ }) => {
515
+ for (const auth of security) {
516
+ if (checkForExistence(options, auth.name)) {
517
+ continue;
518
+ }
519
+ const token = await getAuthToken(auth, options.auth);
520
+ if (!token) {
521
+ continue;
522
+ }
523
+ const name = auth.name ?? "Authorization";
524
+ switch (auth.in) {
525
+ case "query":
526
+ if (!options.query) {
527
+ options.query = {};
528
+ }
529
+ options.query[name] = token;
530
+ break;
531
+ case "cookie":
532
+ options.headers.append("Cookie", `${name}=${token}`);
533
+ break;
534
+ case "header":
535
+ default:
536
+ options.headers.set(name, token);
537
+ break;
538
+ }
168
539
  }
169
- /**
170
- * Delete user account
171
- *
172
- * Permanently delete the current user's account. This operation: -
173
- * Deactivates the account (user cannot log in) - Anonymizes personal data
174
- * (GDPR compliance) - Frees up the email address for re-registration -
175
- * Preserves audit trail The account can be restored by an administrator if
176
- * needed.
177
- */
178
- async accountsProfileDeleteCreate() {
179
- const response = await this.client.request("POST", "/cfg/accounts/profile/delete/");
180
- return response;
540
+ }, "setAuthParams");
541
+ var buildUrl = /* @__PURE__ */ __name((options) => getUrl({
542
+ baseUrl: options.baseUrl,
543
+ path: options.path,
544
+ query: options.query,
545
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
546
+ url: options.url
547
+ }), "buildUrl");
548
+ var mergeConfigs = /* @__PURE__ */ __name((a, b) => {
549
+ const config = { ...a, ...b };
550
+ if (config.baseUrl?.endsWith("/")) {
551
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
552
+ }
553
+ config.headers = mergeHeaders(a.headers, b.headers);
554
+ return config;
555
+ }, "mergeConfigs");
556
+ var headersEntries = /* @__PURE__ */ __name((headers) => {
557
+ const entries = [];
558
+ headers.forEach((value, key) => {
559
+ entries.push([key, value]);
560
+ });
561
+ return entries;
562
+ }, "headersEntries");
563
+ var mergeHeaders = /* @__PURE__ */ __name((...headers) => {
564
+ const mergedHeaders = new Headers();
565
+ for (const header of headers) {
566
+ if (!header) {
567
+ continue;
568
+ }
569
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
570
+ for (const [key, value] of iterator) {
571
+ if (value === null) {
572
+ mergedHeaders.delete(key);
573
+ } else if (Array.isArray(value)) {
574
+ for (const v of value) {
575
+ mergedHeaders.append(key, v);
576
+ }
577
+ } else if (value !== void 0) {
578
+ mergedHeaders.set(
579
+ key,
580
+ typeof value === "object" ? JSON.stringify(value) : value
581
+ );
582
+ }
583
+ }
181
584
  }
182
- /**
183
- * Partial update user profile
184
- *
185
- * Partially update the current authenticated user's profile information.
186
- * Supports avatar upload.
187
- */
188
- async accountsProfilePartialUpdate(data) {
189
- const response = await this.client.request("PUT", "/cfg/accounts/profile/partial/", { body: data });
190
- return response;
585
+ return mergedHeaders;
586
+ }, "mergeHeaders");
587
+ var Interceptors = class {
588
+ static {
589
+ __name(this, "Interceptors");
191
590
  }
192
- /**
193
- * Partial update user profile
194
- *
195
- * Partially update the current authenticated user's profile information.
196
- * Supports avatar upload.
197
- */
198
- async accountsProfilePartialPartialUpdate(data) {
199
- const response = await this.client.request("PATCH", "/cfg/accounts/profile/partial/", { body: data });
200
- return response;
591
+ fns = [];
592
+ clear() {
593
+ this.fns = [];
201
594
  }
202
- /**
203
- * Update user profile
204
- *
205
- * Update the current authenticated user's profile information.
206
- */
207
- async accountsProfileUpdateUpdate(data) {
208
- const response = await this.client.request("PUT", "/cfg/accounts/profile/update/", { body: data });
209
- return response;
595
+ eject(id) {
596
+ const index = this.getInterceptorIndex(id);
597
+ if (this.fns[index]) {
598
+ this.fns[index] = null;
599
+ }
210
600
  }
211
- /**
212
- * Update user profile
213
- *
214
- * Update the current authenticated user's profile information.
215
- */
216
- async accountsProfileUpdatePartialUpdate(data) {
217
- const response = await this.client.request("PATCH", "/cfg/accounts/profile/update/", { body: data });
218
- return response;
601
+ exists(id) {
602
+ const index = this.getInterceptorIndex(id);
603
+ return Boolean(this.fns[index]);
219
604
  }
220
- };
221
-
222
- // src/_api/generated/cfg_accounts/accounts/client.ts
223
- var Accounts = class {
224
- static {
225
- __name(this, "Accounts");
605
+ getInterceptorIndex(id) {
606
+ if (typeof id === "number") {
607
+ return this.fns[id] ? id : -1;
608
+ }
609
+ return this.fns.indexOf(id);
226
610
  }
227
- client;
228
- constructor(client) {
229
- this.client = client;
611
+ update(id, fn) {
612
+ const index = this.getInterceptorIndex(id);
613
+ if (this.fns[index]) {
614
+ this.fns[index] = fn;
615
+ return id;
616
+ }
617
+ return false;
230
618
  }
231
- /**
232
- * Request OTP code to email.
233
- */
234
- async otpRequestCreate(data) {
235
- const response = await this.client.request("POST", "/cfg/accounts/otp/request/", { body: data });
236
- return response;
619
+ use(fn) {
620
+ this.fns.push(fn);
621
+ return this.fns.length - 1;
237
622
  }
238
- /**
239
- * Verify OTP code and return JWT tokens or 2FA session. If user has 2FA
240
- * enabled: - Returns requires_2fa=True with session_id - Client must
241
- * complete 2FA verification at /cfg/totp/verify/ If user has no 2FA: -
242
- * Returns JWT tokens and user data directly
243
- */
244
- async otpVerifyCreate(data) {
245
- const response = await this.client.request("POST", "/cfg/accounts/otp/verify/", { body: data });
246
- return response;
623
+ };
624
+ var createInterceptors = /* @__PURE__ */ __name(() => ({
625
+ error: new Interceptors(),
626
+ request: new Interceptors(),
627
+ response: new Interceptors()
628
+ }), "createInterceptors");
629
+ var defaultQuerySerializer = createQuerySerializer({
630
+ allowReserved: false,
631
+ array: {
632
+ explode: true,
633
+ style: "form"
634
+ },
635
+ object: {
636
+ explode: true,
637
+ style: "deepObject"
247
638
  }
639
+ });
640
+ var defaultHeaders = {
641
+ "Content-Type": "application/json"
248
642
  };
643
+ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
644
+ ...jsonBodySerializer,
645
+ headers: defaultHeaders,
646
+ parseAs: "auto",
647
+ querySerializer: defaultQuerySerializer,
648
+ ...override
649
+ }), "createConfig");
249
650
 
250
- // src/_api/generated/cfg_accounts/http.ts
251
- var FetchAdapter = class {
252
- static {
253
- __name(this, "FetchAdapter");
254
- }
255
- async request(request) {
256
- const { method, url, headers, body, params, formData, binaryBody, responseType } = request;
257
- let finalUrl = url;
258
- if (params) {
259
- const searchParams = new URLSearchParams();
260
- Object.entries(params).forEach(([key, value]) => {
261
- if (value !== null && value !== void 0) {
262
- searchParams.append(key, String(value));
263
- }
651
+ // src/_api/generated/client/client.gen.ts
652
+ var createClient = /* @__PURE__ */ __name((config = {}) => {
653
+ let _config = mergeConfigs(createConfig(), config);
654
+ const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
655
+ const setConfig = /* @__PURE__ */ __name((config2) => {
656
+ _config = mergeConfigs(_config, config2);
657
+ return getConfig();
658
+ }, "setConfig");
659
+ const interceptors = createInterceptors();
660
+ const beforeRequest = /* @__PURE__ */ __name(async (options) => {
661
+ const opts = {
662
+ ..._config,
663
+ ...options,
664
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
665
+ headers: mergeHeaders(_config.headers, options.headers),
666
+ serializedBody: void 0
667
+ };
668
+ if (opts.security) {
669
+ await setAuthParams({
670
+ ...opts,
671
+ security: opts.security
264
672
  });
265
- const queryString = searchParams.toString();
266
- if (queryString) {
267
- finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
268
- }
269
673
  }
270
- const finalHeaders = { ...headers };
271
- let requestBody;
272
- if (formData) {
273
- requestBody = formData;
274
- } else if (binaryBody) {
275
- finalHeaders["Content-Type"] = "application/octet-stream";
276
- requestBody = binaryBody;
277
- } else if (body) {
278
- finalHeaders["Content-Type"] = "application/json";
279
- requestBody = JSON.stringify(body);
674
+ if (opts.requestValidator) {
675
+ await opts.requestValidator(opts);
280
676
  }
281
- const response = await fetch(finalUrl, {
282
- method,
283
- headers: finalHeaders,
284
- body: requestBody,
285
- credentials: "include"
286
- // Include Django session cookies
287
- });
288
- let data = null;
289
- const contentType = response.headers.get("content-type") ?? "";
290
- if (response.status !== 204) {
291
- if (responseType === "blob") {
292
- data = await response.blob();
293
- } else if (responseType === "text") {
294
- data = await response.text();
295
- } else if (responseType === "json") {
296
- data = await response.json();
297
- } else if (contentType.includes("application/json")) {
298
- data = await response.json();
299
- } else if (contentType.startsWith("text/")) {
300
- data = await response.text();
301
- } else {
302
- data = await response.blob();
677
+ if (opts.body !== void 0 && opts.bodySerializer) {
678
+ opts.serializedBody = opts.bodySerializer(opts.body);
679
+ }
680
+ if (opts.body === void 0 || opts.serializedBody === "") {
681
+ opts.headers.delete("Content-Type");
682
+ }
683
+ const resolvedOpts = opts;
684
+ const url = buildUrl(resolvedOpts);
685
+ return { opts: resolvedOpts, url };
686
+ }, "beforeRequest");
687
+ const request = /* @__PURE__ */ __name(async (options) => {
688
+ const throwOnError = options.throwOnError ?? _config.throwOnError;
689
+ const responseStyle = options.responseStyle ?? _config.responseStyle;
690
+ let request2;
691
+ let response;
692
+ try {
693
+ const { opts, url } = await beforeRequest(options);
694
+ const requestInit = {
695
+ redirect: "follow",
696
+ ...opts,
697
+ body: getValidRequestBody(opts)
698
+ };
699
+ request2 = new Request(url, requestInit);
700
+ for (const fn of interceptors.request.fns) {
701
+ if (fn) {
702
+ request2 = await fn(request2, opts);
703
+ }
704
+ }
705
+ const _fetch = opts.fetch;
706
+ response = await _fetch(request2);
707
+ for (const fn of interceptors.response.fns) {
708
+ if (fn) {
709
+ response = await fn(response, request2, opts);
710
+ }
711
+ }
712
+ const result = {
713
+ request: request2,
714
+ response
715
+ };
716
+ if (response.ok) {
717
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
718
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
719
+ let emptyData;
720
+ switch (parseAs) {
721
+ case "arrayBuffer":
722
+ case "blob":
723
+ case "text":
724
+ emptyData = await response[parseAs]();
725
+ break;
726
+ case "formData":
727
+ emptyData = new FormData();
728
+ break;
729
+ case "stream":
730
+ emptyData = response.body;
731
+ break;
732
+ case "json":
733
+ default:
734
+ emptyData = {};
735
+ break;
736
+ }
737
+ return opts.responseStyle === "data" ? emptyData : {
738
+ data: emptyData,
739
+ ...result
740
+ };
741
+ }
742
+ let data;
743
+ switch (parseAs) {
744
+ case "arrayBuffer":
745
+ case "blob":
746
+ case "formData":
747
+ case "text":
748
+ data = await response[parseAs]();
749
+ break;
750
+ case "json": {
751
+ const text = await response.text();
752
+ data = text ? JSON.parse(text) : {};
753
+ break;
754
+ }
755
+ case "stream":
756
+ return opts.responseStyle === "data" ? response.body : {
757
+ data: response.body,
758
+ ...result
759
+ };
760
+ }
761
+ if (parseAs === "json") {
762
+ if (opts.responseValidator) {
763
+ await opts.responseValidator(data);
764
+ }
765
+ if (opts.responseTransformer) {
766
+ data = await opts.responseTransformer(data);
767
+ }
768
+ }
769
+ return opts.responseStyle === "data" ? data : {
770
+ data,
771
+ ...result
772
+ };
773
+ }
774
+ const textError = await response.text();
775
+ let jsonError;
776
+ try {
777
+ jsonError = JSON.parse(textError);
778
+ } catch {
779
+ }
780
+ throw jsonError ?? textError;
781
+ } catch (error) {
782
+ let finalError = error;
783
+ for (const fn of interceptors.error.fns) {
784
+ if (fn) {
785
+ finalError = await fn(finalError, response, request2, options);
786
+ }
303
787
  }
788
+ finalError = finalError || {};
789
+ if (throwOnError) {
790
+ throw finalError;
791
+ }
792
+ return responseStyle === "data" ? void 0 : {
793
+ error: finalError,
794
+ request: request2,
795
+ response
796
+ };
304
797
  }
305
- const responseHeaders = {};
306
- response.headers.forEach((value, key) => {
307
- responseHeaders[key] = value;
798
+ }, "request");
799
+ const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
800
+ const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
801
+ const { opts, url } = await beforeRequest(options);
802
+ return createSseClient({
803
+ ...opts,
804
+ body: opts.body,
805
+ method,
806
+ onRequest: /* @__PURE__ */ __name(async (url2, init) => {
807
+ let request2 = new Request(url2, init);
808
+ for (const fn of interceptors.request.fns) {
809
+ if (fn) {
810
+ request2 = await fn(request2, opts);
811
+ }
812
+ }
813
+ return request2;
814
+ }, "onRequest"),
815
+ serializedBody: getValidRequestBody(opts),
816
+ url
308
817
  });
309
- return {
310
- data,
311
- status: response.status,
312
- statusText: response.statusText,
313
- headers: responseHeaders
314
- };
315
- }
316
- };
818
+ }, "makeSseFn");
819
+ const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl({ ..._config, ...options }), "_buildUrl");
820
+ return {
821
+ buildUrl: _buildUrl,
822
+ connect: makeMethodFn("CONNECT"),
823
+ delete: makeMethodFn("DELETE"),
824
+ get: makeMethodFn("GET"),
825
+ getConfig,
826
+ head: makeMethodFn("HEAD"),
827
+ interceptors,
828
+ options: makeMethodFn("OPTIONS"),
829
+ patch: makeMethodFn("PATCH"),
830
+ post: makeMethodFn("POST"),
831
+ put: makeMethodFn("PUT"),
832
+ request,
833
+ setConfig,
834
+ sse: {
835
+ connect: makeSseFn("CONNECT"),
836
+ delete: makeSseFn("DELETE"),
837
+ get: makeSseFn("GET"),
838
+ head: makeSseFn("HEAD"),
839
+ options: makeSseFn("OPTIONS"),
840
+ patch: makeSseFn("PATCH"),
841
+ post: makeSseFn("POST"),
842
+ put: makeSseFn("PUT"),
843
+ trace: makeSseFn("TRACE")
844
+ },
845
+ trace: makeMethodFn("TRACE")
846
+ };
847
+ }, "createClient");
317
848
 
318
- // src/_api/generated/cfg_accounts/errors.ts
319
- var APIError = class extends Error {
320
- constructor(statusCode, statusText, response, url, message) {
321
- super(message || `HTTP ${statusCode}: ${statusText}`);
322
- this.statusCode = statusCode;
323
- this.statusText = statusText;
324
- this.response = response;
325
- this.url = url;
326
- this.name = "APIError";
327
- }
849
+ // src/_api/generated/client.gen.ts
850
+ var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
851
+
852
+ // src/_api/generated/helpers/storage.ts
853
+ var LocalStorageAdapter = class {
328
854
  static {
329
- __name(this, "APIError");
855
+ __name(this, "LocalStorageAdapter");
330
856
  }
331
- /**
332
- * Get error details from response.
333
- * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
334
- */
335
- get details() {
336
- if (typeof this.response === "object" && this.response !== null) {
337
- return this.response;
857
+ getItem(key) {
858
+ if (typeof window === "undefined") return null;
859
+ try {
860
+ return window.localStorage.getItem(key);
861
+ } catch {
862
+ return null;
338
863
  }
339
- return null;
340
864
  }
341
- /**
342
- * Get field-specific validation errors from DRF.
343
- * Returns: { "field_name": ["error1", "error2"], ... }
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)) {
351
- fieldErrors[key] = value;
352
- }
865
+ setItem(key, value) {
866
+ if (typeof window === "undefined") return;
867
+ try {
868
+ window.localStorage.setItem(key, value);
869
+ } catch {
353
870
  }
354
- return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
355
871
  }
356
- /**
357
- * Get single error message from DRF.
358
- * Checks for "detail", "message", or first field error.
359
- */
360
- get errorMessage() {
361
- const details = this.details;
362
- if (!details) return this.message;
363
- if (details.detail) {
364
- return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
365
- }
366
- if (details.error) {
367
- return String(details.error);
368
- }
369
- if (details.message) {
370
- return String(details.message);
371
- }
372
- const fieldErrors = this.fieldErrors;
373
- if (fieldErrors) {
374
- const firstField = Object.keys(fieldErrors)[0];
375
- if (firstField) {
376
- return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
377
- }
872
+ removeItem(key) {
873
+ if (typeof window === "undefined") return;
874
+ try {
875
+ window.localStorage.removeItem(key);
876
+ } catch {
378
877
  }
379
- return this.message;
380
- }
381
- // Helper methods for common HTTP status codes
382
- get isValidationError() {
383
- return this.statusCode === 400;
384
- }
385
- get isAuthError() {
386
- return this.statusCode === 401;
387
- }
388
- get isPermissionError() {
389
- return this.statusCode === 403;
390
- }
391
- get isNotFoundError() {
392
- return this.statusCode === 404;
393
878
  }
394
- get isServerError() {
395
- return this.statusCode >= 500 && this.statusCode < 600;
396
- }
397
- };
398
- var NetworkError = class extends Error {
399
- constructor(message, url, originalError) {
400
- super(message);
401
- this.url = url;
402
- this.originalError = originalError;
403
- this.name = "NetworkError";
404
- }
405
- static {
406
- __name(this, "NetworkError");
879
+ clear() {
880
+ if (typeof window === "undefined") return;
881
+ try {
882
+ window.localStorage.clear();
883
+ } catch {
884
+ }
407
885
  }
408
886
  };
409
887
 
410
- // src/_api/generated/cfg_accounts/logger.ts
888
+ // src/_api/generated/helpers/logger.ts
411
889
  var import_consola = require("consola");
412
890
  var DEFAULT_CONFIG = {
413
- enabled: process.env.NODE_ENV !== "production",
891
+ enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
414
892
  logRequests: true,
415
893
  logResponses: true,
416
894
  logErrors: true,
@@ -436,688 +914,167 @@ var APILogger = class {
436
914
  level: this.config.enabled ? 4 : 0
437
915
  });
438
916
  }
439
- /**
440
- * Enable logging
441
- */
442
917
  enable() {
443
918
  this.config.enabled = true;
444
919
  }
445
- /**
446
- * Disable logging
447
- */
448
920
  disable() {
449
921
  this.config.enabled = false;
450
922
  }
451
- /**
452
- * Update configuration
453
- */
454
923
  setConfig(config) {
455
924
  this.config = { ...this.config, ...config };
456
925
  }
457
- /**
458
- * Filter sensitive headers
459
- */
460
926
  filterHeaders(headers) {
461
927
  if (!headers) return {};
462
928
  const filtered = {};
463
929
  Object.keys(headers).forEach((key) => {
464
- const lowerKey = key.toLowerCase();
465
- if (SENSITIVE_HEADERS.includes(lowerKey)) {
466
- filtered[key] = "***";
467
- } else {
468
- filtered[key] = headers[key] || "";
469
- }
930
+ filtered[key] = SENSITIVE_HEADERS.includes(key.toLowerCase()) ? "***" : headers[key] || "";
470
931
  });
471
932
  return filtered;
472
933
  }
473
- /**
474
- * Log request
475
- */
476
934
  logRequest(request) {
477
935
  if (!this.config.enabled || !this.config.logRequests) return;
478
936
  const { method, url, headers, body } = request;
479
937
  this.consola.start(`${method} ${url}`);
480
- if (this.config.logHeaders && headers) {
481
- this.consola.debug("Headers:", this.filterHeaders(headers));
482
- }
483
- if (this.config.logBodies && body) {
484
- this.consola.debug("Body:", body);
485
- }
938
+ if (this.config.logHeaders && headers) this.consola.debug("Headers:", this.filterHeaders(headers));
939
+ if (this.config.logBodies && body) this.consola.debug("Body:", body);
486
940
  }
487
- /**
488
- * Log response
489
- */
490
941
  logResponse(request, response) {
491
942
  if (!this.config.enabled || !this.config.logResponses) return;
492
943
  const { method, url } = request;
493
944
  const { status, statusText, data, duration } = response;
494
- const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
495
- this.consola.success(
496
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
497
- );
498
- if (this.config.logBodies && data) {
499
- this.consola.debug("Response:", data);
500
- }
945
+ this.consola.success(`${method} ${url} ${status} ${statusText} (${duration}ms)`);
946
+ if (this.config.logBodies && data) this.consola.debug("Response:", data);
501
947
  }
502
- /**
503
- * Log error
504
- */
505
948
  logError(request, error) {
506
949
  if (!this.config.enabled || !this.config.logErrors) return;
507
950
  const { method, url } = request;
508
951
  const { message, statusCode, fieldErrors, duration } = error;
509
- this.consola.error(
510
- `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
511
- );
952
+ this.consola.error(`${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`);
512
953
  this.consola.error("Message:", message);
513
954
  if (fieldErrors && Object.keys(fieldErrors).length > 0) {
514
955
  this.consola.error("Field Errors:");
515
956
  Object.entries(fieldErrors).forEach(([field, errors]) => {
516
- errors.forEach((err) => {
517
- this.consola.error(` \u2022 ${field}: ${err}`);
518
- });
957
+ errors.forEach((err) => this.consola.error(` \u2022 ${field}: ${err}`));
519
958
  });
520
959
  }
521
960
  }
522
- /**
523
- * Log general info
524
- */
525
961
  info(message, ...args) {
526
- if (!this.config.enabled) return;
527
- this.consola.info(message, ...args);
962
+ if (this.config.enabled) this.consola.info(message, ...args);
528
963
  }
529
- /**
530
- * Log warning
531
- */
532
964
  warn(message, ...args) {
533
- if (!this.config.enabled) return;
534
- this.consola.warn(message, ...args);
965
+ if (this.config.enabled) this.consola.warn(message, ...args);
535
966
  }
536
- /**
537
- * Log error
538
- */
539
967
  error(message, ...args) {
540
- if (!this.config.enabled) return;
541
- this.consola.error(message, ...args);
968
+ if (this.config.enabled) this.consola.error(message, ...args);
542
969
  }
543
- /**
544
- * Log debug
545
- */
546
970
  debug(message, ...args) {
547
- if (!this.config.enabled) return;
548
- this.consola.debug(message, ...args);
971
+ if (this.config.enabled) this.consola.debug(message, ...args);
549
972
  }
550
- /**
551
- * Log success
552
- */
553
973
  success(message, ...args) {
554
- if (!this.config.enabled) return;
555
- this.consola.success(message, ...args);
974
+ if (this.config.enabled) this.consola.success(message, ...args);
556
975
  }
557
- /**
558
- * Create a sub-logger with prefix
559
- */
560
976
  withTag(tag) {
561
977
  return this.consola.withTag(tag);
562
978
  }
563
979
  };
564
980
  var defaultLogger = new APILogger();
565
981
 
566
- // src/_api/generated/cfg_accounts/retry.ts
567
- var import_p_retry = __toESM(require("p-retry"), 1);
568
- var DEFAULT_RETRY_CONFIG = {
569
- retries: 3,
570
- factor: 2,
571
- minTimeout: 1e3,
572
- maxTimeout: 6e4,
573
- randomize: true,
574
- onFailedAttempt: /* @__PURE__ */ __name(() => {
575
- }, "onFailedAttempt")
576
- };
577
- function shouldRetry(error) {
578
- if (error instanceof NetworkError) {
579
- return true;
580
- }
581
- if (error instanceof APIError) {
582
- const status = error.statusCode;
583
- if (status >= 500 && status < 600) {
584
- return true;
982
+ // src/_api/generated/_cfg_accounts/api.ts
983
+ var ACCESS_KEY = "cfg.access_token";
984
+ var REFRESH_KEY = "cfg.refresh_token";
985
+ function detectLocale() {
986
+ try {
987
+ if (typeof document !== "undefined") {
988
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
989
+ if (m) return decodeURIComponent(m[1]);
585
990
  }
586
- if (status === 429) {
587
- return true;
991
+ if (typeof navigator !== "undefined" && navigator.language) {
992
+ return navigator.language;
588
993
  }
589
- return false;
994
+ } catch {
590
995
  }
591
- return true;
592
- }
593
- __name(shouldRetry, "shouldRetry");
594
- async function withRetry(fn, config) {
595
- const finalConfig = { ...DEFAULT_RETRY_CONFIG, ...config };
596
- return (0, import_p_retry.default)(
597
- async () => {
598
- try {
599
- return await fn();
600
- } catch (error) {
601
- if (!shouldRetry(error)) {
602
- throw new import_p_retry.AbortError(error);
603
- }
604
- throw error;
605
- }
606
- },
607
- {
608
- retries: finalConfig.retries,
609
- factor: finalConfig.factor,
610
- minTimeout: finalConfig.minTimeout,
611
- maxTimeout: finalConfig.maxTimeout,
612
- randomize: finalConfig.randomize,
613
- onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
614
- const pRetryError = error;
615
- finalConfig.onFailedAttempt({
616
- error: pRetryError,
617
- attemptNumber: pRetryError.attemptNumber,
618
- retriesLeft: pRetryError.retriesLeft
619
- });
620
- } : void 0
621
- }
622
- );
996
+ return null;
623
997
  }
624
- __name(withRetry, "withRetry");
625
-
626
- // src/_api/generated/cfg_accounts/client.ts
627
- var APIClient = class {
998
+ __name(detectLocale, "detectLocale");
999
+ var API = class {
628
1000
  static {
629
- __name(this, "APIClient");
1001
+ __name(this, "API");
630
1002
  }
631
1003
  baseUrl;
632
- httpClient;
633
- logger = null;
634
- retryConfig = null;
635
- tokenGetter = null;
636
- // Sub-clients
637
- auth;
638
- oauth;
639
- user_profile;
640
- accounts;
641
- constructor(baseUrl, options) {
642
- this.baseUrl = baseUrl.replace(/\/$/, "");
643
- this.httpClient = options?.httpClient || new FetchAdapter();
644
- this.tokenGetter = options?.tokenGetter || null;
645
- if (options?.loggerConfig !== void 0) {
646
- this.logger = new APILogger(options.loggerConfig);
647
- }
648
- if (options?.retryConfig !== void 0) {
649
- this.retryConfig = options.retryConfig;
650
- }
651
- this.auth = new Auth(this);
652
- this.oauth = new Oauth(this);
653
- this.user_profile = new UserProfile(this);
654
- this.accounts = new Accounts(this);
1004
+ storage;
1005
+ locale;
1006
+ apiKey;
1007
+ logger;
1008
+ constructor(baseUrl2, opts = {}) {
1009
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1010
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1011
+ this.logger = new APILogger(opts.logger);
1012
+ this.locale = opts.locale ?? null;
1013
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1014
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1015
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1016
+ client.interceptors.request.use((request) => {
1017
+ const access = this.getToken();
1018
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1019
+ const locale = this.locale ?? detectLocale();
1020
+ if (locale) request.headers.set("Accept-Language", locale);
1021
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1022
+ return request;
1023
+ });
655
1024
  }
656
- /**
657
- * Get CSRF token from cookies (for SessionAuthentication).
658
- *
659
- * Returns null if cookie doesn't exist (JWT-only auth).
660
- */
661
- getCsrfToken() {
662
- const name = "csrftoken";
663
- const value = `; ${document.cookie}`;
664
- const parts = value.split(`; ${name}=`);
665
- if (parts.length === 2) {
666
- return parts.pop()?.split(";").shift() || null;
667
- }
668
- return null;
1025
+ // ── Base URL ────────────────────────────────────────────────────────────
1026
+ getBaseUrl() {
1027
+ return this.baseUrl;
669
1028
  }
670
- /**
671
- * Get the base URL for building streaming/download URLs.
672
- */
673
- getBaseUrl() {
674
- return this.baseUrl;
1029
+ setBaseUrl(url) {
1030
+ this.baseUrl = url.replace(/\/$/, "");
1031
+ client.setConfig({ baseUrl: this.baseUrl });
675
1032
  }
676
- /**
677
- * Get JWT token for URL authentication (used in streaming endpoints).
678
- * Returns null if no token getter is configured or no token is available.
679
- */
1033
+ // ── Tokens ──────────────────────────────────────────────────────────────
680
1034
  getToken() {
681
- return this.tokenGetter ? this.tokenGetter() : null;
1035
+ return this.storage.getItem(ACCESS_KEY);
682
1036
  }
683
- /**
684
- * Make HTTP request with Django CSRF and session handling.
685
- * Automatically retries on network errors and 5xx server errors.
686
- */
687
- async request(method, path, options) {
688
- if (this.retryConfig) {
689
- return withRetry(() => this._makeRequest(method, path, options), {
690
- ...this.retryConfig,
691
- onFailedAttempt: /* @__PURE__ */ __name((info) => {
692
- if (this.logger) {
693
- this.logger.warn(
694
- `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
695
- );
696
- }
697
- this.retryConfig?.onFailedAttempt?.(info);
698
- }, "onFailedAttempt")
699
- });
700
- }
701
- return this._makeRequest(method, path, options);
1037
+ setToken(token) {
1038
+ if (token) this.storage.setItem(ACCESS_KEY, token);
1039
+ else this.storage.removeItem(ACCESS_KEY);
702
1040
  }
703
- /**
704
- * Internal request method (without retry wrapper).
705
- * Used by request() method with optional retry logic.
706
- */
707
- async _makeRequest(method, path, options) {
708
- const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
709
- const startTime = Date.now();
710
- const headers = {
711
- ...options?.headers || {}
712
- };
713
- if (!options?.formData && !options?.binaryBody && !headers["Content-Type"]) {
714
- headers["Content-Type"] = "application/json";
715
- }
716
- if (!headers["Authorization"]) {
717
- const token = this.getToken();
718
- if (token) {
719
- headers["Authorization"] = `Bearer ${token}`;
720
- }
721
- }
722
- if (this.logger) {
723
- this.logger.logRequest({
724
- method,
725
- url,
726
- headers,
727
- body: options?.formData || options?.body,
728
- timestamp: startTime
729
- });
730
- }
731
- try {
732
- const response = await this.httpClient.request({
733
- method,
734
- url,
735
- headers,
736
- params: options?.params,
737
- body: options?.body,
738
- formData: options?.formData,
739
- binaryBody: options?.binaryBody,
740
- responseType: options?.responseType
741
- });
742
- const duration = Date.now() - startTime;
743
- if (response.status >= 400) {
744
- const error = new APIError(
745
- response.status,
746
- response.statusText,
747
- response.data,
748
- url
749
- );
750
- if (this.logger) {
751
- this.logger.logError(
752
- {
753
- method,
754
- url,
755
- headers,
756
- body: options?.formData || options?.body,
757
- timestamp: startTime
758
- },
759
- {
760
- message: error.message,
761
- statusCode: response.status,
762
- duration,
763
- timestamp: Date.now()
764
- }
765
- );
766
- }
767
- throw error;
768
- }
769
- if (this.logger) {
770
- this.logger.logResponse(
771
- {
772
- method,
773
- url,
774
- headers,
775
- body: options?.formData || options?.body,
776
- timestamp: startTime
777
- },
778
- {
779
- status: response.status,
780
- statusText: response.statusText,
781
- data: response.data,
782
- duration,
783
- timestamp: Date.now()
784
- }
785
- );
786
- }
787
- return response.data;
788
- } catch (error) {
789
- const duration = Date.now() - startTime;
790
- if (error instanceof APIError) {
791
- throw error;
792
- }
793
- let possiblyCors = false;
794
- if (error instanceof TypeError && typeof window !== "undefined") {
795
- try {
796
- const isCrossOrigin = (() => {
797
- try {
798
- return new URL(url).origin !== window.location.origin;
799
- } catch {
800
- return false;
801
- }
802
- })();
803
- if (isCrossOrigin) {
804
- const entries = performance.getEntriesByName(url, "resource");
805
- if (entries.length > 0) {
806
- const last = entries[entries.length - 1];
807
- possiblyCors = "responseStatus" in last && last.responseStatus === 0;
808
- }
809
- }
810
- } catch {
811
- }
812
- }
813
- if (this.logger) {
814
- this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
815
- this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
816
- if (possiblyCors) {
817
- this.logger.error(` \u2192 Possibly blocked by CORS policy (configure CORS on the server)`);
818
- }
819
- }
820
- if (typeof window !== "undefined") {
821
- try {
822
- window.dispatchEvent(new CustomEvent("network-error", {
823
- detail: {
824
- url,
825
- method,
826
- error: error instanceof Error ? error.message : String(error),
827
- possibly_cors: possiblyCors,
828
- timestamp: /* @__PURE__ */ new Date()
829
- },
830
- bubbles: true,
831
- cancelable: false
832
- }));
833
- } catch {
834
- }
835
- }
836
- const networkError = error instanceof Error ? new NetworkError(error.message, url, error) : new NetworkError("Unknown error", url);
837
- if (this.logger) {
838
- this.logger.logError(
839
- {
840
- method,
841
- url,
842
- headers,
843
- body: options?.formData || options?.body,
844
- timestamp: startTime
845
- },
846
- {
847
- message: networkError.message,
848
- duration,
849
- timestamp: Date.now()
850
- }
851
- );
852
- }
853
- throw networkError;
854
- }
1041
+ getRefreshToken() {
1042
+ return this.storage.getItem(REFRESH_KEY);
855
1043
  }
856
- };
857
-
858
- // src/_api/generated/cfg_accounts/storage.ts
859
- var LocalStorageAdapter = class {
860
- static {
861
- __name(this, "LocalStorageAdapter");
1044
+ setRefreshToken(token) {
1045
+ if (token) this.storage.setItem(REFRESH_KEY, token);
1046
+ else this.storage.removeItem(REFRESH_KEY);
862
1047
  }
863
- logger;
864
- constructor(logger2) {
865
- this.logger = logger2;
1048
+ clearToken() {
1049
+ this.storage.removeItem(ACCESS_KEY);
1050
+ this.storage.removeItem(REFRESH_KEY);
866
1051
  }
867
- getItem(key) {
868
- try {
869
- if (typeof window !== "undefined" && window.localStorage) {
870
- const value = localStorage.getItem(key);
871
- this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
872
- return value;
873
- }
874
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
875
- } catch (error) {
876
- this.logger?.error("LocalStorage.getItem failed:", error);
877
- }
878
- return null;
1052
+ isAuthenticated() {
1053
+ return this.getToken() !== null;
879
1054
  }
880
- setItem(key, value) {
881
- try {
882
- if (typeof window !== "undefined" && window.localStorage) {
883
- localStorage.setItem(key, value);
884
- this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
885
- } else {
886
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
887
- }
888
- } catch (error) {
889
- this.logger?.error("LocalStorage.setItem failed:", error);
890
- }
1055
+ // ── Locale / API key ────────────────────────────────────────────────────
1056
+ getLocale() {
1057
+ return this.locale ?? detectLocale();
891
1058
  }
892
- removeItem(key) {
893
- try {
894
- if (typeof window !== "undefined" && window.localStorage) {
895
- localStorage.removeItem(key);
896
- this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
897
- } else {
898
- this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
899
- }
900
- } catch (error) {
901
- this.logger?.error("LocalStorage.removeItem failed:", error);
902
- }
1059
+ setLocale(locale) {
1060
+ this.locale = locale;
1061
+ }
1062
+ getApiKey() {
1063
+ return this.apiKey;
1064
+ }
1065
+ setApiKey(key) {
1066
+ this.apiKey = key;
903
1067
  }
904
1068
  };
905
1069
 
906
- // src/_api/generated/cfg_accounts/enums.ts
907
- var OAuthConnectionProvider = /* @__PURE__ */ ((OAuthConnectionProvider2) => {
908
- OAuthConnectionProvider2["GITHUB"] = "github";
909
- return OAuthConnectionProvider2;
910
- })(OAuthConnectionProvider || {});
911
-
912
- // src/_api/generated/cfg_accounts/_utils/schemas/AccountDeleteResponse.schema.ts
913
- var import_zod = require("zod");
914
- var AccountDeleteResponseSchema = import_zod.z.object({
915
- success: import_zod.z.boolean(),
916
- message: import_zod.z.string()
917
- });
918
-
919
- // src/_api/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts
920
- var import_zod2 = require("zod");
921
- var CentrifugoTokenSchema = import_zod2.z.object({
922
- token: import_zod2.z.string(),
923
- centrifugo_url: import_zod2.z.string(),
924
- expires_at: import_zod2.z.string().datetime({ offset: true }),
925
- channels: import_zod2.z.array(import_zod2.z.string())
926
- });
927
-
928
- // src/_api/generated/cfg_accounts/_utils/schemas/CfgAccountsProfileAvatarCreateRequest.schema.ts
929
- var import_zod3 = require("zod");
930
- var CfgAccountsProfileAvatarCreateRequestSchema = import_zod3.z.object({
931
- avatar: import_zod3.z.union([import_zod3.z.instanceof(File), import_zod3.z.instanceof(Blob)])
932
- });
933
-
934
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
935
- var import_zod4 = require("zod");
936
- var OAuthAuthorizeRequestRequestSchema = import_zod4.z.object({
937
- redirect_uri: import_zod4.z.string().optional(),
938
- source_url: import_zod4.z.string().optional()
939
- });
940
-
941
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
942
- var import_zod5 = require("zod");
943
- var OAuthAuthorizeResponseSchema = import_zod5.z.object({
944
- authorization_url: import_zod5.z.string(),
945
- state: import_zod5.z.string()
946
- });
947
-
948
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts
949
- var import_zod6 = require("zod");
950
- var OAuthCallbackRequestRequestSchema = import_zod6.z.object({
951
- code: import_zod6.z.string().min(10).max(500),
952
- state: import_zod6.z.string().min(20).max(100),
953
- redirect_uri: import_zod6.z.string().optional()
954
- });
955
-
956
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
957
- var import_zod7 = require("zod");
958
- var OAuthConnectionSchema = import_zod7.z.object({
959
- id: import_zod7.z.number().int(),
960
- provider: import_zod7.z.nativeEnum(OAuthConnectionProvider),
961
- provider_display: import_zod7.z.string(),
962
- provider_username: import_zod7.z.string(),
963
- provider_email: import_zod7.z.email(),
964
- provider_avatar_url: import_zod7.z.string(),
965
- connected_at: import_zod7.z.string().datetime({ offset: true }),
966
- last_login_at: import_zod7.z.string().datetime({ offset: true })
967
- });
968
-
969
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthDisconnectRequestRequest.schema.ts
970
- var import_zod8 = require("zod");
971
- var OAuthDisconnectRequestRequestSchema = import_zod8.z.object({
972
- provider: import_zod8.z.nativeEnum(OAuthConnectionProvider)
973
- });
974
-
975
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthError.schema.ts
976
- var import_zod9 = require("zod");
977
- var OAuthErrorSchema = import_zod9.z.object({
978
- error: import_zod9.z.string(),
979
- error_description: import_zod9.z.string().optional()
980
- });
981
-
982
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
983
- var import_zod10 = require("zod");
984
- var OAuthProvidersResponseSchema = import_zod10.z.object({
985
- providers: import_zod10.z.array(import_zod10.z.record(import_zod10.z.string(), import_zod10.z.any()))
986
- });
987
-
988
- // src/_api/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
989
- var import_zod11 = require("zod");
990
- var OAuthTokenResponseSchema = import_zod11.z.object({
991
- requires_2fa: import_zod11.z.boolean().optional(),
992
- session_id: import_zod11.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
993
- access: import_zod11.z.string().nullable().optional(),
994
- refresh: import_zod11.z.string().nullable().optional(),
995
- user: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.any()).nullable().optional(),
996
- is_new_user: import_zod11.z.boolean(),
997
- is_new_connection: import_zod11.z.boolean(),
998
- should_prompt_2fa: import_zod11.z.boolean().optional()
999
- });
1000
-
1001
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPErrorResponse.schema.ts
1002
- var import_zod12 = require("zod");
1003
- var OTPErrorResponseSchema = import_zod12.z.object({
1004
- error: import_zod12.z.string(),
1005
- error_code: import_zod12.z.string().nullable().optional(),
1006
- retry_after: import_zod12.z.number().int().nullable().optional()
1007
- });
1008
-
1009
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts
1010
- var import_zod13 = require("zod");
1011
- var OTPRequestRequestSchema = import_zod13.z.object({
1012
- identifier: import_zod13.z.string().min(1),
1013
- source_url: import_zod13.z.string().optional()
1014
- });
1015
-
1016
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
1017
- var import_zod14 = require("zod");
1018
- var OTPRequestResponseSchema = import_zod14.z.object({
1019
- message: import_zod14.z.string()
1020
- });
1021
-
1022
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts
1023
- var import_zod15 = require("zod");
1024
- var OTPVerifyRequestSchema = import_zod15.z.object({
1025
- identifier: import_zod15.z.string().min(1),
1026
- otp: import_zod15.z.string().min(6).max(6),
1027
- source_url: import_zod15.z.string().optional()
1028
- });
1029
-
1030
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
1031
- var import_zod17 = require("zod");
1032
-
1033
- // src/_api/generated/cfg_accounts/_utils/schemas/User.schema.ts
1034
- var import_zod16 = require("zod");
1035
- var UserSchema = import_zod16.z.object({
1036
- id: import_zod16.z.number().int(),
1037
- email: import_zod16.z.email(),
1038
- first_name: import_zod16.z.string().max(50).optional(),
1039
- last_name: import_zod16.z.string().max(50).optional(),
1040
- full_name: import_zod16.z.string(),
1041
- initials: import_zod16.z.string(),
1042
- display_username: import_zod16.z.string(),
1043
- company: import_zod16.z.string().max(100).optional(),
1044
- phone: import_zod16.z.string().max(20).optional(),
1045
- position: import_zod16.z.string().max(100).optional(),
1046
- language: import_zod16.z.string().max(10).optional(),
1047
- avatar: import_zod16.z.string().nullable(),
1048
- is_staff: import_zod16.z.boolean(),
1049
- is_superuser: import_zod16.z.boolean(),
1050
- date_joined: import_zod16.z.string().datetime({ offset: true }),
1051
- last_login: import_zod16.z.string().datetime({ offset: true }).nullable(),
1052
- unanswered_messages_count: import_zod16.z.number().int(),
1053
- centrifugo: CentrifugoTokenSchema.nullable()
1054
- });
1055
-
1056
- // src/_api/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
1057
- var OTPVerifyResponseSchema = import_zod17.z.object({
1058
- requires_2fa: import_zod17.z.boolean().optional(),
1059
- session_id: import_zod17.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i).nullable().optional(),
1060
- refresh: import_zod17.z.string().nullable().optional(),
1061
- access: import_zod17.z.string().nullable().optional(),
1062
- user: UserSchema.nullable().optional(),
1063
- should_prompt_2fa: import_zod17.z.boolean().optional()
1064
- });
1065
-
1066
- // src/_api/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts
1067
- var import_zod18 = require("zod");
1068
- var PatchedUserProfileUpdateRequestSchema = import_zod18.z.object({
1069
- first_name: import_zod18.z.string().max(50).optional(),
1070
- last_name: import_zod18.z.string().max(50).optional(),
1071
- company: import_zod18.z.string().max(100).optional(),
1072
- phone: import_zod18.z.string().max(20).optional(),
1073
- position: import_zod18.z.string().max(100).optional(),
1074
- language: import_zod18.z.string().max(10).optional()
1075
- });
1076
-
1077
- // src/_api/generated/cfg_accounts/_utils/schemas/TokenRefresh.schema.ts
1078
- var import_zod19 = require("zod");
1079
- var TokenRefreshSchema = import_zod19.z.object({
1080
- access: import_zod19.z.string(),
1081
- refresh: import_zod19.z.string()
1082
- });
1083
-
1084
- // src/_api/generated/cfg_accounts/_utils/schemas/TokenRefreshRequest.schema.ts
1085
- var import_zod20 = require("zod");
1086
- var TokenRefreshRequestSchema = import_zod20.z.object({
1087
- refresh: import_zod20.z.string().min(1)
1088
- });
1089
-
1090
- // src/_api/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts
1091
- var import_zod21 = require("zod");
1092
- var UserProfileUpdateRequestSchema = import_zod21.z.object({
1093
- first_name: import_zod21.z.string().max(50).optional(),
1094
- last_name: import_zod21.z.string().max(50).optional(),
1095
- company: import_zod21.z.string().max(100).optional(),
1096
- phone: import_zod21.z.string().max(20).optional(),
1097
- position: import_zod21.z.string().max(100).optional(),
1098
- language: import_zod21.z.string().max(10).optional()
1099
- });
1100
-
1101
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts.ts
1102
- var import_consola2 = require("consola");
1103
-
1104
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts
1105
- var import_consola3 = require("consola");
1106
-
1107
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts
1108
- var import_consola4 = require("consola");
1109
-
1110
- // src/_api/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts
1111
- var import_consola5 = require("consola");
1112
-
1113
- // src/_api/generated/cfg_accounts/index.ts
1114
- var TOKEN_KEY = "auth_token";
1115
- var REFRESH_TOKEN_KEY = "refresh_token";
1116
- function detectLocale() {
1070
+ // src/_api/generated/_cfg_centrifugo/api.ts
1071
+ var ACCESS_KEY2 = "cfg.access_token";
1072
+ var REFRESH_KEY2 = "cfg.refresh_token";
1073
+ function detectLocale2() {
1117
1074
  try {
1118
1075
  if (typeof document !== "undefined") {
1119
- const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1120
- if (match) return match[1];
1076
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1077
+ if (m) return decodeURIComponent(m[1]);
1121
1078
  }
1122
1079
  if (typeof navigator !== "undefined" && navigator.language) {
1123
1080
  return navigator.language;
@@ -1126,344 +1083,195 @@ function detectLocale() {
1126
1083
  }
1127
1084
  return null;
1128
1085
  }
1129
- __name(detectLocale, "detectLocale");
1130
- var API = class {
1086
+ __name(detectLocale2, "detectLocale");
1087
+ var API2 = class {
1131
1088
  static {
1132
1089
  __name(this, "API");
1133
1090
  }
1134
1091
  baseUrl;
1135
- _client;
1136
- _token = null;
1137
- _refreshToken = null;
1138
- _locale = null;
1139
1092
  storage;
1140
- options;
1141
- // Sub-clients
1142
- auth;
1143
- oauth;
1144
- user_profile;
1145
- accounts;
1146
- constructor(baseUrl, options) {
1147
- this.baseUrl = baseUrl;
1148
- this.options = options;
1149
- const logger2 = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
1150
- this.storage = options?.storage || new LocalStorageAdapter(logger2);
1151
- this._locale = options?.locale || null;
1152
- this._loadTokensFromStorage();
1153
- this._client = new APIClient(this.baseUrl, {
1154
- httpClient: this.options?.httpClient,
1155
- retryConfig: this.options?.retryConfig,
1156
- loggerConfig: this.options?.loggerConfig,
1157
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
1158
- });
1159
- this._injectAuthHeader();
1160
- this.auth = this._client.auth;
1161
- this.oauth = this._client.oauth;
1162
- this.user_profile = this._client.user_profile;
1163
- this.accounts = this._client.accounts;
1164
- }
1165
- _loadTokensFromStorage() {
1166
- this._token = this.storage.getItem(TOKEN_KEY);
1167
- this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY);
1168
- }
1169
- _reinitClients() {
1170
- this._client = new APIClient(this.baseUrl, {
1171
- httpClient: this.options?.httpClient,
1172
- retryConfig: this.options?.retryConfig,
1173
- loggerConfig: this.options?.loggerConfig,
1174
- tokenGetter: /* @__PURE__ */ __name(() => this.getToken(), "tokenGetter")
1093
+ locale;
1094
+ apiKey;
1095
+ logger;
1096
+ constructor(baseUrl2, opts = {}) {
1097
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1098
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1099
+ this.logger = new APILogger(opts.logger);
1100
+ this.locale = opts.locale ?? null;
1101
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1102
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1103
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1104
+ client.interceptors.request.use((request) => {
1105
+ const access = this.getToken();
1106
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1107
+ const locale = this.locale ?? detectLocale2();
1108
+ if (locale) request.headers.set("Accept-Language", locale);
1109
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1110
+ return request;
1175
1111
  });
1176
- this._injectAuthHeader();
1177
- this.auth = this._client.auth;
1178
- this.oauth = this._client.oauth;
1179
- this.user_profile = this._client.user_profile;
1180
- this.accounts = this._client.accounts;
1181
- }
1182
- _injectAuthHeader() {
1183
- const originalRequest = this._client.request.bind(this._client);
1184
- this._client.request = async (method, path, options) => {
1185
- const token = this.getToken();
1186
- const locale = this._locale || detectLocale();
1187
- const mergedOptions = {
1188
- ...options,
1189
- headers: {
1190
- ...options?.headers || {},
1191
- ...token ? { "Authorization": `Bearer ${token}` } : {},
1192
- ...locale ? { "Accept-Language": locale } : {}
1193
- }
1194
- };
1195
- return originalRequest(method, path, mergedOptions);
1196
- };
1197
1112
  }
1198
- /**
1199
- * Get current JWT token
1200
- */
1113
+ // ── Base URL ────────────────────────────────────────────────────────────
1114
+ getBaseUrl() {
1115
+ return this.baseUrl;
1116
+ }
1117
+ setBaseUrl(url) {
1118
+ this.baseUrl = url.replace(/\/$/, "");
1119
+ client.setConfig({ baseUrl: this.baseUrl });
1120
+ }
1121
+ // ── Tokens ──────────────────────────────────────────────────────────────
1201
1122
  getToken() {
1202
- return this.storage.getItem(TOKEN_KEY);
1123
+ return this.storage.getItem(ACCESS_KEY2);
1124
+ }
1125
+ setToken(token) {
1126
+ if (token) this.storage.setItem(ACCESS_KEY2, token);
1127
+ else this.storage.removeItem(ACCESS_KEY2);
1203
1128
  }
1204
- /**
1205
- * Get current refresh token
1206
- */
1207
1129
  getRefreshToken() {
1208
- return this.storage.getItem(REFRESH_TOKEN_KEY);
1130
+ return this.storage.getItem(REFRESH_KEY2);
1209
1131
  }
1210
- /**
1211
- * Set JWT token and refresh token
1212
- * @param token - JWT access token
1213
- * @param refreshToken - JWT refresh token (optional)
1214
- */
1215
- setToken(token, refreshToken) {
1216
- this._token = token;
1217
- this.storage.setItem(TOKEN_KEY, token);
1218
- if (refreshToken) {
1219
- this._refreshToken = refreshToken;
1220
- this.storage.setItem(REFRESH_TOKEN_KEY, refreshToken);
1221
- }
1222
- this._reinitClients();
1132
+ setRefreshToken(token) {
1133
+ if (token) this.storage.setItem(REFRESH_KEY2, token);
1134
+ else this.storage.removeItem(REFRESH_KEY2);
1223
1135
  }
1224
- /**
1225
- * Clear all tokens
1226
- */
1227
- clearTokens() {
1228
- this._token = null;
1229
- this._refreshToken = null;
1230
- this.storage.removeItem(TOKEN_KEY);
1231
- this.storage.removeItem(REFRESH_TOKEN_KEY);
1232
- this._reinitClients();
1136
+ clearToken() {
1137
+ this.storage.removeItem(ACCESS_KEY2);
1138
+ this.storage.removeItem(REFRESH_KEY2);
1233
1139
  }
1234
- /**
1235
- * Check if user is authenticated
1236
- */
1237
1140
  isAuthenticated() {
1238
- return !!this.getToken();
1239
- }
1240
- /**
1241
- * Update base URL and reinitialize clients
1242
- * @param url - New base URL
1243
- */
1244
- setBaseUrl(url) {
1245
- this.baseUrl = url;
1246
- this._reinitClients();
1141
+ return this.getToken() !== null;
1247
1142
  }
1248
- /**
1249
- * Get current base URL
1250
- */
1251
- getBaseUrl() {
1252
- return this.baseUrl;
1143
+ // ── Locale / API key ────────────────────────────────────────────────────
1144
+ getLocale() {
1145
+ return this.locale ?? detectLocale2();
1253
1146
  }
1254
- /**
1255
- * Set locale for Accept-Language header
1256
- * @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
1257
- */
1258
1147
  setLocale(locale) {
1259
- this._locale = locale;
1148
+ this.locale = locale;
1260
1149
  }
1261
- /**
1262
- * Get current locale
1263
- */
1264
- getLocale() {
1265
- return this._locale;
1150
+ getApiKey() {
1151
+ return this.apiKey;
1266
1152
  }
1267
- /**
1268
- * Get OpenAPI schema path
1269
- * @returns Path to the OpenAPI schema JSON file
1270
- *
1271
- * Note: The OpenAPI schema is available in the schema.json file.
1272
- * You can load it dynamically using:
1273
- * ```typescript
1274
- * const schema = await fetch('./schema.json').then(r => r.json());
1275
- * // or using fs in Node.js:
1276
- * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
1277
- * ```
1278
- */
1279
- getSchemaPath() {
1280
- return "./schema.json";
1153
+ setApiKey(key) {
1154
+ this.apiKey = key;
1281
1155
  }
1282
1156
  };
1283
1157
 
1284
- // src/_api/generated/cfg_centrifugo/logger.ts
1285
- var import_consola6 = require("consola");
1286
- var DEFAULT_CONFIG2 = {
1287
- enabled: process.env.NODE_ENV !== "production",
1288
- logRequests: true,
1289
- logResponses: true,
1290
- logErrors: true,
1291
- logBodies: true,
1292
- logHeaders: false
1293
- };
1294
- var SENSITIVE_HEADERS2 = [
1295
- "authorization",
1296
- "cookie",
1297
- "set-cookie",
1298
- "x-api-key",
1299
- "x-csrf-token"
1300
- ];
1301
- var APILogger2 = class {
1158
+ // src/_api/generated/_cfg_totp/api.ts
1159
+ var ACCESS_KEY3 = "cfg.access_token";
1160
+ var REFRESH_KEY3 = "cfg.refresh_token";
1161
+ function detectLocale3() {
1162
+ try {
1163
+ if (typeof document !== "undefined") {
1164
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1165
+ if (m) return decodeURIComponent(m[1]);
1166
+ }
1167
+ if (typeof navigator !== "undefined" && navigator.language) {
1168
+ return navigator.language;
1169
+ }
1170
+ } catch {
1171
+ }
1172
+ return null;
1173
+ }
1174
+ __name(detectLocale3, "detectLocale");
1175
+ var API3 = class {
1302
1176
  static {
1303
- __name(this, "APILogger");
1177
+ __name(this, "API");
1304
1178
  }
1305
- config;
1306
- consola;
1307
- constructor(config = {}) {
1308
- this.config = { ...DEFAULT_CONFIG2, ...config };
1309
- this.consola = config.consola || (0, import_consola6.createConsola)({
1310
- level: this.config.enabled ? 4 : 0
1179
+ baseUrl;
1180
+ storage;
1181
+ locale;
1182
+ apiKey;
1183
+ logger;
1184
+ constructor(baseUrl2, opts = {}) {
1185
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1186
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1187
+ this.logger = new APILogger(opts.logger);
1188
+ this.locale = opts.locale ?? null;
1189
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1190
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1191
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1192
+ client.interceptors.request.use((request) => {
1193
+ const access = this.getToken();
1194
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1195
+ const locale = this.locale ?? detectLocale3();
1196
+ if (locale) request.headers.set("Accept-Language", locale);
1197
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1198
+ return request;
1311
1199
  });
1312
1200
  }
1313
- /**
1314
- * Enable logging
1315
- */
1316
- enable() {
1317
- this.config.enabled = true;
1318
- }
1319
- /**
1320
- * Disable logging
1321
- */
1322
- disable() {
1323
- this.config.enabled = false;
1201
+ // ── Base URL ────────────────────────────────────────────────────────────
1202
+ getBaseUrl() {
1203
+ return this.baseUrl;
1324
1204
  }
1325
- /**
1326
- * Update configuration
1327
- */
1328
- setConfig(config) {
1329
- this.config = { ...this.config, ...config };
1205
+ setBaseUrl(url) {
1206
+ this.baseUrl = url.replace(/\/$/, "");
1207
+ client.setConfig({ baseUrl: this.baseUrl });
1330
1208
  }
1331
- /**
1332
- * Filter sensitive headers
1333
- */
1334
- filterHeaders(headers) {
1335
- if (!headers) return {};
1336
- const filtered = {};
1337
- Object.keys(headers).forEach((key) => {
1338
- const lowerKey = key.toLowerCase();
1339
- if (SENSITIVE_HEADERS2.includes(lowerKey)) {
1340
- filtered[key] = "***";
1341
- } else {
1342
- filtered[key] = headers[key] || "";
1343
- }
1344
- });
1345
- return filtered;
1209
+ // ── Tokens ──────────────────────────────────────────────────────────────
1210
+ getToken() {
1211
+ return this.storage.getItem(ACCESS_KEY3);
1346
1212
  }
1347
- /**
1348
- * Log request
1349
- */
1350
- logRequest(request) {
1351
- if (!this.config.enabled || !this.config.logRequests) return;
1352
- const { method, url, headers, body } = request;
1353
- this.consola.start(`${method} ${url}`);
1354
- if (this.config.logHeaders && headers) {
1355
- this.consola.debug("Headers:", this.filterHeaders(headers));
1356
- }
1357
- if (this.config.logBodies && body) {
1358
- this.consola.debug("Body:", body);
1359
- }
1213
+ setToken(token) {
1214
+ if (token) this.storage.setItem(ACCESS_KEY3, token);
1215
+ else this.storage.removeItem(ACCESS_KEY3);
1360
1216
  }
1361
- /**
1362
- * Log response
1363
- */
1364
- logResponse(request, response) {
1365
- if (!this.config.enabled || !this.config.logResponses) return;
1366
- const { method, url } = request;
1367
- const { status, statusText, data, duration } = response;
1368
- const statusColor = status >= 500 ? "red" : status >= 400 ? "yellow" : status >= 300 ? "cyan" : "green";
1369
- this.consola.success(
1370
- `${method} ${url} ${status} ${statusText} (${duration}ms)`
1371
- );
1372
- if (this.config.logBodies && data) {
1373
- this.consola.debug("Response:", data);
1374
- }
1217
+ getRefreshToken() {
1218
+ return this.storage.getItem(REFRESH_KEY3);
1375
1219
  }
1376
- /**
1377
- * Log error
1378
- */
1379
- logError(request, error) {
1380
- if (!this.config.enabled || !this.config.logErrors) return;
1381
- const { method, url } = request;
1382
- const { message, statusCode, fieldErrors, duration } = error;
1383
- this.consola.error(
1384
- `${method} ${url} ${statusCode || "Network"} Error (${duration}ms)`
1385
- );
1386
- this.consola.error("Message:", message);
1387
- if (fieldErrors && Object.keys(fieldErrors).length > 0) {
1388
- this.consola.error("Field Errors:");
1389
- Object.entries(fieldErrors).forEach(([field, errors]) => {
1390
- errors.forEach((err) => {
1391
- this.consola.error(` \u2022 ${field}: ${err}`);
1392
- });
1393
- });
1394
- }
1220
+ setRefreshToken(token) {
1221
+ if (token) this.storage.setItem(REFRESH_KEY3, token);
1222
+ else this.storage.removeItem(REFRESH_KEY3);
1395
1223
  }
1396
- /**
1397
- * Log general info
1398
- */
1399
- info(message, ...args) {
1400
- if (!this.config.enabled) return;
1401
- this.consola.info(message, ...args);
1224
+ clearToken() {
1225
+ this.storage.removeItem(ACCESS_KEY3);
1226
+ this.storage.removeItem(REFRESH_KEY3);
1402
1227
  }
1403
- /**
1404
- * Log warning
1405
- */
1406
- warn(message, ...args) {
1407
- if (!this.config.enabled) return;
1408
- this.consola.warn(message, ...args);
1228
+ isAuthenticated() {
1229
+ return this.getToken() !== null;
1409
1230
  }
1410
- /**
1411
- * Log error
1412
- */
1413
- error(message, ...args) {
1414
- if (!this.config.enabled) return;
1415
- this.consola.error(message, ...args);
1231
+ // ── Locale / API key ────────────────────────────────────────────────────
1232
+ getLocale() {
1233
+ return this.locale ?? detectLocale3();
1416
1234
  }
1417
- /**
1418
- * Log debug
1419
- */
1420
- debug(message, ...args) {
1421
- if (!this.config.enabled) return;
1422
- this.consola.debug(message, ...args);
1235
+ setLocale(locale) {
1236
+ this.locale = locale;
1423
1237
  }
1424
- /**
1425
- * Log success
1426
- */
1427
- success(message, ...args) {
1428
- if (!this.config.enabled) return;
1429
- this.consola.success(message, ...args);
1238
+ getApiKey() {
1239
+ return this.apiKey;
1430
1240
  }
1431
- /**
1432
- * Create a sub-logger with prefix
1433
- */
1434
- withTag(tag) {
1435
- return this.consola.withTag(tag);
1241
+ setApiKey(key) {
1242
+ this.apiKey = key;
1436
1243
  }
1437
1244
  };
1438
- var defaultLogger2 = new APILogger2();
1439
-
1440
- // src/_api/generated/cfg_centrifugo/retry.ts
1441
- var import_p_retry2 = __toESM(require("p-retry"), 1);
1442
-
1443
- // src/_api/generated/cfg_centrifugo/_utils/schemas/ConnectionTokenResponse.schema.ts
1444
- var import_zod22 = require("zod");
1445
- var ConnectionTokenResponseSchema = import_zod22.z.object({
1446
- token: import_zod22.z.string(),
1447
- centrifugo_url: import_zod22.z.string(),
1448
- expires_at: import_zod22.z.string(),
1449
- channels: import_zod22.z.array(import_zod22.z.string())
1450
- });
1451
1245
 
1452
- // src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts
1453
- var import_consola7 = require("consola");
1454
-
1455
- // src/index.ts
1246
+ // src/_api/generated/index.ts
1456
1247
  var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1457
- var apiUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1458
- var api = new API(
1459
- apiUrl,
1460
- {
1461
- storage: new LocalStorageAdapter()
1248
+ var baseUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
1249
+ var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1250
+ var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1251
+ var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1252
+
1253
+ // src/_api/generated/sdk.gen.ts
1254
+ var Auth = class {
1255
+ static {
1256
+ __name(this, "Auth");
1462
1257
  }
1463
- );
1258
+ /**
1259
+ * Refresh JWT token.
1260
+ */
1261
+ static cfgAccountsTokenRefreshCreate(options) {
1262
+ return (options.client ?? client).post({
1263
+ url: "/cfg/accounts/token/refresh/",
1264
+ ...options,
1265
+ headers: {
1266
+ "Content-Type": "application/json",
1267
+ ...options.headers
1268
+ }
1269
+ });
1270
+ }
1271
+ };
1464
1272
 
1465
1273
  // src/auth/utils/logger.ts
1466
- var import_consola8 = require("consola");
1274
+ var import_consola2 = require("consola");
1467
1275
 
1468
1276
  // src/auth/utils/env.ts
1469
1277
  var isDev = process.env.NODE_ENV === "development";
@@ -1471,7 +1279,7 @@ var isDev = process.env.NODE_ENV === "development";
1471
1279
  // src/auth/utils/logger.ts
1472
1280
  var isStaticBuild2 = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
1473
1281
  var showLogs = isDev || isStaticBuild2;
1474
- var logger = (0, import_consola8.createConsola)({
1282
+ var logger = (0, import_consola2.createConsola)({
1475
1283
  level: showLogs ? 4 : 1
1476
1284
  // dev: debug, production: errors only
1477
1285
  }).withTag("api");
@@ -1498,22 +1306,24 @@ async function refreshAccessToken() {
1498
1306
  isRefreshing = true;
1499
1307
  authLogger.info("Starting token refresh...");
1500
1308
  try {
1501
- const refreshToken = api.getRefreshToken();
1309
+ const refreshToken = CfgAccountsApi.getRefreshToken();
1502
1310
  if (!refreshToken) {
1503
1311
  authLogger.warn("No refresh token available for refresh");
1504
1312
  onTokenRefreshed(null);
1505
1313
  return null;
1506
1314
  }
1507
- const result = await api.auth.accountsTokenRefreshCreate({
1508
- refresh: refreshToken
1315
+ const result = await Auth.cfgAccountsTokenRefreshCreate({
1316
+ body: { refresh: refreshToken },
1317
+ throwOnError: true
1509
1318
  });
1510
- const newAccessToken = result.access;
1319
+ const newAccessToken = result.data.access;
1511
1320
  if (!newAccessToken) {
1512
1321
  authLogger.error("Token refresh response missing access token");
1513
1322
  onTokenRefreshed(null);
1514
1323
  return null;
1515
1324
  }
1516
- api.setToken(newAccessToken, refreshToken);
1325
+ CfgAccountsApi.setToken(newAccessToken);
1326
+ CfgAccountsApi.setRefreshToken(refreshToken);
1517
1327
  authLogger.info("Token refreshed successfully");
1518
1328
  onTokenRefreshed(newAccessToken);
1519
1329
  return newAccessToken;
@@ -1533,7 +1343,7 @@ __name(isAuthenticationError, "isAuthenticationError");
1533
1343
  function createAutoRefreshFetch(originalFetch) {
1534
1344
  return async (input, init) => {
1535
1345
  let response = await originalFetch(input, init);
1536
- if (isAuthenticationError(response) && api.getRefreshToken()) {
1346
+ if (isAuthenticationError(response) && CfgAccountsApi.getRefreshToken()) {
1537
1347
  authLogger.info("Received 401, attempting token refresh...");
1538
1348
  const newToken = await refreshAccessToken();
1539
1349
  if (newToken) {
@@ -1555,7 +1365,7 @@ function createAutoRefreshFetch(originalFetch) {
1555
1365
  }
1556
1366
  __name(createAutoRefreshFetch, "createAutoRefreshFetch");
1557
1367
  function isTokenExpiringSoon(thresholdMs = 5 * 60 * 1e3) {
1558
- const token = api.getToken();
1368
+ const token = CfgAccountsApi.getToken();
1559
1369
  if (!token) return false;
1560
1370
  try {
1561
1371
  const payload = JSON.parse(atob(token.split(".")[1]));