@djangocfg/api 2.1.327 → 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 (170) hide show
  1. package/dist/auth-server.cjs +185 -3471
  2. package/dist/auth-server.cjs.map +1 -1
  3. package/dist/auth-server.mjs +185 -3471
  4. package/dist/auth-server.mjs.map +1 -1
  5. package/dist/auth.cjs +952 -3305
  6. package/dist/auth.cjs.map +1 -1
  7. package/dist/auth.d.cts +35 -35
  8. package/dist/auth.d.ts +35 -35
  9. package/dist/auth.mjs +952 -3305
  10. package/dist/auth.mjs.map +1 -1
  11. package/dist/clients.cjs +90 -3396
  12. package/dist/clients.cjs.map +1 -1
  13. package/dist/clients.d.cts +4 -2508
  14. package/dist/clients.d.ts +4 -2508
  15. package/dist/clients.mjs +90 -3396
  16. package/dist/clients.mjs.map +1 -1
  17. package/dist/index.cjs +985 -3052
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1544 -1938
  20. package/dist/index.d.ts +1544 -1938
  21. package/dist/index.mjs +985 -3052
  22. package/dist/index.mjs.map +1 -1
  23. package/package.json +2 -2
  24. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/api.ts +11 -55
  25. package/src/_api/generated/{cfg_totp → _cfg_accounts}/events.ts +3 -3
  26. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/index.ts +1 -1
  27. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthConnectionsList.ts +5 -6
  28. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthDisconnectCreate.ts +3 -3
  29. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +3 -3
  30. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +3 -3
  31. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOauthProvidersRetrieve.ts +5 -6
  32. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpRequestCreate.ts +3 -3
  33. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsOtpVerifyCreate.ts +3 -3
  34. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileAvatarCreate.ts +3 -3
  35. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileDeleteCreate.ts +3 -3
  36. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +3 -3
  37. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfilePartialUpdate.ts +3 -3
  38. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileRetrieve.ts +5 -6
  39. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +3 -3
  40. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsProfileUpdateUpdate.ts +3 -3
  41. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/hooks/useCfgAccountsTokenRefreshCreate.ts +3 -3
  42. package/src/_api/generated/{cfg_centrifugo → _cfg_accounts}/index.ts +3 -3
  43. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/AccountDeleteResponse.ts +3 -3
  44. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CentrifugoToken.ts +4 -4
  45. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/CfgUserUpdateRequest.ts +4 -4
  46. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeRequestRequest.ts +2 -2
  47. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthAuthorizeResponse.ts +2 -2
  48. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthCallbackRequestRequest.ts +3 -3
  49. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthConnection.ts +6 -6
  50. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthDisconnectRequestRequest.ts +2 -2
  51. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthError.ts +2 -2
  52. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthProvidersResponse.ts +3 -3
  53. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OAuthTokenResponse.ts +7 -7
  54. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPErrorResponse.ts +2 -2
  55. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestRequest.ts +2 -2
  56. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPRequestResponse.ts +2 -2
  57. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyRequest.ts +2 -2
  58. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/OTPVerifyResponse.ts +6 -6
  59. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/PatchedCfgUserUpdateRequest.ts +4 -4
  60. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/ProviderEnum.ts +2 -2
  61. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefresh.ts +2 -2
  62. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/TokenRefreshRequest.ts +2 -2
  63. package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/User.ts +13 -13
  64. package/src/_api/generated/_cfg_accounts/sdk.gen.ts +5 -0
  65. package/src/_api/generated/_cfg_accounts/types.gen.ts +5 -0
  66. package/src/_api/generated/{cfg_totp → _cfg_centrifugo}/api.ts +11 -72
  67. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/events.ts +3 -3
  68. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/index.ts +1 -1
  69. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +5 -6
  70. package/src/_api/generated/{cfg_accounts → _cfg_centrifugo}/index.ts +3 -3
  71. package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/ConnectionTokenResponse.ts +4 -4
  72. package/src/_api/generated/_cfg_centrifugo/sdk.gen.ts +5 -0
  73. package/src/_api/generated/_cfg_centrifugo/types.gen.ts +5 -0
  74. package/src/_api/generated/{cfg_accounts → _cfg_totp}/api.ts +11 -78
  75. package/src/_api/generated/{cfg_accounts → _cfg_totp}/events.ts +3 -3
  76. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/index.ts +1 -1
  77. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +3 -3
  78. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpBackupCodesRetrieve.ts +5 -6
  79. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesDestroy.ts +3 -3
  80. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDevicesRetrieve.ts +5 -6
  81. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpDisableCreate.ts +3 -3
  82. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupConfirmCreate.ts +3 -3
  83. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpSetupCreate.ts +3 -3
  84. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyBackupCreate.ts +3 -3
  85. package/src/_api/generated/{cfg_totp → _cfg_totp}/hooks/useCfgTotpVerifyCreate.ts +3 -3
  86. package/src/_api/generated/{cfg_totp → _cfg_totp}/index.ts +3 -3
  87. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateRequest.ts +2 -2
  88. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesRegenerateResponse.ts +2 -2
  89. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/BackupCodesStatus.ts +2 -2
  90. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupRequest.ts +3 -3
  91. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/ConfirmSetupResponse.ts +3 -3
  92. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceList.ts +6 -6
  93. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListResponse.ts +2 -2
  94. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DeviceListStatusEnum.ts +2 -2
  95. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/DisableRequest.ts +2 -2
  96. package/src/_api/generated/_cfg_totp/schemas/SetupRequest.ts +11 -0
  97. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/SetupResponse.ts +4 -4
  98. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/TotpVerifyUser.ts +12 -12
  99. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyBackupRequest.ts +3 -3
  100. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyRequest.ts +3 -3
  101. package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/VerifyResponse.ts +4 -4
  102. package/src/_api/generated/_cfg_totp/sdk.gen.ts +5 -0
  103. package/src/_api/generated/_cfg_totp/types.gen.ts +5 -0
  104. package/src/_api/generated/index.ts +11 -13
  105. package/src/_api/generated/{cfg_accounts/sdk.gen.ts → sdk.gen.ts} +455 -1
  106. package/src/_api/generated/{cfg_accounts/types.gen.ts → types.gen.ts} +607 -77
  107. package/src/auth/context/AccountsContext.tsx +10 -10
  108. package/src/auth/context/AuthContext.tsx +1 -1
  109. package/src/auth/hooks/useDeleteAccount.ts +2 -1
  110. package/src/auth/hooks/useGithubAuth.ts +3 -2
  111. package/src/auth/hooks/useTokenRefresh.ts +2 -1
  112. package/src/auth/hooks/useTwoFactor.ts +4 -3
  113. package/src/auth/hooks/useTwoFactorSetup.ts +3 -2
  114. package/src/auth/hooks/useTwoFactorStatus.ts +4 -3
  115. package/src/auth/middlewares/tokenRefresh.ts +2 -1
  116. package/src/clients.ts +3 -3
  117. package/src/index.ts +22 -5
  118. package/src/server.ts +9 -9
  119. package/src/_api/generated/cfg_centrifugo/client/client.gen.ts +0 -280
  120. package/src/_api/generated/cfg_centrifugo/client/index.ts +0 -25
  121. package/src/_api/generated/cfg_centrifugo/client/types.gen.ts +0 -217
  122. package/src/_api/generated/cfg_centrifugo/client/utils.gen.ts +0 -318
  123. package/src/_api/generated/cfg_centrifugo/client.gen.ts +0 -16
  124. package/src/_api/generated/cfg_centrifugo/core/auth.gen.ts +0 -41
  125. package/src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts +0 -82
  126. package/src/_api/generated/cfg_centrifugo/core/params.gen.ts +0 -169
  127. package/src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts +0 -171
  128. package/src/_api/generated/cfg_centrifugo/core/queryKeySerializer.gen.ts +0 -117
  129. package/src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts +0 -242
  130. package/src/_api/generated/cfg_centrifugo/core/types.gen.ts +0 -104
  131. package/src/_api/generated/cfg_centrifugo/core/utils.gen.ts +0 -140
  132. package/src/_api/generated/cfg_centrifugo/sdk.gen.ts +0 -64
  133. package/src/_api/generated/cfg_centrifugo/types.gen.ts +0 -61
  134. package/src/_api/generated/cfg_totp/client/client.gen.ts +0 -280
  135. package/src/_api/generated/cfg_totp/client/index.ts +0 -25
  136. package/src/_api/generated/cfg_totp/client/types.gen.ts +0 -217
  137. package/src/_api/generated/cfg_totp/client/utils.gen.ts +0 -318
  138. package/src/_api/generated/cfg_totp/client.gen.ts +0 -16
  139. package/src/_api/generated/cfg_totp/core/auth.gen.ts +0 -41
  140. package/src/_api/generated/cfg_totp/core/bodySerializer.gen.ts +0 -82
  141. package/src/_api/generated/cfg_totp/core/params.gen.ts +0 -169
  142. package/src/_api/generated/cfg_totp/core/pathSerializer.gen.ts +0 -171
  143. package/src/_api/generated/cfg_totp/core/queryKeySerializer.gen.ts +0 -117
  144. package/src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts +0 -242
  145. package/src/_api/generated/cfg_totp/core/types.gen.ts +0 -104
  146. package/src/_api/generated/cfg_totp/core/utils.gen.ts +0 -140
  147. package/src/_api/generated/cfg_totp/schemas/SetupRequest.ts +0 -11
  148. package/src/_api/generated/cfg_totp/sdk.gen.ts +0 -432
  149. package/src/_api/generated/cfg_totp/types.gen.ts +0 -479
  150. /package/src/_api/generated/{cfg_accounts → _cfg_accounts}/schemas/index.ts +0 -0
  151. /package/src/_api/generated/{cfg_centrifugo → _cfg_centrifugo}/schemas/index.ts +0 -0
  152. /package/src/_api/generated/{cfg_totp → _cfg_totp}/schemas/index.ts +0 -0
  153. /package/src/_api/generated/{cfg_accounts/client → client}/client.gen.ts +0 -0
  154. /package/src/_api/generated/{cfg_accounts/client → client}/index.ts +0 -0
  155. /package/src/_api/generated/{cfg_accounts/client → client}/types.gen.ts +0 -0
  156. /package/src/_api/generated/{cfg_accounts/client → client}/utils.gen.ts +0 -0
  157. /package/src/_api/generated/{cfg_accounts/client.gen.ts → client.gen.ts} +0 -0
  158. /package/src/_api/generated/{cfg_accounts/core → core}/auth.gen.ts +0 -0
  159. /package/src/_api/generated/{cfg_accounts/core → core}/bodySerializer.gen.ts +0 -0
  160. /package/src/_api/generated/{cfg_accounts/core → core}/params.gen.ts +0 -0
  161. /package/src/_api/generated/{cfg_accounts/core → core}/pathSerializer.gen.ts +0 -0
  162. /package/src/_api/generated/{cfg_accounts/core → core}/queryKeySerializer.gen.ts +0 -0
  163. /package/src/_api/generated/{cfg_accounts/core → core}/serverSentEvents.gen.ts +0 -0
  164. /package/src/_api/generated/{cfg_accounts/core → core}/types.gen.ts +0 -0
  165. /package/src/_api/generated/{cfg_accounts/core → core}/utils.gen.ts +0 -0
  166. /package/src/_api/generated/{_shared → helpers}/errors.ts +0 -0
  167. /package/src/_api/generated/{_shared → helpers}/index.ts +0 -0
  168. /package/src/_api/generated/{_shared → helpers}/logger.ts +0 -0
  169. /package/src/_api/generated/{_shared → helpers}/storage.ts +0 -0
  170. /package/src/_api/generated/{_shared → helpers}/validation-events.ts +0 -0
package/dist/clients.mjs CHANGED
@@ -2,37 +2,12 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
 
5
- // src/_api/generated/cfg_accounts/core/bodySerializer.gen.ts
6
- var serializeFormDataPair = /* @__PURE__ */ __name((data, key, value) => {
7
- if (typeof value === "string" || value instanceof Blob) {
8
- data.append(key, value);
9
- } else if (value instanceof Date) {
10
- data.append(key, value.toISOString());
11
- } else {
12
- data.append(key, JSON.stringify(value));
13
- }
14
- }, "serializeFormDataPair");
15
- var formDataBodySerializer = {
16
- bodySerializer: /* @__PURE__ */ __name((body) => {
17
- const data = new FormData();
18
- Object.entries(body).forEach(([key, value]) => {
19
- if (value === void 0 || value === null) {
20
- return;
21
- }
22
- if (Array.isArray(value)) {
23
- value.forEach((v) => serializeFormDataPair(data, key, v));
24
- } else {
25
- serializeFormDataPair(data, key, value);
26
- }
27
- });
28
- return data;
29
- }, "bodySerializer")
30
- };
5
+ // src/_api/generated/core/bodySerializer.gen.ts
31
6
  var jsonBodySerializer = {
32
7
  bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
33
8
  };
34
9
 
