chore(web): generate API functions with a single argument (#2568)

This commit is contained in:
Sergey Kondrikov
2023-05-28 04:52:22 +03:00
committed by GitHub
parent a460940430
commit 6c6c5ef651
65 changed files with 1913 additions and 491 deletions

View File

@@ -10,7 +10,7 @@ export const load = (async ({ params, locals: { api, user } }) => {
const albumId = params['albumId'];
try {
const { data: album } = await api.albumApi.getAlbumInfo(albumId);
const { data: album } = await api.albumApi.getAlbumInfo({ id: albumId });
return {
album,
meta: {

View File

@@ -90,7 +90,7 @@ describe('Albums BLoC', () => {
const newAlbum = await sut.createAlbum();
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledTimes(1);
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith(payload);
expect(apiMock.albumApi.createAlbum).toHaveBeenCalledWith({ createAlbumDto: payload });
expect(newAlbum).toEqual(returnedAlbum);
});
@@ -130,7 +130,7 @@ describe('Albums BLoC', () => {
const updatedAlbums = get(sut.albums);
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledTimes(1);
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith(albumToDeleteId);
expect(apiMock.albumApi.deleteAlbum).toHaveBeenCalledWith({ id: albumToDeleteId });
expect(updatedAlbums).toHaveLength(4);
expect(updatedAlbums).not.toContain(albumToDelete);
expect(get(sut.isShowContextMenu)).toBe(false);

View File

@@ -40,7 +40,9 @@ export const useAlbums = (props: AlbumsProps) => {
async function createAlbum(): Promise<AlbumResponseDto | undefined> {
try {
const { data: newAlbum } = await api.albumApi.createAlbum({
albumName: 'Untitled'
createAlbumDto: {
albumName: 'Untitled'
}
});
return newAlbum;
@@ -53,7 +55,7 @@ export const useAlbums = (props: AlbumsProps) => {
}
async function deleteAlbum(album: AlbumResponseDto): Promise<void> {
await api.albumApi.deleteAlbum(album.id);
await api.albumApi.deleteAlbum({ id: album.id });
}
async function showAlbumContextMenu(
@@ -83,7 +85,7 @@ export const useAlbums = (props: AlbumsProps) => {
)
) {
try {
await api.albumApi.deleteAlbum(albumToDelete.id);
await api.albumApi.deleteAlbum({ id: albumToDelete.id });
const _albums = get(albums);
albums.set(_albums.filter((a) => a.id !== albumToDelete.id));
} catch {