@djangocfg/api 2.1.231 → 2.1.233

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 (92) hide show
  1. package/README.md +25 -4
  2. package/dist/auth-server.cjs +45 -358
  3. package/dist/auth-server.cjs.map +1 -1
  4. package/dist/auth-server.mjs +43 -356
  5. package/dist/auth-server.mjs.map +1 -1
  6. package/dist/auth.cjs +223 -735
  7. package/dist/auth.cjs.map +1 -1
  8. package/dist/auth.mjs +218 -730
  9. package/dist/auth.mjs.map +1 -1
  10. package/dist/clients.cjs +313 -1568
  11. package/dist/clients.cjs.map +1 -1
  12. package/dist/clients.d.cts +211 -1932
  13. package/dist/clients.d.ts +211 -1932
  14. package/dist/clients.mjs +309 -1564
  15. package/dist/clients.mjs.map +1 -1
  16. package/dist/hooks.cjs +36 -32
  17. package/dist/hooks.cjs.map +1 -1
  18. package/dist/hooks.d.cts +76 -76
  19. package/dist/hooks.d.ts +76 -76
  20. package/dist/hooks.mjs +36 -32
  21. package/dist/hooks.mjs.map +1 -1
  22. package/dist/index.cjs +88 -593
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +88 -88
  25. package/dist/index.d.ts +88 -88
  26. package/dist/index.mjs +88 -593
  27. package/dist/index.mjs.map +1 -1
  28. package/package.json +2 -2
  29. package/src/_api/generated/cfg_accounts/accounts/models.ts +34 -34
  30. package/src/_api/generated/cfg_accounts/accounts__oauth/models.ts +41 -41
  31. package/src/_api/generated/cfg_accounts/accounts__user_profile/models.ts +18 -18
  32. package/src/_api/generated/cfg_accounts/client.ts +39 -42
  33. package/src/_api/generated/cfg_centrifugo/CLAUDE.md +2 -27
  34. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/index.ts +0 -3
  35. package/src/_api/generated/cfg_centrifugo/_utils/hooks/index.ts +0 -3
  36. package/src/_api/generated/cfg_centrifugo/_utils/schemas/index.ts +0 -34
  37. package/src/_api/generated/cfg_centrifugo/client.ts +39 -51
  38. package/src/_api/generated/cfg_centrifugo/index.ts +0 -21
  39. package/src/_api/generated/cfg_centrifugo/schema.json +4 -2039
  40. package/src/_api/generated/cfg_totp/client.ts +39 -42
  41. package/src/_api/generated/cfg_totp/totp__totp_management/models.ts +10 -10
  42. package/src/_api/generated/cfg_totp/totp__totp_setup/models.ts +12 -12
  43. package/src/_api/generated/cfg_totp/totp__totp_verification/models.ts +8 -8
  44. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_admin_api.ts +0 -344
  45. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_monitoring.ts +0 -326
  46. package/src/_api/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_testing.ts +0 -211
  47. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_admin_api.ts +0 -141
  48. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_monitoring.ts +0 -99
  49. package/src/_api/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_testing.ts +0 -82
  50. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelInfo.schema.ts +0 -19
  51. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsRequestRequest.schema.ts +0 -19
  52. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResponse.schema.ts +0 -22
  53. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoChannelsResult.schema.ts +0 -20
  54. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoClientInfo.schema.ts +0 -22
  55. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoError.schema.ts +0 -20
  56. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoHealthCheck.schema.ts +0 -22
  57. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryRequestRequest.schema.ts +0 -23
  58. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResponse.schema.ts +0 -22
  59. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoHistoryResult.schema.ts +0 -22
  60. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResponse.schema.ts +0 -22
  61. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoInfoResult.schema.ts +0 -20
  62. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoMetrics.schema.ts +0 -20
  63. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoNodeInfo.schema.ts +0 -30
  64. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoOverviewStats.schema.ts +0 -26
  65. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceRequestRequest.schema.ts +0 -19
  66. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResponse.schema.ts +0 -22
  67. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceResult.schema.ts +0 -20
  68. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsRequestRequest.schema.ts +0 -19
  69. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResponse.schema.ts +0 -22
  70. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPresenceStatsResult.schema.ts +0 -20
  71. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoProcess.schema.ts +0 -20
  72. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoPublication.schema.ts +0 -23
  73. package/src/_api/generated/cfg_centrifugo/_utils/schemas/CentrifugoStreamPosition.schema.ts +0 -20
  74. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ChannelList.schema.ts +0 -21
  75. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ChannelStats.schema.ts +0 -25
  76. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ManualAckRequestRequest.schema.ts +0 -20
  77. package/src/_api/generated/cfg_centrifugo/_utils/schemas/ManualAckResponse.schema.ts +0 -21
  78. package/src/_api/generated/cfg_centrifugo/_utils/schemas/PaginatedPublishList.schema.ts +0 -24
  79. package/src/_api/generated/cfg_centrifugo/_utils/schemas/Publish.schema.ts +0 -29
  80. package/src/_api/generated/cfg_centrifugo/_utils/schemas/PublishTestRequestRequest.schema.ts +0 -22
  81. package/src/_api/generated/cfg_centrifugo/_utils/schemas/PublishTestResponse.schema.ts +0 -24
  82. package/src/_api/generated/cfg_centrifugo/_utils/schemas/TimelineItem.schema.ts +0 -23
  83. package/src/_api/generated/cfg_centrifugo/_utils/schemas/TimelineResponse.schema.ts +0 -22
  84. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/client.ts +0 -76
  85. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/index.ts +0 -4
  86. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +0 -268
  87. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/client.ts +0 -110
  88. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/index.ts +0 -4
  89. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +0 -144
  90. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/client.ts +0 -48
  91. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/index.ts +0 -4
  92. package/src/_api/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +0 -64
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/api",
3
- "version": "2.1.231",
3
+ "version": "2.1.233",
4
4
  "description": "Auto-generated TypeScript API client with React hooks, SWR integration, and Zod validation for Django REST Framework backends",
