mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-13 05:20:25 +00:00
[iobroker] fix up some type definitions (#43832)
This commit is contained in:
Vendored
+25
-20
@@ -144,10 +144,16 @@ declare global {
|
||||
/** The ID of this object */
|
||||
_id: string;
|
||||
native: Record<string, any>;
|
||||
/** An array of `native` properties which cannot be accessed from outside the defining adapter */
|
||||
protectedNative?: string[];
|
||||
/** Like protectedNative, but the properties are also encrypted and decrypted automatically */
|
||||
encryptedNative?: string[];
|
||||
enums?: Record<string, string>;
|
||||
type: string; // specified in the derived interfaces
|
||||
common: StateCommon | ChannelCommon | DeviceCommon | OtherCommon;
|
||||
acl?: ObjectACL;
|
||||
from?: string;
|
||||
ts?: number;
|
||||
}
|
||||
|
||||
interface StateObject extends BaseObject {
|
||||
@@ -155,7 +161,7 @@ declare global {
|
||||
common: StateCommon;
|
||||
acl?: StateACL;
|
||||
}
|
||||
interface PartialStateObject extends Partial<Pick<StateObject, '_id' | 'native' | 'enums' | 'type'>> {
|
||||
interface PartialStateObject extends Partial<Omit<StateObject, 'common' | 'acl'>> {
|
||||
common?: Partial<StateCommon>;
|
||||
acl?: Partial<StateACL>;
|
||||
}
|
||||
@@ -165,7 +171,7 @@ declare global {
|
||||
common: ChannelCommon;
|
||||
}
|
||||
interface PartialChannelObject
|
||||
extends Partial<Pick<ChannelObject, '_id' | 'native' | 'enums' | 'type' | 'acl'>> {
|
||||
extends Partial<Omit<ChannelObject, 'common'>> {
|
||||
common?: Partial<ChannelCommon>;
|
||||
}
|
||||
|
||||
@@ -173,7 +179,7 @@ declare global {
|
||||
type: 'device';
|
||||
common: DeviceCommon;
|
||||
}
|
||||
interface PartialDeviceObject extends Partial<Pick<DeviceObject, '_id' | 'native' | 'enums' | 'type' | 'acl'>> {
|
||||
interface PartialDeviceObject extends Partial<Omit<DeviceObject, 'common'>> {
|
||||
common?: Partial<DeviceCommon>;
|
||||
}
|
||||
|
||||
@@ -181,7 +187,7 @@ declare global {
|
||||
type: 'adapter' | 'config' | 'enum' | 'group' | 'host' | 'info' | 'instance' | 'meta' | 'script' | 'user';
|
||||
common: OtherCommon;
|
||||
}
|
||||
interface PartialOtherObject extends Partial<Pick<OtherObject, '_id' | 'native' | 'enums' | 'type' | 'acl'>> {
|
||||
interface PartialOtherObject extends Partial<Omit<OtherObject, 'common'>> {
|
||||
common?: Partial<ObjectCommon>;
|
||||
}
|
||||
|
||||
@@ -328,17 +334,16 @@ declare global {
|
||||
/** Parameters for adapter.getObjectView */
|
||||
interface GetObjectViewParams {
|
||||
/** First id to include in the return list */
|
||||
startkey: string;
|
||||
startkey?: string;
|
||||
/** Last id to include in the return list */
|
||||
endkey: string;
|
||||
}
|
||||
|
||||
/** Parameters for @link{Objects.getObjectList} */
|
||||
interface GetObjectListParams extends GetObjectViewParams {
|
||||
endkey?: string;
|
||||
/** Whether docs should be included in the return list */ // TODO: What are docs?
|
||||
include_docs?: boolean;
|
||||
}
|
||||
|
||||
/** Parameters for adapter.getObjectList */
|
||||
type GetObjectListParams = GetObjectViewParams;
|
||||
|
||||
type LogLevel = 'silly' | 'debug' | 'info' | 'warn' | 'error';
|
||||
interface Logger {
|
||||
/** log message with silly level */
|
||||
@@ -1717,16 +1722,16 @@ declare global {
|
||||
|
||||
type MessageCallback = (response?: Message) => void;
|
||||
|
||||
type SetObjectCallback = (err: string | null, obj: { id: string }) => void;
|
||||
type GetObjectCallback = (err: string | null, obj: ioBroker.Object | null | undefined) => void;
|
||||
type GetEnumCallback = (err: string | null, enums: Record<string, Enum>, requestedEnum: string) => void;
|
||||
type SetObjectCallback = (err: string | null, obj?: { id: string }) => void;
|
||||
type GetObjectCallback = (err: string | null, obj?: ioBroker.Object | null) => void;
|
||||
type GetEnumCallback = (err: string | null, enums?: Record<string, Enum>, requestedEnum?: string) => void;
|
||||
type GetEnumsCallback = (
|
||||
err: string | null,
|
||||
result: {
|
||||
result?: {
|
||||
[groupName: string]: Record<string, Enum>;
|
||||
},
|
||||
) => void;
|
||||
type GetObjectsCallback = (err: string | null, objects: Record<string, ioBroker.Object>) => void;
|
||||
type GetObjectsCallback = (err: string | null, objects?: Record<string, ioBroker.Object>) => void;
|
||||
|
||||
type FindObjectCallback = (
|
||||
/** If an error happened, this contains the message */
|
||||
@@ -1783,11 +1788,11 @@ declare global {
|
||||
/** Whether this is a directory or a file */
|
||||
isDir: boolean;
|
||||
/** Access rights */
|
||||
acl: EvaluatedFileACL;
|
||||
acl?: EvaluatedFileACL;
|
||||
/** Date of last modification */
|
||||
modifiedAt: number;
|
||||
modifiedAt?: number;
|
||||
/** Date of creation */
|
||||
createdAt: number;
|
||||
createdAt?: number;
|
||||
}
|
||||
type ReadDirCallback = (err: string | null, entries?: ReadDirResult[]) => void;
|
||||
type ReadFileCallback = (err: string | null, file?: Buffer | string, mimeType?: string) => void;
|
||||
@@ -1829,8 +1834,8 @@ declare global {
|
||||
interface GetObjectViewItem {
|
||||
/** The ID of this object */
|
||||
id: string;
|
||||
/** A copy of the object from the DB or some aggregation result */
|
||||
value: ioBroker.Object | unknown; // TODO: find out how the non-Object return result looks like
|
||||
/** A copy of the object from the DB */
|
||||
value: ioBroker.Object | null;
|
||||
}
|
||||
type GetObjectViewCallback = (err: string | null, result?: { rows: GetObjectViewItem[] }) => void;
|
||||
|
||||
|
||||
@@ -189,8 +189,21 @@ adapter.getForeignObject("obj.id", (err, obj) => { });
|
||||
adapter.getObjectAsync("obj.id").then(obj => obj && obj._id.toLowerCase());
|
||||
adapter.getForeignObjectAsync("obj.id").then(obj => obj && obj._id.toLowerCase());
|
||||
|
||||
adapter.getForeignObjects("*", (err, objs) => objs["foo"]._id.toLowerCase());
|
||||
adapter.getForeignObjectsAsync("*").then(objs => objs["foo"]._id.toLowerCase());
|
||||
adapter.getForeignObjects("*", (err, objs) => objs!["foo"]._id.toLowerCase());
|
||||
adapter.getForeignObjectsAsync("*").then(objs => objs!["foo"]._id.toLowerCase());
|
||||
|
||||
adapter.setObject("id", {
|
||||
_id: "id",
|
||||
type: "device",
|
||||
common: {
|
||||
name: "foo"
|
||||
},
|
||||
native: {},
|
||||
protectedNative: ["none"],
|
||||
encryptedNative: ["none"],
|
||||
from: "me",
|
||||
ts: Date.now(),
|
||||
});
|
||||
|
||||
adapter.getObjectView("system", "admin", {startkey: "foo", endkey: "bar"}, (err, docs) => {
|
||||
docs && docs.rows[0] && docs.rows[0].id.toLowerCase();
|
||||
|
||||
Reference in New Issue
Block a user