///
import { Request } from 'request';
import { Docker } from 'docker-cli-js';
import { CronJob } from 'cron';
import { metrics } from '@nodeswork/utils';
import { LocalStorage } from './utils';
import { nam } from './def';
export interface AuthOptions {
email: string;
password: string;
deviceName: string;
}
export interface AppletManagerOptions {
appPath: string;
nodesworkServer: string;
port: number;
debug?: boolean;
dev?: boolean;
pid?: number;
token?: string;
}
export declare class AppletManager implements nam.INAM {
private options;
ls: LocalStorage;
docker: Docker;
network: Network;
containerProxy: ContainerProxy;
cronJobs: WorkerCronJob[];
private serverApi;
constructor(options: AppletManagerOptions);
authenticated(): boolean;
/**
* Authenticate the container by email and password.
*
* @throws UNAUTHENTICATED_ERROR
*/
authenticate(options: AuthOptions): Promise;
isStarted(): boolean;
/**
* Start the container.
*
* @throws UNAUTHENTICATED_ERROR
*/
startServer(): Promise;
/**
* Stop the container.
*
* @throws UNAUTHENTICATED_ERROR
*/
stopServer(): Promise;
install(options: nam.AppletImage): Promise;
images(): Promise;
run(options: nam.AppletRunOptions): Promise;
kill(options: nam.RouteOptions): Promise;
ps(): Promise;
refreshWorkerCrons(): Promise;
executeCronJob(job: WorkerCronJob): Promise;
updateExecutionMetrics(executionId: string, options: metrics.UpdateMetricsDataOptions): Promise;
work(options: nam.WorkOptions): Promise;
request(options: nam.RequestOptions): Promise;
operateAccount(options: nam.AccountOperateOptions): Promise;
route(options: nam.RouteOptions): Promise;
updateDevice(): Promise;
checkEnvironment(): Promise;
private ensureMongo(options);
private name(options);
private installContainerProxy();
}
export interface Network {
subnet: string;
gateway: string;
containers: object[];
}
export interface ContainerProxy {
version: string;
latestVersion: string;
}
export interface WorkerCronJob {
jobUUID: string;
userApplet: string;
appletId: string;
image: nam.AppletImage;
worker: nam.Worker;
schedule: string;
cronJob?: CronJob;
}