[iobroker] add object type "folder" (#43819)

This commit is contained in:
AlCalzone
2020-04-15 05:31:47 +02:00
committed by GitHub
parent 2594f92015
commit 075eb40cdd
2 changed files with 22 additions and 2 deletions

View File

@@ -183,6 +183,15 @@ declare global {
common?: Partial<DeviceCommon>;
}
interface FolderObject extends BaseObject {
type: 'folder';
// Nothing is set in stone here, so start with allowing every property
common: OtherCommon;
}
interface PartialFolderObject extends Partial<Pick<FolderObject, '_id' | 'native' | 'enums' | 'type' | 'acl'>> {
common?: Partial<OtherCommon>;
}
interface OtherObject extends BaseObject {
type: 'adapter' | 'config' | 'enum' | 'group' | 'host' | 'info' | 'instance' | 'meta' | 'script' | 'user';
common: OtherCommon;
@@ -191,7 +200,7 @@ declare global {
common?: Partial<ObjectCommon>;
}
type Object = StateObject | ChannelObject | DeviceObject | OtherObject;
type Object = StateObject | ChannelObject | DeviceObject | FolderObject | OtherObject;
type SettableObjectWorker<T extends ioBroker.Object> = Pick<T, Exclude<keyof T, '_id' | 'acl'>> & {
_id?: T['_id'];
@@ -200,7 +209,7 @@ declare global {
// In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional
type SettableObject = SettableObjectWorker<ioBroker.Object>;
type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialOtherObject;
type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialFolderObject | PartialOtherObject;
/** Defines access rights for a single file */
interface FileACL {

View File

@@ -386,6 +386,17 @@ function repro3() {
});
}
const folderObj: ioBroker.FolderObject = {
_id: "id",
type: "folder",
common: {
name: "something",
// any property is allowed
foo: "bar",
},
native: {},
};
// Repro from https://github.com/ioBroker/ioBroker.js-controller/issues/782
// $ExpectError
adapter.setState("id", {ack: false});