@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.
- package/dist/auth.cjs +28 -15
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +6 -6
- package/dist/auth.d.ts +6 -6
- package/dist/auth.mjs +28 -15
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +56 -17
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +17 -17
- package/dist/clients.d.ts +17 -17
- package/dist/clients.mjs +56 -17
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +763 -12
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +11 -11
- package/dist/hooks.d.ts +11 -11
- package/dist/hooks.mjs +763 -12
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +893 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +59 -41
- package/dist/index.d.ts +59 -41
- package/dist/index.mjs +893 -69
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/generated/cfg_accounts/_utils/schemas/CentrifugoToken.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts +2 -2
- package/src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OAuthCallbackRequestRequest.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OTPRequestRequest.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/OTPVerifyRequest.schema.ts +1 -1
- package/src/generated/cfg_accounts/_utils/schemas/User.schema.ts +1 -1
- package/src/generated/cfg_accounts/api-instance.ts +61 -13
- package/src/generated/cfg_centrifugo/api-instance.ts +61 -13
- package/src/generated/cfg_totp/CLAUDE.md +90 -0
- package/src/generated/cfg_totp/_utils/fetchers/index.ts +33 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp.ts +49 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_management.ts +108 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_setup.ts +153 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__2fa_verification.ts +152 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +152 -0
- package/src/generated/cfg_totp/_utils/hooks/index.ts +33 -0
- package/src/generated/cfg_totp/_utils/hooks/totp.ts +42 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__2fa_management.ts +58 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__2fa_setup.ts +63 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__2fa_verification.ts +62 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +59 -0
- package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateRequest.schema.ts +19 -0
- package/src/generated/cfg_totp/_utils/schemas/BackupCodesRegenerateResponse.schema.ts +20 -0
- package/src/generated/cfg_totp/_utils/schemas/BackupCodesStatus.schema.ts +21 -0
- package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupRequest.schema.ts +20 -0
- package/src/generated/cfg_totp/_utils/schemas/ConfirmSetupResponse.schema.ts +21 -0
- package/src/generated/cfg_totp/_utils/schemas/DeviceList.schema.ts +26 -0
- package/src/generated/cfg_totp/_utils/schemas/DisableRequest.schema.ts +19 -0
- package/src/generated/cfg_totp/_utils/schemas/PaginatedDeviceListList.schema.ts +24 -0
- package/src/generated/cfg_totp/_utils/schemas/SetupRequest.schema.ts +19 -0
- package/src/generated/cfg_totp/_utils/schemas/SetupResponse.schema.ts +23 -0
- package/src/generated/cfg_totp/_utils/schemas/VerifyBackupRequest.schema.ts +20 -0
- package/src/generated/cfg_totp/_utils/schemas/VerifyRequest.schema.ts +20 -0
- package/src/generated/cfg_totp/_utils/schemas/VerifyResponse.schema.ts +24 -0
- package/src/generated/cfg_totp/_utils/schemas/index.ts +32 -0
- package/src/generated/cfg_totp/api-instance.ts +180 -0
- package/src/generated/cfg_totp/client.ts +313 -0
- package/src/generated/cfg_totp/enums.ts +12 -0
- package/src/generated/cfg_totp/errors.ts +117 -0
- package/src/generated/cfg_totp/http.ts +104 -0
- package/src/generated/cfg_totp/index.ts +302 -0
- package/src/generated/cfg_totp/logger.ts +260 -0
- package/src/generated/cfg_totp/retry.ts +176 -0
- package/src/generated/cfg_totp/schema.json +859 -0
- package/src/generated/cfg_totp/storage.ts +162 -0
- package/src/generated/cfg_totp/totp/client.ts +23 -0
- package/src/generated/cfg_totp/totp/index.ts +3 -0
- package/src/generated/cfg_totp/totp/models.ts +1 -0
- package/src/generated/cfg_totp/totp__2fa_management/client.ts +41 -0
- package/src/generated/cfg_totp/totp__2fa_management/index.ts +3 -0
- package/src/generated/cfg_totp/totp__2fa_management/models.ts +60 -0
- package/src/generated/cfg_totp/totp__2fa_setup/client.ts +32 -0
- package/src/generated/cfg_totp/totp__2fa_setup/index.ts +3 -0
- package/src/generated/cfg_totp/totp__2fa_setup/models.ts +54 -0
- package/src/generated/cfg_totp/totp__2fa_verification/client.ts +32 -0
- package/src/generated/cfg_totp/totp__2fa_verification/index.ts +3 -0
- package/src/generated/cfg_totp/totp__2fa_verification/models.ts +44 -0
- package/src/generated/cfg_totp/totp__backup_codes/client.ts +31 -0
- package/src/generated/cfg_totp/totp__backup_codes/index.ts +3 -0
- package/src/generated/cfg_totp/totp__backup_codes/models.ts +37 -0
- package/src/generated/cfg_totp/validation-events.ts +134 -0
- package/src/generated/cfg_webpush/_utils/schemas/SendPushRequestRequest.schema.ts +2 -2
- package/src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts +1 -1
- package/src/generated/cfg_webpush/api-instance.ts +61 -13
package/dist/index.mjs
CHANGED
|
@@ -982,7 +982,7 @@ __export(schemas_exports, {
|
|
|
982
982
|
import { z } from "zod";
|
|
983
983
|
var CentrifugoTokenSchema = z.object({
|
|
984
984
|
token: z.string(),
|
|
985
|
-
centrifugo_url: z.url(),
|
|
985
|
+
centrifugo_url: z.union([z.url(), z.literal("")]),
|
|
986
986
|
expires_at: z.iso.datetime(),
|
|
987
987
|
channels: z.array(z.string())
|
|
988
988
|
});
|
|
@@ -990,14 +990,14 @@ var CentrifugoTokenSchema = z.object({
|
|
|
990
990
|
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeRequestRequest.schema.ts
|
|
991
991
|
import { z as z2 } from "zod";
|
|
992
992
|
var OAuthAuthorizeRequestRequestSchema = z2.object({
|
|
993
|
-
redirect_uri: z2.url().optional(),
|
|
994
|
-
source_url: z2.url().optional()
|
|
993
|
+
redirect_uri: z2.union([z2.url(), z2.literal("")]).optional(),
|
|
994
|
+
source_url: z2.union([z2.url(), z2.literal("")]).optional()
|
|
995
995
|
});
|
|
996
996
|
|
|
997
997
|
// src/generated/cfg_accounts/_utils/schemas/OAuthAuthorizeResponse.schema.ts
|
|
998
998
|
import { z as z3 } from "zod";
|
|
999
999
|
var OAuthAuthorizeResponseSchema = z3.object({
|
|
1000
|
-
authorization_url: z3.url(),
|
|
1000
|
+
authorization_url: z3.union([z3.url(), z3.literal("")]),
|
|
1001
1001
|
state: z3.string()
|
|
1002
1002
|
});
|
|
1003
1003
|
|
|
@@ -1006,7 +1006,7 @@ import { z as z4 } from "zod";
|
|
|
1006
1006
|
var OAuthCallbackRequestRequestSchema = z4.object({
|
|
1007
1007
|
code: z4.string().min(10).max(500),
|
|
1008
1008
|
state: z4.string().min(20).max(100),
|
|
1009
|
-
redirect_uri: z4.url().optional()
|
|
1009
|
+
redirect_uri: z4.union([z4.url(), z4.literal("")]).optional()
|
|
1010
1010
|
});
|
|
1011
1011
|
|
|
1012
1012
|
// src/generated/cfg_accounts/_utils/schemas/OAuthConnection.schema.ts
|
|
@@ -1017,7 +1017,7 @@ var OAuthConnectionSchema = z5.object({
|
|
|
1017
1017
|
provider_display: z5.string(),
|
|
1018
1018
|
provider_username: z5.string(),
|
|
1019
1019
|
provider_email: z5.email(),
|
|
1020
|
-
provider_avatar_url: z5.url(),
|
|
1020
|
+
provider_avatar_url: z5.union([z5.url(), z5.literal("")]),
|
|
1021
1021
|
connected_at: z5.iso.datetime(),
|
|
1022
1022
|
last_login_at: z5.iso.datetime()
|
|
1023
1023
|
});
|
|
@@ -1038,7 +1038,7 @@ var OAuthErrorSchema = z7.object({
|
|
|
1038
1038
|
// src/generated/cfg_accounts/_utils/schemas/OAuthProvidersResponse.schema.ts
|
|
1039
1039
|
import { z as z8 } from "zod";
|
|
1040
1040
|
var OAuthProvidersResponseSchema = z8.object({
|
|
1041
|
-
providers: z8.array(z8.record(z8.string(), z8.
|
|
1041
|
+
providers: z8.array(z8.record(z8.string(), z8.any()))
|
|
1042
1042
|
});
|
|
1043
1043
|
|
|
1044
1044
|
// src/generated/cfg_accounts/_utils/schemas/OAuthTokenResponse.schema.ts
|
|
@@ -1046,7 +1046,7 @@ import { z as z9 } from "zod";
|
|
|
1046
1046
|
var OAuthTokenResponseSchema = z9.object({
|
|
1047
1047
|
access: z9.string(),
|
|
1048
1048
|
refresh: z9.string(),
|
|
1049
|
-
user: z9.record(z9.string(), z9.
|
|
1049
|
+
user: z9.record(z9.string(), z9.any()),
|
|
1050
1050
|
is_new_user: z9.boolean(),
|
|
1051
1051
|
is_new_connection: z9.boolean()
|
|
1052
1052
|
});
|
|
@@ -1062,7 +1062,7 @@ import { z as z11 } from "zod";
|
|
|
1062
1062
|
var OTPRequestRequestSchema = z11.object({
|
|
1063
1063
|
identifier: z11.string().min(1),
|
|
1064
1064
|
channel: z11.nativeEnum(OTPRequestRequestChannel).optional(),
|
|
1065
|
-
source_url: z11.url().optional()
|
|
1065
|
+
source_url: z11.union([z11.url(), z11.literal("")]).optional()
|
|
1066
1066
|
});
|
|
1067
1067
|
|
|
1068
1068
|
// src/generated/cfg_accounts/_utils/schemas/OTPRequestResponse.schema.ts
|
|
@@ -1077,7 +1077,7 @@ var OTPVerifyRequestSchema = z13.object({
|
|
|
1077
1077
|
identifier: z13.string().min(1),
|
|
1078
1078
|
otp: z13.string().min(6).max(6),
|
|
1079
1079
|
channel: z13.nativeEnum(OTPVerifyRequestChannel).optional(),
|
|
1080
|
-
source_url: z13.url().optional()
|
|
1080
|
+
source_url: z13.union([z13.url(), z13.literal("")]).optional()
|
|
1081
1081
|
});
|
|
1082
1082
|
|
|
1083
1083
|
// src/generated/cfg_accounts/_utils/schemas/OTPVerifyResponse.schema.ts
|
|
@@ -1096,7 +1096,7 @@ var UserSchema = z14.object({
|
|
|
1096
1096
|
company: z14.string().max(100).optional(),
|
|
1097
1097
|
phone: z14.string().max(20).optional(),
|
|
1098
1098
|
position: z14.string().max(100).optional(),
|
|
1099
|
-
avatar: z14.url().nullable(),
|
|
1099
|
+
avatar: z14.union([z14.url(), z14.literal("")]).nullable(),
|
|
1100
1100
|
is_staff: z14.boolean(),
|
|
1101
1101
|
is_superuser: z14.boolean(),
|
|
1102
1102
|
date_joined: z14.iso.datetime(),
|
|
@@ -1218,16 +1218,30 @@ import { consola } from "consola";
|
|
|
1218
1218
|
|
|
1219
1219
|
// src/generated/cfg_accounts/api-instance.ts
|
|
1220
1220
|
var globalAPI = null;
|
|
1221
|
+
var autoConfigAttempted = false;
|
|
1222
|
+
function tryAutoConfigureFromEnv() {
|
|
1223
|
+
if (autoConfigAttempted) return;
|
|
1224
|
+
autoConfigAttempted = true;
|
|
1225
|
+
if (globalAPI) return;
|
|
1226
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
1227
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
1228
|
+
if (baseUrl) {
|
|
1229
|
+
globalAPI = new API(baseUrl);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
__name(tryAutoConfigureFromEnv, "tryAutoConfigureFromEnv");
|
|
1221
1233
|
function getAPIInstance() {
|
|
1234
|
+
tryAutoConfigureFromEnv();
|
|
1222
1235
|
if (!globalAPI) {
|
|
1223
1236
|
throw new Error(
|
|
1224
|
-
'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" })'
|
|
1237
|
+
'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'
|
|
1225
1238
|
);
|
|
1226
1239
|
}
|
|
1227
1240
|
return globalAPI;
|
|
1228
1241
|
}
|
|
1229
1242
|
__name(getAPIInstance, "getAPIInstance");
|
|
1230
1243
|
function isAPIConfigured() {
|
|
1244
|
+
tryAutoConfigureFromEnv();
|
|
1231
1245
|
return globalAPI !== null;
|
|
1232
1246
|
}
|
|
1233
1247
|
__name(isAPIConfigured, "isAPIConfigured");
|
|
@@ -1930,6 +1944,360 @@ var API = class {
|
|
|
1930
1944
|
};
|
|
1931
1945
|
var cfg_accounts_default = API;
|
|
1932
1946
|
|
|
1947
|
+
// src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/client.ts
|
|
1948
|
+
var CentrifugoAdminApi = class {
|
|
1949
|
+
static {
|
|
1950
|
+
__name(this, "CentrifugoAdminApi");
|
|
1951
|
+
}
|
|
1952
|
+
constructor(client) {
|
|
1953
|
+
this.client = client;
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Get connection token for dashboard
|
|
1957
|
+
*
|
|
1958
|
+
* Returns JWT token and config for WebSocket connection to Centrifugo.
|
|
1959
|
+
*/
|
|
1960
|
+
async centrifugoServerAuthTokenCreate() {
|
|
1961
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/auth/token/");
|
|
1962
|
+
return response;
|
|
1963
|
+
}
|
|
1964
|
+
/**
|
|
1965
|
+
* List active channels
|
|
1966
|
+
*
|
|
1967
|
+
* Returns list of active channels with optional pattern filter.
|
|
1968
|
+
*/
|
|
1969
|
+
async centrifugoServerChannelsCreate(data) {
|
|
1970
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/channels/", { body: data });
|
|
1971
|
+
return response;
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Get channel history
|
|
1975
|
+
*
|
|
1976
|
+
* Returns message history for a channel.
|
|
1977
|
+
*/
|
|
1978
|
+
async centrifugoServerHistoryCreate(data) {
|
|
1979
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/history/", { body: data });
|
|
1980
|
+
return response;
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Get Centrifugo server info
|
|
1984
|
+
*
|
|
1985
|
+
* Returns server information including node count, version, and uptime.
|
|
1986
|
+
*/
|
|
1987
|
+
async centrifugoServerInfoCreate() {
|
|
1988
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/info/");
|
|
1989
|
+
return response;
|
|
1990
|
+
}
|
|
1991
|
+
/**
|
|
1992
|
+
* Get channel presence
|
|
1993
|
+
*
|
|
1994
|
+
* Returns list of clients currently subscribed to a channel.
|
|
1995
|
+
*/
|
|
1996
|
+
async centrifugoServerPresenceCreate(data) {
|
|
1997
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/presence/", { body: data });
|
|
1998
|
+
return response;
|
|
1999
|
+
}
|
|
2000
|
+
/**
|
|
2001
|
+
* Get channel presence statistics
|
|
2002
|
+
*
|
|
2003
|
+
* Returns quick statistics about channel presence (num_clients,
|
|
2004
|
+
* num_users).
|
|
2005
|
+
*/
|
|
2006
|
+
async centrifugoServerPresenceStatsCreate(data) {
|
|
2007
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/server/presence-stats/", { body: data });
|
|
2008
|
+
return response;
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
|
|
2012
|
+
// src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts
|
|
2013
|
+
var CentrifugoAuth = class {
|
|
2014
|
+
static {
|
|
2015
|
+
__name(this, "CentrifugoAuth");
|
|
2016
|
+
}
|
|
2017
|
+
constructor(client) {
|
|
2018
|
+
this.client = client;
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
* Get Centrifugo connection token
|
|
2022
|
+
*
|
|
2023
|
+
* Generate JWT token for WebSocket connection to Centrifugo. Token
|
|
2024
|
+
* includes user's allowed channels based on their permissions. Requires
|
|
2025
|
+
* authentication.
|
|
2026
|
+
*/
|
|
2027
|
+
async tokenRetrieve() {
|
|
2028
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/auth/token/");
|
|
2029
|
+
return response;
|
|
2030
|
+
}
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
// src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/client.ts
|
|
2034
|
+
var CentrifugoMonitoring = class {
|
|
2035
|
+
static {
|
|
2036
|
+
__name(this, "CentrifugoMonitoring");
|
|
2037
|
+
}
|
|
2038
|
+
constructor(client) {
|
|
2039
|
+
this.client = client;
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Get channel statistics
|
|
2043
|
+
*
|
|
2044
|
+
* Returns statistics grouped by channel.
|
|
2045
|
+
*/
|
|
2046
|
+
async centrifugoMonitorChannelsRetrieve(...args) {
|
|
2047
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
2048
|
+
let params;
|
|
2049
|
+
if (isParamsObject) {
|
|
2050
|
+
params = args[0];
|
|
2051
|
+
} else {
|
|
2052
|
+
params = { hours: args[0] };
|
|
2053
|
+
}
|
|
2054
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/monitor/channels/", { params });
|
|
2055
|
+
return response.results || response;
|
|
2056
|
+
}
|
|
2057
|
+
/**
|
|
2058
|
+
* Get Centrifugo health status
|
|
2059
|
+
*
|
|
2060
|
+
* Returns the current health status of the Centrifugo client.
|
|
2061
|
+
*/
|
|
2062
|
+
async centrifugoMonitorHealthRetrieve() {
|
|
2063
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/monitor/health/");
|
|
2064
|
+
return response;
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Get overview statistics
|
|
2068
|
+
*
|
|
2069
|
+
* Returns overview statistics for Centrifugo publishes.
|
|
2070
|
+
*/
|
|
2071
|
+
async centrifugoMonitorOverviewRetrieve(...args) {
|
|
2072
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
2073
|
+
let params;
|
|
2074
|
+
if (isParamsObject) {
|
|
2075
|
+
params = args[0];
|
|
2076
|
+
} else {
|
|
2077
|
+
params = { hours: args[0] };
|
|
2078
|
+
}
|
|
2079
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/monitor/overview/", { params });
|
|
2080
|
+
return response;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Get recent publishes
|
|
2084
|
+
*
|
|
2085
|
+
* Returns a paginated list of recent Centrifugo publishes with their
|
|
2086
|
+
* details. Uses standard DRF pagination.
|
|
2087
|
+
*/
|
|
2088
|
+
async centrifugoMonitorPublishesList(...args) {
|
|
2089
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
2090
|
+
let params;
|
|
2091
|
+
if (isParamsObject) {
|
|
2092
|
+
params = args[0];
|
|
2093
|
+
} else {
|
|
2094
|
+
params = { channel: args[0], page: args[1], page_size: args[2], status: args[3] };
|
|
2095
|
+
}
|
|
2096
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/monitor/publishes/", { params });
|
|
2097
|
+
return response;
|
|
2098
|
+
}
|
|
2099
|
+
/**
|
|
2100
|
+
* Get publish timeline
|
|
2101
|
+
*
|
|
2102
|
+
* Returns hourly or daily breakdown of publish counts for charts.
|
|
2103
|
+
*/
|
|
2104
|
+
async centrifugoMonitorTimelineRetrieve(...args) {
|
|
2105
|
+
const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
|
|
2106
|
+
let params;
|
|
2107
|
+
if (isParamsObject) {
|
|
2108
|
+
params = args[0];
|
|
2109
|
+
} else {
|
|
2110
|
+
params = { hours: args[0], interval: args[1] };
|
|
2111
|
+
}
|
|
2112
|
+
const response = await this.client.request("GET", "/cfg/centrifugo/monitor/timeline/", { params });
|
|
2113
|
+
return response;
|
|
2114
|
+
}
|
|
2115
|
+
};
|
|
2116
|
+
|
|
2117
|
+
// src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/client.ts
|
|
2118
|
+
var CentrifugoTesting = class {
|
|
2119
|
+
static {
|
|
2120
|
+
__name(this, "CentrifugoTesting");
|
|
2121
|
+
}
|
|
2122
|
+
constructor(client) {
|
|
2123
|
+
this.client = client;
|
|
2124
|
+
}
|
|
2125
|
+
/**
|
|
2126
|
+
* Publish test message
|
|
2127
|
+
*
|
|
2128
|
+
* Publish test message to Centrifugo via wrapper with optional ACK
|
|
2129
|
+
* tracking.
|
|
2130
|
+
*/
|
|
2131
|
+
async publishTestCreate(data) {
|
|
2132
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/testing/publish-test/", { body: data });
|
|
2133
|
+
return response;
|
|
2134
|
+
}
|
|
2135
|
+
/**
|
|
2136
|
+
* Publish with database logging
|
|
2137
|
+
*
|
|
2138
|
+
* Publish message using CentrifugoClient with database logging. This will
|
|
2139
|
+
* create CentrifugoLog records.
|
|
2140
|
+
*/
|
|
2141
|
+
async publishWithLoggingCreate(data) {
|
|
2142
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/testing/publish-with-logging/", { body: data });
|
|
2143
|
+
return response;
|
|
2144
|
+
}
|
|
2145
|
+
/**
|
|
2146
|
+
* Send manual ACK
|
|
2147
|
+
*
|
|
2148
|
+
* Manually send ACK for a message to the wrapper. Pass message_id in
|
|
2149
|
+
* request body.
|
|
2150
|
+
*/
|
|
2151
|
+
async sendAckCreate(data) {
|
|
2152
|
+
const response = await this.client.request("POST", "/cfg/centrifugo/testing/send-ack/", { body: data });
|
|
2153
|
+
return response;
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
|
|
2157
|
+
// src/generated/cfg_centrifugo/http.ts
|
|
2158
|
+
var FetchAdapter2 = class {
|
|
2159
|
+
static {
|
|
2160
|
+
__name(this, "FetchAdapter");
|
|
2161
|
+
}
|
|
2162
|
+
async request(request) {
|
|
2163
|
+
const { method, url, headers, body, params, formData } = request;
|
|
2164
|
+
let finalUrl = url;
|
|
2165
|
+
if (params) {
|
|
2166
|
+
const searchParams = new URLSearchParams();
|
|
2167
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
2168
|
+
if (value !== null && value !== void 0) {
|
|
2169
|
+
searchParams.append(key, String(value));
|
|
2170
|
+
}
|
|
2171
|
+
});
|
|
2172
|
+
const queryString = searchParams.toString();
|
|
2173
|
+
if (queryString) {
|
|
2174
|
+
finalUrl = url.includes("?") ? `${url}&${queryString}` : `${url}?${queryString}`;
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
const finalHeaders = { ...headers };
|
|
2178
|
+
let requestBody;
|
|
2179
|
+
if (formData) {
|
|
2180
|
+
requestBody = formData;
|
|
2181
|
+
} else if (body) {
|
|
2182
|
+
finalHeaders["Content-Type"] = "application/json";
|
|
2183
|
+
requestBody = JSON.stringify(body);
|
|
2184
|
+
}
|
|
2185
|
+
const response = await fetch(finalUrl, {
|
|
2186
|
+
method,
|
|
2187
|
+
headers: finalHeaders,
|
|
2188
|
+
body: requestBody,
|
|
2189
|
+
credentials: "include"
|
|
2190
|
+
// Include Django session cookies
|
|
2191
|
+
});
|
|
2192
|
+
let data = null;
|
|
2193
|
+
const contentType = response.headers.get("content-type");
|
|
2194
|
+
if (response.status !== 204 && contentType?.includes("application/json")) {
|
|
2195
|
+
data = await response.json();
|
|
2196
|
+
} else if (response.status !== 204) {
|
|
2197
|
+
data = await response.text();
|
|
2198
|
+
}
|
|
2199
|
+
const responseHeaders = {};
|
|
2200
|
+
response.headers.forEach((value, key) => {
|
|
2201
|
+
responseHeaders[key] = value;
|
|
2202
|
+
});
|
|
2203
|
+
return {
|
|
2204
|
+
data,
|
|
2205
|
+
status: response.status,
|
|
2206
|
+
statusText: response.statusText,
|
|
2207
|
+
headers: responseHeaders
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
};
|
|
2211
|
+
|
|
2212
|
+
// src/generated/cfg_centrifugo/errors.ts
|
|
2213
|
+
var APIError2 = class extends Error {
|
|
2214
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
2215
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
2216
|
+
this.statusCode = statusCode;
|
|
2217
|
+
this.statusText = statusText;
|
|
2218
|
+
this.response = response;
|
|
2219
|
+
this.url = url;
|
|
2220
|
+
this.name = "APIError";
|
|
2221
|
+
}
|
|
2222
|
+
static {
|
|
2223
|
+
__name(this, "APIError");
|
|
2224
|
+
}
|
|
2225
|
+
/**
|
|
2226
|
+
* Get error details from response.
|
|
2227
|
+
* DRF typically returns: { "detail": "Error message" } or { "field": ["error1", "error2"] }
|
|
2228
|
+
*/
|
|
2229
|
+
get details() {
|
|
2230
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
2231
|
+
return this.response;
|
|
2232
|
+
}
|
|
2233
|
+
return null;
|
|
2234
|
+
}
|
|
2235
|
+
/**
|
|
2236
|
+
* Get field-specific validation errors from DRF.
|
|
2237
|
+
* Returns: { "field_name": ["error1", "error2"], ... }
|
|
2238
|
+
*/
|
|
2239
|
+
get fieldErrors() {
|
|
2240
|
+
const details = this.details;
|
|
2241
|
+
if (!details) return null;
|
|
2242
|
+
const fieldErrors = {};
|
|
2243
|
+
for (const [key, value] of Object.entries(details)) {
|
|
2244
|
+
if (Array.isArray(value)) {
|
|
2245
|
+
fieldErrors[key] = value;
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Get single error message from DRF.
|
|
2252
|
+
* Checks for "detail", "message", or first field error.
|
|
2253
|
+
*/
|
|
2254
|
+
get errorMessage() {
|
|
2255
|
+
const details = this.details;
|
|
2256
|
+
if (!details) return this.message;
|
|
2257
|
+
if (details.detail) {
|
|
2258
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
2259
|
+
}
|
|
2260
|
+
if (details.message) {
|
|
2261
|
+
return String(details.message);
|
|
2262
|
+
}
|
|
2263
|
+
const fieldErrors = this.fieldErrors;
|
|
2264
|
+
if (fieldErrors) {
|
|
2265
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
2266
|
+
if (firstField) {
|
|
2267
|
+
return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
2268
|
+
}
|
|
2269
|
+
}
|
|
2270
|
+
return this.message;
|
|
2271
|
+
}
|
|
2272
|
+
// Helper methods for common HTTP status codes
|
|
2273
|
+
get isValidationError() {
|
|
2274
|
+
return this.statusCode === 400;
|
|
2275
|
+
}
|
|
2276
|
+
get isAuthError() {
|
|
2277
|
+
return this.statusCode === 401;
|
|
2278
|
+
}
|
|
2279
|
+
get isPermissionError() {
|
|
2280
|
+
return this.statusCode === 403;
|
|
2281
|
+
}
|
|
2282
|
+
get isNotFoundError() {
|
|
2283
|
+
return this.statusCode === 404;
|
|
2284
|
+
}
|
|
2285
|
+
get isServerError() {
|
|
2286
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
var NetworkError2 = class extends Error {
|
|
2290
|
+
constructor(message, url, originalError) {
|
|
2291
|
+
super(message);
|
|
2292
|
+
this.url = url;
|
|
2293
|
+
this.originalError = originalError;
|
|
2294
|
+
this.name = "NetworkError";
|
|
2295
|
+
}
|
|
2296
|
+
static {
|
|
2297
|
+
__name(this, "NetworkError");
|
|
2298
|
+
}
|
|
2299
|
+
};
|
|
2300
|
+
|
|
1933
2301
|
// src/generated/cfg_centrifugo/logger.ts
|
|
1934
2302
|
import { createConsola as createConsola2 } from "consola";
|
|
1935
2303
|
var DEFAULT_CONFIG2 = {
|
|
@@ -2040,52 +2408,354 @@ var APILogger2 = class {
|
|
|
2040
2408
|
});
|
|
2041
2409
|
}
|
|
2042
2410
|
}
|
|
2043
|
-
/**
|
|
2044
|
-
* Log general info
|
|
2045
|
-
*/
|
|
2046
|
-
info(message, ...args) {
|
|
2047
|
-
if (!this.config.enabled) return;
|
|
2048
|
-
this.consola.info(message, ...args);
|
|
2049
|
-
}
|
|
2050
|
-
/**
|
|
2051
|
-
* Log warning
|
|
2052
|
-
*/
|
|
2053
|
-
warn(message, ...args) {
|
|
2054
|
-
if (!this.config.enabled) return;
|
|
2055
|
-
this.consola.warn(message, ...args);
|
|
2411
|
+
/**
|
|
2412
|
+
* Log general info
|
|
2413
|
+
*/
|
|
2414
|
+
info(message, ...args) {
|
|
2415
|
+
if (!this.config.enabled) return;
|
|
2416
|
+
this.consola.info(message, ...args);
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Log warning
|
|
2420
|
+
*/
|
|
2421
|
+
warn(message, ...args) {
|
|
2422
|
+
if (!this.config.enabled) return;
|
|
2423
|
+
this.consola.warn(message, ...args);
|
|
2424
|
+
}
|
|
2425
|
+
/**
|
|
2426
|
+
* Log error
|
|
2427
|
+
*/
|
|
2428
|
+
error(message, ...args) {
|
|
2429
|
+
if (!this.config.enabled) return;
|
|
2430
|
+
this.consola.error(message, ...args);
|
|
2431
|
+
}
|
|
2432
|
+
/**
|
|
2433
|
+
* Log debug
|
|
2434
|
+
*/
|
|
2435
|
+
debug(message, ...args) {
|
|
2436
|
+
if (!this.config.enabled) return;
|
|
2437
|
+
this.consola.debug(message, ...args);
|
|
2438
|
+
}
|
|
2439
|
+
/**
|
|
2440
|
+
* Log success
|
|
2441
|
+
*/
|
|
2442
|
+
success(message, ...args) {
|
|
2443
|
+
if (!this.config.enabled) return;
|
|
2444
|
+
this.consola.success(message, ...args);
|
|
2445
|
+
}
|
|
2446
|
+
/**
|
|
2447
|
+
* Create a sub-logger with prefix
|
|
2448
|
+
*/
|
|
2449
|
+
withTag(tag) {
|
|
2450
|
+
return this.consola.withTag(tag);
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
var defaultLogger2 = new APILogger2();
|
|
2454
|
+
|
|
2455
|
+
// src/generated/cfg_centrifugo/retry.ts
|
|
2456
|
+
import pRetry2, { AbortError as AbortError2 } from "p-retry";
|
|
2457
|
+
var DEFAULT_RETRY_CONFIG2 = {
|
|
2458
|
+
retries: 3,
|
|
2459
|
+
factor: 2,
|
|
2460
|
+
minTimeout: 1e3,
|
|
2461
|
+
maxTimeout: 6e4,
|
|
2462
|
+
randomize: true,
|
|
2463
|
+
onFailedAttempt: /* @__PURE__ */ __name(() => {
|
|
2464
|
+
}, "onFailedAttempt")
|
|
2465
|
+
};
|
|
2466
|
+
function shouldRetry2(error) {
|
|
2467
|
+
if (error instanceof NetworkError2) {
|
|
2468
|
+
return true;
|
|
2469
|
+
}
|
|
2470
|
+
if (error instanceof APIError2) {
|
|
2471
|
+
const status = error.statusCode;
|
|
2472
|
+
if (status >= 500 && status < 600) {
|
|
2473
|
+
return true;
|
|
2474
|
+
}
|
|
2475
|
+
if (status === 429) {
|
|
2476
|
+
return true;
|
|
2477
|
+
}
|
|
2478
|
+
return false;
|
|
2479
|
+
}
|
|
2480
|
+
return true;
|
|
2481
|
+
}
|
|
2482
|
+
__name(shouldRetry2, "shouldRetry");
|
|
2483
|
+
async function withRetry2(fn, config) {
|
|
2484
|
+
const finalConfig = { ...DEFAULT_RETRY_CONFIG2, ...config };
|
|
2485
|
+
return pRetry2(
|
|
2486
|
+
async () => {
|
|
2487
|
+
try {
|
|
2488
|
+
return await fn();
|
|
2489
|
+
} catch (error) {
|
|
2490
|
+
if (!shouldRetry2(error)) {
|
|
2491
|
+
throw new AbortError2(error);
|
|
2492
|
+
}
|
|
2493
|
+
throw error;
|
|
2494
|
+
}
|
|
2495
|
+
},
|
|
2496
|
+
{
|
|
2497
|
+
retries: finalConfig.retries,
|
|
2498
|
+
factor: finalConfig.factor,
|
|
2499
|
+
minTimeout: finalConfig.minTimeout,
|
|
2500
|
+
maxTimeout: finalConfig.maxTimeout,
|
|
2501
|
+
randomize: finalConfig.randomize,
|
|
2502
|
+
onFailedAttempt: finalConfig.onFailedAttempt ? (error) => {
|
|
2503
|
+
const pRetryError = error;
|
|
2504
|
+
finalConfig.onFailedAttempt({
|
|
2505
|
+
error: pRetryError,
|
|
2506
|
+
attemptNumber: pRetryError.attemptNumber,
|
|
2507
|
+
retriesLeft: pRetryError.retriesLeft
|
|
2508
|
+
});
|
|
2509
|
+
} : void 0
|
|
2510
|
+
}
|
|
2511
|
+
);
|
|
2512
|
+
}
|
|
2513
|
+
__name(withRetry2, "withRetry");
|
|
2514
|
+
|
|
2515
|
+
// src/generated/cfg_centrifugo/client.ts
|
|
2516
|
+
var APIClient2 = class {
|
|
2517
|
+
constructor(baseUrl, options) {
|
|
2518
|
+
this.logger = null;
|
|
2519
|
+
this.retryConfig = null;
|
|
2520
|
+
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
2521
|
+
this.httpClient = options?.httpClient || new FetchAdapter2();
|
|
2522
|
+
if (options?.loggerConfig !== void 0) {
|
|
2523
|
+
this.logger = new APILogger2(options.loggerConfig);
|
|
2524
|
+
}
|
|
2525
|
+
if (options?.retryConfig !== void 0) {
|
|
2526
|
+
this.retryConfig = options.retryConfig;
|
|
2527
|
+
}
|
|
2528
|
+
this.centrifugo_admin_api = new CentrifugoAdminApi(this);
|
|
2529
|
+
this.centrifugo_auth = new CentrifugoAuth(this);
|
|
2530
|
+
this.centrifugo_monitoring = new CentrifugoMonitoring(this);
|
|
2531
|
+
this.centrifugo_testing = new CentrifugoTesting(this);
|
|
2532
|
+
}
|
|
2533
|
+
static {
|
|
2534
|
+
__name(this, "APIClient");
|
|
2535
|
+
}
|
|
2536
|
+
/**
|
|
2537
|
+
* Get CSRF token from cookies (for SessionAuthentication).
|
|
2538
|
+
*
|
|
2539
|
+
* Returns null if cookie doesn't exist (JWT-only auth).
|
|
2540
|
+
*/
|
|
2541
|
+
getCsrfToken() {
|
|
2542
|
+
const name = "csrftoken";
|
|
2543
|
+
const value = `; ${document.cookie}`;
|
|
2544
|
+
const parts = value.split(`; ${name}=`);
|
|
2545
|
+
if (parts.length === 2) {
|
|
2546
|
+
return parts.pop()?.split(";").shift() || null;
|
|
2547
|
+
}
|
|
2548
|
+
return null;
|
|
2549
|
+
}
|
|
2550
|
+
/**
|
|
2551
|
+
* Make HTTP request with Django CSRF and session handling.
|
|
2552
|
+
* Automatically retries on network errors and 5xx server errors.
|
|
2553
|
+
*/
|
|
2554
|
+
async request(method, path, options) {
|
|
2555
|
+
if (this.retryConfig) {
|
|
2556
|
+
return withRetry2(() => this._makeRequest(method, path, options), {
|
|
2557
|
+
...this.retryConfig,
|
|
2558
|
+
onFailedAttempt: /* @__PURE__ */ __name((info) => {
|
|
2559
|
+
if (this.logger) {
|
|
2560
|
+
this.logger.warn(
|
|
2561
|
+
`Retry attempt ${info.attemptNumber}/${info.retriesLeft + info.attemptNumber} for ${method} ${path}: ${info.error.message}`
|
|
2562
|
+
);
|
|
2563
|
+
}
|
|
2564
|
+
this.retryConfig?.onFailedAttempt?.(info);
|
|
2565
|
+
}, "onFailedAttempt")
|
|
2566
|
+
});
|
|
2567
|
+
}
|
|
2568
|
+
return this._makeRequest(method, path, options);
|
|
2569
|
+
}
|
|
2570
|
+
/**
|
|
2571
|
+
* Internal request method (without retry wrapper).
|
|
2572
|
+
* Used by request() method with optional retry logic.
|
|
2573
|
+
*/
|
|
2574
|
+
async _makeRequest(method, path, options) {
|
|
2575
|
+
const url = this.baseUrl ? `${this.baseUrl}${path}` : path;
|
|
2576
|
+
const startTime = Date.now();
|
|
2577
|
+
const headers = {
|
|
2578
|
+
...options?.headers || {}
|
|
2579
|
+
};
|
|
2580
|
+
if (!options?.formData && !headers["Content-Type"]) {
|
|
2581
|
+
headers["Content-Type"] = "application/json";
|
|
2582
|
+
}
|
|
2583
|
+
if (this.logger) {
|
|
2584
|
+
this.logger.logRequest({
|
|
2585
|
+
method,
|
|
2586
|
+
url,
|
|
2587
|
+
headers,
|
|
2588
|
+
body: options?.formData || options?.body,
|
|
2589
|
+
timestamp: startTime
|
|
2590
|
+
});
|
|
2591
|
+
}
|
|
2592
|
+
try {
|
|
2593
|
+
const response = await this.httpClient.request({
|
|
2594
|
+
method,
|
|
2595
|
+
url,
|
|
2596
|
+
headers,
|
|
2597
|
+
params: options?.params,
|
|
2598
|
+
body: options?.body,
|
|
2599
|
+
formData: options?.formData
|
|
2600
|
+
});
|
|
2601
|
+
const duration = Date.now() - startTime;
|
|
2602
|
+
if (response.status >= 400) {
|
|
2603
|
+
const error = new APIError2(
|
|
2604
|
+
response.status,
|
|
2605
|
+
response.statusText,
|
|
2606
|
+
response.data,
|
|
2607
|
+
url
|
|
2608
|
+
);
|
|
2609
|
+
if (this.logger) {
|
|
2610
|
+
this.logger.logError(
|
|
2611
|
+
{
|
|
2612
|
+
method,
|
|
2613
|
+
url,
|
|
2614
|
+
headers,
|
|
2615
|
+
body: options?.formData || options?.body,
|
|
2616
|
+
timestamp: startTime
|
|
2617
|
+
},
|
|
2618
|
+
{
|
|
2619
|
+
message: error.message,
|
|
2620
|
+
statusCode: response.status,
|
|
2621
|
+
duration,
|
|
2622
|
+
timestamp: Date.now()
|
|
2623
|
+
}
|
|
2624
|
+
);
|
|
2625
|
+
}
|
|
2626
|
+
throw error;
|
|
2627
|
+
}
|
|
2628
|
+
if (this.logger) {
|
|
2629
|
+
this.logger.logResponse(
|
|
2630
|
+
{
|
|
2631
|
+
method,
|
|
2632
|
+
url,
|
|
2633
|
+
headers,
|
|
2634
|
+
body: options?.formData || options?.body,
|
|
2635
|
+
timestamp: startTime
|
|
2636
|
+
},
|
|
2637
|
+
{
|
|
2638
|
+
status: response.status,
|
|
2639
|
+
statusText: response.statusText,
|
|
2640
|
+
data: response.data,
|
|
2641
|
+
duration,
|
|
2642
|
+
timestamp: Date.now()
|
|
2643
|
+
}
|
|
2644
|
+
);
|
|
2645
|
+
}
|
|
2646
|
+
return response.data;
|
|
2647
|
+
} catch (error) {
|
|
2648
|
+
const duration = Date.now() - startTime;
|
|
2649
|
+
if (error instanceof APIError2) {
|
|
2650
|
+
throw error;
|
|
2651
|
+
}
|
|
2652
|
+
const isCORSError = error instanceof TypeError && (error.message.toLowerCase().includes("cors") || error.message.toLowerCase().includes("failed to fetch") || error.message.toLowerCase().includes("network request failed"));
|
|
2653
|
+
if (this.logger) {
|
|
2654
|
+
if (isCORSError) {
|
|
2655
|
+
this.logger.error(`\u{1F6AB} CORS Error: ${method} ${url}`);
|
|
2656
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
2657
|
+
this.logger.error(` \u2192 Configure security_domains parameter on the server`);
|
|
2658
|
+
} else {
|
|
2659
|
+
this.logger.error(`\u26A0\uFE0F Network Error: ${method} ${url}`);
|
|
2660
|
+
this.logger.error(` \u2192 ${error instanceof Error ? error.message : String(error)}`);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
if (typeof window !== "undefined") {
|
|
2664
|
+
try {
|
|
2665
|
+
if (isCORSError) {
|
|
2666
|
+
window.dispatchEvent(new CustomEvent("cors-error", {
|
|
2667
|
+
detail: {
|
|
2668
|
+
url,
|
|
2669
|
+
method,
|
|
2670
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2671
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
2672
|
+
},
|
|
2673
|
+
bubbles: true,
|
|
2674
|
+
cancelable: false
|
|
2675
|
+
}));
|
|
2676
|
+
} else {
|
|
2677
|
+
window.dispatchEvent(new CustomEvent("network-error", {
|
|
2678
|
+
detail: {
|
|
2679
|
+
url,
|
|
2680
|
+
method,
|
|
2681
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2682
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
2683
|
+
},
|
|
2684
|
+
bubbles: true,
|
|
2685
|
+
cancelable: false
|
|
2686
|
+
}));
|
|
2687
|
+
}
|
|
2688
|
+
} catch (eventError) {
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
const networkError = error instanceof Error ? new NetworkError2(error.message, url, error) : new NetworkError2("Unknown error", url);
|
|
2692
|
+
if (this.logger) {
|
|
2693
|
+
this.logger.logError(
|
|
2694
|
+
{
|
|
2695
|
+
method,
|
|
2696
|
+
url,
|
|
2697
|
+
headers,
|
|
2698
|
+
body: options?.formData || options?.body,
|
|
2699
|
+
timestamp: startTime
|
|
2700
|
+
},
|
|
2701
|
+
{
|
|
2702
|
+
message: networkError.message,
|
|
2703
|
+
duration,
|
|
2704
|
+
timestamp: Date.now()
|
|
2705
|
+
}
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
throw networkError;
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
// src/generated/cfg_centrifugo/storage.ts
|
|
2714
|
+
var LocalStorageAdapter2 = class {
|
|
2715
|
+
static {
|
|
2716
|
+
__name(this, "LocalStorageAdapter");
|
|
2056
2717
|
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
*/
|
|
2060
|
-
error(message, ...args) {
|
|
2061
|
-
if (!this.config.enabled) return;
|
|
2062
|
-
this.consola.error(message, ...args);
|
|
2718
|
+
constructor(logger) {
|
|
2719
|
+
this.logger = logger;
|
|
2063
2720
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2721
|
+
getItem(key) {
|
|
2722
|
+
try {
|
|
2723
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
2724
|
+
const value = localStorage.getItem(key);
|
|
2725
|
+
this.logger?.debug(`LocalStorage.getItem("${key}"): ${value ? "found" : "not found"}`);
|
|
2726
|
+
return value;
|
|
2727
|
+
}
|
|
2728
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
2729
|
+
} catch (error) {
|
|
2730
|
+
this.logger?.error("LocalStorage.getItem failed:", error);
|
|
2731
|
+
}
|
|
2732
|
+
return null;
|
|
2070
2733
|
}
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2734
|
+
setItem(key, value) {
|
|
2735
|
+
try {
|
|
2736
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
2737
|
+
localStorage.setItem(key, value);
|
|
2738
|
+
this.logger?.debug(`LocalStorage.setItem("${key}"): success`);
|
|
2739
|
+
} else {
|
|
2740
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
2741
|
+
}
|
|
2742
|
+
} catch (error) {
|
|
2743
|
+
this.logger?.error("LocalStorage.setItem failed:", error);
|
|
2744
|
+
}
|
|
2077
2745
|
}
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2746
|
+
removeItem(key) {
|
|
2747
|
+
try {
|
|
2748
|
+
if (typeof window !== "undefined" && window.localStorage) {
|
|
2749
|
+
localStorage.removeItem(key);
|
|
2750
|
+
this.logger?.debug(`LocalStorage.removeItem("${key}"): success`);
|
|
2751
|
+
} else {
|
|
2752
|
+
this.logger?.warn("LocalStorage not available: window.localStorage is undefined");
|
|
2753
|
+
}
|
|
2754
|
+
} catch (error) {
|
|
2755
|
+
this.logger?.error("LocalStorage.removeItem failed:", error);
|
|
2756
|
+
}
|
|
2083
2757
|
}
|
|
2084
2758
|
};
|
|
2085
|
-
var defaultLogger2 = new APILogger2();
|
|
2086
|
-
|
|
2087
|
-
// src/generated/cfg_centrifugo/retry.ts
|
|
2088
|
-
import pRetry2, { AbortError as AbortError2 } from "p-retry";
|
|
2089
2759
|
|
|
2090
2760
|
// src/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelInfo.schema.ts
|
|
2091
2761
|
import { z as z20 } from "zod";
|
|
@@ -2409,10 +3079,23 @@ import { consola as consola5 } from "consola";
|
|
|
2409
3079
|
|
|
2410
3080
|
// src/generated/cfg_centrifugo/api-instance.ts
|
|
2411
3081
|
var globalAPI2 = null;
|
|
3082
|
+
var autoConfigAttempted2 = false;
|
|
3083
|
+
function tryAutoConfigureFromEnv2() {
|
|
3084
|
+
if (autoConfigAttempted2) return;
|
|
3085
|
+
autoConfigAttempted2 = true;
|
|
3086
|
+
if (globalAPI2) return;
|
|
3087
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
3088
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
3089
|
+
if (baseUrl) {
|
|
3090
|
+
globalAPI2 = new API2(baseUrl);
|
|
3091
|
+
}
|
|
3092
|
+
}
|
|
3093
|
+
__name(tryAutoConfigureFromEnv2, "tryAutoConfigureFromEnv");
|
|
2412
3094
|
function getAPIInstance2() {
|
|
3095
|
+
tryAutoConfigureFromEnv2();
|
|
2413
3096
|
if (!globalAPI2) {
|
|
2414
3097
|
throw new Error(
|
|
2415
|
-
'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" })'
|
|
3098
|
+
'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'
|
|
2416
3099
|
);
|
|
2417
3100
|
}
|
|
2418
3101
|
return globalAPI2;
|
|
@@ -2471,6 +3154,133 @@ import { consola as consola7 } from "consola";
|
|
|
2471
3154
|
// src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_testing.ts
|
|
2472
3155
|
import { consola as consola8 } from "consola";
|
|
2473
3156
|
|
|
3157
|
+
// src/generated/cfg_centrifugo/index.ts
|
|
3158
|
+
var TOKEN_KEY2 = "auth_token";
|
|
3159
|
+
var REFRESH_TOKEN_KEY2 = "refresh_token";
|
|
3160
|
+
var API2 = class {
|
|
3161
|
+
constructor(baseUrl, options) {
|
|
3162
|
+
this._token = null;
|
|
3163
|
+
this._refreshToken = null;
|
|
3164
|
+
this.baseUrl = baseUrl;
|
|
3165
|
+
this.options = options;
|
|
3166
|
+
const logger = options?.loggerConfig ? new APILogger2(options.loggerConfig) : void 0;
|
|
3167
|
+
this.storage = options?.storage || new LocalStorageAdapter2(logger);
|
|
3168
|
+
this._loadTokensFromStorage();
|
|
3169
|
+
this._client = new APIClient2(this.baseUrl, {
|
|
3170
|
+
retryConfig: this.options?.retryConfig,
|
|
3171
|
+
loggerConfig: this.options?.loggerConfig
|
|
3172
|
+
});
|
|
3173
|
+
this._injectAuthHeader();
|
|
3174
|
+
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
3175
|
+
this.centrifugo_auth = this._client.centrifugo_auth;
|
|
3176
|
+
this.centrifugo_monitoring = this._client.centrifugo_monitoring;
|
|
3177
|
+
this.centrifugo_testing = this._client.centrifugo_testing;
|
|
3178
|
+
}
|
|
3179
|
+
static {
|
|
3180
|
+
__name(this, "API");
|
|
3181
|
+
}
|
|
3182
|
+
_loadTokensFromStorage() {
|
|
3183
|
+
this._token = this.storage.getItem(TOKEN_KEY2);
|
|
3184
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY2);
|
|
3185
|
+
}
|
|
3186
|
+
_reinitClients() {
|
|
3187
|
+
this._client = new APIClient2(this.baseUrl, {
|
|
3188
|
+
retryConfig: this.options?.retryConfig,
|
|
3189
|
+
loggerConfig: this.options?.loggerConfig
|
|
3190
|
+
});
|
|
3191
|
+
this._injectAuthHeader();
|
|
3192
|
+
this.centrifugo_admin_api = this._client.centrifugo_admin_api;
|
|
3193
|
+
this.centrifugo_auth = this._client.centrifugo_auth;
|
|
3194
|
+
this.centrifugo_monitoring = this._client.centrifugo_monitoring;
|
|
3195
|
+
this.centrifugo_testing = this._client.centrifugo_testing;
|
|
3196
|
+
}
|
|
3197
|
+
_injectAuthHeader() {
|
|
3198
|
+
const originalRequest = this._client.request.bind(this._client);
|
|
3199
|
+
this._client.request = async (method, path, options) => {
|
|
3200
|
+
const token = this.getToken();
|
|
3201
|
+
const mergedOptions = {
|
|
3202
|
+
...options,
|
|
3203
|
+
headers: {
|
|
3204
|
+
...options?.headers || {},
|
|
3205
|
+
...token ? { "Authorization": `Bearer ${token}` } : {}
|
|
3206
|
+
}
|
|
3207
|
+
};
|
|
3208
|
+
return originalRequest(method, path, mergedOptions);
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
/**
|
|
3212
|
+
* Get current JWT token
|
|
3213
|
+
*/
|
|
3214
|
+
getToken() {
|
|
3215
|
+
return this.storage.getItem(TOKEN_KEY2);
|
|
3216
|
+
}
|
|
3217
|
+
/**
|
|
3218
|
+
* Get current refresh token
|
|
3219
|
+
*/
|
|
3220
|
+
getRefreshToken() {
|
|
3221
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY2);
|
|
3222
|
+
}
|
|
3223
|
+
/**
|
|
3224
|
+
* Set JWT token and refresh token
|
|
3225
|
+
* @param token - JWT access token
|
|
3226
|
+
* @param refreshToken - JWT refresh token (optional)
|
|
3227
|
+
*/
|
|
3228
|
+
setToken(token, refreshToken) {
|
|
3229
|
+
this._token = token;
|
|
3230
|
+
this.storage.setItem(TOKEN_KEY2, token);
|
|
3231
|
+
if (refreshToken) {
|
|
3232
|
+
this._refreshToken = refreshToken;
|
|
3233
|
+
this.storage.setItem(REFRESH_TOKEN_KEY2, refreshToken);
|
|
3234
|
+
}
|
|
3235
|
+
this._reinitClients();
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Clear all tokens
|
|
3239
|
+
*/
|
|
3240
|
+
clearTokens() {
|
|
3241
|
+
this._token = null;
|
|
3242
|
+
this._refreshToken = null;
|
|
3243
|
+
this.storage.removeItem(TOKEN_KEY2);
|
|
3244
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY2);
|
|
3245
|
+
this._reinitClients();
|
|
3246
|
+
}
|
|
3247
|
+
/**
|
|
3248
|
+
* Check if user is authenticated
|
|
3249
|
+
*/
|
|
3250
|
+
isAuthenticated() {
|
|
3251
|
+
return !!this.getToken();
|
|
3252
|
+
}
|
|
3253
|
+
/**
|
|
3254
|
+
* Update base URL and reinitialize clients
|
|
3255
|
+
* @param url - New base URL
|
|
3256
|
+
*/
|
|
3257
|
+
setBaseUrl(url) {
|
|
3258
|
+
this.baseUrl = url;
|
|
3259
|
+
this._reinitClients();
|
|
3260
|
+
}
|
|
3261
|
+
/**
|
|
3262
|
+
* Get current base URL
|
|
3263
|
+
*/
|
|
3264
|
+
getBaseUrl() {
|
|
3265
|
+
return this.baseUrl;
|
|
3266
|
+
}
|
|
3267
|
+
/**
|
|
3268
|
+
* Get OpenAPI schema path
|
|
3269
|
+
* @returns Path to the OpenAPI schema JSON file
|
|
3270
|
+
*
|
|
3271
|
+
* Note: The OpenAPI schema is available in the schema.json file.
|
|
3272
|
+
* You can load it dynamically using:
|
|
3273
|
+
* ```typescript
|
|
3274
|
+
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
3275
|
+
* // or using fs in Node.js:
|
|
3276
|
+
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
3277
|
+
* ```
|
|
3278
|
+
*/
|
|
3279
|
+
getSchemaPath() {
|
|
3280
|
+
return "./schema.json";
|
|
3281
|
+
}
|
|
3282
|
+
};
|
|
3283
|
+
|
|
2474
3284
|
// src/generated/cfg_webpush/index.ts
|
|
2475
3285
|
var cfg_webpush_exports = {};
|
|
2476
3286
|
__export(cfg_webpush_exports, {
|
|
@@ -2485,13 +3295,13 @@ __export(cfg_webpush_exports, {
|
|
|
2485
3295
|
LocalStorageAdapter: () => LocalStorageAdapter3,
|
|
2486
3296
|
MemoryStorageAdapter: () => MemoryStorageAdapter3,
|
|
2487
3297
|
NetworkError: () => NetworkError3,
|
|
2488
|
-
REFRESH_TOKEN_KEY: () =>
|
|
3298
|
+
REFRESH_TOKEN_KEY: () => REFRESH_TOKEN_KEY3,
|
|
2489
3299
|
Schemas: () => schemas_exports3,
|
|
2490
3300
|
SendPushRequestRequestSchema: () => SendPushRequestRequestSchema,
|
|
2491
3301
|
SendPushResponseSchema: () => SendPushResponseSchema,
|
|
2492
3302
|
SubscribeRequestRequestSchema: () => SubscribeRequestRequestSchema,
|
|
2493
3303
|
SubscribeResponseSchema: () => SubscribeResponseSchema,
|
|
2494
|
-
TOKEN_KEY: () =>
|
|
3304
|
+
TOKEN_KEY: () => TOKEN_KEY3,
|
|
2495
3305
|
VapidPublicKeyResponseSchema: () => VapidPublicKeyResponseSchema,
|
|
2496
3306
|
WebPushTypes: () => models_exports9,
|
|
2497
3307
|
clearAPITokens: () => clearAPITokens3,
|
|
@@ -3240,8 +4050,8 @@ import { z as z55 } from "zod";
|
|
|
3240
4050
|
var SendPushRequestRequestSchema = z55.object({
|
|
3241
4051
|
title: z55.string().min(1).max(255),
|
|
3242
4052
|
body: z55.string().min(1),
|
|
3243
|
-
icon: z55.url().nullable().optional(),
|
|
3244
|
-
url: z55.url().nullable().optional()
|
|
4053
|
+
icon: z55.union([z55.url(), z55.literal("")]).nullable().optional(),
|
|
4054
|
+
url: z55.union([z55.url(), z55.literal("")]).nullable().optional()
|
|
3245
4055
|
});
|
|
3246
4056
|
|
|
3247
4057
|
// src/generated/cfg_webpush/_utils/schemas/SendPushResponse.schema.ts
|
|
@@ -3254,7 +4064,7 @@ var SendPushResponseSchema = z56.object({
|
|
|
3254
4064
|
// src/generated/cfg_webpush/_utils/schemas/SubscribeRequestRequest.schema.ts
|
|
3255
4065
|
import { z as z57 } from "zod";
|
|
3256
4066
|
var SubscribeRequestRequestSchema = z57.object({
|
|
3257
|
-
endpoint: z57.url(),
|
|
4067
|
+
endpoint: z57.union([z57.url(), z57.literal("")]),
|
|
3258
4068
|
keys: z57.record(z57.string(), z57.string().min(1))
|
|
3259
4069
|
});
|
|
3260
4070
|
|
|
@@ -3334,16 +4144,30 @@ import { consola as consola9 } from "consola";
|
|
|
3334
4144
|
|
|
3335
4145
|
// src/generated/cfg_webpush/api-instance.ts
|
|
3336
4146
|
var globalAPI3 = null;
|
|
4147
|
+
var autoConfigAttempted3 = false;
|
|
4148
|
+
function tryAutoConfigureFromEnv3() {
|
|
4149
|
+
if (autoConfigAttempted3) return;
|
|
4150
|
+
autoConfigAttempted3 = true;
|
|
4151
|
+
if (globalAPI3) return;
|
|
4152
|
+
if (typeof process === "undefined" || !process.env) return;
|
|
4153
|
+
const baseUrl = process.env.NEXT_PUBLIC_API_URL || process.env.VITE_API_URL || process.env.REACT_APP_API_URL || process.env.API_URL;
|
|
4154
|
+
if (baseUrl) {
|
|
4155
|
+
globalAPI3 = new API3(baseUrl);
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
__name(tryAutoConfigureFromEnv3, "tryAutoConfigureFromEnv");
|
|
3337
4159
|
function getAPIInstance3() {
|
|
4160
|
+
tryAutoConfigureFromEnv3();
|
|
3338
4161
|
if (!globalAPI3) {
|
|
3339
4162
|
throw new Error(
|
|
3340
|
-
'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" })'
|
|
4163
|
+
'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'
|
|
3341
4164
|
);
|
|
3342
4165
|
}
|
|
3343
4166
|
return globalAPI3;
|
|
3344
4167
|
}
|
|
3345
4168
|
__name(getAPIInstance3, "getAPIInstance");
|
|
3346
4169
|
function isAPIConfigured3() {
|
|
4170
|
+
tryAutoConfigureFromEnv3();
|
|
3347
4171
|
return globalAPI3 !== null;
|
|
3348
4172
|
}
|
|
3349
4173
|
__name(isAPIConfigured3, "isAPIConfigured");
|
|
@@ -3511,8 +4335,8 @@ Method: GET`);
|
|
|
3511
4335
|
__name(getWebpushVapidRetrieve, "getWebpushVapidRetrieve");
|
|
3512
4336
|
|
|
3513
4337
|
// src/generated/cfg_webpush/index.ts
|
|
3514
|
-
var
|
|
3515
|
-
var
|
|
4338
|
+
var TOKEN_KEY3 = "auth_token";
|
|
4339
|
+
var REFRESH_TOKEN_KEY3 = "refresh_token";
|
|
3516
4340
|
var API3 = class {
|
|
3517
4341
|
constructor(baseUrl, options) {
|
|
3518
4342
|
this._token = null;
|
|
@@ -3533,8 +4357,8 @@ var API3 = class {
|
|
|
3533
4357
|
__name(this, "API");
|
|
3534
4358
|
}
|
|
3535
4359
|
_loadTokensFromStorage() {
|
|
3536
|
-
this._token = this.storage.getItem(
|
|
3537
|
-
this._refreshToken = this.storage.getItem(
|
|
4360
|
+
this._token = this.storage.getItem(TOKEN_KEY3);
|
|
4361
|
+
this._refreshToken = this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
3538
4362
|
}
|
|
3539
4363
|
_reinitClients() {
|
|
3540
4364
|
this._client = new APIClient3(this.baseUrl, {
|
|
@@ -3562,13 +4386,13 @@ var API3 = class {
|
|
|
3562
4386
|
* Get current JWT token
|
|
3563
4387
|
*/
|
|
3564
4388
|
getToken() {
|
|
3565
|
-
return this.storage.getItem(
|
|
4389
|
+
return this.storage.getItem(TOKEN_KEY3);
|
|
3566
4390
|
}
|
|
3567
4391
|
/**
|
|
3568
4392
|
* Get current refresh token
|
|
3569
4393
|
*/
|
|
3570
4394
|
getRefreshToken() {
|
|
3571
|
-
return this.storage.getItem(
|
|
4395
|
+
return this.storage.getItem(REFRESH_TOKEN_KEY3);
|
|
3572
4396
|
}
|
|
3573
4397
|
/**
|
|
3574
4398
|
* Set JWT token and refresh token
|
|
@@ -3577,10 +4401,10 @@ var API3 = class {
|
|
|
3577
4401
|
*/
|
|
3578
4402
|
setToken(token, refreshToken) {
|
|
3579
4403
|
this._token = token;
|
|
3580
|
-
this.storage.setItem(
|
|
4404
|
+
this.storage.setItem(TOKEN_KEY3, token);
|
|
3581
4405
|
if (refreshToken) {
|
|
3582
4406
|
this._refreshToken = refreshToken;
|
|
3583
|
-
this.storage.setItem(
|
|
4407
|
+
this.storage.setItem(REFRESH_TOKEN_KEY3, refreshToken);
|
|
3584
4408
|
}
|
|
3585
4409
|
this._reinitClients();
|
|
3586
4410
|
}
|
|
@@ -3590,8 +4414,8 @@ var API3 = class {
|
|
|
3590
4414
|
clearTokens() {
|
|
3591
4415
|
this._token = null;
|
|
3592
4416
|
this._refreshToken = null;
|
|
3593
|
-
this.storage.removeItem(
|
|
3594
|
-
this.storage.removeItem(
|
|
4417
|
+
this.storage.removeItem(TOKEN_KEY3);
|
|
4418
|
+
this.storage.removeItem(REFRESH_TOKEN_KEY3);
|
|
3595
4419
|
this._reinitClients();
|
|
3596
4420
|
}
|
|
3597
4421
|
/**
|