[chore] Fix type errors

This commit is contained in:
Cohee
2024-10-11 21:33:36 +03:00
parent 72138c632d
commit 4fcad0752f
25 changed files with 78 additions and 44 deletions

View File

@ -65,6 +65,7 @@ router.post('/upscalers', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.name);
return names;
@ -85,6 +86,7 @@ router.post('/upscalers', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.name);
return names;
@ -118,6 +120,7 @@ router.post('/vaes', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.model_name);
return response.send(names);
@ -143,6 +146,7 @@ router.post('/samplers', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.name);
return response.send(names);
@ -169,6 +173,7 @@ router.post('/schedulers', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.name);
return response.send(names);
@ -194,6 +199,7 @@ router.post('/models', jsonParser, async (request, response) => {
throw new Error('SD WebUI returned an error.');
}
/** @type {any} */
const data = await result.json();
const models = data.map(x => ({ value: x.title, text: x.title }));
return response.send(models);
@ -214,6 +220,7 @@ router.post('/get-model', jsonParser, async (request, response) => {
'Authorization': getBasicAuthHeader(request.body.auth),
},
});
/** @type {any} */
const data = await result.json();
return response.send(data['sd_model_checkpoint']);
} catch (error) {
@ -233,7 +240,6 @@ router.post('/set-model', jsonParser, async (request, response) => {
headers: {
'Authorization': getBasicAuthHeader(request.body.auth),
},
timeout: 0,
});
const data = await result.json();
return data;
@ -253,7 +259,6 @@ router.post('/set-model', jsonParser, async (request, response) => {
'Content-Type': 'application/json',
'Authorization': getBasicAuthHeader(request.body.auth),
},
timeout: 0,
});
if (!result.ok) {
@ -264,6 +269,7 @@ router.post('/set-model', jsonParser, async (request, response) => {
const CHECK_INTERVAL = 2000;
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
/** @type {any} */
const progressState = await getProgress();
const progress = progressState['progress'];
@ -308,8 +314,6 @@ router.post('/generate', jsonParser, async (request, response) => {
'Content-Type': 'application/json',
'Authorization': getBasicAuthHeader(request.body.auth),
},
timeout: 0,
// @ts-ignore
signal: controller.signal,
});
@ -345,6 +349,7 @@ router.post('/sd-next/upscalers', jsonParser, async (request, response) => {
// Vlad doesn't provide Latent Upscalers in the API, so we have to hardcode them here
const latentUpscalers = ['Latent', 'Latent (antialiased)', 'Latent (bicubic)', 'Latent (bicubic antialiased)', 'Latent (nearest)', 'Latent (nearest-exact)'];
/** @type {any} */
const data = await result.json();
const names = data.map(x => x.name);
@ -387,6 +392,7 @@ comfy.post('/samplers', jsonParser, async (request, response) => {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const data = await result.json();
return response.send(data.KSampler.input.required.sampler_name[0]);
} catch (error) {
@ -404,6 +410,7 @@ comfy.post('/models', jsonParser, async (request, response) => {
if (!result.ok) {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const data = await result.json();
return response.send(data.CheckpointLoaderSimple.input.required.ckpt_name[0].map(it => ({ value: it, text: it })));
} catch (error) {
@ -422,6 +429,7 @@ comfy.post('/schedulers', jsonParser, async (request, response) => {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const data = await result.json();
return response.send(data.KSampler.input.required.scheduler[0]);
} catch (error) {
@ -440,6 +448,7 @@ comfy.post('/vaes', jsonParser, async (request, response) => {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const data = await result.json();
return response.send(data.VAELoader.input.required.vae_name[0]);
} catch (error) {
@ -521,6 +530,7 @@ comfy.post('/generate', jsonParser, async (request, response) => {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const data = await promptResult.json();
const id = data.prompt_id;
let item;
@ -531,6 +541,7 @@ comfy.post('/generate', jsonParser, async (request, response) => {
if (!result.ok) {
throw new Error('ComfyUI returned an error.');
}
/** @type {any} */
const history = await result.json();
item = history[id];
if (item) {
@ -633,6 +644,7 @@ together.post('/generate', jsonParser, async (request, response) => {
return response.sendStatus(500);
}
/** @type {any} */
const data = await result.json();
console.log('TogetherAI response:', data);
@ -681,6 +693,8 @@ drawthings.post('/get-model', jsonParser, async (request, response) => {
const result = await fetch(url, {
method: 'GET',
});
/** @type {any} */
const data = await result.json();
return response.send(data['model']);
@ -698,6 +712,8 @@ drawthings.post('/get-upscaler', jsonParser, async (request, response) => {
const result = await fetch(url, {
method: 'GET',
});
/** @type {any} */
const data = await result.json();
return response.send(data['upscaler']);
@ -726,7 +742,6 @@ drawthings.post('/generate', jsonParser, async (request, response) => {
'Content-Type': 'application/json',
'Authorization': auth,
},
timeout: 0,
});
if (!result.ok) {
@ -848,7 +863,6 @@ stability.post('/generate', jsonParser, async (request, response) => {
'Accept': 'image/*',
},
body: formData,
timeout: 0,
});
if (!result.ok) {