diff --git a/README.md b/README.md index d0097b3..d00bf8c 100644 --- a/README.md +++ b/README.md @@ -87,6 +87,13 @@ The configuration here is enhanced by an "enabled" key and passed to the "init" One example is the Sentry plugin available at https://github.com/ioBroker/plugin-sentry ## Changelog +### 2.0.0 (2024-03-13) +**Breaking Changes:** +* (foxriver76) Methods no longer work with callback, please check the methods according to the types. +* (foxriver76) All methods with `async` postfix are now working renamed to methods without the postfix +while the callback methods have been removed +* (foxriver76) Renamed `instanciatePlugin` to `instantiatePlugin` +* (foxriver76) renamed `isPluginInstanciated` to `isPluginInstantiated` ### 1.2.1 (2021-01-24) * (Apollon77) Add error handling in some places when setting active Status diff --git a/lib/PluginBase.d.ts b/lib/PluginBase.d.ts index 3a18047..0978575 100644 --- a/lib/PluginBase.d.ts +++ b/lib/PluginBase.d.ts @@ -14,7 +14,7 @@ declare class PluginBase { pluginScope: "adapter" | "controller"; parentNamespace: string; pluginNamespace: string; - log: import("./NamespaceLogger"); + log: NamespaceLogger; iobrokerConfig: Record; parentPackage: Record; settings: import("@iobroker/plugin-base/types").PluginSettings; @@ -29,37 +29,22 @@ declare class PluginBase { * Method for Plugin developer to initialize his Plugin * * @param {Record} pluginConfig plugin configuration from config files - * @param {import("@iobroker/plugin-base/types").InitCallback} callback Will be called when done. On err or `initSuccessful === false` the plugin instance will be discarded. + * @return {Promise} resolves if init was successful else rejects */ - init(pluginConfig: Record, callback: import("@iobroker/plugin-base/types").InitCallback): void; + init(pluginConfig: Record): Promise; /** * Method which is called on a clean end of the process to pot. clean up used resources * * @return {boolean} The return value indicates if the exit was successful. If no action needs to be taken, you should return true. */ destroy(): boolean; - /** - * Get a State from State DB - * - * @param {string} id id of the state to retrieve - * @param {ioBroker.GetStateCallback} callback Will be called with the result - */ - getState(id: string, callback: ioBroker.GetStateCallback): void; /** * Get a State from State DB * * @param {string} id id of the state to retrieve * @return {ReturnType} Promise with error or result */ - getStateAsync(id: string): Promise; - /** - * Set a State in State DB - * - * @param {string} id id of the state to set - * @param {Partial} state state value to set - * @param {ioBroker.SetStateCallback} [callback] Will be called with the result - */ - setState(id: string, state: Partial, callback?: ioBroker.SetStateCallback): void; + getState(id: string): ReturnType; /** * Set a State in State DB * @@ -67,29 +52,14 @@ declare class PluginBase { * @param {Partial} state state value to set * @return {Promise} Promise with error or result */ - setStateAsync(id: string, state: Partial): Promise; - /** - * Get an Object from Objects DB - * - * @param {string} id id of the object to retrieve - * @param {ioBroker.GetObjectCallback} callback Will be called with the result - */ - getObject(id: string, callback: ioBroker.GetObjectCallback): void; + setState(id: string, state: Partial): Promise; /** * Get an Object from Objects DB * * @param {string} id id of the object to retrieve * @return {Promise} Promise with result or error */ - getObjectAsync(id: string): Promise; - /** - * Set an Object in Objects DB - * - * @param {string} id id of the object to set - * @param {ioBroker.Object} obj object to set - * @param {ioBroker.SetObjectCallback} [callback] Will be called with the result - */ - setObject(id: string, obj: ioBroker.Object, callback?: ioBroker.SetObjectCallback): void; + getObject(id: string): Promise; /** * Set an Object in Objects DB * @@ -97,17 +67,7 @@ declare class PluginBase { * @param {ioBroker.Object} obj object to set * @return {ReturnType} Promise with error or result */ - setObjectAsync(id: string, obj: ioBroker.Object): Promise<{ - id: string; - }>; - /** - * Set/Extend an Object in Objects DB - * - * @param {string} id id of the object to set/extend - * @param {ioBroker.Object} obj object to set - * @param {ioBroker.ExtendObjectCallback} [callback] Will be called with the result - */ - extendObject(id: string, obj: ioBroker.Object, callback?: ioBroker.ExtendObjectCallback): void; + setObject(id: string, obj: ioBroker.Object): ReturnType; /** * Set/Extend an Object in Objects DB * @@ -115,9 +75,7 @@ declare class PluginBase { * @param {object} obj object to set * @return {ReturnType} Promise with result or error */ - extendObjectAsync(id: string, obj: any): Promise<{ - id: string; - }>; + extendObject(id: string, obj: object): ReturnType; /**************************************** * Internal methods!! ****************************************/ @@ -143,15 +101,14 @@ declare class PluginBase { * * @param {Record} pluginConfig plugin configuration from config files * @param {Record} parentConfig io-package from parent module where plugin is used in - * @param {import("@iobroker/plugin-base/types").InitCallback} callback Will be called when done. On err or `initSuccessful === false` the plugin instance will be discarded. */ - initPlugin(pluginConfig: Record, parentConfig: Record, callback: import("@iobroker/plugin-base/types").InitCallback): Promise; + initPlugin(pluginConfig: Record, parentConfig: Record): Promise; parentIoPackage: Record; /** * @internal * @param {Record} pluginConfig * @param {string | boolean} activate - * @param {import("@iobroker/plugin-base/types").InitCallback} callback */ - _initialize(pluginConfig: Record, activate: string | boolean, callback: import("@iobroker/plugin-base/types").InitCallback): Promise; + _initialize(pluginConfig: Record, activate: string | boolean): Promise; } +import NamespaceLogger = require("./NamespaceLogger"); diff --git a/lib/PluginBase.js b/lib/PluginBase.js index 58cdb81..851d1f6 100644 --- a/lib/PluginBase.js +++ b/lib/PluginBase.js @@ -36,11 +36,11 @@ class PluginBase { * Method for Plugin developer to initialize his Plugin * * @param {Record} pluginConfig plugin configuration from config files - * @param {import("@iobroker/plugin-base/types").InitCallback} callback Will be called when done. On err or `initSuccessful === false` the plugin instance will be discarded. + * @return {Promise} resolves if init was successful else rejects */ - init(pluginConfig, callback) { + init(pluginConfig) { // Implement in your Plugin instance if needed - callback(new Error('Not implemented')); + return Promise.reject(new Error('Not implemented')); } /** @@ -53,46 +53,19 @@ class PluginBase { return true; } - /** - * Get a State from State DB - * - * @param {string} id id of the state to retrieve - * @param {ioBroker.GetStateCallback} callback Will be called with the result - */ - getState(id, callback) { - if (!this.statesDb) { - throw new Error('States Database not initialized.'); - } - this.statesDb.getState(id, callback); - } - /** * Get a State from State DB * * @param {string} id id of the state to retrieve * @return {ReturnType} Promise with error or result */ - getStateAsync(id) { + getState(id) { if (!this.statesDb) { return Promise.reject(new Error('States Database not initialized.')); } return this.statesDb.getStateAsync(id); } - /** - * Set a State in State DB - * - * @param {string} id id of the state to set - * @param {Partial} state state value to set - * @param {ioBroker.SetStateCallback} [callback] Will be called with the result - */ - setState(id, state, callback) { - if (!this.statesDb) { - throw new Error('States Database not initialized.'); - } - this.statesDb.setState(id, state, callback); - } - /** * Set a State in State DB * @@ -100,53 +73,26 @@ class PluginBase { * @param {Partial} state state value to set * @return {Promise} Promise with error or result */ - setStateAsync(id, state) { + setState(id, state) { if (!this.statesDb) { return Promise.reject(new Error('States Database not initialized.')); } return this.statesDb.setStateAsync(id, state); } - /** - * Get an Object from Objects DB - * - * @param {string} id id of the object to retrieve - * @param {ioBroker.GetObjectCallback} callback Will be called with the result - */ - getObject(id, callback) { - if (!this.objectsDb) { - throw new Error('Objects Database not initialized.'); - } - this.objectsDb.getObject(id, callback); - } - /** * Get an Object from Objects DB * * @param {string} id id of the object to retrieve * @return {Promise} Promise with result or error */ - getObjectAsync(id) { + getObject(id) { if (!this.objectsDb) { return Promise.reject(new Error('Objects Database not initialized.')); } return this.objectsDb.getObjectAsync(id); } - /** - * Set an Object in Objects DB - * - * @param {string} id id of the object to set - * @param {ioBroker.Object} obj object to set - * @param {ioBroker.SetObjectCallback} [callback] Will be called with the result - */ - setObject(id, obj, callback) { - if (!this.objectsDb) { - throw new Error('Objects Database not initialized.'); - } - this.objectsDb.setObject(id, obj, callback); - } - /** * Set an Object in Objects DB * @@ -154,27 +100,13 @@ class PluginBase { * @param {ioBroker.Object} obj object to set * @return {ReturnType} Promise with error or result */ - setObjectAsync(id, obj) { + setObject(id, obj) { if (!this.objectsDb) { return Promise.reject(new Error('Objects Database not initialized.')); } return this.objectsDb.setObjectAsync(id, obj); } - /** - * Set/Extend an Object in Objects DB - * - * @param {string} id id of the object to set/extend - * @param {ioBroker.Object} obj object to set - * @param {ioBroker.ExtendObjectCallback} [callback] Will be called with the result - */ - extendObject(id, obj, callback) { - if (!this.objectsDb) { - throw new Error('Objects Database not initialized.'); - } - this.objectsDb.extendObject(id, obj, callback); - } - /** * Set/Extend an Object in Objects DB * @@ -182,7 +114,7 @@ class PluginBase { * @param {object} obj object to set * @return {ReturnType} Promise with result or error */ - extendObjectAsync(id, obj) { + extendObject(id, obj) { if (!this.objectsDb) { return Promise.reject(new Error('Objects Database not initialized.')); } @@ -201,7 +133,7 @@ class PluginBase { */ async setActive(active) { this.isActive = !!active; - await this.setStateAsync(this.pluginNamespace + '.enabled', { + await this.setState(this.pluginNamespace + '.enabled', { val: !!active, ack: true, from: this.pluginNamespace @@ -227,24 +159,23 @@ class PluginBase { * * @param {Record} pluginConfig plugin configuration from config files * @param {Record} parentConfig io-package from parent module where plugin is used in - * @param {import("@iobroker/plugin-base/types").InitCallback} callback Will be called when done. On err or `initSuccessful === false` the plugin instance will be discarded. */ - async initPlugin(pluginConfig, parentConfig, callback) { + async initPlugin(pluginConfig, parentConfig) { if (!pluginConfig) { - return void callback(new Error('No configuration for plugin')); + throw new Error('No configuration for plugin'); } this.parentIoPackage = parentConfig; let pluginEnabledState; try { - await this.extendObjectAsync(this.pluginNamespace, { + await this.extendObject(this.pluginNamespace, { type: 'folder', common: { name: 'Plugin States', }, native: {} }); - await this.extendObjectAsync(this.pluginNamespace + '.enabled', { + await this.extendObject(`${this.pluginNamespace}.enabled`, { type: 'state', common: { name: 'Plugin - enabled', @@ -256,13 +187,13 @@ class PluginBase { native: {} }); - pluginEnabledState = await this.getStateAsync(this.pluginNamespace + '.enabled'); + pluginEnabledState = await this.getState(`${this.pluginNamespace}.enabled`); } catch { // ignore } if (pluginEnabledState && typeof pluginEnabledState.val !== 'object' && pluginEnabledState.val !== undefined) { // We already have a enabled flag state, use it - return this._initialize(pluginConfig, !!pluginEnabledState.val, callback); + return this._initialize(pluginConfig, !!pluginEnabledState.val); } // We have first start and no enabled flag is set @@ -272,51 +203,37 @@ class PluginBase { let hostState; try { - hostState = await this.getStateAsync(hostNamespace + '.enabled'); + hostState = await this.getState(`${hostNamespace}.enabled`); } catch { // ignore } if (hostState && typeof hostState.val !== 'object' && hostState.val !== undefined) { // We simply use the host enabled flag state - return this._initialize(pluginConfig, !!hostState.val, callback); + return this._initialize(pluginConfig, !!hostState.val); } } - this._initialize(pluginConfig, pluginConfig.enabled === undefined ? true : !!pluginConfig.enabled, callback); + this._initialize(pluginConfig, pluginConfig.enabled === undefined ? true : !!pluginConfig.enabled); } /** * @internal * @param {Record} pluginConfig * @param {string | boolean} activate - * @param {import("@iobroker/plugin-base/types").InitCallback} callback */ - async _initialize(pluginConfig, activate, callback) { + async _initialize(pluginConfig, activate) { if (activate) { - this.log.debug('Initialize Plugin (enabled=' + activate + ')'); + this.log.debug(`Initialize Plugin (enabled=${activate})`); pluginConfig.enabled = activate; - this.init(pluginConfig, async (err, success) => { - try { - if (!err && success) { - await this.setActive(true); - } else { - await this.setActive(false); - } - } catch (ex) { - if (!err) { - err = ex - } - } - callback(err, success); - }); - } else { - this.log.debug('Do not initialize Plugin (enabled=' + activate + ')'); try { + await this.init(pluginConfig); + await this.setActive(true); + } catch (e) { await this.setActive(false); - } catch (ex) { - return callback(ex, false); } - callback(null, false); + } else { + this.log.debug(`Do not initialize Plugin (enabled=${activate})`); + await this.setActive(false); } } } diff --git a/lib/PluginHandler.d.ts b/lib/PluginHandler.d.ts index 3b28783..779aeab 100644 --- a/lib/PluginHandler.d.ts +++ b/lib/PluginHandler.d.ts @@ -11,7 +11,7 @@ declare class PluginHandler { */ constructor(settings: import("@iobroker/plugin-base/types").PluginHandlerSettings); settings: import("@iobroker/plugin-base/types").PluginHandlerSettings; - log: import("./NamespaceLogger"); + log: NamespaceLogger; /** @type {Record, instance?: import("./PluginBase") | null}>} */ plugins: Record; @@ -25,13 +25,13 @@ declare class PluginHandler { */ addPlugins(configs: Record, resolveDirs: string | string[]): void; /** - * Resole, Require and Instanciate Plugins + * Resole, Require and instantiate Plugins * * @param {string} name name of the plugin * @param {Record} config plugin configuration - * @param {string | string[]} resolveDirs Resolve directories + * @param {string | string[]} resolveDirsOrDir Resolve directories */ - instanciatePlugin(name: string, config: Record, resolveDirs: string | string[]): void; + instantiatePlugin(name: string, config: Record, resolveDirsOrDir: string | string[]): void; /** * Set Objects and States databases for all isActive plugins * @@ -52,16 +52,14 @@ declare class PluginHandler { * * @param {string} name name of the plugin * @param {Record} parentConfig io-package of the parent module that uses the plugins (adapter/controller) - * @param {(error?: string) => void} [callback] callback function which is called after initialization is done for all plugins */ - initPlugin(name: string, parentConfig: Record, callback?: (error?: string) => void): void; + initPlugin(name: string, parentConfig: Record): Promise; /** * Initialize all Plugins that are registered * * @param {Record} parentConfig io-package of the parent module that uses the plugins (adapter/controller) - * @param {(error?: string) => void} callback callback function which is called after initialization is done for all plugins */ - initPlugins(parentConfig: Record, callback: (error?: string) => void): void; + initPlugins(parentConfig: Record): Promise; /** * Destroy one plugin instance * @@ -79,14 +77,14 @@ declare class PluginHandler { * @param {string} name name of the plugin to return * @returns {import("./PluginBase") | null} plugin instance or null if not existent or not isActive */ - getPluginInstance(name: string): import("./PluginBase"); + getPluginInstance(name: string): import("./PluginBase") | null; /** * Return plugin configuration * * @param {string} name name of the plugin to return * @returns {Record | null} plugin configuration or null if not existent or not isActive */ - getPluginConfig(name: string): Record; + getPluginConfig(name: string): Record | null; /** * Return if plugin exists * @@ -100,7 +98,7 @@ declare class PluginHandler { * @param {string} name name of the plugin to check * @returns {boolean} true/false if plugin is successfully isActive */ - isPluginInstanciated(name: string): boolean; + isPluginInstantiated(name: string): boolean; /** * Return if plugin is active * @@ -109,3 +107,4 @@ declare class PluginHandler { */ isPluginActive(name: string): boolean; } +import NamespaceLogger = require("./NamespaceLogger"); diff --git a/lib/PluginHandler.js b/lib/PluginHandler.js index 2de7940..e8bc125 100644 --- a/lib/PluginHandler.js +++ b/lib/PluginHandler.js @@ -27,32 +27,30 @@ class PluginHandler { addPlugins(configs, resolveDirs) { if (!configs) return; Object.keys(configs).forEach(plugin => { - this.instanciatePlugin(plugin, configs[plugin], resolveDirs); + this.instantiatePlugin(plugin, configs[plugin], resolveDirs); }); } /** - * Resole, Require and Instanciate Plugins + * Resole, Require and instantiate Plugins * * @param {string} name name of the plugin * @param {Record} config plugin configuration - * @param {string | string[]} resolveDirs Resolve directories + * @param {string | string[]} resolveDirsOrDir Resolve directories */ - instanciatePlugin(name, config, resolveDirs) { + instantiatePlugin(name, config, resolveDirsOrDir) { if (this.plugins[name] && this.plugins[name].instance) { - this.log.info('Ignore duplicate plugin ' + name); + this.log.info(`Ignore duplicate plugin ${name}`); return; } - if (resolveDirs && !Array.isArray(resolveDirs)) { - resolveDirs = [resolveDirs]; - } + const resolveDirs = typeof resolveDirsOrDir === 'string' ? [resolveDirsOrDir] : resolveDirsOrDir; - const pluginPath = require.resolve('@iobroker/plugin-' + name, { + const pluginPath = require.resolve(`@iobroker/plugin-${name}`, { paths: resolveDirs }); if (!pluginPath) { - this.log.info('Plugin ' + name + ' could not be resolved'); + this.log.info(`Plugin ${name} could not be resolved`); return; } @@ -60,8 +58,8 @@ class PluginHandler { let ResolvedPlugin; try { ResolvedPlugin = require(pluginPath); - } catch (err) { - this.log.info('Plugin ' + name + ' could not be required: ' + err); + } catch (e) { + this.log.info(`Plugin ${name} could not be required: ${e.message}`); return; } @@ -82,8 +80,8 @@ class PluginHandler { try { this.plugins[name].instance = new ResolvedPlugin(pluginSettings); - } catch (err) { - this.log.info('Plugin ' + name + ' could not be initialized: ' + err); + } catch (e) { + this.log.info(`Plugin ${name} could not be initialized: ${e.message}`); this.plugins[name].instance = null; } } @@ -115,39 +113,33 @@ class PluginHandler { * * @param {string} name name of the plugin * @param {Record} parentConfig io-package of the parent module that uses the plugins (adapter/controller) - * @param {(error?: string) => void} [callback] callback function which is called after initialization is done for all plugins */ - initPlugin(name, parentConfig, callback) { + async initPlugin(name, parentConfig) { const instance = this.plugins[name].instance; if (!instance) { - typeof callback === 'function' && callback(new Error('Please instanciate plugin first!')); - return; + throw new Error('Please instantiate plugin first!'); } - instance.initPlugin(this.plugins[name].config, parentConfig, (err, initSuccessful) => { - if (err || !initSuccessful) { - this.log.debug('Plugin ' + name + ' destroyed because not initialized correctly'); - instance.destroy(); - delete this.plugins[name].instance; - } - typeof callback === 'function' && callback(); - }) + try { + await instance.initPlugin(this.plugins[name].config, parentConfig) + } catch (e) { + this.log.debug(`Plugin ${name} destroyed because not initialized correctly`); + + instance.destroy(); + delete this.plugins[name].instance; + } } /** * Initialize all Plugins that are registered * * @param {Record} parentConfig io-package of the parent module that uses the plugins (adapter/controller) - * @param {(error?: string) => void} callback callback function which is called after initialization is done for all plugins */ - initPlugins(parentConfig, callback) { - let callbackCnt = 0; - Object.keys(this.plugins).forEach(plugin => { - if (!this.plugins[plugin].instance) return; - callbackCnt++; - this.initPlugin(plugin, parentConfig, () => !--callbackCnt && typeof callback === 'function' && callback()); - }); - callbackCnt === 0 && typeof callback === 'function' && callback(); + async initPlugins(parentConfig) { + for (const [pluginName, plugin] of Object.entries(this.plugins)) { + if (!plugin.instance) return; + await this.initPlugin(pluginName, parentConfig); + } } /** @@ -225,7 +217,7 @@ class PluginHandler { * @param {string} name name of the plugin to check * @returns {boolean} true/false if plugin is successfully isActive */ - isPluginInstanciated(name) { + isPluginInstantiated(name) { return !!(this.plugins[name] && this.plugins[name].instance); } diff --git a/lib/types.d.ts b/lib/types.d.ts index 77f8bad..abea20e 100644 --- a/lib/types.d.ts +++ b/lib/types.d.ts @@ -35,9 +35,4 @@ declare module "@iobroker/plugin-base/types" { /** The version of the installed JS-Controller */ controllerVersion: string; } - - export type InitCallback = ( - err: Error | null | undefined, - initSuccessful?: boolean - ) => void; } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d465e9e..3f3cc1a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "devDependencies": { "@alcalzone/release-script": "^2.2.2", - "@types/iobroker": "^4.0.5", + "@iobroker/types": "^5.0.19", "@types/node": "^18.15.7", "eslint": "^8.36.0", "eslint-config-prettier": "^8.8.0", @@ -129,6 +129,15 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "node_modules/@iobroker/types": { + "version": "5.0.19", + "resolved": "https://registry.npmjs.org/@iobroker/types/-/types-5.0.19.tgz", + "integrity": "sha512-FY+lpPbYVlX/WHzEGVIXZrM6XQXI+GtWb3E/ZR2ZKdSBK4/w7VezUQuqxq1lYW914LxjcynXxYtLxHva/nal6g==", + "dev": true, + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -164,15 +173,6 @@ "node": ">= 8" } }, - "node_modules/@types/iobroker": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/iobroker/-/iobroker-4.0.5.tgz", - "integrity": "sha512-D1tJwuDQEQQQ/cZVFjFjFUhUuMxJbfrz5U2UooiZwhgs69D/t8IowMvBI6Lk4ZR8HnCSxYwWHVRKyQnEMNgJPA==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/node": { "version": "18.15.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.7.tgz", @@ -1666,6 +1666,12 @@ "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", "dev": true }, + "@iobroker/types": { + "version": "5.0.19", + "resolved": "https://registry.npmjs.org/@iobroker/types/-/types-5.0.19.tgz", + "integrity": "sha512-FY+lpPbYVlX/WHzEGVIXZrM6XQXI+GtWb3E/ZR2ZKdSBK4/w7VezUQuqxq1lYW914LxjcynXxYtLxHva/nal6g==", + "dev": true + }, "@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -1692,15 +1698,6 @@ "fastq": "^1.6.0" } }, - "@types/iobroker": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/@types/iobroker/-/iobroker-4.0.5.tgz", - "integrity": "sha512-D1tJwuDQEQQQ/cZVFjFjFUhUuMxJbfrz5U2UooiZwhgs69D/t8IowMvBI6Lk4ZR8HnCSxYwWHVRKyQnEMNgJPA==", - "dev": true, - "requires": { - "@types/node": "*" - } - }, "@types/node": { "version": "18.15.7", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.7.tgz", diff --git a/package.json b/package.json index f85bfd6..35117a5 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,9 @@ "url": "https://github.com/ioBroker/plugin-base/issues" }, "homepage": "https://github.com/ioBroker/plugin-base#readme", - "dependencies": {}, "devDependencies": { "@alcalzone/release-script": "^2.2.2", - "@types/iobroker": "^4.0.5", + "@iobroker/types": "^5.0.19", "@types/node": "^18.15.7", "eslint": "^8.36.0", "eslint-config-prettier": "^8.8.0", diff --git a/tsconfig.json b/tsconfig.json index d9c5a12..337a1b9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -62,10 +62,17 @@ /* Experimental Options */ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - + "useUnknownInCatchVariables": false, /* Advanced Options */ "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */ - "newLine": "lf" + "newLine": "lf", + "typeRoots": [ + "node_modules/@types" + ], + "types": [ + "@iobroker/types", + "node" + ] }, "include": [ "./lib/*.js"