fix type check for deleted app type
This commit is contained in:
parent
567c7fd485
commit
108d18df75
|
@ -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<App | DeletedAppMetadata> {
|
||||
export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
|
||||
const client = await getAppClient()
|
||||
// try cache
|
||||
let metadata = await client.get(appId)
|
||||
|
|
|
@ -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<App>).value)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue