///
import { DomoModule, InitObject } from '../lib/module';
import { Source, DefaultSource } from '../sources/source';
import { GenericDevice } from '../devices/genericDevice';
import { Scenario } from '../scenarios/scenario';
import Module = require('module');
import * as userMgr from '../managers/userMgr';
declare type User = userMgr.User;
import * as events from 'events';
import { ConfigLoader as importedConfigLoader } from '..';
import * as Parser from "shitty-peg/dist/Parser";
declare var logger: any;
export interface Map {
[index: string]: T;
}
declare type importItem = {
module: string;
class: new () => DomoModule;
comment1: string;
comment2: string;
source?: string;
device?: string;
};
declare type value = string | Function | string[] | {
[s: string]: value;
};
declare type plainObject = {
source?: string;
type?: string;
[key: string]: value;
};
declare type sourceItem = {
name: string;
object: plainObject;
source: Source;
};
declare type deviceItem = {
name: string;
object: plainObject;
device: GenericDevice;
};
declare type pageItem = {
name: string;
menuItem: string;
title: string;
page: string;
args: Map;
};
export declare type Sandbox = {
isReleased(): boolean;
console: typeof console;
assert: typeof assert;
require: typeof require;
setTimeout: typeof setTimeout;
clearTimeout: typeof clearTimeout;
setInterval: typeof setInterval;
clearInterval: typeof clearInterval;
args: {
args: any;
result: any;
};
getDevice: typeof getDevice;
getSource: typeof getSource;
setDeviceState: typeof setDeviceState;
getDeviceState: typeof getDeviceState;
getDevicePreviousState: typeof getDevicePreviousState;
getDeviceLastUpdateDate: typeof getDeviceLastUpdateDate;
getDeviceStateHistory: typeof getDeviceStateHistory;
logger: typeof logger;
msg: {
emitter: string;
oldValue: string;
newValue: string;
};
scriptFile: string;
scriptLine: number;
functionString: string;
};
export declare class ConfigLoader extends events.EventEmitter {
released: boolean;
secrets: Map;
imports: Map;
sources: Map;
devices: Map;
scenarios: Map;
pages: Map;
userMgr: userMgr.UserMgr;
comments: string[];
DEFAULT_SOURCE: DefaultSource;
rootModule: Module;
currentParsedFile: string;
currentGlobalDebugMode: boolean;
private sandbox;
constructor();
release(): void;
parse(fileOrDir: string, done: (err?: Error) => void): void;
private parseSingleFile;
unparse(): string;
createInstance(instanceFullname: string, moduleClass: new () => DomoModule, data: InitObject): DomoModule;
getDevice(path: string): GenericDevice;
getDevicesFromIds(ids: string[] | string): GenericDevice[];
private getModuleClass;
private compiledScripts;
private vm;
sandboxedFunction(location: Parser.Location, fct: string): Function;
sandboxedExtFunction(location: Parser.Location, func: string): Function;
setSandboxMsg(msg: {
[k: string]: any;
}): void;
}
import assert = require('assert');
export declare let IDENTIFIER: Parser.Token;
export declare let DASH: Parser.Token;
export declare let FUNCTION_EXT: Parser.Token;
declare function importItem(c: Parser.Parse): importItem;
declare function sourceItem(c: Parser.Parse): sourceItem;
declare function deviceItem(c: Parser.Parse): deviceItem;
declare function pageItem(c: Parser.Parse): pageItem;
declare function plainObject(c: Parser.Parse): Object;
declare function value(c: Parser.Parse): value;
export declare function loadFile(file: string, done: (err: Error, doc: ConfigLoader) => void): void;
export declare let sources: Map;
export declare let devices: Map;
export declare let pages: Map;
export declare function getDevices(): GenericDevice[];
export declare function getDevice(shortPath: string): GenericDevice;
export declare function getSource(sourceID: string): Source;
declare function setDeviceState(path: string, state: string, callback?: (err: Error) => void): void;
declare function getDeviceState(path: string): string;
declare function getDevicePreviousState(path: string): string;
declare function getDeviceLastUpdateDate(path: string): Date;
declare function getDeviceStateHistory(path: string, aggregate: "none" | "minute" | "hour" | "day" | "month" | "year", fromDate: Date, toDate: Date, callback: (err: Error, res?: string[]) => void): void;
export declare function getCurrentConfig(): importedConfigLoader;
declare type DoneFunction = (err: Error, doc: ConfigLoader) => void;
export declare function reloadConfig(done: DoneFunction): void;
export declare function reloadConfig(file: string, done: DoneFunction): void;
import { IVerifyOptions } from 'passport-local';
export declare function checkUser(username: string, password: string, done: (error: any, user?: any, options?: IVerifyOptions) => void): void;
export declare function findUserById(id: string, fn: (err: Error, user: User) => void): void;
export {};