@djangocfg/api 2.1.359 → 2.1.360
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 +67 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +67 -0
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +74 -67
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +7 -10
- package/dist/auth.d.ts +7 -10
- package/dist/auth.mjs +74 -67
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +67 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +14 -20
- package/dist/clients.d.ts +14 -20
- package/dist/clients.mjs +67 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +67 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +67 -0
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +78 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -40
- package/dist/index.d.ts +28 -40
- package/dist/index.mjs +78 -71
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +7 -7
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +7 -7
- package/src/_api/generated/helpers/auth.ts +14 -0
- package/src/_api/generated/types.gen.ts +28 -40
package/dist/auth.cjs
CHANGED
|
@@ -323,6 +323,66 @@ var useAutoAuth = /* @__PURE__ */ __name((options = {}) => {
|
|
|
323
323
|
// src/auth/hooks/useTwoFactor.ts
|
|
324
324
|
var import_react6 = require("react");
|
|
325
325
|
|
|
326
|
+
// src/_api/generated/helpers/errors.ts
|
|
327
|
+
var APIError = class extends Error {
|
|
328
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
329
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
330
|
+
this.statusCode = statusCode;
|
|
331
|
+
this.statusText = statusText;
|
|
332
|
+
this.response = response;
|
|
333
|
+
this.url = url;
|
|
334
|
+
this.name = "APIError";
|
|
335
|
+
}
|
|
336
|
+
static {
|
|
337
|
+
__name(this, "APIError");
|
|
338
|
+
}
|
|
339
|
+
get details() {
|
|
340
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
341
|
+
return this.response;
|
|
342
|
+
}
|
|
343
|
+
return null;
|
|
344
|
+
}
|
|
345
|
+
get fieldErrors() {
|
|
346
|
+
const details = this.details;
|
|
347
|
+
if (!details) return null;
|
|
348
|
+
const fieldErrors = {};
|
|
349
|
+
for (const [key, value] of Object.entries(details)) {
|
|
350
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
351
|
+
}
|
|
352
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
353
|
+
}
|
|
354
|
+
get errorMessage() {
|
|
355
|
+
const details = this.details;
|
|
356
|
+
if (!details) return this.message;
|
|
357
|
+
if (details.detail) {
|
|
358
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
359
|
+
}
|
|
360
|
+
if (details.error) return String(details.error);
|
|
361
|
+
if (details.message) return String(details.message);
|
|
362
|
+
const fieldErrors = this.fieldErrors;
|
|
363
|
+
if (fieldErrors) {
|
|
364
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
365
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
366
|
+
}
|
|
367
|
+
return this.message;
|
|
368
|
+
}
|
|
369
|
+
get isValidationError() {
|
|
370
|
+
return this.statusCode === 400;
|
|
371
|
+
}
|
|
372
|
+
get isAuthError() {
|
|
373
|
+
return this.statusCode === 401;
|
|
374
|
+
}
|
|
375
|
+
get isPermissionError() {
|
|
376
|
+
return this.statusCode === 403;
|
|
377
|
+
}
|
|
378
|
+
get isNotFoundError() {
|
|
379
|
+
return this.statusCode === 404;
|
|
380
|
+
}
|
|
381
|
+
get isServerError() {
|
|
382
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
|
|
326
386
|
// src/_api/generated/helpers/auth.ts
|
|
327
387
|
var ACCESS_KEY = "cfg.access_token";
|
|
328
388
|
var REFRESH_KEY = "cfg.refresh_token";
|
|
@@ -565,6 +625,13 @@ function installAuthOnClient(client2) {
|
|
|
565
625
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
566
626
|
return request;
|
|
567
627
|
});
|
|
628
|
+
client2.interceptors.error.use((err, res, req) => {
|
|
629
|
+
if (err instanceof APIError) return err;
|
|
630
|
+
const url = req?.url ?? "";
|
|
631
|
+
const status = res?.status ?? 0;
|
|
632
|
+
const statusText = res?.statusText ?? "";
|
|
633
|
+
return new APIError(status, statusText, err, url);
|
|
634
|
+
});
|
|
568
635
|
client2.interceptors.response.use(async (response, request) => {
|
|
569
636
|
if (response.status !== 401) return response;
|
|
570
637
|
if (request.headers.get(RETRY_MARKER)) {
|
|
@@ -2100,66 +2167,6 @@ var API = class {
|
|
|
2100
2167
|
}
|
|
2101
2168
|
};
|
|
2102
2169
|
|
|
2103
|
-
// src/_api/generated/helpers/errors.ts
|
|
2104
|
-
var APIError = class extends Error {
|
|
2105
|
-
constructor(statusCode, statusText, response, url, message) {
|
|
2106
|
-
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
2107
|
-
this.statusCode = statusCode;
|
|
2108
|
-
this.statusText = statusText;
|
|
2109
|
-
this.response = response;
|
|
2110
|
-
this.url = url;
|
|
2111
|
-
this.name = "APIError";
|
|
2112
|
-
}
|
|
2113
|
-
static {
|
|
2114
|
-
__name(this, "APIError");
|
|
2115
|
-
}
|
|
2116
|
-
get details() {
|
|
2117
|
-
if (typeof this.response === "object" && this.response !== null) {
|
|
2118
|
-
return this.response;
|
|
2119
|
-
}
|
|
2120
|
-
return null;
|
|
2121
|
-
}
|
|
2122
|
-
get fieldErrors() {
|
|
2123
|
-
const details = this.details;
|
|
2124
|
-
if (!details) return null;
|
|
2125
|
-
const fieldErrors = {};
|
|
2126
|
-
for (const [key, value] of Object.entries(details)) {
|
|
2127
|
-
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
2128
|
-
}
|
|
2129
|
-
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
2130
|
-
}
|
|
2131
|
-
get errorMessage() {
|
|
2132
|
-
const details = this.details;
|
|
2133
|
-
if (!details) return this.message;
|
|
2134
|
-
if (details.detail) {
|
|
2135
|
-
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
2136
|
-
}
|
|
2137
|
-
if (details.error) return String(details.error);
|
|
2138
|
-
if (details.message) return String(details.message);
|
|
2139
|
-
const fieldErrors = this.fieldErrors;
|
|
2140
|
-
if (fieldErrors) {
|
|
2141
|
-
const firstField = Object.keys(fieldErrors)[0];
|
|
2142
|
-
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
2143
|
-
}
|
|
2144
|
-
return this.message;
|
|
2145
|
-
}
|
|
2146
|
-
get isValidationError() {
|
|
2147
|
-
return this.statusCode === 400;
|
|
2148
|
-
}
|
|
2149
|
-
get isAuthError() {
|
|
2150
|
-
return this.statusCode === 401;
|
|
2151
|
-
}
|
|
2152
|
-
get isPermissionError() {
|
|
2153
|
-
return this.statusCode === 403;
|
|
2154
|
-
}
|
|
2155
|
-
get isNotFoundError() {
|
|
2156
|
-
return this.statusCode === 404;
|
|
2157
|
-
}
|
|
2158
|
-
get isServerError() {
|
|
2159
|
-
return this.statusCode >= 500 && this.statusCode < 600;
|
|
2160
|
-
}
|
|
2161
|
-
};
|
|
2162
|
-
|
|
2163
2170
|
// src/_api/generated/_cfg_centrifugo/api.ts
|
|
2164
2171
|
var API2 = class {
|
|
2165
2172
|
static {
|
|
@@ -3890,16 +3897,16 @@ var CentrifugoTokenSchema = import_zod12.z.object({
|
|
|
3890
3897
|
var UserSchema = import_zod13.z.object({
|
|
3891
3898
|
id: import_zod13.z.number().int(),
|
|
3892
3899
|
email: import_zod13.z.email(),
|
|
3893
|
-
first_name: import_zod13.z.string().max(50).optional(),
|
|
3894
|
-
last_name: import_zod13.z.string().max(50).optional(),
|
|
3900
|
+
first_name: import_zod13.z.string().max(50).nullable().optional(),
|
|
3901
|
+
last_name: import_zod13.z.string().max(50).nullable().optional(),
|
|
3895
3902
|
full_name: import_zod13.z.string(),
|
|
3896
3903
|
initials: import_zod13.z.string(),
|
|
3897
3904
|
display_username: import_zod13.z.string(),
|
|
3898
|
-
company: import_zod13.z.string().max(100).optional(),
|
|
3899
|
-
phone: import_zod13.z.string().max(20).optional(),
|
|
3900
|
-
position: import_zod13.z.string().max(100).optional(),
|
|
3901
|
-
language: import_zod13.z.string().max(10).optional(),
|
|
3902
|
-
timezone: import_zod13.z.string().max(64).optional(),
|
|
3905
|
+
company: import_zod13.z.string().max(100).nullable().optional(),
|
|
3906
|
+
phone: import_zod13.z.string().max(20).nullable().optional(),
|
|
3907
|
+
position: import_zod13.z.string().max(100).nullable().optional(),
|
|
3908
|
+
language: import_zod13.z.string().max(10).nullable().optional(),
|
|
3909
|
+
timezone: import_zod13.z.string().max(64).nullable().optional(),
|
|
3903
3910
|
avatar: import_zod13.z.string().nullable(),
|
|
3904
3911
|
is_staff: import_zod13.z.boolean(),
|
|
3905
3912
|
is_superuser: import_zod13.z.boolean(),
|