homey-api 3.0.0 → 3.0.1

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.
@@ -267,6 +267,19 @@
267
267
  ):
268
268
  string | null;
269
269
 
270
+ hasRole(
271
+
272
+
273
+
274
+
275
+ roleId: string,
276
+
277
+
278
+
279
+
280
+ ):
281
+ any;
282
+
270
283
  createAppAPI(
271
284
 
272
285
 
@@ -348,6 +361,19 @@
348
361
  ):
349
362
  string | null;
350
363
 
364
+ hasRole(
365
+
366
+
367
+
368
+
369
+ roleId: string,
370
+
371
+
372
+
373
+
374
+ ):
375
+ any;
376
+
351
377
  }
352
378
 
353
379
  export class HomeyAPIV2 extends HomeyAPI {
@@ -379,6 +405,19 @@
379
405
  ):
380
406
  string | null;
381
407
 
408
+ hasRole(
409
+
410
+
411
+
412
+
413
+ roleId: string,
414
+
415
+
416
+
417
+
418
+ ):
419
+ any;
420
+
382
421
  }
383
422
 
384
423
  export class HomeyAPIV3 extends HomeyAPIV2 {
@@ -419,6 +458,19 @@
419
458
  ):
420
459
  string | null;
421
460
 
461
+ hasRole(
462
+
463
+
464
+
465
+
466
+ roleId: string,
467
+
468
+
469
+
470
+
471
+ ):
472
+ any;
473
+
422
474
  }
423
475
 
424
476
  export class HomeyAPIV3Cloud extends HomeyAPIV3 {
@@ -455,6 +507,19 @@
455
507
  ):
456
508
  string | null;
457
509
 
510
+ hasRole(
511
+
512
+
513
+
514
+
515
+ roleId: string,
516
+
517
+
518
+
519
+
520
+ ):
521
+ any;
522
+
458
523
  }
459
524
 
460
525
  export class HomeyAPIV3Local extends HomeyAPIV3 {
@@ -491,6 +556,19 @@
491
556
  ):
492
557
  string | null;
493
558
 
559
+ hasRole(
560
+
561
+
562
+
563
+
564
+ roleId: string,
565
+
566
+
567
+
568
+
569
+ ):
570
+ any;
571
+
494
572
  }
495
573
 
496
574
 
@@ -5382,6 +5382,19 @@
5382
5382
  ):
5383
5383
  string | null;
5384
5384
 
5385
+ hasRole(
5386
+
5387
+
5388
+
5389
+
5390
+ roleId: string,
5391
+
5392
+
5393
+
5394
+
5395
+ ):
5396
+ any;
5397
+
5385
5398
  createAppAPI(
5386
5399
 
5387
5400
 
@@ -5463,6 +5476,19 @@
5463
5476
  ):
5464
5477
  string | null;
5465
5478
 
5479
+ hasRole(
5480
+
5481
+
5482
+
5483
+
5484
+ roleId: string,
5485
+
5486
+
5487
+
5488
+
5489
+ ):
5490
+ any;
5491
+
5466
5492
  }
5467
5493
 
5468
5494
  export class HomeyAPIV2 extends HomeyAPI {
@@ -5494,6 +5520,19 @@
5494
5520
  ):
5495
5521
  string | null;
5496
5522
 
5523
+ hasRole(
5524
+
5525
+
5526
+
5527
+
5528
+ roleId: string,
5529
+
5530
+
5531
+
5532
+
5533
+ ):
5534
+ any;
5535
+
5497
5536
  }
5498
5537
 
5499
5538
  export class HomeyAPIV3 extends HomeyAPIV2 {
@@ -5534,6 +5573,19 @@
5534
5573
  ):
5535
5574
  string | null;
5536
5575
 
5576
+ hasRole(
5577
+
5578
+
5579
+
5580
+
5581
+ roleId: string,
5582
+
5583
+
5584
+
5585
+
5586
+ ):
5587
+ any;
5588
+
5537
5589
  }
5538
5590
 
5539
5591
  export class HomeyAPIV3Cloud extends HomeyAPIV3 {
@@ -5570,6 +5622,19 @@
5570
5622
  ):
