@djangocfg/api 2.1.359 → 2.1.361
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 +68 -0
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +68 -0
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +75 -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 +75 -67
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +68 -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 +68 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +68 -0
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.mjs +68 -0
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +79 -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 +79 -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/openapi.json +1811 -0
- 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_centrifugo/openapi.json +132 -0
- 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/openapi.json +927 -0
- package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +7 -7
- package/src/_api/generated/helpers/auth.ts +27 -2
- package/src/_api/generated/openapi.json +2789 -0
- package/src/_api/generated/types.gen.ts +28 -40
package/dist/auth-server.mjs
CHANGED
|
@@ -21,6 +21,66 @@ var proxyMiddlewareConfig = {
|
|
|
21
21
|
matcher: ["/media/:path*", "/api/:path*"]
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
// src/_api/generated/helpers/errors.ts
|
|
25
|
+
var APIError = class extends Error {
|
|
26
|
+
constructor(statusCode, statusText, response, url, message) {
|
|
27
|
+
super(message || `HTTP ${statusCode}: ${statusText}`);
|
|
28
|
+
this.statusCode = statusCode;
|
|
29
|
+
this.statusText = statusText;
|
|
30
|
+
this.response = response;
|
|
31
|
+
this.url = url;
|
|
32
|
+
this.name = "APIError";
|
|
33
|
+
}
|
|
34
|
+
static {
|
|
35
|
+
__name(this, "APIError");
|
|
36
|
+
}
|
|
37
|
+
get details() {
|
|
38
|
+
if (typeof this.response === "object" && this.response !== null) {
|
|
39
|
+
return this.response;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
get fieldErrors() {
|
|
44
|
+
const details = this.details;
|
|
45
|
+
if (!details) return null;
|
|
46
|
+
const fieldErrors = {};
|
|
47
|
+
for (const [key, value] of Object.entries(details)) {
|
|
48
|
+
if (Array.isArray(value)) fieldErrors[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(fieldErrors).length > 0 ? fieldErrors : null;
|
|
51
|
+
}
|
|
52
|
+
get errorMessage() {
|
|
53
|
+
const details = this.details;
|
|
54
|
+
if (!details) return this.message;
|
|
55
|
+
if (details.detail) {
|
|
56
|
+
return Array.isArray(details.detail) ? details.detail.join(", ") : String(details.detail);
|
|
57
|
+
}
|
|
58
|
+
if (details.error) return String(details.error);
|
|
59
|
+
if (details.message) return String(details.message);
|
|
60
|
+
const fieldErrors = this.fieldErrors;
|
|
61
|
+
if (fieldErrors) {
|
|
62
|
+
const firstField = Object.keys(fieldErrors)[0];
|
|
63
|
+
if (firstField) return `${firstField}: ${fieldErrors[firstField]?.join(", ")}`;
|
|
64
|
+
}
|
|
65
|
+
return this.message;
|
|
66
|
+
}
|
|
67
|
+
get isValidationError() {
|
|
68
|
+
return this.statusCode === 400;
|
|
69
|
+
}
|
|
70
|
+
get isAuthError() {
|
|
71
|
+
return this.statusCode === 401;
|
|
72
|
+
}
|
|
73
|
+
get isPermissionError() {
|
|
74
|
+
return this.statusCode === 403;
|
|
75
|
+
}
|
|
76
|
+
get isNotFoundError() {
|
|
77
|
+
return this.statusCode === 404;
|
|
78
|
+
}
|
|
79
|
+
get isServerError() {
|
|
80
|
+
return this.statusCode >= 500 && this.statusCode < 600;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
24
84
|
// src/_api/generated/helpers/auth.ts
|
|
25
85
|
var ACCESS_KEY = "cfg.access_token";
|
|
26
86
|
var REFRESH_KEY = "cfg.refresh_token";
|
|
@@ -99,6 +159,7 @@ function defaultBaseUrl() {
|
|
|
99
159
|
}
|
|
100
160
|
__name(defaultBaseUrl, "defaultBaseUrl");
|
|
101
161
|
function defaultApiKey() {
|
|
162
|
+
if (isBrowser) return null;
|
|
102
163
|
try {
|
|
103
164
|
if (typeof process !== "undefined" && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
104
165
|
return process.env.NEXT_PUBLIC_API_KEY;
|
|
@@ -263,6 +324,13 @@ function installAuthOnClient(client2) {
|
|
|
263
324
|
request.headers.set("X-Client-Time", (/* @__PURE__ */ new Date()).toISOString());
|
|
264
325
|
return request;
|
|
265
326
|
});
|
|
327
|
+
client2.interceptors.error.use((err, res, req) => {
|
|
328
|
+
if (err instanceof APIError) return err;
|
|
329
|
+
const url = req?.url ?? "";
|
|
330
|
+
const status = res?.status ?? 0;
|
|
331
|
+
const statusText = res?.statusText ?? "";
|
|
332
|
+
return new APIError(status, statusText, err, url);
|
|
333
|
+
});
|
|
266
334
|
client2.interceptors.response.use(async (response, request) => {
|
|
267
335
|
if (response.status !== 401) return response;
|
|
268
336
|
if (request.headers.get(RETRY_MARKER)) {
|