UNPKG

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