Define TargetApplicationState in types and remove Application type

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-11-06 16:51:46 +00:00
parent 1d89174caf
commit fea80c5205
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 42 additions and 12 deletions

View File

@ -1,12 +0,0 @@
import { ServiceComposeConfig } from '../compose/types/service';
export class Application {
public appId: number;
public commit: string;
public name: string;
public releaseId: number;
public networks: Dictionary<any>;
public volumes: Dictionary<any>;
public services: Dictionary<ServiceComposeConfig>;
}

View File

@ -1,3 +1,7 @@
import { ComposeNetworkConfig } from '../compose/types/network';
import { ServiceComposeConfig } from '../compose/types/service';
import { ComposeVolumeConfig } from '../compose/volume';
export interface DeviceApplicationState {
local?: {
config?: Dictionary<string>;
@ -17,3 +21,41 @@ export interface DeviceApplicationState {
dependent?: any;
commit?: string;
}
// TODO: Define this with io-ts so we can perform validation
// on the target state from the api, local mode, and preload
export interface TargetState {
local: {
name: string;
config: Dictionary<string>;
apps: {
[appId: string]: {
name: string;
commit: string;
releaseId: number;
services: {
[serviceId: string]: {
labels: Dictionary<string>;
imageId: number;
serviceName: string;
image: string;
running: boolean;
environment: Dictionary<string>;
} & ServiceComposeConfig;
};
volumes: Dictionary<Partial<ComposeVolumeConfig>>;
networks: Dictionary<Partial<ComposeNetworkConfig>>;
};
};
};
// TODO: Correctly type this once dependent devices are
// actually properly supported
dependent: Dictionary<any>;
}
export type LocalTargetState = TargetState['local'];
export type TargetApplications = LocalTargetState['apps'];
export type TargetApplication = LocalTargetState['apps'][0];
export type AppsJsonFormat = Omit<TargetState['local'], 'name'> & {
pinDevice?: boolean;
};