@iobroker/js-controller-adapter 7.2.2 → 7.2.3-alpha.1-20260621-61726ea22
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/build/cjs/lib/_Types.d.ts +256 -0
- package/build/cjs/lib/adapter/adapter.d.ts +1403 -3
- package/build/cjs/lib/adapter/adapter.js +147 -24
- package/build/cjs/lib/adapter/adapter.js.map +2 -2
- package/build/cjs/lib/adapter/defaultObjs.d.ts +5 -0
- package/build/cjs/lib/adapter/defaultObjs.js.map +2 -2
- package/build/cjs/lib/adapter/log.d.ts +25 -0
- package/build/cjs/lib/adapter/log.js +25 -0
- package/build/cjs/lib/adapter/log.js.map +2 -2
- package/build/cjs/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
- package/build/cjs/lib/adapter/userInterfaceMessagingController.js +3 -0
- package/build/cjs/lib/adapter/userInterfaceMessagingController.js.map +2 -2
- package/build/cjs/lib/adapter/validator.d.ts +4 -0
- package/build/cjs/lib/adapter/validator.js.map +2 -2
- package/build/esm/lib/_Types.d.ts +256 -0
- package/build/esm/lib/_Types.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.d.ts +1403 -3
- package/build/esm/lib/adapter/adapter.d.ts.map +1 -1
- package/build/esm/lib/adapter/adapter.js +147 -24
- package/build/esm/lib/adapter/adapter.js.map +1 -1
- package/build/esm/lib/adapter/defaultObjs.d.ts +5 -0
- package/build/esm/lib/adapter/defaultObjs.d.ts.map +1 -1
- package/build/esm/lib/adapter/defaultObjs.js +5 -0
- package/build/esm/lib/adapter/defaultObjs.js.map +1 -1
- package/build/esm/lib/adapter/log.d.ts +25 -0
- package/build/esm/lib/adapter/log.d.ts.map +1 -1
- package/build/esm/lib/adapter/log.js +25 -0
- package/build/esm/lib/adapter/log.js.map +1 -1
- package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts +10 -0
- package/build/esm/lib/adapter/userInterfaceMessagingController.d.ts.map +1 -1
- package/build/esm/lib/adapter/userInterfaceMessagingController.js +6 -0
- package/build/esm/lib/adapter/userInterfaceMessagingController.js.map +1 -1
- package/build/esm/lib/adapter/validator.d.ts +4 -0
- package/build/esm/lib/adapter/validator.d.ts.map +1 -1
- package/build/esm/lib/adapter/validator.js +3 -0
- package/build/esm/lib/adapter/validator.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -188,6 +188,9 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
188
188
|
SUPPORTED_FEATURES = (0, import_utils.getSupportedFeatures)();
|
|
189
189
|
/** Controller for messaging related functionality */
|
|
190
190
|
uiMessagingController;
|
|
191
|
+
/**
|
|
192
|
+
* @param options Adapter options, or the adapter name as a string
|
|
193
|
+
*/
|
|
191
194
|
constructor(options) {
|
|
192
195
|
super();
|
|
193
196
|
if (typeof options === "string") {
|
|
@@ -468,6 +471,12 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
468
471
|
return import_js_controller_common.tools.encrypt(secretVal, value);
|
|
469
472
|
}
|
|
470
473
|
// unknown guard implementation
|
|
474
|
+
/**
|
|
475
|
+
* Read a session from the states DB
|
|
476
|
+
*
|
|
477
|
+
* @param id the session id
|
|
478
|
+
* @param callback return result
|
|
479
|
+
*/
|
|
471
480
|
getSession(id, callback) {
|
|
472
481
|
import_validator.Validator.assertString(id, "id");
|
|
473
482
|
import_validator.Validator.assertCallback(callback, "callback");
|
|
@@ -482,6 +491,14 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
482
491
|
this.#states.getSession(options.id, options.callback);
|
|
483
492
|
}
|
|
484
493
|
// unknown implementation guards
|
|
494
|
+
/**
|
|
495
|
+
* Store a session in the states DB
|
|
496
|
+
*
|
|
497
|
+
* @param id the session id
|
|
498
|
+
* @param ttl time to live in seconds
|
|
499
|
+
* @param data the session data to store
|
|
500
|
+
* @param callback return result
|
|
501
|
+
*/
|
|
485
502
|
setSession(id, ttl, data, callback) {
|
|
486
503
|
import_validator.Validator.assertString(id, "id");
|
|
487
504
|
import_validator.Validator.assertOptionalCallback(callback, "callback");
|
|
@@ -497,6 +514,12 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
497
514
|
}
|
|
498
515
|
this.#states.setSession(options.id, options.ttl, options.data, options.callback);
|
|
499
516
|
}
|
|
517
|
+
/**
|
|
518
|
+
* Destroy a session in the states DB
|
|
519
|
+
*
|
|
520
|
+
* @param id the session id
|
|
521
|
+
* @param callback return result
|
|
522
|
+
*/
|
|
500
523
|
destroySession(id, callback) {
|
|
501
524
|
import_validator.Validator.assertString(id, "id");
|
|
502
525
|
import_validator.Validator.assertOptionalCallback(callback, "callback");
|
|
@@ -2712,7 +2735,7 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
2712
2735
|
* @param options optional user context with language
|
|
2713
2736
|
* @param options.user current user
|
|
2714
2737
|
* @param options.language language in which the search must be done for multi-language names
|
|
2715
|
-
* @
|
|
2738
|
+
* @returns if the object was found by ID it will return id and may be the multi-language name it exists. If the object was found by name it will return id and the multi-language name. If the object was not found, it will return only name that was searched for.
|
|
2716
2739
|
*/
|
|
2717
2740
|
findForeignObjectAsync(id, type, options) {
|
|
2718
2741
|
return new Promise((resolve, reject) => this.findForeignObject(id, type, options || {}, (err, id2, name) => {
|
|
@@ -3208,11 +3231,11 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3208
3231
|
return id;
|
|
3209
3232
|
}
|
|
3210
3233
|
/**
|
|
3211
|
-
* @param deviceName
|
|
3212
|
-
* @param common
|
|
3213
|
-
* @param _native
|
|
3214
|
-
* @param options
|
|
3215
|
-
* @param callback
|
|
3234
|
+
* @param deviceName the name of the device
|
|
3235
|
+
* @param common the common section of the device object
|
|
3236
|
+
* @param _native the native section of the device object
|
|
3237
|
+
* @param options optional user context
|
|
3238
|
+
* @param callback return result
|
|
3216
3239
|
* @deprecated use `this.extendObject` instead
|
|
3217
3240
|
*/
|
|
3218
3241
|
createDevice(deviceName, common, _native, options, callback) {
|
|
@@ -3262,12 +3285,12 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3262
3285
|
/**
|
|
3263
3286
|
* Name of channel must be in format "channel"
|
|
3264
3287
|
*
|
|
3265
|
-
* @param parentDevice
|
|
3266
|
-
* @param channelName
|
|
3267
|
-
* @param roleOrCommon
|
|
3268
|
-
* @param _native
|
|
3269
|
-
* @param options
|
|
3270
|
-
* @param callback
|
|
3288
|
+
* @param parentDevice the parent device name
|
|
3289
|
+
* @param channelName the name of the channel
|
|
3290
|
+
* @param roleOrCommon role string or the common section of the channel object
|
|
3291
|
+
* @param _native the native section of the channel object
|
|
3292
|
+
* @param options optional user context
|
|
3293
|
+
* @param callback return result
|
|
3271
3294
|
* @deprecated use `this.extendObject` instead
|
|
3272
3295
|
*/
|
|
3273
3296
|
createChannel(parentDevice, channelName, roleOrCommon, _native, options, callback) {
|
|
@@ -3315,13 +3338,13 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3315
3338
|
this.setObjectNotExists(channelName, obj, options, callback);
|
|
3316
3339
|
}
|
|
3317
3340
|
/**
|
|
3318
|
-
* @param parentDevice
|
|
3319
|
-
* @param parentChannel
|
|
3320
|
-
* @param stateName
|
|
3321
|
-
* @param roleOrCommon
|
|
3322
|
-
* @param _native
|
|
3323
|
-
* @param options
|
|
3324
|
-
* @param callback
|
|
3341
|
+
* @param parentDevice the parent device name
|
|
3342
|
+
* @param parentChannel the parent channel name
|
|
3343
|
+
* @param stateName the name of the state
|
|
3344
|
+
* @param roleOrCommon role string or the common section of the state object
|
|
3345
|
+
* @param _native the native section of the state object
|
|
3346
|
+
* @param options optional user context
|
|
3347
|
+
* @param callback return result
|
|
3325
3348
|
* @deprecated use `this.extendObject` instead
|
|
3326
3349
|
*/
|
|
3327
3350
|
createState(parentDevice, parentChannel, stateName, roleOrCommon, _native, options, callback) {
|
|
@@ -3518,6 +3541,16 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3518
3541
|
}
|
|
3519
3542
|
return import_js_controller_common.tools.maybeCallback(callback);
|
|
3520
3543
|
}
|
|
3544
|
+
/**
|
|
3545
|
+
* Add a channel to an enum.
|
|
3546
|
+
*
|
|
3547
|
+
* @param enumName the enum category (e.g. rooms, functions)
|
|
3548
|
+
* @param addTo the enum id to add the channel to
|
|
3549
|
+
* @param parentDevice the parent device name
|
|
3550
|
+
* @param channelName the name of the channel
|
|
3551
|
+
* @param options optional user context
|
|
3552
|
+
* @param callback return result
|
|
3553
|
+
*/
|
|
3521
3554
|
addChannelToEnum(enumName, addTo, parentDevice, channelName, options, callback) {
|
|
3522
3555
|
if (typeof options === "function") {
|
|
3523
3556
|
callback = options;
|
|
@@ -3603,6 +3636,15 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3603
3636
|
});
|
|
3604
3637
|
}
|
|
3605
3638
|
}
|
|
3639
|
+
/**
|
|
3640
|
+
* Remove a channel from an enum.
|
|
3641
|
+
*
|
|
3642
|
+
* @param enumName the enum category (e.g. rooms, functions)
|
|
3643
|
+
* @param parentDevice the parent device name
|
|
3644
|
+
* @param channelName the name of the channel
|
|
3645
|
+
* @param options optional user context
|
|
3646
|
+
* @param callback return result
|
|
3647
|
+
*/
|
|
3606
3648
|
deleteChannelFromEnum(enumName, parentDevice, channelName, options, callback) {
|
|
3607
3649
|
if (typeof options === "function") {
|
|
3608
3650
|
callback = options;
|
|
@@ -3755,11 +3797,11 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3755
3797
|
return import_js_controller_common.tools.maybeCallback(callback);
|
|
3756
3798
|
}
|
|
3757
3799
|
/**
|
|
3758
|
-
* @param parentDevice
|
|
3759
|
-
* @param parentChannel
|
|
3760
|
-
* @param stateName
|
|
3761
|
-
* @param options
|
|
3762
|
-
* @param callback
|
|
3800
|
+
* @param parentDevice the parent device name
|
|
3801
|
+
* @param parentChannel the parent channel name
|
|
3802
|
+
* @param stateName the name of the state
|
|
3803
|
+
* @param options optional user context
|
|
3804
|
+
* @param callback return result
|
|
3763
3805
|
* @deprecated use `this.delObject` instead
|
|
3764
3806
|
*/
|
|
3765
3807
|
deleteState(parentDevice, parentChannel, stateName, options, callback) {
|
|
@@ -3841,6 +3883,12 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3841
3883
|
const _name = this._DCS2ID(parentDevice, parentChannel, stateName);
|
|
3842
3884
|
this.delObject(_name, options, callback);
|
|
3843
3885
|
}
|
|
3886
|
+
/**
|
|
3887
|
+
* Get all devices of this adapter.
|
|
3888
|
+
*
|
|
3889
|
+
* @param options optional user context, or the callback
|
|
3890
|
+
* @param callback return result
|
|
3891
|
+
*/
|
|
3844
3892
|
getDevices(options, callback) {
|
|
3845
3893
|
if (typeof options === "function" && typeof callback === "object") {
|
|
3846
3894
|
const tmp = callback;
|
|
@@ -3879,6 +3927,13 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3879
3927
|
return import_js_controller_common.tools.maybeCallbackWithError(callback, null, res);
|
|
3880
3928
|
});
|
|
3881
3929
|
}
|
|
3930
|
+
/**
|
|
3931
|
+
* Get all channels of this adapter or of the given device.
|
|
3932
|
+
*
|
|
3933
|
+
* @param parentDevice the parent device name, or the callback
|
|
3934
|
+
* @param options optional user context, or the callback
|
|
3935
|
+
* @param callback return result
|
|
3936
|
+
*/
|
|
3882
3937
|
getChannelsOf(parentDevice, options, callback) {
|
|
3883
3938
|
if (typeof options === "function") {
|
|
3884
3939
|
callback = options;
|
|
@@ -3926,6 +3981,14 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
3926
3981
|
return import_js_controller_common.tools.maybeCallbackWithError(options.callback, null, res);
|
|
3927
3982
|
});
|
|
3928
3983
|
}
|
|
3984
|
+
/**
|
|
3985
|
+
* Get all states of this adapter or of the given device/channel.
|
|
3986
|
+
*
|
|
3987
|
+
* @param parentDevice the parent device name, or the callback
|
|
3988
|
+
* @param parentChannel the parent channel name, or the callback
|
|
3989
|
+
* @param options optional user context, or the callback
|
|
3990
|
+
* @param callback return result
|
|
3991
|
+
*/
|
|
3929
3992
|
getStatesOf(parentDevice, parentChannel, options, callback) {
|
|
3930
3993
|
if (typeof options === "function") {
|
|
3931
3994
|
callback = options;
|
|
@@ -4002,6 +4065,17 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4002
4065
|
}
|
|
4003
4066
|
});
|
|
4004
4067
|
}
|
|
4068
|
+
/**
|
|
4069
|
+
* Add a state to an enum.
|
|
4070
|
+
*
|
|
4071
|
+
* @param enumName the enum category (e.g. rooms, functions)
|
|
4072
|
+
* @param addTo the enum id to add the state to
|
|
4073
|
+
* @param parentDevice the parent device name
|
|
4074
|
+
* @param parentChannel the parent channel name
|
|
4075
|
+
* @param stateName the name of the state
|
|
4076
|
+
* @param options optional user context
|
|
4077
|
+
* @param callback return result
|
|
4078
|
+
*/
|
|
4005
4079
|
addStateToEnum(enumName, addTo, parentDevice, parentChannel, stateName, options, callback) {
|
|
4006
4080
|
if (typeof options === "function") {
|
|
4007
4081
|
callback = options;
|
|
@@ -4099,6 +4173,16 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4099
4173
|
});
|
|
4100
4174
|
}
|
|
4101
4175
|
}
|
|
4176
|
+
/**
|
|
4177
|
+
* Remove a state from an enum.
|
|
4178
|
+
*
|
|
4179
|
+
* @param enumName the enum category (e.g. rooms, functions)
|
|
4180
|
+
* @param parentDevice the parent device name
|
|
4181
|
+
* @param parentChannel the parent channel name
|
|
4182
|
+
* @param stateName the name of the state
|
|
4183
|
+
* @param options optional user context
|
|
4184
|
+
* @param callback return result
|
|
4185
|
+
*/
|
|
4102
4186
|
deleteStateFromEnum(enumName, parentDevice, parentChannel, stateName, options, callback) {
|
|
4103
4187
|
if (typeof options === "function") {
|
|
4104
4188
|
callback = options;
|
|
@@ -4312,6 +4396,14 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4312
4396
|
}
|
|
4313
4397
|
this.#objects.readDir(_adapter, path, options, callback);
|
|
4314
4398
|
}
|
|
4399
|
+
/**
|
|
4400
|
+
* Deletes a file in the DB.
|
|
4401
|
+
*
|
|
4402
|
+
* @param _adapter adapter name, or null for the current adapter
|
|
4403
|
+
* @param name path to the file
|
|
4404
|
+
* @param options optional user context
|
|
4405
|
+
* @param callback return result
|
|
4406
|
+
*/
|
|
4315
4407
|
unlink(_adapter, name, options, callback) {
|
|
4316
4408
|
if (_adapter === null) {
|
|
4317
4409
|
_adapter = this.name;
|
|
@@ -4332,6 +4424,15 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4332
4424
|
}
|
|
4333
4425
|
this.#objects.unlink(_adapter, name, options, callback);
|
|
4334
4426
|
}
|
|
4427
|
+
/**
|
|
4428
|
+
* Renames a file in the DB.
|
|
4429
|
+
*
|
|
4430
|
+
* @param _adapter adapter name, or null for the current adapter
|
|
4431
|
+
* @param oldName current path to the file
|
|
4432
|
+
* @param newName new path to the file
|
|
4433
|
+
* @param options optional user context
|
|
4434
|
+
* @param callback return result
|
|
4435
|
+
*/
|
|
4335
4436
|
rename(_adapter, oldName, newName, options, callback) {
|
|
4336
4437
|
if (_adapter === null) {
|
|
4337
4438
|
_adapter = this.name;
|
|
@@ -4353,6 +4454,14 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4353
4454
|
}
|
|
4354
4455
|
this.#objects.rename(_adapter, oldName, newName, options, callback);
|
|
4355
4456
|
}
|
|
4457
|
+
/**
|
|
4458
|
+
* Creates a directory in the DB.
|
|
4459
|
+
*
|
|
4460
|
+
* @param _adapter adapter name, or null for the current adapter
|
|
4461
|
+
* @param dirname path to the directory
|
|
4462
|
+
* @param options optional user context
|
|
4463
|
+
* @param callback return result
|
|
4464
|
+
*/
|
|
4356
4465
|
mkdir(_adapter, dirname, options, callback) {
|
|
4357
4466
|
if (_adapter === null) {
|
|
4358
4467
|
_adapter = this.name;
|
|
@@ -4489,6 +4598,13 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4489
4598
|
return import_js_controller_common.tools.maybeCallbackWithError(callback, e);
|
|
4490
4599
|
}
|
|
4491
4600
|
}
|
|
4601
|
+
/**
|
|
4602
|
+
* Formats a numeric value using the given format string.
|
|
4603
|
+
*
|
|
4604
|
+
* @param value the value to format
|
|
4605
|
+
* @param decimals number of decimals to keep, or the format string
|
|
4606
|
+
* @param _format optional format string for the decimal and thousands separator
|
|
4607
|
+
*/
|
|
4492
4608
|
formatValue(value, decimals, _format) {
|
|
4493
4609
|
if (typeof decimals !== "number") {
|
|
4494
4610
|
_format = decimals;
|
|
@@ -4506,6 +4622,13 @@ class AdapterClass extends import_node_events.EventEmitter {
|
|
|
4506
4622
|
value.toFixed(decimals).replace(format[0], format[1]).replace(/\B(?=(\d{3})+(?!\d))/g, format[0])
|
|
4507
4623
|
);
|
|
4508
4624
|
}
|
|
4625
|
+
/**
|
|
4626
|
+
* Formats a date or duration according to the given format string.
|
|
4627
|
+
*
|
|
4628
|
+
* @param dateObj the date to format
|
|
4629
|
+
* @param isDuration whether the value represents a duration, or the format string
|
|
4630
|
+
* @param _format optional format string
|
|
4631
|
+
*/
|
|
4509
4632
|
formatDate(dateObj, isDuration, _format) {
|
|
4510
4633
|
if (typeof isDuration === "string" && isDuration.toLowerCase() === "duration" || isDuration === true) {
|
|
4511
4634
|
isDuration = true;
|