@iobroker/db-objects-redis 7.2.3 → 8.0.0-alpha.1-20260921-e5941ca8a

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.
Files changed (57) hide show
  1. package/build/cjs/index.d.ts +1 -1
  2. package/build/cjs/index.js +5 -3
  3. package/build/cjs/index.js.map +2 -2
  4. package/build/cjs/lib/objects/constants.js.map +2 -2
  5. package/build/cjs/lib/objects/interview.js +2 -0
  6. package/build/cjs/lib/objects/interview.js.map +1 -1
  7. package/build/cjs/lib/objects/lua-v3/custom.lua +23 -1
  8. package/build/cjs/lib/objects/lua-v3/filter.lua +23 -1
  9. package/build/cjs/lib/objects/lua-v3/programs.lua +23 -1
  10. package/build/cjs/lib/objects/lua-v3/script.lua +23 -1
  11. package/build/cjs/lib/objects/lua-v3/variables.lua +23 -1
  12. package/build/cjs/lib/objects/lua-v4/custom.lua +23 -1
  13. package/build/cjs/lib/objects/lua-v4/filter.lua +23 -1
  14. package/build/cjs/lib/objects/lua-v4/programs.lua +23 -1
  15. package/build/cjs/lib/objects/lua-v4/script.lua +23 -1
  16. package/build/cjs/lib/objects/lua-v4/variables.lua +23 -1
  17. package/build/cjs/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  18. package/build/cjs/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  19. package/build/cjs/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  20. package/build/cjs/lib/objects/lua-v4-no-sets/script.lua +23 -1
  21. package/build/cjs/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  22. package/build/cjs/lib/objects/objectsInRedisClient.d.ts +961 -125
  23. package/build/cjs/lib/objects/objectsInRedisClient.js +1092 -776
  24. package/build/cjs/lib/objects/objectsInRedisClient.js.map +3 -3
  25. package/build/cjs/lib/objects/objectsUtils.d.ts +139 -17
  26. package/build/cjs/lib/objects/objectsUtils.js +212 -192
  27. package/build/cjs/lib/objects/objectsUtils.js.map +3 -3
  28. package/build/esm/index.d.ts +1 -1
  29. package/build/esm/index.d.ts.map +1 -1
  30. package/build/esm/index.js.map +1 -1
  31. package/build/esm/lib/objects/constants.d.ts.map +1 -1
  32. package/build/esm/lib/objects/constants.js.map +1 -1
  33. package/build/esm/lib/objects/lua-v3/custom.lua +23 -1
  34. package/build/esm/lib/objects/lua-v3/filter.lua +23 -1
  35. package/build/esm/lib/objects/lua-v3/programs.lua +23 -1
  36. package/build/esm/lib/objects/lua-v3/script.lua +23 -1
  37. package/build/esm/lib/objects/lua-v3/variables.lua +23 -1
  38. package/build/esm/lib/objects/lua-v4/custom.lua +23 -1
  39. package/build/esm/lib/objects/lua-v4/filter.lua +23 -1
  40. package/build/esm/lib/objects/lua-v4/programs.lua +23 -1
  41. package/build/esm/lib/objects/lua-v4/script.lua +23 -1
  42. package/build/esm/lib/objects/lua-v4/variables.lua +23 -1
  43. package/build/esm/lib/objects/lua-v4-no-sets/custom.lua +23 -1
  44. package/build/esm/lib/objects/lua-v4-no-sets/filter.lua +23 -1
  45. package/build/esm/lib/objects/lua-v4-no-sets/programs.lua +23 -1
  46. package/build/esm/lib/objects/lua-v4-no-sets/script.lua +23 -1
  47. package/build/esm/lib/objects/lua-v4-no-sets/variables.lua +23 -1
  48. package/build/esm/lib/objects/objectsInRedisClient.d.ts +961 -125
  49. package/build/esm/lib/objects/objectsInRedisClient.d.ts.map +1 -1
  50. package/build/esm/lib/objects/objectsInRedisClient.js +880 -571
  51. package/build/esm/lib/objects/objectsInRedisClient.js.map +1 -1
  52. package/build/esm/lib/objects/objectsUtils.d.ts +139 -17
  53. package/build/esm/lib/objects/objectsUtils.d.ts.map +1 -1
  54. package/build/esm/lib/objects/objectsUtils.js +273 -221
  55. package/build/esm/lib/objects/objectsUtils.js.map +1 -1
  56. package/build/tsconfig.build.tsbuildinfo +1 -1
  57. package/package.json +9 -9
@@ -1,48 +1,48 @@
1
- import type { ACLObject, CheckFileRightsCallback, GetUserGroupPromiseReturn } from '../../lib/objects/objectsUtils.js';
1
+ import { type ACLObject, type FileObject, type UserContext } from '../../lib/objects/objectsUtils.js';
2
+ import * as CONSTS from '../../lib/objects/constants.js';
2
3
  import type { InternalLogger } from '@iobroker/js-controller-common-db/tools';
3
4
  import type { ConnectionOptions, DbStatus } from '@iobroker/db-base/inMemFileDB';
4
5
  type ChangeFunction = (id: string, object: ioBroker.Object | null) => void;
5
- type GetUserGroupCallbackNoError = (user: string, groups: string[], acl: ioBroker.ObjectPermissions) => void;
6
+ type GetUserGroupCallbackNoError = (user: ioBroker.ObjectIDs.User, groups: ioBroker.ObjectIDs.Group[], acl: ioBroker.ObjectPermissions) => void;
6
7
  interface RedisConnectionOptions extends ConnectionOptions {
7
8
  redisNamespace?: string;
8
9
  }
10
+ /** Settings for the objects database client */
9
11
  export interface ObjectsSettings {
12
+ /** Called once the client is connected */
10
13
  connected: () => void;
14
+ /** Whether this client runs inside the controller */
11
15
  controller?: boolean;
16
+ /** Called when the connection to the primary host is lost */
12
17
  primaryHostLost?: () => void;
18
+ /** Called when the client gets disconnected */
13
19
  disconnected?: () => void;
20
+ /** Handler for system-level object changes */
14
21
  change?: ChangeFunction;
22
+ /** Handler for user-level object changes */
15
23
  changeUser?: ChangeFunction;
24
+ /** Handler for user-level file changes */
16
25
  changeFileUser?: ioBroker.FileChangeHandler;
26
+ /** Whether to connect to the database immediately (default true) */
17
27
  autoConnect?: boolean;
28
+ /** Logger instance to use */
18
29
  logger: InternalLogger;
30
+ /** Name of this host */
19
31
  hostname?: string;
32
+ /** Namespace of this client */
20
33
  namespace?: string;
34
+ /** Default ACL applied to newly created objects */
21
35
  defaultNewAcl?: ACLObject;
36
+ /** Namespace used for meta-information */
22
37
  metaNamespace?: string;
38
+ /** Redis key prefix (defaults to "cfg") */
23
39
  redisNamespace?: string;
40
+ /** Connection options for the redis server */
24
41
  connection: RedisConnectionOptions;
25
42
  }
