fix(ui): fix thunks not using configured api client

This commit is contained in:
psychedelicious 2023-06-24 10:49:36 +10:00
parent 3619c86f07
commit 8bacee115a
2 changed files with 11 additions and 6 deletions

View File

@ -4,8 +4,6 @@ import { size } from 'lodash-es';
import { paths } from 'services/api/schema'; import { paths } from 'services/api/schema';
import { $client } from 'services/api/client'; import { $client } from 'services/api/client';
const { get, post, patch, del } = $client.get();
type GetImageUrlsArg = type GetImageUrlsArg =
paths['/api/v1/images/{image_name}/urls']['get']['parameters']['path']; paths['/api/v1/images/{image_name}/urls']['get']['parameters']['path'];
@ -27,6 +25,7 @@ export const imageUrlsReceived = createAppAsyncThunk<
GetImageUrlsThunkConfig GetImageUrlsThunkConfig
>('api/imageUrlsReceived', async (arg, { rejectWithValue }) => { >('api/imageUrlsReceived', async (arg, { rejectWithValue }) => {
const { image_name } = arg; const { image_name } = arg;
const { get } = $client.get();
const { data, error, response } = await get( const { data, error, response } = await get(
'/api/v1/images/{image_name}/urls', '/api/v1/images/{image_name}/urls',
{ {
@ -64,6 +63,7 @@ export const imageMetadataReceived = createAppAsyncThunk<
GetImageMetadataThunkConfig GetImageMetadataThunkConfig
>('api/imageMetadataReceived', async (arg, { rejectWithValue }) => { >('api/imageMetadataReceived', async (arg, { rejectWithValue }) => {
const { image_name } = arg; const { image_name } = arg;
const { get } = $client.get();
const { data, error, response } = await get( const { data, error, response } = await get(
'/api/v1/images/{image_name}/metadata', '/api/v1/images/{image_name}/metadata',
{ {
@ -151,6 +151,7 @@ export const imageUploaded = createAppAsyncThunk<
is_intermediate, is_intermediate,
session_id, session_id,
} = arg; } = arg;
const { post } = $client.get();
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
const { data, error, response } = await post('/api/v1/images/', { const { data, error, response } = await post('/api/v1/images/', {
@ -195,6 +196,7 @@ export const imageDeleted = createAppAsyncThunk<
DeleteImageThunkConfig DeleteImageThunkConfig
>('api/imageDeleted', async (arg, { rejectWithValue }) => { >('api/imageDeleted', async (arg, { rejectWithValue }) => {
const { image_name } = arg; const { image_name } = arg;
const { del } = $client.get();
const { data, error, response } = await del('/api/v1/images/{image_name}', { const { data, error, response } = await del('/api/v1/images/{image_name}', {
params: { params: {
path: { path: {
@ -230,6 +232,7 @@ export const imageUpdated = createAppAsyncThunk<
UpdateImageThunkConfig UpdateImageThunkConfig
>('api/imageUpdated', async (arg, { rejectWithValue }) => { >('api/imageUpdated', async (arg, { rejectWithValue }) => {
const { image_name, image_category, is_intermediate, session_id } = arg; const { image_name, image_category, is_intermediate, session_id } = arg;
const { patch } = $client.get();
const { data, error, response } = await patch('/api/v1/images/{image_name}', { const { data, error, response } = await patch('/api/v1/images/{image_name}', {
params: { params: {
path: { path: {
@ -278,6 +281,8 @@ export const receivedPageOfImages = createAppAsyncThunk<
ListImagesArg, ListImagesArg,
ListImagesThunkConfig ListImagesThunkConfig
>('api/receivedPageOfImages', async (arg, { getState, rejectWithValue }) => { >('api/receivedPageOfImages', async (arg, { getState, rejectWithValue }) => {
const { get } = $client.get();
const state = getState(); const state = getState();
const { categories } = state.images; const { categories } = state.images;
const { selectedBoardId } = state.boards; const { selectedBoardId } = state.boards;

View File

@ -1,5 +1,4 @@
import { createAppAsyncThunk } from 'app/store/storeUtils'; import { createAppAsyncThunk } from 'app/store/storeUtils';
import { GraphExecutionState } from 'services/api/types';
import { log } from 'app/logging/useLogger'; import { log } from 'app/logging/useLogger';
import { isObject } from 'lodash-es'; import { isObject } from 'lodash-es';
import { isAnyOf } from '@reduxjs/toolkit'; import { isAnyOf } from '@reduxjs/toolkit';
@ -7,8 +6,6 @@ import { paths } from 'services/api/schema';
import { $client } from 'services/api/client'; import { $client } from 'services/api/client';
import { O } from 'ts-toolbelt'; import { O } from 'ts-toolbelt';
const { get, post, put, patch, del } = $client.get();
const sessionLog = log.child({ namespace: 'session' }); const sessionLog = log.child({ namespace: 'session' });
type CreateSessionArg = { type CreateSessionArg = {
@ -37,6 +34,7 @@ export const sessionCreated = createAppAsyncThunk<
CreateSessionThunkConfig CreateSessionThunkConfig
>('api/sessionCreated', async (arg, { rejectWithValue }) => { >('api/sessionCreated', async (arg, { rejectWithValue }) => {
const { graph } = arg; const { graph } = arg;
const { post } = $client.get();
const { data, error, response } = await post('/api/v1/sessions/', { const { data, error, response } = await post('/api/v1/sessions/', {
body: graph, body: graph,
}); });
@ -74,6 +72,7 @@ export const sessionInvoked = createAppAsyncThunk<
InvokedSessionThunkConfig InvokedSessionThunkConfig
>('api/sessionInvoked', async (arg, { rejectWithValue }) => { >('api/sessionInvoked', async (arg, { rejectWithValue }) => {
const { session_id } = arg; const { session_id } = arg;
const { put } = $client.get();
const { data, error, response } = await put( const { data, error, response } = await put(
'/api/v1/sessions/{session_id}/invoke', '/api/v1/sessions/{session_id}/invoke',
{ {
@ -111,7 +110,7 @@ export const sessionCanceled = createAppAsyncThunk<
CancelSessionThunkConfig CancelSessionThunkConfig
>('api/sessionCanceled', async (arg, { rejectWithValue }) => { >('api/sessionCanceled', async (arg, { rejectWithValue }) => {
const { session_id } = arg; const { session_id } = arg;
const { del } = $client.get();
const { data, error, response } = await del( const { data, error, response } = await del(
'/api/v1/sessions/{session_id}/invoke', '/api/v1/sessions/{session_id}/invoke',
{ {
@ -151,6 +150,7 @@ export const listedSessions = createAppAsyncThunk<
ListSessionsThunkConfig ListSessionsThunkConfig
>('api/listSessions', async (arg, { rejectWithValue }) => { >('api/listSessions', async (arg, { rejectWithValue }) => {
const { params } = arg; const { params } = arg;
const { get } = $client.get();
const { data, error, response } = await get('/api/v1/sessions/', { const { data, error, response } = await get('/api/v1/sessions/', {
params, params,
}); });