Move fetchDatasetDetails to api/datasets

This commit is contained in:
davelopez
2023-10-23 18:13:43 +02:00
parent a9a8fa342b
commit 93e8332446
5 changed files with 13 additions and 15 deletions
+10
View File
@@ -1,5 +1,6 @@
import type { FetchArgType } from "openapi-typescript-fetch";
import { DatasetDetails } from "@/api";
import { fetcher } from "@/api/schema";
import { withPrefix } from "@/utils/redirect";
@@ -35,6 +36,15 @@ export async function getDatasets(options: GetDatasetsOptions = {}) {
return data;
}
const getDataset = fetcher.path("/api/datasets/{dataset_id}").method("get").create();
export async function fetchDatasetDetails(params: { id: string }): Promise<DatasetDetails> {
const { data } = await getDataset({ dataset_id: params.id, view: "detailed" });
// We know that the server will return a DatasetDetails object because of the view parameter
// but the type system doesn't, so we have to cast it.
return data as unknown as DatasetDetails;
}
const updateHistoryDataset = fetcher.path("/api/histories/{history_id}/contents/{type}s/{id}").method("put").create();
export async function undeleteHistoryDataset(historyId: string, datasetId: string) {
@@ -7,7 +7,7 @@
<script>
import { mapCacheActions } from "vuex-cache";
import { fetchDatasetDetails } from "@/stores/services/dataset.service";
import { fetchDatasetDetails } from "@/api/datasets";
export default {
props: {
@@ -1,8 +1,8 @@
import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import { fetchDatasetDetails } from "@/api/datasets";
import { SingleQueryProvider } from "@/components/providers/SingleQueryProvider";
import { fetchDatasetDetails } from "@/stores/services/dataset.service";
import { rethrowSimple } from "@/utils/simple-error";
import { stateIsTerminal } from "./utils";
+1 -2
View File
@@ -2,8 +2,7 @@ import { defineStore } from "pinia";
import Vue, { computed, ref } from "vue";
import { DatasetDetails, DatasetEntry, HistoryContentItemBase } from "@/api";
import { fetchDatasetDetails } from "./services/dataset.service";
import { fetchDatasetDetails } from "@/api/datasets";
export const useDatasetStore = defineStore("datasetStore", () => {
const storedDatasets = ref<{ [key: string]: DatasetDetails }>({});
@@ -1,11 +0,0 @@
import { DatasetDetails } from "@/api";
import { fetcher } from "@/api/schema";
const getDataset = fetcher.path("/api/datasets/{dataset_id}").method("get").create();
export async function fetchDatasetDetails(params: { id: string }): Promise<DatasetDetails> {
const { data } = await getDataset({ dataset_id: params.id, view: "detailed" });
// We know that the server will return a DatasetDetails object because of the view parameter
// but the type system doesn't, so we have to cast it.
return data as unknown as DatasetDetails;
}