hoffmation-base 2.9.8 → 2.9.10
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/lib/server/devices/baseDeviceInterfaces/iButtonSwitch.d.ts +2 -1
- package/lib/server/devices/button/button.d.ts +1 -0
- package/lib/server/devices/button/button.js +13 -0
- package/lib/server/devices/button/buttonPosition.d.ts +10 -0
- package/lib/server/devices/button/buttonPosition.js +14 -0
- package/lib/server/devices/button/index.d.ts +1 -0
- package/lib/server/devices/button/index.js +1 -0
- package/lib/server/devices/groups/Window.d.ts +1 -2
- package/lib/server/devices/groups/Window.js +1 -2
- package/lib/server/devices/groups/windowGroup.js +1 -1
- package/lib/server/devices/hmIPDevices/hmIpTaster.d.ts +2 -1
- package/lib/server/devices/hmIPDevices/hmIpTaster.js +39 -0
- package/lib/server/devices/hmIPDevices/hmIpWippe.d.ts +2 -1
- package/lib/server/devices/hmIPDevices/hmIpWippe.js +11 -0
- package/lib/server/devices/zigbee/BaseDevices/zigbeeSwitch.d.ts +2 -1
- package/lib/server/devices/zigbee/BaseDevices/zigbeeSwitch.js +40 -0
- package/lib/server/services/ShutterService.js +5 -3
- package/lib/server/services/api/api-service.d.ts +9 -1
- package/lib/server/services/api/api-service.js +21 -2
- package/lib/server/services/utils/utils.js +6 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Button, ButtonPressType } from '../button';
|
|
1
|
+
import { Button, ButtonPosition, ButtonPressType } from '../button';
|
|
2
2
|
import { iRoomDevice } from './iRoomDevice';
|
|
3
3
|
export interface iButtonSwitch extends iRoomDevice {
|
|
4
4
|
buttonTopLeft: Button | undefined;
|
|
@@ -11,4 +11,5 @@ export interface iButtonSwitch extends iRoomDevice {
|
|
|
11
11
|
buttonTop: Button | undefined;
|
|
12
12
|
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
13
13
|
getButtonAssignment(): string;
|
|
14
|
+
pressButton(position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
14
15
|
}
|
|
@@ -83,5 +83,18 @@ class Button {
|
|
|
83
83
|
toJSON() {
|
|
84
84
|
return services_1.Utils.jsonFilter(this);
|
|
85
85
|
}
|
|
86
|
+
press(pressType) {
|
|
87
|
+
if ((pressType === buttonPressType_1.ButtonPressType.long && !this.buttonCapabilities.longPress) ||
|
|
88
|
+
(pressType === buttonPressType_1.ButtonPressType.short && !this.buttonCapabilities.shortPress) ||
|
|
89
|
+
(pressType === buttonPressType_1.ButtonPressType.double && !this.buttonCapabilities.doublePress) ||
|
|
90
|
+
(pressType === buttonPressType_1.ButtonPressType.triple && !this.buttonCapabilities.triplePress)) {
|
|
91
|
+
return new Error(`This Button doesn't support press Type ${buttonPressType_1.ButtonPressType[pressType]}`);
|
|
92
|
+
}
|
|
93
|
+
this.updateState(pressType, true);
|
|
94
|
+
services_1.Utils.guardedTimeout(() => {
|
|
95
|
+
this.updateState(pressType, false);
|
|
96
|
+
}, 200, this);
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
86
99
|
}
|
|
87
100
|
exports.Button = Button;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ButtonPosition = void 0;
|
|
4
|
+
var ButtonPosition;
|
|
5
|
+
(function (ButtonPosition) {
|
|
6
|
+
ButtonPosition[ButtonPosition["topLeft"] = 1] = "topLeft";
|
|
7
|
+
ButtonPosition[ButtonPosition["topRight"] = 2] = "topRight";
|
|
8
|
+
ButtonPosition[ButtonPosition["midLeft"] = 3] = "midLeft";
|
|
9
|
+
ButtonPosition[ButtonPosition["midRight"] = 4] = "midRight";
|
|
10
|
+
ButtonPosition[ButtonPosition["botLeft"] = 5] = "botLeft";
|
|
11
|
+
ButtonPosition[ButtonPosition["botRight"] = 6] = "botRight";
|
|
12
|
+
ButtonPosition[ButtonPosition["top"] = 11] = "top";
|
|
13
|
+
ButtonPosition[ButtonPosition["bottom"] = 12] = "bottom";
|
|
14
|
+
})(ButtonPosition = exports.ButtonPosition || (exports.ButtonPosition = {}));
|
|
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./button"), exports);
|
|
18
18
|
__exportStar(require("./buttonCapabilities"), exports);
|
|
19
19
|
__exportStar(require("./buttonPressType"), exports);
|
|
20
|
+
__exportStar(require("./buttonPosition"), exports);
|
|
@@ -9,10 +9,9 @@ export declare class Window extends BaseGroup {
|
|
|
9
9
|
readonly vibrationIds: string[];
|
|
10
10
|
readonly shutterIds: string[];
|
|
11
11
|
readonly magnetIds: string[];
|
|
12
|
-
noRolloOnSunrise: boolean;
|
|
13
12
|
desiredPosition: number;
|
|
14
13
|
settings: WindowSettings;
|
|
15
|
-
constructor(roomName: string, handleIds?: string[], vibrationIds?: string[], shutterIds?: string[], magnetIds?: string[]
|
|
14
|
+
constructor(roomName: string, handleIds?: string[], vibrationIds?: string[], shutterIds?: string[], magnetIds?: string[]);
|
|
16
15
|
/**
|
|
17
16
|
* sets the desired Pos and moves rollo to this level
|
|
18
17
|
* @param {number} value
|
|
@@ -9,13 +9,12 @@ const group_type_1 = require("./group-type");
|
|
|
9
9
|
const device_cluster_type_1 = require("../device-cluster-type");
|
|
10
10
|
const device_list_1 = require("../device-list");
|
|
11
11
|
class Window extends base_group_1.BaseGroup {
|
|
12
|
-
constructor(roomName, handleIds = [], vibrationIds = [], shutterIds = [], magnetIds = []
|
|
12
|
+
constructor(roomName, handleIds = [], vibrationIds = [], shutterIds = [], magnetIds = []) {
|
|
13
13
|
super(roomName, group_type_1.GroupType.Window);
|
|
14
14
|
this.handleIds = handleIds;
|
|
15
15
|
this.vibrationIds = vibrationIds;
|
|
16
16
|
this.shutterIds = shutterIds;
|
|
17
17
|
this.magnetIds = magnetIds;
|
|
18
|
-
this.noRolloOnSunrise = noRolloOnSunrise;
|
|
19
18
|
this.desiredPosition = 0;
|
|
20
19
|
this.settings = new models_2.WindowSettings();
|
|
21
20
|
this.deviceCluster.deviceMap.set(device_cluster_type_1.DeviceClusterType.Handle, new device_list_1.DeviceList(handleIds));
|
|
@@ -93,7 +93,7 @@ class WindowGroup extends base_group_1.BaseGroup {
|
|
|
93
93
|
}
|
|
94
94
|
sunriseUp(initial = false) {
|
|
95
95
|
this.windows.forEach((f) => {
|
|
96
|
-
if (
|
|
96
|
+
if (!this.getRoom().settings.sonnenAufgangRollos || f.getShutter().length === 0) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
this.log(models_1.LogLevel.Debug, `Fahre das Rollo zum Sonnenaufgang ${initial ? '(ggf. nachträglich)' : ''} hoch`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="iobroker" />
|
|
2
2
|
import { HmIPDevice } from './hmIpDevice';
|
|
3
3
|
import { iBatteryDevice, iButtonSwitch } from '../baseDeviceInterfaces';
|
|
4
|
-
import { Button, ButtonPressType } from '../button';
|
|
4
|
+
import { Button, ButtonPosition, ButtonPressType } from '../button';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBatteryDevice {
|
|
7
7
|
private _battery;
|
|
@@ -22,4 +22,5 @@ export declare class HmIpTaster extends HmIPDevice implements iButtonSwitch, iBa
|
|
|
22
22
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
23
23
|
getButtonAssignment(): string;
|
|
24
24
|
persistBatteryDevice(): void;
|
|
25
|
+
pressButton(position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
25
26
|
}
|
|
@@ -122,6 +122,45 @@ class HmIpTaster extends hmIpDevice_1.HmIPDevice {
|
|
|
122
122
|
(_a = services_1.Utils.dbo) === null || _a === void 0 ? void 0 : _a.persistBatteryDevice(this);
|
|
123
123
|
this._lastBatteryPersist = now;
|
|
124
124
|
}
|
|
125
|
+
pressButton(position, pressType) {
|
|
126
|
+
let taste;
|
|
127
|
+
switch (position) {
|
|
128
|
+
case button_1.ButtonPosition.topLeft:
|
|
129
|
+
taste = this.buttonTopLeft;
|
|
130
|
+
break;
|
|
131
|
+
case button_1.ButtonPosition.topRight:
|
|
132
|
+
taste = this.buttonTopRight;
|
|
133
|
+
break;
|
|
134
|
+
case button_1.ButtonPosition.midLeft:
|
|
135
|
+
taste = this.buttonMidLeft;
|
|
136
|
+
break;
|
|
137
|
+
case button_1.ButtonPosition.midRight:
|
|
138
|
+
taste = this.buttonMidRight;
|
|
139
|
+
break;
|
|
140
|
+
case button_1.ButtonPosition.botLeft:
|
|
141
|
+
taste = this.buttonBotLeft;
|
|
142
|
+
break;
|
|
143
|
+
case button_1.ButtonPosition.botRight:
|
|
144
|
+
taste = this.buttonBotRight;
|
|
145
|
+
break;
|
|
146
|
+
case button_1.ButtonPosition.top:
|
|
147
|
+
taste = this.buttonTop;
|
|
148
|
+
break;
|
|
149
|
+
case button_1.ButtonPosition.bottom:
|
|
150
|
+
taste = this.buttonBot;
|
|
151
|
+
break;
|
|
152
|
+
default:
|
|
153
|
+
return new Error(`Unknown Button Position: ${position}`);
|
|
154
|
+
}
|
|
155
|
+
if (taste === undefined) {
|
|
156
|
+
return new Error(`Switch has no Button at position ${position}`);
|
|
157
|
+
}
|
|
158
|
+
const result = taste.press(pressType);
|
|
159
|
+
if (result === null) {
|
|
160
|
+
this.log(models_1.LogLevel.Info, `Simulated ButtonPress for ${taste.name} type: ${pressType}`);
|
|
161
|
+
}
|
|
162
|
+
return result;
|
|
163
|
+
}
|
|
125
164
|
}
|
|
126
165
|
HmIpTaster.BUTTON_CAPABILLITIES = {
|
|
127
166
|
shortPress: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="iobroker" />
|
|
2
2
|
import { HmIPDevice } from './hmIpDevice';
|
|
3
|
-
import { Button, ButtonPressType } from '../button';
|
|
3
|
+
import { Button, ButtonPosition, ButtonPressType } from '../button';
|
|
4
4
|
import { iButtonSwitch } from '../baseDeviceInterfaces';
|
|
5
5
|
import { IoBrokerDeviceInfo } from '../IoBrokerDeviceInfo';
|
|
6
6
|
export declare class HmIpWippe extends HmIPDevice implements iButtonSwitch {
|
|
@@ -17,4 +17,5 @@ export declare class HmIpWippe extends HmIPDevice implements iButtonSwitch {
|
|
|
17
17
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean): void;
|
|
18
18
|
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
19
19
|
getButtonAssignment(): string;
|
|
20
|
+
pressButton(position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
20
21
|
}
|
|
@@ -69,6 +69,17 @@ class HmIpWippe extends hmIpDevice_1.HmIPDevice {
|
|
|
69
69
|
result.push('____________');
|
|
70
70
|
return result.join('\n');
|
|
71
71
|
}
|
|
72
|
+
pressButton(position, pressType) {
|
|
73
|
+
if (position !== button_1.ButtonPosition.top && position !== button_1.ButtonPosition.bottom) {
|
|
74
|
+
return new Error(`Switch has no Button at position ${position}`);
|
|
75
|
+
}
|
|
76
|
+
const taste = position === button_1.ButtonPosition.top ? this.buttonTop : this.buttonBot;
|
|
77
|
+
const result = taste.press(pressType);
|
|
78
|
+
if (result === null) {
|
|
79
|
+
this.log(models_1.LogLevel.Info, `Simulated ButtonPress for ${taste.name} type: ${pressType}`);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
HmIpWippe.BUTTON_CAPABILLITIES = {
|
|
74
85
|
shortPress: true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { iButtonSwitch } from '../../baseDeviceInterfaces';
|
|
3
3
|
import { ZigbeeDevice } from './zigbeeDevice';
|
|
4
4
|
import { DeviceType } from '../../deviceType';
|
|
5
|
-
import { Button, ButtonPressType } from '../../button';
|
|
5
|
+
import { Button, ButtonPosition, ButtonPressType } from '../../button';
|
|
6
6
|
import { IoBrokerDeviceInfo } from '../../IoBrokerDeviceInfo';
|
|
7
7
|
export declare abstract class ZigbeeSwitch extends ZigbeeDevice implements iButtonSwitch {
|
|
8
8
|
battery: number;
|
|
@@ -18,4 +18,5 @@ export declare abstract class ZigbeeSwitch extends ZigbeeDevice implements iButt
|
|
|
18
18
|
persist(buttonName: string, pressType: ButtonPressType): void;
|
|
19
19
|
update(idSplit: string[], state: ioBroker.State, initial?: boolean, pOverrride?: boolean): void;
|
|
20
20
|
abstract getButtonAssignment(): string;
|
|
21
|
+
pressButton(position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
21
22
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ZigbeeSwitch = void 0;
|
|
4
4
|
const zigbeeDevice_1 = require("./zigbeeDevice");
|
|
5
|
+
const button_1 = require("../../button");
|
|
5
6
|
const DeviceCapability_1 = require("../../DeviceCapability");
|
|
6
7
|
const models_1 = require("../../../../models");
|
|
7
8
|
const services_1 = require("../../../services");
|
|
@@ -26,5 +27,44 @@ class ZigbeeSwitch extends zigbeeDevice_1.ZigbeeDevice {
|
|
|
26
27
|
break;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
pressButton(position, pressType) {
|
|
31
|
+
let taste;
|
|
32
|
+
switch (position) {
|
|
33
|
+
case button_1.ButtonPosition.topLeft:
|
|
34
|
+
taste = this.buttonTopLeft;
|
|
35
|
+
break;
|
|
36
|
+
case button_1.ButtonPosition.topRight:
|
|
37
|
+
taste = this.buttonTopRight;
|
|
38
|
+
break;
|
|
39
|
+
case button_1.ButtonPosition.midLeft:
|
|
40
|
+
taste = this.buttonMidLeft;
|
|
41
|
+
break;
|
|
42
|
+
case button_1.ButtonPosition.midRight:
|
|
43
|
+
taste = this.buttonMidRight;
|
|
44
|
+
break;
|
|
45
|
+
case button_1.ButtonPosition.botLeft:
|
|
46
|
+
taste = this.buttonBotLeft;
|
|
47
|
+
break;
|
|
48
|
+
case button_1.ButtonPosition.botRight:
|
|
49
|
+
taste = this.buttonBotRight;
|
|
50
|
+
break;
|
|
51
|
+
case button_1.ButtonPosition.top:
|
|
52
|
+
taste = this.buttonTop;
|
|
53
|
+
break;
|
|
54
|
+
case button_1.ButtonPosition.bottom:
|
|
55
|
+
taste = this.buttonBot;
|
|
56
|
+
break;
|
|
57
|
+
default:
|
|
58
|
+
return new Error(`Unknown Button Position: ${position}`);
|
|
59
|
+
}
|
|
60
|
+
if (taste === undefined) {
|
|
61
|
+
return new Error(`Switch has no Button at position ${position}`);
|
|
62
|
+
}
|
|
63
|
+
const result = taste.press(pressType);
|
|
64
|
+
if (result === null) {
|
|
65
|
+
this.log(models_1.LogLevel.Info, `Simulated ButtonPress for ${taste.name} type: ${pressType}`);
|
|
66
|
+
}
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
29
69
|
}
|
|
30
70
|
exports.ZigbeeSwitch = ZigbeeSwitch;
|
|
@@ -29,9 +29,11 @@ class ShutterService {
|
|
|
29
29
|
}
|
|
30
30
|
for (const f of r.WindowGroup.windows) {
|
|
31
31
|
f.getShutter().forEach((shutter) => {
|
|
32
|
-
var _a, _b, _c, _d;
|
|
33
|
-
response.push(`Rollo: "${shutter.info.customName}"\t${
|
|
34
|
-
|
|
32
|
+
var _a, _b, _c, _d, _e;
|
|
33
|
+
response.push(`Rollo: "${shutter.info.customName}"\t${((_a = shutter.room) === null || _a === void 0 ? void 0 : _a.settings.sonnenAufgangRollos) === true
|
|
34
|
+
? (_c = (_b = r.sunriseShutterCallback) === null || _b === void 0 ? void 0 : _b.nextToDo) === null || _c === void 0 ? void 0 : _c.toLocaleTimeString()
|
|
35
|
+
: 'Hochfahren inaktiv'}`);
|
|
36
|
+
down.push(`Rollo: "${shutter.info.customName}"\t${(_e = (_d = r.sunsetShutterCallback) === null || _d === void 0 ? void 0 : _d.nextToDo) === null || _e === void 0 ? void 0 : _e.toLocaleTimeString()}`);
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
39
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { iBaseDevice } from '../../devices';
|
|
1
|
+
import { ButtonPosition, ButtonPressType, iBaseDevice } from '../../devices';
|
|
2
2
|
import { CollisionSolving, DeviceSettings, RoomBase } from '../../../models';
|
|
3
3
|
import { LogObject } from '../log-service';
|
|
4
4
|
import { AcDevice, AcMode } from '../ac';
|
|
@@ -73,6 +73,13 @@ export declare class API {
|
|
|
73
73
|
* @returns {Error | null} In case it failed the Error containing the reason
|
|
74
74
|
*/
|
|
75
75
|
static setLedLamp(deviceId: string, state: boolean, timeout?: number, brightness?: number, transitionTime?: number, color?: string, colorTemp?: number): Error | null;
|
|
76
|
+
/**
|
|
77
|
+
* Changes the position of a given shutter
|
|
78
|
+
* if needed this updates the window position as well
|
|
79
|
+
* @param {string} deviceId The device Id of the shutter
|
|
80
|
+
* @param {number} level The desired new level (0 being open, 100 being closed)
|
|
81
|
+
* @returns {Error | null} Error if there is no shutter with the given id
|
|
82
|
+
*/
|
|
76
83
|
static setShutter(deviceId: string, level: number): Error | null;
|
|
77
84
|
static speakOnDevice(deviceId: string, message: string, volume?: number): Error | null;
|
|
78
85
|
/**
|
|
@@ -113,4 +120,5 @@ export declare class API {
|
|
|
113
120
|
* @returns {Error | null} In case it failed the Error containing the reason
|
|
114
121
|
*/
|
|
115
122
|
static blockAutomatic(deviceId: string, duration: number, onCollision?: CollisionSolving): Error | null;
|
|
123
|
+
static pressButtonSwitch(deviceId: string, position: ButtonPosition, pressType: ButtonPressType): Error | null;
|
|
116
124
|
}
|
|
@@ -172,6 +172,13 @@ class API {
|
|
|
172
172
|
d.setLight(state, timeout, true, brightness, transitionTime, color, colorTemp);
|
|
173
173
|
return null;
|
|
174
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Changes the position of a given shutter
|
|
177
|
+
* if needed this updates the window position as well
|
|
178
|
+
* @param {string} deviceId The device Id of the shutter
|
|
179
|
+
* @param {number} level The desired new level (0 being open, 100 being closed)
|
|
180
|
+
* @returns {Error | null} Error if there is no shutter with the given id
|
|
181
|
+
*/
|
|
175
182
|
static setShutter(deviceId, level) {
|
|
176
183
|
const d = this.getDevice(deviceId);
|
|
177
184
|
if (d === undefined) {
|
|
@@ -180,10 +187,12 @@ class API {
|
|
|
180
187
|
if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.shutter)) {
|
|
181
188
|
return new Error(`Device with ID ${deviceId} is no Shutter`);
|
|
182
189
|
}
|
|
183
|
-
d.setLevel(level, false);
|
|
184
190
|
if (d.window) {
|
|
185
191
|
// otherwise it will be overridden shortly after
|
|
186
|
-
d.window.
|
|
192
|
+
d.window.setDesiredPosition(level);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
d.setLevel(level, false);
|
|
187
196
|
}
|
|
188
197
|
return null;
|
|
189
198
|
}
|
|
@@ -303,5 +312,15 @@ class API {
|
|
|
303
312
|
d.blockAutomationHandler.disableAutomatic(duration, onCollision);
|
|
304
313
|
return null;
|
|
305
314
|
}
|
|
315
|
+
static pressButtonSwitch(deviceId, position, pressType) {
|
|
316
|
+
const d = this.getDevice(deviceId);
|
|
317
|
+
if (d === undefined) {
|
|
318
|
+
return new Error(`Device with ID ${deviceId} not found`);
|
|
319
|
+
}
|
|
320
|
+
if (!d.deviceCapabilities.includes(DeviceCapability_1.DeviceCapability.buttonSwitch)) {
|
|
321
|
+
return new Error(`Device with ID ${deviceId} is no switch`);
|
|
322
|
+
}
|
|
323
|
+
return d.pressButton(position, pressType);
|
|
324
|
+
}
|
|
306
325
|
}
|
|
307
326
|
exports.API = API;
|
|
@@ -158,7 +158,10 @@ class Utils {
|
|
|
158
158
|
const modToCheck = this.positiveMod(degreeToCheck, 360);
|
|
159
159
|
return modMin < modMax ? modToCheck <= modMax && modToCheck >= modMin : modToCheck > modMin || modToCheck < modMax;
|
|
160
160
|
}
|
|
161
|
-
static deepOmit(obj, keysToOmit) {
|
|
161
|
+
static deepOmit(obj, keysToOmit, level = 1, currentKey = '') {
|
|
162
|
+
if (level > 10) {
|
|
163
|
+
log_service_1.ServerLogService.writeLog(models_1.LogLevel.Warn, `DeepOmit Loop Level ${level} reached for ${currentKey}`);
|
|
164
|
+
}
|
|
162
165
|
// the inner function which will be called recursivley
|
|
163
166
|
return lodash_1.default.transform(obj, (result, value, key) => {
|
|
164
167
|
if (value === undefined || value === null) {
|
|
@@ -179,7 +182,7 @@ class Utils {
|
|
|
179
182
|
const map = value;
|
|
180
183
|
for (const mapName of map.keys()) {
|
|
181
184
|
dict[mapName] = lodash_1.default.isObject(map.get(mapName))
|
|
182
|
-
? this.deepOmit(map.get(mapName), keysToOmit)
|
|
185
|
+
? this.deepOmit(map.get(mapName), keysToOmit, level + 1, `${currentKey}.${lowerKey}.${mapName}`)
|
|
183
186
|
: map.get(mapName);
|
|
184
187
|
}
|
|
185
188
|
result[newKey] = dict;
|
|
@@ -191,7 +194,7 @@ class Utils {
|
|
|
191
194
|
return;
|
|
192
195
|
}
|
|
193
196
|
// if the key is an object run it through the inner function - omitFromObject
|
|
194
|
-
result[key] = lodash_1.default.isObject(value) ? this.deepOmit(value, keysToOmit) : value;
|
|
197
|
+
result[key] = lodash_1.default.isObject(value) ? this.deepOmit(value, keysToOmit, level + 1, `${currentKey}.${key}`) : value;
|
|
195
198
|
});
|
|
196
199
|
}
|
|
197
200
|
static nextMatchingDate(hours = 0, minutes = 0, now = new Date()) {
|