diff --git a/packages/backend-core/src/cache/appMetadata.ts b/packages/backend-core/src/cache/appMetadata.ts index 69f734162b..0c320ec776 100644 --- a/packages/backend-core/src/cache/appMetadata.ts +++ b/packages/backend-core/src/cache/appMetadata.ts @@ -5,6 +5,11 @@ import { Database, App } from "@budibase/types" export enum AppState { INVALID = "invalid", } + +export interface DeletedApp { + state: AppState +} + const EXPIRY_SECONDS = 3600 /** @@ -24,10 +29,6 @@ function isInvalid(metadata?: { state: string }) { return !metadata || metadata.state === AppState.INVALID } -interface DeletedAppMetadata { - state: AppState -} - /** * Get the requested app metadata by id. * Use redis cache to first read the app metadata. @@ -35,9 +36,7 @@ interface DeletedAppMetadata { * @param {string} appId the id of the app to get metadata from. * @returns {object} the app metadata. */ -export async function getAppMetadata( - appId: string -): Promise { +export async function getAppMetadata(appId: string): Promise { const client = await getAppClient() // try cache let metadata = await client.get(appId) diff --git a/packages/backend-core/src/db/utils.ts b/packages/backend-core/src/db/utils.ts index b6e793c065..4ebf8392b5 100644 --- a/packages/backend-core/src/db/utils.ts +++ b/packages/backend-core/src/db/utils.ts @@ -2,7 +2,7 @@ import env from "../environment" import { DEFAULT_TENANT_ID, SEPARATOR, DocumentType } from "../constants" import { getTenantId, getGlobalDBName } from "../context" import { doWithDB, directCouchAllDbs } from "./db" -import { AppState, getAppMetadata } from "../cache/appMetadata" +import { AppState, DeletedApp, getAppMetadata } from "../cache/appMetadata" import { isDevApp, isDevAppID, getProdAppID } from "../docIds/conversions" import { App, Database } from "@budibase/types" import { getStartEndKeyURL } from "../docIds" @@ -131,7 +131,7 @@ export async function getAppsByIDs(appIds: string[]) { .filter( promise => promise.status === "fulfilled" && - promise.value?.state !== AppState.INVALID + (promise.value as DeletedApp).state !== AppState.INVALID ) .map(promise => (promise as PromiseFulfilledResult).value) }