[WIKI-181] chore: asset check endpoint added #7140

This commit is contained in:
Aaryan Khandelwal 2025-05-30 20:58:06 +05:30 committed by GitHub
parent 0f828fd5e0
commit 151fc8389e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 0 deletions

View file

@ -29,6 +29,10 @@ export const useEditorConfig = () => {
const { projectId, workspaceId, workspaceSlug } = args;
return {
checkIfAssetExists: async (assetId: string) => {
const res = await fileService.checkIfAssetExists(workspaceSlug, assetId);
return res?.exists ?? false;
},
getAssetSrc: async (path) => {
if (!path) return "";
if (path?.startsWith("http")) {

View file

@ -236,6 +236,19 @@ export class FileService extends APIService {
});
}
async checkIfAssetExists(
workspaceSlug: string,
assetId: string
): Promise<{
exists: boolean;
}> {
return this.get(`/api/assets/v2/workspaces/${workspaceSlug}/check/${assetId}/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async restoreOldEditorAsset(workspaceId: string, src: string): Promise<void> {
const assetKey = getAssetIdFromUrl(src);
return this.post(`/api/workspaces/file-assets/${workspaceId}/${assetKey}/restore/`)