refactor: Update typings of /me/settings and /users/:id/settings endpoints (no-changelog) (#9620)

This commit is contained in:
Tomi Turtiainen 2024-06-05 09:35:43 +03:00 committed by GitHub
parent 5322802992
commit d6a046b8ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 17 deletions

View file

@ -47,7 +47,7 @@ export class UserSettingsUpdatePayload {
@Expose()
@IsBoolean({ message: 'userActivated should be a boolean' })
@IsOptional()
userActivated: boolean;
userActivated?: boolean;
@Expose()
@IsBoolean({ message: 'allowSSOManualLogin should be a boolean' })

View file

@ -5,9 +5,14 @@ import type {
IUserResponse,
InvitableRoleName,
} from '@/Interface';
import type { IDataObject } from 'n8n-workflow';
import type { IDataObject, IUserSettings } from 'n8n-workflow';
import { makeRestApiRequest } from '@/utils/apiUtils';
export interface IUpdateUserSettingsReqPayload {
allowSSOManualLogin?: boolean;
userActivated?: boolean;
}
export async function loginCurrentUser(
context: IRestApiContext,
): Promise<CurrentUserResponse | null> {
@ -93,27 +98,22 @@ export async function updateCurrentUser(
email: string;
},
): Promise<IUserResponse> {
return await makeRestApiRequest(context, 'PATCH', '/me', params as unknown as IDataObject);
return await makeRestApiRequest(context, 'PATCH', '/me', params);
}
export async function updateCurrentUserSettings(
context: IRestApiContext,
settings: IUserResponse['settings'],
): Promise<IUserResponse['settings']> {
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings as IDataObject);
settings: IUpdateUserSettingsReqPayload,
): Promise<IUserSettings> {
return await makeRestApiRequest(context, 'PATCH', '/me/settings', settings);
}
export async function updateOtherUserSettings(
context: IRestApiContext,
userId: string,
settings: IUserResponse['settings'],
): Promise<IUserResponse['settings']> {
return await makeRestApiRequest(
context,
'PATCH',
`/users/${userId}/settings`,
settings as IDataObject,
);
settings: IUpdateUserSettingsReqPayload,
): Promise<IUserSettings> {
return await makeRestApiRequest(context, 'PATCH', `/users/${userId}/settings`, settings);
}
export async function updateCurrentUserPassword(

View file

@ -1,4 +1,4 @@
import type { UpdateGlobalRolePayload } from '@/api/users';
import type { IUpdateUserSettingsReqPayload, UpdateGlobalRolePayload } from '@/api/users';
import {
changePassword,
deleteUser,
@ -246,7 +246,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
const user = await updateCurrentUser(rootStore.getRestApiContext, params);
this.addUsers([user]);
},
async updateUserSettings(settings: IUserResponse['settings']): Promise<void> {
async updateUserSettings(settings: IUpdateUserSettingsReqPayload): Promise<void> {
const rootStore = useRootStore();
const updatedSettings = await updateCurrentUserSettings(
rootStore.getRestApiContext,
@ -259,7 +259,7 @@ export const useUsersStore = defineStore(STORES.USERS, {
},
async updateOtherUserSettings(
userId: string,
settings: IUserResponse['settings'],
settings: IUpdateUserSettingsReqPayload,
): Promise<void> {
const rootStore = useRootStore();
const updatedSettings = await updateOtherUserSettings(