@iobroker/types 5.0.0-alpha.0-20221217-d87d529d

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.
package/objects.d.ts ADDED
@@ -0,0 +1,793 @@
1
+ import * as os from 'os';
2
+
3
+ declare global {
4
+ namespace ioBroker {
5
+ /** Defines access rights for a single file */
6
+ interface FileACL {
7
+ /** Full name of the user who owns this file, e.g. "system.user.admin" */
8
+ owner: string;
9
+ /** Full name of the group who owns this file, e.g. "system.group.administrator" */
10
+ ownerGroup: string;
11
+ /** Linux-type permissions defining access to this file */
12
+ permissions: number;
13
+ }
14
+ /** Defines access rights for a single file, applied to a user or group */
15
+ interface EvaluatedFileACL extends FileACL {
16
+ /** Whether the user may read the file */
17
+ read: boolean;
18
+ /** Whether the user may write the file */
19
+ write: boolean;
20
+ }
21
+
22
+ /** Defines access rights for a single object */
23
+ interface ObjectACL {
24
+ /** Full name of the user who owns this object, e.g. "system.user.admin" */
25
+ owner: string;
26
+ /** Full name of the group who owns this object, e.g. "system.group.administrator" */
27
+ ownerGroup: string;
28
+ /** Linux-type permissions defining access to this object */
29
+ object: number;
30
+ }
31
+ /** Defines access rights for a single state object */
32
+ interface StateACL extends ObjectACL {
33
+ /** Linux-type permissions defining access to this state */
34
+ state: number;
35
+ }
36
+
37
+ /** Defines the existing object types in ioBroker */
38
+ type ObjectType =
39
+ | 'state'
40
+ | 'channel'
41
+ | 'device'
42
+ | 'folder'
43
+ | 'enum'
44
+ | 'adapter'
45
+ | 'config'
46
+ | 'group'
47
+ | 'host'
48
+ | 'instance'
49
+ | 'meta'
50
+ | 'script'
51
+ | 'user'
52
+ | 'chart';
53
+
54
+ // Define the naming schemes for objects so we can provide more specific types for get/setObject
55
+
56
+ namespace ObjectIDs {
57
+ // Guaranteed meta objects
58
+ type Meta =
59
+ | `${string}.${number}`
60
+ | `${string}.${'meta' | 'admin'}`
61
+ | `${string}.meta.${string}`
62
+ | `${string}.${number}.meta.${string}`;
63
+
64
+ // Unsure, can be folder, device, channel or state
65
+ // --> We need this match to avoid matching the more specific types below
66
+ type Misc = `system.host.${string}.${string}` | `0_userdata.0.${string}`;
67
+
68
+ // Guaranteed channel objects
69
+ type Channel = `script.js.${'common' | 'global'}` | `${string}.${number}.info`;
70
+ // Either script or channel object
71
+ type ScriptOrChannel = `script.js.${string}`;
72
+ // Guaranteed state objects
73
+ type State = `system.adapter.${string}.${number}.${string}`;
74
+ // Guaranteed enum objects
75
+ type Enum = `enum.${string}`;
76
+ // Guaranteed instance objects
77
+ type Instance = `system.adapter.${string}.${number}`;
78
+ // Guaranteed adapter objects
79
+ type Adapter = `system.adapter.${string}`;
80
+ // Guaranteed group objects
81
+ type Group = `system.group.${string}`;
82
+ // Guaranteed user objects
83
+ type User = `system.user.${string}`;
84
+ // Guaranteed host objects
85
+ type Host = `system.host.${string}`;
86
+ // Guaranteed config objects
87
+ type Config = `system.${'certificates' | 'config' | 'repositories'}`;
88
+ // Guranteed design objects
89
+ type Design = `_design/${string}`;
90
+
91
+ // Unsure, can be folder, device, channel or state (or whatever an adapter does)
92
+ type AdapterScoped = `${string}.${number}.${string}`;
93
+
94
+ /** All possible typed object IDs */
95
+ type Any =
96
+ | Meta
97
+ | Misc
98
+ | Channel
99
+ | ScriptOrChannel
100
+ | State
101
+ | Enum
102
+ | Instance
103
+ | Adapter
104
+ | Group
105
+ | User
106
+ | Host
107
+ | Config
108
+ | AdapterScoped;
109
+ }
110
+
111
+ type ObjectIdToObjectType<T extends string, Read extends 'read' | 'write' = 'read'> =
112
+ // State must come before Adapter or system.adapter.admin.0.foobar will resolve to AdapterObject
113
+ T extends ObjectIDs.State
114
+ ? StateObject
115
+ : // Instance and Adapter must come before meta or `system.adapter.admin` will resolve to MetaObject
116
+ T extends ObjectIDs.Instance
117
+ ? InstanceObject
118
+ : T extends ObjectIDs.Adapter
119
+ ? AdapterObject
120
+ : T extends ObjectIDs.Channel
121
+ ? ChannelObject
122
+ : T extends ObjectIDs.Meta
123
+ ? MetaObject
124
+ : T extends ObjectIDs.Misc
125
+ ? AdapterScopedObject
126
+ : T extends ObjectIDs.ScriptOrChannel
127
+ ? ScriptObject | ChannelObject
128
+ : T extends ObjectIDs.Enum
129
+ ? EnumObject
130
+ : T extends ObjectIDs.Group
131
+ ? GroupObject
132
+ : T extends ObjectIDs.User
133
+ ? UserObject
134
+ : T extends ObjectIDs.Host
135
+ ? HostObject
136
+ : T extends ObjectIDs.Design
137
+ ? DesignObject
138
+ : T extends ObjectIDs.Config
139
+ ? OtherObject & { type: 'config' }
140
+ : T extends ObjectIDs.AdapterScoped
141
+ ? AdapterScopedObject
142
+ : Read extends 'read'
143
+ ? ioBroker.Object
144
+ : AnyObject;
145
+
146
+ type Languages = 'en' | 'de' | 'ru' | 'pt' | 'nl' | 'fr' | 'it' | 'es' | 'pl' | 'zh-cn';
147
+ /** For objects we require the English language to be present */
148
+ type StringOrTranslated = string | ({ en: string } & { [lang in Languages]?: string });
149
+
150
+ type CommonType = 'number' | 'string' | 'boolean' | 'array' | 'object' | 'mixed' | 'file';
151
+
152
+ interface ObjectCommon {
153
+ /** The name of this object as a simple string or an object with translations */
154
+ name: StringOrTranslated;
155
+
156
+ /** When set to true, this object may not be deleted */
157
+ dontDelete?: true;
158
+
159
+ /** When set to true, this object is only visible when expert mode is turned on in admin */
160
+ expert?: true;
161
+
162
+ // Icon and role aren't defined in SCHEMA.md,
163
+ // but they are being used by some adapters
164
+ /** Icon for this object */
165
+ icon?: string;
166
+ /** role of the object */
167
+ role?: string;
168
+ }
169
+
170
+ interface StateCommon extends ObjectCommon {
171
+ /** Type of this state. See https://github.com/ioBroker/ioBroker/blob/master/doc/SCHEMA.md#state-commonrole for a detailed description */
172
+ type?: CommonType;
173
+ /** minimum value */
174
+ min?: number;
175
+ /** maximum value */
176
+ max?: number;
177
+ /** allowed interval for numeric values */
178
+ step?: number;
179
+ /** unit of the value */
180
+ unit?: string;
181
+ /** description of this state */
182
+ desc?: StringOrTranslated;
183
+
184
+ /** if this state is readable */
185
+ read: boolean;
186
+ /** if this state is writable */
187
+ write: boolean;
188
+ /** role of the state (used in user interfaces to indicate which widget to choose) */
189
+ role: string;
190
+
191
+ /** the default value */
192
+ def?: any;
193
+ /** the default status of the ack flag */
194
+ defAck?: boolean;
195
+
196
+ /** Configures this state as an alias for another state */
197
+ alias?: {
198
+ /** The target state id */
199
+ id:
200
+ | string
201
+ | {
202
+ read: string;
203
+ write: string;
204
+ };
205
+ /** An optional conversion function when reading, e.g. `"(val − 32) * 5/9"` */
206
+ read?: string;
207
+ /** An optional conversion function when reading, e.g. `"(val * 9/5) + 32"` */
208
+ write?: string;
209
+ };
210
+
211
+ /**
212
+ * Dictionary of possible values for this state in the form
213
+ * ```jsonc
214
+ * {
215
+ * "internal value 1": "displayed value 1",
216
+ * "internal value 2": "displayed value 2",
217
+ * // ...
218
+ * }
219
+ * ```
220
+ *
221
+ * or as an array:
222
+ * ```jsonc
223
+ * [ "value 1", "value 2", // ... ]
224
+ * ```
225
+ *
226
+ * In old ioBroker versions, this could also be a string of the form
227
+ * `"val1:text1;val2:text2"` (now deprecated)
228
+ */
229
+ states?: Record<string, string> | string[] | string;
230
+
231
+ /** ID of a helper state indicating if the handler of this state is working */
232
+ workingID?: string;
233
+
234
+ /** attached history information */
235
+ history?: any;
236
+
237
+ /** Custom settings for this state */
238
+ custom?: Record<string, any>;
239
+
240
+ /** Custom defined properties for backward compatibility of material adapter */
241
+ material?: any;
242
+
243
+ /** Custom defined properties for backward compatibility of habpanel adapter */
244
+ habpanel?: any;
245
+
246
+ /** Custom defined properties for backward compatibility of habpanel adapter */
247
+ mobile?: any;
248
+
249
+ /**
250
+ * Settings for IOT adapters and how the state should be named in e.g. Alexa.
251
+ * The string "ignore" is a special case, causing the state to be ignored.
252
+ */
253
+ smartName?:
254
+ | string
255
+ | ({ [lang in Languages]?: string } & {
256
+ /** Which kind of device this is */
257
+ smartType?: string | null;
258
+ /** Which value to set when the ON command is issued */
259
+ byOn?: string | null;
260
+ });
261
+ }
262
+ interface ChannelCommon extends ObjectCommon {
263
+ /** description of this channel */
264
+ desc?: string;
265
+
266
+ // Make it possible to narrow the object type using the custom property
267
+ custom?: undefined;
268
+ }
269
+ interface DeviceCommon extends ObjectCommon {
270
+ // TODO: any other definition for device?
271
+
272
+ // Make it possible to narrow the object type using the custom property
273
+ custom?: undefined;
274
+ }
275
+ interface EnumCommon extends ObjectCommon {
276
+ /** The IDs of the enum members */
277
+ members?: string[];
278
+
279
+ // Make it possible to narrow the object type using the custom property
280
+ custom?: undefined;
281
+ }
282
+
283
+ interface MetaCommon extends ObjectCommon {
284
+ // Meta objects have to additional CommonTypes
285
+ type: CommonType | 'meta.user' | 'meta.folder';
286
+
287
+ // Make it possible to narrow the object type using the custom property
288
+ custom?: undefined;
289
+ }
290
+
291
+ type InstanceMode = 'none' | 'daemon' | 'subscribe' | 'schedule' | 'once' | 'extension';
292
+ interface InstanceCommon extends ObjectCommon {
293
+ /** The name of the host where this instance is running */
294
+ host: string;
295
+ enabled: boolean;
296
+ /** How and when this instance should be started */
297
+ mode: InstanceMode;
298
+ /**
299
+ * The starting priority of this adapter:
300
+ * - **1:** Logic adapters
301
+ * - **2:** Data providers
302
+ * - **3:** All other adapters
303
+ */
304
+ tier?: 1 | 2 | 3;
305
+
306
+ // Make it possible to narrow the object type using the custom property
307
+ custom?: undefined;
308
+ }
309
+
310
+ interface HostCommon extends ObjectCommon {
311
+ /** The display name of this host */
312
+ name: string;
313
+ title: string;
314
+ installedVersion: string; // e.g. 1.2.3 (following semver)
315
+ /** The command line of the executable */
316
+ cmd: string;
317
+ hostname: string;
318
+ /** An array of IP addresses this host exposes */
319
+ address: string[]; // IPv4 or IPv6
320
+
321
+ type: 'js-controller';
322
+ platform: 'Javascript/Node.js';
323
+
324
+ // Make it possible to narrow the object type using the custom property
325
+ custom?: undefined;
326
+ }
327
+
328
+ interface HostNative {
329
+ process: {
330
+ title: string;
331
+ versions: NodeJS.ProcessVersions;
332
+ env: Record<string, string>;
333
+ };
334
+ os: {
335
+ hostname: string;
336
+ type: ReturnType<typeof os['type']>;
337
+ platform: ReturnType<typeof os['platform']>;
338
+ arch: ReturnType<typeof os['arch']>;
339
+ release: ReturnType<typeof os['release']>;
340
+ endianness: ReturnType<typeof os['endianness']>;
341
+ tmpdir: ReturnType<typeof os['tmpdir']>;
342
+ };
343
+ hardware: {
344
+ cpus: ReturnType<typeof os['cpus']>;
345
+ totalmem: ReturnType<typeof os['totalmem']>;
346
+ networkInterfaces: ReturnType<typeof os['networkInterfaces']>;
347
+ };
348
+ }
349
+
350
+ interface UserCommon extends ObjectCommon {
351
+ /** The username */
352
+ name: string;
353
+ /** The hashed password */
354
+ password: string;
355
+ /** Whether this user is enabled */
356
+ enabled: boolean;
357
+
358
+ // Make it possible to narrow the object type using the custom property
359
+ custom?: undefined;
360
+ }
361
+
362
+ interface GroupCommon extends ObjectCommon {
363
+ /** The name of this group */
364
+ name: string;
365
+ /** The users of this group */
366
+ members: string[]; // system.user.name, ...
367
+ /** The default permissions of this group */
368
+ acl: Omit<PermissionSet, 'user' | 'groups'>;
369
+
370
+ // Make it possible to narrow the object type using the custom property
371
+ custom?: undefined;
372
+ }
373
+
374
+ interface ScriptCommon extends ObjectCommon {
375
+ name: string;
376
+ /** Defines the type of the script, e.g. TypeScript/ts, JavaScript/js or Blockly */
377
+ engineType: string;
378
+ /** The instance id of the instance which executes this script */
379
+ engine: string;
380
+ /** The source code of this script */
381
+ source: string;
382
+ debug: boolean;
383
+ verbose: boolean;
384
+ /** Whether this script should be executed */
385
+ enabled: boolean;
386
+ /** Is used to determine whether a script has changed and needs to be recompiled */
387
+ sourceHash?: string;
388
+ /** If the script uses a compiled language like TypeScript, this contains the compilation output */
389
+ compiled?: string;
390
+ /** If the script uses a compiled language like TypeScript, this contains the generated declarations (global scripts only) */
391
+ declarations?: string;
392
+
393
+ // Make it possible to narrow the object type using the custom property
394
+ custom?: undefined;
395
+ }
396
+
397
+ type WelcomeScreenEntry =
398
+ | string
399
+ | {
400
+ link: string;
401
+ name: string;
402
+ img: string;
403
+ color: string;
404
+ };
405
+
406
+ interface AdapterCommon extends ObjectCommon {
407
+ /** Custom attributes to be shown in admin in the object browser */
408
+ adminColumns?: any[];
409
+ /** Settings for custom Admin Tabs */
410
+ adminTab?: {
411
+ name?: string;
412
+ /** Icon name for FontAwesome */
413
+ 'fa-icon'?: string;
414
+ /** If true, the Tab is not reloaded when the configuration changes */
415
+ ignoreConfigUpdate?: boolean;
416
+ /** Which URL should be loaded in the tab. Supports placeholders like http://%ip%:%port% */
417
+ link?: string;
418
+ /** If true, only one instance of this tab will be created for all instances */
419
+ singleton?: boolean;
420
+ };
421
+ allowInit?: boolean;
422
+ /** Possible values for the instance mode (if more than one is possible) */
423
+ availableModes?: InstanceMode[];
424
+ /** Whether this adapter includes custom blocks for Blockly. If true, `admin/blockly.js` must exist. */
425
+ blockly?: boolean;
426
+ /** Where the adapter will get its data from. Set this together with @see dataSource */
427
+ connectionType?: 'local' | 'cloud';
428
+ /** If true, this adapter can be started in compact mode (in the same process as other adpaters) */
429
+ compact?: boolean;
430
+ /** The directory relative to iobroker-data where the adapter stores the data. Supports the placeholder `%INSTANCE%`. This folder will be backed up and restored automatically. */
431
+ dataFolder?: string;
432
+ /** How the adapter will mainly receive its data. Set this together with @see connectionType */
433
+ dataSource?: 'poll' | 'push' | 'assumption';
434
+ /** A record of ioBroker adapters (including "js-controller") and version ranges which are required for this adapter. */
435
+ dependencies?: Array<Record<string, string>>;
436
+ /** Which files outside of the README.md have documentation for the adapter */
437
+ docs?: Partial<Record<Languages, string | string[]>>;
438
+ /** Whether new instances should be enabled by default. *Should* be `false`! */
439
+ enabled: boolean;
440
+ /** If true, all previous data in the target directory (web) should be deleted before uploading */
441
+ eraseOnUpload?: boolean;
442
+ /** URL of an external icon that is shown for adapters that are not installed */
443
+ extIcon?: string;
444
+ /** Whether this adapter responds to `getHistory` messages */
445
+ getHistory?: boolean;
446
+ /** Filename of the local icon which is shown for installed adapters. Should be located in the `admin` directory */
447
+ icon?: string;
448
+ /** Which version of this adapter is installed */
449
+ installedVersion: string;
450
+ keywords?: string[];
451
+ /** A dictionary of links to web services this adapter provides */
452
+ localLinks?: Record<string, string>;
453
+ /** @deprecated Use @see localLinks */
454
+ localLink?: string;
455
+ logLevel?: LogLevel;
456
+ /** Whether this adapter receives logs from other hosts and adapters (e.g. to strore them somewhere) */
457
+ logTransporter?: boolean;
458
+ /** Path to the start file of the adapter. Should be the same as in `package.json` */
459
+ main?: string;
460
+ /** Whether the admin tab is written in materialize style. Required for Admin 3+ */
461
+ materializeTab: boolean;
462
+ /** Whether the admin configuration dialog is written in materialize style. Required for Admin 3+ */
463
+ materialize: boolean;
464
+ /** If `true`, the object `system.adapter.<adaptername>.<adapterinstance>.messagebox will be created to send messages to the adapter (used for email, pushover, etc...) */
465
+ messagebox?: true;
466
+ mode: InstanceMode;
467
+ /** Name of the adapter (without leading `ioBroker.`) */
468
+ name: string;
469
+ /** If `true`, no configuration dialog will be shown */
470
+ noConfig?: true;
471
+ /** If `true`, this adapter's instances will not be shown in the admin overview screen. Useful for icon sets and widgets... */
472
+ noIntro?: true;
473
+ /** Set to `true` if the adapter is not available in the official ioBroker repositories. */
474
+ noRepository?: true;
475
+ /** If `true`, manual installation from GitHub is not possible */
476
+ nogit?: true;
477
+ /** If `true`, this adapter cannot be deleted or updated manually. */
478
+ nondeletable?: true;
479
+ /** If `true`, this "adapter" only contains HTML files and no main executable */
480
+ onlyWWW?: boolean;
481
+ /** Used to configure native (OS) dependencies of this adapter that need to be installed with system package manager before installing the adapter */
482
+ osDependencies?: {
483
+ /** For OSX */
484
+ darwin: string[];
485
+ /** For Linux */
486
+ linux: string[];
487
+ /** For Windows */
488
+ win32: string[];
489
+ };
490
+ /** Which OSes this adapter supports */
491
+ os?: 'linux' | 'darwin' | 'win32' | Array<'linux' | 'darwin' | 'win32'>;
492
+ platform: 'Javascript/Node.js';
493
+ /** The keys of common attributes (e.g. `history`) which are not deleted in a `setObject` call even if they are not present. Deletion must be done explicitly by setting them to `null`. */
494
+ preserveSettings?: string | string[];
495
+ /** Which adapters must be restarted after installing or updating this adapter. */
496
+ restartAdapters?: string[];
497
+ /** If the adapter runs in `schedule` mode, this contains the CRON */
498
+ schedule?: string;
499
+ serviceStates?: boolean | string;
500
+ /** Whether this adapter may only be installed once per host */
501
+ singletonHost?: boolean;
502
+ /** Whether this adapter may only be installed once in the whole system */
503
+ singleton?: boolean;
504
+ /** Whether the adapter must be stopped before an update */
505
+ stopBeforeUpdate?: boolean;
506
+ /** Overrides the default timeout that ioBroker will wait before force-stopping the adapter */
507
+ stopTimeout?: number;
508
+ subscribable?: boolean;
509
+ subscribe?: any; // ?
510
+ /** If `true`, this adapter provides custom per-state settings. Requires a `custom_m.html` file in the `admin` directory. */
511
+ supportCustoms?: boolean;
512
+ /** Whether the adapter supports the signal stopInstance via messagebox */
513
+ supportStopInstance?: boolean;
514
+ /** The translated names of this adapter to be shown in the admin UI */
515
+ titleLang?: Record<Languages, string>;
516
+ /** @deprecated The name of this adapter to be shown in the admin UI. Use @see titleLang instead. */
517
+ title?: string;
518
+ /** The type of this adapter */
519
+ type?: string;
520
+ /** If `true`, the `npm` package must be installed with the `--unsafe-perm` flag */
521
+ unsafePerm?: true;
522
+ /** The available version in the ioBroker repo. */
523
+ version: string;
524
+ /** If `true`, the adapter will be started if any value is written into `system.adapter.<name>.<instance>.wakeup. Normally the adapter should stop after processing the event. */
525
+ wakeup?: boolean;
526
+ /** Include the adapter version in the URL of the web adapter, e.g. `http://ip:port/1.2.3/material` instead of `http://ip:port/material` */
527
+ webByVersion?: boolean;
528
+ /** Whether the web server in this adapter can be extended with plugin/extensions */
529
+ webExtendable?: boolean;
530
+ /** Relative path to a module that contains an extension for the web adapter. Use together with @see native.webInstance to configure which instances this affects */
531
+ webExtension?: string;
532
+ webPreSettings?: any; // ?
533
+ webservers?: any; // ?
534
+ /** A list of pages that should be shown on the "web" index page */
535
+ welcomeScreen?: WelcomeScreenEntry[];
536
+ /** A list of pages that should be shown on the ioBroker cloud index page */
537
+ welcomeScreenPro?: WelcomeScreenEntry[];
538
+ wwwDontUpload?: boolean;
539
+
540
+ // Make it possible to narrow the object type using the custom property
541
+ custom?: undefined;
542
+ }
543
+
544
+ interface OtherCommon extends ObjectCommon {
545
+ [propName: string]: any;
546
+
547
+ // Make it possible to narrow the object type using the custom property
548
+ custom?: undefined;
549
+ }
550
+
551
+ /* Base type for Objects. Should not be used directly */
552
+ interface BaseObject {
553
+ /** The ID of this object */
554
+ _id: string;
555
+ type: ObjectType; // specified in the derived interfaces
556
+ // Ideally we would limit this to JSON-serializable objects, but TypeScript doesn't allow this
557
+ // without bugging users to change their code --> https://github.com/microsoft/TypeScript/issues/15300
558
+ native: Record<string, any>;
559
+ common: Record<string, any>;
560
+ enums?: Record<string, string>;
561
+ acl?: ObjectACL;
562
+ from?: string;
563
+ /** The user who created or updated this object */
564
+ user?: string;
565
+ ts?: number;
566
+ }
567
+
568
+ interface StateObject extends BaseObject {
569
+ type: 'state';
570
+ common: StateCommon;
571
+ acl?: StateACL;
572
+ }
573
+ interface PartialStateObject extends Partial<Omit<StateObject, 'common' | 'acl'>> {
574
+ common?: Partial<StateCommon>;
575
+ acl?: Partial<StateACL>;
576
+ }
577
+
578
+ interface ChannelObject extends BaseObject {
579
+ type: 'channel';
580
+ common: ChannelCommon;
581
+ }
582
+ interface PartialChannelObject extends Partial<Omit<ChannelObject, 'common'>> {
583
+ common?: Partial<ChannelCommon>;
584
+ }
585
+
586
+ interface DeviceObject extends BaseObject {
587
+ type: 'device';
588
+ common: DeviceCommon;
589
+ }
590
+ interface PartialDeviceObject extends Partial<Omit<DeviceObject, 'common'>> {
591
+ common?: Partial<DeviceCommon>;
592
+ }
593
+
594
+ interface FolderObject extends BaseObject {
595
+ type: 'folder';
596
+ // Nothing is set in stone here, so start with allowing every property
597
+ common: OtherCommon;
598
+ }
599
+ interface PartialFolderObject extends Partial<Omit<FolderObject, 'common'>> {
600
+ common?: Partial<OtherCommon>;
601
+ }
602
+
603
+ interface EnumObject extends BaseObject {
604
+ type: 'enum';
605
+ common: EnumCommon;
606
+ }
607
+ interface PartialEnumObject extends Partial<Omit<EnumObject, 'common'>> {
608
+ common?: Partial<EnumCommon>;
609
+ }
610
+
611
+ interface MetaObject extends BaseObject {
612
+ type: 'meta';
613
+ common: MetaCommon;
614
+ }
615
+ interface PartialMetaObject extends Partial<Omit<MetaObject, 'common'>> {
616
+ common?: Partial<MetaCommon>;
617
+ }
618
+
619
+ interface InstanceObject extends BaseObject {
620
+ type: 'instance';
621
+ common: InstanceCommon;
622
+ }
623
+ interface PartialInstanceObject extends Partial<Omit<InstanceObject, 'common'>> {
624
+ common?: Partial<InstanceCommon>;
625
+ }
626
+
627
+ interface AdapterObject extends BaseObject {
628
+ type: 'adapter';
629
+ common: AdapterCommon;
630
+ /** An array of `native` properties which cannot be accessed from outside the defining adapter */
631
+ protectedNative?: string[];
632
+ /** Like protectedNative, but the properties are also encrypted and decrypted automatically */
633
+ encryptedNative?: string[];
634
+ }
635
+ interface PartialAdapterObject extends Partial<Omit<AdapterObject, 'common'>> {
636
+ common?: Partial<AdapterCommon>;
637
+ }
638
+
639
+ interface HostObject extends BaseObject {
640
+ type: 'host';
641
+ common: HostCommon;
642
+ native: HostNative;
643
+ }
644
+ interface PartialHostObject extends Partial<Omit<HostObject, 'common' | 'native'>> {
645
+ common?: Partial<HostCommon>;
646
+ native?: Partial<HostNative>;
647
+ }
648
+
649
+ interface UserObject extends BaseObject {
650
+ type: 'user';
651
+ common: UserCommon;
652
+ }
653
+ interface PartialUserObject extends Partial<Omit<UserObject, 'common'>> {
654
+ common?: Partial<UserCommon>;
655
+ }
656
+
657
+ interface GroupObject extends BaseObject {
658
+ type: 'group';
659
+ common: GroupCommon;
660
+ }
661
+ interface PartialGroupObject extends Partial<Omit<GroupObject, 'common'>> {
662
+ common?: Partial<GroupCommon>;
663
+ }
664
+
665
+ interface ScriptObject extends BaseObject {
666
+ type: 'script';
667
+ common: ScriptCommon;
668
+ }
669
+ interface PartialScriptObject extends Partial<Omit<ScriptObject, 'common'>> {
670
+ common?: Partial<ScriptCommon>;
671
+ }
672
+
673
+ interface OtherObject extends BaseObject {
674
+ type: 'config' | 'chart';
675
+ common: OtherCommon;
676
+ }
677
+
678
+ interface PartialOtherObject extends Partial<Omit<OtherObject, 'common'>> {
679
+ common?: Partial<OtherCommon>;
680
+ }
681
+
682
+ interface DesignObject extends Omit<BaseObject, 'common'> {
683
+ language: 'javascript';
684
+ common?: OtherCommon;
685
+ views: Record<string, { map: string }>;
686
+ }
687
+
688
+ interface PartialDesignObject extends Partial<Omit<DesignObject, 'common'>> {
689
+ common?: Partial<OtherCommon>;
690
+ }
691
+
692
+ type AnyObject =
693
+ | StateObject
694
+ | ChannelObject
695
+ | DeviceObject
696
+ | FolderObject
697
+ | EnumObject
698
+ | MetaObject
699
+ | HostObject
700
+ | AdapterObject
701
+ | InstanceObject
702
+ | UserObject
703
+ | GroupObject
704
+ | ScriptObject
705
+ | OtherObject;
706
+
707
+ type AnyPartialObject =
708
+ | PartialStateObject
709
+ | PartialChannelObject
710
+ | PartialDeviceObject
711
+ | PartialFolderObject
712
+ | PartialEnumObject
713
+ | PartialMetaObject
714
+ | PartialHostObject
715
+ | PartialAdapterObject
716
+ | PartialInstanceObject
717
+ | PartialUserObject
718
+ | PartialGroupObject
719
+ | PartialScriptObject
720
+ | PartialOtherObject;
721
+
722
+ /** All objects that usually appear in an adapter scope */
723
+ type AdapterScopedObject = FolderObject | DeviceObject | ChannelObject | StateObject;
724
+
725
+ // For all objects that are exposed to the user we need to tone the strictness down.
726
+ // Otherwise, every operation on objects becomes a pain to work with
727
+ type Object = AnyObject & {
728
+ common: Record<string, any>;
729
+ native: Record<string, any>;
730
+ };
731
+
732
+ // In set[Foreign]Object[NotExists] methods, the ID and acl of the object is optional
733
+ type SettableObjectWorker<T> = T extends AnyObject
734
+ ? Omit<T, '_id' | 'acl'> & {
735
+ _id?: T['_id'];
736
+ acl?: T['acl'];
737
+ }
738
+ : never;
739
+ // in extend[Foreign]Object, most properties are optional
740
+ type PartialObjectWorker<T> = T extends AnyObject ? AnyPartialObject & { type?: T['type'] } : never;
741
+
742
+ type PartialObject<T extends AnyObject = AnyObject> = PartialObjectWorker<T>;
743
+
744
+ // Convenient definitions for manually specifying settable object types
745
+ type SettableObject<T extends AnyObject = AnyObject> = SettableObjectWorker<T>;
746
+ type SettableStateObject = SettableObject<StateObject>;
747
+ type SettableChannelObject = SettableObject<ChannelObject>;
748
+ type SettableDeviceObject = SettableObject<DeviceObject>;
749
+ type SettableFolderObject = SettableObject<FolderObject>;
750
+ type SettableEnumObject = SettableObject<EnumObject>;
751
+ type SettableMetaObject = SettableObject<MetaObject>;
752
+ type SettableHostObject = SettableObject<HostObject>;
753
+ type SettableAdapterObject = SettableObject<AdapterObject>;
754
+ type SettableInstanceObject = SettableObject<InstanceObject>;
755
+ type SettableUserObject = SettableObject<UserObject>;
756
+ type SettableGroupObject = SettableObject<GroupObject>;
757
+ type SettableScriptObject = SettableObject<ScriptObject>;
758
+ type SettableOtherObject = SettableObject<OtherObject>;
759
+
760
+ // Used to infer the return type of GetObjectView
761
+ type InferGetObjectViewItemType<Design extends string, View extends string> = Design extends 'system'
762
+ ? View extends 'host'
763
+ ? HostObject
764
+ : View extends 'adapter'
765
+ ? AdapterObject
766
+ : View extends 'instance'
767
+ ? InstanceObject
768
+ : View extends 'meta'
769
+ ? MetaObject
770
+ : View extends 'device'
771
+ ? DeviceObject
772
+ : View extends 'channel'
773
+ ? ChannelObject
774
+ : View extends 'state'
775
+ ? StateObject
776
+ : View extends 'folder'
777
+ ? FolderObject
778
+ : View extends 'enum'
779
+ ? EnumObject
780
+ : View extends 'script'
781
+ ? ScriptObject
782
+ : View extends 'group'
783
+ ? GroupObject
784
+ : View extends 'user'
785
+ ? UserObject
786
+ : View extends 'config'
787
+ ? OtherObject & { type: 'config' }
788
+ : View extends 'custom'
789
+ ? NonNullable<StateObject['common']['custom']>
790
+ : ioBroker.Object
791
+ : any;
792
+ }
793
+ }