diff --git a/src/types/application.ts b/src/types/application.ts deleted file mode 100644 index 3afac3ef..00000000 --- a/src/types/application.ts +++ /dev/null @@ -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; - public volumes: Dictionary; - - public services: Dictionary; -} diff --git a/src/types/state.ts b/src/types/state.ts index 6dd90100..bcff9cc9 100644 --- a/src/types/state.ts +++ b/src/types/state.ts @@ -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; @@ -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; + apps: { + [appId: string]: { + name: string; + commit: string; + releaseId: number; + services: { + [serviceId: string]: { + labels: Dictionary; + imageId: number; + serviceName: string; + image: string; + running: boolean; + environment: Dictionary; + } & ServiceComposeConfig; + }; + volumes: Dictionary>; + networks: Dictionary>; + }; + }; + }; + // TODO: Correctly type this once dependent devices are + // actually properly supported + dependent: Dictionary; +} + +export type LocalTargetState = TargetState['local']; +export type TargetApplications = LocalTargetState['apps']; +export type TargetApplication = LocalTargetState['apps'][0]; +export type AppsJsonFormat = Omit & { + pinDevice?: boolean; +};