5571
5623
  string | null;
5572
5624
 
5625
+ hasRole(
5626
+
5627
+
5628
+
5629
+
5630
+ roleId: string,
5631
+
5632
+
5633
+
5634
+
5635
+ ):
5636
+ any;
5637
+
5573
5638
  }
5574
5639
 
5575
5640
  export class HomeyAPIV3Local extends HomeyAPIV3 {
@@ -5606,6 +5671,19 @@
5606
5671
  ):
5607
5672
  string | null;
5608
5673
 
5674
+ hasRole(
5675
+
5676
+
5677
+
5678
+
5679
+ roleId: string,
5680
+
5681
+
5682
+
5683
+
5684
+ ):
5685
+ any;
5686
+
5609
5687
  }
5610
5688
 
5611
5689
  export class HomeyCloudAPI {
@@ -59,6 +59,10 @@ class User extends APIDefinition {
59
59
  return homey;
60
60
  }
61
61
 
62
+ hasRole(roleId) {
63
+ return this.roleIds.includes(roleId);
64
+ }
65
+
62
66
  }
63
67
 
64
68
  module.exports = User;
@@ -80,8 +80,15 @@ class HomeyAPI {
80
80
  });
81
81
 
82
82
  // Set Language
83
- Object.defineProperty(this, 'Language', {
84
- value: properties.Language ?? null,
83
+ Object.defineProperty(this, 'language', {
84
+ value: properties.language ?? null,
85
+ enumerable: true,
86
+ writable: true,
87
+ });
88
+
89
+ // Set Role
90
+ Object.defineProperty(this, 'role', {
91
+ value: properties.role ?? null,
85
92
  enumerable: true,
86
93
  writable: true,
87
94
  });
@@ -158,6 +165,14 @@ class HomeyAPI {
158
165
  return null;
159
166
  }
160
167
 
168
+ /**
169
+ * Check the current role.
170
+ * @param {string} roleId - The role ID, e.g. `owner`, `manager`, `user` or `guest`.
171
+ */
172
+ hasRole(roleId) {
173
+ return this.role === roleId;
174
+ }
175
+
161
176
  /**
162
177
  * Creates a {@link HomeyAPIV3Local} or {@link HomeyAPIV2} instance for use in the Apps SDK.
163
178
  * @param {Object} opts
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ const ManagerDevkitV3 = require('../HomeyAPIV3Local/ManagerDevkit');
4
+
5
+ class ManagerDevkit extends ManagerDevkitV3 {
6
+
7
+ }
8
+
9
+ module.exports = ManagerDevkit;
@@ -5,6 +5,7 @@ const ManagerFlow = require('./HomeyAPIV2/ManagerFlow');
5
5
  const ManagerFlowToken = require('./HomeyAPIV2/ManagerFlowToken');
6
6
  const ManagerDevices = require('./HomeyAPIV2/ManagerDevices');
7
7
  const ManagerDrivers = require('./HomeyAPIV2/ManagerDrivers');
8
+ const ManagerDevkit = require('./HomeyAPIV2/ManagerDevkit');
8
9
  const ManagerInsights = require('./HomeyAPIV2/ManagerInsights');
9
10
 
10
11
  /**
@@ -22,6 +23,7 @@ class HomeyAPIV2 extends HomeyAPIV3 {
22
23
  ManagerFlowToken,
23
24
  ManagerDevices,
24
25
  ManagerDrivers,
26
+ ManagerDevkit,
25
27
  ManagerInsights,
26
28
  };
27
29
 
@@ -16,7 +16,7 @@ class ManagerDevkit extends Manager {
16
16
  form.append('app', app);
17
17
  form.append('env', JSON.stringify(env));
18
18
  form.append('debug', debug ? 'true' : 'false');
19
- form.append('purgseSettings', clean ? 'true' : 'false');
19
+ form.append('purgeSettings', clean ? 'true' : 'false');
20
20
 
21
21
  return this.homey.call({
22
22
  $timeout: 1000 * 60 * 5, // 5 minutes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homey-api",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Homey API",
5
5
  "main": "index.js",
6
6
  "files": [