homey-api 3.13.1 → 3.13.2

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.
@@ -20,18 +20,27 @@ class AdvancedFlow extends AdvancedFlowV3 {
20
20
  }
21
21
 
22
22
  static transformSet(item) {
23
- if (item.cards) {
24
- for (const card of Object.values(item.cards)) {
23
+ const nextItem = {
24
+ ...item,
25
+ };
26
+
27
+ if (nextItem.cards) {
28
+ nextItem.cards = { ...nextItem.cards };
29
+
30
+ for (const [key, card] of Object.entries(nextItem.cards)) {
25
31
  if (card.type !== 'trigger' && card.type !== 'condition' && card.type !== 'action') {
26
32
  continue;
27
33
  }
28
34
 
29
- card.ownerUri = card.id.split(':', 3).join(':');
30
- card.id = card.id.split(':').reverse()[0];
35
+ nextItem.cards[key] = {
36
+ ...card,
37
+ ownerUri: card.id.split(':', 3).join(':'),
38
+ id: card.id.split(':').reverse()[0],
39
+ };
31
40
  }
32
41
  }
33
42
 
34
- return item;
43
+ return nextItem;
35
44
  }
36
45
  }
37
46
 
@@ -3,7 +3,6 @@
3
3
  const FlowV3 = require('../../HomeyAPIV3/ManagerFlow/Flow');
4
4
 
5
5
  class Flow extends FlowV3 {
6
-
7
6
  static transformGet(item) {
8
7
  item = super.transformGet(item);
9
8
 
@@ -13,14 +12,14 @@ class Flow extends FlowV3 {
13
12
  }
14
13
 
15
14
  if (Array.isArray(item.conditions)) {
16
- item.conditions.forEach(card => {
15
+ item.conditions.forEach((card) => {
17
16
  card.id = `${card.uri}:${card.id}`;
18
17
  delete card.uri;
19
18
  });
20
19
  }
21
20
 
22
21
  if (Array.isArray(item.actions)) {
23
- item.actions.forEach(card => {
22
+ item.actions.forEach((card) => {
24
23
  card.id = `${card.uri}:${card.id}`;
25
24
  delete card.uri;
26
25
  });
@@ -32,28 +31,36 @@ class Flow extends FlowV3 {
32
31
  }
33
32
 
34
33
  static transformSet(item) {
35
- if (item.trigger) {
36
- item.trigger.uri = item.trigger.id.split(':', 3).join(':');
37
- item.trigger.id = item.trigger.id.split(':').slice(3).join(':');
34
+ const nextItem = {
35
+ ...item,
36
+ };
37
+
38
+ if (nextItem.trigger) {
39
+ nextItem.trigger = {
40
+ ...nextItem.trigger,
41
+ uri: nextItem.trigger.id.split(':', 3).join(':'),
42
+ id: nextItem.trigger.id.split(':').slice(3).join(':'),
43
+ };
38
44
  }
39
45
 
40
- if (Array.isArray(item.conditions)) {
41
- item.conditions.forEach(card => {
42
- card.uri = card.id.split(':', 3).join(':');
43
- card.id = card.id.split(':').slice(3).join(':');
44
- });
46
+ if (Array.isArray(nextItem.conditions)) {
47
+ nextItem.conditions = nextItem.conditions.map((card) => ({
48
+ ...card,
49
+ uri: card.id.split(':', 3).join(':'),
50
+ id: card.id.split(':').slice(3).join(':'),
51
+ }));
45
52
  }
46
53
 
47
- if (Array.isArray(item.actions)) {
48
- item.actions.forEach(card => {
49
- card.uri = card.id.split(':', 3).join(':');
50
- card.id = card.id.split(':').slice(3).join(':');
51
- });
54
+ if (Array.isArray(nextItem.actions)) {
55
+ nextItem.actions = nextItem.actions.map((card) => ({
56
+ ...card,
57
+ uri: card.id.split(':', 3).join(':'),
58
+ id: card.id.split(':').slice(3).join(':'),
59
+ }));
52
60
  }
53
61
 
54
- return item;
62
+ return nextItem;
55
63
  }
56
-
57
64
  }
58
65
 
59
66
  module.exports = Flow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "3.13.1",
3
+ "version": "3.13.2",
4
4
  "description": "Homey API",
5
5
  "main": "index.js",
6
6
  "files": [