@iobroker/types 5.0.18 → 5.0.20-alpha.0-20240131-ea40ee4f

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.
@@ -1,4 +1,4 @@
1
- import * as os from 'os';
1
+ import type * as os from 'os';
2
2
 
3
3
  declare global {
4
4
  namespace ioBroker {
@@ -85,8 +85,12 @@ declare global {
85
85
  type User = `system.user.${string}`;
86
86
  // Guaranteed host objects
87
87
  type Host = `system.host.${string}`;
88
+ // Guaranteed repository object
89
+ type Repository = 'system.repositories';
88
90
  // Guaranteed config objects
89
- type Config = `system.${'certificates' | 'config' | 'repositories'}`;
91
+ type Config = 'system.certificates';
92
+ // Guaranteed system config objects
93
+ type SystemConfig = 'system.config';
90
94
  // Guaranteed design objects
91
95
  type Design = `_design/${string}`;
92
96
 
@@ -115,35 +119,39 @@ declare global {
115
119
  T extends ObjectIDs.State
116
120
  ? StateObject
117
121
  : // Instance and Adapter must come before meta or `system.adapter.admin` will resolve to MetaObject
118
- T extends ObjectIDs.Instance
119
- ? InstanceObject
120
- : T extends ObjectIDs.Adapter
121
- ? AdapterObject
122
- : T extends ObjectIDs.Channel
123
- ? ChannelObject
124
- : T extends ObjectIDs.Meta
125
- ? MetaObject
126
- : T extends ObjectIDs.Misc
127
- ? AdapterScopedObject
128
- : T extends ObjectIDs.ScriptOrChannel
129
- ? ScriptObject | ChannelObject
130
- : T extends ObjectIDs.Enum
131
- ? EnumObject
132
- : T extends ObjectIDs.Group
133
- ? GroupObject
134
- : T extends ObjectIDs.User
135
- ? UserObject
136
- : T extends ObjectIDs.Host
137
- ? HostObject
138
- : T extends ObjectIDs.Design
139
- ? DesignObject
140
- : T extends ObjectIDs.Config
141
- ? OtherObject & { type: 'config' }
142
- : T extends ObjectIDs.AdapterScoped
143
- ? AdapterScopedObject
144
- : Read extends 'read'
145
- ? ioBroker.Object
146
- : AnyObject;
122
+ T extends ObjectIDs.Instance
123
+ ? InstanceObject
124
+ : T extends ObjectIDs.Adapter
125
+ ? AdapterObject
126
+ : T extends ObjectIDs.Channel
127
+ ? ChannelObject
128
+ : T extends ObjectIDs.Meta
129
+ ? MetaObject
130
+ : T extends ObjectIDs.Misc
131
+ ? AdapterScopedObject
132
+ : T extends ObjectIDs.ScriptOrChannel
133
+ ? ScriptObject | ChannelObject
134
+ : T extends ObjectIDs.Enum
135
+ ? EnumObject
136
+ : T extends ObjectIDs.Group
137
+ ? GroupObject
138
+ : T extends ObjectIDs.User
139
+ ? UserObject
140
+ : T extends ObjectIDs.Host
141
+ ? HostObject
142
+ : T extends ObjectIDs.Design
143
+ ? DesignObject
144
+ : T extends ObjectIDs.Repository
145
+ ? RepositoryObject
146
+ : T extends ObjectIDs.SystemConfig
147
+ ? SystemConfigObject
148
+ : T extends ObjectIDs.Config
149
+ ? OtherObject & { type: 'config' }
150
+ : T extends ObjectIDs.AdapterScoped
151
+ ? AdapterScopedObject
152
+ : Read extends 'read'
153
+ ? ioBroker.Object
154
+ : AnyObject;
147
155
 
148
156
  type Languages = 'en' | 'de' | 'ru' | 'pt' | 'nl' | 'fr' | 'it' | 'es' | 'pl' | 'uk' | 'zh-cn';
149
157
  type Translated = { en: string } & { [lang in Languages]?: string };
@@ -157,6 +165,9 @@ declare global {
157
165
  /** The name of this object as a simple string or an object with translations */
158
166
  name: StringOrTranslated;
159
167
 
168
+ /** Description of this object */
169
+ desc?: StringOrTranslated;
170
+
160
171
  /** When set to true, this object may not be deleted */
161
172
  dontDelete?: true;
162
173
 
@@ -182,8 +193,6 @@ declare global {
182
193
  step?: number;
183
194
  /** unit of the value */
184
195
  unit?: string;
185
- /** description of this state */
186
- desc?: StringOrTranslated;
187
196
 
188
197
  /** if this state is readable */
189
198
  read: boolean;
@@ -264,9 +273,6 @@ declare global {
264
273
  });
265
274
  }
266
275
  interface ChannelCommon extends ObjectCommon {
267
- /** description of this channel */
268
- desc?: string;
269
-
270
276
  // Make it possible to narrow the object type using the custom property
271
277
  custom?: undefined;
272
278
  }
@@ -288,6 +294,10 @@ declare global {
288
294
  custom?: undefined;
289
295
  }
290
296
 
297
+ interface RepositoryCommon extends ObjectCommon {
298
+ custom?: undefined;
299
+ }
300
+
291
301
  interface ChartCommon extends ObjectCommon {
292
302
  enabled?: boolean;
293
303
  color?: string;
@@ -529,6 +539,8 @@ declare global {
529
539
  singleton?: boolean;
530
540
  };
531
541
  allowInit?: boolean;
542
+ /** If the adapter should be automatically upgraded and which version ranges are supported */
543
+ automaticUpgrade?: AutoUpgradePolicy;
532
544
  /** Possible values for the instance mode (if more than one is possible) */
533
545
  availableModes?: InstanceMode[];
534
546
  /** Array which lists all blocked versions. Blocked versions will not be started. Use semver notation to specify the version ranges. The information is always used from the io-package.json in the GitHub repository. */
@@ -668,6 +680,49 @@ declare global {
668
680
  custom?: undefined;
669
681
  }
670
682
 
683
+ interface SystemConfigCommon extends ObjectCommon {
684
+ /** Name of all active repositories */
685
+ activeRepo: string[];
686
+ /** Current configured language */
687
+ language: Languages;
688
+ /** If floating comma is used instead of dot */
689
+ isFloatComma: boolean;
690
+ /** Configured longitude */
691
+ longitude: string;
692
+ /** Configured latitude */
693
+ latitude: string;
694
+ /** Default history instance */
695
+ defaultHistory: string;
696
+ /** Which diag data is allowed to be sent */
697
+ diag: 'none' | 'extended' | 'no-city';
698
+ /** If license has already been confirmed */
699
+ licenseConfirmed: boolean;
700
+ /** System wide default log level */
701
+ defaultLogLevel?: LogLevel;
702
+ /** Used date format for formatting */
703
+ dateFormat: string;
704
+ /** Default acl for new objects */
705
+ defaultNewAcl: {
706
+ object: number;
707
+ state: number;
708
+ file: number;
709
+ owner: ObjectIDs.User;
710
+ ownerGroup: ObjectIDs.Group;
711
+ };
712
+ /** Configured auto upgrade policy */
713
+ adapterAutoUpgrade?: {
714
+ /** Configuration for each repository */
715
+ repositories: {
716
+ [repoName: string]: boolean;
717
+ };
718
+ /** Default policy, if none has been set explicit for the adapter */
719
+ defaultPolicy: AutoUpgradePolicy;
720
+ };
721
+
722
+ // Make it possible to narrow the object type using the custom property
723
+ custom?: undefined;
724
+ }
725
+
671
726
  interface OtherCommon extends ObjectCommon {
672
727
  [propName: string]: any;
673
728
 
@@ -780,6 +835,54 @@ declare global {
780
835
  common?: Partial<ScheduleCommon>;
781
836
  }
782
837
 
838
+ interface PartialRepositoryObject extends Partial<Omit<RepositoryObject, 'common'>> {
839
+ common?: Partial<RepositoryCommon>;
840
+ }
841
+
842
+ interface RepositoryJsonAdapterContent {
843
+ /** Adapter name */
844
+ name: string;
845
+ /** Newest available version */
846
+ version: string;
847
+ /** Other Adapter related properties, not important for this implementation */
848
+ [other: string]: unknown;
849
+ }
850
+
851
+ interface RepositoryJson {
852
+ _repoInfo: {
853
+ /** If it is the official stable repository */
854
+ stable?: boolean;
855
+ /** i18n name of the repository */
856
+ name: Required<ioBroker.Translated>;
857
+ /** Time of repository update */
858
+ repoTime: string;
859
+ };
860
+ /** Information about each adapter - Record needed for _repoInfo */
861
+ [adapter: string]: RepositoryJsonAdapterContent | Record<string, any>;
862
+ }
863
+
864
+ interface RepositoryInformation {
865
+ /** Url to the repository */
866
+ link: string;
867
+ json: RepositoryJson | null;
868
+ hash?: string;
869
+ time?: string;
870
+ }
871
+
872
+ interface RepositoryObject extends BaseObject {
873
+ _id: ObjectIDs.Repository;
874
+ type: 'config';
875
+ native: {
876
+ repositories: {
877
+ [repoName: string]: RepositoryInformation;
878
+ };
879
+ oldRepositories?: {
880
+ [repoName: string]: RepositoryInformation;
881
+ };
882
+ };
883
+ common: RepositoryCommon;
884
+ }
885
+
783
886
  interface InstanceObject extends BaseObject {
784
887
  _id: ObjectIDs.Instance;
785
888
  type: 'instance';
@@ -865,6 +968,15 @@ declare global {
865
968
  common?: Partial<ScriptCommon>;
866
969
  }
867
970
 
971
+ interface SystemConfigObject extends BaseObject {
972
+ type: 'config';
973
+ common: SystemConfigCommon;
974
+ }
975
+
976
+ interface PartialSystemConfigObject extends Partial<Omit<SystemConfigObject, 'common'>> {
977
+ common?: Partial<SystemConfigCommon>;
978
+ }
979
+
868
980
  interface OtherObject extends BaseObject {
869
981
  type: 'config' | 'chart';
870
982
  common: OtherCommon;
@@ -902,6 +1014,7 @@ declare global {
902
1014
  | ScriptObject
903
1015
  | ChartObject
904
1016
  | ScheduleObject
1017
+ | RepositoryObject
905
1018
  | OtherObject
906
1019
  | DesignObject;
907
1020
 
@@ -920,6 +1033,8 @@ declare global {
920
1033
  | PartialScriptObject
921
1034
  | PartialChartObject
922
1035
  | PartialScheduleObject
1036
+ | PartialRepositoryObject
1037
+ | PartialSystemConfigObject
923
1038
  | PartialOtherObject
924
1039
  | PartialDesignObject;
925
1040
 
@@ -962,6 +1077,8 @@ declare global {
962
1077
  type SettableScheduleObject = SettableObject<ScheduleObject>;
963
1078
  type SettableChartObject = SettableObject<ChartObject>;
964
1079
  type SettableDesignObject = SettableObject<DesignObject>;
1080
+ type SettableRepositoryObject = SettableObject<RepositoryObject>;
1081
+ type SettableSystemConfigObject = SettableObject<SystemConfigObject>;
965
1082
  type SettableOtherObject = SettableObject<OtherObject>;
966
1083
 
967
1084
  // Used to infer the return type of GetObjectView
@@ -969,36 +1086,36 @@ declare global {
969
1086
  ? View extends 'host'
970
1087
  ? HostObject
971
1088
  : View extends 'adapter'
972
- ? AdapterObject
973
- : View extends 'instance'
974
- ? InstanceObject
975
- : View extends 'meta'
976
- ? MetaObject
977
- : View extends 'device'
978
- ? DeviceObject
979
- : View extends 'channel'
980
- ? ChannelObject
981
- : View extends 'state'
982
- ? StateObject
983
- : View extends 'folder'
984
- ? FolderObject
985
- : View extends 'enum'
986
- ? EnumObject
987
- : View extends 'script'
988
- ? ScriptObject
989
- : View extends 'group'
990
- ? GroupObject
991
- : View extends 'user'
992
- ? UserObject
993
- : View extends 'chart'
994
- ? ChartObject
995
- : View extends 'schedule'
996
- ? ScheduleObject
997
- : View extends 'config'
998
- ? OtherObject & { type: 'config' }
999
- : View extends 'custom'
1000
- ? NonNullable<StateObject['common']['custom']>
1001
- : ioBroker.Object
1089
+ ? AdapterObject
1090
+ : View extends 'instance'
1091
+ ? InstanceObject
1092
+ : View extends 'meta'
1093
+ ? MetaObject
1094
+ : View extends 'device'
1095
+ ? DeviceObject
1096
+ : View extends 'channel'
1097
+ ? ChannelObject
1098
+ : View extends 'state'
1099
+ ? StateObject
1100
+ : View extends 'folder'
1101
+ ? FolderObject
1102
+ : View extends 'enum'
1103
+ ? EnumObject
1104
+ : View extends 'script'
1105
+ ? ScriptObject
1106
+ : View extends 'group'
1107
+ ? GroupObject
1108
+ : View extends 'user'
1109
+ ? UserObject
1110
+ : View extends 'chart'
1111
+ ? ChartObject
1112
+ : View extends 'schedule'
1113
+ ? ScheduleObject
1114
+ : View extends 'config'
1115
+ ? RepositoryObject | SystemConfigObject | (OtherObject & { type: 'config' })
1116
+ : View extends 'custom'
1117
+ ? NonNullable<StateObject['common']['custom']>
1118
+ : ioBroker.Object
1002
1119
  : any;
1003
1120
  }
1004
1121
  }
package/build/shared.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Types which are safe to share within this repository AND publicly
2
2
 
3
- import * as fs from 'fs';
3
+ import type * as fs from 'fs';
4
4
  import './objects';
5
5
  import type { IoBJson, DatabaseOptions, ObjectsDatabaseOptions as ObjectsDbOptions } from './config';
6
6
 
package/build/types.d.ts CHANGED
@@ -22,7 +22,10 @@ export declare interface AdapterClass {
22
22
  /** Only emitted for compact instances */
23
23
  on(event: 'exit', listener: (exitCode: number, reason: string) => Promise<void> | void): this;
24
24
  on(event: 'log', listener: (info: any) => Promise<void> | void): this;
25
- /** Extend an object and create it if it might not exist */
25
+ /**
26
+ * Extend an object and create it if it might not exist
27
+ * @deprecated use `adapter.extendObject` without callback instead
28
+ */
26
29
  extendObjectAsync(id: string, objPart: ioBroker.PartialObject, options?: ioBroker.ExtendObjectOptions): ioBroker.SetObjectPromise;
27
30
  /** Set capabilities of the given executable. Only works on Linux systems. */
28
31
  setExecutableCapabilities(execPath: string, capabilities: string[], modeEffective?: boolean, modePermitted?: boolean, modeInherited?: boolean): Promise<void>;
@@ -102,7 +105,7 @@ export declare interface AdapterClass {
102
105
  /** Read all states of this adapter which match the given pattern */
103
106
  getStatesAsync(pattern: string, options?: unknown): ioBroker.GetStatesPromise;
104
107
  /** Read all states (which might not belong to this adapter) which match the given pattern */
105
- getForeignStatesAsync(pattern: string, options?: unknown): ioBroker.GetStatesPromise;
108
+ getForeignStatesAsync(pattern: Pattern, options?: unknown): ioBroker.GetStatesPromise;
106
109
  /** Subscribe to changes of states (which might not belong to this adapter) */
107
110
  subscribeForeignStatesAsync(pattern: string | string[], options?: unknown): Promise<void>;
108
111
  /** Subscribe from changes of states (which might not belong to this adapter) */
@@ -199,9 +202,12 @@ export declare interface AdapterClass {
199
202
  delFile(adapterName: string | null, path: string, options: unknown, callback: ioBroker.ErrnoCallback): void;
200
203
  /**
201
204
  * Writes a value into the states DB.
205
+ * @deprecated use `adapter.setState` without callback instead
202
206
  */
203
207
  setStateAsync(id: string, state: ioBroker.State | ioBroker.StateValue | ioBroker.SettableState, ack?: boolean): ioBroker.SetStatePromise;
208
+ /** @deprecated use `adapter.setState` without callback instead */
204
209
  setStateAsync(id: string, state: ioBroker.State | ioBroker.StateValue | ioBroker.SettableState, options?: unknown): ioBroker.SetStatePromise;
210
+ /** @deprecated use `adapter.setState` without callback instead */
205
211
  setStateAsync(id: string, state: ioBroker.State | ioBroker.StateValue | ioBroker.SettableState, ack: boolean, options: unknown): ioBroker.SetStatePromise;
206
212
  /**
207
213
  * Writes a value (which might not belong to this adapter) into the states DB.
@@ -372,9 +378,9 @@ export declare class AdapterClass extends EventEmitter {
372
378
  /** configured language of system.config, only available if requested via AdapterOptions `useFormatDate` */
373
379
  language?: ioBroker.Languages;
374
380
  /** longitude configured in system.config, only available if requested via AdapterOptions `useFormatDate`*/
375
- longitude?: number;
381
+ longitude?: string;
376
382
  /** latitude configured in system.config, only available if requested via AdapterOptions `useFormatDate`*/
377
- latitude?: number;
383
+ latitude?: string;
378
384
  private _defaultObjs?;
379
385
  private _aliasObjectsSubscribed?;
380
386
  config: ioBroker.AdapterConfig;
@@ -491,7 +497,9 @@ export declare class AdapterClass extends EventEmitter {
491
497
  private _setObjectWithDefaultValue;
492
498
  getAdapterObjects(callback: (objects: Record<string, ioBroker.AdapterScopedObject>) => void): Promise<Record<string, ioBroker.AdapterScopedObject> | void>;
493
499
  private _getAdapterObjects;
500
+ extendObject(id: string, objPart: ioBroker.PartialObject): ioBroker.SetObjectPromise;
494
501
  extendObject(id: string, objPart: ioBroker.PartialObject, callback?: ioBroker.SetObjectCallback): void;
502
+ extendObject(id: string, objPart: ioBroker.PartialObject, options: ioBroker.ExtendObjectOptions): ioBroker.SetObjectPromise;
495
503
  extendObject(id: string, objPart: ioBroker.PartialObject, options: ioBroker.ExtendObjectOptions, callback?: ioBroker.SetObjectCallback): void;
496
504
  private _extendObject;
497
505
  setForeignObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, callback?: ioBroker.SetObjectCallback): void;
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
1
  {
2
- "name": "@iobroker/types",
3
- "version": "5.0.18",
4
- "engines": {
5
- "node": ">=12.0.0"
6
- },
7
- "keywords": [
8
- "ioBroker"
9
- ],
10
- "author": "foxriver76 <moritz.heusinger@gmail.com>",
11
- "contributors": [
12
- "foxriver76 <moritz.heusinger@gmail.com>"
13
- ],
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/ioBroker/ioBroker.js-controller/packages/types"
17
- },
18
- "devDependencies": {
19
- "tsd": "^0.24.1"
20
- },
21
- "scripts": {
22
- "build": "ts-node build.ts",
23
- "test": "tsd"
24
- },
25
- "main": "index.js",
26
- "types": "index.d.ts",
27
- "license": "MIT",
28
- "publishConfig": {
29
- "access": "public"
30
- },
31
- "files": [
32
- "build/",
33
- "index.d.ts",
34
- "public.d.ts",
35
- "LICENSE"
36
- ],
37
- "tsd": {
38
- "compilerOptions": {
39
- "types": [
40
- "@iobroker/types"
41
- ]
42
- }
43
- },
44
- "gitHead": "4609455d62438f63207b5ad869e54ea8b1325c0c"
2
+ "name": "@iobroker/types",
3
+ "version": "5.0.20-alpha.0-20240131-ea40ee4f",
4
+ "engines": {
5
+ "node": ">=12.0.0"
6
+ },
7
+ "keywords": [
8
+ "ioBroker"
9
+ ],
10
+ "author": "foxriver76 <moritz.heusinger@gmail.com>",
11
+ "contributors": [
12
+ "foxriver76 <moritz.heusinger@gmail.com>"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/ioBroker/ioBroker.js-controller/packages/types"
17
+ },
18
+ "devDependencies": {
19
+ "tsd": "^0.24.1"
20
+ },
21
+ "scripts": {
22
+ "build": "ts-node build.ts",
23
+ "test": "tsd"
24
+ },
25
+ "main": "index.js",
26
+ "types": "index.d.ts",
27
+ "license": "MIT",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "files": [
32
+ "build/",
33
+ "index.d.ts",
34
+ "public.d.ts",
35
+ "LICENSE"
36
+ ],
37
+ "tsd": {
38
+ "compilerOptions": {
39
+ "types": [
40
+ "@iobroker/types"
41
+ ]
42
+ }
43
+ },
44
+ "gitHead": "e95a41bedc1520053271e31a35d5272df6415e6e"
45
45
  }
package/public.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Types which are only safe to share publicly
2
2
 
3
- import { AdapterClass, AdapterOptions as _AdapterOptions } from './build/types';
3
+ import type { AdapterClass, AdapterOptions as _AdapterOptions } from './build/types';
4
4
 
5
5
  declare global {
6
6
  namespace ioBroker {