ui/api: simplify types in api

This commit is contained in:
Johannes Kirschbauer
2025-08-11 11:00:30 +02:00
parent 1524dc963e
commit 0859a86ce0
2 changed files with 9 additions and 10 deletions

View File

@@ -72,7 +72,7 @@ export const callApi = <K extends OperationNames>(
const op_key = backendOpts?.op_key ?? crypto.randomUUID(); const op_key = backendOpts?.op_key ?? crypto.randomUUID();
const req: BackendSendType<OperationNames> = { const req: BackendSendType<K> = {
body: args, body: args,
header: { header: {
...backendOpts, ...backendOpts,
@@ -83,11 +83,9 @@ export const callApi = <K extends OperationNames>(
const result = ( const result = (
window as unknown as Record< window as unknown as Record<
OperationNames, OperationNames,
( (args: BackendSendType<K>) => Promise<BackendReturnType<K>>
args: BackendSendType<OperationNames>,
) => Promise<BackendReturnType<OperationNames>>
> >
)[method](req) as Promise<BackendReturnType<K>>; )[method](req);
return { return {
uuid: op_key, uuid: op_key,

View File

@@ -2,6 +2,7 @@ import { Typography } from "@/src/components/Typography/Typography";
import { BackButton, NextButton, StepLayout } from "../../Steps"; import { BackButton, NextButton, StepLayout } from "../../Steps";
import { import {
createForm, createForm,
FieldValues,
getError, getError,
SubmitHandler, SubmitHandler,
valiForm, valiForm,
@@ -12,7 +13,7 @@ import { getStepStore, useStepper } from "@/src/hooks/stepper";
import { InstallSteps, InstallStoreType, PromptValues } from "../install"; import { InstallSteps, InstallStoreType, PromptValues } from "../install";
import { TextInput } from "@/src/components/Form/TextInput"; import { TextInput } from "@/src/components/Form/TextInput";
import { Alert } from "@/src/components/Alert/Alert"; import { Alert } from "@/src/components/Alert/Alert";
import { For, onMount, Show } from "solid-js"; import { For, Show } from "solid-js";
import { Divider } from "@/src/components/Divider/Divider"; import { Divider } from "@/src/components/Divider/Divider";
import { Orienter } from "@/src/components/Form/Orienter"; import { Orienter } from "@/src/components/Form/Orienter";
import { Button } from "@/src/components/Button/Button"; import { Button } from "@/src/components/Button/Button";
@@ -302,19 +303,19 @@ const ConfigureData = () => {
); );
}; };
type PromptGroup = { interface PromptGroup {
name: string; name: string;
fields: { fields: {
prompt: Prompt; prompt: Prompt;
generator: string; generator: string;
value?: string | null; value?: string | null;
}[]; }[];
}; }
type Prompt = NonNullable<MachineGenerators[number]["prompts"]>[number]; type Prompt = NonNullable<MachineGenerators[number]["prompts"]>[number];
type PromptForm = { interface PromptForm extends FieldValues {
promptValues: PromptValues; promptValues: PromptValues;
}; }
interface PromptsFieldsProps { interface PromptsFieldsProps {
generators: MachineGenerators; generators: MachineGenerators;