Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bugfix]: Inform about different version #2897

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions packages/adapter/src/lib/adapter/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,14 @@
/**
* 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[],
Expand All @@ -194,7 +194,7 @@
params: ioBroker.GetObjectViewParams | null | undefined,
options?: unknown
): ioBroker.GetObjectViewPromise<ioBroker.InferGetObjectViewItemType<Design, Search>>;
/** 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<string, any>
Expand Down Expand Up @@ -288,7 +288,7 @@
delStateAsync(id: string, options?: unknown): Promise<void>;
/** Deletes a state from the states DB, but not the associated object */
delForeignStateAsync(id: string, options?: unknown): Promise<void>;
/** 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;
Expand Down Expand Up @@ -1605,7 +1605,7 @@
* ...
* }
* ```

Check warning on line 1608 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Expected JSDoc block to be aligned
* @param featureName the name of the feature to check
* @returns true/false if the feature is in the list of supported features
*/
Expand Down Expand Up @@ -5138,11 +5138,11 @@
): void;

/**
* @param deviceName

Check warning on line 5141 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "deviceName" description
* @param common

Check warning on line 5142 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "common" description
* @param _native

Check warning on line 5143 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "_native" description
* @param options

Check warning on line 5144 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "options" description
* @param callback

Check warning on line 5145 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "callback" description
* @deprecated use `this.extendObject` instead
*/
createDevice(deviceName: unknown, common: unknown, _native?: unknown, options?: unknown, callback?: unknown): any {
Expand Down Expand Up @@ -5233,10 +5233,10 @@
/**
* Name of channel must be in format "channel"
*
* @param parentDevice

Check warning on line 5236 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "parentDevice" description
* @param channelName

Check warning on line 5237 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "channelName" description
* @param roleOrCommon

Check warning on line 5238 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "roleOrCommon" description
* @param _native

Check warning on line 5239 in packages/adapter/src/lib/adapter/adapter.ts

View workflow job for this annotation

GitHub Actions / Eslint

Missing JSDoc @param "_native" description
* @param options
* @param callback
* @deprecated use `this.extendObject` instead
Expand Down Expand Up @@ -7220,7 +7220,7 @@
* 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
Expand All @@ -7229,7 +7229,7 @@
* 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') {
Expand Down Expand Up @@ -7263,12 +7263,12 @@

/**
* 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) => {
Expand Down Expand Up @@ -8586,7 +8586,7 @@
}

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,
Expand Down Expand Up @@ -8671,7 +8671,7 @@
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
Expand Down Expand Up @@ -8980,7 +8980,7 @@

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
Expand All @@ -8994,7 +8994,7 @@
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
Expand Down Expand Up @@ -11519,6 +11519,14 @@

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}".`
GermanBluefox marked this conversation as resolved.
Show resolved Hide resolved
);
}

this._utils = new Validator(
this.#objects,
this.#states,
Expand Down
10 changes: 5 additions & 5 deletions packages/types-dev/objects.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.<adaptername>.<adapterinstance>.messagebox will be created to send messages to the adapter (used for email, pushover, etc...)
*/
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
Loading