@djangocfg/api 2.1.55 → 2.1.57

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 (93) hide show
  1. package/dist/auth.cjs +28 -15
  2. package/dist/auth.cjs.map +1 -1
  3. package/dist/auth.d.cts +6 -6
  4. package/dist/auth.d.ts +6 -6
  5. package/dist/auth.mjs +28 -15
  6. package/dist/auth.mjs.map +1 -1
  7. package/dist/clients.cjs +56 -17
  8. package/dist/clients.cjs.map +1 -1
  9. package/dist/clients.d.cts +17 -17
  10. package/dist/clients.d.ts +17 -17
  11. package/dist/clients.mjs +56 -17
  12. package/dist/clients.mjs.map +1 -1
  13. package/dist/hooks.cjs +763 -12
  14. package/dist/hooks.cjs.map +1 -1
  15. package/dist/hooks.d.cts +11 -11
  16. package/dist/hooks.d.ts +11 -11
  17. package/dist/hooks.mjs +763 -12
  18. package/dist/hooks.mjs.map +1 -1
  19. package/dist/index.cjs +893 -69
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +59 -41
  22. package/dist/index.d.ts +59 -41
  23. package/dist/index.mjs +893 -69
  24. package/dist/index.mjs.map +1 -1
  25. package/package.json +3 -3
  26. package/src/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +1 -1
  27. package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +2 -2
  28. package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +1 -1
  29. package/src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +1 -1
  30. package/src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +1 -1
  31. package/src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +1 -1
  32. package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +1 -1
  33. package/src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +1 -1
  34. package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +1 -1
  35. package/src/generated/cfg_accounts/_utils/schemas/User.schema.ts +1 -1
  36. package/src/generated/cfg_accounts/api-instance.ts +61 -13
  37. package/src/generated/cfg_centrifugo/api-instance.ts +61 -13
  38. package/src/generated/cfg_totp/CLAUDE.md +90 -0
  39. package/src/generated/cfg_totp/_utils/fetchers/index.ts +33 -0
  40. package/src/generated/cfg_totp/_utils/fetchers/totp.ts +49 -0
  41. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_management.ts +108 -0
  42. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_setup.ts +153 -0
  43. package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_verification.ts +152 -0
  44. package/src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +152 -0
  45. package/src/generated/cfg_totp/_utils/hooks/index.ts +33 -0
  46. package/src/generated/cfg_totp/_utils/hooks/totp.ts +42 -0
  47. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_management.ts +58 -0
  48. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_setup.ts +63 -0
  49. package/src/generated/cfg_totp/_utils/hooks/totp__2fa_verification.ts +62 -0
  50. package/src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +59 -0
  51. package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +19 -0
  52. package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +20 -0
  53. package/src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +21 -0
  54. package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +20 -0
  55. package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +21 -0
  56. package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +26 -0
  57. package/src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +19 -0
  58. package/src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts +24 -0
  59. package/src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +19 -0
  60. package/src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +23 -0
  61. package/src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +20 -0
  62. package/src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +20 -0
  63. package/src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +24 -0
  64. package/src/generated/cfg_totp/_utils/schemas/index.ts +32 -0
  65. package/src/generated/cfg_totp/api-instance.ts +180 -0
  66. package/src/generated/cfg_totp/client.ts +313 -0
  67. package/src/generated/cfg_totp/enums.ts +12 -0
  68. package/src/generated/cfg_totp/errors.ts +117 -0
  69. package/src/generated/cfg_totp/http.ts +104 -0
  70. package/src/generated/cfg_totp/index.ts +302 -0
  71. package/src/generated/cfg_totp/logger.ts +260 -0
  72. package/src/generated/cfg_totp/retry.ts +176 -0
  73. package/src/generated/cfg_totp/schema.json +859 -0
  74. package/src/generated/cfg_totp/storage.ts +162 -0
  75. package/src/generated/cfg_totp/totp/client.ts +23 -0
  76. package/src/generated/cfg_totp/totp/index.ts +3 -0
  77. package/src/generated/cfg_totp/totp/models.ts +1 -0
  78. package/src/generated/cfg_totp/totp__2fa_management/client.ts +41 -0
  79. package/src/generated/cfg_totp/totp__2fa_management/index.ts +3 -0
  80. package/src/generated/cfg_totp/totp__2fa_management/models.ts +60 -0
  81. package/src/generated/cfg_totp/totp__2fa_setup/client.ts +32 -0
  82. package/src/generated/cfg_totp/totp__2fa_setup/index.ts +3 -0
  83. package/src/generated/cfg_totp/totp__2fa_setup/models.ts +54 -0
  84. package/src/generated/cfg_totp/totp__2fa_verification/client.ts +32 -0
  85. package/src/generated/cfg_totp/totp__2fa_verification/index.ts +3 -0
  86. package/src/generated/cfg_totp/totp__2fa_verification/models.ts +44 -0
  87. package/src/generated/cfg_totp/totp__backup_codes/client.ts +31 -0
  88. package/src/generated/cfg_totp/totp__backup_codes/index.ts +3 -0
  89. package/src/generated/cfg_totp/totp__backup_codes/models.ts +37 -0
  90. package/src/generated/cfg_totp/validation-events.ts +134 -0
  91. package/src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts +2 -2
  92. package/src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts +1 -1
  93. package/src/generated/cfg_webpush/api-instance.ts +61 -13
