diff --git a/src/api/session.js b/src/api/session.ts similarity index 88% rename from src/api/session.js rename to src/api/session.ts index 110cfeac6..3ed07a6e6 100644 --- a/src/api/session.js +++ b/src/api/session.ts @@ -1,4 +1,4 @@ -import axios from "axios"; +import axios, { type AxiosInstance } from "axios"; import axiosRetry from "axios-retry"; import { DC_BASE } from "../config/config.js"; @@ -30,11 +30,12 @@ export function getCsrfToken() { return token; } -const session = axios.create({ - xsrfCookieName: CSRF_COOKIE_NAME, - xsrfHeaderName: CSRF_HEADER_NAME, - withCredentials: cookiesEnabled, -}); +const session: AxiosInstance & { getStatic?: (url: string) => any } = + axios.create({ + xsrfCookieName: CSRF_COOKIE_NAME, + xsrfHeaderName: CSRF_HEADER_NAME, + withCredentials: cookiesEnabled, + }); session.interceptors.response.use( (response) => { @@ -55,6 +56,11 @@ session.interceptors.response.use( const CACHE_LIMIT = 50; +export interface SessionCache { + cached: any[]; + cachedByUrl: Record; +} + export class SessionCache { constructor() { this.cached = []; @@ -86,8 +92,7 @@ export class SessionCache { const sessionCache = new SessionCache(); -// @ts-ignore -session.getStatic = async function getStatic(url) { +session.getStatic = async function getStatic(url: string) { if (sessionCache.has(url)) { return sessionCache.lookup(url); } diff --git a/src/api/types/document.ts b/src/api/types/document.ts index 0f03fc923..ec6a85949 100644 --- a/src/api/types/document.ts +++ b/src/api/types/document.ts @@ -4,6 +4,13 @@ import type { Project } from "./project"; export type DocumentAccess = "public" | "organization" | "private"; +export type DocumentStatus = + | "success" + | "readable" + | "pending" + | "error" + | "nofile"; + export interface DocumentRevision { version: number; user: number; @@ -19,7 +26,7 @@ export interface Document { asset_url: string; canonical_url: string; created_at: string; - data: Record; + data: Record; description: string; edit_access: boolean; file_hash: string; @@ -39,7 +46,7 @@ export interface Document { revisions?: DocumentRevision[]; slug: string; source: string; - status: "success" | "failure" | "queued" | "in_progress"; + status: DocumentStatus; title: string; updated_at: string; user: User | number; diff --git a/src/api/viewer.js b/src/api/viewer.ts similarity index 100% rename from src/api/viewer.js rename to src/api/viewer.ts diff --git a/src/common/ProgressiveImage.svelte b/src/common/ProgressiveImage.svelte index c7dc18c34..3f54d6890 100644 --- a/src/common/ProgressiveImage.svelte +++ b/src/common/ProgressiveImage.svelte @@ -1,7 +1,7 @@