@iobroker/js-controller-adapter 7.0.4-alpha.1-20241120-1e3f92f91 → 7.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -124,9 +124,17 @@ export interface AdapterClass {
124
124
  checkGroupAsync(user: string, group: string, options?: unknown): Promise<boolean>;
125
125
  /** <INTERNAL> Determines the users permissions */
126
126
  calculatePermissionsAsync(user: string, commandsPermissions: CommandsPermissions, options?: unknown): Promise<ioBroker.PermissionSet>;
127
- /** Creates or overwrites an object in the object db */
127
+ /**
128
+ * Creates or overwrites an object in the object db
129
+ *
130
+ * @deprecated use `adapter.setObject` without a callback instead
131
+ */
128
132
  setObjectAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): ioBroker.SetObjectPromise;
129
- /** Creates or overwrites an object (which might not belong to this adapter) in the object db */
133
+ /**
134
+ * Creates or overwrites an object (which might not belong to this adapter) in the object db
135
+ *
136
+ * @deprecated use `adapter.setForeignObject` without a callback instead
137
+ */
130
138
  setForeignObjectAsync<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: unknown): ioBroker.SetObjectPromise;
131
139
  getCertificatesAsync(publicName?: string, privateName?: string, chainedName?: string): Promise<GetCertificatesPromiseReturnType>;
132
140
  /** Get all states, channels, devices and folders of this adapter */
@@ -483,9 +491,10 @@ export declare class AdapterClass extends EventEmitter {
483
491
  delay(timeout: number): Promise<void>;
484
492
  setInterval<TCallback extends TimeoutCallback>(cb: TCallback, timeout: number, ...args: Parameters<TCallback>): ioBroker.Interval | undefined;
485
493
  clearInterval(interval: ioBroker.Interval | undefined): void;
486
- setObject(id: string, obj: ioBroker.SettableObject, callback?: ioBroker.SetObjectCallback): Promise<void>;
487
- setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: ioBroker.SetObjectCallback): Promise<void>;
488
- setObject(id: string, obj: ioBroker.SettableObject, callback?: ioBroker.SetObjectCallback): Promise<void>;
494
+ setObject(id: string, obj: ioBroker.SettableObject): Promise<ioBroker.NonNullCallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
495
+ setObject(id: string, obj: ioBroker.SettableObject, callback: ioBroker.SetObjectCallback): void;
496
+ setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback: ioBroker.SetObjectCallback): void;
497
+ setObject(id: string, obj: ioBroker.SettableObject, options: unknown): Promise<ioBroker.NonNullCallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
489
498
  private _setObject;
490
499
  /**
491
500
  * Helper method for `set[Foreign]Object[NotExists]` that also sets the default value if one is configured
@@ -503,11 +512,15 @@ export declare class AdapterClass extends EventEmitter {
503
512
  extendObject(id: string, objPart: ioBroker.PartialObject, options: ioBroker.ExtendObjectOptions): ioBroker.SetObjectPromise;
504
513
  extendObject(id: string, objPart: ioBroker.PartialObject, options: ioBroker.ExtendObjectOptions, callback?: ioBroker.SetObjectCallback): void;
505
514
  private _extendObject;
506
- setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, callback?: ioBroker.SetObjectCallback): void;
507
- setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: unknown, callback?: ioBroker.SetObjectCallback): void;
515
+ setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>): Promise<ioBroker.NonNullCallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
516
+ setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, callback: ioBroker.SetObjectCallback): void;
517
+ setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: unknown): Promise<ioBroker.NonNullCallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
518
+ setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: unknown, callback?: ioBroker.SetObjectCallback): void | Promise<ioBroker.NonNullCallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
508
519
  private _setForeignObject;
509
- extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, callback?: ioBroker.SetObjectCallback): void;
510
- extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: ioBroker.ExtendObjectOptions, callback?: ioBroker.SetObjectCallback): void;
520
+ extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
521
+ extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, callback: ioBroker.SetObjectCallback): void;
522
+ extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: ioBroker.ExtendObjectOptions, callback: ioBroker.SetObjectCallback): void;
523
+ extendForeignObject<T extends string>(id: T, objPart: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options: ioBroker.ExtendObjectOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
511
524
  private _extendForeignObjectAsync;
512
525
  objectExists(id: string, options?: Record<string, any> | null): Promise<boolean | void>;
513
526
  foreignObjectExists(id: string, options?: Record<string, any> | null): Promise<boolean | void>;
@@ -1608,11 +1608,10 @@ class AdapterClass extends import_node_events.EventEmitter {
1608
1608
  options.obj.from = options.obj.from || `system.adapter.${this.namespace}`;
1609
1609
  options.obj.user = options.obj.user || (options.options ? options.options.user : "") || import_constants.SYSTEM_ADMIN_USER;
1610
1610
  options.obj.ts = options.obj.ts || Date.now();
1611
- this._setObjectWithDefaultValue(options.id, options.obj, options.options, options.callback);
1612
- } else {
1613
- this._logger.error(`${this.namespaceLog} setObject ${options.id} mandatory property type missing!`);
1614
- return import_js_controller_common.tools.maybeCallbackWithError(options.callback, "mandatory property type missing!");
1611
+ return this._setObjectWithDefaultValue(options.id, options.obj, options.options, options.callback);
1615
1612
  }
1613
+ this._logger.error(`${this.namespaceLog} setObject ${options.id} mandatory property type missing!`);
1614
+ return import_js_controller_common.tools.maybeCallbackWithError(options.callback, "mandatory property type missing!");
1616
1615
  }
1617
1616
  /**
1618
1617
  * Helper method for `set[Foreign]Object[NotExists]` that also sets the default value if one is configured
@@ -1971,7 +1970,7 @@ class AdapterClass extends import_node_events.EventEmitter {
1971
1970
  }
1972
1971
  }
1973
1972
  }
1974
- this._setObjectWithDefaultValue(id, obj, options, callback);
1973
+ return this._setObjectWithDefaultValue(id, obj, options, callback);
1975
1974
  }
1976
1975
  /**
1977
1976
  * Same as {@link AdapterClass.extendObject}, but for any object.
@@ -6091,7 +6090,7 @@ class AdapterClass extends import_node_events.EventEmitter {
6091
6090
  return import_js_controller_common.tools.maybeCallbackWithError(callback, e);
6092
6091
  }
6093
6092
  }
6094
- this.#states.delState(id, callback);
6093
+ await this.#states.delState(id, callback);
6095
6094
  }
6096
6095
  /**
6097
6096
  * Read all states of this adapter, that pass the pattern
@@ -6433,7 +6432,7 @@ class AdapterClass extends import_node_events.EventEmitter {
6433
6432
  }
6434
6433
  subs[pattern][this.namespace]++;
6435
6434
  this.outputCount++;
6436
- this.#states.setState(`system.adapter.${autoSubEntry}.subscribes`, JSON.stringify(subs));
6435
+ await this.#states.setState(`system.adapter.${autoSubEntry}.subscribes`, JSON.stringify(subs));
6437
6436
  }
6438
6437
  }
6439
6438
  if (Array.isArray(pattern)) {
@@ -6597,7 +6596,7 @@ class AdapterClass extends import_node_events.EventEmitter {
6597
6596
  delete subs[pattern];
6598
6597
  }
6599
6598
  this.outputCount++;
6600
- this.#states.setState(`system.adapter.${autoSub}.subscribes`, JSON.stringify(subs));
6599
+ await this.#states.setState(`system.adapter.${autoSub}.subscribes`, JSON.stringify(subs));
6601
6600
  }
6602
6601
  }
6603
6602
  }