package/dist/index.cjs CHANGED
@@ -1079,7 +1079,7 @@ __export(schemas_exports, {
1079
1079
  var import_zod = require("zod");
1080
1080
  var CentrifugoTokenSchema = import_zod.z.object({
1081
1081
  token: import_zod.z.string(),
1082
- centrifugo_url: import_zod.z.url(),
1082
+ centrifugo_url: import_zod.z.union([import_zod.z.url(), import_zod.z.literal("")]),
1083
1083
  expires_at: import_zod.z.iso.datetime(),
1084
1084
  channels: import_zod.z.array(import_zod.z.string())
1085
1085
  });
@@ -1087,14 +1087,14 @@ var CentrifugoTokenSchema = import_zod.z.object({
1087
1087
  // src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
1088
1088
  var import_zod2 = require("zod");
1089
1089
  var OAuthAuthorizeRequestRequestSchema = import_zod2.z.object({
1090
- redirect_uri: import_zod2.z.url().optional(),
1091
- source_url: import_zod2.z.url().optional()
1090
+ redirect_uri: import_zod2.z.union([import_zod2.z.url(), import_zod2.z.literal("")]).optional(),
1091
+ source_url: import_zod2.z.union([import_zod2.z.url(), import_zod2.z.literal("")]).optional()
1092
1092
  });
1093
1093
 
1094
1094
  // src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
1095
1095
  var import_zod3 = require("zod");
1096
1096
  var OAuthAuthorizeResponseSchema = import_zod3.z.object({
1097
- authorization_url: import_zod3.z.url(),
1097
+ authorization_url: import_zod3.z.union([import_zod3.z.url(), import_zod3.z.literal("")]),
1098
1098
  state: import_zod3.z.string()
1099
1099
  });
1100
1100
 
@@ -1103,7 +1103,7 @@ var import_zod4 = require("zod");
1103
1103
  var OAuthCallbackRequestRequestSchema = import_zod4.z.object({
1104
1104
  code: import_zod4.z.string().min(10).max(500),
1105
1105
  state: import_zod4.z.string().min(20).max(100),
1106
- redirect_uri: import_zod4.z.url().optional()
1106
+ redirect_uri: import_zod4.z.union([import_zod4.z.url(), import_zod4.z.literal("")]).optional()
1107
1107
  });
1108
1108
 
1109
1109
  // src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
@@ -1114,7 +1114,7 @@ var OAuthConnectionSchema = import_zod5.z.object({
1114
1114
  provider_display: import_zod5.z.string(),
1115
1115
  provider_username: import_zod5.z.string(),
1116
1116
  provider_email: import_zod5.z.email(),
1117
- provider_avatar_url: import_zod5.z.url(),
1117
+ provider_avatar_url: import_zod5.z.union([import_zod5.z.url(), import_zod5.z.literal("")]),
1118
1118
  connected_at: import_zod5.z.iso.datetime(),
1119
1119
  last_login_at: import_zod5.z.iso.datetime()
1120
1120
  });
@@ -1135,7 +1135,7 @@ var OAuthErrorSchema = import_zod7.z.object({
1135
1135
  // src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
1136
1136
  var import_zod8 = require("zod");
1137
1137
  var OAuthProvidersResponseSchema = import_zod8.z.object({
1138
- providers: import_zod8.z.array(import_zod8.z.record(import_zod8.z.string(), import_zod8.z.record(import_zod8.z.string(), import_zod8.z.any())))
1138
+ providers: import_zod8.z.array(import_zod8.z.record(import_zod8.z.string(), import_zod8.z.any()))
1139
1139
  });
1140
1140
 
1141
1141
  // src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
@@ -1143,7 +1143,7 @@ var import_zod9 = require("zod");
1143
1143
  var OAuthTokenResponseSchema = import_zod9.z.object({
1144
1144
  access: import_zod9.z.string(),
1145
1145
  refresh: import_zod9.z.string(),
1146
- user: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.record(import_zod9.z.string(), import_zod9.z.any())),
1146
+ user: import_zod9.z.record(import_zod9.z.string(), import_zod9.z.any()),
1147
1147
  is_new_user: import_zod9.z.boolean(),
1148
1148
  is_new_connection: import_zod9.z.boolean()
1149
1149
  });
@@ -1159,7 +1159,7 @@ var import_zod11 = require("zod");
1159
1159
  var OTPRequestRequestSchema = import_zod11.z.object({
1160
1160
  identifier: import_zod11.z.string().min(1),
1161
1161
  channel: import_zod11.z.nativeEnum(OTPRequestRequestChannel).optional(),
1162
- source_url: import_zod11.z.url().optional()
1162
+ source_url: import_zod11.z.union([import_zod11.z.url(), import_zod11.z.literal("")]).optional()
1163
1163
  });
1164
1164
 
1165
1165
  // src/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
@@ -1174,7 +1174,7 @@ var OTPVerifyRequestSchema = import_zod13.z.object({
1174
1174
  identifier: import_zod13.z.string().min(1),
1175
1175
  otp: import_zod13.z.string().min(6).max(6),
1176
1176
  channel: import_zod13.z.nativeEnum(OTPVerifyRequestChannel).optional(),
1177
- source_url: import_zod13.z.url().optional()
1177
+ source_url: import_zod13.z.union([import_zod13.z.url(), import_zod13.z.literal("")]).optional()
1178
1178
  });
1179
1179
 
1180
1180
  // src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
@@ -1193,7 +1193,7 @@ var UserSchema = import_zod14.z.object({
1193
1193
  company: import_zod14.z.string().max(100).optional(),
1194
1194
  phone: import_zod14.z.string().max(20).optional(),
1195
1195
  position: import_zod14.z.string().max(100).optional(),
1196
- avatar: import_zod14.z.url().nullable(),
1196
+ avatar: import_zod14.z.union([import_zod14.z.url(), import_zod14.z.literal("")]).nullable(),
1197
1197
  is_staff: import_zod14.z.boolean(),
1198
1198
  is_superuser: import_zod14.z.boolean(),
1199
1199
  date_joined: import_zod14.z.iso.datetime(),
@@ -1315,16 +1315,30 @@ var import_consola2 = require("consola");
1315
1315
 
1316
1316
  // src/generated/cfg_accounts/api-instance.ts
1317
1317
  var globalAPI = null;
1318
+ var autoConfigAttempted = false;
1319
+ function tryAutoConfigureFromEnv() {
1320
+ if (autoConfigAttempted) return;
1321
+ autoConfigAttempted = true;
1322
+ if (globalAPI) return;
1323
+ if (typeof process === "undefined" || !process.env) return;
1324
+ const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
1325
+ if (baseUrl) {
1326
+ globalAPI = new API(baseUrl);
1327
+ }
1328
+ }
1329
+ __name(tryAutoConfigureFromEnv, "tryAutoConfigureFromEnv");
1318
1330
  function getAPIInstance() {
1331
+ tryAutoConfigureFromEnv();
1319
1332
  if (!globalAPI) {
1320
1333
  throw new Error(
1321
- 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })'
1334
+ 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
1322
1335
  );
1323
1336
  }
1324
1337
  return globalAPI;
1325
1338
  }
1326
1339
  __name(getAPIInstance, "getAPIInstance");
1327
1340
  function isAPIConfigured() {
1341
+ tryAutoConfigureFromEnv();
1328
1342
  return globalAPI !== null;
1329
1343
  }
1330
1344
  __name(isAPIConfigured, "isAPIConfigured");
@@ -2027,6 +2041,360 @@ var API = class {
2027
2041
  };
2028
2042
  var cfg_accounts_default = API;
2029
2043
 
2044
+ // src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/client.ts
2045
+ var CentrifugoAdminApi = class {
2046
+ static {
2047
+ __name(this, "CentrifugoAdminApi");
2048
+ }
2049
+ constructor(client) {
2050
+ this.client = client;
2051
+ }
2052
+ /**
2053
+ * Get connection token for dashboard
2054
+ *
2055
+ * Returns JWT token and config for WebSocket connection to Centrifugo.
2056
+ */
2057
+ async centrifugoServerAuthTokenCreate() {
2058
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/auth/token/");
2059
+ return response;
2060
+ }
2061
+ /**
2062
+ * List active channels
2063
+ *
2064
+ * Returns list of active channels with optional pattern filter.
2065
+ */
2066
+ async centrifugoServerChannelsCreate(data) {
2067
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/channels/", { body: data });
2068
+ return response;
2069
+ }
2070
+ /**
2071
+ * Get channel history
2072
+ *
2073
+ * Returns message history for a channel.
2074
+ */
2075
+ async centrifugoServerHistoryCreate(data) {
2076
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/history/", { body: data });
2077
+ return response;
2078
+ }
2079
+ /**
2080
+ * Get Centrifugo server info
2081
+ *
2082
+ * Returns server information including node count, version, and uptime.
2083
+ */
2084
+ async centrifugoServerInfoCreate() {
2085
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/info/");
2086
+ return response;
2087
+ }
2088
+ /**
2089
+ * Get channel presence
2090
+ *
2091
+ * Returns list of clients currently subscribed to a channel.
2092
+ */
2093
+ async centrifugoServerPresenceCreate(data) {
2094
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/presence/", { body: data });
2095
+ return response;
2096
+ }
2097
+ /**
2098
+ * Get channel presence statistics
2099
+ *
2100
+ * Returns quick statistics about channel presence (num_clients,
2101
+ * num_users).
2102
+ */
2103
+ async centrifugoServerPresenceStatsCreate(data) {
2104
+ const response = await this.client.request("POST", "/cfg/centrifugo/server/presence-stats/", { body: data });
2105
+ return response;
2106
+ }
2107
+ };
2108
+
2109
+ // src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts
2110
+ var CentrifugoAuth = class {
2111
+ static {
2112
+ __name(this, "CentrifugoAuth");
2113
+ }
2114
+ constructor(client) {
2115
+ this.client = client;
2116
+ }
2117
+ /**
2118
+ * Get Centrifugo connection token
2119
+ *
2120
+ * Generate JWT token for WebSocket connection to Centrifugo. Token
2121
+ * includes user's allowed channels based on their permissions. Requires
2122
+ * authentication.
2123
+ */
2124
+ async tokenRetrieve() {
2125
+ const response = await this.client.request("GET", "/cfg/centrifugo/auth/token/");
2126
+ return response;
2127
+ }
2128
+ };
2129
+
2130
+ // src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/client.ts
2131
+ var CentrifugoMonitoring = class {
2132
+ static {
2133
+ __name(this, "CentrifugoMonitoring");
2134
+ }
2135
+ constructor(client) {
2136
+ this.client = client;
2137
+ }
2138
+ /**
2139
+ * Get channel statistics
2140
+ *
2141
+ * Returns statistics grouped by channel.
2142
+ */
2143
+ async centrifugoMonitorChannelsRetrieve(...args) {
2144
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2145
+ let params;
2146
+ if (isParamsObject) {
2147
+ params = args[0];
2148
+ } else {
2149
+ params = { hours: args[0] };
2150
+ }
2151
+ const response = await this.client.request("GET", "/cfg/centrifugo/monitor/channels/", { params });
2152
+ return response.results || response;
2153
+ }
2154
+ /**
2155
+ * Get Centrifugo health status
2156
+ *
2157
+ * Returns the current health status of the Centrifugo client.
2158
+ */
2159
+ async centrifugoMonitorHealthRetrieve() {
2160
+ const response = await this.client.request("GET", "/cfg/centrifugo/monitor/health/");
2161
+ return response;
2162
+ }
2163
+ /**
2164
+ * Get overview statistics
2165
+ *
2166
+ * Returns overview statistics for Centrifugo publishes.
2167
+ */
2168
+ async centrifugoMonitorOverviewRetrieve(...args) {
2169
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2170
+ let params;
2171
+ if (isParamsObject) {
2172
+ params = args[0];
2173
+ } else {
2174
+ params = { hours: args[0] };
2175
+ }
2176
+ const response = await this.client.request("GET", "/cfg/centrifugo/monitor/overview/", { params });
2177
+ return response;
2178
+ }
2179
+ /**
2180
+ * Get recent publishes
2181
+ *
2182
+ * Returns a paginated list of recent Centrifugo publishes with their
2183
+ * details. Uses standard DRF pagination.
2184
+ */
2185
+ async centrifugoMonitorPublishesList(...args) {
2186
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2187
+ let params;
2188
+ if (isParamsObject) {
2189
+ params = args[0];
2190
+ } else {
2191
+ params = { channel: args[0], page: args[1], page_size: args[2], status: args[3] };
2192
+ }
2193
+ const response = await this.client.request("GET", "/cfg/centrifugo/monitor/publishes/", { params });
2194
+ return response;
2195
+ }
2196
+ /**
2197
+ * Get publish timeline
2198
+ *
2199
+ * Returns hourly or daily breakdown of publish counts for charts.
2200
+ */
2201
+ async centrifugoMonitorTimelineRetrieve(...args) {
2202
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
2203
+ let params;
2204
+ if (isParamsObject) {
2205
+ params = args[0];
2206
+ } else {
2207
+ params = { hours: args[0], interval: args[1] };
2208
+ }
2209
+ const response = await this.client.request("GET", "/cfg/centrifugo/monitor/timeline/", { params });
2210
+ return response;
2211
+ }
2212
+ };
2213
+
2214
+ // src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/client.ts
2215
+ var CentrifugoTesting = class {
2216
+ static {
2217
+ __name(this, "CentrifugoTesting");
2218
+ }
2219
+ constructor(client) {
2220
+ this.client = client;
2221
+ }
2222
+ /**
2223
+ * Publish test message
2224
+ *
2225
+ * Publish test message to Centrifugo via wrapper with optional ACK
2226
+ * tracking.
2227
+ */
2228
+ async publishTestCreate(data) {
2229
+ const response = await this.client.request("POST", "/cfg/centrifugo/testing/publish-test/", { body: data });
2230
+ return response;
2231
+ }
2232
+ /**
2233
+ * Publish with database logging
2234
+ *
2235
+ * Publish message using CentrifugoClient with database logging. This will
2236
+ * create CentrifugoLog records.
2237
+ */
2238
+ async publishWithLoggingCreate(data) {
2239
+ const response = await this.client.request("POST", "/cfg/centrifugo/testing/publish-with-logging/", { body: data });
2240
+ return response;
2241
+ }
2242
+ /**
2243
+ * Send manual ACK
2244
+ *
2245
+ * Manually send ACK for a message to the wrapper. Pass message_id in
2246
+ * request body.
2247
+ */
2248
+ async sendAckCreate(data) {
2249
+ const response = await this.client.request("POST", "/cfg/centrifugo/testing/send-ack/", { body: data });
2250
+ return response;
2251
+ }
2252
+ };
2253
+
2254
+ // src/generated/cfg_centrifugo/http.ts
2255
+ var FetchAdapter2 = class {
2256
+ static {
2257
+ __name(this, "FetchAdapter");
2258
+ }
2259
+ async request(request) {
2260
+ const { method, url, headers, body, params, formData } = request;
2261
+ let finalUrl = url;
2262
+ if (params) {
2263
+ const searchParams = new URLSearchParams();
2264
+ Object.entries(params).forEach(([key, value]) => {
2265
+ if (value !== null && value !== void 0) {
2266
+ searchParams.append(key, String(value));
2267
+ }
2268
+ });
2269
+ const queryString = searchParams.toString();
2270
+ if (queryString) {
2271
+ finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
2272
+ }
2273
+ }
2274
+ const finalHeaders = { ...headers };
2275
+ let requestBody;
2276
+ if (formData) {
2277
+ requestBody = formData;
2278
+ } else if (body) {
2279
+ finalHeaders["Content-Type"] = "application/json";
2280
+ requestBody = JSON.stringify(body);
2281
+ }
2282
+ const response = await fetch(finalUrl, {
2283
+ method,
2284
+ headers: finalHeaders,
2285
+ body: requestBody,
2286
+ credentials: "include"
2287
+ // Include Django session cookies
2288
+ });
2289
+ let data = null;
2290
+ const contentType = response.headers.get("content-type");
2291
+ if (response.status !== 204 && contentType?.includes("application/json")) {
2292
+ data = await response.json();
2293
+ } else if (response.status !== 204) {
2294
+ data = await response.text();
2295
+ }
2296
+ const responseHeaders = {};
2297
+ response.headers.forEach((value, key) => {
2298
+ responseHeaders[key] = value;
2299
+ });
2300
+ return {
2301
+ data,
2302
+ status: response.status,
2303
+ statusText: response.statusText,
2304
+ headers: responseHeaders
2305
+ };
2306
+ }
2307
+ };
2308
+
2309
+ // src/generated/cfg_centrifugo/errors.ts
2310
+ var APIError2 = class extends Error {
2311
+ constructor(statusCode, statusText, response, url, message) {
2312
+ super(message || `HTTP ${statusCode}: ${statusText}`);
2313
+ this.statusCode = statusCode;
2314
+ this.statusText = statusText;
2315
+ this.response = response;
2316
+ this.url = url;
2317
+ this.name = "APIError";
2318
+ }
2319
+ static {
2320
+ __name(this, "APIError");
2321
+ }
2322
+ /**
2323
+ * Get error details from response.
2324
+ * DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
2325
+ */
2326
+ get details() {
2327
+ if (typeof this.response === "object" && this.response !== null) {
2328
+ return this.response;
2329
+ }
2330
+ return null;
2331
+ }
2332
+ /**
2333
+ * Get field-specific validation errors from DRF.
2334
+ * Returns: { "field_name": ["error1", "error2"], ... }
2335
+ */
2336
+ get fieldErrors() {
2337
+ const details = this.details;
2338
+ if (!details) return null;
2339
+ const fieldErrors = {};
2340
+ for (const [key, value] of Object.entries(details)) {
2341
+ if (Array.isArray(value)) {
2342
+ fieldErrors[key] = value;
2343
+ }
2344
+ }
2345
+ return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
2346
+ }
2347
+ /**
2348
+ * Get single error message from DRF.
2349
+ * Checks for "detail", "message", or first field error.
2350
+ */
2351
+ get errorMessage() {
2352
+ const details = this.details;
2353
+ if (!details) return this.message;
2354
+ if (details.detail) {
2355
+ return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
2356
+ }
2357
+ if (details.message) {
2358
+ return String(details.message);
2359
+ }
2360
+ const fieldErrors = this.fieldErrors;
2361
+ if (fieldErrors) {
2362
+ const firstField = Object.keys(fieldErrors)[0];
2363
+ if (firstField) {
2364
+ return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
2365
+ }
2366
+ }
2367
+ return this.message;
2368
+ }
2369
+ // Helper methods for common HTTP status codes
2370
+ get isValidationError() {
2371
+ return this.statusCode === 400;
2372
+ }
2373
+ get isAuthError() {
2374
+ return this.statusCode === 401;
2375
+ }
2376
+ get isPermissionError() {
2377
+ return this.statusCode === 403;
2378
+ }
2379
+ get isNotFoundError() {
2380
+ return this.statusCode === 404;
2381
+ }
2382
+ get isServerError() {
2383
+ return this.statusCode >= 500 && this.statusCode < 600;
2384
+ }
2385
+ };
2386
+ var NetworkError2 = class extends Error {
2387
+ constructor(message, url, originalError) {
2388
+ super(message);
2389
+ this.url = url;
2390
+ this.originalError = originalError;
2391
+ this.name = "NetworkError";
2392
+ }
2393
+ static {
2394
+ __name(this, "NetworkError");
2395
+ }
2396
+ };
2397
+
2030
2398
  // src/generated/cfg_centrifugo/logger.ts
2031
2399
  var import_consola6 = require("consola");
2032
2400
  var DEFAULT_CONFIG2 = {
@@ -2137,52 +2505,354 @@ var APILogger2 = class {
2137
2505
  });
2138
2506
  }
2139
2507
  }
2140
- /**
2141
- * Log general info
2142
- */
2143
- info(message, ...args) {
2144
- if (!this.config.enabled) return;
2145
- this.consola.info(message, ...args);
2146
- }
2147
- /**
2148
- * Log warning
2149
- */
2150
- warn(message, ...args) {
2151
- if (!this.config.enabled) return;
2152
- this.consola.warn(message, ...args);
2508
+ /**
2509
+ * Log general info
2510
+ */
2511
+ info(message, ...args) {
2512
+ if (!this.config.enabled) return;
2513
+ this.consola.info(message, ...args);
2514
+ }
2515
+ /**
2516
+ * Log warning
2517
+ */
2518
+ warn(message, ...args) {
2519
+ if (!this.config.enabled) return;
2520
+ this.consola.warn(message, ...args);
2521
+ }
2522
+ /**
2523
+ * Log error
2524
+ */
2525
+ error(message, ...args) {
2526
+ if (!this.config.enabled) return;
2527
+ this.consola.error(message, ...args);
2528
+ }
2529
+ /**
2530
+ * Log debug
2531
+ */
2532
+ debug(message, ...args) {
2533
+ if (!this.config.enabled) return;
2534
+ this.consola.debug(message, ...args);
2535
+ }
2536
+ /**
2537
+ * Log success
2538
+ */
2539
+ success(message, ...args) {
2540
+ if (!this.config.enabled) return;
2541
+ this.consola.success(message, ...args);
2542
+ }
2543
+ /**
2544
+ * Create a sub-logger with prefix
2545
+ */
2546
+ withTag(tag) {
2547
+ return this.consola.withTag(tag);
2548
+ }
2549
+ };
2550
+ var defaultLogger2 = new APILogger2();
2551
+
2552
+ // src/generated/cfg_centrifugo/retry.ts
2553
+ var import_p_retry2 = __toESM(require("p-retry"), 1);
2554
+ var DEFAULT_RETRY_CONFIG2 = {
2555
+ retries: 3,
2556
+ factor: 2,
2557
+ minTimeout: 1e3,
2558
+ maxTimeout: 6e4,
2559
+ randomize: true,
2560
+ onFailedAttempt: /* @__PURE__ */ __name(() => {
2561
+ }, "onFailedAttempt")
2562
+ };
2563
+ function shouldRetry2(error) {
2564
+ if (error instanceof NetworkError2) {
2565
+ return true;
2566
+ }
2567
+ if (error instanceof APIError2) {
2568
+ const status = error.statusCode;
2569
+ if (status >= 500 && status < 600) {
2570
+ return true;
2571
+ }
2572
+ if (status === 429) {
2573
+ return true;
2574
+ }
2575
+ return false;
2576
+ }
2577
+ return true;
2578
+ }
2579
+ __name(shouldRetry2, "shouldRetry");
2580
+ async function withRetry2(fn, config) {
2581
+ const finalConfig = { ...DEFAULT_RETRY_CONFIG2, ...config };
2582
+ return (0, import_p_retry2.default)(
2583
+ async () => {
2584
+ try {
2585
+ return await fn();
2586
+ } catch (error) {
2587
+ if (!shouldRetry2(error)) {
2588
+ throw new import_p_retry2.AbortError(error);
2589
+ }
2590
+ throw error;
2591
+ }
2592
+ },
2593
+ {
2594
+ retries: finalConfig.retries,
2595
+ factor: finalConfig.factor,
2596
+ minTimeout: finalConfig.minTimeout,
2597
+ maxTimeout: finalConfig.maxTimeout,
2598
+ randomize: finalConfig.randomize,
2599
+ onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
2600
+ const pRetryError = error;
2601
+ finalConfig.onFailedAttempt({
2602
+ error: pRetryError,
2603
+ attemptNumber: pRetryError.attemptNumber,
2604
+ retriesLeft: pRetryError.retriesLeft
2605
+ });
2606
+ } : void 0
2607
+ }
2608
+ );
2609
+ }
2610
+ __name(withRetry2, "withRetry");
2611
+
2612
+ // src/generated/cfg_centrifugo/client.ts
2613
+ var APIClient2 = class {
2614
+ constructor(baseUrl, options) {
2615
+ this.logger = null;
2616
+ this.retryConfig = null;
2617
+ this.baseUrl = baseUrl.replace(/\/$/, "");
2618
+ this.httpClient = options?.httpClient || new FetchAdapter2();
2619
+ if (options?.loggerConfig !== void 0) {
2620
+ this.logger = new APILogger2(options.loggerConfig);
2621
+ }
2622
+ if (options?.retryConfig !== void 0) {
2623
+ this.retryConfig = options.retryConfig;
2624
+ }
2625
+ this.centrifugo_admin_api = new CentrifugoAdminApi(this);
2626
+ this.centrifugo_auth = new CentrifugoAuth(this);
2627
+ this.centrifugo_monitoring = new CentrifugoMonitoring(this);
2628
+ this.centrifugo_testing = new CentrifugoTesting(this);
2629
+ }
2630
+ static {
2631
+ __name(this, "APIClient");
2632
+ }
2633
+ /**
2634
+ * Get CSRF token from cookies (for SessionAuthentication).
2635
+ *
2636
+ * Returns null if cookie doesn't exist (JWT-only auth).
2637
+ */
2638
+ getCsrfToken() {
2639
+ const name = "csrftoken";
2640
+ const value = `; ${document.cookie}`;
2641
+ const parts = value.split(`; ${name}=`);
2642
+ if (parts.length === 2) {
2643
+ return parts.pop()?.split(";").shift() || null;
2644
+ }
2645
+ return null;
2646
+ }
2647
+ /**
2648
+ * Make HTTP request with Django CSRF and session handling.
2649
+ * Automatically retries on network errors and 5xx server errors.
2650
+ */
2651
+ async request(method, path, options) {
2652
+ if (this.retryConfig) {
2653
+ return withRetry2(() => this._makeRequest(method, path, options), {
2654
+ ...this.retryConfig,
2655
+ onFailedAttempt: /* @__PURE__ */ __name((info) => {
2656
+ if (this.logger) {
2657
+ this.logger.warn(
2658
+ `Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
2659
+ );
2660
+ }
2661
+ this.retryConfig?.onFailedAttempt?.(info);
2662
+ }, "onFailedAttempt")
2663
+ });
2664
+ }
2665
+ return this._makeRequest(method, path, options);
2666
+ }
2667
+ /**
2668
+ * Internal request method (without retry wrapper).
2669
+ * Used by request() method with optional retry logic.
2670
+ */
2671
+ async _makeRequest(method, path, options) {
2672
+ const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
2673
+ const startTime = Date.now();
2674
+ const headers = {
2675
+ ...options?.headers || {}
2676
+ };
2677
+ if (!options?.formData && !headers["Content-Type"]) {
2678
+ headers["Content-Type"] = "application/json";
2679
+ }
2680
+ if (this.logger) {
2681
+ this.logger.logRequest({
2682
+ method,
2683
+ url,
2684
+ headers,
2685
+ body: options?.formData || options?.body,
2686
+ timestamp: startTime
2687
+ });
2688
+ }
2689
+ try {
2690
+ const response = await this.httpClient.request({
2691
+ method,
2692
+ url,
2693
+ headers,
2694
+ params: options?.params,
2695
+ body: options?.body,
2696
+ formData: options?.formData
2697
+ });
2698
+ const duration = Date.now() - startTime;
2699
+ if (response.status >= 400) {
2700
+ const error = new APIError2(
2701
+ response.status,
2702
+ response.statusText,
2703
+ response.data,
2704
+ url
2705
+ );
2706
+ if (this.logger) {
2707
+ this.logger.logError(
2708
+ {
2709
+ method,
2710
+ url,
2711
+ headers,
2712
+ body: options?.formData || options?.body,
2713
+ timestamp: startTime
2714
+ },
2715
+ {
2716
+ message: error.message,
2717
+ statusCode: response.status,
2718
+ duration,
2719
+ timestamp: Date.now()
2720
+ }
2721
+ );
2722
+ }
2723
+ throw error;
2724
+ }
2725
+ if (this.logger) {
2726
+ this.logger.logResponse(
2727
+ {
2728
+ method,
2729
+ url,
2730
+ headers,
2731
+ body: options?.formData || options?.body,
2732
+ timestamp: startTime
2733
+ },
2734
+ {
2735
+ status: response.status,
2736
+ statusText: response.statusText,
2737
+ data: response.data,
2738
+ duration,
2739
+ timestamp: Date.now()
2740
+ }
2741
+ );
2742
+ }
2743
+ return response.data;
2744
+ } catch (error) {
2745
+ const duration = Date.now() - startTime;
2746
+ if (error instanceof APIError2) {
2747
+ throw error;
2748
+ }
2749
+ const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
2750
+ if (this.logger) {
2751
+ if (isCORSError) {
2752
+ this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
2753
+ this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
2754
+ this.logger.error(` \u2192 Configure security_domains parameter on the server`);
2755
+ } else {
2756
+ this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
2757
+ this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
2758
+ }
2759
+ }
2760
+ if (typeof window !== "undefined") {
2761
+ try {
2762
+ if (isCORSError) {
2763
+ window.dispatchEvent(new CustomEvent("cors-error", {
2764
+ detail: {
2765
+ url,
2766
+ method,
2767
+ error: error instanceof Error ? error.message : String(error),
2768
+ timestamp: /* @__PURE__ */ new Date()
2769
+ },
2770
+ bubbles: true,
2771
+ cancelable: false
2772
+ }));
2773
+ } else {
2774
+ window.dispatchEvent(new CustomEvent("network-error", {
2775
+ detail: {
2776
+ url,
2777
+ method,
2778
+ error: error instanceof Error ? error.message : String(error),
2779
+ timestamp: /* @__PURE__ */ new Date()
2780
+ },
2781
+ bubbles: true,
2782
+ cancelable: false
2783
+ }));
2784
+ }
2785
+ } catch (eventError) {
2786
+ }
2787
+ }
2788
+ const networkError = error instanceof Error ? new NetworkError2(error.message, url, error) : new NetworkError2("Unknown error", url);
2789
+ if (this.logger) {
2790
+ this.logger.logError(
2791
+ {
2792
+ method,
2793
+ url,
2794
+ headers,
2795
+ body: options?.formData || options?.body,
2796
+ timestamp: startTime
2797
+ },
2798
+ {
2799
+ message: networkError.message,
2800
+ duration,
2801
+ timestamp: Date.now()
2802
+ }
2803
+ );
2804
+ }
2805
+ throw networkError;
2806
+ }
2807
+ }
2808
+ };
2809
+
2810
+ // src/generated/cfg_centrifugo/storage.ts
2811
+ var LocalStorageAdapter2 = class {
2812
+ static {
2813
+ __name(this, "LocalStorageAdapter");
2153
2814
  }
2154
- /**
2155
- * Log error
2156
- */
2157
- error(message, ...args) {
2158
- if (!this.config.enabled) return;
2159
- this.consola.error(message, ...args);
2815
+ constructor(logger) {
2816
+ this.logger = logger;
2160
2817
  }
2161
- /**
2162
- * Log debug
2163
- */
2164
- debug(message, ...args) {
2165
- if (!this.config.enabled) return;
2166
- this.consola.debug(message, ...args);
2818
+ getItem(key) {
2819
+ try {
2820
+ if (typeof window !== "undefined" && window.localStorage) {
2821
+ const value = localStorage.getItem(key);
2822
+ this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
2823
+ return value;
2824
+ }
2825
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
2826
+ } catch (error) {
2827
+ this.logger?.error("LocalStorage.getItem failed:", error);
2828
+ }
2829
+ return null;
2167
2830
  }
2168
- /**
2169
- * Log success
2170
- */
2171
- success(message, ...args) {
2172
- if (!this.config.enabled) return;
2173
- this.consola.success(message, ...args);
2831
+ setItem(key, value) {
2832
+ try {
2833
+ if (typeof window !== "undefined" && window.localStorage) {
2834
+ localStorage.setItem(key, value);
2835
+ this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
2836
+ } else {
2837
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
2838
+ }
2839
+ } catch (error) {
2840
+ this.logger?.error("LocalStorage.setItem failed:", error);
2841
+ }
2174
2842
  }
2175
- /**
2176
- * Create a sub-logger with prefix
2177
- */
2178
- withTag(tag) {
2179
- return this.consola.withTag(tag);
2843
+ removeItem(key) {
2844
+ try {
2845
+ if (typeof window !== "undefined" && window.localStorage) {
2846
+ localStorage.removeItem(key);
2847
+ this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
2848
+ } else {
2849
+ this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
2850
+ }
2851
+ } catch (error) {
2852
+ this.logger?.error("LocalStorage.removeItem failed:", error);
2853
+ }
2180
2854
  }
2181
2855
  };
2182
- var defaultLogger2 = new APILogger2();
2183
-
2184
- // src/generated/cfg_centrifugo/retry.ts
2185
- var import_p_retry2 = __toESM(require("p-retry"), 1);
2186
2856
 
2187
2857
  // src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelInfo.schema.ts
2188
2858
  var import_zod20 = require("zod");
@@ -2506,10 +3176,23 @@ var import_consola7 = require("consola");
2506
3176
 
2507
3177
  // src/generated/cfg_centrifugo/api-instance.ts
2508
3178
  var globalAPI2 = null;
3179
+ var autoConfigAttempted2 = false;
3180
+ function tryAutoConfigureFromEnv2() {
3181
+ if (autoConfigAttempted2) return;
3182
+ autoConfigAttempted2 = true;
3183
+ if (globalAPI2) return;
3184
+ if (typeof process === "undefined" || !process.env) return;
3185
+ const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
3186
+ if (baseUrl) {
3187
+ globalAPI2 = new API2(baseUrl);
3188
+ }
3189
+ }
3190
+ __name(tryAutoConfigureFromEnv2, "tryAutoConfigureFromEnv");
2509
3191
  function getAPIInstance2() {
3192
+ tryAutoConfigureFromEnv2();
2510
3193
  if (!globalAPI2) {
2511
3194
  throw new Error(
2512
- 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })'
3195
+ 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
2513
3196
  );
2514
3197
  }
2515
3198
  return globalAPI2;
@@ -2568,6 +3251,133 @@ var import_consola9 = require("consola");
2568
3251
  // src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_testing.ts
2569
3252
  var import_consola10 = require("consola");
2570
3253
 
3254
+ // src/generated/cfg_centrifugo/index.ts
3255
+ var TOKEN_KEY2 = "auth_token";
3256
+ var REFRESH_TOKEN_KEY2 = "refresh_token";
3257
+ var API2 = class {
3258
+ constructor(baseUrl, options) {
3259
+ this._token = null;
3260
+ this._refreshToken = null;
3261
+ this.baseUrl = baseUrl;
3262
+ this.options = options;
3263
+ const logger = options?.loggerConfig ? new APILogger2(options.loggerConfig) : void 0;
3264
+ this.storage = options?.storage || new LocalStorageAdapter2(logger);
3265
+ this._loadTokensFromStorage();
3266
+ this._client = new APIClient2(this.baseUrl, {
3267
+ retryConfig: this.options?.retryConfig,
3268
+ loggerConfig: this.options?.loggerConfig
3269
+ });
3270
+ this._injectAuthHeader();
3271
+ this.centrifugo_admin_api = this._client.centrifugo_admin_api;
3272
+ this.centrifugo_auth = this._client.centrifugo_auth;
3273
+ this.centrifugo_monitoring = this._client.centrifugo_monitoring;
3274
+ this.centrifugo_testing = this._client.centrifugo_testing;
3275
+ }
3276
+ static {
3277
+ __name(this, "API");
3278
+ }
3279
+ _loadTokensFromStorage() {
3280
+ this._token = this.storage.getItem(TOKEN_KEY2);
3281
+ this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY2);
3282
+ }
3283
+ _reinitClients() {
3284
+ this._client = new APIClient2(this.baseUrl, {
3285
+ retryConfig: this.options?.retryConfig,
3286
+ loggerConfig: this.options?.loggerConfig
3287
+ });
3288
+ this._injectAuthHeader();
3289
+ this.centrifugo_admin_api = this._client.centrifugo_admin_api;
3290
+ this.centrifugo_auth = this._client.centrifugo_auth;
3291
+ this.centrifugo_monitoring = this._client.centrifugo_monitoring;
3292
+ this.centrifugo_testing = this._client.centrifugo_testing;
3293
+ }
3294
+ _injectAuthHeader() {
3295
+ const originalRequest = this._client.request.bind(this._client);
3296
+ this._client.request = async (method, path, options) => {
3297
+ const token = this.getToken();
3298
+ const mergedOptions = {
3299
+ ...options,
3300
+ headers: {
3301
+ ...options?.headers || {},
3302
+ ...token ? { "Authorization": `Bearer ${token}` } : {}
3303
+ }
3304
+ };
3305
+ return originalRequest(method, path, mergedOptions);
3306
+ };
3307
+ }
3308
+ /**
3309
+ * Get current JWT token
3310
+ */
3311
+ getToken() {
3312
+ return this.storage.getItem(TOKEN_KEY2);
3313
+ }
3314
+ /**
3315
+ * Get current refresh token
3316
+ */
3317
+ getRefreshToken() {
3318
+ return this.storage.getItem(REFRESH_TOKEN_KEY2);
3319
+ }
3320
+ /**
3321
+ * Set JWT token and refresh token
3322
+ * @param token - JWT access token
3323
+ * @param refreshToken - JWT refresh token (optional)
3324
+ */
3325
+ setToken(token, refreshToken) {
3326
+ this._token = token;
3327
+ this.storage.setItem(TOKEN_KEY2, token);
3328
+ if (refreshToken) {
3329
+ this._refreshToken = refreshToken;
3330
+ this.storage.setItem(REFRESH_TOKEN_KEY2, refreshToken);
3331
+ }
3332
+ this._reinitClients();
3333
+ }
3334
+ /**
3335
+ * Clear all tokens
3336
+ */
3337
+ clearTokens() {
3338
+ this._token = null;
3339
+ this._refreshToken = null;
3340
+ this.storage.removeItem(TOKEN_KEY2);
3341
+ this.storage.removeItem(REFRESH_TOKEN_KEY2);
3342
+ this._reinitClients();
3343
+ }
3344
+ /**
3345
+ * Check if user is authenticated
3346
+ */
3347
+ isAuthenticated() {
3348
+ return !!this.getToken();
3349
+ }
3350
+ /**
3351
+ * Update base URL and reinitialize clients
3352
+ * @param url - New base URL
3353
+ */
3354
+ setBaseUrl(url) {
3355
+ this.baseUrl = url;
3356
+ this._reinitClients();
3357
+ }
3358
+ /**
3359
+ * Get current base URL
3360
+ */
3361
+ getBaseUrl() {
3362
+ return this.baseUrl;
3363
+ }
3364
+ /**
3365
+ * Get OpenAPI schema path
3366
+ * @returns Path to the OpenAPI schema JSON file
3367
+ *
3368
+ * Note: The OpenAPI schema is available in the schema.json file.
3369
+ * You can load it dynamically using:
3370
+ * ```typescript
3371
+ * const schema = await fetch('./schema.json').then(r => r.json());
3372
+ * // or using fs in Node.js:
3373
+ * // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
3374
+ * ```
3375
+ */
3376
+ getSchemaPath() {
3377
+ return "./schema.json";
3378
+ }
3379
+ };
3380
+
2571
3381
  // src/generated/cfg_webpush/index.ts
2572
3382
  var cfg_webpush_exports = {};
2573
3383
  __export(cfg_webpush_exports, {
@@ -2582,13 +3392,13 @@ __export(cfg_webpush_exports, {
2582
3392
  LocalStorageAdapter: () => LocalStorageAdapter3,
2583
3393
  MemoryStorageAdapter: () => MemoryStorageAdapter3,
2584
3394
  NetworkError: () => NetworkError3,
2585
- REFRESH_TOKEN_KEY: () => REFRESH_TOKEN_KEY2,
3395
+ REFRESH_TOKEN_KEY: () => REFRESH_TOKEN_KEY3,
2586
3396
  Schemas: () => schemas_exports3,
2587
3397
  SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
2588
3398
  SendPushResponseSchema: () => SendPushResponseSchema,
2589
3399
  SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
2590
3400
  SubscribeResponseSchema: () => SubscribeResponseSchema,
2591
- TOKEN_KEY: () => TOKEN_KEY2,
3401
+ TOKEN_KEY: () => TOKEN_KEY3,
2592
3402
  VapidPublicKeyResponseSchema: () => VapidPublicKeyResponseSchema,
2593
3403
  WebPushTypes: () => models_exports9,
2594
3404
  clearAPITokens: () => clearAPITokens3,
@@ -3337,8 +4147,8 @@ var import_zod55 = require("zod");
3337
4147
  var SendPushRequestRequestSchema = import_zod55.z.object({
3338
4148
  title: import_zod55.z.string().min(1).max(255),
3339
4149
  body: import_zod55.z.string().min(1),
3340
- icon: import_zod55.z.url().nullable().optional(),
3341
- url: import_zod55.z.url().nullable().optional()
4150
+ icon: import_zod55.z.union([import_zod55.z.url(), import_zod55.z.literal("")]).nullable().optional(),
4151
+ url: import_zod55.z.union([import_zod55.z.url(), import_zod55.z.literal("")]).nullable().optional()
3342
4152
  });
3343
4153
 
3344
4154
  // src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
@@ -3351,7 +4161,7 @@ var SendPushResponseSchema = import_zod56.z.object({
3351
4161
  // src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
3352
4162
  var import_zod57 = require("zod");
3353
4163
  var SubscribeRequestRequestSchema = import_zod57.z.object({
3354
- endpoint: import_zod57.z.url(),
4164
+ endpoint: import_zod57.z.union([import_zod57.z.url(), import_zod57.z.literal("")]),
3355
4165
  keys: import_zod57.z.record(import_zod57.z.string(), import_zod57.z.string().min(1))
3356
4166
  });
3357
4167
 
@@ -3431,16 +4241,30 @@ var import_consola12 = require("consola");
3431
4241
 
3432
4242
  // src/generated/cfg_webpush/api-instance.ts
3433
4243
  var globalAPI3 = null;
4244
+ var autoConfigAttempted3 = false;
4245
+ function tryAutoConfigureFromEnv3() {
4246
+ if (autoConfigAttempted3) return;
4247
+ autoConfigAttempted3 = true;
4248
+ if (globalAPI3) return;
4249
+ if (typeof process === "undefined" || !process.env) return;
4250
+ const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
4251
+ if (baseUrl) {
4252
+ globalAPI3 = new API3(baseUrl);
4253
+ }
4254
+ }
4255
+ __name(tryAutoConfigureFromEnv3, "tryAutoConfigureFromEnv");
3434
4256
  function getAPIInstance3() {
4257
+ tryAutoConfigureFromEnv3();
3435
4258
  if (!globalAPI3) {
3436
4259
  throw new Error(
3437
- 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })'
4260
+ 'API not configured. Call configureAPI() with your base URL before using fetchers or hooks.\n\nExample:\n import { configureAPI } from "./api-instance"\n configureAPI({ baseUrl: "https://api.example.com" })\n\nOr set environment variable: NEXT_PUBLIC_API_URL, VITE_API_URL, or REACT_APP_API_URL'
3438
4261
  );
3439
4262
  }
3440
4263
  return globalAPI3;
3441
4264
  }
3442
4265
  __name(getAPIInstance3, "getAPIInstance");
3443
4266
  function isAPIConfigured3() {
4267
+ tryAutoConfigureFromEnv3();
3444
4268
  return globalAPI3 !== null;
3445
4269
  }
3446
4270
  __name(isAPIConfigured3, "isAPIConfigured");
@@ -3608,8 +4432,8 @@ Method: GET`);
3608
4432
  __name(getWebpushVapidRetrieve, "getWebpushVapidRetrieve");
3609
4433
 
3610
4434
  // src/generated/cfg_webpush/index.ts
3611
- var TOKEN_KEY2 = "auth_token";
3612
- var REFRESH_TOKEN_KEY2 = "refresh_token";
4435
+ var TOKEN_KEY3 = "auth_token";
4436
+ var REFRESH_TOKEN_KEY3 = "refresh_token";
3613
4437
  var API3 = class {
3614
4438
  constructor(baseUrl, options) {
3615
4439
  this._token = null;
@@ -3630,8 +4454,8 @@ var API3 = class {
3630
4454
  __name(this, "API");
3631
4455
  }
3632
4456
  _loadTokensFromStorage() {
3633
- this._token = this.storage.getItem(TOKEN_KEY2);
3634
- this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY2);
4457
+ this._token = this.storage.getItem(TOKEN_KEY3);
4458
+ this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY3);
3635
4459
  }
3636
4460
  _reinitClients() {
3637
4461
  this._client = new APIClient3(this.baseUrl, {
@@ -3659,13 +4483,13 @@ var API3 = class {
3659
4483
  * Get current JWT token
3660
4484
  */
3661
4485
  getToken() {
3662
- return this.storage.getItem(TOKEN_KEY2);
4486
+ return this.storage.getItem(TOKEN_KEY3);
3663
4487
  }
3664
4488
  /**
3665
4489
  * Get current refresh token
3666
4490
  */
3667
4491
  getRefreshToken() {
3668
- return this.storage.getItem(REFRESH_TOKEN_KEY2);
4492
+ return this.storage.getItem(REFRESH_TOKEN_KEY3);
3669
4493
  }
3670
4494
  /**
3671
4495
  * Set JWT token and refresh token
@@ -3674,10 +4498,10 @@ var API3 = class {
3674
4498
  */
3675
4499
  setToken(token, refreshToken) {
3676
4500
  this._token = token;
3677
- this.storage.setItem(TOKEN_KEY2, token);
4501
+ this.storage.setItem(TOKEN_KEY3, token);
3678
4502
  if (refreshToken) {
3679
4503
  this._refreshToken = refreshToken;
3680
- this.storage.setItem(REFRESH_TOKEN_KEY2, refreshToken);
4504
+ this.storage.setItem(REFRESH_TOKEN_KEY3, refreshToken);
3681
4505
  }
3682
4506
  this._reinitClients();
3683
4507
  }
@@ -3687,8 +4511,8 @@ var API3 = class {
3687
4511
  clearTokens() {
3688
4512
  this._token = null;
3689
4513
  this._refreshToken = null;
3690
- this.storage.removeItem(TOKEN_KEY2);
3691
- this.storage.removeItem(REFRESH_TOKEN_KEY2);
4514
+ this.storage.removeItem(TOKEN_KEY3);
4515
+ this.storage.removeItem(REFRESH_TOKEN_KEY3);
3692
4516
  this._reinitClients();
3693
4517
  }
3694
4518
  /**