Migrate to openapi-ts generator

This commit is contained in:
2024-07-03 15:08:54 +02:00
parent c36b64cff1
commit ef531f6491
81 changed files with 1157 additions and 1004 deletions

View File

@@ -37,7 +37,7 @@ export default function TranscriptCorrect({
const markAsDone = () => {
if (transcript.response && !transcript.response.reviewed) {
api
?.v1TranscriptUpdate(transcriptId, { reviewed: true })
?.v1TranscriptUpdate({ transcriptId, requestBody: { reviewed: true } })
.then(() => {
router.push(`/transcripts/${transcriptId}`);
})

View File

@@ -123,10 +123,13 @@ const ParticipantList = ({
setLoading(true);
try {
await api?.v1TranscriptAssignSpeaker(transcriptId, {
participant: participant.id,
timestamp_from: selectedText.start,
timestamp_to: selectedText.end,
await api?.v1TranscriptAssignSpeaker({
transcriptId,
requestBody: {
participant: participant.id,
timestamp_from: selectedText.start,
timestamp_to: selectedText.end,
},
});
onSuccess();
} catch (error) {
@@ -142,9 +145,12 @@ const ParticipantList = ({
setLoading(true);
if (participantTo.speaker) {
try {
await api?.v1TranscriptMergeSpeaker(transcriptId, {
speaker_from: speakerFrom,
speaker_to: participantTo.speaker,
await api?.v1TranscriptMergeSpeaker({
transcriptId,
requestBody: {
speaker_from: speakerFrom,
speaker_to: participantTo.speaker,
},
});
onSuccess();
} catch (error) {
@@ -153,11 +159,11 @@ const ParticipantList = ({
}
} else {
try {
await api?.v1TranscriptUpdateParticipant(
await api?.v1TranscriptUpdateParticipant({
transcriptId,
participantTo.id,
{ speaker: speakerFrom },
);
participantId: participantTo.id,
requestBody: { speaker: speakerFrom },
});
onSuccess();
} catch (error) {
setError(error, "There was an error merging (update)");
@@ -183,8 +189,12 @@ const ParticipantList = ({
if (participant && participant.name !== participantInput) {
setLoading(true);
api
?.v1TranscriptUpdateParticipant(transcriptId, participant.id, {
name: participantInput,
?.v1TranscriptUpdateParticipant({
transcriptId,
participantId: participant.id,
requestBody: {
name: participantInput,
},
})
.then(() => {
participants.refetch();
@@ -202,9 +212,12 @@ const ParticipantList = ({
) {
setLoading(true);
api
?.v1TranscriptAddParticipant(transcriptId, {
name: participantInput,
speaker: selectedText,
?.v1TranscriptAddParticipant({
transcriptId,
requestBody: {
name: participantInput,
speaker: selectedText,
},
})
.then(() => {
participants.refetch();
@@ -222,12 +235,12 @@ const ParticipantList = ({
) {
setLoading(true);
try {
const participant = await api?.v1TranscriptAddParticipant(
const participant = await api?.v1TranscriptAddParticipant({
transcriptId,
{
requestBody: {
name: participantInput,
},
);
});
setLoading(false);
assignTo(participant)().catch(() => {
// error and loading are handled by assignTo catch
@@ -240,8 +253,11 @@ const ParticipantList = ({
} else if (action == "Create") {
setLoading(true);
api
?.v1TranscriptAddParticipant(transcriptId, {
name: participantInput,
?.v1TranscriptAddParticipant({
transcriptId,
requestBody: {
name: participantInput,
},
})
.then(() => {
participants.refetch();
@@ -261,7 +277,7 @@ const ParticipantList = ({
if (loading || participants.loading || topicWithWords.loading) return;
setLoading(true);
api
?.v1TranscriptDeleteParticipant(transcriptId, participantId)
?.v1TranscriptDeleteParticipant({ transcriptId, participantId })
.then(() => {
participants.refetch();
setLoading(false);

View File

@@ -49,10 +49,10 @@ export default function FinalSummary(props: FinalSummaryProps) {
const requestBody: UpdateTranscript = {
long_summary: newSummary,
};
const updatedTranscript = await api?.v1TranscriptUpdate(
const updatedTranscript = await api?.v1TranscriptUpdate({
transcriptId,
requestBody,
);
});
console.log("Updated long summary:", updatedTranscript);
} catch (err) {
console.error("Failed to update long summary:", err);

View File

@@ -24,7 +24,7 @@ const useCreateTranscript = (): UseCreateTranscript => {
setLoading(true);
api
.v1TranscriptsCreate(transcriptCreationDetails)
.v1TranscriptsCreate({ requestBody: transcriptCreationDetails })
.then((transcript) => {
setTranscript(transcript);
setLoading(false);

View File

@@ -27,7 +27,10 @@ export default function FileUploadButton(props: FileUploadButton) {
// Add other properties if required by the type definition
};
api?.v1TranscriptRecordUpload(props.transcriptId, uploadData);
api?.v1TranscriptRecordUpload({
transcriptId: props.transcriptId,
formData: uploadData,
});
}
};

View File

@@ -57,10 +57,10 @@ export default function ShareAndPrivacy(props: ShareAndPrivacyProps) {
share_mode: toShareMode(selectedShareMode.value),
};
const updatedTranscript = await api.v1TranscriptUpdate(
props.transcriptResponse.id,
const updatedTranscript = await api.v1TranscriptUpdate({
transcriptId: props.transcriptResponse.id,
requestBody,
);
});
setShareMode(
shareOptions.find(
(option) => option.value === updatedTranscript.share_mode,

View File

@@ -21,10 +21,10 @@ const TranscriptTitle = (props: TranscriptTitle) => {
const requestBody: UpdateTranscript = {
title: newTitle,
};
const updatedTranscript = await api?.v1TranscriptUpdate(
const updatedTranscript = await api?.v1TranscriptUpdate({
transcriptId,
requestBody,
);
});
console.log("Updated transcript:", updatedTranscript);
} catch (err) {
console.error("Failed to update transcript:", err);

View File

@@ -49,7 +49,7 @@ const useParticipants = (transcriptId: string): UseParticipants => {
setLoading(true);
api
.v1TranscriptGetParticipants(transcriptId)
.v1TranscriptGetParticipants({ transcriptId })
.then((result) => {
setResponse(result);
setLoading(false);

View File

@@ -56,7 +56,7 @@ const useTopicWithWords = (
setLoading(true);
api
.v1TranscriptGetTopicsWithWordsPerSpeaker(transcriptId, topicId)
.v1TranscriptGetTopicsWithWordsPerSpeaker({ transcriptId, topicId })
.then((result) => {
setResponse(result);
setLoading(false);

View File

@@ -23,7 +23,7 @@ const useTopics = (id: string): TranscriptTopics => {
setLoading(true);
api
.v1TranscriptGetTopics(id)
.v1TranscriptGetTopics({ transcriptId: id })
.then((result) => {
setTopics(result);
setLoading(false);

View File

@@ -37,7 +37,7 @@ const useTranscript = (
setLoading(true);
api
.v1TranscriptGet(id)
.v1TranscriptGet({ transcriptId: id })
.then((result) => {
setResponse(result);
setLoading(false);

View File

@@ -28,7 +28,7 @@ const useTranscriptList = (page: number): TranscriptList => {
if (!api) return;
setLoading(true);
api
.v1TranscriptsList(page)
.v1TranscriptsList({ page })
.then((response) => {
setResponse(response);
setLoading(false);

View File

@@ -21,7 +21,7 @@ const useWaveform = (id: string): AudioWaveFormResponse => {
if (!id || !api) return;
setLoading(true);
api
.v1TranscriptGetAudioWaveform(id)
.v1TranscriptGetAudioWaveform({ transcriptId: id })
.then((result) => {
setWaveform(result);
setLoading(false);

View File

@@ -41,7 +41,7 @@ const useWebRTC = (
};
api
.v1TranscriptRecordWebrtc(transcriptId, rtcOffer)
.v1TranscriptRecordWebrtc({ transcriptId, requestBody: rtcOffer })
.then((answer) => {
try {
p.signal(answer);

View File

@@ -316,7 +316,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
if (!transcriptId || !api) return;
api?.v1TranscriptGetWebsocketEvents(transcriptId).then((result) => {});
api?.v1TranscriptGetWebsocketEvents({ transcriptId }).then((result) => {});
const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`;
let ws = new WebSocket(url);