Skip to content

Commit

Permalink
docs(common): add more docs (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirily11 authored Mar 8, 2022
1 parent 836d527 commit de351ac
Show file tree
Hide file tree
Showing 12 changed files with 217 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,44 @@ import { ContainerInfo, ImageInfo } from "dockerode";
import { Web3DataInfo } from "../etd_interfaces";

interface Docker {
/**
* Docker images' info
*/
images: ImageInfo[];
/**
* Docker container's info
*/
containers: ContainerInfo[];
}

export interface DeviceDBInterface {
/**
* Device's online status
*/
isOnline?: boolean;
/**
* Last seen time. This will be set on server side.
* DO NOT provide this field in your request, otherwise, it will be overwritten.
*/
lastSeen?: Date;
/**
* Name of the device
*/
name: string;
/**
* ID of the device
*/
user: string | null;
/**
* Admin node's version
*/
adminVersion: string;
/**
* ETD Node's info
*/
data?: Web3DataInfo;
/**
* Device's docker info
*/
docker?: Docker;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
export interface DockerImageDBInterface {
/**
* Name of the docker image. For example hello-world
*/
imageName: string;
/**
* List of tags of the given image. For example [latest, 1.0, 1.1]
*/
tags: DockerImageVersionDBInterface[];
/**
* Will be set when query from installation template
* Read only! Will be set when query from installation template.
*/
tag?: DockerImageVersionDBInterface;
}

interface DockerImageVersionDBInterface {
/**
* Tag of the image. For example 1.0
*/
tag: string;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
export interface ExecutionPlanDBInterface {
/**
* Creation timestamp of the execution plan
*/
createdAt: any;
/**
* Update template's id related to this execution plan
*/
updateTemplate: any;
/**
* Is the execution finished?
*/
isDone: boolean;
/**
* Does the execution plan contain any error?
*/
isError: boolean;
/**
* Name of the execution plan
*/
name: string;
/**
* Description of the execution plan
*/
description: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,50 @@
import { DockerImageDBInterface } from "./docker_interfaces";

export interface InstallationTemplateDBInterface {
/**
* Docker compose version
*/
version: string;
/**
* Docker compose services. This should be the same format as the docker compose file
*/
services: { name: string; service: InstallationTemplateServiceDBInterface }[];
/**
* Template tag used to identify the template
*/
// eslint-disable-next-line camelcase
template_tag: string;
/**
* Author of this installation template. Will be set on server.
*/
// eslint-disable-next-line camelcase
created_by: string;
}

export interface InstallationTemplateServiceDBInterface {
/**
* Docker Image of this service
*/
image: DockerImageDBInterface;
/**
* Restart policy
*/
restart: string;
/**
* Environments used in the docker compose. For example a=hello
*/
environment: string[];
/**
* Network mode
*/
// eslint-disable-next-line camelcase
network_mode: string;
/**
* Mounting options. For example ./data:/var/usr
*/
volumes: string[];
/**
* Labels of the docker compose
*/
labels: string[];
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,36 @@
import { JobTaskType } from "../../enums";

export interface JobResultDBInterface {
/**
* Pending job's id
*/
jobId: string;
/**
* Submission date
*/
time: Date;
/**
* Submitted by which device
*/
deviceID: string;
/**
* From which client. This will be the unique id
* From which client who sent this job. This will be the unique id
*/
from: string;
/**
* actual command
*/
command: any;
/**
* Job's result
*/
result: any;
/**
* Is success?
*/
success: boolean;
commandType: string;
/**
* Command type. Should be one of the job task type enum
*/
commandType: JobTaskType;
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import { JobTaskType, PendingJobTaskType } from "../../enums";

interface Task<T extends PendingJobTaskType> {
/**
* Job type
*/
type: JobTaskType;
/**
* Job value
*/
value: T;
}

export interface PendingJobDBInterface<T> {
/**
* Send this job to which device
*/
targetDeviceId: string;
/**
* From client id.
*/
from: string;
/**
* Task object
*/
task: Task<T>;
/**
* Creation timestamp
*/
createdAt: string;
/**
* Whether this job has been retrieved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export interface StaticNodeDBInterface {
/**
* Static node's name
*/
nodeName: string;
/**
* Static node's enode url
*/
nodeURL: string;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import { DeviceDBInterface } from "./device_interfaces";

export interface StorageUserDBInterface {
/**
* User name
*/
// eslint-disable-next-line camelcase
user_name: string;
/**
* User id
*/
// eslint-disable-next-line camelcase
user_id: string;
/**
* User's coinbase
*/
coinbase?: string;
}

/**
* @deprecated this interface will be removed in the future
*/
export interface OwnerDBInterface {
// eslint-disable-next-line camelcase
user_id: string;
Expand Down Expand Up @@ -44,5 +56,8 @@ export interface StorageItemDBInterface {

export interface StorageItemWithStatusDBInterface
extends StorageItemDBInterface {
/**
* Realtime status of the device
*/
status?: DeviceDBInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,41 @@ import { DeviceRequest, MountConfig } from "dockerode";
* Stack to describe the structure of the container
*/
export interface ContainerStack {
/**
* Docker container's id. If this was sent by remote server used to create a new container,
* then this field will be undefined
*/
containerId?: string;
/**
* Docker container's name
*/
containerName: string;
/**
* Related image
*/
image: ImageStack;
/**
* Map of container's configuration. Similar to the docker's config
*/
config?: DockerContainerConfig;
/**
* Log of container
*/
runningLog?: string;
}

export interface ImageStack {
/**
* Image id. This field will be set during pulling. It will be undefined when receiving from the server.
*/
imageId?: string;
/**
* Image name
*/
image: string;
/**
* Image tag
*/
tag: string;
}

Expand Down
45 changes: 45 additions & 0 deletions packages/etd-common/src/interfaces/etd_interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,71 @@ export interface TransactionSummary {

interface PeerInfo {
caps: string[];
/**
* Peer's id
*/
id: string;
/**
* Peer's name
*/
name: string;
network: {
/**
* Peer's local ip address
*/
localAddress: string;
/**
* Peer's network ip address
*/
remoteAddress: string;
};
/**
* Peer's protocol info
*/
protocols: any;
}

export interface Web3DataInfo extends BlockTransactionString {
systemInfo: {
/**
* @deprecated Use admin version in device data directly. This field will be deleted in the future.
*/
adminVersion: string;
/**
* ETD Node version
*/
nodeVersion: string;
/**
* Number of peers connected to the
*/
peerCount: number;
/**
* Syncing status of the ETD node
*/
isSyncing: boolean;
/**
* Mining status of the ETD node
*/
isMining: boolean;
/**
* Coinbase of the ETD node. Might be undefined if the node doesn't have one.
*/
coinbase: string | undefined;
/**
* Hashing rate of the ETD node
*/
hashRate: number;
};
/**
* Block time between this block and the previous block
*/
blockTime: number;
/**
* Avg block time between this block and the x blocks before
*/
avgBlockTime: number;
/**
* Peers info
*/
peers: PeerInfo[];
}
2 changes: 1 addition & 1 deletion packages/etd-common/src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import deviceSchema from "./device_interfaces.json";
import dockerSchema from "./docker_interfaces.json";
import etdSchema from "./etd_interfaces.json";
import executionPlanSchema from "./execution_plan_interfaces.json";
import installationTemplateSchema from "./execution_plan_interfaces.json";
import installationTemplateSchema from "./installation_template_interfaces.json";
import jobResultSchema from "./job_result_interfaces.json";
import pendingJobSchema from "./pending_job_interfaces.json";
import pluginInterfaceSchema from "./plugin_interfaces.json";
Expand Down
Loading

0 comments on commit de351ac

Please sign in to comment.