@ha4us/script.adapter
Version:
Scripting Adapter for the ha4us
69 lines (68 loc) • 3.16 kB
TypeScript
import { StateService, YamlService, ObjectService, MediaService } from '@ha4us/adapter';
import { DateTime } from 'luxon';
import { ScheduleEvent, Scheduler, TimeDefinition, CalculatedTime } from 'us-scheduler';
import { Ha4usOperators, Ha4usLogger, Ha4usMessage, Ha4usObject, render, compile, randomString, Ha4usMediaDefinition } from '@ha4us/core';
import * as rxjs from 'rxjs';
import { Observable } from 'rxjs';
import { Ha4usScript } from './ha4us-script';
export declare class Sandbox {
protected _script: Ha4usScript;
stop$: rxjs.Subject<void>;
protected _log: Ha4usLogger;
_onDestroy: () => void;
onlyRetained: typeof Ha4usOperators.onlyRetained;
noRetained: typeof Ha4usOperators.noRetained;
pick: typeof Ha4usOperators.pick;
pickEach: typeof Ha4usOperators.pickEach;
render: typeof render;
compileTemplate: typeof compile;
randomString: typeof randomString;
protected _modules: {
[moduleName: string]: any;
};
protected _name: string;
protected _$states: StateService;
protected _$yaml: YamlService;
protected _$objects: ObjectService;
protected $media: MediaService;
http: {
parse: (url: string, query: object) => Promise<CheerioStatic>;
get: (url: string, query: object) => Promise<string>;
};
console: {
log: (message: string, ...args: any[]) => void;
debug: (message: string, ...args: any[]) => void;
info: (message: string, ...args: any[]) => void;
warn: (message: string, ...args: any[]) => void;
error: (message: string, ...args: any[]) => void;
};
log: {
log: (message: string, ...args: any[]) => void;
debug: (message: string, ...args: any[]) => void;
info: (message: string, ...args: any[]) => void;
warn: (message: string, ...args: any[]) => void;
error: (message: string, ...args: any[]) => void;
};
protected _scheduler: Scheduler;
constructor(_script: Ha4usScript);
readonly sandbox: Sandbox;
protected _setupLogger(): Ha4usLogger;
require(md: string): any;
observe(topic: string, ...params: any[]): rxjs.Observable<Ha4usMessage<any>>;
combine(...pattern: string[]): Observable<Ha4usMessage[]>;
set(topic: string, value: any): Promise<any>;
get(topic: string): Promise<Ha4usMessage>;
status(topic: string, value: any, retained?: boolean): Promise<Ha4usMessage<any>>;
emit(topic: string, value: any, retained?: boolean): Promise<Ha4usMessage<any>>;
schedule(...times: TimeDefinition<any>[]): Observable<ScheduleEvent>;
cron(cronPattern: string): Observable<DateTime>;
doIn<T>(duration: string | number, data?: T): Observable<T>;
doAt<T>(date: TimeDefinition<any>): Observable<CalculatedTime<any>>;
load(file: string): any;
save(data: any, file: string): any;
createObject(topic: string, data: Partial<Ha4usObject>): Promise<any>;
$onDestroy(destroyFunc: () => void): void;
random(maxOrMin: number, max?: number): number;
downloadImage(url: string, fileOptions: Partial<Ha4usMediaDefinition>): Promise<string>;
event(msg: string, opt: any): void;
}