@djangocfg/api 2.1.192 → 2.1.194
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
|
@@ -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
|
|
@@ -112,6 +113,20 @@ export { withRetry, shouldRetry, DEFAULT_RETRY_CONFIG } from "./retry";
|
|
|
112
113
|
export const TOKEN_KEY = "auth_token";
|
|
113
114
|
export const REFRESH_TOKEN_KEY = "refresh_token";
|
|
114
115
|
|
|
116
|
+
/** Auto-detect locale from cookie NEXT_LOCALE or navigator.language */
|
|
117
|
+
function detectLocale(): string | null {
|
|
118
|
+
try {
|
|
119
|
+
if (typeof document !== 'undefined') {
|
|
120
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
121
|
+
if (match) return match[1];
|
|
122
|
+
}
|
|
123
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
124
|
+
return navigator.language;
|
|
125
|
+
}
|
|
126
|
+
} catch {}
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
115
130
|
export interface APIOptions {
|
|
116
131
|
/** Custom storage adapter (defaults to LocalStorageAdapter) */
|
|
117
132
|
storage?: StorageAdapter;
|
|
@@ -119,6 +134,8 @@ export interface APIOptions {
|
|
|
119
134
|
retryConfig?: RetryConfig;
|
|
120
135
|
/** Logger configuration */
|
|
121
136
|
loggerConfig?: Partial<LoggerConfig>;
|
|
137
|
+
/** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
|
|
138
|
+
locale?: string;
|
|
122
139
|
}
|
|
123
140
|
|
|
124
141
|
export class API {
|
|
@@ -126,6 +143,7 @@ export class API {
|
|
|
126
143
|
private _client: APIClient;
|
|
127
144
|
private _token: string | null = null;
|
|
128
145
|
private _refreshToken: string | null = null;
|
|
146
|
+
private _locale: string | null = null;
|
|
129
147
|
private storage: StorageAdapter;
|
|
130
148
|
private options?: APIOptions;
|
|
131
149
|
|
|
@@ -145,6 +163,8 @@ export class API {
|
|
|
145
163
|
// Initialize storage with logger
|
|
146
164
|
this.storage = options?.storage || new LocalStorageAdapter(logger);
|
|
147
165
|
|
|
166
|
+
this._locale = options?.locale || null;
|
|
167
|
+
|
|
148
168
|
this._loadTokensFromStorage();
|
|
149
169
|
|
|
150
170
|
// Initialize APIClient with token getter for URL authentication
|
|
@@ -196,11 +216,13 @@ export class API {
|
|
|
196
216
|
): Promise<T> => {
|
|
197
217
|
// Read token from storage dynamically (supports JWT injection after instantiation)
|
|
198
218
|
const token = this.getToken();
|
|
219
|
+
const locale = this._locale || detectLocale();
|
|
199
220
|
const mergedOptions = {
|
|
200
221
|
...options,
|
|
201
222
|
headers: {
|
|
202
223
|
...(options?.headers || {}),
|
|
203
224
|
...(token ? { 'Authorization': `Bearer ${token}` } : {}),
|
|
225
|
+
...(locale ? { 'Accept-Language': locale } : {}),
|
|
204
226
|
},
|
|
205
227
|
};
|
|
206
228
|
|
|
@@ -276,6 +298,21 @@ export class API {
|
|
|
276
298
|
return this.baseUrl;
|
|
277
299
|
}
|
|
278
300
|
|
|
301
|
+
/**
|
|
302
|
+
* Set locale for Accept-Language header
|
|
303
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
304
|
+
*/
|
|
305
|
+
setLocale(locale: string | null): void {
|
|
306
|
+
this._locale = locale;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Get current locale
|
|
311
|
+
*/
|
|
312
|
+
getLocale(): string | null {
|
|
313
|
+
return this._locale;
|
|
314
|
+
}
|
|
315
|
+
|
|
279
316
|
/**
|
|
280
317
|
* Get OpenAPI schema path
|
|
281
318
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
'use client';
|
|
3
4
|
|
|
@@ -32,7 +33,7 @@ import type { PaginatedDeviceListResponseList } from '../schemas/PaginatedDevice
|
|
|
32
33
|
*/
|
|
33
34
|
export function useTotpDevicesList(params?: { ordering?: string; page?: number; page_size?: number; search?: string }, client?: API): ReturnType<typeof useSWR<PaginatedDeviceListResponseList>> {
|
|
34
35
|
return useSWR<PaginatedDeviceListResponseList>(
|
|
35
|
-
|
|
36
|
+
['cfg-totp-devices', params],
|
|
36
37
|
() => Fetchers.getTotpDevicesList(params, client)
|
|
37
38
|
)
|
|
38
39
|
}
|
|
@@ -20,6 +20,7 @@ export const TotpVerifyUserSchema = z.object({
|
|
|
20
20
|
company: z.string().max(100).optional(),
|
|
21
21
|
phone: z.string().max(20).optional(),
|
|
22
22
|
position: z.string().max(100).optional(),
|
|
23
|
+
language: z.string().max(10).optional(),
|
|
23
24
|
avatar: z.union([z.url(), z.literal('')]).nullable(),
|
|
24
25
|
is_staff: z.boolean(),
|
|
25
26
|
is_superuser: z.boolean(),
|
|
@@ -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
|
|
@@ -117,6 +118,20 @@ export { withRetry, shouldRetry, DEFAULT_RETRY_CONFIG } from "./retry";
|
|
|
117
118
|
export const TOKEN_KEY = "auth_token";
|
|
118
119
|
export const REFRESH_TOKEN_KEY = "refresh_token";
|
|
119
120
|
|
|
121
|
+
/** Auto-detect locale from cookie NEXT_LOCALE or navigator.language */
|
|
122
|
+
function detectLocale(): string | null {
|
|
123
|
+
try {
|
|
124
|
+
if (typeof document !== 'undefined') {
|
|
125
|
+
const match = document.cookie.match(/(?:^|;\s*)NEXT_LOCALE=([^;]*)/);
|
|
126
|
+
if (match) return match[1];
|
|
127
|
+
}
|
|
128
|
+
if (typeof navigator !== 'undefined' && navigator.language) {
|
|
129
|
+
return navigator.language;
|
|
130
|
+
}
|
|
131
|
+
} catch {}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
|
|
120
135
|
export interface APIOptions {
|
|
121
136
|
/** Custom storage adapter (defaults to LocalStorageAdapter) */
|
|
122
137
|
storage?: StorageAdapter;
|
|
@@ -124,6 +139,8 @@ export interface APIOptions {
|
|
|
124
139
|
retryConfig?: RetryConfig;
|
|
125
140
|
/** Logger configuration */
|
|
126
141
|
loggerConfig?: Partial<LoggerConfig>;
|
|
142
|
+
/** Locale for Accept-Language header (e.g. 'en', 'ko', 'ru') */
|
|
143
|
+
locale?: string;
|
|
127
144
|
}
|
|
128
145
|
|
|
129
146
|
export class API {
|
|
@@ -131,6 +148,7 @@ export class API {
|
|
|
131
148
|
private _client: APIClient;
|
|
132
149
|
private _token: string | null = null;
|
|
133
150
|
private _refreshToken: string | null = null;
|
|
151
|
+
private _locale: string | null = null;
|
|
134
152
|
private storage: StorageAdapter;
|
|
135
153
|
private options?: APIOptions;
|
|
136
154
|
|
|
@@ -151,6 +169,8 @@ export class API {
|
|
|
151
169
|
// Initialize storage with logger
|
|
152
170
|
this.storage = options?.storage || new LocalStorageAdapter(logger);
|
|
153
171
|
|
|
172
|
+
this._locale = options?.locale || null;
|
|
173
|
+
|
|
154
174
|
this._loadTokensFromStorage();
|
|
155
175
|
|
|
156
176
|
// Initialize APIClient with token getter for URL authentication
|
|
@@ -204,11 +224,13 @@ export class API {
|
|
|
204
224
|
): Promise<T> => {
|
|
205
225
|
// Read token from storage dynamically (supports JWT injection after instantiation)
|
|
206
226
|
const token = this.getToken();
|
|
227
|
+
const locale = this._locale || detectLocale();
|
|
207
228
|
const mergedOptions = {
|
|
208
229
|
...options,
|
|
209
230
|
headers: {
|
|
210
231
|
...(options?.headers || {}),
|
|
211
232
|
...(token ? { 'Authorization': `Bearer ${token}` } : {}),
|
|
233
|
+
...(locale ? { 'Accept-Language': locale } : {}),
|
|
212
234
|
},
|
|
213
235
|
};
|
|
214
236
|
|
|
@@ -284,6 +306,21 @@ export class API {
|
|
|
284
306
|
return this.baseUrl;
|
|
285
307
|
}
|
|
286
308
|
|
|
309
|
+
/**
|
|
310
|
+
* Set locale for Accept-Language header
|
|
311
|
+
* @param locale - Locale string (e.g. 'en', 'ko', 'ru') or null to clear
|
|
312
|
+
*/
|
|
313
|
+
setLocale(locale: string | null): void {
|
|
314
|
+
this._locale = locale;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Get current locale
|
|
319
|
+
*/
|
|
320
|
+
getLocale(): string | null {
|
|
321
|
+
return this._locale;
|
|
322
|
+
}
|
|
323
|
+
|
|
287
324
|
/**
|
|
288
325
|
* Get OpenAPI schema path
|
|
289
326
|
* @returns Path to the OpenAPI schema JSON file
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
1
2
|
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
2
3
|
/**
|
|
3
4
|
* Serializer for TOTP code verification during login.
|
|
@@ -60,6 +61,7 @@ export interface TotpVerifyUser {
|
|
|
60
61
|
company?: string;
|
|
61
62
|
phone?: string;
|
|
62
63
|
position?: string;
|
|
64
|
+
language?: string;
|
|
63
65
|
avatar?: string | null;
|
|
64
66
|
/** Designates whether the user can log into this admin site. */
|
|
65
67
|
is_staff: boolean;
|