35
- // src/_api/generated/cfg_accounts/core/params.gen.ts
10
+ // src/_api/generated/core/params.gen.ts
36
11
  var extraPrefixesMap = {
37
12
  $body_: "body",
38
13
  $headers_: "headers",
@@ -41,7 +16,7 @@ var extraPrefixesMap = {
41
16
  };
42
17
  var extraPrefixes = Object.entries(extraPrefixesMap);
43
18
 
44
- // src/_api/generated/cfg_accounts/core/serverSentEvents.gen.ts
19
+ // src/_api/generated/core/serverSentEvents.gen.ts
45
20
  function createSseClient({
46
21
  onRequest,
47
22
  onSseError,
@@ -169,7 +144,7 @@ function createSseClient({
169
144
  }
170
145
  __name(createSseClient, "createSseClient");
171
146
 
172
- // src/_api/generated/cfg_accounts/core/pathSerializer.gen.ts
147
+ // src/_api/generated/core/pathSerializer.gen.ts
173
148
  var separatorArrayExplode = /* @__PURE__ */ __name((style) => {
174
149
  switch (style) {
175
150
  case "label":
@@ -293,7 +268,7 @@ var serializeObjectParam = /* @__PURE__ */ __name(({
293
268
  return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
294
269
  }, "serializeObjectParam");
295
270
 
296
- // src/_api/generated/cfg_accounts/core/utils.gen.ts
271
+ // src/_api/generated/core/utils.gen.ts
297
272
  var PATH_PARAM_RE = /\{[^{}]+\}/g;
298
273
  var defaultPathSerializer = /* @__PURE__ */ __name(({ path, url: _url }) => {
299
274
  let url = _url;
@@ -391,7 +366,7 @@ function getValidRequestBody(options) {
391
366
  }
392
367
  __name(getValidRequestBody, "getValidRequestBody");
393
368
 
394
- // src/_api/generated/cfg_accounts/core/auth.gen.ts
369
+ // src/_api/generated/core/auth.gen.ts
395
370
  var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
396
371
  const token = typeof callback === "function" ? await callback(auth) : callback;
397
372
  if (!token) {
@@ -406,7 +381,7 @@ var getAuthToken = /* @__PURE__ */ __name(async (auth, callback) => {
406
381
  return token;
407
382
  }, "getAuthToken");
408
383
 
409
- // src/_api/generated/cfg_accounts/client/utils.gen.ts
384
+ // src/_api/generated/client/utils.gen.ts
410
385
  var createQuerySerializer = /* @__PURE__ */ __name(({
411
386
  parameters = {},
412
387
  ...args
@@ -625,7 +600,7 @@ var createConfig = /* @__PURE__ */ __name((override = {}) => ({
625
600
  ...override
626
601
  }), "createConfig");
627
602
 
628
- // src/_api/generated/cfg_accounts/client/client.gen.ts
603
+ // src/_api/generated/client/client.gen.ts
629
604
  var createClient = /* @__PURE__ */ __name((config = {}) => {
630
605
  let _config = mergeConfigs(createConfig(), config);
631
606
  const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
@@ -823,10 +798,10 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
823
798
  };
824
799
  }, "createClient");
825
800
 
826
- // src/_api/generated/cfg_accounts/client.gen.ts
801
+ // src/_api/generated/client.gen.ts
827
802
  var client = createClient(createConfig({ baseUrl: "http://localhost:8000" }));
828
803
 
829
- // src/_api/generated/_shared/storage.ts
804
+ // src/_api/generated/helpers/storage.ts
830
805
  var LocalStorageAdapter = class {
831
806
  static {
832
807
  __name(this, "LocalStorageAdapter");
@@ -862,7 +837,7 @@ var LocalStorageAdapter = class {
862
837
  }
863
838
  };
864
839
 
865
- // src/_api/generated/_shared/logger.ts
840
+ // src/_api/generated/helpers/logger.ts
866
841
  import { createConsola } from "consola";
867
842
  var DEFAULT_CONFIG = {
868
843
  enabled: typeof process !== "undefined" && process.env.NODE_ENV !== "production",
@@ -956,980 +931,9 @@ var APILogger = class {
956
931
  };
957
932
  var defaultLogger = new APILogger();
958
933
 
959
- // src/_api/generated/cfg_accounts/sdk.gen.ts
960
- var Cfg = class {
961
- static {
962
- __name(this, "Cfg");
963
- }
964
- /**
965
- * List OAuth connections
966
- *
967
- * Get all OAuth connections for the current user.
968
- */
969
- static cfgAccountsOauthConnectionsList(options) {
970
- return (options?.client ?? client).get({
971
- security: [{ scheme: "bearer", type: "http" }],
972
- url: "/cfg/accounts/oauth/connections/",
973
- ...options
974
- });
975
- }
976
- /**
977
- * Disconnect OAuth provider
978
- *
979
- * Remove OAuth connection for the specified provider.
980
- */
981
- static cfgAccountsOauthDisconnectCreate(options) {
982
- return (options.client ?? client).post({
983
- security: [{ scheme: "bearer", type: "http" }],
984
- url: "/cfg/accounts/oauth/disconnect/",
985
- ...options,
986
- headers: {
987
- "Content-Type": "application/json",
988
- ...options.headers
989
- }
990
- });
991
- }
992
- /**
993
- * Start GitHub OAuth
994
- *
995
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
996
- */
997
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
998
- return (options?.client ?? client).post({
999
- url: "/cfg/accounts/oauth/github/authorize/",
1000
- ...options,
1001
- headers: {
1002
- "Content-Type": "application/json",
1003
- ...options?.headers
1004
- }
1005
- });
1006
- }
1007
- /**
1008
- * Complete GitHub OAuth
1009
- *
1010
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1011
- */
1012
- static cfgAccountsOauthGithubCallbackCreate(options) {
1013
- return (options.client ?? client).post({
1014
- url: "/cfg/accounts/oauth/github/callback/",
1015
- ...options,
1016
- headers: {
1017
- "Content-Type": "application/json",
1018
- ...options.headers
1019
- }
1020
- });
1021
- }
1022
- /**
1023
- * List OAuth providers
1024
- *
1025
- * Get list of available OAuth providers for authentication.
1026
- */
1027
- static cfgAccountsOauthProvidersRetrieve(options) {
1028
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1029
- }
1030
- /**
1031
- * Request OTP code to email.
1032
- */
1033
- static cfgAccountsOtpRequestCreate(options) {
1034
- return (options.client ?? client).post({
1035
- security: [{ scheme: "bearer", type: "http" }],
1036
- url: "/cfg/accounts/otp/request/",
1037
- ...options,
1038
- headers: {
1039
- "Content-Type": "application/json",
1040
- ...options.headers
1041
- }
1042
- });
1043
- }
1044
- /**
1045
- * Verify OTP code and return JWT tokens or 2FA session.
1046
- *
1047
- * If user has 2FA enabled:
1048
- * - Returns requires_2fa=True with session_id
1049
- * - Client must complete 2FA verification at /cfg/totp/verify/
1050
- *
1051
- * If user has no 2FA:
1052
- * - Returns JWT tokens and user data directly
1053
- */
1054
- static cfgAccountsOtpVerifyCreate(options) {
1055
- return (options.client ?? client).post({
1056
- security: [{ scheme: "bearer", type: "http" }],
1057
- url: "/cfg/accounts/otp/verify/",
1058
- ...options,
1059
- headers: {
1060
- "Content-Type": "application/json",
1061
- ...options.headers
1062
- }
1063
- });
1064
- }
1065
- /**
1066
- * Get current user profile
1067
- *
1068
- * Retrieve the current authenticated user's profile information.
1069
- */
1070
- static cfgAccountsProfileRetrieve(options) {
1071
- return (options?.client ?? client).get({
1072
- security: [{ scheme: "bearer", type: "http" }, {
1073
- in: "cookie",
1074
- name: "sessionid",
1075
- type: "apiKey"
1076
- }],
1077
- url: "/cfg/accounts/profile/",
1078
- ...options
1079
- });
1080
- }
1081
- /**
1082
- * Upload user avatar
1083
- *
1084
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1085
- */
1086
- static cfgAccountsProfileAvatarCreate(options) {
1087
- return (options?.client ?? client).post({
1088
- ...formDataBodySerializer,
1089
- security: [{ scheme: "bearer", type: "http" }],
1090
- url: "/cfg/accounts/profile/avatar/",
1091
- ...options,
1092
- headers: {
1093
- "Content-Type": null,
1094
- ...options?.headers
1095
- }
1096
- });
1097
- }
1098
- /**
1099
- * Delete user account
1100
- *
1101
- *
1102
- * Permanently delete the current user's account.
1103
- *
1104
- * This operation:
1105
- * - Deactivates the account (user cannot log in)
1106
- * - Anonymizes personal data (GDPR compliance)
1107
- * - Frees up the email address for re-registration
1108
- * - Preserves audit trail
1109
- *
1110
- * The account can be restored by an administrator if needed.
1111
- *
1112
- */
1113
- static cfgAccountsProfileDeleteCreate(options) {
1114
- return (options?.client ?? client).post({
1115
- security: [{ scheme: "bearer", type: "http" }, {
1116
- in: "cookie",
1117
- name: "sessionid",
1118
- type: "apiKey"
1119
- }],
1120
- url: "/cfg/accounts/profile/delete/",
1121
- ...options
1122
- });
1123
- }
1124
- /**
1125
- * Partial update user profile
1126
- *
1127
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1128
- */
1129
- static cfgAccountsProfilePartialPartialUpdate(options) {
1130
- return (options?.client ?? client).patch({
1131
- security: [{ scheme: "bearer", type: "http" }, {
1132
- in: "cookie",
1133
- name: "sessionid",
1134
- type: "apiKey"
1135
- }],
1136
- url: "/cfg/accounts/profile/partial/",
1137
- ...options,
1138
- headers: {
1139
- "Content-Type": "application/json",
1140
- ...options?.headers
1141
- }
1142
- });
1143
- }
1144
- /**
1145
- * Partial update user profile
1146
- *
1147
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1148
- */
1149
- static cfgAccountsProfilePartialUpdate(options) {
1150
- return (options?.client ?? client).put({
1151
- security: [{ scheme: "bearer", type: "http" }, {
1152
- in: "cookie",
1153
- name: "sessionid",
1154
- type: "apiKey"
1155
- }],
1156
- url: "/cfg/accounts/profile/partial/",
1157
- ...options,
1158
- headers: {
1159
- "Content-Type": "application/json",
1160
- ...options?.headers
1161
- }
1162
- });
1163
- }
1164
- /**
1165
- * Update user profile
1166
- *
1167
- * Update the current authenticated user's profile information.
1168
- */
1169
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1170
- return (options?.client ?? client).patch({
1171
- security: [{ scheme: "bearer", type: "http" }, {
1172
- in: "cookie",
1173
- name: "sessionid",
1174
- type: "apiKey"
1175
- }],
1176
- url: "/cfg/accounts/profile/update/",
1177
- ...options,
1178
- headers: {
1179
- "Content-Type": "application/json",
1180
- ...options?.headers
1181
- }
1182
- });
1183
- }
1184
- /**
1185
- * Update user profile
1186
- *
1187
- * Update the current authenticated user's profile information.
1188
- */
1189
- static cfgAccountsProfileUpdateUpdate(options) {
1190
- return (options?.client ?? client).put({
1191
- security: [{ scheme: "bearer", type: "http" }, {
1192
- in: "cookie",
1193
- name: "sessionid",
1194
- type: "apiKey"
1195
- }],
1196
- url: "/cfg/accounts/profile/update/",
1197
- ...options,
1198
- headers: {
1199
- "Content-Type": "application/json",
1200
- ...options?.headers
1201
- }
1202
- });
1203
- }
1204
- /**
1205
- * Refresh JWT token.
1206
- */
1207
- static cfgAccountsTokenRefreshCreate(options) {
1208
- return (options.client ?? client).post({
1209
- url: "/cfg/accounts/token/refresh/",
1210
- ...options,
1211
- headers: {
1212
- "Content-Type": "application/json",
1213
- ...options.headers
1214
- }
1215
- });
1216
- }
1217
- };
1218
- var Accounts = class {
1219
- static {
1220
- __name(this, "Accounts");
1221
- }
1222
- /**
1223
- * List OAuth connections
1224
- *
1225
- * Get all OAuth connections for the current user.
1226
- */
1227
- static cfgAccountsOauthConnectionsList(options) {
1228
- return (options?.client ?? client).get({
1229
- security: [{ scheme: "bearer", type: "http" }],
1230
- url: "/cfg/accounts/oauth/connections/",
1231
- ...options
1232
- });
1233
- }
1234
- /**
1235
- * Disconnect OAuth provider
1236
- *
1237
- * Remove OAuth connection for the specified provider.
1238
- */
1239
- static cfgAccountsOauthDisconnectCreate(options) {
1240
- return (options.client ?? client).post({
1241
- security: [{ scheme: "bearer", type: "http" }],
1242
- url: "/cfg/accounts/oauth/disconnect/",
1243
- ...options,
1244
- headers: {
1245
- "Content-Type": "application/json",
1246
- ...options.headers
1247
- }
1248
- });
1249
- }
1250
- /**
1251
- * Start GitHub OAuth
1252
- *
1253
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1254
- */
1255
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1256
- return (options?.client ?? client).post({
1257
- url: "/cfg/accounts/oauth/github/authorize/",
1258
- ...options,
1259
- headers: {
1260
- "Content-Type": "application/json",
1261
- ...options?.headers
1262
- }
1263
- });
1264
- }
1265
- /**
1266
- * Complete GitHub OAuth
1267
- *
1268
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1269
- */
1270
- static cfgAccountsOauthGithubCallbackCreate(options) {
1271
- return (options.client ?? client).post({
1272
- url: "/cfg/accounts/oauth/github/callback/",
1273
- ...options,
1274
- headers: {
1275
- "Content-Type": "application/json",
1276
- ...options.headers
1277
- }
1278
- });
1279
- }
1280
- /**
1281
- * List OAuth providers
1282
- *
1283
- * Get list of available OAuth providers for authentication.
1284
- */
1285
- static cfgAccountsOauthProvidersRetrieve(options) {
1286
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1287
- }
1288
- /**
1289
- * Request OTP code to email.
1290
- */
1291
- static cfgAccountsOtpRequestCreate(options) {
1292
- return (options.client ?? client).post({
1293
- security: [{ scheme: "bearer", type: "http" }],
1294
- url: "/cfg/accounts/otp/request/",
1295
- ...options,
1296
- headers: {
1297
- "Content-Type": "application/json",
1298
- ...options.headers
1299
- }
1300
- });
1301
- }
1302
- /**
1303
- * Verify OTP code and return JWT tokens or 2FA session.
1304
- *
1305
- * If user has 2FA enabled:
1306
- * - Returns requires_2fa=True with session_id
1307
- * - Client must complete 2FA verification at /cfg/totp/verify/
1308
- *
1309
- * If user has no 2FA:
1310
- * - Returns JWT tokens and user data directly
1311
- */
1312
- static cfgAccountsOtpVerifyCreate(options) {
1313
- return (options.client ?? client).post({
1314
- security: [{ scheme: "bearer", type: "http" }],
1315
- url: "/cfg/accounts/otp/verify/",
1316
- ...options,
1317
- headers: {
1318
- "Content-Type": "application/json",
1319
- ...options.headers
1320
- }
1321
- });
1322
- }
1323
- /**
1324
- * Get current user profile
1325
- *
1326
- * Retrieve the current authenticated user's profile information.
1327
- */
1328
- static cfgAccountsProfileRetrieve(options) {
1329
- return (options?.client ?? client).get({
1330
- security: [{ scheme: "bearer", type: "http" }, {
1331
- in: "cookie",
1332
- name: "sessionid",
1333
- type: "apiKey"
1334
- }],
1335
- url: "/cfg/accounts/profile/",
1336
- ...options
1337
- });
1338
- }
1339
- /**
1340
- * Upload user avatar
1341
- *
1342
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1343
- */
1344
- static cfgAccountsProfileAvatarCreate(options) {
1345
- return (options?.client ?? client).post({
1346
- ...formDataBodySerializer,
1347
- security: [{ scheme: "bearer", type: "http" }],
1348
- url: "/cfg/accounts/profile/avatar/",
1349
- ...options,
1350
- headers: {
1351
- "Content-Type": null,
1352
- ...options?.headers
1353
- }
1354
- });
1355
- }
1356
- /**
1357
- * Delete user account
1358
- *
1359
- *
1360
- * Permanently delete the current user's account.
1361
- *
1362
- * This operation:
1363
- * - Deactivates the account (user cannot log in)
1364
- * - Anonymizes personal data (GDPR compliance)
1365
- * - Frees up the email address for re-registration
1366
- * - Preserves audit trail
1367
- *
1368
- * The account can be restored by an administrator if needed.
1369
- *
1370
- */
1371
- static cfgAccountsProfileDeleteCreate(options) {
1372
- return (options?.client ?? client).post({
1373
- security: [{ scheme: "bearer", type: "http" }, {
1374
- in: "cookie",
1375
- name: "sessionid",
1376
- type: "apiKey"
1377
- }],
1378
- url: "/cfg/accounts/profile/delete/",
1379
- ...options
1380
- });
1381
- }
1382
- /**
1383
- * Partial update user profile
1384
- *
1385
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1386
- */
1387
- static cfgAccountsProfilePartialPartialUpdate(options) {
1388
- return (options?.client ?? client).patch({
1389
- security: [{ scheme: "bearer", type: "http" }, {
1390
- in: "cookie",
1391
- name: "sessionid",
1392
- type: "apiKey"
1393
- }],
1394
- url: "/cfg/accounts/profile/partial/",
1395
- ...options,
1396
- headers: {
1397
- "Content-Type": "application/json",
1398
- ...options?.headers
1399
- }
1400
- });
1401
- }
1402
- /**
1403
- * Partial update user profile
1404
- *
1405
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1406
- */
1407
- static cfgAccountsProfilePartialUpdate(options) {
1408
- return (options?.client ?? client).put({
1409
- security: [{ scheme: "bearer", type: "http" }, {
1410
- in: "cookie",
1411
- name: "sessionid",
1412
- type: "apiKey"
1413
- }],
1414
- url: "/cfg/accounts/profile/partial/",
1415
- ...options,
1416
- headers: {
1417
- "Content-Type": "application/json",
1418
- ...options?.headers
1419
- }
1420
- });
1421
- }
1422
- /**
1423
- * Update user profile
1424
- *
1425
- * Update the current authenticated user's profile information.
1426
- */
1427
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1428
- return (options?.client ?? client).patch({
1429
- security: [{ scheme: "bearer", type: "http" }, {
1430
- in: "cookie",
1431
- name: "sessionid",
1432
- type: "apiKey"
1433
- }],
1434
- url: "/cfg/accounts/profile/update/",
1435
- ...options,
1436
- headers: {
1437
- "Content-Type": "application/json",
1438
- ...options?.headers
1439
- }
1440
- });
1441
- }
1442
- /**
1443
- * Update user profile
1444
- *
1445
- * Update the current authenticated user's profile information.
1446
- */
1447
- static cfgAccountsProfileUpdateUpdate(options) {
1448
- return (options?.client ?? client).put({
1449
- security: [{ scheme: "bearer", type: "http" }, {
1450
- in: "cookie",
1451
- name: "sessionid",
1452
- type: "apiKey"
1453
- }],
1454
- url: "/cfg/accounts/profile/update/",
1455
- ...options,
1456
- headers: {
1457
- "Content-Type": "application/json",
1458
- ...options?.headers
1459
- }
1460
- });
1461
- }
1462
- /**
1463
- * Refresh JWT token.
1464
- */
1465
- static cfgAccountsTokenRefreshCreate(options) {
1466
- return (options.client ?? client).post({
1467
- url: "/cfg/accounts/token/refresh/",
1468
- ...options,
1469
- headers: {
1470
- "Content-Type": "application/json",
1471
- ...options.headers
1472
- }
1473
- });
1474
- }
1475
- };
1476
- var OAuth = class {
1477
- static {
1478
- __name(this, "OAuth");
1479
- }
1480
- /**
1481
- * List OAuth connections
1482
- *
1483
- * Get all OAuth connections for the current user.
1484
- */
1485
- static cfgAccountsOauthConnectionsList(options) {
1486
- return (options?.client ?? client).get({
1487
- security: [{ scheme: "bearer", type: "http" }],
1488
- url: "/cfg/accounts/oauth/connections/",
1489
- ...options
1490
- });
1491
- }
1492
- /**
1493
- * Disconnect OAuth provider
1494
- *
1495
- * Remove OAuth connection for the specified provider.
1496
- */
1497
- static cfgAccountsOauthDisconnectCreate(options) {
1498
- return (options.client ?? client).post({
1499
- security: [{ scheme: "bearer", type: "http" }],
1500
- url: "/cfg/accounts/oauth/disconnect/",
1501
- ...options,
1502
- headers: {
1503
- "Content-Type": "application/json",
1504
- ...options.headers
1505
- }
1506
- });
1507
- }
1508
- /**
1509
- * Start GitHub OAuth
1510
- *
1511
- * Generate GitHub OAuth authorization URL. Redirect user to this URL to start authentication.
1512
- */
1513
- static cfgAccountsOauthGithubAuthorizeCreate(options) {
1514
- return (options?.client ?? client).post({
1515
- url: "/cfg/accounts/oauth/github/authorize/",
1516
- ...options,
1517
- headers: {
1518
- "Content-Type": "application/json",
1519
- ...options?.headers
1520
- }
1521
- });
1522
- }
1523
- /**
1524
- * Complete GitHub OAuth
1525
- *
1526
- * Exchange authorization code for JWT tokens. Call this after GitHub redirects back with code.
1527
- */
1528
- static cfgAccountsOauthGithubCallbackCreate(options) {
1529
- return (options.client ?? client).post({
1530
- url: "/cfg/accounts/oauth/github/callback/",
1531
- ...options,
1532
- headers: {
1533
- "Content-Type": "application/json",
1534
- ...options.headers
1535
- }
1536
- });
1537
- }
1538
- /**
1539
- * List OAuth providers
1540
- *
1541
- * Get list of available OAuth providers for authentication.
1542
- */
1543
- static cfgAccountsOauthProvidersRetrieve(options) {
1544
- return (options?.client ?? client).get({ url: "/cfg/accounts/oauth/providers/", ...options });
1545
- }
1546
- };
1547
- var UserProfile = class {
1548
- static {
1549
- __name(this, "UserProfile");
1550
- }
1551
- /**
1552
- * Get current user profile
1553
- *
1554
- * Retrieve the current authenticated user's profile information.
1555
- */
1556
- static cfgAccountsProfileRetrieve(options) {
1557
- return (options?.client ?? client).get({
1558
- security: [{ scheme: "bearer", type: "http" }, {
1559
- in: "cookie",
1560
- name: "sessionid",
1561
- type: "apiKey"
1562
- }],
1563
- url: "/cfg/accounts/profile/",
1564
- ...options
1565
- });
1566
- }
1567
- /**
1568
- * Upload user avatar
1569
- *
1570
- * Upload avatar image for the current authenticated user. Accepts multipart/form-data with 'avatar' field.
1571
- */
1572
- static cfgAccountsProfileAvatarCreate(options) {
1573
- return (options?.client ?? client).post({
1574
- ...formDataBodySerializer,
1575
- security: [{ scheme: "bearer", type: "http" }],
1576
- url: "/cfg/accounts/profile/avatar/",
1577
- ...options,
1578
- headers: {
1579
- "Content-Type": null,
1580
- ...options?.headers
1581
- }
1582
- });
1583
- }
1584
- /**
1585
- * Delete user account
1586
- *
1587
- *
1588
- * Permanently delete the current user's account.
1589
- *
1590
- * This operation:
1591
- * - Deactivates the account (user cannot log in)
1592
- * - Anonymizes personal data (GDPR compliance)
1593
- * - Frees up the email address for re-registration
1594
- * - Preserves audit trail
1595
- *
1596
- * The account can be restored by an administrator if needed.
1597
- *
1598
- */
1599
- static cfgAccountsProfileDeleteCreate(options) {
1600
- return (options?.client ?? client).post({
1601
- security: [{ scheme: "bearer", type: "http" }, {
1602
- in: "cookie",
1603
- name: "sessionid",
1604
- type: "apiKey"
1605
- }],
1606
- url: "/cfg/accounts/profile/delete/",
1607
- ...options
1608
- });
1609
- }
1610
- /**
1611
- * Partial update user profile
1612
- *
1613
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1614
- */
1615
- static cfgAccountsProfilePartialPartialUpdate(options) {
1616
- return (options?.client ?? client).patch({
1617
- security: [{ scheme: "bearer", type: "http" }, {
1618
- in: "cookie",
1619
- name: "sessionid",
1620
- type: "apiKey"
1621
- }],
1622
- url: "/cfg/accounts/profile/partial/",
1623
- ...options,
1624
- headers: {
1625
- "Content-Type": "application/json",
1626
- ...options?.headers
1627
- }
1628
- });
1629
- }
1630
- /**
1631
- * Partial update user profile
1632
- *
1633
- * Partially update the current authenticated user's profile information. Supports avatar upload.
1634
- */
1635
- static cfgAccountsProfilePartialUpdate(options) {
1636
- return (options?.client ?? client).put({
1637
- security: [{ scheme: "bearer", type: "http" }, {
1638
- in: "cookie",
1639
- name: "sessionid",
1640
- type: "apiKey"
1641
- }],
1642
- url: "/cfg/accounts/profile/partial/",
1643
- ...options,
1644
- headers: {
1645
- "Content-Type": "application/json",
1646
- ...options?.headers
1647
- }
1648
- });
1649
- }
1650
- /**
1651
- * Update user profile
1652
- *
1653
- * Update the current authenticated user's profile information.
1654
- */
1655
- static cfgAccountsProfileUpdatePartialUpdate(options) {
1656
- return (options?.client ?? client).patch({
1657
- security: [{ scheme: "bearer", type: "http" }, {
1658
- in: "cookie",
1659
- name: "sessionid",
1660
- type: "apiKey"
1661
- }],
1662
- url: "/cfg/accounts/profile/update/",
1663
- ...options,
1664
- headers: {
1665
- "Content-Type": "application/json",
1666
- ...options?.headers
1667
- }
1668
- });
1669
- }
1670
- /**
1671
- * Update user profile
1672
- *
1673
- * Update the current authenticated user's profile information.
1674
- */
1675
- static cfgAccountsProfileUpdateUpdate(options) {
1676
- return (options?.client ?? client).put({
1677
- security: [{ scheme: "bearer", type: "http" }, {
1678
- in: "cookie",
1679
- name: "sessionid",
1680
- type: "apiKey"
1681
- }],
1682
- url: "/cfg/accounts/profile/update/",
1683
- ...options,
1684
- headers: {
1685
- "Content-Type": "application/json",
1686
- ...options?.headers
1687
- }
1688
- });
1689
- }
1690
- };
1691
- var Auth = class {
1692
- static {
1693
- __name(this, "Auth");
1694
- }
1695
- /**
1696
- * Refresh JWT token.
1697
- */
1698
- static cfgAccountsTokenRefreshCreate(options) {
1699
- return (options.client ?? client).post({
1700
- url: "/cfg/accounts/token/refresh/",
1701
- ...options,
1702
- headers: {
1703
- "Content-Type": "application/json",
1704
- ...options.headers
1705
- }
1706
- });
1707
- }
1708
- };
1709
-
1710
- // src/_api/generated/cfg_accounts/schemas/AccountDeleteResponse.ts
1711
- import { z } from "zod";
1712
- var AccountDeleteResponseSchema = z.object({
1713
- success: z.boolean(),
1714
- message: z.string()
1715
- });
1716
-
1717
- // src/_api/generated/cfg_accounts/schemas/CentrifugoToken.ts
1718
- import { z as z2 } from "zod";
1719
- var CentrifugoTokenSchema = z2.object({
1720
- token: z2.string(),
1721
- centrifugo_url: z2.string(),
1722
- expires_at: z2.string().datetime({ offset: true }),
1723
- channels: z2.array(z2.string())
1724
- });
1725
-
1726
- // src/_api/generated/cfg_accounts/schemas/CfgUserUpdateRequest.ts
1727
- import { z as z3 } from "zod";
1728
- var CfgUserUpdateRequestSchema = z3.object({
1729
- first_name: z3.string().max(50).optional(),
1730
- last_name: z3.string().max(50).optional(),
1731
- company: z3.string().max(100).optional(),
1732
- phone: z3.string().max(20).optional(),
1733
- position: z3.string().max(100).optional(),
1734
- language: z3.string().max(10).optional()
1735
- });
1736
-
1737
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeRequestRequest.ts
1738
- import { z as z4 } from "zod";
1739
- var OAuthAuthorizeRequestRequestSchema = z4.object({
1740
- redirect_uri: z4.string().optional(),
1741
- source_url: z4.string().optional()
1742
- });
1743
-
1744
- // src/_api/generated/cfg_accounts/schemas/OAuthAuthorizeResponse.ts
1745
- import { z as z5 } from "zod";
1746
- var OAuthAuthorizeResponseSchema = z5.object({
1747
- authorization_url: z5.string(),
1748
- state: z5.string()
1749
- });
1750
-
1751
- // src/_api/generated/cfg_accounts/schemas/OAuthCallbackRequestRequest.ts
1752
- import { z as z6 } from "zod";
1753
- var OAuthCallbackRequestRequestSchema = z6.object({
1754
- code: z6.string().min(10).max(500),
1755
- state: z6.string().min(20).max(100),
1756
- redirect_uri: z6.string().optional()
1757
- });
1758
-
1759
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
1760
- import { z as z8 } from "zod";
1761
-
1762
- // src/_api/generated/cfg_accounts/schemas/ProviderEnum.ts
1763
- import { z as z7 } from "zod";
1764
- var ProviderEnumSchema = z7.enum(["github"]);
1765
-
1766
- // src/_api/generated/cfg_accounts/schemas/OAuthConnection.ts
1767
- var OAuthConnectionSchema = z8.object({
1768
- id: z8.number().int(),
1769
- provider: ProviderEnumSchema,
1770
- provider_display: z8.string(),
1771
- provider_username: z8.string(),
1772
- provider_email: z8.email(),
1773
- provider_avatar_url: z8.string(),
1774
- connected_at: z8.string().datetime({ offset: true }),
1775
- last_login_at: z8.string().datetime({ offset: true })
1776
- });
1777
-
1778
- // src/_api/generated/cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts
1779
- import { z as z9 } from "zod";
1780
- var OAuthDisconnectRequestRequestSchema = z9.object({
1781
- provider: ProviderEnumSchema
1782
- });
1783
-
1784
- // src/_api/generated/cfg_accounts/schemas/OAuthError.ts
1785
- import { z as z10 } from "zod";
1786
- var OAuthErrorSchema = z10.object({
1787
- error: z10.string(),
1788
- error_description: z10.string().optional()
1789
- });
1790
-
1791
- // src/_api/generated/cfg_accounts/schemas/OAuthProvidersResponse.ts
1792
- import { z as z11 } from "zod";
1793
- var OAuthProvidersResponseSchema = z11.object({
1794
- providers: z11.array(z11.object({}))
1795
- });
1796
-
1797
- // src/_api/generated/cfg_accounts/schemas/OAuthTokenResponse.ts
1798
- import { z as z12 } from "zod";
1799
- var OAuthTokenResponseSchema = z12.object({
1800
- requires_2fa: z12.boolean().optional(),
1801
- session_id: z12.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(),
1802
- access: z12.string().nullable().optional(),
1803
- refresh: z12.string().nullable().optional(),
1804
- user: z12.object({}).nullable().optional(),
1805
- is_new_user: z12.boolean(),
1806
- is_new_connection: z12.boolean(),
1807
- should_prompt_2fa: z12.boolean().optional()
1808
- });
1809
-
1810
- // src/_api/generated/cfg_accounts/schemas/OTPErrorResponse.ts
1811
- import { z as z13 } from "zod";
1812
- var OTPErrorResponseSchema = z13.object({
1813
- error: z13.string(),
1814
- error_code: z13.string().nullable().optional(),
1815
- retry_after: z13.number().int().nullable().optional()
1816
- });
1817
-
1818
- // src/_api/generated/cfg_accounts/schemas/OTPRequestRequest.ts
1819
- import { z as z14 } from "zod";
1820
- var OTPRequestRequestSchema = z14.object({
1821
- identifier: z14.string().min(1),
1822
- source_url: z14.string().optional()
1823
- });
1824
-
1825
- // src/_api/generated/cfg_accounts/schemas/OTPRequestResponse.ts
1826
- import { z as z15 } from "zod";
1827
- var OTPRequestResponseSchema = z15.object({
1828
- message: z15.string()
1829
- });
1830
-
1831
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyRequest.ts
1832
- import { z as z16 } from "zod";
1833
- var OTPVerifyRequestSchema = z16.object({
1834
- identifier: z16.string().min(1),
1835
- otp: z16.string().min(6).max(6),
1836
- source_url: z16.string().optional()
1837
- });
1838
-
1839
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
1840
- import { z as z18 } from "zod";
1841
-
1842
- // src/_api/generated/cfg_accounts/schemas/User.ts
1843
- import { z as z17 } from "zod";
1844
- var UserSchema = z17.object({
1845
- id: z17.number().int(),
1846
- email: z17.email(),
1847
- first_name: z17.string().max(50).optional(),
1848
- last_name: z17.string().max(50).optional(),
1849
- full_name: z17.string(),
1850
- initials: z17.string(),
1851
- display_username: z17.string(),
1852
- company: z17.string().max(100).optional(),
1853
- phone: z17.string().max(20).optional(),
1854
- position: z17.string().max(100).optional(),
1855
- language: z17.string().max(10).optional(),
1856
- avatar: z17.string().nullable(),
1857
- is_staff: z17.boolean(),
1858
- is_superuser: z17.boolean(),
1859
- date_joined: z17.string().datetime({ offset: true }),
1860
- last_login: z17.string().datetime({ offset: true }).nullable(),
1861
- unanswered_messages_count: z17.number().int(),
1862
- centrifugo: CentrifugoTokenSchema.nullable()
1863
- });
1864
-
1865
- // src/_api/generated/cfg_accounts/schemas/OTPVerifyResponse.ts
1866
- var OTPVerifyResponseSchema = z18.object({
1867
- requires_2fa: z18.boolean().optional(),
1868
- session_id: z18.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(),
1869
- refresh: z18.string().nullable().optional(),
1870
- access: z18.string().nullable().optional(),
1871
- user: UserSchema.nullable().optional(),
1872
- should_prompt_2fa: z18.boolean().optional()
1873
- });
1874
-
1875
- // src/_api/generated/cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts
1876
- import { z as z19 } from "zod";
1877
- var PatchedCfgUserUpdateRequestSchema = z19.object({
1878
- first_name: z19.string().max(50).optional(),
1879
- last_name: z19.string().max(50).optional(),
1880
- company: z19.string().max(100).optional(),
1881
- phone: z19.string().max(20).optional(),
1882
- position: z19.string().max(100).optional(),
1883
- language: z19.string().max(10).optional()
1884
- });
1885
-
1886
- // src/_api/generated/cfg_accounts/schemas/TokenRefresh.ts
1887
- import { z as z20 } from "zod";
1888
- var TokenRefreshSchema = z20.object({
1889
- access: z20.string(),
1890
- refresh: z20.string()
1891
- });
1892
-
1893
- // src/_api/generated/cfg_accounts/schemas/TokenRefreshRequest.ts
1894
- import { z as z21 } from "zod";
1895
- var TokenRefreshRequestSchema = z21.object({
1896
- refresh: z21.string().min(1)
1897
- });
1898
-
1899
- // src/_api/generated/_shared/validation-events.ts
1900
- function dispatchValidationError(detail) {
1901
- if (typeof window === "undefined") return;
1902
- try {
1903
- const event = new CustomEvent("zod-validation-error", {
1904
- detail,
1905
- bubbles: true,
1906
- cancelable: false
1907
- });
1908
- window.dispatchEvent(event);
1909
- } catch (error) {
1910
- console.warn("Failed to dispatch validation error event:", error);
1911
- }
1912
- }
1913
- __name(dispatchValidationError, "dispatchValidationError");
1914
-
1915
- // src/_api/generated/cfg_accounts/api.ts
934
+ // src/_api/generated/_cfg_accounts/api.ts
1916
935
  var ACCESS_KEY = "cfg.access_token";
1917
936
  var REFRESH_KEY = "cfg.refresh_token";
1918
- var VALIDATION_ROUTES = [
1919
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/authorize/?$"), schema: OAuthAuthorizeResponseSchema, path: "/cfg/accounts/oauth/github/authorize/" },
1920
- { method: "POST", re: new RegExp("^/cfg/accounts/oauth/github/callback/?$"), schema: OAuthTokenResponseSchema, path: "/cfg/accounts/oauth/github/callback/" },
1921
- { method: "GET", re: new RegExp("^/cfg/accounts/oauth/providers/?$"), schema: OAuthProvidersResponseSchema, path: "/cfg/accounts/oauth/providers/" },
1922
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/request/?$"), schema: OTPRequestResponseSchema, path: "/cfg/accounts/otp/request/" },
1923
- { method: "POST", re: new RegExp("^/cfg/accounts/otp/verify/?$"), schema: OTPVerifyResponseSchema, path: "/cfg/accounts/otp/verify/" },
1924
- { method: "GET", re: new RegExp("^/cfg/accounts/profile/?$"), schema: UserSchema, path: "/cfg/accounts/profile/" },
1925
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/avatar/?$"), schema: UserSchema, path: "/cfg/accounts/profile/avatar/" },
1926
- { method: "POST", re: new RegExp("^/cfg/accounts/profile/delete/?$"), schema: AccountDeleteResponseSchema, path: "/cfg/accounts/profile/delete/" },
1927
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
1928
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/partial/?$"), schema: UserSchema, path: "/cfg/accounts/profile/partial/" },
1929
- { method: "PUT", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
1930
- { method: "PATCH", re: new RegExp("^/cfg/accounts/profile/update/?$"), schema: UserSchema, path: "/cfg/accounts/profile/update/" },
1931
- { method: "POST", re: new RegExp("^/cfg/accounts/token/refresh/?$"), schema: TokenRefreshSchema, path: "/cfg/accounts/token/refresh/" }
1932
- ];
1933
937
  function detectLocale() {
1934
938
  try {
1935
939
  if (typeof document !== "undefined") {
@@ -1953,11 +957,6 @@ var API = class {
1953
957
  locale;
1954
958
  apiKey;
1955
959
  logger;
1956
- cfg = Cfg;
1957
- accounts = Accounts;
1958
- oAuth = OAuth;
1959
- userProfile = UserProfile;
1960
- auth = Auth;
1961
960
  constructor(baseUrl2, opts = {}) {
1962
961
  this.baseUrl = baseUrl2.replace(/\/$/, "");
1963
962
  this.storage = opts.storage ?? new LocalStorageAdapter();
@@ -1974,35 +973,6 @@ var API = class {
1974
973
  if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1975
974
  return request;
1976
975
  });
1977
- client.interceptors.response.use(async (response, request) => {
1978
- if (!response.ok) return response;
1979
- const ct = response.headers.get("content-type") || "";
1980
- if (!ct.includes("application/json")) return response;
1981
- const url = new URL(request.url);
1982
- const method = request.method.toUpperCase();
1983
- const route = VALIDATION_ROUTES.find(
1984
- (r) => r.method === method && r.re.test(url.pathname)
1985
- );
1986
- if (!route) return response;
1987
- let payload;
1988
- try {
1989
- payload = await response.clone().json();
1990
- } catch {
1991
- return response;
1992
- }
1993
- const result = route.schema.safeParse(payload);
1994
- if (!result.success) {
1995
- dispatchValidationError({
1996
- operation: `${method} ${route.path}`,
1997
- path: route.path,
1998
- method,
1999
- error: result.error,
2000
- response: payload,
2001
- timestamp: /* @__PURE__ */ new Date()
2002
- });
2003
- }
2004
- return response;
2005
- });
2006
976
  }
2007
977
  // ── Base URL ────────────────────────────────────────────────────────────
2008
978
  getBaseUrl() {
@@ -2049,2338 +1019,97 @@ var API = class {
2049
1019
  }
2050
1020
  };
2051
1021
 
2052
- // src/_api/generated/cfg_centrifugo/core/bodySerializer.gen.ts
2053
- var jsonBodySerializer2 = {
2054
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
2055
- };
2056
-
2057
- // src/_api/generated/cfg_centrifugo/core/params.gen.ts
2058
- var extraPrefixesMap2 = {
2059
- $body_: "body",
2060
- $headers_: "headers",
2061
- $path_: "path",
2062
- $query_: "query"
2063
- };
2064
- var extraPrefixes2 = Object.entries(extraPrefixesMap2);
2065
-
2066
- // src/_api/generated/cfg_centrifugo/core/serverSentEvents.gen.ts
2067
- function createSseClient2({
2068
- onRequest,
2069
- onSseError,
2070
- onSseEvent,
2071
- responseTransformer,
2072
- responseValidator,
2073
- sseDefaultRetryDelay,
2074
- sseMaxRetryAttempts,
2075
- sseMaxRetryDelay,
2076
- sseSleepFn,
2077
- url,
2078
- ...options
2079
- }) {
2080
- let lastEventId;
2081
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
2082
- const createStream = /* @__PURE__ */ __name(async function* () {
2083
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
2084
- let attempt = 0;
2085
- const signal = options.signal ?? new AbortController().signal;
2086
- while (true) {
2087
- if (signal.aborted) break;
2088
- attempt++;
2089
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
2090
- if (lastEventId !== void 0) {
2091
- headers.set("Last-Event-ID", lastEventId);
2092
- }
2093
- try {
2094
- const requestInit = {
2095
- redirect: "follow",
2096
- ...options,
2097
- body: options.serializedBody,
2098
- headers,
2099
- signal
2100
- };
2101
- let request = new Request(url, requestInit);
2102
- if (onRequest) {
2103
- request = await onRequest(url, requestInit);
2104
- }
2105
- const _fetch = options.fetch ?? globalThis.fetch;
2106
- const response = await _fetch(request);
2107
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
2108
- if (!response.body) throw new Error("No body in SSE response");
2109
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
2110
- let buffer = "";
2111
- const abortHandler = /* @__PURE__ */ __name(() => {
2112
- try {
2113
- reader.cancel();
2114
- } catch {
2115
- }
2116
- }, "abortHandler");
2117
- signal.addEventListener("abort", abortHandler);
2118
- try {
2119
- while (true) {
2120
- const { done, value } = await reader.read();
2121
- if (done) break;
2122
- buffer += value;
2123
- buffer = buffer.replace(/\r\n?/g, "\n");
2124
- const chunks = buffer.split("\n\n");
2125
- buffer = chunks.pop() ?? "";
2126
- for (const chunk of chunks) {
2127
- const lines = chunk.split("\n");
2128
- const dataLines = [];
2129
- let eventName;
2130
- for (const line of lines) {
2131
- if (line.startsWith("data:")) {
2132
- dataLines.push(line.replace(/^data:\s*/, ""));
2133
- } else if (line.startsWith("event:")) {
2134
- eventName = line.replace(/^event:\s*/, "");
2135
- } else if (line.startsWith("id:")) {
2136
- lastEventId = line.replace(/^id:\s*/, "");
2137
- } else if (line.startsWith("retry:")) {
2138
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
2139
- if (!Number.isNaN(parsed)) {
2140
- retryDelay = parsed;
2141
- }
2142
- }
2143
- }
2144
- let data;
2145
- let parsedJson = false;
2146
- if (dataLines.length) {
2147
- const rawData = dataLines.join("\n");
2148
- try {
2149
- data = JSON.parse(rawData);
2150
- parsedJson = true;
2151
- } catch {
2152
- data = rawData;
2153
- }
2154
- }
2155
- if (parsedJson) {
2156
- if (responseValidator) {
2157
- await responseValidator(data);
2158
- }
2159
- if (responseTransformer) {
2160
- data = await responseTransformer(data);
2161
- }
2162
- }
2163
- onSseEvent?.({
2164
- data,
2165
- event: eventName,
2166
- id: lastEventId,
2167
- retry: retryDelay
2168
- });
2169
- if (dataLines.length) {
2170
- yield data;
2171
- }
2172
- }
2173
- }
2174
- } finally {
2175
- signal.removeEventListener("abort", abortHandler);
2176
- reader.releaseLock();
2177
- }
2178
- break;
2179
- } catch (error) {
2180
- onSseError?.(error);
2181
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
2182
- break;
2183
- }
2184
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
2185
- await sleep(backoff);
2186
- }
2187
- }
2188
- }, "createStream");
2189
- const stream = createStream();
2190
- return { stream };
2191
- }
2192
- __name(createSseClient2, "createSseClient");
2193
-
2194
- // src/_api/generated/cfg_centrifugo/core/pathSerializer.gen.ts
2195
- var separatorArrayExplode2 = /* @__PURE__ */ __name((style) => {
2196
- switch (style) {
2197
- case "label":
2198
- return ".";
2199
- case "matrix":
2200
- return ";";
2201
- case "simple":
2202
- return ",";
2203
- default:
2204
- return "&";
2205
- }
2206
- }, "separatorArrayExplode");
2207
- var separatorArrayNoExplode2 = /* @__PURE__ */ __name((style) => {
2208
- switch (style) {
2209
- case "form":
2210
- return ",";
2211
- case "pipeDelimited":
2212
- return "|";
2213
- case "spaceDelimited":
2214
- return "%20";
2215
- default:
2216
- return ",";
2217
- }
2218
- }, "separatorArrayNoExplode");
2219
- var separatorObjectExplode2 = /* @__PURE__ */ __name((style) => {
2220
- switch (style) {
2221
- case "label":
2222
- return ".";
2223
- case "matrix":
2224
- return ";";
2225
- case "simple":
2226
- return ",";
2227
- default:
2228
- return "&";
2229
- }
2230
- }, "separatorObjectExplode");
2231
- var serializeArrayParam2 = /* @__PURE__ */ __name(({
2232
- allowReserved,
2233
- explode,
2234
- name,
2235
- style,
2236
- value
2237
- }) => {
2238
- if (!explode) {
2239
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode2(style));
2240
- switch (style) {
2241
- case "label":
2242
- return `.${joinedValues2}`;
2243
- case "matrix":
2244
- return `;${name}=${joinedValues2}`;
2245
- case "simple":
2246
- return joinedValues2;
2247
- default:
2248
- return `${name}=${joinedValues2}`;
2249
- }
2250
- }
2251
- const separator = separatorArrayExplode2(style);
2252
- const joinedValues = value.map((v) => {
2253
- if (style === "label" || style === "simple") {
2254
- return allowReserved ? v : encodeURIComponent(v);
2255
- }
2256
- return serializePrimitiveParam2({
2257
- allowReserved,
2258
- name,
2259
- value: v
2260
- });
2261
- }).join(separator);
2262
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2263
- }, "serializeArrayParam");
2264
- var serializePrimitiveParam2 = /* @__PURE__ */ __name(({
2265
- allowReserved,
2266
- name,
2267
- value
2268
- }) => {
2269
- if (value === void 0 || value === null) {
2270
- return "";
2271
- }
2272
- if (typeof value === "object") {
2273
- throw new Error(
2274
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
2275
- );
2276
- }
2277
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
2278
- }, "serializePrimitiveParam");
2279
- var serializeObjectParam2 = /* @__PURE__ */ __name(({
2280
- allowReserved,
2281
- explode,
2282
- name,
2283
- style,
2284
- value,
2285
- valueOnly
2286
- }) => {
2287
- if (value instanceof Date) {
2288
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
2289
- }
2290
- if (style !== "deepObject" && !explode) {
2291
- let values = [];
2292
- Object.entries(value).forEach(([key, v]) => {
2293
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
2294
- });
2295
- const joinedValues2 = values.join(",");
2296
- switch (style) {
2297
- case "form":
2298
- return `${name}=${joinedValues2}`;
2299
- case "label":
2300
- return `.${joinedValues2}`;
2301
- case "matrix":
2302
- return `;${name}=${joinedValues2}`;
2303
- default:
2304
- return joinedValues2;
2305
- }
2306
- }
2307
- const separator = separatorObjectExplode2(style);
2308
- const joinedValues = Object.entries(value).map(
2309
- ([key, v]) => serializePrimitiveParam2({
2310
- allowReserved,
2311
- name: style === "deepObject" ? `${name}[${key}]` : key,
2312
- value: v
2313
- })
2314
- ).join(separator);
2315
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
2316
- }, "serializeObjectParam");
2317
-
2318
- // src/_api/generated/cfg_centrifugo/core/utils.gen.ts
2319
- var PATH_PARAM_RE2 = /\{[^{}]+\}/g;
2320
- var defaultPathSerializer2 = /* @__PURE__ */ __name(({ path, url: _url }) => {
2321
- let url = _url;
2322
- const matches = _url.match(PATH_PARAM_RE2);
2323
- if (matches) {
2324
- for (const match of matches) {
2325
- let explode = false;
2326
- let name = match.substring(1, match.length - 1);
2327
- let style = "simple";
2328
- if (name.endsWith("*")) {
2329
- explode = true;
2330
- name = name.substring(0, name.length - 1);
2331
- }
2332
- if (name.startsWith(".")) {
2333
- name = name.substring(1);
2334
- style = "label";
2335
- } else if (name.startsWith(";")) {
2336
- name = name.substring(1);
2337
- style = "matrix";
2338
- }
2339
- const value = path[name];
2340
- if (value === void 0 || value === null) {
2341
- continue;
2342
- }
2343
- if (Array.isArray(value)) {
2344
- url = url.replace(match, serializeArrayParam2({ explode, name, style, value }));
2345
- continue;
2346
- }
2347
- if (typeof value === "object") {
2348
- url = url.replace(
2349
- match,
2350
- serializeObjectParam2({
2351
- explode,
2352
- name,
2353
- style,
2354
- value,
2355
- valueOnly: true
2356
- })
2357
- );
2358
- continue;
2359
- }
2360
- if (style === "matrix") {
2361
- url = url.replace(
2362
- match,
2363
- `;${serializePrimitiveParam2({
2364
- name,
2365
- value
2366
- })}`
2367
- );
2368
- continue;
2369
- }
2370
- const replaceValue = encodeURIComponent(
2371
- style === "label" ? `.${value}` : value
2372
- );
2373
- url = url.replace(match, replaceValue);
2374
- }
2375
- }
2376
- return url;
2377
- }, "defaultPathSerializer");
2378
- var getUrl2 = /* @__PURE__ */ __name(({
2379
- baseUrl: baseUrl2,
2380
- path,
2381
- query,
2382
- querySerializer,
2383
- url: _url
2384
- }) => {
2385
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
2386
- let url = (baseUrl2 ?? "") + pathUrl;
2387
- if (path) {
2388
- url = defaultPathSerializer2({ path, url });
2389
- }
2390
- let search = query ? querySerializer(query) : "";
2391
- if (search.startsWith("?")) {
2392
- search = search.substring(1);
2393
- }
2394
- if (search) {
2395
- url += `?${search}`;
2396
- }
2397
- return url;
2398
- }, "getUrl");
2399
- function getValidRequestBody2(options) {
2400
- const hasBody = options.body !== void 0;
2401
- const isSerializedBody = hasBody && options.bodySerializer;
2402
- if (isSerializedBody) {
2403
- if ("serializedBody" in options) {
2404
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
2405
- return hasSerializedBody ? options.serializedBody : null;
2406
- }
2407
- return options.body !== "" ? options.body : null;
2408
- }
2409
- if (hasBody) {
2410
- return options.body;
2411
- }
2412
- return void 0;
2413
- }
2414
- __name(getValidRequestBody2, "getValidRequestBody");
2415
-
2416
- // src/_api/generated/cfg_centrifugo/core/auth.gen.ts
2417
- var getAuthToken2 = /* @__PURE__ */ __name(async (auth, callback) => {
2418
- const token = typeof callback === "function" ? await callback(auth) : callback;
2419
- if (!token) {
2420
- return;
2421
- }
2422
- if (auth.scheme === "bearer") {
2423
- return `Bearer ${token}`;
2424
- }
2425
- if (auth.scheme === "basic") {
2426
- return `Basic ${btoa(token)}`;
2427
- }
2428
- return token;
2429
- }, "getAuthToken");
2430
-
2431
- // src/_api/generated/cfg_centrifugo/client/utils.gen.ts
2432
- var createQuerySerializer2 = /* @__PURE__ */ __name(({
2433
- parameters = {},
2434
- ...args
2435
- } = {}) => {
2436
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
2437
- const search = [];
2438
- if (queryParams && typeof queryParams === "object") {
2439
- for (const name in queryParams) {
2440
- const value = queryParams[name];
2441
- if (value === void 0 || value === null) {
2442
- continue;
2443
- }
2444
- const options = parameters[name] || args;
2445
- if (Array.isArray(value)) {
2446
- const serializedArray = serializeArrayParam2({
2447
- allowReserved: options.allowReserved,
2448
- explode: true,
2449
- name,
2450
- style: "form",
2451
- value,
2452
- ...options.array
2453
- });
2454
- if (serializedArray) search.push(serializedArray);
2455
- } else if (typeof value === "object") {
2456
- const serializedObject = serializeObjectParam2({
2457
- allowReserved: options.allowReserved,
2458
- explode: true,
2459
- name,
2460
- style: "deepObject",
2461
- value,
2462
- ...options.object
2463
- });
2464
- if (serializedObject) search.push(serializedObject);
2465
- } else {
2466
- const serializedPrimitive = serializePrimitiveParam2({
2467
- allowReserved: options.allowReserved,
2468
- name,
2469
- value
2470
- });
2471
- if (serializedPrimitive) search.push(serializedPrimitive);
2472
- }
2473
- }
2474
- }
2475
- return search.join("&");
2476
- }, "querySerializer");
2477
- return querySerializer;
2478
- }, "createQuerySerializer");
2479
- var getParseAs2 = /* @__PURE__ */ __name((contentType) => {
2480
- if (!contentType) {
2481
- return "stream";
2482
- }
2483
- const cleanContent = contentType.split(";")[0]?.trim();
2484
- if (!cleanContent) {
2485
- return;
2486
- }
2487
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
2488
- return "json";
2489
- }
2490
- if (cleanContent === "multipart/form-data") {
2491
- return "formData";
2492
- }
2493
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
2494
- return "blob";
2495
- }
2496
- if (cleanContent.startsWith("text/")) {
2497
- return "text";
2498
- }
2499
- return;
2500
- }, "getParseAs");
2501
- var checkForExistence2 = /* @__PURE__ */ __name((options, name) => {
2502
- if (!name) {
2503
- return false;
2504
- }
2505
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
2506
- return true;
2507
- }
2508
- return false;
2509
- }, "checkForExistence");
2510
- var setAuthParams2 = /* @__PURE__ */ __name(async ({
2511
- security,
2512
- ...options
2513
- }) => {
2514
- for (const auth of security) {
2515
- if (checkForExistence2(options, auth.name)) {
2516
- continue;
2517
- }
2518
- const token = await getAuthToken2(auth, options.auth);
2519
- if (!token) {
2520
- continue;
2521
- }
2522
- const name = auth.name ?? "Authorization";
2523
- switch (auth.in) {
2524
- case "query":
2525
- if (!options.query) {
2526
- options.query = {};
2527
- }
2528
- options.query[name] = token;
2529
- break;
2530
- case "cookie":
2531
- options.headers.append("Cookie", `${name}=${token}`);
2532
- break;
2533
- case "header":
2534
- default:
2535
- options.headers.set(name, token);
2536
- break;
2537
- }
2538
- }
2539
- }, "setAuthParams");
2540
- var buildUrl2 = /* @__PURE__ */ __name((options) => getUrl2({
2541
- baseUrl: options.baseUrl,
2542
- path: options.path,
2543
- query: options.query,
2544
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer2(options.querySerializer),
2545
- url: options.url
2546
- }), "buildUrl");
2547
- var mergeConfigs2 = /* @__PURE__ */ __name((a, b) => {
2548
- const config = { ...a, ...b };
2549
- if (config.baseUrl?.endsWith("/")) {
2550
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
2551
- }
2552
- config.headers = mergeHeaders2(a.headers, b.headers);
2553
- return config;
2554
- }, "mergeConfigs");
2555
- var headersEntries2 = /* @__PURE__ */ __name((headers) => {
2556
- const entries = [];
2557
- headers.forEach((value, key) => {
2558
- entries.push([key, value]);
2559
- });
2560
- return entries;
2561
- }, "headersEntries");
2562
- var mergeHeaders2 = /* @__PURE__ */ __name((...headers) => {
2563
- const mergedHeaders = new Headers();
2564
- for (const header of headers) {
2565
- if (!header) {
2566
- continue;
2567
- }
2568
- const iterator = header instanceof Headers ? headersEntries2(header) : Object.entries(header);
2569
- for (const [key, value] of iterator) {
2570
- if (value === null) {
2571
- mergedHeaders.delete(key);
2572
- } else if (Array.isArray(value)) {
2573
- for (const v of value) {
2574
- mergedHeaders.append(key, v);
2575
- }
2576
- } else if (value !== void 0) {
2577
- mergedHeaders.set(
2578
- key,
2579
- typeof value === "object" ? JSON.stringify(value) : value
2580
- );
2581
- }
2582
- }
2583
- }
2584
- return mergedHeaders;
2585
- }, "mergeHeaders");
2586
- var Interceptors2 = class {
2587
- static {
2588
- __name(this, "Interceptors");
2589
- }
2590
- fns = [];
2591
- clear() {
2592
- this.fns = [];
2593
- }
2594
- eject(id) {
2595
- const index = this.getInterceptorIndex(id);
2596
- if (this.fns[index]) {
2597
- this.fns[index] = null;
2598
- }
2599
- }
2600
- exists(id) {
2601
- const index = this.getInterceptorIndex(id);
2602
- return Boolean(this.fns[index]);
2603
- }
2604
- getInterceptorIndex(id) {
2605
- if (typeof id === "number") {
2606
- return this.fns[id] ? id : -1;
2607
- }
2608
- return this.fns.indexOf(id);
2609
- }
2610
- update(id, fn) {
2611
- const index = this.getInterceptorIndex(id);
2612
- if (this.fns[index]) {
2613
- this.fns[index] = fn;
2614
- return id;
2615
- }
2616
- return false;
2617
- }
2618
- use(fn) {
2619
- this.fns.push(fn);
2620
- return this.fns.length - 1;
2621
- }
2622
- };
2623
- var createInterceptors2 = /* @__PURE__ */ __name(() => ({
2624
- error: new Interceptors2(),
2625
- request: new Interceptors2(),
2626
- response: new Interceptors2()
2627
- }), "createInterceptors");
2628
- var defaultQuerySerializer2 = createQuerySerializer2({
2629
- allowReserved: false,
2630
- array: {
2631
- explode: true,
2632
- style: "form"
2633
- },
2634
- object: {
2635
- explode: true,
2636
- style: "deepObject"
2637
- }
2638
- });
2639
- var defaultHeaders2 = {
2640
- "Content-Type": "application/json"
2641
- };
2642
- var createConfig2 = /* @__PURE__ */ __name((override = {}) => ({
2643
- ...jsonBodySerializer2,
2644
- headers: defaultHeaders2,
2645
- parseAs: "auto",
2646
- querySerializer: defaultQuerySerializer2,
2647
- ...override
2648
- }), "createConfig");
2649
-
2650
- // src/_api/generated/cfg_centrifugo/client/client.gen.ts
2651
- var createClient2 = /* @__PURE__ */ __name((config = {}) => {
2652
- let _config = mergeConfigs2(createConfig2(), config);
2653
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
2654
- const setConfig = /* @__PURE__ */ __name((config2) => {
2655
- _config = mergeConfigs2(_config, config2);
2656
- return getConfig();
2657
- }, "setConfig");
2658
- const interceptors = createInterceptors2();
2659
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
2660
- const opts = {
2661
- ..._config,
2662
- ...options,
2663
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
2664
- headers: mergeHeaders2(_config.headers, options.headers),
2665
- serializedBody: void 0
2666
- };
2667
- if (opts.security) {
2668
- await setAuthParams2({
2669
- ...opts,
2670
- security: opts.security
2671
- });
2672
- }
2673
- if (opts.requestValidator) {
2674
- await opts.requestValidator(opts);
2675
- }
2676
- if (opts.body !== void 0 && opts.bodySerializer) {
2677
- opts.serializedBody = opts.bodySerializer(opts.body);
2678
- }
2679
- if (opts.body === void 0 || opts.serializedBody === "") {
2680
- opts.headers.delete("Content-Type");
2681
- }
2682
- const resolvedOpts = opts;
2683
- const url = buildUrl2(resolvedOpts);
2684
- return { opts: resolvedOpts, url };
2685
- }, "beforeRequest");
2686
- const request = /* @__PURE__ */ __name(async (options) => {
2687
- const throwOnError = options.throwOnError ?? _config.throwOnError;
2688
- const responseStyle = options.responseStyle ?? _config.responseStyle;
2689
- let request2;
2690
- let response;
2691
- try {
2692
- const { opts, url } = await beforeRequest(options);
2693
- const requestInit = {
2694
- redirect: "follow",
2695
- ...opts,
2696
- body: getValidRequestBody2(opts)
2697
- };
2698
- request2 = new Request(url, requestInit);
2699
- for (const fn of interceptors.request.fns) {
2700
- if (fn) {
2701
- request2 = await fn(request2, opts);
2702
- }
2703
- }
2704
- const _fetch = opts.fetch;
2705
- response = await _fetch(request2);
2706
- for (const fn of interceptors.response.fns) {
2707
- if (fn) {
2708
- response = await fn(response, request2, opts);
2709
- }
2710
- }
2711
- const result = {
2712
- request: request2,
2713
- response
2714
- };
2715
- if (response.ok) {
2716
- const parseAs = (opts.parseAs === "auto" ? getParseAs2(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
2717
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
2718
- let emptyData;
2719
- switch (parseAs) {
2720
- case "arrayBuffer":
2721
- case "blob":
2722
- case "text":
2723
- emptyData = await response[parseAs]();
2724
- break;
2725
- case "formData":
2726
- emptyData = new FormData();
2727
- break;
2728
- case "stream":
2729
- emptyData = response.body;
2730
- break;
2731
- case "json":
2732
- default:
2733
- emptyData = {};
2734
- break;
2735
- }
2736
- return opts.responseStyle === "data" ? emptyData : {
2737
- data: emptyData,
2738
- ...result
2739
- };
2740
- }
2741
- let data;
2742
- switch (parseAs) {
2743
- case "arrayBuffer":
2744
- case "blob":
2745
- case "formData":
2746
- case "text":
2747
- data = await response[parseAs]();
2748
- break;
2749
- case "json": {
2750
- const text = await response.text();
2751
- data = text ? JSON.parse(text) : {};
2752
- break;
2753
- }
2754
- case "stream":
2755
- return opts.responseStyle === "data" ? response.body : {
2756
- data: response.body,
2757
- ...result
2758
- };
2759
- }
2760
- if (parseAs === "json") {
2761
- if (opts.responseValidator) {
2762
- await opts.responseValidator(data);
2763
- }
2764
- if (opts.responseTransformer) {
2765
- data = await opts.responseTransformer(data);
2766
- }
2767
- }
2768
- return opts.responseStyle === "data" ? data : {
2769
- data,
2770
- ...result
2771
- };
2772
- }
2773
- const textError = await response.text();
2774
- let jsonError;
2775
- try {
2776
- jsonError = JSON.parse(textError);
2777
- } catch {
2778
- }
2779
- throw jsonError ?? textError;
2780
- } catch (error) {
2781
- let finalError = error;
2782
- for (const fn of interceptors.error.fns) {
2783
- if (fn) {
2784
- finalError = await fn(finalError, response, request2, options);
2785
- }
2786
- }
2787
- finalError = finalError || {};
2788
- if (throwOnError) {
2789
- throw finalError;
2790
- }
2791
- return responseStyle === "data" ? void 0 : {
2792
- error: finalError,
2793
- request: request2,
2794
- response
2795
- };
2796
- }
2797
- }, "request");
2798
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
2799
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
2800
- const { opts, url } = await beforeRequest(options);
2801
- return createSseClient2({
2802
- ...opts,
2803
- body: opts.body,
2804
- method,
2805
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
2806
- let request2 = new Request(url2, init);
2807
- for (const fn of interceptors.request.fns) {
2808
- if (fn) {
2809
- request2 = await fn(request2, opts);
2810
- }
2811
- }
2812
- return request2;
2813
- }, "onRequest"),
2814
- serializedBody: getValidRequestBody2(opts),
2815
- url
2816
- });
2817
- }, "makeSseFn");
2818
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl2({ ..._config, ...options }), "_buildUrl");
2819
- return {
2820
- buildUrl: _buildUrl,
2821
- connect: makeMethodFn("CONNECT"),
2822
- delete: makeMethodFn("DELETE"),
2823
- get: makeMethodFn("GET"),
2824
- getConfig,
2825
- head: makeMethodFn("HEAD"),
2826
- interceptors,
2827
- options: makeMethodFn("OPTIONS"),
2828
- patch: makeMethodFn("PATCH"),
2829
- post: makeMethodFn("POST"),
2830
- put: makeMethodFn("PUT"),
2831
- request,
2832
- setConfig,
2833
- sse: {
2834
- connect: makeSseFn("CONNECT"),
2835
- delete: makeSseFn("DELETE"),
2836
- get: makeSseFn("GET"),
2837
- head: makeSseFn("HEAD"),
2838
- options: makeSseFn("OPTIONS"),
2839
- patch: makeSseFn("PATCH"),
2840
- post: makeSseFn("POST"),
2841
- put: makeSseFn("PUT"),
2842
- trace: makeSseFn("TRACE")
2843
- },
2844
- trace: makeMethodFn("TRACE")
2845
- };
2846
- }, "createClient");
2847
-
2848
- // src/_api/generated/cfg_centrifugo/client.gen.ts
2849
- var client2 = createClient2(createConfig2({ baseUrl: "http://localhost:8000" }));
2850
-
2851
- // src/_api/generated/cfg_centrifugo/sdk.gen.ts
2852
- var Cfg2 = class {
2853
- static {
2854
- __name(this, "Cfg");
2855
- }
2856
- /**
2857
- * Get Centrifugo connection token
2858
- *
2859
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2860
- */
2861
- static cfgCentrifugoAuthTokenRetrieve(options) {
2862
- return (options?.client ?? client2).get({
2863
- security: [{ scheme: "bearer", type: "http" }],
2864
- url: "/cfg/centrifugo/auth/token/",
2865
- ...options
2866
- });
2867
- }
2868
- };
2869
- var Centrifugo = class {
2870
- static {
2871
- __name(this, "Centrifugo");
2872
- }
2873
- /**
2874
- * Get Centrifugo connection token
2875
- *
2876
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2877
- */
2878
- static cfgCentrifugoAuthTokenRetrieve(options) {
2879
- return (options?.client ?? client2).get({
2880
- security: [{ scheme: "bearer", type: "http" }],
2881
- url: "/cfg/centrifugo/auth/token/",
2882
- ...options
2883
- });
2884
- }
2885
- };
2886
- var CentrifugoAuth = class {
2887
- static {
2888
- __name(this, "CentrifugoAuth");
2889
- }
2890
- /**
2891
- * Get Centrifugo connection token
2892
- *
2893
- * Generate JWT token for WebSocket connection to Centrifugo. Token includes user's allowed channels based on their permissions. Requires authentication.
2894
- */
2895
- static cfgCentrifugoAuthTokenRetrieve(options) {
2896
- return (options?.client ?? client2).get({
2897
- security: [{ scheme: "bearer", type: "http" }],
2898
- url: "/cfg/centrifugo/auth/token/",
2899
- ...options
2900
- });
2901
- }
2902
- };
2903
-
2904
- // src/_api/generated/cfg_centrifugo/schemas/ConnectionTokenResponse.ts
2905
- import { z as z22 } from "zod";
2906
- var ConnectionTokenResponseSchema = z22.object({
2907
- token: z22.string(),
2908
- centrifugo_url: z22.string(),
2909
- expires_at: z22.string(),
2910
- channels: z22.array(z22.string())
2911
- });
2912
-
2913
- // src/_api/generated/cfg_centrifugo/api.ts
2914
- var ACCESS_KEY2 = "cfg.access_token";
2915
- var REFRESH_KEY2 = "cfg.refresh_token";
2916
- var VALIDATION_ROUTES2 = [
2917
- { method: "GET", re: new RegExp("^/cfg/centrifugo/auth/token/?$"), schema: ConnectionTokenResponseSchema, path: "/cfg/centrifugo/auth/token/" }
2918
- ];
2919
- function detectLocale2() {
2920
- try {
2921
- if (typeof document !== "undefined") {
2922
- const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
2923
- if (m) return decodeURIComponent(m[1]);
2924
- }
2925
- if (typeof navigator !== "undefined" && navigator.language) {
2926
- return navigator.language;
2927
- }
2928
- } catch {
2929
- }
2930
- return null;
2931
- }
2932
- __name(detectLocale2, "detectLocale");
2933
- var API2 = class {
2934
- static {
2935
- __name(this, "API");
2936
- }
2937
- baseUrl;
2938
- storage;
2939
- locale;
2940
- apiKey;
2941
- logger;
2942
- cfg = Cfg2;
2943
- centrifugo = Centrifugo;
2944
- centrifugoAuth = CentrifugoAuth;
2945
- constructor(baseUrl2, opts = {}) {
2946
- this.baseUrl = baseUrl2.replace(/\/$/, "");
2947
- this.storage = opts.storage ?? new LocalStorageAdapter();
2948
- this.logger = new APILogger(opts.logger);
2949
- this.locale = opts.locale ?? null;
2950
- this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
2951
- const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
2952
- client2.setConfig({ baseUrl: this.baseUrl, credentials });
2953
- client2.interceptors.request.use((request) => {
2954
- const access = this.getToken();
2955
- if (access) request.headers.set("Authorization", `Bearer ${access}`);
2956
- const locale = this.locale ?? detectLocale2();
2957
- if (locale) request.headers.set("Accept-Language", locale);
2958
- if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
2959
- return request;
2960
- });
2961
- client2.interceptors.response.use(async (response, request) => {
2962
- if (!response.ok) return response;
2963
- const ct = response.headers.get("content-type") || "";
2964
- if (!ct.includes("application/json")) return response;
2965
- const url = new URL(request.url);
2966
- const method = request.method.toUpperCase();
2967
- const route = VALIDATION_ROUTES2.find(
2968
- (r) => r.method === method && r.re.test(url.pathname)
2969
- );
2970
- if (!route) return response;
2971
- let payload;
2972
- try {
2973
- payload = await response.clone().json();
2974
- } catch {
2975
- return response;
2976
- }
2977
- const result = route.schema.safeParse(payload);
2978
- if (!result.success) {
2979
- dispatchValidationError({
2980
- operation: `${method} ${route.path}`,
2981
- path: route.path,
2982
- method,
2983
- error: result.error,
2984
- response: payload,
2985
- timestamp: /* @__PURE__ */ new Date()
2986
- });
2987
- }
2988
- return response;
2989
- });
2990
- }
2991
- // ── Base URL ────────────────────────────────────────────────────────────
2992
- getBaseUrl() {
2993
- return this.baseUrl;
2994
- }
2995
- setBaseUrl(url) {
2996
- this.baseUrl = url.replace(/\/$/, "");
2997
- client2.setConfig({ baseUrl: this.baseUrl });
2998
- }
2999
- // ── Tokens ──────────────────────────────────────────────────────────────
3000
- getToken() {
3001
- return this.storage.getItem(ACCESS_KEY2);
3002
- }
3003
- setToken(token) {
3004
- if (token) this.storage.setItem(ACCESS_KEY2, token);
3005
- else this.storage.removeItem(ACCESS_KEY2);
3006
- }
3007
- getRefreshToken() {
3008
- return this.storage.getItem(REFRESH_KEY2);
3009
- }
3010
- setRefreshToken(token) {
3011
- if (token) this.storage.setItem(REFRESH_KEY2, token);
3012
- else this.storage.removeItem(REFRESH_KEY2);
3013
- }
3014
- clearToken() {
3015
- this.storage.removeItem(ACCESS_KEY2);
3016
- this.storage.removeItem(REFRESH_KEY2);
3017
- }
3018
- isAuthenticated() {
3019
- return this.getToken() !== null;
3020
- }
3021
- // ── Locale / API key ────────────────────────────────────────────────────
3022
- getLocale() {
3023
- return this.locale ?? detectLocale2();
3024
- }
3025
- setLocale(locale) {
3026
- this.locale = locale;
3027
- }
3028
- getApiKey() {
3029
- return this.apiKey;
3030
- }
3031
- setApiKey(key) {
3032
- this.apiKey = key;
3033
- }
3034
- };
3035
-
3036
- // src/_api/generated/cfg_totp/core/bodySerializer.gen.ts
3037
- var jsonBodySerializer3 = {
3038
- bodySerializer: /* @__PURE__ */ __name((body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value), "bodySerializer")
3039
- };
3040
-
3041
- // src/_api/generated/cfg_totp/core/params.gen.ts
3042
- var extraPrefixesMap3 = {
3043
- $body_: "body",
3044
- $headers_: "headers",
3045
- $path_: "path",
3046
- $query_: "query"
3047
- };
3048
- var extraPrefixes3 = Object.entries(extraPrefixesMap3);
3049
-
3050
- // src/_api/generated/cfg_totp/core/serverSentEvents.gen.ts
3051
- function createSseClient3({
3052
- onRequest,
3053
- onSseError,
3054
- onSseEvent,
3055
- responseTransformer,
3056
- responseValidator,
3057
- sseDefaultRetryDelay,
3058
- sseMaxRetryAttempts,
3059
- sseMaxRetryDelay,
3060
- sseSleepFn,
3061
- url,
3062
- ...options
3063
- }) {
3064
- let lastEventId;
3065
- const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
3066
- const createStream = /* @__PURE__ */ __name(async function* () {
3067
- let retryDelay = sseDefaultRetryDelay ?? 3e3;
3068
- let attempt = 0;
3069
- const signal = options.signal ?? new AbortController().signal;
3070
- while (true) {
3071
- if (signal.aborted) break;
3072
- attempt++;
3073
- const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
3074
- if (lastEventId !== void 0) {
3075
- headers.set("Last-Event-ID", lastEventId);
3076
- }
3077
- try {
3078
- const requestInit = {
3079
- redirect: "follow",
3080
- ...options,
3081
- body: options.serializedBody,
3082
- headers,
3083
- signal
3084
- };
3085
- let request = new Request(url, requestInit);
3086
- if (onRequest) {
3087
- request = await onRequest(url, requestInit);
3088
- }
3089
- const _fetch = options.fetch ?? globalThis.fetch;
3090
- const response = await _fetch(request);
3091
- if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
3092
- if (!response.body) throw new Error("No body in SSE response");
3093
- const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
3094
- let buffer = "";
3095
- const abortHandler = /* @__PURE__ */ __name(() => {
3096
- try {
3097
- reader.cancel();
3098
- } catch {
3099
- }
3100
- }, "abortHandler");
3101
- signal.addEventListener("abort", abortHandler);
3102
- try {
3103
- while (true) {
3104
- const { done, value } = await reader.read();
3105
- if (done) break;
3106
- buffer += value;
3107
- buffer = buffer.replace(/\r\n?/g, "\n");
3108
- const chunks = buffer.split("\n\n");
3109
- buffer = chunks.pop() ?? "";
3110
- for (const chunk of chunks) {
3111
- const lines = chunk.split("\n");
3112
- const dataLines = [];
3113
- let eventName;
3114
- for (const line of lines) {
3115
- if (line.startsWith("data:")) {
3116
- dataLines.push(line.replace(/^data:\s*/, ""));
3117
- } else if (line.startsWith("event:")) {
3118
- eventName = line.replace(/^event:\s*/, "");
3119
- } else if (line.startsWith("id:")) {
3120
- lastEventId = line.replace(/^id:\s*/, "");
3121
- } else if (line.startsWith("retry:")) {
3122
- const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
3123
- if (!Number.isNaN(parsed)) {
3124
- retryDelay = parsed;
3125
- }
3126
- }
3127
- }
3128
- let data;
3129
- let parsedJson = false;
3130
- if (dataLines.length) {
3131
- const rawData = dataLines.join("\n");
3132
- try {
3133
- data = JSON.parse(rawData);
3134
- parsedJson = true;
3135
- } catch {
3136
- data = rawData;
3137
- }
3138
- }
3139
- if (parsedJson) {
3140
- if (responseValidator) {
3141
- await responseValidator(data);
3142
- }
3143
- if (responseTransformer) {
3144
- data = await responseTransformer(data);
3145
- }
3146
- }
3147
- onSseEvent?.({
3148
- data,
3149
- event: eventName,
3150
- id: lastEventId,
3151
- retry: retryDelay
3152
- });
3153
- if (dataLines.length) {
3154
- yield data;
3155
- }
3156
- }
3157
- }
3158
- } finally {
3159
- signal.removeEventListener("abort", abortHandler);
3160
- reader.releaseLock();
3161
- }
3162
- break;
3163
- } catch (error) {
3164
- onSseError?.(error);
3165
- if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
3166
- break;
3167
- }
3168
- const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
3169
- await sleep(backoff);
3170
- }
3171
- }
3172
- }, "createStream");
3173
- const stream = createStream();
3174
- return { stream };
3175
- }
3176
- __name(createSseClient3, "createSseClient");
3177
-
3178
- // src/_api/generated/cfg_totp/core/pathSerializer.gen.ts
3179
- var separatorArrayExplode3 = /* @__PURE__ */ __name((style) => {
3180
- switch (style) {
3181
- case "label":
3182
- return ".";
3183
- case "matrix":
3184
- return ";";
3185
- case "simple":
3186
- return ",";
3187
- default:
3188
- return "&";
3189
- }
3190
- }, "separatorArrayExplode");
3191
- var separatorArrayNoExplode3 = /* @__PURE__ */ __name((style) => {
3192
- switch (style) {
3193
- case "form":
3194
- return ",";
3195
- case "pipeDelimited":
3196
- return "|";
3197
- case "spaceDelimited":
3198
- return "%20";
3199
- default:
3200
- return ",";
3201
- }
3202
- }, "separatorArrayNoExplode");
3203
- var separatorObjectExplode3 = /* @__PURE__ */ __name((style) => {
3204
- switch (style) {
3205
- case "label":
3206
- return ".";
3207
- case "matrix":
3208
- return ";";
3209
- case "simple":
3210
- return ",";
3211
- default:
3212
- return "&";
3213
- }
3214
- }, "separatorObjectExplode");
3215
- var serializeArrayParam3 = /* @__PURE__ */ __name(({
3216
- allowReserved,
3217
- explode,
3218
- name,
3219
- style,
3220
- value
3221
- }) => {
3222
- if (!explode) {
3223
- const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode3(style));
3224
- switch (style) {
3225
- case "label":
3226
- return `.${joinedValues2}`;
3227
- case "matrix":
3228
- return `;${name}=${joinedValues2}`;
3229
- case "simple":
3230
- return joinedValues2;
3231
- default:
3232
- return `${name}=${joinedValues2}`;
3233
- }
3234
- }
3235
- const separator = separatorArrayExplode3(style);
3236
- const joinedValues = value.map((v) => {
3237
- if (style === "label" || style === "simple") {
3238
- return allowReserved ? v : encodeURIComponent(v);
3239
- }
3240
- return serializePrimitiveParam3({
3241
- allowReserved,
3242
- name,
3243
- value: v
3244
- });
3245
- }).join(separator);
3246
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3247
- }, "serializeArrayParam");
3248
- var serializePrimitiveParam3 = /* @__PURE__ */ __name(({
3249
- allowReserved,
3250
- name,
3251
- value
3252
- }) => {
3253
- if (value === void 0 || value === null) {
3254
- return "";
3255
- }
3256
- if (typeof value === "object") {
3257
- throw new Error(
3258
- "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
3259
- );
3260
- }
3261
- return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
3262
- }, "serializePrimitiveParam");
3263
- var serializeObjectParam3 = /* @__PURE__ */ __name(({
3264
- allowReserved,
3265
- explode,
3266
- name,
3267
- style,
3268
- value,
3269
- valueOnly
3270
- }) => {
3271
- if (value instanceof Date) {
3272
- return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
3273
- }
3274
- if (style !== "deepObject" && !explode) {
3275
- let values = [];
3276
- Object.entries(value).forEach(([key, v]) => {
3277
- values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
3278
- });
3279
- const joinedValues2 = values.join(",");
3280
- switch (style) {
3281
- case "form":
3282
- return `${name}=${joinedValues2}`;
3283
- case "label":
3284
- return `.${joinedValues2}`;
3285
- case "matrix":
3286
- return `;${name}=${joinedValues2}`;
3287
- default:
3288
- return joinedValues2;
3289
- }
3290
- }
3291
- const separator = separatorObjectExplode3(style);
3292
- const joinedValues = Object.entries(value).map(
3293
- ([key, v]) => serializePrimitiveParam3({
3294
- allowReserved,
3295
- name: style === "deepObject" ? `${name}[${key}]` : key,
3296
- value: v
3297
- })
3298
- ).join(separator);
3299
- return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
3300
- }, "serializeObjectParam");
3301
-
3302
- // src/_api/generated/cfg_totp/core/utils.gen.ts
3303
- var PATH_PARAM_RE3 = /\{[^{}]+\}/g;
3304
- var defaultPathSerializer3 = /* @__PURE__ */ __name(({ path, url: _url }) => {
3305
- let url = _url;
3306
- const matches = _url.match(PATH_PARAM_RE3);
3307
- if (matches) {
3308
- for (const match of matches) {
3309
- let explode = false;
3310
- let name = match.substring(1, match.length - 1);
3311
- let style = "simple";
3312
- if (name.endsWith("*")) {
3313
- explode = true;
3314
- name = name.substring(0, name.length - 1);
3315
- }
3316
- if (name.startsWith(".")) {
3317
- name = name.substring(1);
3318
- style = "label";
3319
- } else if (name.startsWith(";")) {
3320
- name = name.substring(1);
3321
- style = "matrix";
3322
- }
3323
- const value = path[name];
3324
- if (value === void 0 || value === null) {
3325
- continue;
3326
- }
3327
- if (Array.isArray(value)) {
3328
- url = url.replace(match, serializeArrayParam3({ explode, name, style, value }));
3329
- continue;
3330
- }
3331
- if (typeof value === "object") {
3332
- url = url.replace(
3333
- match,
3334
- serializeObjectParam3({
3335
- explode,
3336
- name,
3337
- style,
3338
- value,
3339
- valueOnly: true
3340
- })
3341
- );
3342
- continue;
3343
- }
3344
- if (style === "matrix") {
3345
- url = url.replace(
3346
- match,
3347
- `;${serializePrimitiveParam3({
3348
- name,
3349
- value
3350
- })}`
3351
- );
3352
- continue;
3353
- }
3354
- const replaceValue = encodeURIComponent(
3355
- style === "label" ? `.${value}` : value
3356
- );
3357
- url = url.replace(match, replaceValue);
3358
- }
3359
- }
3360
- return url;
3361
- }, "defaultPathSerializer");
3362
- var getUrl3 = /* @__PURE__ */ __name(({
3363
- baseUrl: baseUrl2,
3364
- path,
3365
- query,
3366
- querySerializer,
3367
- url: _url
3368
- }) => {
3369
- const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
3370
- let url = (baseUrl2 ?? "") + pathUrl;
3371
- if (path) {
3372
- url = defaultPathSerializer3({ path, url });
3373
- }
3374
- let search = query ? querySerializer(query) : "";
3375
- if (search.startsWith("?")) {
3376
- search = search.substring(1);
3377
- }
3378
- if (search) {
3379
- url += `?${search}`;
3380
- }
3381
- return url;
3382
- }, "getUrl");
3383
- function getValidRequestBody3(options) {
3384
- const hasBody = options.body !== void 0;
3385
- const isSerializedBody = hasBody && options.bodySerializer;
3386
- if (isSerializedBody) {
3387
- if ("serializedBody" in options) {
3388
- const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
3389
- return hasSerializedBody ? options.serializedBody : null;
3390
- }
3391
- return options.body !== "" ? options.body : null;
3392
- }
3393
- if (hasBody) {
3394
- return options.body;
3395
- }
3396
- return void 0;
3397
- }
3398
- __name(getValidRequestBody3, "getValidRequestBody");
3399
-
3400
- // src/_api/generated/cfg_totp/core/auth.gen.ts
3401
- var getAuthToken3 = /* @__PURE__ */ __name(async (auth, callback) => {
3402
- const token = typeof callback === "function" ? await callback(auth) : callback;
3403
- if (!token) {
3404
- return;
3405
- }
3406
- if (auth.scheme === "bearer") {
3407
- return `Bearer ${token}`;
3408
- }
3409
- if (auth.scheme === "basic") {
3410
- return `Basic ${btoa(token)}`;
3411
- }
3412
- return token;
3413
- }, "getAuthToken");
3414
-
3415
- // src/_api/generated/cfg_totp/client/utils.gen.ts
3416
- var createQuerySerializer3 = /* @__PURE__ */ __name(({
3417
- parameters = {},
3418
- ...args
3419
- } = {}) => {
3420
- const querySerializer = /* @__PURE__ */ __name((queryParams) => {
3421
- const search = [];
3422
- if (queryParams && typeof queryParams === "object") {
3423
- for (const name in queryParams) {
3424
- const value = queryParams[name];
3425
- if (value === void 0 || value === null) {
3426
- continue;
3427
- }
3428
- const options = parameters[name] || args;
3429
- if (Array.isArray(value)) {
3430
- const serializedArray = serializeArrayParam3({
3431
- allowReserved: options.allowReserved,
3432
- explode: true,
3433
- name,
3434
- style: "form",
3435
- value,
3436
- ...options.array
3437
- });
3438
- if (serializedArray) search.push(serializedArray);
3439
- } else if (typeof value === "object") {
3440
- const serializedObject = serializeObjectParam3({
3441
- allowReserved: options.allowReserved,
3442
- explode: true,
3443
- name,
3444
- style: "deepObject",
3445
- value,
3446
- ...options.object
3447
- });
3448
- if (serializedObject) search.push(serializedObject);
3449
- } else {
3450
- const serializedPrimitive = serializePrimitiveParam3({
3451
- allowReserved: options.allowReserved,
3452
- name,
3453
- value
3454
- });
3455
- if (serializedPrimitive) search.push(serializedPrimitive);
3456
- }
3457
- }
3458
- }
3459
- return search.join("&");
3460
- }, "querySerializer");
3461
- return querySerializer;
3462
- }, "createQuerySerializer");
3463
- var getParseAs3 = /* @__PURE__ */ __name((contentType) => {
3464
- if (!contentType) {
3465
- return "stream";
3466
- }
3467
- const cleanContent = contentType.split(";")[0]?.trim();
3468
- if (!cleanContent) {
3469
- return;
3470
- }
3471
- if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
3472
- return "json";
3473
- }
3474
- if (cleanContent === "multipart/form-data") {
3475
- return "formData";
3476
- }
3477
- if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
3478
- return "blob";
3479
- }
3480
- if (cleanContent.startsWith("text/")) {
3481
- return "text";
3482
- }
3483
- return;
3484
- }, "getParseAs");
3485
- var checkForExistence3 = /* @__PURE__ */ __name((options, name) => {
3486
- if (!name) {
3487
- return false;
3488
- }
3489
- if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
3490
- return true;
3491
- }
3492
- return false;
3493
- }, "checkForExistence");
3494
- var setAuthParams3 = /* @__PURE__ */ __name(async ({
3495
- security,
3496
- ...options
3497
- }) => {
3498
- for (const auth of security) {
3499
- if (checkForExistence3(options, auth.name)) {
3500
- continue;
3501
- }
3502
- const token = await getAuthToken3(auth, options.auth);
3503
- if (!token) {
3504
- continue;
3505
- }
3506
- const name = auth.name ?? "Authorization";
3507
- switch (auth.in) {
3508
- case "query":
3509
- if (!options.query) {
3510
- options.query = {};
3511
- }
3512
- options.query[name] = token;
3513
- break;
3514
- case "cookie":
3515
- options.headers.append("Cookie", `${name}=${token}`);
3516
- break;
3517
- case "header":
3518
- default:
3519
- options.headers.set(name, token);
3520
- break;
3521
- }
3522
- }
3523
- }, "setAuthParams");
3524
- var buildUrl3 = /* @__PURE__ */ __name((options) => getUrl3({
3525
- baseUrl: options.baseUrl,
3526
- path: options.path,
3527
- query: options.query,
3528
- querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer3(options.querySerializer),
3529
- url: options.url
3530
- }), "buildUrl");
3531
- var mergeConfigs3 = /* @__PURE__ */ __name((a, b) => {
3532
- const config = { ...a, ...b };
3533
- if (config.baseUrl?.endsWith("/")) {
3534
- config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
3535
- }
3536
- config.headers = mergeHeaders3(a.headers, b.headers);
3537
- return config;
3538
- }, "mergeConfigs");
3539
- var headersEntries3 = /* @__PURE__ */ __name((headers) => {
3540
- const entries = [];
3541
- headers.forEach((value, key) => {
3542
- entries.push([key, value]);
3543
- });
3544
- return entries;
3545
- }, "headersEntries");
3546
- var mergeHeaders3 = /* @__PURE__ */ __name((...headers) => {
3547
- const mergedHeaders = new Headers();
3548
- for (const header of headers) {
3549
- if (!header) {
3550
- continue;
3551
- }
3552
- const iterator = header instanceof Headers ? headersEntries3(header) : Object.entries(header);
3553
- for (const [key, value] of iterator) {
3554
- if (value === null) {
3555
- mergedHeaders.delete(key);
3556
- } else if (Array.isArray(value)) {
3557
- for (const v of value) {
3558
- mergedHeaders.append(key, v);
3559
- }
3560
- } else if (value !== void 0) {
3561
- mergedHeaders.set(
3562
- key,
3563
- typeof value === "object" ? JSON.stringify(value) : value
3564
- );
3565
- }
3566
- }
3567
- }
3568
- return mergedHeaders;
3569
- }, "mergeHeaders");
3570
- var Interceptors3 = class {
3571
- static {
3572
- __name(this, "Interceptors");
3573
- }
3574
- fns = [];
3575
- clear() {
3576
- this.fns = [];
3577
- }
3578
- eject(id) {
3579
- const index = this.getInterceptorIndex(id);
3580
- if (this.fns[index]) {
3581
- this.fns[index] = null;
3582
- }
3583
- }
3584
- exists(id) {
3585
- const index = this.getInterceptorIndex(id);
3586
- return Boolean(this.fns[index]);
3587
- }
3588
- getInterceptorIndex(id) {
3589
- if (typeof id === "number") {
3590
- return this.fns[id] ? id : -1;
3591
- }
3592
- return this.fns.indexOf(id);
3593
- }
3594
- update(id, fn) {
3595
- const index = this.getInterceptorIndex(id);
3596
- if (this.fns[index]) {
3597
- this.fns[index] = fn;
3598
- return id;
3599
- }
3600
- return false;
3601
- }
3602
- use(fn) {
3603
- this.fns.push(fn);
3604
- return this.fns.length - 1;
3605
- }
3606
- };
3607
- var createInterceptors3 = /* @__PURE__ */ __name(() => ({
3608
- error: new Interceptors3(),
3609
- request: new Interceptors3(),
3610
- response: new Interceptors3()
3611
- }), "createInterceptors");
3612
- var defaultQuerySerializer3 = createQuerySerializer3({
3613
- allowReserved: false,
3614
- array: {
3615
- explode: true,
3616
- style: "form"
3617
- },
3618
- object: {
3619
- explode: true,
3620
- style: "deepObject"
3621
- }
3622
- });
3623
- var defaultHeaders3 = {
3624
- "Content-Type": "application/json"
3625
- };
3626
- var createConfig3 = /* @__PURE__ */ __name((override = {}) => ({
3627
- ...jsonBodySerializer3,
3628
- headers: defaultHeaders3,
3629
- parseAs: "auto",
3630
- querySerializer: defaultQuerySerializer3,
3631
- ...override
3632
- }), "createConfig");
3633
-
3634
- // src/_api/generated/cfg_totp/client/client.gen.ts
3635
- var createClient3 = /* @__PURE__ */ __name((config = {}) => {
3636
- let _config = mergeConfigs3(createConfig3(), config);
3637
- const getConfig = /* @__PURE__ */ __name(() => ({ ..._config }), "getConfig");
3638
- const setConfig = /* @__PURE__ */ __name((config2) => {
3639
- _config = mergeConfigs3(_config, config2);
3640
- return getConfig();
3641
- }, "setConfig");
3642
- const interceptors = createInterceptors3();
3643
- const beforeRequest = /* @__PURE__ */ __name(async (options) => {
3644
- const opts = {
3645
- ..._config,
3646
- ...options,
3647
- fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
3648
- headers: mergeHeaders3(_config.headers, options.headers),
3649
- serializedBody: void 0
3650
- };
3651
- if (opts.security) {
3652
- await setAuthParams3({
3653
- ...opts,
3654
- security: opts.security
3655
- });
3656
- }
3657
- if (opts.requestValidator) {
3658
- await opts.requestValidator(opts);
3659
- }
3660
- if (opts.body !== void 0 && opts.bodySerializer) {
3661
- opts.serializedBody = opts.bodySerializer(opts.body);
3662
- }
3663
- if (opts.body === void 0 || opts.serializedBody === "") {
3664
- opts.headers.delete("Content-Type");
3665
- }
3666
- const resolvedOpts = opts;
3667
- const url = buildUrl3(resolvedOpts);
3668
- return { opts: resolvedOpts, url };
3669
- }, "beforeRequest");
3670
- const request = /* @__PURE__ */ __name(async (options) => {
3671
- const throwOnError = options.throwOnError ?? _config.throwOnError;
3672
- const responseStyle = options.responseStyle ?? _config.responseStyle;
3673
- let request2;
3674
- let response;
3675
- try {
3676
- const { opts, url } = await beforeRequest(options);
3677
- const requestInit = {
3678
- redirect: "follow",
3679
- ...opts,
3680
- body: getValidRequestBody3(opts)
3681
- };
3682
- request2 = new Request(url, requestInit);
3683
- for (const fn of interceptors.request.fns) {
3684
- if (fn) {
3685
- request2 = await fn(request2, opts);
3686
- }
3687
- }
3688
- const _fetch = opts.fetch;
3689
- response = await _fetch(request2);
3690
- for (const fn of interceptors.response.fns) {
3691
- if (fn) {
3692
- response = await fn(response, request2, opts);
3693
- }
3694
- }
3695
- const result = {
3696
- request: request2,
3697
- response
3698
- };
3699
- if (response.ok) {
3700
- const parseAs = (opts.parseAs === "auto" ? getParseAs3(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
3701
- if (response.status === 204 || response.headers.get("Content-Length") === "0") {
3702
- let emptyData;
3703
- switch (parseAs) {
3704
- case "arrayBuffer":
3705
- case "blob":
3706
- case "text":
3707
- emptyData = await response[parseAs]();
3708
- break;
3709
- case "formData":
3710
- emptyData = new FormData();
3711
- break;
3712
- case "stream":
3713
- emptyData = response.body;
3714
- break;
3715
- case "json":
3716
- default:
3717
- emptyData = {};
3718
- break;
3719
- }
3720
- return opts.responseStyle === "data" ? emptyData : {
3721
- data: emptyData,
3722
- ...result
3723
- };
3724
- }
3725
- let data;
3726
- switch (parseAs) {
3727
- case "arrayBuffer":
3728
- case "blob":
3729
- case "formData":
3730
- case "text":
3731
- data = await response[parseAs]();
3732
- break;
3733
- case "json": {
3734
- const text = await response.text();
3735
- data = text ? JSON.parse(text) : {};
3736
- break;
3737
- }
3738
- case "stream":
3739
- return opts.responseStyle === "data" ? response.body : {
3740
- data: response.body,
3741
- ...result
3742
- };
3743
- }
3744
- if (parseAs === "json") {
3745
- if (opts.responseValidator) {
3746
- await opts.responseValidator(data);
3747
- }
3748
- if (opts.responseTransformer) {
3749
- data = await opts.responseTransformer(data);
3750
- }
3751
- }
3752
- return opts.responseStyle === "data" ? data : {
3753
- data,
3754
- ...result
3755
- };
3756
- }
3757
- const textError = await response.text();
3758
- let jsonError;
3759
- try {
3760
- jsonError = JSON.parse(textError);
3761
- } catch {
3762
- }
3763
- throw jsonError ?? textError;
3764
- } catch (error) {
3765
- let finalError = error;
3766
- for (const fn of interceptors.error.fns) {
3767
- if (fn) {
3768
- finalError = await fn(finalError, response, request2, options);
3769
- }
3770
- }
3771
- finalError = finalError || {};
3772
- if (throwOnError) {
3773
- throw finalError;
3774
- }
3775
- return responseStyle === "data" ? void 0 : {
3776
- error: finalError,
3777
- request: request2,
3778
- response
3779
- };
1022
+ // src/_api/generated/_cfg_centrifugo/api.ts
1023
+ var ACCESS_KEY2 = "cfg.access_token";
1024
+ var REFRESH_KEY2 = "cfg.refresh_token";
1025
+ function detectLocale2() {
1026
+ try {
1027
+ if (typeof document !== "undefined") {
1028
+ const m = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
1029
+ if (m) return decodeURIComponent(m[1]);
3780
1030
  }
3781
- }, "request");
3782
- const makeMethodFn = /* @__PURE__ */ __name((method) => (options) => request({ ...options, method }), "makeMethodFn");
3783
- const makeSseFn = /* @__PURE__ */ __name((method) => async (options) => {
3784
- const { opts, url } = await beforeRequest(options);
3785
- return createSseClient3({
3786
- ...opts,
3787
- body: opts.body,
3788
- method,
3789
- onRequest: /* @__PURE__ */ __name(async (url2, init) => {
3790
- let request2 = new Request(url2, init);
3791
- for (const fn of interceptors.request.fns) {
3792
- if (fn) {
3793
- request2 = await fn(request2, opts);
3794
- }
3795
- }
3796
- return request2;
3797
- }, "onRequest"),
3798
- serializedBody: getValidRequestBody3(opts),
3799
- url
3800
- });
3801
- }, "makeSseFn");
3802
- const _buildUrl = /* @__PURE__ */ __name((options) => buildUrl3({ ..._config, ...options }), "_buildUrl");
3803
- return {
3804
- buildUrl: _buildUrl,
3805
- connect: makeMethodFn("CONNECT"),
3806
- delete: makeMethodFn("DELETE"),
3807
- get: makeMethodFn("GET"),
3808
- getConfig,
3809
- head: makeMethodFn("HEAD"),
3810
- interceptors,
3811
- options: makeMethodFn("OPTIONS"),
3812
- patch: makeMethodFn("PATCH"),
3813
- post: makeMethodFn("POST"),
3814
- put: makeMethodFn("PUT"),
3815
- request,
3816
- setConfig,
3817
- sse: {
3818
- connect: makeSseFn("CONNECT"),
3819
- delete: makeSseFn("DELETE"),
3820
- get: makeSseFn("GET"),
3821
- head: makeSseFn("HEAD"),
3822
- options: makeSseFn("OPTIONS"),
3823
- patch: makeSseFn("PATCH"),
3824
- post: makeSseFn("POST"),
3825
- put: makeSseFn("PUT"),
3826
- trace: makeSseFn("TRACE")
3827
- },
3828
- trace: makeMethodFn("TRACE")
3829
- };
3830
- }, "createClient");
3831
-
3832
- // src/_api/generated/cfg_totp/client.gen.ts
3833
- var client3 = createClient3(createConfig3({ baseUrl: "http://localhost:8000" }));
3834
-
3835
- // src/_api/generated/cfg_totp/sdk.gen.ts
3836
- var Cfg3 = class {
3837
- static {
3838
- __name(this, "Cfg");
3839
- }
3840
- /**
3841
- * Get backup codes status for user.
3842
- */
3843
- static cfgTotpBackupCodesRetrieve(options) {
3844
- return (options?.client ?? client3).get({
3845
- security: [{ scheme: "bearer", type: "http" }],
3846
- url: "/cfg/totp/backup-codes/",
3847
- ...options
3848
- });
3849
- }
3850
- /**
3851
- * Regenerate backup codes.
3852
- *
3853
- * Requires TOTP code for verification.
3854
- * Invalidates all existing codes.
3855
- */
3856
- static cfgTotpBackupCodesRegenerateCreate(options) {
3857
- return (options.client ?? client3).post({
3858
- security: [{ scheme: "bearer", type: "http" }],
3859
- url: "/cfg/totp/backup-codes/regenerate/",
3860
- ...options,
3861
- headers: {
3862
- "Content-Type": "application/json",
3863
- ...options.headers
3864
- }
3865
- });
3866
- }
3867
- /**
3868
- * List all TOTP devices for user.
3869
- */
3870
- static cfgTotpDevicesRetrieve(options) {
3871
- return (options?.client ?? client3).get({
3872
- security: [{ scheme: "bearer", type: "http" }],
3873
- url: "/cfg/totp/devices/",
3874
- ...options
3875
- });
3876
- }
3877
- /**
3878
- * Delete a TOTP device.
3879
- *
3880
- * Requires verification code if removing the last/primary device.
3881
- */
3882
- static cfgTotpDevicesDestroy(options) {
3883
- return (options.client ?? client3).delete({
3884
- security: [{ scheme: "bearer", type: "http" }],
3885
- url: "/cfg/totp/devices/{id}/",
3886
- ...options
3887
- });
3888
- }
3889
- /**
3890
- * Completely disable 2FA for account.
3891
- *
3892
- * Requires verification code.
3893
- */
3894
- static cfgTotpDisableCreate(options) {
3895
- return (options.client ?? client3).post({
3896
- security: [{ scheme: "bearer", type: "http" }],
3897
- url: "/cfg/totp/disable/",
3898
- ...options,
3899
- headers: {
3900
- "Content-Type": "application/json",
3901
- ...options.headers
3902
- }
3903
- });
3904
- }
3905
- /**
3906
- * Start 2FA setup process.
3907
- *
3908
- * Creates a new TOTP device and returns QR code for scanning.
3909
- */
3910
- static cfgTotpSetupCreate(options) {
3911
- return (options?.client ?? client3).post({
3912
- security: [{ scheme: "bearer", type: "http" }],
3913
- url: "/cfg/totp/setup/",
3914
- ...options,
3915
- headers: {
3916
- "Content-Type": "application/json",
3917
- ...options?.headers
3918
- }
3919
- });
3920
- }
3921
- /**
3922
- * Confirm 2FA setup with first valid code.
3923
- *
3924
- * Activates the device and generates backup codes.
3925
- */
3926
- static cfgTotpSetupConfirmCreate(options) {
3927
- return (options.client ?? client3).post({
3928
- security: [{ scheme: "bearer", type: "http" }],
3929
- url: "/cfg/totp/setup/confirm/",
3930
- ...options,
3931
- headers: {
3932
- "Content-Type": "application/json",
3933
- ...options.headers
3934
- }
3935
- });
3936
- }
3937
- /**
3938
- * Verify TOTP code for 2FA session.
3939
- *
3940
- * Completes authentication and returns JWT tokens on success.
3941
- */
3942
- static cfgTotpVerifyCreate(options) {
3943
- return (options.client ?? client3).post({
3944
- security: [{ scheme: "bearer", type: "http" }],
3945
- url: "/cfg/totp/verify/",
3946
- ...options,
3947
- headers: {
3948
- "Content-Type": "application/json",
3949
- ...options.headers
3950
- }
3951
- });
3952
- }
3953
- /**
3954
- * Verify backup recovery code for 2FA session.
3955
- *
3956
- * Alternative verification method when TOTP device unavailable.
3957
- */
3958
- static cfgTotpVerifyBackupCreate(options) {
3959
- return (options.client ?? client3).post({
3960
- security: [{ scheme: "bearer", type: "http" }],
3961
- url: "/cfg/totp/verify/backup/",
3962
- ...options,
3963
- headers: {
3964
- "Content-Type": "application/json",
3965
- ...options.headers
3966
- }
3967
- });
1031
+ if (typeof navigator !== "undefined" && navigator.language) {
1032
+ return navigator.language;
1033
+ }
1034
+ } catch {
3968
1035
  }
3969
- };
3970
- var Totp = class {
1036
+ return null;
1037
+ }
1038
+ __name(detectLocale2, "detectLocale");
1039
+ var API2 = class {
3971
1040
  static {
3972
- __name(this, "Totp");
3973
- }
3974
- /**
3975
- * Get backup codes status for user.
3976
- */
3977
- static cfgTotpBackupCodesRetrieve(options) {
3978
- return (options?.client ?? client3).get({
3979
- security: [{ scheme: "bearer", type: "http" }],
3980
- url: "/cfg/totp/backup-codes/",
3981
- ...options
3982
- });
3983
- }
3984
- /**
3985
- * Regenerate backup codes.
3986
- *
3987
- * Requires TOTP code for verification.
3988
- * Invalidates all existing codes.
3989
- */
3990
- static cfgTotpBackupCodesRegenerateCreate(options) {
3991
- return (options.client ?? client3).post({
3992
- security: [{ scheme: "bearer", type: "http" }],
3993
- url: "/cfg/totp/backup-codes/regenerate/",
3994
- ...options,
3995
- headers: {
3996
- "Content-Type": "application/json",
3997
- ...options.headers
3998
- }
3999
- });
4000
- }
4001
- /**
4002
- * List all TOTP devices for user.
4003
- */
4004
- static cfgTotpDevicesRetrieve(options) {
4005
- return (options?.client ?? client3).get({
4006
- security: [{ scheme: "bearer", type: "http" }],
4007
- url: "/cfg/totp/devices/",
4008
- ...options
4009
- });
4010
- }
4011
- /**
4012
- * Delete a TOTP device.
4013
- *
4014
- * Requires verification code if removing the last/primary device.
4015
- */
4016
- static cfgTotpDevicesDestroy(options) {
4017
- return (options.client ?? client3).delete({
4018
- security: [{ scheme: "bearer", type: "http" }],
4019
- url: "/cfg/totp/devices/{id}/",
4020
- ...options
4021
- });
4022
- }
4023
- /**
4024
- * Completely disable 2FA for account.
4025
- *
4026
- * Requires verification code.
4027
- */
4028
- static cfgTotpDisableCreate(options) {
4029
- return (options.client ?? client3).post({
4030
- security: [{ scheme: "bearer", type: "http" }],
4031
- url: "/cfg/totp/disable/",
4032
- ...options,
4033
- headers: {
4034
- "Content-Type": "application/json",
4035
- ...options.headers
4036
- }
4037
- });
4038
- }
4039
- /**
4040
- * Start 2FA setup process.
4041
- *
4042
- * Creates a new TOTP device and returns QR code for scanning.
4043
- */
4044
- static cfgTotpSetupCreate(options) {
4045
- return (options?.client ?? client3).post({
4046
- security: [{ scheme: "bearer", type: "http" }],
4047
- url: "/cfg/totp/setup/",
4048
- ...options,
4049
- headers: {
4050
- "Content-Type": "application/json",
4051
- ...options?.headers
4052
- }
4053
- });
4054
- }
4055
- /**
4056
- * Confirm 2FA setup with first valid code.
4057
- *
4058
- * Activates the device and generates backup codes.
4059
- */
4060
- static cfgTotpSetupConfirmCreate(options) {
4061
- return (options.client ?? client3).post({
4062
- security: [{ scheme: "bearer", type: "http" }],
4063
- url: "/cfg/totp/setup/confirm/",
4064
- ...options,
4065
- headers: {
4066
- "Content-Type": "application/json",
4067
- ...options.headers
4068
- }
4069
- });
4070
- }
4071
- /**
4072
- * Verify TOTP code for 2FA session.
4073
- *
4074
- * Completes authentication and returns JWT tokens on success.
4075
- */
4076
- static cfgTotpVerifyCreate(options) {
4077
- return (options.client ?? client3).post({
4078
- security: [{ scheme: "bearer", type: "http" }],
4079
- url: "/cfg/totp/verify/",
4080
- ...options,
4081
- headers: {
4082
- "Content-Type": "application/json",
4083
- ...options.headers
4084
- }
4085
- });
1041
+ __name(this, "API");
4086
1042
  }
4087
- /**
4088
- * Verify backup recovery code for 2FA session.
4089
- *
4090
- * Alternative verification method when TOTP device unavailable.
4091
- */
4092
- static cfgTotpVerifyBackupCreate(options) {
4093
- return (options.client ?? client3).post({
4094
- security: [{ scheme: "bearer", type: "http" }],
4095
- url: "/cfg/totp/verify/backup/",
4096
- ...options,
4097
- headers: {
4098
- "Content-Type": "application/json",
4099
- ...options.headers
4100
- }
1043
+ baseUrl;
1044
+ storage;
1045
+ locale;
1046
+ apiKey;
1047
+ logger;
1048
+ constructor(baseUrl2, opts = {}) {
1049
+ this.baseUrl = baseUrl2.replace(/\/$/, "");
1050
+ this.storage = opts.storage ?? new LocalStorageAdapter();
1051
+ this.logger = new APILogger(opts.logger);
1052
+ this.locale = opts.locale ?? null;
1053
+ this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
1054
+ const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
1055
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1056
+ client.interceptors.request.use((request) => {
1057
+ const access = this.getToken();
1058
+ if (access) request.headers.set("Authorization", `Bearer ${access}`);
1059
+ const locale = this.locale ?? detectLocale2();
1060
+ if (locale) request.headers.set("Accept-Language", locale);
1061
+ if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
1062
+ return request;
4101
1063
  });
4102
1064
  }
4103
- };
4104
- var BackupCodes = class {
4105
- static {
4106
- __name(this, "BackupCodes");
1065
+ // ── Base URL ────────────────────────────────────────────────────────────
1066
+ getBaseUrl() {
1067
+ return this.baseUrl;
4107
1068
  }
4108
- /**
4109
- * Get backup codes status for user.
4110
- */
4111
- static cfgTotpBackupCodesRetrieve(options) {
4112
- return (options?.client ?? client3).get({
4113
- security: [{ scheme: "bearer", type: "http" }],
4114
- url: "/cfg/totp/backup-codes/",
4115
- ...options
4116
- });
1069
+ setBaseUrl(url) {
1070
+ this.baseUrl = url.replace(/\/$/, "");
1071
+ client.setConfig({ baseUrl: this.baseUrl });
4117
1072
  }
4118
- /**
4119
- * Regenerate backup codes.
4120
- *
4121
- * Requires TOTP code for verification.
4122
- * Invalidates all existing codes.
4123
- */
4124
- static cfgTotpBackupCodesRegenerateCreate(options) {
4125
- return (options.client ?? client3).post({
4126
- security: [{ scheme: "bearer", type: "http" }],
4127
- url: "/cfg/totp/backup-codes/regenerate/",
4128
- ...options,
4129
- headers: {
4130
- "Content-Type": "application/json",
4131
- ...options.headers
4132
- }
4133
- });
1073
+ // ── Tokens ──────────────────────────────────────────────────────────────
1074
+ getToken() {
1075
+ return this.storage.getItem(ACCESS_KEY2);
4134
1076
  }
4135
- };
4136
- var TotpManagement = class {
4137
- static {
4138
- __name(this, "TotpManagement");
1077
+ setToken(token) {
1078
+ if (token) this.storage.setItem(ACCESS_KEY2, token);
1079
+ else this.storage.removeItem(ACCESS_KEY2);
4139
1080
  }
4140
- /**
4141
- * List all TOTP devices for user.
4142
- */
4143
- static cfgTotpDevicesRetrieve(options) {
4144
- return (options?.client ?? client3).get({
4145
- security: [{ scheme: "bearer", type: "http" }],
4146
- url: "/cfg/totp/devices/",
4147
- ...options
4148
- });
1081
+ getRefreshToken() {
1082
+ return this.storage.getItem(REFRESH_KEY2);
4149
1083
  }
4150
- /**
4151
- * Completely disable 2FA for account.
4152
- *
4153
- * Requires verification code.
4154
- */
4155
- static cfgTotpDisableCreate(options) {
4156
- return (options.client ?? client3).post({
4157
- security: [{ scheme: "bearer", type: "http" }],
4158
- url: "/cfg/totp/disable/",
4159
- ...options,
4160
- headers: {
4161
- "Content-Type": "application/json",
4162
- ...options.headers
4163
- }
4164
- });
1084
+ setRefreshToken(token) {
1085
+ if (token) this.storage.setItem(REFRESH_KEY2, token);
1086
+ else this.storage.removeItem(REFRESH_KEY2);
4165
1087
  }
4166
- };
4167
- var TotpSetup = class {
4168
- static {
4169
- __name(this, "TotpSetup");
1088
+ clearToken() {
1089
+ this.storage.removeItem(ACCESS_KEY2);
1090
+ this.storage.removeItem(REFRESH_KEY2);
4170
1091
  }
4171
- /**
4172
- * Start 2FA setup process.
4173
- *
4174
- * Creates a new TOTP device and returns QR code for scanning.
4175
- */
4176
- static cfgTotpSetupCreate(options) {
4177
- return (options?.client ?? client3).post({
4178
- security: [{ scheme: "bearer", type: "http" }],
4179
- url: "/cfg/totp/setup/",
4180
- ...options,
4181
- headers: {
4182
- "Content-Type": "application/json",
4183
- ...options?.headers
4184
- }
4185
- });
1092
+ isAuthenticated() {
1093
+ return this.getToken() !== null;
4186
1094
  }
4187
- /**
4188
- * Confirm 2FA setup with first valid code.
4189
- *
4190
- * Activates the device and generates backup codes.
4191
- */
4192
- static cfgTotpSetupConfirmCreate(options) {
4193
- return (options.client ?? client3).post({
4194
- security: [{ scheme: "bearer", type: "http" }],
4195
- url: "/cfg/totp/setup/confirm/",
4196
- ...options,
4197
- headers: {
4198
- "Content-Type": "application/json",
4199
- ...options.headers
4200
- }
4201
- });
1095
+ // ── Locale / API key ────────────────────────────────────────────────────
1096
+ getLocale() {
1097
+ return this.locale ?? detectLocale2();
4202
1098
  }
4203
- };
4204
- var TotpVerification = class {
4205
- static {
4206
- __name(this, "TotpVerification");
1099
+ setLocale(locale) {
1100
+ this.locale = locale;
4207
1101
  }
4208
- /**
4209
- * Verify TOTP code for 2FA session.
4210
- *
4211
- * Completes authentication and returns JWT tokens on success.
4212
- */
4213
- static cfgTotpVerifyCreate(options) {
4214
- return (options.client ?? client3).post({
4215
- security: [{ scheme: "bearer", type: "http" }],
4216
- url: "/cfg/totp/verify/",
4217
- ...options,
4218
- headers: {
4219
- "Content-Type": "application/json",
4220
- ...options.headers
4221
- }
4222
- });
1102
+ getApiKey() {
1103
+ return this.apiKey;
4223
1104
  }
4224
- /**
4225
- * Verify backup recovery code for 2FA session.
4226
- *
4227
- * Alternative verification method when TOTP device unavailable.
4228
- */
4229
- static cfgTotpVerifyBackupCreate(options) {
4230
- return (options.client ?? client3).post({
4231
- security: [{ scheme: "bearer", type: "http" }],
4232
- url: "/cfg/totp/verify/backup/",
4233
- ...options,
4234
- headers: {
4235
- "Content-Type": "application/json",
4236
- ...options.headers
4237
- }
4238
- });
1105
+ setApiKey(key) {
1106
+ this.apiKey = key;
4239
1107
  }
4240
1108
  };
4241
1109
 
4242
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateRequest.ts
4243
- import { z as z23 } from "zod";
4244
- var BackupCodesRegenerateRequestSchema = z23.object({
4245
- code: z23.string().min(6).max(6)
4246
- });
4247
-
4248
- // src/_api/generated/cfg_totp/schemas/BackupCodesRegenerateResponse.ts
4249
- import { z as z24 } from "zod";
4250
- var BackupCodesRegenerateResponseSchema = z24.object({
4251
- backup_codes: z24.array(z24.string()),
4252
- warning: z24.string()
4253
- });
4254
-
4255
- // src/_api/generated/cfg_totp/schemas/BackupCodesStatus.ts
4256
- import { z as z25 } from "zod";
4257
- var BackupCodesStatusSchema = z25.object({
4258
- remaining_count: z25.number().int(),
4259
- total_generated: z25.number().int(),
4260
- warning: z25.string().nullable().optional()
4261
- });
4262
-
4263
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupRequest.ts
4264
- import { z as z26 } from "zod";
4265
- var ConfirmSetupRequestSchema = z26.object({
4266
- device_id: z26.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4267
- code: z26.string().min(6).max(6)
4268
- });
4269
-
4270
- // src/_api/generated/cfg_totp/schemas/ConfirmSetupResponse.ts
4271
- import { z as z27 } from "zod";
4272
- var ConfirmSetupResponseSchema = z27.object({
4273
- message: z27.string(),
4274
- backup_codes: z27.array(z27.string()),
4275
- backup_codes_warning: z27.string()
4276
- });
4277
-
4278
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4279
- import { z as z29 } from "zod";
4280
-
4281
- // src/_api/generated/cfg_totp/schemas/DeviceListStatusEnum.ts
4282
- import { z as z28 } from "zod";
4283
- var DeviceListStatusEnumSchema = z28.enum(["pending", "active", "disabled"]);
4284
-
4285
- // src/_api/generated/cfg_totp/schemas/DeviceList.ts
4286
- var DeviceListSchema = z29.object({
4287
- id: z29.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4288
- name: z29.string(),
4289
- is_primary: z29.boolean(),
4290
- status: DeviceListStatusEnumSchema,
4291
- created_at: z29.string().datetime({ offset: true }),
4292
- confirmed_at: z29.string().datetime({ offset: true }).nullable(),
4293
- last_used_at: z29.string().datetime({ offset: true }).nullable()
4294
- });
4295
-
4296
- // src/_api/generated/cfg_totp/schemas/DeviceListResponse.ts
4297
- import { z as z30 } from "zod";
4298
- var DeviceListResponseSchema = z30.object({
4299
- devices: z30.array(DeviceListSchema),
4300
- has_2fa_enabled: z30.boolean()
4301
- });
4302
-
4303
- // src/_api/generated/cfg_totp/schemas/DisableRequest.ts
4304
- import { z as z31 } from "zod";
4305
- var DisableRequestSchema = z31.object({
4306
- code: z31.string().min(6).max(6)
4307
- });
4308
-
4309
- // src/_api/generated/cfg_totp/schemas/SetupRequest.ts
4310
- import { z as z32 } from "zod";
4311
- var SetupRequestSchema = z32.object({
4312
- device_name: z32.string().min(1).max(100).optional()
4313
- });
4314
-
4315
- // src/_api/generated/cfg_totp/schemas/SetupResponse.ts
4316
- import { z as z33 } from "zod";
4317
- var SetupResponseSchema = z33.object({
4318
- device_id: z33.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4319
- secret: z33.string(),
4320
- provisioning_uri: z33.string(),
4321
- qr_code_base64: z33.string(),
4322
- expires_in: z33.number().int()
4323
- });
4324
-
4325
- // src/_api/generated/cfg_totp/schemas/TotpVerifyUser.ts
4326
- import { z as z34 } from "zod";
4327
- var TotpVerifyUserSchema = z34.object({
4328
- id: z34.number().int(),
4329
- email: z34.email(),
4330
- first_name: z34.string().max(50).optional(),
4331
- last_name: z34.string().max(50).optional(),
4332
- full_name: z34.string(),
4333
- initials: z34.string(),
4334
- display_username: z34.string(),
4335
- company: z34.string().max(100).optional(),
4336
- phone: z34.string().max(20).optional(),
4337
- position: z34.string().max(100).optional(),
4338
- language: z34.string().max(10).optional(),
4339
- avatar: z34.string().nullable(),
4340
- is_staff: z34.boolean(),
4341
- is_superuser: z34.boolean(),
4342
- date_joined: z34.string().datetime({ offset: true }),
4343
- last_login: z34.string().datetime({ offset: true }).nullable(),
4344
- unanswered_messages_count: z34.number().int()
4345
- });
4346
-
4347
- // src/_api/generated/cfg_totp/schemas/VerifyBackupRequest.ts
4348
- import { z as z35 } from "zod";
4349
- var VerifyBackupRequestSchema = z35.object({
4350
- session_id: z35.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4351
- backup_code: z35.string().min(8).max(8)
4352
- });
4353
-
4354
- // src/_api/generated/cfg_totp/schemas/VerifyRequest.ts
4355
- import { z as z36 } from "zod";
4356
- var VerifyRequestSchema = z36.object({
4357
- session_id: z36.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
4358
- code: z36.string().min(6).max(6)
4359
- });
4360
-
4361
- // src/_api/generated/cfg_totp/schemas/VerifyResponse.ts
4362
- import { z as z37 } from "zod";
4363
- var VerifyResponseSchema = z37.object({
4364
- message: z37.string(),
4365
- access_token: z37.string(),
4366
- refresh_token: z37.string(),
4367
- user: TotpVerifyUserSchema,
4368
- remaining_backup_codes: z37.number().int().optional(),
4369
- warning: z37.string().optional()
4370
- });
4371
-
4372
- // src/_api/generated/cfg_totp/api.ts
1110
+ // src/_api/generated/_cfg_totp/api.ts
4373
1111
  var ACCESS_KEY3 = "cfg.access_token";
4374
1112
  var REFRESH_KEY3 = "cfg.refresh_token";
4375
- var VALIDATION_ROUTES3 = [
4376
- { method: "GET", re: new RegExp("^/cfg/totp/backup\\-codes/?$"), schema: BackupCodesStatusSchema, path: "/cfg/totp/backup-codes/" },
4377
- { method: "POST", re: new RegExp("^/cfg/totp/backup\\-codes/regenerate/?$"), schema: BackupCodesRegenerateResponseSchema, path: "/cfg/totp/backup-codes/regenerate/" },
4378
- { method: "GET", re: new RegExp("^/cfg/totp/devices/?$"), schema: DeviceListResponseSchema, path: "/cfg/totp/devices/" },
4379
- { method: "POST", re: new RegExp("^/cfg/totp/setup/?$"), schema: SetupResponseSchema, path: "/cfg/totp/setup/" },
4380
- { method: "POST", re: new RegExp("^/cfg/totp/setup/confirm/?$"), schema: ConfirmSetupResponseSchema, path: "/cfg/totp/setup/confirm/" },
4381
- { method: "POST", re: new RegExp("^/cfg/totp/verify/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/" },
4382
- { method: "POST", re: new RegExp("^/cfg/totp/verify/backup/?$"), schema: VerifyResponseSchema, path: "/cfg/totp/verify/backup/" }
4383
- ];
4384
1113
  function detectLocale3() {
4385
1114
  try {
4386
1115
  if (typeof document !== "undefined") {
@@ -4404,12 +1133,6 @@ var API3 = class {
4404
1133
  locale;
4405
1134
  apiKey;
4406
1135
  logger;
4407
- cfg = Cfg3;
4408
- totp = Totp;
4409
- backupCodes = BackupCodes;
4410
- totpManagement = TotpManagement;
4411
- totpSetup = TotpSetup;
4412
- totpVerification = TotpVerification;
4413
1136
  constructor(baseUrl2, opts = {}) {
4414
1137
  this.baseUrl = baseUrl2.replace(/\/$/, "");
4415
1138
  this.storage = opts.storage ?? new LocalStorageAdapter();
@@ -4417,8 +1140,8 @@ var API3 = class {
4417
1140
  this.locale = opts.locale ?? null;
4418
1141
  this.apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env?.NEXT_PUBLIC_API_KEY ?? null : null);
4419
1142
  const credentials = opts.withCredentials ?? true ? "include" : "same-origin";
4420
- client3.setConfig({ baseUrl: this.baseUrl, credentials });
4421
- client3.interceptors.request.use((request) => {
1143
+ client.setConfig({ baseUrl: this.baseUrl, credentials });
1144
+ client.interceptors.request.use((request) => {
4422
1145
  const access = this.getToken();
4423
1146
  if (access) request.headers.set("Authorization", `Bearer ${access}`);
4424
1147
  const locale = this.locale ?? detectLocale3();
@@ -4426,35 +1149,6 @@ var API3 = class {
4426
1149
  if (this.apiKey) request.headers.set("X-API-Key", this.apiKey);
4427
1150
  return request;
4428
1151
  });
4429
- client3.interceptors.response.use(async (response, request) => {
4430
- if (!response.ok) return response;
4431
- const ct = response.headers.get("content-type") || "";
4432
- if (!ct.includes("application/json")) return response;
4433
- const url = new URL(request.url);
4434
- const method = request.method.toUpperCase();
4435
- const route = VALIDATION_ROUTES3.find(
4436
- (r) => r.method === method && r.re.test(url.pathname)
4437
- );
4438
- if (!route) return response;
4439
- let payload;
4440
- try {
4441
- payload = await response.clone().json();
4442
- } catch {
4443
- return response;
4444
- }
4445
- const result = route.schema.safeParse(payload);
4446
- if (!result.success) {
4447
- dispatchValidationError({
4448
- operation: `${method} ${route.path}`,
4449
- path: route.path,
4450
- method,
4451
- error: result.error,
4452
- response: payload,
4453
- timestamp: /* @__PURE__ */ new Date()
4454
- });
4455
- }
4456
- return response;
4457
- });
4458
1152
  }
4459
1153
  // ── Base URL ────────────────────────────────────────────────────────────
4460
1154
  getBaseUrl() {
@@ -4462,7 +1156,7 @@ var API3 = class {
4462
1156
  }
4463
1157
  setBaseUrl(url) {
4464
1158
  this.baseUrl = url.replace(/\/$/, "");
4465
- client3.setConfig({ baseUrl: this.baseUrl });
1159
+ client.setConfig({ baseUrl: this.baseUrl });
4466
1160
  }
4467
1161
  // ── Tokens ──────────────────────────────────────────────────────────────
4468
1162
  getToken() {
@@ -4504,15 +1198,15 @@ var API3 = class {
4504
1198
  // src/_api/generated/index.ts
4505
1199
  var isStaticBuild = process.env.NEXT_PUBLIC_STATIC_BUILD === "true";
4506
1200
  var baseUrl = isStaticBuild ? "" : process.env.NEXT_PUBLIC_API_URL || "";
4507
- var cfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
4508
- var cfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
4509
- var cfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
1201
+ var CfgAccountsApi = new API(baseUrl, { storage: new LocalStorageAdapter() });
1202
+ var CfgCentrifugoApi = new API2(baseUrl, { storage: new LocalStorageAdapter() });
1203
+ var CfgTotpApi = new API3(baseUrl, { storage: new LocalStorageAdapter() });
4510
1204
  export {
4511
1205
  API as AccountsAPI,
4512
1206
  API2 as CentrifugoAPI,
4513
1207
  API3 as TotpAPI,
4514
- cfgAccountsApi as apiAccounts,
4515
- cfgCentrifugoApi as apiCentrifugo,
4516
- cfgTotpApi as apiTotp
1208
+ CfgAccountsApi as apiAccounts,
1209
+ CfgCentrifugoApi as apiCentrifugo,
1210
+ CfgTotpApi as apiTotp
4517
1211
  };
4518
1212
  //# sourceMappingURL=clients.mjs.map