Improve and extend internal typings

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-12-18 15:53:37 +00:00
parent 5a95613dd7
commit e161888516
No known key found for this signature in database
GPG Key ID: 49690ED87032539F

View File

@ -1,9 +1,29 @@
import { ComposeNetworkConfig } from '../compose/types/network';
import { ServiceComposeConfig } from '../compose/types/service';
import { ComposeVolumeConfig } from '../compose/volume';
import Volume, { ComposeVolumeConfig } from '../compose/volume';
import { EnvVarObject, LabelObject } from '../lib/types';
export interface DeviceApplicationState {
import Network from '../compose/network';
import Service from '../compose/service';
export type DeviceReportFields = Partial<{
api_port: number;
api_secret: string | null;
ip_address: string;
os_version: string | null;
os_variant: string | null;
supervisor_version: string;
provisioning_progress: null | number;
provisioning_state: string;
status: string;
update_failed: boolean;
update_pending: boolean;
update_downloaded: boolean;
is_on__commit: string;
logs_channel: null;
}>;
export interface DeviceStatus {
local?: {
config?: Dictionary<string>;
apps?: {
@ -17,7 +37,7 @@ export interface DeviceApplicationState {
};
};
};
};
} & DeviceReportFields;
// TODO: Type the dependent entry correctly
dependent?: any;
commit?: string;
@ -40,8 +60,8 @@ export interface TargetState {
imageId: number;
serviceName: string;
image: string;
running: boolean;
environment: EnvVarObject;
running?: boolean;
environment: Dictionary<string>;
} & ServiceComposeConfig;
};
volumes: Dictionary<Partial<ComposeVolumeConfig>>;
@ -86,3 +106,28 @@ export type ApplicationDatabaseFormat = Array<{
networks: string;
volumes: string;
}>;
// This structure is the internal representation of both
// target and current state. We create instances of compose
// objects and these are what the state engine uses to
// detect what it should do to move between them
export interface InstancedAppState {
[appId: number]: {
appId: number;
commit: string;
releaseId: number;
name: string;
services: Service[];
volumes: { [name: string]: Volume };
networks: { [name: string]: Network };
};
}
export interface InstancedDeviceState {
local: {
name: string;
config: Dictionary<string>;
apps: InstancedAppState;
};
dependent: any;
}