@djangocfg/api 2.1.192 → 2.1.193
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-server.cjs +37 -3
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +37 -3
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +102 -5
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +4 -0
- package/dist/auth.d.ts +4 -0
- package/dist/auth.mjs +102 -5
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +107 -10
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +47 -0
- package/dist/clients.d.ts +47 -0
- package/dist/clients.mjs +107 -10
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +37 -3
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +20 -0
- package/dist/hooks.d.ts +20 -0
- package/dist/hooks.mjs +37 -3
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +69 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.mjs +69 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/generated/cfg_accounts/_utils/fetchers/accounts.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__auth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__oauth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/accounts__user_profile.ts +1 -0
- package/src/generated/cfg_accounts/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__auth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__oauth.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/accounts__user_profile.ts +1 -0
- package/src/generated/cfg_accounts/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/PatchedUserProfileUpdateRequest.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/User.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/UserProfileUpdateRequest.schema.ts +1 -0
- package/src/generated/cfg_accounts/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts/models.ts +2 -0
- package/src/generated/cfg_accounts/accounts__auth/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__auth/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__auth/models.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__oauth/models.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/client.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/index.ts +1 -0
- package/src/generated/cfg_accounts/accounts__user_profile/models.ts +4 -0
- package/src/generated/cfg_accounts/api-instance.ts +1 -0
- package/src/generated/cfg_accounts/enums.ts +1 -0
- package/src/generated/cfg_accounts/errors.ts +1 -0
- package/src/generated/cfg_accounts/http.ts +1 -0
- package/src/generated/cfg_accounts/index.ts +37 -0
- package/src/generated/cfg_accounts/logger.ts +1 -0
- package/src/generated/cfg_accounts/retry.ts +1 -0
- package/src/generated/cfg_accounts/schema.json +12 -0
- package/src/generated/cfg_accounts/storage.ts +1 -0
- package/src/generated/cfg_accounts/validation-events.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_admin_api.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_auth.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_monitoring.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/centrifugo__centrifugo_testing.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_admin_api.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_auth.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_monitoring.ts +5 -4
- package/src/generated/cfg_centrifugo/_utils/hooks/centrifugo__centrifugo_testing.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_centrifugo/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_centrifugo/api-instance.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_admin_api/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_auth/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_monitoring/models.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/client.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/index.ts +1 -0
- package/src/generated/cfg_centrifugo/centrifugo__centrifugo_testing/models.ts +1 -0
- package/src/generated/cfg_centrifugo/errors.ts +1 -0
- package/src/generated/cfg_centrifugo/http.ts +1 -0
- package/src/generated/cfg_centrifugo/index.ts +37 -0
- package/src/generated/cfg_centrifugo/logger.ts +1 -0
- package/src/generated/cfg_centrifugo/retry.ts +1 -0
- package/src/generated/cfg_centrifugo/storage.ts +1 -0
- package/src/generated/cfg_centrifugo/validation-events.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/index.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__backup_codes.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_management.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_setup.ts +1 -0
- package/src/generated/cfg_totp/_utils/fetchers/totp__totp_verification.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/index.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__backup_codes.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_management.ts +2 -1
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_setup.ts +1 -0
- package/src/generated/cfg_totp/_utils/hooks/totp__totp_verification.ts +1 -0
- package/src/generated/cfg_totp/_utils/schemas/TotpVerifyUser.schema.ts +1 -0
- package/src/generated/cfg_totp/_utils/schemas/index.ts +1 -0
- package/src/generated/cfg_totp/api-instance.ts +1 -0
- package/src/generated/cfg_totp/enums.ts +1 -0
- package/src/generated/cfg_totp/errors.ts +1 -0
- package/src/generated/cfg_totp/http.ts +1 -0
- package/src/generated/cfg_totp/index.ts +37 -0
- package/src/generated/cfg_totp/logger.ts +1 -0
- package/src/generated/cfg_totp/retry.ts +1 -0
- package/src/generated/cfg_totp/schema.json +4 -0
- package/src/generated/cfg_totp/storage.ts +1 -0
- package/src/generated/cfg_totp/totp/client.ts +1 -0
- package/src/generated/cfg_totp/totp/index.ts +1 -0
- package/src/generated/cfg_totp/totp/models.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/client.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/index.ts +1 -0
- package/src/generated/cfg_totp/totp__backup_codes/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_management/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_setup/models.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/client.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/index.ts +1 -0
- package/src/generated/cfg_totp/totp__totp_verification/models.ts +2 -0
- package/src/generated/cfg_totp/validation-events.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/api",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.193",
|
|
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.0.0",
|
|
87
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
87
|
+
"@djangocfg/typescript-config": "^2.1.193",
|
|
88
88
|
"next": "^16.0.0",
|
|
89
89
|
"react": "^19.0.0",
|
|
90
90
|
"tsup": "^8.5.0",
|
|
@@ -21,6 +21,7 @@ export const UserSchema = z.object({
|
|
|
21
21
|
company: z.string().max(100).optional(),
|
|
22
22
|
phone: z.string().max(20).optional(),
|
|
23
23
|
position: z.string().max(100).optional(),
|
|
24
|
+
language: z.string().max(10).optional(),
|
|
24
25
|
avatar: z.union([z.url(), z.literal('')]).nullable(),
|
|
25
26
|
is_staff: z.boolean(),
|
|
26
27
|
is_superuser: z.boolean(),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
import * as Enums from "../enums";
|
|
3
4
|
|
|
@@ -97,6 +98,7 @@ export interface User {
|
|
|
97
98
|
company?: string;
|
|
98
99
|
phone?: string;
|
|
99
100
|
position?: string;
|
|
101
|
+
language?: string;
|
|
100
102
|
avatar?: string | null;
|
|
101
103
|
/** Designates whether the user can log into this admin site. */
|
|
102
104
|
is_staff: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
/**
|
|
3
4
|
* Serializer for user details.
|
|
@@ -18,6 +19,7 @@ export interface User {
|
|
|
18
19
|
company?: string;
|
|
19
20
|
phone?: string;
|
|
20
21
|
position?: string;
|
|
22
|
+
language?: string;
|
|
21
23
|
avatar?: string | null;
|
|
22
24
|
/** Designates whether the user can log into this admin site. */
|
|
23
25
|
is_staff: boolean;
|
|
@@ -61,6 +63,7 @@ export interface UserProfileUpdateRequest {
|
|
|
61
63
|
company?: string;
|
|
62
64
|
phone?: string;
|
|
63
65
|
position?: string;
|
|
66
|
+
language?: string;
|
|
64
67
|
}
|
|
65
68
|
|
|
66
69
|
/**
|
|
@@ -74,6 +77,7 @@ export interface PatchedUserProfileUpdateRequest {
|
|
|
74
77
|
company?: string;
|
|
75
78
|
phone?: string;
|
|
76
79
|
position?: string;
|
|
80
|
+
language?: string;
|
|
77
81
|
}
|
|
78
82
|
|
|
79
83
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
/**
|
|
3
4
|
* Django CFG API - API Client with JWT Management
|
|
@@ -113,6 +114,20 @@ export { withRetry, shouldRetry, DEFAULT_RETRY_CONFIG } from "./retry";
|
|
|
113
114
|
export const TOKEN_KEY = "auth_token";
|
|
114
115
|
export const REFRESH_TOKEN_KEY = "refresh_token";
|
|
115
116
|
|
|
117
|
+
/** Auto-detect locale from cookie NEXT_LOCALE or navigator.language */
|
|
118
|
+
function detectLocale(): string | null {
|
|
119
|
+
try {
|
|
120
|
+
if (typeof document !== 'undefined') {
|
|
121
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
122
|
+
if (match) return match[1];
|
|
123
|
+
}
|
|
124
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
125
|
+
return navigator.language;
|
|
126
|
+
}
|
|
127
|
+
} catch {}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
export interface APIOptions {
|
|
117
132
|
/** Custom storage adapter (defaults to LocalStorageAdapter) */
|
|
118
133
|
storage?: StorageAdapter;
|
|
@@ -120,6 +135,8 @@ export interface APIOptions {
|
|
|
120
135
|
retryConfig?: RetryConfig;
|
|
121
136
|
/** Logger configuration */
|
|
122
137
|
loggerConfig?: Partial<LoggerConfig>;
|
|
138
|
+
/** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
|
|
139
|
+
locale?: string;
|
|
123
140
|
}
|
|
124
141
|
|
|
125
142
|
export class API {
|
|
@@ -127,6 +144,7 @@ export class API {
|
|
|
127
144
|
private _client: APIClient;
|
|
128
145
|
private _token: string | null = null;
|
|
129
146
|
private _refreshToken: string | null = null;
|
|
147
|
+
private _locale: string | null = null;
|
|
130
148
|
private storage: StorageAdapter;
|
|
131
149
|
private options?: APIOptions;
|
|
132
150
|
|
|
@@ -146,6 +164,8 @@ export class API {
|
|
|
146
164
|
// Initialize storage with logger
|
|
147
165
|
this.storage = options?.storage || new LocalStorageAdapter(logger);
|
|
148
166
|
|
|
167
|
+
this._locale = options?.locale || null;
|
|
168
|
+
|
|
149
169
|
this._loadTokensFromStorage();
|
|
150
170
|
|
|
151
171
|
// Initialize APIClient with token getter for URL authentication
|
|
@@ -197,11 +217,13 @@ export class API {
|
|
|
197
217
|
): Promise<T> => {
|
|
198
218
|
// Read token from storage dynamically (supports JWT injection after instantiation)
|
|
199
219
|
const token = this.getToken();
|
|
220
|
+
const locale = this._locale || detectLocale();
|
|
200
221
|
const mergedOptions = {
|
|
201
222
|
...options,
|
|
202
223
|
headers: {
|
|
203
224
|
...(options?.headers || {}),
|
|
204
225
|
...(token ? { 'Authorization': `Bearer ${token}` } : {}),
|
|
226
|
+
...(locale ? { 'Accept-Language': locale } : {}),
|
|
205
227
|
},
|
|
206
228
|
};
|
|
207
229
|
|
|
@@ -277,6 +299,21 @@ export class API {
|
|
|
277
299
|
return this.baseUrl;
|
|
278
300
|
}
|
|
279
301
|
|
|
302
|
+
/**
|
|
303
|
+
* Set locale for Accept-Language header
|
|
304
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
305
|
+
*/
|
|
306
|
+
setLocale(locale: string | null): void {
|
|
307
|
+
this._locale = locale;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Get current locale
|
|
312
|
+
*/
|
|
313
|
+
getLocale(): string | null {
|
|
314
|
+
return this._locale;
|
|
315
|
+
}
|
|
316
|
+
|
|
280
317
|
/**
|
|
281
318
|
* Get OpenAPI schema path
|
|
282
319
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -1345,6 +1345,10 @@
|
|
|
1345
1345
|
"position": {
|
|
1346
1346
|
"type": "string",
|
|
1347
1347
|
"maxLength": 100
|
|
1348
|
+
},
|
|
1349
|
+
"language": {
|
|
1350
|
+
"type": "string",
|
|
1351
|
+
"maxLength": 10
|
|
1348
1352
|
}
|
|
1349
1353
|
}
|
|
1350
1354
|
},
|
|
@@ -1424,6 +1428,10 @@
|
|
|
1424
1428
|
"type": "string",
|
|
1425
1429
|
"maxLength": 100
|
|
1426
1430
|
},
|
|
1431
|
+
"language": {
|
|
1432
|
+
"type": "string",
|
|
1433
|
+
"maxLength": 10
|
|
1434
|
+
},
|
|
1427
1435
|
"avatar": {
|
|
1428
1436
|
"type": "string",
|
|
1429
1437
|
"format": "uri",
|
|
@@ -1506,6 +1514,10 @@
|
|
|
1506
1514
|
"position": {
|
|
1507
1515
|
"type": "string",
|
|
1508
1516
|
"maxLength": 100
|
|
1517
|
+
},
|
|
1518
|
+
"language": {
|
|
1519
|
+
"type": "string",
|
|
1520
|
+
"maxLength": 10
|
|
1509
1521
|
}
|
|
1510
1522
|
}
|
|
1511
1523
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
'use client';
|
|
3
4
|
|
|
@@ -34,7 +35,7 @@ import type { TimelineResponse } from '../schemas/TimelineResponse.schema'
|
|
|
34
35
|
*/
|
|
35
36
|
export function useCentrifugoMonitorChannelsRetrieve(params?: { hours?: number }, client?: API): ReturnType<typeof useSWR<ChannelList>> {
|
|
36
37
|
return useSWR<ChannelList>(
|
|
37
|
-
|
|
38
|
+
['cfg-centrifugo-monitor-channel', params],
|
|
38
39
|
() => Fetchers.getCentrifugoMonitorChannelsRetrieve(params, client)
|
|
39
40
|
)
|
|
40
41
|
}
|
|
@@ -62,7 +63,7 @@ export function useCentrifugoMonitorHealthRetrieve(client?: API): ReturnType<typ
|
|
|
62
63
|
*/
|
|
63
64
|
export function useCentrifugoMonitorOverviewRetrieve(params?: { hours?: number }, client?: API): ReturnType<typeof useSWR<CentrifugoOverviewStats>> {
|
|
64
65
|
return useSWR<CentrifugoOverviewStats>(
|
|
65
|
-
|
|
66
|
+
['cfg-centrifugo-monitor-overview', params],
|
|
66
67
|
() => Fetchers.getCentrifugoMonitorOverviewRetrieve(params, client)
|
|
67
68
|
)
|
|
68
69
|
}
|
|
@@ -76,7 +77,7 @@ export function useCentrifugoMonitorOverviewRetrieve(params?: { hours?: number }
|
|
|
76
77
|
*/
|
|
77
78
|
export function useCentrifugoMonitorPublishesList(params?: { channel?: string; ordering?: string; page?: number; page_size?: number; search?: string; status?: string }, client?: API): ReturnType<typeof useSWR<PaginatedPublishList>> {
|
|
78
79
|
return useSWR<PaginatedPublishList>(
|
|
79
|
-
|
|
80
|
+
['cfg-centrifugo-monitor-publishes', params],
|
|
80
81
|
() => Fetchers.getCentrifugoMonitorPublishesList(params, client)
|
|
81
82
|
)
|
|
82
83
|
}
|
|
@@ -90,7 +91,7 @@ export function useCentrifugoMonitorPublishesList(params?: { channel?: string; o
|
|
|
90
91
|
*/
|
|
91
92
|
export function useCentrifugoMonitorTimelineRetrieve(params?: { hours?: number; interval?: string }, client?: API): ReturnType<typeof useSWR<TimelineResponse>> {
|
|
92
93
|
return useSWR<TimelineResponse>(
|
|
93
|
-
|
|
94
|
+
['cfg-centrifugo-monitor-timeline', params],
|
|
94
95
|
() => Fetchers.getCentrifugoMonitorTimelineRetrieve(params, client)
|
|
95
96
|
)
|
|
96
97
|
}
|