feat: add baseos node enrollment
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export type TBaseOsRuntimeLevel = 'app-layer' | 'host-os' | 'target-state';
|
||||
|
||||
export type TBaseOsCloudlyConnectionStatus =
|
||||
| 'not-configured'
|
||||
| 'connecting'
|
||||
| 'connected'
|
||||
| 'failed';
|
||||
|
||||
export interface IBaseOsRuntimeInfo {
|
||||
runtime: 'baseos';
|
||||
runtimeLevel: TBaseOsRuntimeLevel;
|
||||
nodeId: string;
|
||||
cloudlyUrl?: string;
|
||||
cloudlyConnectionStatus: TBaseOsCloudlyConnectionStatus;
|
||||
supervisorAvailable: boolean;
|
||||
supervisorAddress?: string;
|
||||
deviceState?: Record<string, unknown>;
|
||||
stateStatus?: Record<string, unknown>;
|
||||
checkedAt: number;
|
||||
}
|
||||
|
||||
export interface IBaseOsDesiredState {
|
||||
release?: string;
|
||||
targetState?: Record<string, unknown>;
|
||||
updatedAt?: number;
|
||||
}
|
||||
|
||||
export interface IBaseOsNodeData {
|
||||
runtimeInfo: IBaseOsRuntimeInfo;
|
||||
desiredState?: IBaseOsDesiredState;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
lastHeartbeatAt?: number;
|
||||
}
|
||||
|
||||
export interface IBaseOsNodePublic {
|
||||
id: string;
|
||||
data: IBaseOsNodeData;
|
||||
}
|
||||
|
||||
@plugins.smartdata.managed()
|
||||
export class BaseOsNode extends plugins.smartdata.SmartDataDbDoc<BaseOsNode, IBaseOsNodePublic> {
|
||||
constructor(optionsArg?: IBaseOsNodePublic & { nodeToken?: string }) {
|
||||
super();
|
||||
if (optionsArg) {
|
||||
Object.assign(this, optionsArg);
|
||||
}
|
||||
}
|
||||
|
||||
@plugins.smartdata.unI()
|
||||
public id!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public nodeToken!: string;
|
||||
|
||||
@plugins.smartdata.svDb()
|
||||
public data!: IBaseOsNodeData;
|
||||
|
||||
public toPublicNode(): IBaseOsNodePublic {
|
||||
return {
|
||||
id: this.id,
|
||||
data: this.data,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user