From fc55301632554679bf16c9881d03c2bec2fd460c Mon Sep 17 00:00:00 2001 From: GermanBluefox Date: Fri, 6 Sep 2024 15:10:04 +0800 Subject: [PATCH 1/2] Inform about diff version --- packages/adapter/src/lib/adapter/adapter.ts | 32 +++++++++++++-------- packages/types-dev/objects.d.ts | 10 +++---- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/packages/adapter/src/lib/adapter/adapter.ts b/packages/adapter/src/lib/adapter/adapter.ts index 538ec3544..57643c6f5 100644 --- a/packages/adapter/src/lib/adapter/adapter.ts +++ b/packages/adapter/src/lib/adapter/adapter.ts @@ -160,14 +160,14 @@ export interface AdapterClass { /** * Extend an object and create it if it might not exist * - * @deprecated use `adapter.extendObject` without callback instead + * @deprecated use `adapter.extendObject` without a callback instead */ extendObjectAsync( id: string, objPart: ioBroker.PartialObject, options?: ioBroker.ExtendObjectOptions ): ioBroker.SetObjectPromise; - /** Set capabilities of the given executable. Only works on Linux systems. */ + /** Set the capabilities of the given executable. Only works on Linux systems. */ setExecutableCapabilities( execPath: string, capabilities: string[], @@ -194,7 +194,7 @@ export interface AdapterClass { params: ioBroker.GetObjectViewParams | null | undefined, options?: unknown ): ioBroker.GetObjectViewPromise>; - /** Returns a list of objects with id between params.startkey and params.endkey */ + /** Returns a list of objects with id between `params.startkey` and `params.endkey` */ getObjectListAsync( params: ioBroker.GetObjectListParams | null, options?: { sorted?: boolean } | Record @@ -288,7 +288,7 @@ export interface AdapterClass { delStateAsync(id: string, options?: unknown): Promise; /** Deletes a state from the states DB, but not the associated object */ delForeignStateAsync(id: string, options?: unknown): Promise; - /** Read all states of this adapter which match the given pattern */ + /** Read all states of this adapter that match the given pattern */ getStatesAsync(pattern: string, options?: unknown): ioBroker.GetStatesPromise; /** Read all states (which might not belong to this adapter) which match the given pattern */ getForeignStatesAsync(pattern: Pattern, options?: unknown): ioBroker.GetStatesPromise; @@ -7220,7 +7220,7 @@ export class AdapterClass extends EventEmitter { * If no instance given (e.g. "pushover"), the callback argument will be ignored. Because normally many responses will come. * * @param instanceName name of the instance where the message must be sent to. E.g. "pushover.0" or "system.adapter.pushover.0". - * @param command command name, like "send", "browse", "list". Command is depend on target adapter implementation. + * @param command command name, like "send", "browse", "list". Command is depending on target adapter implementation. * @param message object that will be given as argument for request * @param callback optional return result * ```js @@ -7229,7 +7229,7 @@ export class AdapterClass extends EventEmitter { * if (!result) adapter.log.error('No response received'); * } * ``` - * @param options optional options to define a timeout. This allows to get an error callback if no answer received in time (only if target is specific instance) + * @param options optional options to define a timeout. This allows getting an error callback if no answer received in time (only if target is specific instance) */ sendTo(instanceName: unknown, command: unknown, message: unknown, callback?: unknown, options?: unknown): any { if (typeof message === 'function' && typeof callback === 'undefined') { @@ -7263,12 +7263,12 @@ export class AdapterClass extends EventEmitter { /** * Async version of sendTo - * As we have a special case (first arg can be error or result, we need to promisify manually) + * As we have a special case (first arg can be an error or result, we need to promisify manually) * * @param instanceName name of the instance where the message must be sent to. E.g. "pushover.0" or "system.adapter.pushover.0". * @param command command name, like "send", "browse", "list". Command is depend on target adapter implementation. * @param message object that will be given as argument for request - * @param options optional options to define a timeout. This allows to get an error callback if no answer received in time (only if target is specific instance) + * @param options optional options to define a timeout. This allows getting an error callback if no answer received in time (only if target is specific instance) */ sendToAsync(instanceName: unknown, command: unknown, message?: unknown, options?: unknown): any { return new Promise((resolve, reject) => { @@ -8586,7 +8586,7 @@ export class AdapterClass extends EventEmitter { } let targetObj; - // we ignore permissions on the target object and thus get it as admin user + // we ignore permissions on the target object and thus get it as an admin user try { targetObj = await this.#objects.getObject(aliasId, { ...options, @@ -8671,7 +8671,7 @@ export class AdapterClass extends EventEmitter { return tools.maybeCallbackWithError(callback, tools.ERRORS.ERROR_DB_CLOSED); } - // read object for formatting - we ignore permissions on the target object and thus get it as admin user + // read an object for formatting - we ignore permissions on the target object and thus get it as an admin user const targetObj = await this.#objects.getObject(targetId, { ...options, user: SYSTEM_ADMIN_USER @@ -8980,7 +8980,7 @@ export class AdapterClass extends EventEmitter { if (id.startsWith(ALIAS_STARTS_WITH)) { if (obj?.common?.alias?.id) { - // id can be string or can have attribute id.read + // id can be a string or can have attribute id.read const aliasId = tools.isObject(obj.common.alias.id) ? obj.common.alias.id.read : obj.common.alias.id; // validate here because we use objects/states db directly @@ -8994,7 +8994,7 @@ export class AdapterClass extends EventEmitter { if (aliasId) { let sourceObj; try { - // we ignore permissions on the source object and thus get it as admin user + // we ignore permissions on the source object and thus get it as an admin user sourceObj = (await this.#objects.getObject(aliasId, { ...options, user: SYSTEM_ADMIN_USER @@ -11519,6 +11519,14 @@ export class AdapterClass extends EventEmitter { this.adapterConfig = adapterConfig; + // Check that version in DB is the same as on disk + if ((adapterConfig as ioBroker.InstanceObject).common.version !== packJson.version) { + // TODO: think about to make upload automatically if a version on disk is newer than in DB. Now it is just hint in the log. + this._logger.warn( + `${this.namespaceLog} Version in DB is ${(adapterConfig as ioBroker.InstanceObject).common.version}, but this version is ${packJson.version}. Please synchronise the adapter with "iob upload ${(adapterConfig as ioBroker.InstanceObject).common.name}".` + ); + } + this._utils = new Validator( this.#objects, this.#states, diff --git a/packages/types-dev/objects.d.ts b/packages/types-dev/objects.d.ts index d1676de50..da47a431e 100644 --- a/packages/types-dev/objects.d.ts +++ b/packages/types-dev/objects.d.ts @@ -486,7 +486,7 @@ declare global { }; /** - * Object which defines, if the adapter supports receiving messages via sendTo. + * Object which defines if the adapter supports receiving messages via sendTo. * Additionally, it defines if specific messages are supported. * If one property is enabled, the object `system.adapter...messagebox will be created to send messages to the adapter (used for email, pushover, etc...) */ @@ -522,8 +522,8 @@ declare global { /** Use 'paid' for adapters which do not work without a paid license. Use 'commercial' for adapters which require a license for commercial use only. Use 'limited' if some functionalities are not available without a paid license. */ type: 'free'; /** - * Hyperlink, where information about the license can be found. For non-free licenses the linked page should contain information about free features (if applicable), time of validity, link to shop and seller information. - * This is required if the license type is different from 'free'. For 'free' licenses an optional link to the license file can be placed here. + * Hyperlink, where information about the license can be found. For non-free licenses, the linked page should contain information about free features (if applicable), time of validity, link to shop and seller information. + * This is required if the license type is different from 'free'. For 'free' licenses, an optional link to the license file can be placed here. */ link?: string; } @@ -534,8 +534,8 @@ declare global { /** Use 'paid' for adapters which do not work without a paid license. Use 'commercial' for adapters which require a license for commercial use only. Use 'limited' if some functionalities are not available without a paid license. */ type: PaidLicenseType; /** - * Hyperlink, where information about the license can be found. For non-free licenses the linked page should contain information about free features (if applicable), time of validity, link to shop and seller information. - * This is required if the license type is different from 'free'. For 'free' licenses an optional link to the license file can be placed here. + * Hyperlink, where information about the license can be found. For non-free licenses, the linked page should contain information about free features (if applicable), time of validity, link to shop and seller information. + * This is required if the license type is different from 'free'. For 'free' licenses, an optional link to the license file can be placed here. */ link: string; } From 0e8aa7bbbab0eb9e0ad457d2ea3d8c97b2fa52fc Mon Sep 17 00:00:00 2001 From: Bluefox Date: Fri, 6 Sep 2024 22:39:06 +0800 Subject: [PATCH 2/2] Update packages/adapter/src/lib/adapter/adapter.ts Co-authored-by: Ingo Fischer --- packages/adapter/src/lib/adapter/adapter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/adapter/src/lib/adapter/adapter.ts b/packages/adapter/src/lib/adapter/adapter.ts index 57643c6f5..9cf397f60 100644 --- a/packages/adapter/src/lib/adapter/adapter.ts +++ b/packages/adapter/src/lib/adapter/adapter.ts @@ -11523,7 +11523,7 @@ export class AdapterClass extends EventEmitter { if ((adapterConfig as ioBroker.InstanceObject).common.version !== packJson.version) { // TODO: think about to make upload automatically if a version on disk is newer than in DB. Now it is just hint in the log. this._logger.warn( - `${this.namespaceLog} Version in DB is ${(adapterConfig as ioBroker.InstanceObject).common.version}, but this version is ${packJson.version}. Please synchronise the adapter with "iob upload ${(adapterConfig as ioBroker.InstanceObject).common.name}".` + `${this.namespaceLog} Version in DB is ${(adapterConfig as ioBroker.InstanceObject).common.version}, but installed version is ${packJson.version}. Please synchronise the adapter with "iob upload ${(adapterConfig as ioBroker.InstanceObject).common.name}".` ); }