26
- interface CallOptions {
27
- groups?: string[];
28
- group?: string;
29
- user?: ioBroker.ObjectIDs.User;
30
- owner?: ioBroker.ObjectIDs.User;
31
- ownerGroup?: string;
32
- acl?: any;
33
- [other: string]: any;
34
- }
35
- interface WriteFileOptions extends CallOptions {
36
- mimeType?: string;
37
- }
38
- interface Options {
39
- /** The user id for database operations */
40
- user?: string;
41
- [other: string]: unknown;
42
- }
43
- type CheckFileCallback = (checkFailed: boolean, options?: CallOptions, fileOptions?: {
44
- notExists: boolean;
45
- }) => void;
43
+ /**
44
+ * Client for the objects database backed by Redis (or the in-memory redis-protocol server)
45
+ */
46
46
  export declare class ObjectsInRedisClient {
47
47
  private client;
48
48
  private readonly fileNamespace;
@@ -69,222 +69,1058 @@ export declare class ObjectsInRedisClient {
69
69
  private noLegacyMultihost?;
70
70
  private readonly userSubscriptions;
71
71
  private readonly systemSubscriptions;
72
+ /**
73
+ * @param settings Settings for the objects client including connection and namespaces
74
+ */
72
75
  constructor(settings: ObjectsSettings);
73
76
  /**
74
77
  * Checks if we are allowed to start and sets the protocol version accordingly
75
78
  */
76
79
  private _determineProtocolVersion;
80
+ /**
81
+ * Connect to the objects database and set up the change and file subscriptions
82
+ */
77
83
  connectDb(): void;
84
+ /**
85
+ * Get the current status of the database
86
+ */
78
87
  getStatus(): DbStatus;
79
88
  /**
80
89
  * Checks if given ID is a meta-object, else throws error
81
90
  *
82
91
  * @param id to check
83
- * @throws Error if id is invalid
92
+ * @throws {Error} if id is invalid
84
93
  */
85
94
  validateMetaObject(id: string): Promise<void>;
95
+ /**
96
+ * Normalize a file name by collapsing slashes and backslashes into a single forward slash
97
+ *
98
+ * @param name The file name to normalize
99
+ */
86
100
  normalizeFilename(name: string): string;
87
101
  /**
88
102
  * Sets a buffer to the Redis DB
89
103
  *
90
- * @param id id of the file
104
+ * @param id ID of the file
91
105
  * @param data content, if string is passed it will be converted to a Buffer
92
106
  */
93
107
  private _setBinaryState;
94
108
  /**
95
- * get buffer of given id from redis
109
+ * Get a buffer of a given ID from redis
96
110
  *
97
111
  * @param id - id of the data with namespace prefix
98
112
  */
99
113
  private _getBinaryState;
100
114
  /**
101
- * deletes binary state of given id from redis db
115
+ * deletes binary state of a given ID from redis db
102
116
  *
103
117
  * @param id - id to delete, with namespace prefix
104
118
  */
105
119
  private _delBinaryState;
120
+ /**
121
+ * Build the internal redis key for a file
122
+ *
123
+ * @param id The ID of the object owning the file
124
+ * @param name The file name
125
+ * @param isMeta Whether to return the key of the meta-entry (true) or the data entry (false)
126
+ */
106
127
  getFileId(id: string, name: string, isMeta?: boolean): string;
107
- checkFile(id: string, name: string, options: CallOptions, flag: any, callback?: CheckFileCallback): Promise<ioBroker.CallbackReturnTypeOf<CheckFileCallback> | void>;
108
- checkFileRights(id: string, name: string | null, options?: CallOptions | null, flag?: any, callback?: CheckFileRightsCallback): void;
128
+ /**
129
+ * Check whether the current options have the required rights on a file
130
+ *
131
+ * @param id The id of the object owning the file
132
+ * @param name The file name
133
+ * @param userContext The resolved user context used for permission checks
134
+ * @param flag The access flag(s) to check for
135
+ */
136
+ checkFileAsync(id: string, name: string | null, userContext: UserContext, flag: CONSTS.GenericAccessFlags): Promise<FileObject | null>;
137
+ /**
138
+ * Check whether the current user is allowed to access a file
139
+ *
140
+ * @param id The id of the object owning the file
141
+ * @param name The file name, or null for the whole namespace
142
+ * @param options The current request options including the user
143
+ * @param flag The access flag(s) to check for
144
+ * @param callback Called with the effective options once the rights have been checked
145
+ */
146
+ checkFileRights(id: string, name: string | null, options: {
147
+ user?: ioBroker.ObjectIDs.User;
148
+ } | null | undefined, flag: CONSTS.GenericAccessFlags, callback: (err: Error | string | null | undefined, fileOptions?: FileObject, userContext?: {
149
+ user: ioBroker.ObjectIDs.User;
150
+ group: ioBroker.ObjectIDs.Group;
151
+ groups: ioBroker.ObjectIDs.Group[];
152
+ acl: ioBroker.ObjectPermissions;
153
+ checked?: boolean;
154
+ }) => void): void;
109
155
  private _setDefaultAcl;
156
+ /**
157
+ * Set the default ACL applied to new objects and apply it to all existing objects without an ACL
158
+ *
159
+ * @param defaultNewAcl The default ACL to use, or null to use the built-in default
160
+ */
110
161
  setDefaultAcl(defaultNewAcl: ACLObject | null): Promise<void>;
111
- getUserGroup(user: ioBroker.ObjectIDs.User, callback: GetUserGroupCallbackNoError): Promise<GetUserGroupPromiseReturn> | void;
162
+ /**
163
+ * Determine the groups and effective ACL of the given user
164
+ *
165
+ * @param user The id of the user to look up
166
+ * @param callback Called with the user, its groups, and the effective ACL
167
+ */
168
+ getUserGroup(user: ioBroker.ObjectIDs.User, callback: GetUserGroupCallbackNoError): void;
112
169
  private _writeFile;
113
- writeFile(id: string, name: string, data: any, callback?: ioBroker.ErrorCallback): Promise<void>;
114
- writeFile(id: string, name: string, data: any, options?: WriteFileOptions | null, callback?: ioBroker.ErrorCallback): Promise<void>;
115
- writeFileAsync(id: string, name: string, data: any, options?: WriteFileOptions | null): Promise<void>;
170
+ /**
171
+ * Write data into a file of an object
172
+ *
173
+ * @param id The id of the object owning the file
174
+ * @param name The file name
175
+ * @param data The data to write
176
+ * @param callback Called once the file has been written
177
+ */
178
+ writeFile(id: string, name: string, data: string | Buffer | null | undefined, callback?: ioBroker.ErrorCallback): Promise<void>;
179
+ /**
180
+ * Write data into a file of an object
181
+ *
182
+ * @param id The id of the object owning the file
183
+ * @param name The file name
184
+ * @param data The data to write
185
+ * @param options The current request options including the user
186
+ * @param callback Called once the file has been written
187
+ */
188
+ writeFile(id: string, name: string, data: string | Buffer | null | undefined, options?: {
189
+ virtualFile?: boolean;
190
+ user?: ioBroker.ObjectIDs.User;
191
+ group?: ioBroker.ObjectIDs.Group;
192
+ mode?: number;
193
+ mimeType?: string;
194
+ } | null, callback?: ioBroker.ErrorCallback): Promise<void>;
195
+ /**
196
+ * Promise-version of writeFile
197
+ *
198
+ * @param id The ID of the object owning the file
199
+ * @param name The file name
200
+ * @param data The data to write
201
+ * @param options The current request options including the user
202
+ */
203
+ writeFileAsync(id: string, name: string, data: string | Buffer | null | undefined, options?: {
204
+ virtualFile?: boolean;
205
+ user?: ioBroker.ObjectIDs.User;
206
+ group?: ioBroker.ObjectIDs.Group;
207
+ mode?: number;
208
+ mimeType?: string;
209
+ } | null): Promise<void>;
116
210
  private _readFile;
117
- readFile(id: string, name: string, options?: CallOptions | null): ioBroker.ReadFilePromise;
118
- readFile(id: string, name: string, options: CallOptions | null | undefined, callback: ioBroker.ReadFileCallback): void;
119
211
  /**
120
- * Check if given object exists
212
+ * Read a file of an object
213
+ *
214
+ * @param id The ID of the object owning the file
215
+ * @param name The file name
216
+ * @param options The current request options including the user
217
+ */
218
+ readFile(id: string, name: string, options?: {
219
+ user?: ioBroker.ObjectIDs.User;
220
+ } | null): ioBroker.ReadFilePromise;
221
+ /**
222
+ * Read a file of an object
121
223
  *
122
- * @param id id of the object
224
+ * @param id The ID of the object owning the file
225
+ * @param name The file name
226
+ * @param options The current request options including the user
227
+ * @param callback Called with the file content and mime type
228
+ */
229
+ readFile(id: string, name: string, options: {
230
+ user?: ioBroker.ObjectIDs.User;
231
+ } | null | undefined, callback: ioBroker.ReadFileCallback): void;
232
+ /**
233
+ * Check if a given object exists
234
+ *
235
+ * @param id ID of the object
123
236
  * @param options optional user context
124
237
  */
125
- objectExists(id: string, options?: CallOptions | null): Promise<boolean>;
238
+ objectExists(id: string, options?: {
239
+ user?: ioBroker.ObjectIDs.User;
240
+ } | null): Promise<boolean>;
126
241
  /**
127
- * Check if given file exists
242
+ * Check if a given file exists
128
243
  *
129
- * @param id id of the namespace
244
+ * @param id ID of the namespace
130
245
  * @param name name of the file
131
246
  * @param options optional user context
132
247
  */
133
- fileExists(id: string, name: string, options?: CallOptions | null): Promise<boolean>;
248
+ fileExists(id: string, name: string, options?: {
249
+ user?: ioBroker.ObjectIDs.User;
250
+ } | null): Promise<boolean>;
134
251
  private _unlink;
135
- unlink(id: string, name: string, options: CallOptions | null | undefined, callback?: ioBroker.RmCallback): void;
136
- unlinkAsync(id: string, name: string, options?: CallOptions): Promise<void>;
137
- delFile(id: string, name: string, options: CallOptions, callback: ioBroker.ErrorCallback): void;
138
- delFileAsync(id: string, name: string, options: CallOptions): Promise<void>;
252
+ /**
253
+ * Delete a file or directory of an object
254
+ *
255
+ * @param id The id of the object owning the file
256
+ * @param name The file or directory name to delete
257
+ * @param options The current request options including the user, or the callback
258
+ * @param callback Called with the list of removed files
259
+ */
260
+ unlink(id: string, name: string, options: {
261
+ user?: ioBroker.ObjectIDs.User;
262
+ } | null | undefined, callback?: ioBroker.RmCallback): void;
263
+ /**
264
+ * Promise-version of unlink
265
+ *
266
+ * @param id The id of the object owning the file
267
+ * @param name The file or directory name to delete
268
+ * @param options The current request options including the user
269
+ */
270
+ unlinkAsync(id: string, name: string, options?: {
271
+ user?: ioBroker.ObjectIDs.User;
272
+ } | null): Promise<void>;
273
+ /**
274
+ * Delete a file of an object (alias for {@link unlink})
275
+ *
276
+ * @param id The id of the object owning the file
277
+ * @param name The file name to delete
278
+ * @param options The current request options including the user
279
+ * @param callback Called once the file has been deleted
280
+ */
281
+ delFile(id: string, name: string, options: {
282
+ user?: ioBroker.ObjectIDs.User;
283
+ } | null | undefined, callback: ioBroker.ErrorCallback): void;
284
+ /**
285
+ * Promise-version of delFile
286
+ *
287
+ * @param id The id of the object owning the file
288
+ * @param name The file name to delete
289
+ * @param options The current request options including the user
290
+ */
291
+ delFileAsync(id: string, name: string, options?: {
292
+ user?: ioBroker.ObjectIDs.User;
293
+ } | null): Promise<void>;
139
294
  private _readDir;
140
- readDir(id: string, name: string, options: CallOptions | null | undefined, callback: ioBroker.ReadDirCallback): void;
141
- readDirAsync(id: string, name: string, options?: CallOptions): ioBroker.ReadDirPromise;
295
+ /**
296
+ * List the contents of a directory of an object
297
+ *
298
+ * @param id The id of the object owning the files
299
+ * @param name The directory name to list
300
+ * @param options The current request options including the user, or the callback
301
+ * @param callback Called with the directory entries
302
+ */
303
+ readDir(id: string, name: string, options: {
304
+ user?: ioBroker.ObjectIDs.User;
305
+ } | null | undefined, callback: ioBroker.ReadDirCallback): void;
306
+ /**
307
+ * Promise-version of readDir
308
+ *
309
+ * @param id The id of the object owning the files
310
+ * @param name The directory name to list
311
+ * @param options The current request options including the user
312
+ */
313
+ readDirAsync(id: string, name: string, options?: {
314
+ user?: ioBroker.ObjectIDs.User;
315
+ } | null): ioBroker.ReadDirPromise;
142
316
  private _renameHelper;
143
317
  private _rename;
144
- rename(id: string, oldName: string, newName: string, options?: CallOptions | null, callback?: ioBroker.ErrorCallback): void | Promise<void>;
145
- renameAsync(id: string, oldName: string, newName: string, options: CallOptions): Promise<void>;
318
+ /**
319
+ * Rename a file or directory of an object
320
+ *
321
+ * @param id The id of the object owning the file
322
+ * @param oldName The current file or directory name
323
+ * @param newName The new file or directory name
324
+ * @param options The current request options including the user, or the callback
325
+ * @param callback Called once the file has been renamed
326
+ */
327
+ rename(id: string, oldName: string, newName: string, options?: {
328
+ user?: ioBroker.ObjectIDs.User;
329
+ } | null, callback?: ioBroker.ErrorCallback): void | Promise<void>;
330
+ /**
331
+ * Promise-version of rename
332
+ *
333
+ * @param id The id of the object owning the file
334
+ * @param oldName The current file or directory name
335
+ * @param newName The new file or directory name
336
+ * @param options The current request options including the user
337
+ * @param options.user The user on whose behalf the operation is performed
338
+ */
339
+ renameAsync(id: string, oldName: string, newName: string, options: {
340
+ user?: ioBroker.ObjectIDs.User;
341
+ }): Promise<void>;
146
342
  private _touch;
147
- touch(id: string, name: string, options: CallOptions | null, callback: ioBroker.ErrorCallback): void;
148
- touchAsync(id: string, name: string, options: CallOptions): Promise<void>;
343
+ /**
344
+ * Update the modification time of a file
345
+ *
346
+ * @param id The id of the object owning the file
347
+ * @param name The file name
348
+ * @param options The current request options including the user, or the callback
349
+ * @param callback Called once the file has been touched
350
+ */
351
+ touch(id: string, name: string, options: {
352
+ user?: ioBroker.ObjectIDs.User;
353
+ } | null, callback: ioBroker.ErrorCallback): void;
354
+ /**
355
+ * Promise-version of touch
356
+ *
357
+ * @param id The id of the object owning the file
358
+ * @param name The file name
359
+ * @param options The current request options including the user
360
+ * @param options.user The user on whose behalf the operation is performed
361
+ */
362
+ touchAsync(id: string, name: string, options: {
363
+ user?: ioBroker.ObjectIDs.User;
364
+ }): Promise<void>;
149
365
  private _rmHelper;
150
366
  private _rm;
151
- rm(id: string, name: string, options: CallOptions | null, callback: ioBroker.RmCallback): void;
152
- rmAsync(id: string, name: string, options: CallOptions): Promise<void | ioBroker.RmResult[]>;
153
- mkdir(id: string, dirName?: string, options?: CallOptions | null, callback?: ioBroker.ErrorCallback): void;
154
- mkdirAsync(id: string, dirName?: string, options?: CallOptions): Promise<void>;
367
+ /**
368
+ * Delete a file or directory of an object
369
+ *
370
+ * @param id The id of the object owning the file
371
+ * @param name The file or directory name to delete
372
+ * @param options The current request options including the user, or the callback
373
+ * @param callback Called with the list of removed files
374
+ */
375
+ rm(id: string, name: string, options: {
376
+ user?: ioBroker.ObjectIDs.User;
377
+ } | null, callback: ioBroker.RmCallback): void;
378
+ /**
379
+ * Promise-version of rm
380
+ *
381
+ * @param id The id of the object owning the file
382
+ * @param name The file or directory name to delete
383
+ * @param options The current request options including the user
384
+ * @param options.user The user on whose behalf the operation is performed
385
+ */
386
+ rmAsync(id: string, name: string, options: {
387
+ user?: ioBroker.ObjectIDs.User;
388
+ }): Promise<void | ioBroker.RmResult[]>;
389
+ /**
390
+ * Create a directory for an object's files (simulated, as redis has no real directories)
391
+ *
392
+ * @param id The id of the object owning the files
393
+ * @param dirName The directory name to create
394
+ * @param options The current request options including the user, or the callback
395
+ * @param callback Called once the directory has been created
396
+ */
397
+ mkdir(id: string, dirName?: string, options?: {
398
+ user?: ioBroker.ObjectIDs.User;
399
+ mode?: number;
400
+ group?: ioBroker.ObjectIDs.Group;
401
+ } | null | ioBroker.ErrorCallback, callback?: ioBroker.ErrorCallback): void;
402
+ /**
403
+ * Promise-version of mkdir
404
+ *
405
+ * @param id The id of the object owning the files
406
+ * @param dirName The directory name to create
407
+ * @param options The current request options including the user
408
+ */
409
+ mkdirAsync(id: string, dirName?: string, options?: {
410
+ user?: ioBroker.ObjectIDs.User;
411
+ mode?: number;
412
+ group: ioBroker.ObjectIDs.Group;
413
+ } | null): Promise<void>;
155
414
  private _chownFileHelper;
156
415
  private _chownFile;
157
- chownFile(id: string, name: string, options: CallOptions, callback: ioBroker.ChownFileCallback): void;
158
- chownFileAsync(id: string, name: string, options: CallOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownFileCallback>>;
416
+ /**
417
+ * Change the owner and owner group of a file
418
+ *
419
+ * @param id The id of the object owning the file
420
+ * @param name The file name
421
+ * @param options The current request options including the new owner and the user
422
+ * @param options.owner The new owner (user id) to assign to the file
423
+ * @param options.user The user on whose behalf the operation is performed
424
+ * @param options.ownerGroup The new owner group to assign to the file
425
+ * @param options.group The new owner group to assign (alias for ownerGroup)
426
+ * @param callback Called with the processed file(s)
427
+ */
428
+ chownFile(id: string, name: string, options: {
429
+ owner: ioBroker.ObjectIDs.User;
430
+ user?: ioBroker.ObjectIDs.User;
431
+ ownerGroup?: ioBroker.ObjectIDs.Group;
432
+ group?: ioBroker.ObjectIDs.Group;
433
+ }, callback: ioBroker.ChownFileCallback): void;
434
+ /**
435
+ * Promise-version of chownFile
436
+ *
437
+ * @param id The id of the object owning the file
438
+ * @param name The file name
439
+ * @param options The current request options including the new owner and the user
440
+ * @param options.user The user on whose behalf the operation is performed
441
+ * @param options.owner The new owner (user id) to assign to the file
442
+ * @param options.ownerGroup The new owner group to assign to the file
443
+ */
444
+ chownFileAsync(id: string, name: string, options: {
445
+ user?: ioBroker.ObjectIDs.User;
446
+ owner: ioBroker.ObjectIDs.User;
447
+ ownerGroup?: ioBroker.ObjectIDs.Group;
448
+ }): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownFileCallback>>;
159
449
  /**
160
450
  *
161
451
  * @param keys Key names to handle
162
452
  * @param metas Objects for the keys to handle
163
453
  * @param options options
454
+ * @param options.user The user on whose behalf the operation is performed
455
+ * @param options.mode The new permission mode to apply
164
456
  * @param callback callback function
165
457
  */
166
458
  private _chmodFileHelper;
167
459
  private _chmodFile;
168
- chmodFile(id: string, name: string, options: CallOptions | null, callback: ioBroker.ChownFileCallback): void;
169
- chmodFileAsync(id: string, name: string, options: CallOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownFileCallback>>;
460
+ /**
461
+ * Change the file mode (permissions) of a single file
462
+ *
463
+ * @param id The id of the object owning the file
464
+ * @param name The file name
465
+ * @param options The current request options including the new mode and the user, or the callback
466
+ * @param options.user The user on whose behalf the operation is performed
467
+ * @param options.mode The new permission mode to apply
468
+ * @param callback Called with the processed file
469
+ */
470
+ chmodFile(id: string, name: string, options: {
471
+ user?: ioBroker.ObjectIDs.User;
472
+ mode: number;
473
+ }, callback: ioBroker.ChownFileCallback): void;
474
+ /**
475
+ * Promise-version of chmodFile
476
+ *
477
+ * @param id The id of the object owning the file
478
+ * @param name The file name
479
+ * @param options The current request options including the new mode and the user
480
+ * @param options.user The user on whose behalf the operation is performed
481
+ * @param options.mode The new permission mode to apply
482
+ */
483
+ chmodFileAsync(id: string, name: string, options: {
484
+ user?: ioBroker.ObjectIDs.User;
485
+ mode: number;
486
+ }): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownFileCallback>>;
487
+ /**
488
+ * Enable or disable the file cache
489
+ *
490
+ * @param enabled Whether the file cache should be enabled
491
+ * @param callback Called with the resulting cache state
492
+ */
170
493
  enableFileCache(enabled: boolean, callback?: (err: Error | null | undefined, res: boolean) => void): void;
171
- enableFileCache(enabled: boolean, options?: CallOptions, callback?: (err: Error | null | undefined, res: boolean) => void): void;
172
- enableFileCacheAsync(enabled: boolean, options?: CallOptions): Promise<boolean>;
494
+ /**
495
+ * Enable or disable the file cache
496
+ *
497
+ * @param enabled Whether the file cache should be enabled
498
+ * @param options The current request options including the user
499
+ * @param callback Called with the resulting cache state
500
+ */
501
+ enableFileCache(enabled: boolean, options?: {
502
+ user?: ioBroker.ObjectIDs.User;
503
+ } | null | ((err: Error | null | undefined, res: boolean) => void), callback?: (err: Error | null | undefined, res: boolean) => void): void;
504
+ /**
505
+ * Promise-version of enableFileCache
506
+ *
507
+ * @param enabled Whether the file cache should be enabled
508
+ * @param options The current request options including the user
509
+ */
510
+ enableFileCacheAsync(enabled: boolean, options?: {
511
+ user?: ioBroker.ObjectIDs.User;
512
+ } | null): Promise<boolean>;
173
513
  private _subscribeFile;
174
514
  private _unsubscribeFile;
175
- subscribeUserFile(id: string, pattern: string | string[], options?: CallOptions | null): Promise<void>;
176
- unsubscribeUserFile(id: string, pattern: string | string[], options?: CallOptions | null): Promise<void>;
515
+ /**
516
+ * Subscribe a user to file changes of an object
517
+ *
518
+ * @param id The id of the object owning the files
519
+ * @param pattern One or more file name patterns to subscribe to
520
+ * @param options The current request options including the user
521
+ */
522
+ subscribeUserFile(id: string, pattern: string | string[], options?: {
523
+ user?: ioBroker.ObjectIDs.User;
524
+ } | null): Promise<void>;
525
+ /**
526
+ * Unsubscribe a user from file changes of an object
527
+ *
528
+ * @param id The id of the object owning the files
529
+ * @param pattern One or more file name patterns to unsubscribe from
530
+ * @param options The current request options including the user
531
+ */
532
+ unsubscribeUserFile(id: string, pattern: string | string[], options?: {
533
+ user?: ioBroker.ObjectIDs.User;
534
+ } | null): Promise<void>;
177
535
  private _subscribe;
178
536
  private subscribeConfig;
537
+ /**
538
+ * Subscribe to object changes matching the given pattern
539
+ *
540
+ * @param pattern One or more patterns to subscribe to
541
+ * @param callback Called once the subscription is registered
542
+ */
179
543
  subscribe(pattern: string | string[], callback?: ioBroker.ErrorCallback): void;
180
- subscribe(pattern: string | string[], options?: CallOptions, callback?: ioBroker.ErrorCallback): void;
181
- subscribeAsync(pattern: string | string[], options?: CallOptions): Promise<void>;
544
+ /**
545
+ * Subscribe to object changes matching the given pattern
546
+ *
547
+ * @param pattern One or more patterns to subscribe to
548
+ * @param options The current request options including the user
549
+ * @param callback Called once the subscription is registered
550
+ */
551
+ subscribe(pattern: string | string[], options?: {
552
+ user?: ioBroker.ObjectIDs.User;
553
+ } | null, callback?: ioBroker.ErrorCallback): void;
554
+ /**
555
+ * Promise-version of subscribe
556
+ *
557
+ * @param pattern One or more patterns to subscribe to
558
+ * @param options The current request options including the user
559
+ */
560
+ subscribeAsync(pattern: string | string[], options?: {
561
+ user?: ioBroker.ObjectIDs.User;
562
+ } | null): Promise<void>;
563
+ /**
564
+ * Subscribe a user to object changes matching the given pattern
565
+ *
566
+ * @param pattern One or more patterns to subscribe to
567
+ * @param callback Called once the subscription is registered
568
+ */
182
569
  subscribeUser(pattern: string | string[], callback?: ioBroker.ErrorCallback): void;
183
- subscribeUser(pattern: string | string[], options?: CallOptions | null, callback?: ioBroker.ErrorCallback): void;
184
- subscribeUserAsync(pattern: string | string[], options: CallOptions): Promise<void>;
570
+ /**
571
+ * Subscribe a user to object changes matching the given pattern
572
+ *
573
+ * @param pattern One or more patterns to subscribe to
574
+ * @param options The current request options including the user
575
+ * @param callback Called once the subscription is registered
576
+ */
577
+ subscribeUser(pattern: string | string[], options?: {
578
+ user?: ioBroker.ObjectIDs.User;
579
+ } | null, callback?: ioBroker.ErrorCallback): void;
580
+ /**
581
+ * Promise-version of subscribeUser
582
+ *
583
+ * @param pattern One or more patterns to subscribe to
584
+ * @param options The current request options including the user
585
+ */
586
+ subscribeUserAsync(pattern: string | string[], options: {
587
+ user?: ioBroker.ObjectIDs.User;
588
+ } | null): Promise<void>;
185
589
  private _unsubscribe;
186
590
  private unsubscribeConfig;
591
+ /**
592
+ * Unsubscribe from object changes matching the given pattern
593
+ *
594
+ * @param pattern One or more patterns to unsubscribe from
595
+ * @param callback Called once the subscription is removed
596
+ */
187
597
  unsubscribe(pattern: string | string[], callback?: ioBroker.ErrorCallback): void;
188
- unsubscribe(pattern: string | string[], options?: CallOptions | null, callback?: ioBroker.ErrorCallback): void;
189
- unsubscribeAsync(pattern: string | string[], options: CallOptions): Promise<void>;
190
- unsubscribeUser(pattern: string | string[], options?: CallOptions | null, callback?: ioBroker.ErrorCallback): void;
191
- unsubscribeUserAsync(pattern: string | string[], options: CallOptions): Promise<void>;
598
+ /**
599
+ * Unsubscribe from object changes matching the given pattern
600
+ *
601
+ * @param pattern One or more patterns to unsubscribe from
602
+ * @param options The current request options including the user
603
+ * @param callback Called once the subscription is removed
604
+ */
605
+ unsubscribe(pattern: string | string[], options?: {
606
+ user?: ioBroker.ObjectIDs.User;
607
+ } | null, callback?: ioBroker.ErrorCallback): void;
608
+ /**
609
+ * Promise-version of unsubscribe
610
+ *
611
+ * @param pattern One or more patterns to unsubscribe from
612
+ * @param options The current request options including the user
613
+ */
614
+ unsubscribeAsync(pattern: string | string[], options?: {
615
+ user?: ioBroker.ObjectIDs.User;
616
+ } | null): Promise<void>;
617
+ /**
618
+ * Unsubscribe a user from object changes matching the given pattern
619
+ *
620
+ * @param pattern One or more patterns to unsubscribe from
621
+ * @param options The current request options including the user, or the callback
622
+ * @param callback Called once the subscription is removed
623
+ */
624
+ unsubscribeUser(pattern: string | string[], options?: {
625
+ user?: ioBroker.ObjectIDs.User;
626
+ } | null, callback?: ioBroker.ErrorCallback): void;
627
+ /**
628
+ * Promise-version of unsubscribeUser
629
+ *
630
+ * @param pattern One or more patterns to unsubscribe from
631
+ * @param options The current request options including the user
632
+ */
633
+ unsubscribeUserAsync(pattern: string | string[], options?: {
634
+ user?: ioBroker.ObjectIDs.User;
635
+ } | null): Promise<void>;
192
636
  private _objectHelper;
193
637
  private _chownObject;
194
- chownObject(pattern: string, options: CallOptions, callback?: ioBroker.ChownObjectCallback): void | Promise<void>;
195
- chownObjectAsync(pattern: string, options: CallOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownObjectCallback>>;
638
+ /**
639
+ * Change the owner and owner group of all objects matching the given pattern
640
+ *
641
+ * @param pattern The pattern of object ids whose owner should be changed
642
+ * @param options The current request options including the new owner and the user, or the callback
643
+ * @param options.user The user on whose behalf the operation is performed
644
+ * @param options.owner The new owner (user id) to assign to the objects
645
+ * @param options.ownerGroup The new owner group to assign to the objects
646
+ * @param options.group The new owner group to assign (alias for ownerGroup)
647
+ * @param callback Called with the list of changed objects
648
+ */
649
+ chownObject(pattern: string, options: {
650
+ user?: ioBroker.ObjectIDs.User;
651
+ owner: ioBroker.ObjectIDs.User;
652
+ ownerGroup?: ioBroker.ObjectIDs.Group;
653
+ group?: ioBroker.ObjectIDs.Group;
654
+ }, callback?: ioBroker.ChownObjectCallback): void | Promise<void>;
655
+ /**
656
+ * Promise-version of chownObject
657
+ *
658
+ * @param pattern The pattern of object ids whose owner should be changed
659
+ * @param options The current request options including the new owner and the user
660
+ * @param options.user The user on whose behalf the operation is performed
661
+ * @param options.owner The new owner (user id) to assign to the objects
662
+ * @param options.ownerGroup The new owner group to assign to the objects
663
+ * @param options.group The new owner group to assign (alias for ownerGroup)
664
+ */
665
+ chownObjectAsync(pattern: string, options: {
666
+ user?: ioBroker.ObjectIDs.User;
667
+ owner: ioBroker.ObjectIDs.User;
668
+ ownerGroup?: ioBroker.ObjectIDs.Group;
669
+ group?: ioBroker.ObjectIDs.Group;
670
+ }): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownObjectCallback>>;
196
671
  private _chmodObject;
197
- chmodObject(pattern: string, options: CallOptions | null, callback?: ioBroker.ChownObjectCallback): void | Promise<void>;
198
- chmodObjectAsync(pattern: string, options: CallOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownObjectCallback>>;
672
+ /**
673
+ * Change the file mode (permissions) of all files matching the given pattern
674
+ *
675
+ * @param pattern The pattern of object ids whose files should be changed
676
+ * @param options The current request options including the new mode and the user, or the callback
677
+ * @param options.mode The new permission mode to apply
678
+ * @param options.user The user on whose behalf the operation is performed
679
+ * @param options.object The permission bitmask for object access
680
+ * @param options.state The permission bitmask for state access
681
+ * @param callback Called with the list of changed objects
682
+ */
683
+ chmodObject(pattern: string, options: {
684
+ mode?: number;
685
+ user?: ioBroker.ObjectIDs.User;
686
+ object?: number;
687
+ state?: number;
688
+ }, callback?: ioBroker.ChownObjectCallback): void | Promise<void>;
689
+ /**
690
+ * Promise-version of chmodObject
691
+ *
692
+ * @param pattern The pattern of object ids whose files should be changed
693
+ * @param options The current request options including the new mode and the user
694
+ * @param options.mode The new permission mode to apply
695
+ * @param options.user The user on whose behalf the operation is performed
696
+ * @param options.object The permission bitmask for object access
697
+ * @param options.state The permission bitmask for state access
698
+ */
699
+ chmodObjectAsync(pattern: string, options: {
700
+ mode?: number;
701
+ user?: ioBroker.ObjectIDs.User;
702
+ object?: number;
703
+ state?: number;
704
+ }): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ChownObjectCallback>>;
199
705
  private _getObject;
200
- getObject<T extends string>(id: T, options: Options | undefined | null, callback: ioBroker.GetObjectCallback<T>): void;
201
- getObject<T extends string>(id: T, options?: Options | null): ioBroker.GetObjectPromise<T>;
706
+ /**
707
+ * Get a single object by its id
708
+ *
709
+ * @param id The id of the object to read
710
+ * @param options The current request options including the user
711
+ * @param callback Called with the read object
712
+ */
713
+ getObject<T extends string>(id: T, options: {
714
+ user?: ioBroker.ObjectIDs.User;
715
+ } | undefined | null, callback: ioBroker.GetObjectCallback<T>): void;
716
+ /**
717
+ * Get a single object by its id
718
+ *
719
+ * @param id The id of the object to read
720
+ * @param options The current request options including the user
721
+ */
722
+ getObject<T extends string>(id: T, options?: {
723
+ user?: ioBroker.ObjectIDs.User;
724
+ } | null): ioBroker.GetObjectPromise<T>;
725
+ /**
726
+ * Get a single object by its id
727
+ *
728
+ * @param id The id of the object to read
729
+ * @param callback Called with the read object
730
+ */
202
731
  getObject<T extends string>(id: T, callback: ioBroker.GetObjectCallback<T>): void;
203
732
  /**
733
+ * Promise-version of getObject
204
734
  *
205
- * @param id
206
- * @param options
735
+ * @param id The id of the object to read
736
+ * @param options The current request options including the user
207
737
  * @deprecated use `getObject` without callback instead
208
738
  */
209
- getObjectAsync<T extends string>(id: T, options?: Record<string, any> | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetObjectCallback<T>>>;
739
+ getObjectAsync<T extends string>(id: T, options?: {
740
+ user?: ioBroker.ObjectIDs.User;
741
+ } | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetObjectCallback<T>>>;
210
742
  private _getKeys;
211
- getKeys(pattern: string, options: CallOptions | null | undefined, callback: ioBroker.GetKeysCallback, dontModify?: boolean): void;
743
+ /**
744
+ * Get all object ids matching the given pattern
745
+ *
746
+ * @param pattern The pattern to match object ids against
747
+ * @param options The current request options including the user
748
+ * @param callback Called with the matching keys
749
+ * @param dontModify If true, the returned keys are not stripped of the namespace
750
+ */
751
+ getKeys(pattern: string, options: {
752
+ user?: ioBroker.ObjectIDs.User;
753
+ } | null | undefined, callback: ioBroker.GetKeysCallback, dontModify?: boolean): void;
754
+ /**
755
+ * Get all object ids matching the given pattern
756
+ *
757
+ * @param pattern The pattern to match object ids against
758
+ * @param callback Called with the matching keys
759
+ */
212
760
  getKeys(pattern: string, callback: ioBroker.GetKeysCallback): void;
213
- getKeys(pattern: string, options?: CallOptions | null, callback?: undefined, dontModify?: boolean): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetKeysCallback>>;
214
- getKeysAsync(id: string, options?: CallOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetKeysCallback>>;
761
+ /**
762
+ * Get all object ids matching the given pattern
763
+ *
764
+ * @param pattern The pattern to match object ids against
765
+ * @param options The current request options including the user
766
+ * @param callback Must be undefined for the promise variant
767
+ * @param dontModify If true, the returned keys are not stripped of the namespace
768
+ */
769
+ getKeys(pattern: string, options?: {
770
+ user?: ioBroker.ObjectIDs.User;
771
+ } | null, callback?: undefined, dontModify?: boolean): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetKeysCallback>>;
772
+ /**
773
+ * Promise-version of getKeys
774
+ *
775
+ * @param pattern The pattern to match object ids against
776
+ * @param options The current request options including the user
777
+ * @param options.user The user on whose behalf the keys are read
778
+ */
779
+ getKeysAsync(pattern: string, options?: {
780
+ user?: ioBroker.ObjectIDs.User;
781
+ }): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.GetKeysCallback>>;
215
782
  private _getObjects;
216
- getObjects(keys: string[], options?: CallOptions | null): Promise<ioBroker.AnyObject[]>;
217
- getObjects(keys: string[], callback: (err?: Error | null, objs?: ioBroker.AnyObject[]) => void): void;
218
- getObjects(keys: string[], options: CallOptions | null, callback: (err?: Error | null, objs?: ioBroker.AnyObject[]) => void, dontModify?: boolean): void;
219
- getObjectsAsync(keys: string[], options?: CallOptions | null): Promise<ioBroker.AnyObject[]>;
783
+ /**
784
+ * Get multiple objects by their ids
785
+ *
786
+ * @param keys The ids of the objects to read
787
+ * @param options The current request options including the user
788
+ */
789
+ getObjects(keys: string[], options?: {
790
+ user?: ioBroker.ObjectIDs.User;
791
+ } | null): Promise<ioBroker.AnyObject[]>;
792
+ /**
793
+ * Get multiple objects by their ids
794
+ *
795
+ * @param keys The ids of the objects to read
796
+ * @param callback Called with the read objects
797
+ */
798
+ getObjects(keys: string[], callback: (err?: Error | null, objs?: ({
799
+ error: string;
800
+ } | ioBroker.AnyObject | null)[]) => void): void;
801
+ /**
802
+ * Get multiple objects by their ids
803
+ *
804
+ * @param keys The ids of the objects to read
805
+ * @param options The current request options including the user
806
+ * @param callback Called with the read objects
807
+ * @param dontModify If true, the returned objects are not cloned/modified
808
+ */
809
+ getObjects(keys: string[], options: {
810
+ user?: ioBroker.ObjectIDs.User;
811
+ } | null | undefined, callback: (err?: Error | null, objs?: ({
812
+ error: string;
813
+ } | ioBroker.AnyObject | null)[]) => void, dontModify?: boolean): void;
814
+ /**
815
+ * Promise-version of getObjects
816
+ *
817
+ * @param keys The ids of the objects to read
818
+ * @param options The current request options including the user
819
+ */
820
+ getObjectsAsync(keys: string[], options?: {
821
+ user?: ioBroker.ObjectIDs.User;
822
+ } | null): Promise<ioBroker.AnyObject[]>;
220
823
  private _getObjectsByPattern;
221
- getObjectsByPattern(pattern: string, options: CallOptions | null): Promise<ioBroker.AnyObject[] | void>;
222
- getObjectsByPattern(pattern: string, options: CallOptions | null, callback: (err?: Error | null, objs?: ioBroker.AnyObject[]) => void): void;
223
- getObjectsByPatternAsync(pattern: string, options: CallOptions): Promise<ioBroker.AnyObject[] | void>;
824
+ /**
825
+ * Get all objects whose id matches the given pattern
826
+ *
827
+ * @param pattern The pattern to match object ids against
828
+ * @param options The current request options including the user
829
+ */
830
+ getObjectsByPattern(pattern: string, options: {
831
+ user?: ioBroker.ObjectIDs.User;
832
+ } | null): Promise<ioBroker.AnyObject[] | void>;
833
+ /**
834
+ * Get all objects whose id matches the given pattern
835
+ *
836
+ * @param pattern The pattern to match object ids against
837
+ * @param options The current request options including the user
838
+ * @param callback Called with the matching objects
839
+ */
840
+ getObjectsByPattern(pattern: string, options: {
841
+ user?: ioBroker.ObjectIDs.User;
842
+ } | null, callback: (err?: Error | null, objs?: ({
843
+ error: string;
844
+ } | ioBroker.AnyObject | null)[]) => void): void;
845
+ /**
846
+ * Promise-version of getObjectsByPattern
847
+ *
848
+ * @param pattern The pattern to match object ids against
849
+ * @param options The current request options including the user
850
+ * @param options.user The user on whose behalf the objects are read
851
+ */
852
+ getObjectsByPatternAsync(pattern: string, options: {
853
+ user?: ioBroker.ObjectIDs.User;
854
+ }): Promise<({
855
+ error: string;
856
+ } | ioBroker.AnyObject | null)[] | void>;
224
857
  private _setObject;
225
- setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
226
- setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>, callback?: ioBroker.SetObjectCallback): void | Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
227
- setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>, options?: CallOptions | null, callback?: ioBroker.SetObjectCallback): void | Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
228
858
  /**
859
+ * Set anew or update an object
860
+ *
861
+ * @param id ID of the object
862
+ * @param obj The object to write
863
+ * @param options options for access control are optional
864
+ */
865
+ setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>, options?: {
866
+ user?: ioBroker.ObjectIDs.User;
867
+ } | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
868
+ /**
869
+ * Set anew or update an object
870
+ *
871
+ * @param id ID of the object
872
+ * @param obj The object to write
873
+ * @param options options for access control are optional
874
+ * @param callback return function
875
+ */
876
+ setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>, options: {
877
+ user?: ioBroker.ObjectIDs.User;
878
+ } | undefined | null, callback: ioBroker.SetObjectCallback): void;
879
+ /**
880
+ * Set anew or update an object
229
881
  *
230
- * @param id
231
- * @param obj
232
- * @param options
882
+ * @param id ID of the object
883
+ * @param obj The object to write
884
+ * @param callback return function
885
+ */
886
+ setObject<T extends string>(id: T, obj: ioBroker.SettableObject<ioBroker.ObjectIdToObjectType<T>>, callback: ioBroker.SetObjectCallback): void;
887
+ /**
888
+ * Promise-version of setObject
889
+ *
890
+ * @param id ID of the object
891
+ * @param obj The object to write
892
+ * @param options options for access control are optional
233
893
  * @deprecated use `setObject` without callback instead
234
894
  */
235
- setObjectAsync(id: string, obj: ioBroker.SettableObject, options?: CallOptions | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
895
+ setObjectAsync(id: string, obj: ioBroker.SettableObject, options?: {
896
+ user?: ioBroker.ObjectIDs.User;
897
+ } | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.SetObjectCallback>>;
236
898
  private _delObject;
899
+ /**
900
+ * Delete an object
901
+ *
902
+ * @param id The id of the object to delete
903
+ * @param callback Called once the object has been deleted
904
+ */
237
905
  delObject(id: string, callback: ioBroker.ErrorCallback): void;
238
- delObject(id: string, options: CallOptions | null, callback: ioBroker.ErrorCallback): void;
239
- delObject(id: string, options?: CallOptions | null): Promise<void>;
240
- delObjectAsync(id: string, options?: CallOptions): Promise<void>;
241
906
  /**
242
- * Function to checks if comparisons will work according to the configured Locale
907
+ * Delete an object
908
+ *
909
+ * @param id The id of the object to delete
910
+ * @param options The current request options including the user
911
+ * @param callback Called once the object has been deleted
912
+ */
913
+ delObject(id: string, options: {
914
+ user?: ioBroker.ObjectIDs.User;
915
+ } | null | undefined, callback: ioBroker.ErrorCallback): void;
916
+ /**
917
+ * Delete an object
918
+ *
919
+ * @param id The id of the object to delete
920
+ * @param options The current request options including the user
921
+ */
922
+ delObject(id: string, options?: {
923
+ user?: ioBroker.ObjectIDs.User;
924
+ } | null): Promise<void>;
925
+ /**
926
+ * Promise-version of delObject
927
+ *
928
+ * @param id The id of the object to delete
929
+ * @param options The current request options including the user
930
+ * @param options.user The user on whose behalf the operation is performed
931
+ */
932
+ delObjectAsync(id: string, options?: {
933
+ user?: ioBroker.ObjectIDs.User;
934
+ }): Promise<void>;
935
+ /**
936
+ * Function to check if comparisons will work according to the configured Locale
243
937
  */
244
938
  isSystemLocaleSupported(): Promise<boolean>;
245
939
  private _applyViewFunc;
246
940
  private _getObjectView;
247
- getObjectView<Design extends string = string, Search extends string = string>(design: Design, search: Search, params?: ioBroker.GetObjectViewParams, options?: CallOptions | null): ioBroker.GetObjectViewPromise<ioBroker.InferGetObjectViewItemType<Design, Search>>;
248
- getObjectView<Design extends string = string, Search extends string = string>(design: Design, search: Search, params: ioBroker.GetObjectViewParams | undefined, options: CallOptions | undefined | null, callback: ioBroker.GetObjectViewCallback<ioBroker.InferGetObjectViewItemType<Design, Search>>): void;
941
+ /**
942
+ * Run a predefined object view (design document) and return the matching rows
943
+ *
944
+ * @param design The design document name
945
+ * @param search The view name within the design document
946
+ * @param params Query parameters such as startkey and endkey
947
+ * @param options The current request options including the user
948
+ */
949
+ getObjectView<Design extends string = string, Search extends string = string>(design: Design, search: Search, params?: ioBroker.GetObjectViewParams, options?: {
950
+ user?: ioBroker.ObjectIDs.User;
951
+ } | null): ioBroker.GetObjectViewPromise<ioBroker.InferGetObjectViewItemType<Design, Search>>;
952
+ /**
953
+ * Run a predefined object view (design document) and return the matching rows
954
+ *
955
+ * @param design The design document name
956
+ * @param search The view name within the design document
957
+ * @param params Query parameters such as startkey and endkey
958
+ * @param options The current request options including the user
959
+ * @param callback Called with the matching rows
960
+ */
961
+ getObjectView<Design extends string = string, Search extends string = string>(design: Design, search: Search, params: ioBroker.GetObjectViewParams | undefined, options: {
962
+ user?: ioBroker.ObjectIDs.User;
963
+ } | undefined | null, callback: ioBroker.GetObjectViewCallback<ioBroker.InferGetObjectViewItemType<Design, Search>>): void;
964
+ /**
965
+ * Run a predefined object view (design document) and return the matching rows
966
+ *
967
+ * @param design The design document name
968
+ * @param search The view name within the design document
969
+ * @param params Query parameters such as startkey and endkey
970
+ * @param callback Called with the matching rows
971
+ */
249
972
  getObjectView<Design extends string = string, Search extends string = string>(design: Design, search: Search, params: ioBroker.GetObjectViewParams, callback: ioBroker.GetObjectViewCallback<ioBroker.InferGetObjectViewItemType<Design, Search>>): void;
250
- getObjectViewAsync<Design extends string = string, Search extends string = string>(design: Design, search: Search, params?: ioBroker.GetObjectViewParams, options?: CallOptions): ioBroker.GetObjectViewPromise<ioBroker.InferGetObjectViewItemType<Design, Search>>;
973
+ /**
974
+ * Promise-version of getObjectView
975
+ *
976
+ * @param design The design document name
977
+ * @param search The view name within the design document
978
+ * @param params Query parameters such as startkey and endkey
979
+ * @param options The current request options including the user
980
+ * @param options.user The user on whose behalf the view is queried
981
+ */
982
+ getObjectViewAsync<Design extends string = string, Search extends string = string>(design: Design, search: Search, params?: ioBroker.GetObjectViewParams, options?: {
983
+ user?: ioBroker.ObjectIDs.User;
984
+ }): ioBroker.GetObjectViewPromise<ioBroker.InferGetObjectViewItemType<Design, Search>>;
251
985
  private _getObjectList;
986
+ /**
987
+ * Get the list of objects matching the given parameters
988
+ *
989
+ * @param params Query parameters such as startkey and endkey
990
+ */
252
991
  getObjectList(params: ioBroker.GetObjectListParams): ioBroker.GetObjectListPromise;
253
- getObjectList(params: ioBroker.GetObjectListParams, options?: CallOptions | null): ioBroker.GetObjectListPromise;
992
+ /**
993
+ * Get the list of objects matching the given parameters
994
+ *
995
+ * @param params Query parameters such as startkey and endkey
996
+ * @param options The current request options including the user
997
+ */
998
+ getObjectList(params: ioBroker.GetObjectListParams, options?: {
999
+ user?: ioBroker.ObjectIDs.User;
1000
+ sorted?: boolean;
1001
+ } | null): ioBroker.GetObjectListPromise;
1002
+ /**
1003
+ * Get the list of objects matching the given parameters
1004
+ *
1005
+ * @param params Query parameters such as startkey and endkey
1006
+ * @param callback Called with the matching objects
1007
+ */
254
1008
  getObjectList(params: ioBroker.GetObjectListParams, callback: ioBroker.GetObjectListCallback<ioBroker.Object>): void;
255
- getObjectList<T extends ioBroker.GetObjectListCallback<ioBroker.Object>>(params: ioBroker.GetObjectListParams, options?: CallOptions | null, callback?: T): T extends ioBroker.GetObjectListCallback<ioBroker.Object> ? void : ioBroker.GetObjectListPromise;
256
- getObjectListAsync(params: ioBroker.GetObjectListParams, options?: CallOptions): ioBroker.GetObjectListPromise;
1009
+ /**
1010
+ * Get the list of objects matching the given parameters
1011
+ *
1012
+ * @param params Query parameters such as startkey and endkey
1013
+ * @param options The current request options including the user
1014
+ * @param callback Called with the matching objects
1015
+ */
1016
+ getObjectList<T extends ioBroker.GetObjectListCallback<ioBroker.Object>>(params: ioBroker.GetObjectListParams, options?: {
1017
+ user?: ioBroker.ObjectIDs.User;
1018
+ sorted?: boolean;
1019
+ } | null, callback?: T): T extends ioBroker.GetObjectListCallback<ioBroker.Object> ? void : ioBroker.GetObjectListPromise;
1020
+ /**
1021
+ * Promise-version of getObjectList
1022
+ *
1023
+ * @param params Query parameters such as startkey and endkey
1024
+ * @param options The current request options including the user
1025
+ */
1026
+ getObjectListAsync(params: ioBroker.GetObjectListParams, options?: {
1027
+ user?: ioBroker.ObjectIDs.User;
1028
+ checked?: true;
1029
+ sorted?: boolean;
1030
+ } | null): ioBroker.GetObjectListPromise;
257
1031
  private _extendObject;
258
- extendObject<T extends string>(id: T, obj: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: ioBroker.ExtendObjectOptions | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ExtendObjectCallback>>;
259
- extendObject<T extends string>(id: T, obj: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: ioBroker.ExtendObjectOptions | null, callback?: ioBroker.ExtendObjectCallback): void | Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ExtendObjectCallback>>;
260
- extendObjectAsync(id: string, obj: Partial<ioBroker.AnyObject>, options?: ioBroker.ExtendObjectOptions): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.ExtendObjectCallback>>;
1032
+ /**
1033
+ * Extend an existing object with the given partial object, creating it if it does not exist
1034
+ *
1035
+ * @param id The id of the object to extend
1036
+ * @param obj The partial object to merge into the existing object
1037
+ * @param options The current request options including the user, or the callback
1038
+ */
1039
+ extendObject<T extends string>(id: T, obj: ioBroker.PartialObject<ioBroker.ObjectIdToObjectType<T, 'write'>>, options?: ioBroker.ExtendObjectOptions | null): Promise<{
1040
+ id: string;
1041
+ value: ioBroker.AnyObject;
1042
+ }>;
261
1043
  /**
262
1044
  * Returns the object id if found
263
1045
  *
264
- * @param idOrName
265
- * @param type
266
- * @param options
267
- * @param callback
1046
+ * @param idOrName The id or name to search for
1047
+ * @param type The expected common type, or null for any
1048
+ * @param options The current request options (may include a language)
1049
+ * @param options.language The language to use when resolving names
1050
+ * @param options.user The user on whose behalf the lookup is performed
1051
+ * @param userContext The resolved user context to check the rights against
1052
+ * @param callback Called with the found id and the original id/name
268
1053
  */
269
1054
  private _findObject;
270
- findObject(idOrName: string, type: ioBroker.CommonType | null, options: (CallOptions & {
1055
+ /**
1056
+ * Find an object by its id or name
1057
+ *
1058
+ * @param idOrName The id or name to search for
1059
+ * @param type The expected common type, or null for any
1060
+ * @param options The current request options (may include a language)
1061
+ * @param callback Called with the found id and the original id/name
1062
+ */
1063
+ findObject(idOrName: string, type: ioBroker.CommonType | null, options: {
271
1064
  language?: ioBroker.Languages;
272
- }) | null, callback: ioBroker.FindObjectCallback): void;
1065
+ user?: ioBroker.ObjectIDs.User;
1066
+ } | null, callback: ioBroker.FindObjectCallback): void;
1067
+ /**
1068
+ * Find an object by its id or name
1069
+ *
1070
+ * @param idOrName The id or name to search for
1071
+ * @param type The expected common type, or null for any
1072
+ * @param callback Called with the found id and the original id/name
1073
+ */
273
1074
  findObject(idOrName: string, type: ioBroker.CommonType | null, callback: ioBroker.FindObjectCallback): void;
274
- findObject(idOrName: string, type?: ioBroker.CommonType | null, options?: (CallOptions & {
1075
+ /**
1076
+ * Find an object by its id or name
1077
+ *
1078
+ * @param idOrName The id or name to search for
1079
+ * @param type The expected common type, or null for any
1080
+ * @param options The current request options (may include a language)
1081
+ */
1082
+ findObject(idOrName: string, type?: ioBroker.CommonType | null, options?: {
275
1083
  language?: ioBroker.Languages;
276
- }) | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.FindObjectCallback>>;
1084
+ user?: ioBroker.ObjectIDs.User;
1085
+ } | null): Promise<ioBroker.CallbackReturnTypeOf<ioBroker.FindObjectCallback>>;
1086
+ /**
1087
+ * Add object property paths that should be preserved when an object is overwritten (controller only)
1088
+ *
1089
+ * @param settings One or more property paths to preserve
1090
+ */
277
1091
  addPreserveSettings(settings: string[] | string): void;
278
1092
  private _destroyDBHelper;
279
1093
  private _destroyDB;
280
- destroyDB(options: CallOptions | null | undefined, callback: ioBroker.ErrorCallback): void;
281
- destroyDBAsync(options?: CallOptions): Promise<void>;
1094
+ /**
1095
+ * Delete the whole objects database (requires admin rights)
1096
+ *
1097
+ * @param options The current request options including the user, or the callback
1098
+ * @param callback Called once the database has been destroyed
1099
+ */
1100
+ destroyDB(options: {
1101
+ user?: ioBroker.ObjectIDs.User;
1102
+ } | null | undefined, callback: ioBroker.ErrorCallback): void;
1103
+ /**
1104
+ * Promise-version of destroyDB
1105
+ *
1106
+ * @param options The current request options including the user
1107
+ * @param options.user The user on whose behalf the database is destroyed
1108
+ */
1109
+ destroyDBAsync(options?: {
1110
+ user?: ioBroker.ObjectIDs.User;
1111
+ }): Promise<void>;
1112
+ /**
1113
+ * Destructor of the class. Called when shutting down to close the redis connections.
1114
+ */
282
1115
  destroy(): Promise<void>;
1116
+ /**
1117
+ * Load and register the Lua scripts used for atomic operations on the redis server
1118
+ */
283
1119
  loadLuaScripts(): Promise<void>;
284
1120
  /**
285
- * Get all keys matching a pattern using redis SCAN command, duplicates are filtered out
1121
+ * Get all keys matching a pattern using redis SCAN command; duplicates are filtered out
286
1122
  *
287
- * @param pattern - pattern to match, e. g. io.hm-rpc.0*
1123
+ * @param pattern - pattern to match, e.g. io.hm-rpc.0*
288
1124
  * @param count - count argument used by redis SCAN, default is 250
289
1125
  */
290
1126
  private _getKeysViaScan;
@@ -313,15 +1149,15 @@ export declare class ObjectsInRedisClient {
313
1149
  */
314
1150
  extendPrimaryHostLock(ms: number): Promise<number>;
315
1151
  /**
316
- * Sets current host as primary if no primary host active
317
- * Value will expire after ms milliseconds
1152
+ * Sets the current host as primary if no primary host active
1153
+ * Value expires after ms milliseconds
318
1154
  *
319
1155
  * @param ms - ms until value expires
320
1156
  * @returns 1 if lock acquired else 0
321
1157
  */
322
1158
  setPrimaryHost(ms: number): Promise<number>;
323
1159
  /**
324
- * Get name of the primary host
1160
+ * Get the name of the primary host
325
1161
  */
326
1162
  getPrimaryHost(): Promise<string | null>;
327
1163
  /**
@@ -335,7 +1171,7 @@ export declare class ObjectsInRedisClient {
335
1171
  */
336
1172
  setProtocolVersion(version: number | string): Promise<void>;
337
1173
  /**
338
- * Subscribe to expired events to get expiration of primary host
1174
+ * Subscribe to expired events to get expiration of the primary host
339
1175
  */
340
1176
  subscribePrimaryHost(): Promise<void>;
341
1177
  /**