@djangocfg/api 2.1.358 → 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/hooks.cjs
CHANGED
|
@@ -837,6 +837,66 @@ var createClient = /* @__PURE__ */ __name((config = {}) => {
|
|
|
837
837
|
};
|
|
838
838
|
}, "createClient");
|
|
839
839
|
|
|
840
|
+
// src/_api/generated/helpers/errors.ts
|
|
841
|
+
var APIError = class extends Error {
|
|
842
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
843
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
844
|
+
this.statusCode = statusCode;
|
|
845
|
+
this.statusText = statusText;
|
|
846
|
+
this.response = response;
|
|
847
|
+
this.url = url;
|
|
848
|
+
this.name = "APIError";
|
|
849
|
+
}
|
|
850
|
+
static {
|
|
851
|
+
__name(this, "APIError");
|
|
852
|
+
}
|
|
853
|
+
get details() {
|
|
854
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
855
|
+
return this.response;
|
|
856
|
+
}
|
|
857
|
+
return null;
|
|
858
|
+
}
|
|
859
|
+
get fieldErrors() {
|
|
860
|
+
const details = this.details;
|
|
861
|
+
if (!details) return null;
|
|
862
|
+
const fieldErrors = {};
|
|
863
|
+
for (const [key, value] of Object.entries(details)) {
|
|
864
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
865
|
+
}
|
|
866
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
867
|
+
}
|
|
868
|
+
get errorMessage() {
|
|
869
|
+
const details = this.details;
|
|
870
|
+
if (!details) return this.message;
|
|
871
|
+
if (details.detail) {
|
|
872
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
873
|
+
}
|
|
874
|
+
if (details.error) return String(details.error);
|
|
875
|
+
if (details.message) return String(details.message);
|
|
876
|
+
const fieldErrors = this.fieldErrors;
|
|
877
|
+
if (fieldErrors) {
|
|
878
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
879
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
880
|
+
}
|
|
881
|
+
return this.message;
|
|
882
|
+
}
|
|
883
|
+
get isValidationError() {
|
|
884
|
+
return this.statusCode === 400;
|
|
885
|
+
}
|
|
886
|
+
get isAuthError() {
|
|
887
|
+
return this.statusCode === 401;
|
|
888
|
+
}
|
|
889
|
+
get isPermissionError() {
|
|
890
|
+
return this.statusCode === 403;
|
|
891
|
+
}
|
|
892
|
+
get isNotFoundError() {
|
|
893
|
+
return this.statusCode === 404;
|
|
894
|
+
}
|
|
895
|
+
get isServerError() {
|
|
896
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
|
|
840
900
|
// src/_api/generated/helpers/auth.ts
|
|
841
901
|
var ACCESS_KEY = "cfg.access_token";
|
|
842
902
|
var REFRESH_KEY = "cfg.refresh_token";
|
|
@@ -1079,6 +1139,13 @@ function installAuthOnClient(client2) {
|
|
|
1079
1139
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
1080
1140
|
return request;
|
|
1081
1141
|
});
|
|
1142
|
+
client2.interceptors.error.use((err, res, req) => {
|
|
1143
|
+
if (err instanceof APIError) return err;
|
|
1144
|
+
const url = req?.url ?? "";
|
|
1145
|
+
const status = res?.status ?? 0;
|
|
1146
|
+
const statusText = res?.statusText ?? "";
|
|
1147
|
+
return new APIError(status, statusText, err, url);
|
|
1148
|
+
});
|
|
1082
1149
|
client2.interceptors.response.use(async (response, request) => {
|
|
1083
1150
|
if (response.status !== 401) return response;
|
|
1084
1151
|
if (request.headers.get(RETRY_MARKER)) {
|