Add types for Responses
This commit is contained in:
parent
07359370e6
commit
4090dd2dfe
|
@ -3,6 +3,9 @@ import { App } from "@budibase/types"
|
|||
import { Response } from "node-fetch"
|
||||
import InternalAPIClient from "./InternalAPIClient"
|
||||
import FormData from "form-data"
|
||||
import { RouteConfig } from "../fixtures/types/routing"
|
||||
import { AppPackageResponse } from "../fixtures/types/appPackage"
|
||||
import { DeployConfig } from "../fixtures/types/deploy"
|
||||
|
||||
type messageResponse = { message: string }
|
||||
|
||||
|
@ -25,13 +28,13 @@ export default class AppApi {
|
|||
return [response, Object.keys(json.routes).length > 0]
|
||||
}
|
||||
|
||||
async getAppPackage(appId: string): Promise<[Response, any]> {
|
||||
async getAppPackage(appId: string): Promise<[Response, AppPackageResponse]> {
|
||||
const response = await this.api.get(`/applications/${appId}/appPackage`)
|
||||
const json = await response.json()
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async publish(): Promise<[Response, any]> {
|
||||
async publish(): Promise<[Response, DeployConfig]> {
|
||||
const response = await this.api.post("/deploy")
|
||||
const json = await response.json()
|
||||
return [response, json]
|
||||
|
@ -73,12 +76,6 @@ export default class AppApi {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async getAppDefinition(appId: string): Promise<[Response, any]> {
|
||||
const response = await this.api.get(`/applications/${appId}/definition`)
|
||||
const json = await response.json()
|
||||
return [response, json]
|
||||
}
|
||||
|
||||
async update(appId: string, body: any): Promise<[Response, Application]> {
|
||||
const response = await this.api.put(`/applications/${appId}`, { body })
|
||||
const json = await response.json()
|
||||
|
@ -91,7 +88,7 @@ export default class AppApi {
|
|||
return [response, json]
|
||||
}
|
||||
|
||||
async getRoutes(): Promise<[Response, any]> {
|
||||
async getRoutes(): Promise<[Response, RouteConfig]> {
|
||||
const response = await this.api.get(`/routing`)
|
||||
const json = await response.json()
|
||||
return [response, json]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import { Application } from "@budibase/server/api/controllers/public/mapping/types"
|
||||
import { Layout } from "@budibase/types"
|
||||
import { Screen } from "@budibase/types"
|
||||
// Create type for getAppPackage response
|
||||
export interface AppPackageResponse {
|
||||
application: Partial<Application>,
|
||||
layout: Layout,
|
||||
screens: Screen[]
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
export interface DeployConfig {
|
||||
appUrl: string,
|
||||
status: string,
|
||||
"_id": string
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
export interface RouteConfig {
|
||||
routes: Record<string, Route>
|
||||
}
|
||||
|
||||
export interface Route {
|
||||
subpaths: Record<string, Subpath>
|
||||
}
|
||||
|
||||
export interface Subpath {
|
||||
screens: ScreenRouteConfig
|
||||
}
|
||||
|
||||
export interface ScreenRouteConfig {
|
||||
BASIC?: string
|
||||
POWER?: string
|
||||
ADMIN?: string
|
||||
}
|
Loading…
Reference in New Issue