@djangocfg/api 2.1.355 → 2.1.357
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/README.md +53 -632
- package/dist/auth-server.cjs +717 -200
- package/dist/auth-server.cjs.map +1 -1
- package/dist/auth-server.mjs +717 -200
- package/dist/auth-server.mjs.map +1 -1
- package/dist/auth.cjs +843 -783
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +58 -37
- package/dist/auth.d.ts +58 -37
- package/dist/auth.mjs +846 -784
- package/dist/auth.mjs.map +1 -1
- package/dist/clients.cjs +1427 -0
- package/dist/clients.cjs.map +1 -1
- package/dist/clients.d.cts +1686 -0
- package/dist/clients.d.ts +1686 -0
- package/dist/clients.mjs +1427 -0
- package/dist/clients.mjs.map +1 -1
- package/dist/hooks.cjs +1277 -1924
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +18 -1206
- package/dist/hooks.d.ts +18 -1206
- package/dist/hooks.mjs +1253 -1900
- package/dist/hooks.mjs.map +1 -1
- package/dist/index.cjs +545 -1232
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1389 -1455
- package/dist/index.d.ts +1389 -1455
- package/dist/index.mjs +545 -1232
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -2
- package/src/_api/generated/_cfg_accounts/api.ts +11 -3
- package/src/_api/generated/_cfg_accounts/hooks/index.ts +3 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRegenerateCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyRetrieve.ts +65 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsApiKeyTestCreate.ts +64 -0
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthConnectionsList.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthDisconnectCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubAuthorizeCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthGithubCallbackCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOauthProvidersRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpRequestCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsOtpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileAvatarCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileDeleteCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialPartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfilePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdatePartialUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsProfileUpdateUpdate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/hooks/useCfgAccountsTokenRefreshCreate.ts +43 -3
- package/src/_api/generated/_cfg_accounts/index.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/APIKey.ts +13 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRegenerate.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyRequest.ts +13 -0
- package/src/_api/generated/{_cfg_totp/schemas/DeviceListStatusEnum.ts → _cfg_accounts/schemas/APIKeyTestRequest.ts} +4 -2
- package/src/_api/generated/_cfg_accounts/schemas/APIKeyTestResult.ts +12 -0
- package/src/_api/generated/_cfg_accounts/schemas/AccountDeleteResponse.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/CentrifugoToken.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/CfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthCallbackRequestRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OAuthConnection.ts +6 -6
- package/src/_api/generated/_cfg_accounts/schemas/OAuthDisconnectRequestRequest.ts +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/{ProviderEnum.ts → OAuthProviderEnum.ts} +2 -2
- package/src/_api/generated/_cfg_accounts/schemas/OAuthTokenResponse.ts +5 -5
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_accounts/schemas/OTPVerifyResponse.ts +3 -3
- package/src/_api/generated/_cfg_accounts/schemas/PatchedCfgUserUpdateRequest.ts +3 -2
- package/src/_api/generated/_cfg_accounts/schemas/User.ts +12 -10
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_connections_response_200_AutoRef.ts +10 -0
- package/src/_api/generated/_cfg_accounts/schemas/cfg_accounts_oauth_disconnect_response_200_AutoRef.ts +11 -0
- package/src/_api/generated/_cfg_accounts/schemas/index.ts +8 -1
- package/src/_api/generated/_cfg_centrifugo/api.ts +3 -3
- package/src/_api/generated/_cfg_centrifugo/hooks/useCfgCentrifugoAuthTokenRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_centrifugo/index.ts +1 -1
- package/src/_api/generated/_cfg_centrifugo/schemas/ConnectionTokenResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/api.ts +9 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRegenerateCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpBackupCodesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesDestroy.ts +7 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDevicesRetrieve.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpDisableCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupConfirmCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpSetupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyBackupCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/hooks/useCfgTotpVerifyCreate.ts +43 -3
- package/src/_api/generated/_cfg_totp/index.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/ConfirmSetupResponse.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/DeviceList.ts +5 -5
- package/src/_api/generated/_cfg_totp/schemas/DeviceStatusEnum.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/SetupResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/TotpVerifyUser.ts +11 -9
- package/src/_api/generated/_cfg_totp/schemas/VerifyBackupRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyRequest.ts +1 -1
- package/src/_api/generated/_cfg_totp/schemas/VerifyResponse.ts +2 -2
- package/src/_api/generated/_cfg_totp/schemas/cfg_totp_disable_response_200_AutoRef.ts +9 -0
- package/src/_api/generated/_cfg_totp/schemas/index.ts +2 -1
- package/src/_api/generated/index.ts +3 -1
- package/src/_api/generated/sdk.gen.ts +80 -813
- package/src/_api/generated/types.gen.ts +320 -159
- package/src/auth/context/AccountsContext.tsx +18 -6
- package/src/auth/context/AuthContext.tsx +11 -3
- package/src/auth/hooks/useDeleteAccount.ts +2 -2
- package/src/auth/hooks/useGithubAuth.ts +3 -3
- package/src/auth/hooks/useTokenRefresh.ts +2 -2
- package/src/auth/hooks/useTwoFactor.ts +3 -3
- package/src/auth/hooks/useTwoFactorSetup.ts +3 -3
- package/src/auth/hooks/useTwoFactorStatus.ts +3 -3
- package/src/auth/middlewares/tokenRefresh.ts +2 -2
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useApiKey.ts +73 -0
- package/src/index.ts +12 -16
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/accounts/otp/verify/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccounts } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsOtpVerifyCreateData, CfgAccountsOtpVerifyCreateResponses } from "../../types.gen";
|
|
11
|
+
import { OTPVerifyResponseSchema } from "../schemas/OTPVerifyResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsOtpVerifyCreateData, "url">;
|
|
11
14
|
type Result = CfgAccountsOtpVerifyCreateResponses[keyof CfgAccountsOtpVerifyCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsOtpVerifyCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_otp_verify_create"], Args>(
|
|
17
20
|
["cfg_accounts_otp_verify_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccounts.cfgAccountsOtpVerifyCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = OTPVerifyResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_otp_verify_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/accounts/otp/verify/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_otp_verify_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/accounts/otp/verify/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Upload user avatar
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfileAvatarCreateData, CfgAccountsProfileAvatarCreateResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfileAvatarCreateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfileAvatarCreateResponses[keyof CfgAccountsProfileAvatarCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfileAvatarCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_avatar_create"], Args>(
|
|
17
20
|
["cfg_accounts_profile_avatar_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfileAvatarCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = UserSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_avatar_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/accounts/profile/avatar/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_avatar_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/accounts/profile/avatar/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Delete user account
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfileDeleteCreateData, CfgAccountsProfileDeleteCreateResponses } from "../../types.gen";
|
|
11
|
+
import { AccountDeleteResponseSchema } from "../schemas/AccountDeleteResponse";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfileDeleteCreateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfileDeleteCreateResponses[keyof CfgAccountsProfileDeleteCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfileDeleteCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_delete_create"], Args>(
|
|
17
20
|
["cfg_accounts_profile_delete_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfileDeleteCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = AccountDeleteResponseSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_delete_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/accounts/profile/delete/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_delete_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/accounts/profile/delete/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Partial update user profile
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfilePartialPartialUpdateData, CfgAccountsProfilePartialPartialUpdateResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfilePartialPartialUpdateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfilePartialPartialUpdateResponses[keyof CfgAccountsProfilePartialPartialUpdateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfilePartialPartialUpdate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_partial_partial_update"], Args>(
|
|
17
20
|
["cfg_accounts_profile_partial_partial_update"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfilePartialPartialUpdate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = UserSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_partial_partial_update",
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
path: "/cfg/accounts/profile/partial/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_partial_partial_update",
|
|
44
|
+
method: "PATCH",
|
|
45
|
+
path: "/cfg/accounts/profile/partial/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Partial update user profile
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfilePartialUpdateData, CfgAccountsProfilePartialUpdateResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfilePartialUpdateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfilePartialUpdateResponses[keyof CfgAccountsProfilePartialUpdateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfilePartialUpdate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_partial_update"], Args>(
|
|
17
20
|
["cfg_accounts_profile_partial_update"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfilePartialUpdate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = UserSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_partial_update",
|
|
32
|
+
method: "PUT",
|
|
33
|
+
path: "/cfg/accounts/profile/partial/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_partial_update",
|
|
44
|
+
method: "PUT",
|
|
45
|
+
path: "/cfg/accounts/profile/partial/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Get current user profile
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWR from "swr";
|
|
6
8
|
import type { SWRConfiguration } from "swr";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfileRetrieveData, CfgAccountsProfileRetrieveResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Result = CfgAccountsProfileRetrieveResponses[keyof CfgAccountsProfileRetrieveResponses];
|
|
11
14
|
|
|
@@ -17,8 +20,45 @@ export function useCfgAccountsProfileRetrieve(
|
|
|
17
20
|
return useSWR<Result>(
|
|
18
21
|
key,
|
|
19
22
|
async () => {
|
|
20
|
-
const res = await
|
|
21
|
-
|
|
23
|
+
const res = await CfgAccountsProfile.cfgAccountsProfileRetrieve({ ...(args ?? {}), throwOnError: true } as never);
|
|
24
|
+
const data = res.data as Result;
|
|
25
|
+
const parsed = UserSchema.safeParse(data);
|
|
26
|
+
if (!parsed.success) {
|
|
27
|
+
// Log first so the failure is always visible, even if the
|
|
28
|
+
// event handler swallows it.
|
|
29
|
+
console.warn(
|
|
30
|
+
"[zod] response did not match schema",
|
|
31
|
+
{
|
|
32
|
+
operation: "cfg_accounts_profile_retrieve",
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: "/cfg/accounts/profile/",
|
|
35
|
+
issues: parsed.error.issues,
|
|
36
|
+
data,
|
|
37
|
+
},
|
|
38
|
+
);
|
|
39
|
+
if (typeof window !== "undefined") {
|
|
40
|
+
try {
|
|
41
|
+
window.dispatchEvent(
|
|
42
|
+
new CustomEvent("zod-validation-error", {
|
|
43
|
+
detail: {
|
|
44
|
+
operation: "cfg_accounts_profile_retrieve",
|
|
45
|
+
method: "GET",
|
|
46
|
+
path: "/cfg/accounts/profile/",
|
|
47
|
+
issues: parsed.error.issues,
|
|
48
|
+
data,
|
|
49
|
+
timestamp: new Date(),
|
|
50
|
+
},
|
|
51
|
+
bubbles: true,
|
|
52
|
+
cancelable: false,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
} catch {
|
|
56
|
+
// Event dispatch is best-effort.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
return parsed.data as Result;
|
|
22
62
|
},
|
|
23
63
|
config,
|
|
24
64
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Update user profile
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfileUpdatePartialUpdateData, CfgAccountsProfileUpdatePartialUpdateResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfileUpdatePartialUpdateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfileUpdatePartialUpdateResponses[keyof CfgAccountsProfileUpdatePartialUpdateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfileUpdatePartialUpdate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_update_partial_update"], Args>(
|
|
17
20
|
["cfg_accounts_profile_update_partial_update"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfileUpdatePartialUpdate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = UserSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_update_partial_update",
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
path: "/cfg/accounts/profile/update/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_update_partial_update",
|
|
44
|
+
method: "PATCH",
|
|
45
|
+
path: "/cfg/accounts/profile/update/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// Update user profile
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsProfile } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsProfileUpdateUpdateData, CfgAccountsProfileUpdateUpdateResponses } from "../../types.gen";
|
|
11
|
+
import { UserSchema } from "../schemas/User";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsProfileUpdateUpdateData, "url">;
|
|
11
14
|
type Result = CfgAccountsProfileUpdateUpdateResponses[keyof CfgAccountsProfileUpdateUpdateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsProfileUpdateUpdate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_profile_update_update"], Args>(
|
|
17
20
|
["cfg_accounts_profile_update_update"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsProfile.cfgAccountsProfileUpdateUpdate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = UserSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_profile_update_update",
|
|
32
|
+
method: "PUT",
|
|
33
|
+
path: "/cfg/accounts/profile/update/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_profile_update_update",
|
|
44
|
+
method: "PUT",
|
|
45
|
+
path: "/cfg/accounts/profile/update/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// AUTO-GENERATED by openapi_processor / ts.hooks
|
|
2
4
|
// POST /cfg/accounts/token/refresh/
|
|
3
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
4
6
|
|
|
5
7
|
import useSWRMutation from "swr/mutation";
|
|
6
8
|
import type { SWRMutationConfiguration } from "swr/mutation";
|
|
7
|
-
import {
|
|
9
|
+
import { CfgAccountsAuth } from "../../sdk.gen";
|
|
8
10
|
import type { CfgAccountsTokenRefreshCreateData, CfgAccountsTokenRefreshCreateResponses } from "../../types.gen";
|
|
11
|
+
import { TokenRefreshSchema } from "../schemas/TokenRefresh";
|
|
9
12
|
|
|
10
13
|
type Args = Omit<CfgAccountsTokenRefreshCreateData, "url">;
|
|
11
14
|
type Result = CfgAccountsTokenRefreshCreateResponses[keyof CfgAccountsTokenRefreshCreateResponses];
|
|
@@ -16,8 +19,45 @@ export function useCfgAccountsTokenRefreshCreate(
|
|
|
16
19
|
return useSWRMutation<Result, Error, readonly ["cfg_accounts_token_refresh_create"], Args>(
|
|
17
20
|
["cfg_accounts_token_refresh_create"] as const,
|
|
18
21
|
async (_key, { arg }: { arg: Args }) => {
|
|
19
|
-
const res = await
|
|
20
|
-
|
|
22
|
+
const res = await CfgAccountsAuth.cfgAccountsTokenRefreshCreate({ ...arg, throwOnError: true } as never);
|
|
23
|
+
const data = res.data as Result;
|
|
24
|
+
const parsed = TokenRefreshSchema.safeParse(data);
|
|
25
|
+
if (!parsed.success) {
|
|
26
|
+
// Log first so the failure is always visible, even if the
|
|
27
|
+
// event handler swallows it.
|
|
28
|
+
console.warn(
|
|
29
|
+
"[zod] response did not match schema",
|
|
30
|
+
{
|
|
31
|
+
operation: "cfg_accounts_token_refresh_create",
|
|
32
|
+
method: "POST",
|
|
33
|
+
path: "/cfg/accounts/token/refresh/",
|
|
34
|
+
issues: parsed.error.issues,
|
|
35
|
+
data,
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
try {
|
|
40
|
+
window.dispatchEvent(
|
|
41
|
+
new CustomEvent("zod-validation-error", {
|
|
42
|
+
detail: {
|
|
43
|
+
operation: "cfg_accounts_token_refresh_create",
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: "/cfg/accounts/token/refresh/",
|
|
46
|
+
issues: parsed.error.issues,
|
|
47
|
+
data,
|
|
48
|
+
timestamp: new Date(),
|
|
49
|
+
},
|
|
50
|
+
bubbles: true,
|
|
51
|
+
cancelable: false,
|
|
52
|
+
}),
|
|
53
|
+
);
|
|
54
|
+
} catch {
|
|
55
|
+
// Event dispatch is best-effort.
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
59
|
+
}
|
|
60
|
+
return parsed.data as Result;
|
|
21
61
|
},
|
|
22
62
|
config,
|
|
23
63
|
);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Group barrel. DO NOT EDIT — re-run `make gen`.
|
|
3
3
|
|
|
4
4
|
// Wrapper class + per-group SDK re-exports + global auth.
|
|
5
|
-
export { API, type APIOptions, auth,
|
|
5
|
+
export { API, type APIOptions, auth, CfgAccountsApiKey, CfgAccountsOauth, CfgAccounts, CfgAccountsProfile, CfgAccountsAuth } from './api';
|
|
6
6
|
|
|
7
7
|
// Shared utilities.
|
|
8
8
|
export {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export const APIKeySchema = z.object({
|
|
8
|
+
key: z.string(),
|
|
9
|
+
reissued_at: z.string().datetime({ offset: true }).nullable(),
|
|
10
|
+
created_at: z.string().datetime({ offset: true }),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type APIKey = z.infer<typeof APIKeySchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export const APIKeyRegenerateSchema = z.object({
|
|
8
|
+
key: z.string(),
|
|
9
|
+
reissued_at: z.string().datetime({ offset: true }),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type APIKeyRegenerate = z.infer<typeof APIKeyRegenerateSchema>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export const APIKeyRequestSchema = z.object({
|
|
8
|
+
key: z.string().min(1),
|
|
9
|
+
reissued_at: z.string().datetime({ offset: true }).nullable(),
|
|
10
|
+
created_at: z.string().datetime({ offset: true }),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type APIKeyRequest = z.infer<typeof APIKeyRequestSchema>;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const APIKeyTestRequestSchema = z.object({
|
|
8
|
+
key: z.string().min(1),
|
|
9
|
+
});
|
|
8
10
|
|
|
9
|
-
export type
|
|
11
|
+
export type APIKeyTestRequest = z.infer<typeof APIKeyTestRequestSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
|
|
2
|
+
// Source: OpenAPI 3.1 components.schemas
|
|
3
|
+
// DO NOT EDIT — re-run `make gen-clients`.
|
|
4
|
+
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
|
|
7
|
+
export const APIKeyTestResultSchema = z.object({
|
|
8
|
+
valid: z.boolean(),
|
|
9
|
+
user_id: z.string().nullable(),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export type APIKeyTestResult = z.infer<typeof APIKeyTestResultSchema>;
|