diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index 22db899b4e..23f5233bf2 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -332,7 +332,7 @@ declare global { /** Parameters for @link{Objects.getObjectList} */ interface GetObjectListParams extends GetObjectViewParams { /** Whether docs should be included in the return list */ // TODO: What are docs? - include_docs: boolean; + include_docs?: boolean; } type LogLevel = 'silly' | 'debug' | 'info' | 'warn' | 'error'; @@ -839,6 +839,30 @@ declare global { options?: unknown, ): Promise>; + /** + * Returns a list of objects with id between params.startkey and params.endkey + * @param params Parameters determining the objects included in the return list. Null to include all objects + * @param options If the returned list should be sorted. And some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + // TODO: options should be optional: https://github.com/ioBroker/ioBroker.js-controller/issues/574 + // getObjectList(params: GetObjectListParams | null, callback: GetObjectListCallback): void; + getObjectList( + params: GetObjectListParams | null, + options: { sorted?: boolean } | Record, + callback: GetObjectListCallback, + ): void; + /** + * Returns a list of objects with id between params.startkey and params.endkey + * @param params Parameters determining the objects included in the return list. Null to include all objects + * @param options If the returned list should be sorted. And some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getObjectListAsync( + params: GetObjectListParams | null, + options: { sorted?: boolean } | Record, + ): Promise>; + // ============================== // states diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 0c2a5eafe1..d3e0c477ee 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -198,6 +198,15 @@ adapter.getObjectViewAsync("system", "admin", {startkey: "foo", endkey: "bar"}). docs && docs.rows[0] && docs.rows[0].id.toLowerCase(); }); +// TODO: https://github.com/ioBroker/ioBroker.js-controller/issues/574 +// {} should be left out or undefined +adapter.getObjectList({startkey: "foo", endkey: "bar"}, {}, (err, result) => { + result && result.rows[0] && result.rows[0].id.toLowerCase(); +}); +adapter.getObjectListAsync({startkey: "foo", endkey: "bar"}, {}).then(result => { + result && result.rows[0] && result.rows[0].id.toLowerCase(); +}); + adapter.subscribeObjects("*"); adapter.subscribeStates("*"); adapter.subscribeForeignObjects("*");