UNPKG

2.08 kBTypeScriptView Raw
1/// <reference types="iobroker" />
2/** The root directory of JS-Controller */
3export declare const controllerDir: string;
4/** Reads the configuration file of JS-Controller */
5export declare function getConfig(): Record<string, any>;
6/**
7 * This type is used to include and exclude the states and objects cache from the adaptert type definition depending on the creation options
8 */
9export interface AdapterInstance<HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined> extends Omit<ioBroker.Adapter, "oObjects" | "oStates"> {
10 oObjects: HasObjectsCache extends true ? Exclude<ioBroker.Adapter["oObjects"], undefined> : undefined;
11 oStates: HasStatesCache extends true ? Exclude<ioBroker.Adapter["oStates"], undefined> : undefined;
12}
13/** This type augments the ioBroker Adapter options to accept two generics for the objects and states cache */
14export declare type AdapterOptions<HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined> = Omit<ioBroker.AdapterOptions, "objects" | "states"> & (true extends HasObjectsCache ? {
15 objects: true;
16} : {
17 objects?: HasObjectsCache;
18}) & (true extends HasStatesCache ? {
19 states: true;
20} : {
21 states?: HasStatesCache;
22});
23/** Selects the correct instance type depending on the constructor params */
24interface AdapterConstructor {
25 new <HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined>(adapterOptions: AdapterOptions<HasObjectsCache, HasStatesCache> | string): AdapterInstance<HasObjectsCache, HasStatesCache>;
26 <HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined>(adapterOptions: AdapterOptions<HasObjectsCache, HasStatesCache> | string): AdapterInstance<HasObjectsCache, HasStatesCache>;
27}
28/** Creates a new adapter instance */
29export declare const adapter: AdapterConstructor;
30/** Creates a new adapter instance */
31export declare const Adapter: AdapterConstructor;
32export {};