1
0
Fork 0
mirror of synced 2024-06-02 10:34:40 +12:00

Update types

This commit is contained in:
Andrew Kingston 2022-08-25 08:10:11 +01:00
parent a6bf8084e7
commit 44a191d00d
3 changed files with 15 additions and 11 deletions

View file

@ -252,7 +252,6 @@ const performAppCreate = async (ctx: any) => {
const appId = instance._id
const db = context.getAppDB()
// Create new app doc
let newApplication: App = {
_id: DocumentType.APP_METADATA,
_rev: undefined,
@ -263,7 +262,7 @@ const performAppCreate = async (ctx: any) => {
name: name,
url: url,
template: templateKey,
instance: instance,
instance,
tenantId: getTenantId(),
updatedAt: new Date().toISOString(),
createdAt: new Date().toISOString(),
@ -290,15 +289,14 @@ const performAppCreate = async (ctx: any) => {
// Fetch and migrate some metadata from the existing app.
try {
const existing: App = await db.get(DocumentType.APP_METADATA)
const keys: string[] = [
const keys: (keyof App)[] = [
"_rev",
"navigation",
"theme",
"customTheme",
"icon",
]
keys.forEach((key: string) => {
// @ts-ignore
keys.forEach(key => {
if (existing[key]) {
// @ts-ignore
newApplication[key] = existing[key]
@ -602,17 +600,15 @@ const updateAppPackage = async (appPackage: any, appId: any) => {
const migrateAppNavigation = async () => {
const db = context.getAppDB()
const existing: App = await db.get(DocumentType.APP_METADATA)
const layouts = await getLayouts()
const screens = await getScreens()
const layouts: Layout[] = await getLayouts()
const screens: Screen[] = await getScreens()
// Migrate all screens, removing custom layouts
for (let screen of screens) {
if (!screen.layoutId) {
return
}
const layout = layouts.find(
(layout: Layout) => layout._id === screen.layoutId
)
const layout = layouts.find(layout => layout._id === screen.layoutId)
screen.layoutId = undefined
screen.showNavigation = layout?.props.navigation !== "None"
screen.width = layout?.props.width || "Large"

View file

@ -18,6 +18,7 @@ export interface App extends Document {
revertableVersion?: string
navigation?: AppNavigation
automationErrors?: AppMetadataErrors
icon?: AppIcon
}
export interface AppInstance {
@ -53,3 +54,8 @@ export interface AppCustomTheme {
navTextColor?: string
navBackground?: string
}
export interface AppIcon {
name: string
color: string
}

View file

@ -1,3 +1,5 @@
import { Document } from "../document"
export interface Layout extends Document {}
export interface Layout extends Document {
props: any
}