UNPKG

2.01 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 adaptert 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 oObjects: HasObjectsCache extends true ? Exclude<ioBroker.Adapter["oObjects"], undefined> : undefined;
10 oStates: HasStatesCache extends true ? Exclude<ioBroker.Adapter["oStates"], undefined> : undefined;
11}
12/** This type augments the ioBroker Adapter options to accept two generics for the objects and states cache */
13export type AdapterOptions<HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined> = Omit<ioBroker.AdapterOptions, "objects" | "states"> & (true extends HasObjectsCache ? {
14 objects: true;
15} : {
16 objects?: HasObjectsCache;
17}) & (true extends HasStatesCache ? {
18 states: true;
19} : {
20 states?: HasStatesCache;
21});
22/** Selects the correct instance type depending on the constructor params */
23interface AdapterConstructor {
24 new <HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined>(adapterOptions: AdapterOptions<HasObjectsCache, HasStatesCache> | string): AdapterInstance<HasObjectsCache, HasStatesCache>;
25 <HasObjectsCache extends boolean | undefined = undefined, HasStatesCache extends boolean | undefined = undefined>(adapterOptions: AdapterOptions<HasObjectsCache, HasStatesCache> | string): AdapterInstance<HasObjectsCache, HasStatesCache>;
26}
27/** Creates a new adapter instance */
28export declare const adapter: AdapterConstructor;
29/** Creates a new adapter instance */
30export declare const Adapter: AdapterConstructor;
31export {};