5
5
  "keywords": [
6
6
  "django",
@@ -84,7 +84,7 @@
84
84
  "devDependencies": {
85
85
  "@types/node": "^24.7.2",
86
86
  "@types/react": "^19.1.0",
87
- "@djangocfg/typescript-config": "^2.1.231",
87
+ "@djangocfg/typescript-config": "^2.1.233",
88
88
  "next": "^16.0.10",
89
89
  "react": "^19.1.0",
90
90
  "tsup": "^8.5.0",
@@ -1,27 +1,5 @@
1
1
  // @ts-nocheck
2
2
  // Auto-generated by DjangoCFG - see CLAUDE.md
3
- /**
4
- * OTP verification response. When 2FA is required: - requires_2fa: True -
5
- * session_id: UUID of 2FA verification session - refresh/access/user: null
6
- * When 2FA is not required: - requires_2fa: False - session_id: null -
7
- * refresh/access/user: populated
8
- *
9
- * Response model (includes read-only fields).
10
- */
11
- export interface OTPVerifyResponse {
12
- /** Whether 2FA verification is required */
13
- requires_2fa?: boolean;
14
- /** 2FA session ID (if requires_2fa is True) */
15
- session_id?: string | null;
16
- /** JWT refresh token (if requires_2fa is False) */
17
- refresh?: string | null;
18
- /** JWT access token (if requires_2fa is False) */
19
- access?: string | null;
20
- user?: User | null;
21
- /** Whether user should be prompted to enable 2FA */
22
- should_prompt_2fa?: boolean;
23
- }
24
-
25
3
  /**
26
4
  * Serializer for OTP verification.
27
5
  *
@@ -35,18 +13,6 @@ export interface OTPVerifyRequest {
35
13
  source_url?: string;
36
14
  }
37
15
 
38
- /**
39
- * Serializer for OTP request.
40
- *
41
- * Request model (no read-only fields).
42
- */
43
- export interface OTPRequestRequest {
44
- /** Email address for OTP delivery */
45
- identifier: string;
46
- /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
47
- source_url?: string;
48
- }
49
-
50
16
  /**
51
17
  * OTP request response.
52
18
  *
@@ -78,6 +44,40 @@ export interface OTPErrorResponse {
78
44
  retry_after?: number | null;
79
45
  }
80
46
 
47
+ /**
48
+ * Serializer for OTP request.
49
+ *
50
+ * Request model (no read-only fields).
51
+ */
52
+ export interface OTPRequestRequest {
53
+ /** Email address for OTP delivery */
54
+ identifier: string;
55
+ /** Source URL for tracking registration (e.g., https://my.djangocfg.com) */
56
+ source_url?: string;
57
+ }
58
+
59
+ /**
60
+ * OTP verification response. When 2FA is required: - requires_2fa: True -
61
+ * session_id: UUID of 2FA verification session - refresh/access/user: null
62
+ * When 2FA is not required: - requires_2fa: False - session_id: null -
63
+ * refresh/access/user: populated
64
+ *
65
+ * Response model (includes read-only fields).
66
+ */
67
+ export interface OTPVerifyResponse {
68
+ /** Whether 2FA verification is required */
69
+ requires_2fa?: boolean;
70
+ /** 2FA session ID (if requires_2fa is True) */
71
+ session_id?: string | null;
72
+ /** JWT refresh token (if requires_2fa is False) */
73
+ refresh?: string | null;
74
+ /** JWT access token (if requires_2fa is False) */
75
+ access?: string | null;
76
+ user?: User | null;
77
+ /** Whether user should be prompted to enable 2FA */
78
+ should_prompt_2fa?: boolean;
79
+ }
80
+
81
81
  /**
82
82
  * Serializer for user details.
83
83
  *
@@ -3,27 +3,13 @@
3
3
  import * as Enums from "../enums";
4
4
 
5
5
  /**
6
- * Request to start OAuth flow.
7
- *
8
- * Request model (no read-only fields).
9
- */
10
- export interface OAuthAuthorizeRequestRequest {
11
- /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
12
- redirect_uri?: string;
13
- /** Optional source URL for registration tracking */
14
- source_url?: string;
15
- }
16
-
17
- /**
18
- * Error response for OAuth endpoints.
6
+ * Response with available OAuth providers.
19
7
  *
20
8
  * Response model (includes read-only fields).
21
9
  */
22
- export interface OAuthError {
23
- /** Error code */
24
- error: string;
25
- /** Human-readable error description */
26
- error_description?: string;
10
+ export interface OAuthProvidersResponse {
11
+ /** List of available OAuth providers */
12
+ providers: Array<Record<string, any>>;
27
13
  }
28
14
 
29
15
  /**
@@ -39,39 +25,27 @@ export interface OAuthDisconnectRequestRequest {
39
25
  }
40
26
 
41
27
  /**
42
- * Response with available OAuth providers.
28
+ * Error response for OAuth endpoints.
43
29
  *
44
30
  * Response model (includes read-only fields).
45
31
  */
46
- export interface OAuthProvidersResponse {
47
- /** List of available OAuth providers */
48
- providers: Array<Record<string, any>>;
32
+ export interface OAuthError {
33
+ /** Error code */
34
+ error: string;
35
+ /** Human-readable error description */
36
+ error_description?: string;
49
37
  }
50
38
 
51
39
  /**
52
- * Request to complete OAuth flow (callback handler).
40
+ * Request to start OAuth flow.
53
41
  *
54
42
  * Request model (no read-only fields).
55
43
  */
56
- export interface OAuthCallbackRequestRequest {
57
- /** Authorization code from OAuth provider callback */
58
- code: string;
59
- /** State token for CSRF verification (from authorize response) */
60
- state: string;
61
- /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
44
+ export interface OAuthAuthorizeRequestRequest {
45
+ /** URL to redirect after OAuth authorization. If not provided, uses config's site_url + callback_path */
62
46
  redirect_uri?: string;
63
- }
64
-
65
- /**
66
- * Response with OAuth authorization URL.
67
- *
68
- * Response model (includes read-only fields).
69
- */
70
- export interface OAuthAuthorizeResponse {
71
- /** Full URL to redirect user to OAuth provider */
72
- authorization_url: string;
73
- /** State token for CSRF protection. Store this and verify on callback. */
74
- state: string;
47
+ /** Optional source URL for registration tracking */
48
+ source_url?: string;
75
49
  }
76
50
 
77
51
  /**
@@ -125,3 +99,29 @@ export interface OAuthConnection {
125
99
  last_login_at: string;
126
100
  }
127
101
 
102
+ /**
103
+ * Response with OAuth authorization URL.
104
+ *
105
+ * Response model (includes read-only fields).
106
+ */
107
+ export interface OAuthAuthorizeResponse {
108
+ /** Full URL to redirect user to OAuth provider */
109
+ authorization_url: string;
110
+ /** State token for CSRF protection. Store this and verify on callback. */
111
+ state: string;
112
+ }
113
+
114
+ /**
115
+ * Request to complete OAuth flow (callback handler).
116
+ *
117
+ * Request model (no read-only fields).
118
+ */
119
+ export interface OAuthCallbackRequestRequest {
120
+ /** Authorization code from OAuth provider callback */
121
+ code: string;
122
+ /** State token for CSRF verification (from authorize response) */
123
+ state: string;
124
+ /** Same redirect_uri used in authorize request. If not provided, uses config's site_url + callback_path */
125
+ redirect_uri?: string;
126
+ }
127
+
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * Request model (no read-only fields).
7
7
  */
8
- export interface UserProfileUpdateRequest {
8
+ export interface PatchedUserProfileUpdateRequest {
9
9
  first_name?: string;
10
10
  last_name?: string;
11
11
  company?: string;
@@ -14,15 +14,6 @@ export interface UserProfileUpdateRequest {
14
14
  language?: string;
15
15
  }
16
16
 
17
- /**
18
- *
19
- * Request model (no read-only fields).
20
- */
21
- export interface CfgAccountsProfileAvatarCreateRequest {
22
- /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
23
- avatar: File | Blob;
24
- }
25
-
26
17
  /**
27
18
  * Serializer for user details.
28
19
  *
@@ -54,12 +45,24 @@ export interface User {
54
45
  centrifugo: CentrifugoToken | null;
55
46
  }
56
47
 
48
+ /**
49
+ * Response serializer for account deletion.
50
+ *
51
+ * Response model (includes read-only fields).
52
+ */
53
+ export interface AccountDeleteResponse {
54
+ /** Whether the account was successfully deleted */
55
+ success: boolean;
56
+ /** Human-readable message about the deletion */
57
+ message: string;
58
+ }
59
+
57
60
  /**
58
61
  * Serializer for updating user profile.
59
62
  *
60
63
  * Request model (no read-only fields).
61
64
  */
62
- export interface PatchedUserProfileUpdateRequest {
65
+ export interface UserProfileUpdateRequest {
63
66
  first_name?: string;
64
67
  last_name?: string;
65
68
  company?: string;
@@ -69,15 +72,12 @@ export interface PatchedUserProfileUpdateRequest {
69
72
  }
70
73
 
71
74
  /**
72
- * Response serializer for account deletion.
73
75
  *
74
- * Response model (includes read-only fields).
76
+ * Request model (no read-only fields).
75
77
  */
76
- export interface AccountDeleteResponse {
77
- /** Whether the account was successfully deleted */
78
- success: boolean;
79
- /** Human-readable message about the deletion */
80
- message: string;
78
+ export interface CfgAccountsProfileAvatarCreateRequest {
79
+ /** Avatar image file (JPEG, PNG, GIF, WebP, max 5MB) */
80
+ avatar: File | Blob;
81
81
  }
82
82
 
83
83
  /**
@@ -251,55 +251,52 @@ export class APIClient {
251
251
  throw error;
252
252
  }
253
253
 
254
- // Detect CORS errors and dispatch event
255
- const isCORSError = error instanceof TypeError &&
256
- (error.message.toLowerCase().includes('cors') ||
257
- error.message.toLowerCase().includes('failed to fetch') ||
258
- error.message.toLowerCase().includes('network request failed'));
254
+ // Classify network error using PerformanceResourceTiming.
255
+ // Browser intentionally makes CORS errors indistinguishable from network failures
256
+ // (same TypeError: "Failed to fetch") for security reasons. We use PerformanceResourceTiming
257
+ // as the best available heuristic:
258
+ // - Entry exists with responseStatus === 0 → request reached server, JS blocked → likely CORS
259
+ // - No entry / entry missing → connection never established → server unavailable / DNS / offline
260
+ // All cases are dispatched as 'network-error' with a `possibly_cors` flag.
261
+ let possiblyCors = false;
262
+ if (error instanceof TypeError && typeof window !== 'undefined') {
263
+ try {
264
+ const isCrossOrigin = (() => {
265
+ try { return new URL(url).origin !== window.location.origin; } catch { return false; }
266
+ })();
267
+ if (isCrossOrigin) {
268
+ const entries = performance.getEntriesByName(url, 'resource');
269
+ if (entries.length > 0) {
270
+ const last = entries[entries.length - 1] as PerformanceResourceTiming;
271
+ possiblyCors = 'responseStatus' in last && (last as any).responseStatus === 0;
272
+ }
273
+ }
274
+ } catch { /* ignore — PerformanceResourceTiming not available */ }
275
+ }
259
276
 
260
- // Log specific error type first
261
277
  if (this.logger) {
262
- if (isCORSError) {
263
- this.logger.error(`🚫 CORS Error: ${method} ${url}`);
264
- this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
265
- this.logger.error(` → Configure security_domains parameter on the server`);
266
- } else {
267
- this.logger.error(`⚠️ Network Error: ${method} ${url}`);
268
- this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
278
+ this.logger.error(`⚠️ Network Error: ${method} ${url}`);
279
+ this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
280
+ if (possiblyCors) {
281
+ this.logger.error(` → Possibly blocked by CORS policy (configure CORS on the server)`);
269
282
  }
270
283
  }
271
284
 
272
- // Dispatch browser events
285
+ // Dispatch network-error event with possibly_cors hint
273
286
  if (typeof window !== 'undefined') {
274
287
  try {
275
- if (isCORSError) {
276
- // Dispatch CORS-specific error event
277
- window.dispatchEvent(new CustomEvent('cors-error', {
278
- detail: {
279
- url: url,
280
- method: method,
281
- error: error instanceof Error ? error.message : String(error),
282
- timestamp: new Date(),
283
- },
284
- bubbles: true,
285
- cancelable: false,
286
- }));
287
- } else {
288
- // Dispatch generic network error event
289
- window.dispatchEvent(new CustomEvent('network-error', {
290
- detail: {
291
- url: url,
292
- method: method,
293
- error: error instanceof Error ? error.message : String(error),
294
- timestamp: new Date(),
295
- },
296
- bubbles: true,
297
- cancelable: false,
298
- }));
299
- }
300
- } catch (eventError) {
301
- // Silently fail - event dispatch should never crash the app
302
- }
288
+ window.dispatchEvent(new CustomEvent('network-error', {
289
+ detail: {
290
+ url: url,
291
+ method: method,
292
+ error: error instanceof Error ? error.message : String(error),
293
+ possibly_cors: possiblyCors,
294
+ timestamp: new Date(),
295
+ },
296
+ bubbles: true,
297
+ cancelable: false,
298
+ }));
299
+ } catch { /* silently ignore — event dispatch must never crash the app */ }
303
300
  }
304
301
 
305
302
  // Wrap other errors as NetworkError
@@ -11,41 +11,18 @@ python manage.py generate_client --groups cfg_centrifugo --typescript
11
11
  | | |
12
12
  |---|---|
13
13
  | Version | 3.1.0 |
14
- | Operations | 15 |
15
- | Schemas | 35 |
14
+ | Operations | 1 |
15
+ | Schemas | 1 |
16
16
 
17
17
  ## Resources
18
18
 
19
- - **Centrifugo Admin API** (6 ops)
20
19
  - **Centrifugo Auth** (1 ops)
21
- - **Centrifugo Monitoring** (5 ops)
22
- - **Centrifugo Testing** (3 ops)
23
20
 
24
21
  ## Operations
25
22
 
26
- **Centrifugo Admin API:**
27
- - `POST` /cfg/centrifugo/server/auth/token/ → `cfg_centrifugo_server_auth_token_create`
28
- - `POST` /cfg/centrifugo/server/channels/ → `cfg_centrifugo_server_channels_create`
29
- - `POST` /cfg/centrifugo/server/history/ → `cfg_centrifugo_server_history_create`
30
- - `POST` /cfg/centrifugo/server/info/ → `cfg_centrifugo_server_info_create`
31
- - `POST` /cfg/centrifugo/server/presence/ → `cfg_centrifugo_server_presence_create`
32
- - `POST` /cfg/centrifugo/server/presence-stats/ → `cfg_centrifugo_server_presence_stats_create`
33
-
34
23
  **Centrifugo Auth:**
35
24
  - `GET` /cfg/centrifugo/auth/token/ → `cfg_centrifugo_auth_token_retrieve`
36
25
 
37
- **Centrifugo Monitoring:**
38
- - `GET` /cfg/centrifugo/monitor/channels/ → `cfg_centrifugo_monitor_channels_retrieve`
39
- - `GET` /cfg/centrifugo/monitor/health/ → `cfg_centrifugo_monitor_health_retrieve`
40
- - `GET` /cfg/centrifugo/monitor/overview/ → `cfg_centrifugo_monitor_overview_retrieve`
41
- - `GET` /cfg/centrifugo/monitor/publishes/ → `cfg_centrifugo_monitor_publishes_list`
42
- - `GET` /cfg/centrifugo/monitor/timeline/ → `cfg_centrifugo_monitor_timeline_retrieve`
43
-
44
- **Centrifugo Testing:**
45
- - `POST` /cfg/centrifugo/testing/publish-test/ → `cfg_centrifugo_testing_publish_test_create`
46
- - `POST` /cfg/centrifugo/testing/publish-with-logging/ → `cfg_centrifugo_testing_publish_with_logging_create`
47
- - `POST` /cfg/centrifugo/testing/send-ack/ → `cfg_centrifugo_testing_send_ack_create`
48
-
49
26
  ## Usage
50
27
 
51
28
  ```typescript
@@ -54,8 +31,6 @@ import { APIClient } from './';
54
31
  const client = new APIClient({ baseUrl, token });
55
32
 
56
33
  await client.centrifugo auth.retrieve({ id: 1 });
57
- await client.centrifugo monitoring.list();
58
- await client.centrifugo monitoring.retrieve({ id: 1 });
59
34
  ```
60
35
 
61
36
  **SWR Hooks:**
@@ -27,7 +27,4 @@
27
27
  * ```
28
28
  */
29
29
 
30
- export * from './centrifugo__centrifugo_admin_api'
31
30
  export * from './centrifugo__centrifugo_auth'
32
- export * from './centrifugo__centrifugo_monitoring'
33
- export * from './centrifugo__centrifugo_testing'
@@ -27,7 +27,4 @@
27
27
  * ```
28
28
  */
29
29
 
30
- export * from './centrifugo__centrifugo_admin_api'
31
30
  export * from './centrifugo__centrifugo_auth'
32
- export * from './centrifugo__centrifugo_monitoring'
33
- export * from './centrifugo__centrifugo_testing'
@@ -18,38 +18,4 @@
18
18
  * ```
19
19
  */
20
20
 
21
- export * from './CentrifugoChannelInfo.schema'
22
- export * from './CentrifugoChannelsRequestRequest.schema'
23
- export * from './CentrifugoChannelsResponse.schema'
24
- export * from './CentrifugoChannelsResult.schema'
25
- export * from './CentrifugoClientInfo.schema'
26
- export * from './CentrifugoError.schema'
27
- export * from './CentrifugoHealthCheck.schema'
28
- export * from './CentrifugoHistoryRequestRequest.schema'
29
- export * from './CentrifugoHistoryResponse.schema'
30
- export * from './CentrifugoHistoryResult.schema'
31
- export * from './CentrifugoInfoResponse.schema'
32
- export * from './CentrifugoInfoResult.schema'
33
- export * from './CentrifugoMetrics.schema'
34
- export * from './CentrifugoNodeInfo.schema'
35
- export * from './CentrifugoOverviewStats.schema'
36
- export * from './CentrifugoPresenceRequestRequest.schema'
37
- export * from './CentrifugoPresenceResponse.schema'
38
- export * from './CentrifugoPresenceResult.schema'
39
- export * from './CentrifugoPresenceStatsRequestRequest.schema'
40
- export * from './CentrifugoPresenceStatsResponse.schema'
41
- export * from './CentrifugoPresenceStatsResult.schema'
42
- export * from './CentrifugoProcess.schema'
43
- export * from './CentrifugoPublication.schema'
44
- export * from './CentrifugoStreamPosition.schema'
45
- export * from './ChannelList.schema'
46
- export * from './ChannelStats.schema'
47
21
  export * from './ConnectionTokenResponse.schema'
48
- export * from './ManualAckRequestRequest.schema'
49
- export * from './ManualAckResponse.schema'
50
- export * from './PaginatedPublishList.schema'
51
- export * from './Publish.schema'
52
- export * from './PublishTestRequestRequest.schema'
53
- export * from './PublishTestResponse.schema'
54
- export * from './TimelineItem.schema'
55
- export * from './TimelineResponse.schema'
@@ -1,7 +1,4 @@
1
- import { CentrifugoAdminApi } from "./centrifugo__centrifugo_admin_api";
2
1
  import { CentrifugoAuth } from "./centrifugo__centrifugo_auth";
3
- import { CentrifugoMonitoring } from "./centrifugo__centrifugo_monitoring";
4
- import { CentrifugoTesting } from "./centrifugo__centrifugo_testing";
5
2
  import { HttpClientAdapter, FetchAdapter } from "./http";
6
3
  import { APIError, NetworkError } from "./errors";
7
4
  import { APILogger, type LoggerConfig } from "./logger";
@@ -31,10 +28,7 @@ export class APIClient {
31
28
  private tokenGetter: (() => string | null) | null = null;
32
29
 
33
30
  // Sub-clients
34
- public centrifugo_admin_api: CentrifugoAdminApi;
35
31
  public centrifugo_auth: CentrifugoAuth;
36
- public centrifugo_monitoring: CentrifugoMonitoring;
37
- public centrifugo_testing: CentrifugoTesting;
38
32
 
39
33
  constructor(
40
34
  baseUrl: string,
@@ -60,10 +54,7 @@ export class APIClient {
60
54
  }
61
55
 
62
56
  // Initialize sub-clients
63
- this.centrifugo_admin_api = new CentrifugoAdminApi(this);
64
57
  this.centrifugo_auth = new CentrifugoAuth(this);
65
- this.centrifugo_monitoring = new CentrifugoMonitoring(this);
66
- this.centrifugo_testing = new CentrifugoTesting(this);
67
58
  }
68
59
 
69
60
  /**
@@ -251,55 +242,52 @@ export class APIClient {
251
242
  throw error;
252
243
  }
253
244
 
254
- // Detect CORS errors and dispatch event
255
- const isCORSError = error instanceof TypeError &&
256
- (error.message.toLowerCase().includes('cors') ||
257
- error.message.toLowerCase().includes('failed to fetch') ||
258
- error.message.toLowerCase().includes('network request failed'));
245
+ // Classify network error using PerformanceResourceTiming.
246
+ // Browser intentionally makes CORS errors indistinguishable from network failures
247
+ // (same TypeError: "Failed to fetch") for security reasons. We use PerformanceResourceTiming
248
+ // as the best available heuristic:
249
+ // - Entry exists with responseStatus === 0 → request reached server, JS blocked → likely CORS
250
+ // - No entry / entry missing → connection never established → server unavailable / DNS / offline
251
+ // All cases are dispatched as 'network-error' with a `possibly_cors` flag.
252
+ let possiblyCors = false;
253
+ if (error instanceof TypeError && typeof window !== 'undefined') {
254
+ try {
255
+ const isCrossOrigin = (() => {
256
+ try { return new URL(url).origin !== window.location.origin; } catch { return false; }
257
+ })();
258
+ if (isCrossOrigin) {
259
+ const entries = performance.getEntriesByName(url, 'resource');
260
+ if (entries.length > 0) {
261
+ const last = entries[entries.length - 1] as PerformanceResourceTiming;
262
+ possiblyCors = 'responseStatus' in last && (last as any).responseStatus === 0;
263
+ }
264
+ }
265
+ } catch { /* ignore — PerformanceResourceTiming not available */ }
266
+ }
259
267
 
260
- // Log specific error type first
261
268
  if (this.logger) {
262
- if (isCORSError) {
263
- this.logger.error(`🚫 CORS Error: ${method} ${url}`);
264
- this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
265
- this.logger.error(` → Configure security_domains parameter on the server`);
266
- } else {
267
- this.logger.error(`⚠️ Network Error: ${method} ${url}`);
268
- this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
269
+ this.logger.error(`⚠️ Network Error: ${method} ${url}`);
270
+ this.logger.error(` → ${error instanceof Error ? error.message : String(error)}`);
271
+ if (possiblyCors) {
272
+ this.logger.error(` → Possibly blocked by CORS policy (configure CORS on the server)`);
269
273
  }
270
274
  }
271
275
 
272
- // Dispatch browser events
276
+ // Dispatch network-error event with possibly_cors hint
273
277
  if (typeof window !== 'undefined') {
274
278
  try {
275
- if (isCORSError) {
276
- // Dispatch CORS-specific error event
277
- window.dispatchEvent(new CustomEvent('cors-error', {
278
- detail: {
279
- url: url,
280
- method: method,
281
- error: error instanceof Error ? error.message : String(error),
282
- timestamp: new Date(),
283
- },
284
- bubbles: true,
285
- cancelable: false,
286
- }));
287
- } else {
288
- // Dispatch generic network error event
289
- window.dispatchEvent(new CustomEvent('network-error', {
290
- detail: {
291
- url: url,
292
- method: method,
293
- error: error instanceof Error ? error.message : String(error),
294
- timestamp: new Date(),
295
- },
296
- bubbles: true,
297
- cancelable: false,
298
- }));
299
- }
300
- } catch (eventError) {
301
- // Silently fail - event dispatch should never crash the app
302
- }
279
+ window.dispatchEvent(new CustomEvent('network-error', {
280
+ detail: {
281
+ url: url,
282
+ method: method,
283
+ error: error instanceof Error ? error.message : String(error),
284
+ possibly_cors: possiblyCors,
285
+ timestamp: new Date(),
286
+ },
287
+ bubbles: true,
288
+ cancelable: false,
289
+ }));
290
+ } catch { /* silently ignore — event dispatch must never crash the app */ }
303
291
  }
304
292
 
305
293
  // Wrap other errors as NetworkError