@kohost/api-client 3.0.0-beta.46 → 3.0.0-beta.47

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.
@@ -30,11 +30,16 @@ var require_code = __commonJS({
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
31
  exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
32
32
  var _CodeOrName = class {
33
+ static {
34
+ __name(this, "_CodeOrName");
35
+ }
33
36
  };
34
- __name(_CodeOrName, "_CodeOrName");
35
37
  exports._CodeOrName = _CodeOrName;
36
38
  exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
37
39
  var Name = class extends _CodeOrName {
40
+ static {
41
+ __name(this, "Name");
42
+ }
38
43
  constructor(s) {
39
44
  super();
40
45
  if (!exports.IDENTIFIER.test(s))
@@ -51,9 +56,11 @@ var require_code = __commonJS({
51
56
  return { [this.str]: 1 };
52
57
  }
53
58
  };
54
- __name(Name, "Name");
55
59
  exports.Name = Name;
56
60
  var _Code = class extends _CodeOrName {
61
+ static {
62
+ __name(this, "_Code");
63
+ }
57
64
  constructor(code) {
58
65
  super();
59
66
  this._items = typeof code === "string" ? [code] : code;
@@ -80,7 +87,6 @@ var require_code = __commonJS({
80
87
  }, {});
81
88
  }
82
89
  };
83
- __name(_Code, "_Code");
84
90
  exports._Code = _Code;
85
91
  exports.nil = new _Code("");
86
92
  function _(strs, ...args) {
@@ -200,12 +206,14 @@ var require_scope = __commonJS({
200
206
  exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
201
207
  var code_1 = require_code();
202
208
  var ValueError = class extends Error {
209
+ static {
210
+ __name(this, "ValueError");
211
+ }
203
212
  constructor(name) {
204
213
  super(`CodeGen: "code" for ${name} not defined`);
205
214
  this.value = name.value;
206
215
  }
207
216
  };
208
- __name(ValueError, "ValueError");
209
217
  var UsedValueState;
210
218
  (function(UsedValueState2) {
211
219
  UsedValueState2[UsedValueState2["Started"] = 0] = "Started";
@@ -217,6 +225,9 @@ var require_scope = __commonJS({
217
225
  var: new code_1.Name("var")
218
226
  };
219
227
  var Scope = class {
228
+ static {
229
+ __name(this, "Scope");
230
+ }
220
231
  constructor({ prefixes, parent } = {}) {
221
232
  this._names = {};
222
233
  this._prefixes = prefixes;
@@ -240,9 +251,11 @@ var require_scope = __commonJS({
240
251
  return this._names[prefix] = { prefix, index: 0 };
241
252
  }
242
253
  };
243
- __name(Scope, "Scope");
244
254
  exports.Scope = Scope;
245
255
  var ValueScopeName = class extends code_1.Name {
256
+ static {
257
+ __name(this, "ValueScopeName");
258
+ }
246
259
  constructor(prefix, nameStr) {
247
260
  super(nameStr);
248
261
  this.prefix = prefix;
@@ -252,10 +265,12 @@ var require_scope = __commonJS({
252
265
  this.scopePath = (0, code_1._)`.${new code_1.Name(property)}[${itemIndex}]`;
253
266
  }
254
267
  };
255
- __name(ValueScopeName, "ValueScopeName");
256
268
  exports.ValueScopeName = ValueScopeName;
257
269
  var line = (0, code_1._)`\n`;
258
270
  var ValueScope = class extends Scope {
271
+ static {
272
+ __name(this, "ValueScope");
273
+ }
259
274
  constructor(opts) {
260
275
  super(opts);
261
276
  this._values = {};
@@ -336,7 +351,6 @@ var require_scope = __commonJS({
336
351
  return code;
337
352
  }
338
353
  };
339
- __name(ValueScope, "ValueScope");
340
354
  exports.ValueScope = ValueScope;
341
355
  }
342
356
  });
@@ -400,6 +414,9 @@ var require_codegen = __commonJS({
400
414
  ADD: new code_1._Code("+")
401
415
  };
402
416
  var Node = class {
417
+ static {
418
+ __name(this, "Node");
419
+ }
403
420
  optimizeNodes() {
404
421
  return this;
405
422
  }
@@ -407,8 +424,10 @@ var require_codegen = __commonJS({
407
424
  return this;
408
425
  }
409
426
  };
410
- __name(Node, "Node");
411
427
  var Def = class extends Node {
428
+ static {
429
+ __name(this, "Def");
430
+ }
412
431
  constructor(varKind, name, rhs) {
413
432
  super();
414
433
  this.varKind = varKind;
@@ -431,8 +450,10 @@ var require_codegen = __commonJS({
431
450
  return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
432
451
  }
433
452
  };
434
- __name(Def, "Def");
435
453
  var Assign = class extends Node {
454
+ static {
455
+ __name(this, "Assign");
456
+ }
436
457
  constructor(lhs, rhs, sideEffects) {
437
458
  super();
438
459
  this.lhs = lhs;
@@ -453,8 +474,10 @@ var require_codegen = __commonJS({
453
474
  return addExprNames(names, this.rhs);
454
475
  }
455
476
  };
456
- __name(Assign, "Assign");
457
477
  var AssignOp = class extends Assign {
478
+ static {
479
+ __name(this, "AssignOp");
480
+ }
458
481
  constructor(lhs, op, rhs, sideEffects) {
459
482
  super(lhs, rhs, sideEffects);
460
483
  this.op = op;
@@ -463,8 +486,10 @@ var require_codegen = __commonJS({
463
486
  return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
464
487
  }
465
488
  };
466
- __name(AssignOp, "AssignOp");
467
489
  var Label = class extends Node {
490
+ static {
491
+ __name(this, "Label");
492
+ }
468
493
  constructor(label) {
469
494
  super();
470
495
  this.label = label;
@@ -474,8 +499,10 @@ var require_codegen = __commonJS({
474
499
  return `${this.label}:` + _n;
475
500
  }
476
501
  };
477
- __name(Label, "Label");
478
502
  var Break = class extends Node {
503
+ static {
504
+ __name(this, "Break");
505
+ }
479
506
  constructor(label) {
480
507
  super();
481
508
  this.label = label;
@@ -486,8 +513,10 @@ var require_codegen = __commonJS({
486
513
  return `break${label};` + _n;
487
514
  }
488
515
  };
489
- __name(Break, "Break");
490
516
  var Throw = class extends Node {
517
+ static {
518
+ __name(this, "Throw");
519
+ }
491
520
  constructor(error) {
492
521
  super();
493
522
  this.error = error;
@@ -499,8 +528,10 @@ var require_codegen = __commonJS({
499
528
  return this.error.names;
500
529
  }
501
530
  };
502
- __name(Throw, "Throw");
503
531
  var AnyCode = class extends Node {
532
+ static {
533
+ __name(this, "AnyCode");
534
+ }
504
535
  constructor(code) {
505
536
  super();
506
537
  this.code = code;
@@ -519,8 +550,10 @@ var require_codegen = __commonJS({
519
550
  return this.code instanceof code_1._CodeOrName ? this.code.names : {};
520
551
  }
521
552
  };
522
- __name(AnyCode, "AnyCode");
523
553
  var ParentNode = class extends Node {
554
+ static {
555
+ __name(this, "ParentNode");
556
+ }
524
557
  constructor(nodes = []) {
525
558
  super();
526
559
  this.nodes = nodes;
@@ -558,21 +591,29 @@ var require_codegen = __commonJS({
558
591
  return this.nodes.reduce((names, n) => addNames(names, n.names), {});
559
592
  }
560
593
  };
561
- __name(ParentNode, "ParentNode");
562
594
  var BlockNode = class extends ParentNode {
595
+ static {
596
+ __name(this, "BlockNode");
597
+ }
563
598
  render(opts) {
564
599
  return "{" + opts._n + super.render(opts) + "}" + opts._n;
565
600
  }
566
601
  };
567
- __name(BlockNode, "BlockNode");
568
602
  var Root = class extends ParentNode {
603
+ static {
604
+ __name(this, "Root");
605
+ }
569
606
  };
570
- __name(Root, "Root");
571
607
  var Else = class extends BlockNode {
608
+ static {
609
+ __name(this, "Else");
610
+ }
572
611
  };
573
- __name(Else, "Else");
574
612
  Else.kind = "else";
575
- var If = class extends BlockNode {
613
+ var If = class _If extends BlockNode {
614
+ static {
615
+ __name(this, "If");
616
+ }
576
617
  constructor(condition, nodes) {
577
618
  super(nodes);
578
619
  this.condition = condition;
@@ -595,10 +636,10 @@ var require_codegen = __commonJS({
595
636
  }
596
637
  if (e) {
597
638
  if (cond === false)
598
- return e instanceof If ? e : e.nodes;
639
+ return e instanceof _If ? e : e.nodes;
599
640
  if (this.nodes.length)
600
641
  return this;
601
- return new If(not(cond), e instanceof If ? [e] : e.nodes);
642
+ return new _If(not(cond), e instanceof _If ? [e] : e.nodes);
602
643
  }
603
644
  if (cond === false || !this.nodes.length)
604
645
  return void 0;
@@ -620,13 +661,17 @@ var require_codegen = __commonJS({
620
661
  return names;
621
662
  }
622
663
  };
623
- __name(If, "If");
624
664
  If.kind = "if";
625
665
  var For = class extends BlockNode {
666
+ static {
667
+ __name(this, "For");
668
+ }
626
669
  };
627
- __name(For, "For");
628
670
  For.kind = "for";
629
671
  var ForLoop = class extends For {
672
+ static {
673
+ __name(this, "ForLoop");
674
+ }
630
675
  constructor(iteration) {
631
676
  super();
632
677
  this.iteration = iteration;
@@ -644,8 +689,10 @@ var require_codegen = __commonJS({
644
689
  return addNames(super.names, this.iteration.names);
645
690
  }
646
691
  };
647
- __name(ForLoop, "ForLoop");
648
692
  var ForRange = class extends For {
693
+ static {
694
+ __name(this, "ForRange");
695
+ }
649
696
  constructor(varKind, name, from, to) {
650
697
  super();
651
698
  this.varKind = varKind;
@@ -663,8 +710,10 @@ var require_codegen = __commonJS({
663
710
  return addExprNames(names, this.to);
664
711
  }
665
712
  };
666
- __name(ForRange, "ForRange");
667
713
  var ForIter = class extends For {
714
+ static {
715
+ __name(this, "ForIter");
716
+ }
668
717
  constructor(loop, varKind, name, iterable) {
669
718
  super();
670
719
  this.loop = loop;
@@ -685,8 +734,10 @@ var require_codegen = __commonJS({
685
734
  return addNames(super.names, this.iterable.names);
686
735
  }
687
736
  };
688
- __name(ForIter, "ForIter");
689
737
  var Func = class extends BlockNode {
738
+ static {
739
+ __name(this, "Func");
740
+ }
690
741
  constructor(name, args, async) {
691
742
  super();
692
743
  this.name = name;
@@ -698,16 +749,20 @@ var require_codegen = __commonJS({
698
749
  return `${_async}function ${this.name}(${this.args})` + super.render(opts);
699
750
  }
700
751
  };
701
- __name(Func, "Func");
702
752
  Func.kind = "func";
703
753
  var Return = class extends ParentNode {
754
+ static {
755
+ __name(this, "Return");
756
+ }
704
757
  render(opts) {
705
758
  return "return " + super.render(opts);
706
759
  }
707
760
  };
708
- __name(Return, "Return");
709
761
  Return.kind = "return";
710
762
  var Try = class extends BlockNode {
763
+ static {
764
+ __name(this, "Try");
765
+ }
711
766
  render(opts) {
712
767
  let code = "try" + super.render(opts);
713
768
  if (this.catch)
@@ -739,8 +794,10 @@ var require_codegen = __commonJS({
739
794
  return names;
740
795
  }
741
796
  };
742
- __name(Try, "Try");
743
797
  var Catch = class extends BlockNode {
798
+ static {
799
+ __name(this, "Catch");
800
+ }
744
801
  constructor(error) {
745
802
  super();
746
803
  this.error = error;
@@ -749,16 +806,20 @@ var require_codegen = __commonJS({
749
806
  return `catch(${this.error})` + super.render(opts);
750
807
  }
751
808
  };
752
- __name(Catch, "Catch");
753
809
  Catch.kind = "catch";
754
810
  var Finally = class extends BlockNode {
811
+ static {
812
+ __name(this, "Finally");
813
+ }
755
814
  render(opts) {
756
815
  return "finally" + super.render(opts);
757
816
  }
758
817
  };
759
- __name(Finally, "Finally");
760
818
  Finally.kind = "finally";
761
819
  var CodeGen = class {
820
+ static {
821
+ __name(this, "CodeGen");
822
+ }
762
823
  constructor(extScope, opts = {}) {
763
824
  this._values = {};
764
825
  this._blockStarts = [];
@@ -1022,7 +1083,6 @@ var require_codegen = __commonJS({
1022
1083
  ns[ns.length - 1] = node;
1023
1084
  }
1024
1085
  };
1025
- __name(CodeGen, "CodeGen");
1026
1086
  exports.CodeGen = CodeGen;
1027
1087
  function addNames(names, from) {
1028
1088
  for (const n in from)
@@ -2771,6 +2831,9 @@ var require_validate = __commonJS({
2771
2831
  }
2772
2832
  __name(strictTypesError, "strictTypesError");
2773
2833
  var KeywordCxt = class {
2834
+ static {
2835
+ __name(this, "KeywordCxt");
2836
+ }
2774
2837
  constructor(it, def, keyword) {
2775
2838
  (0, keyword_1.validateKeywordUsage)(it, def, keyword);
2776
2839
  this.gen = it.gen;
@@ -2942,7 +3005,6 @@ var require_validate = __commonJS({
2942
3005
  }
2943
3006
  }
2944
3007
  };
2945
- __name(KeywordCxt, "KeywordCxt");
2946
3008
  exports.KeywordCxt = KeywordCxt;
2947
3009
  function keywordCode(it, keyword, def, ruleType) {
2948
3010
  const cxt = new KeywordCxt(it, def, keyword);
@@ -3011,13 +3073,15 @@ var require_validation_error = __commonJS({
3011
3073
  "use strict";
3012
3074
  Object.defineProperty(exports, "__esModule", { value: true });
3013
3075
  var ValidationError = class extends Error {
3076
+ static {
3077
+ __name(this, "ValidationError");
3078
+ }
3014
3079
  constructor(errors) {
3015
3080
  super("validation failed");
3016
3081
  this.errors = errors;
3017
3082
  this.ajv = this.validation = true;
3018
3083
  }
3019
3084
  };
3020
- __name(ValidationError, "ValidationError");
3021
3085
  exports.default = ValidationError;
3022
3086
  }
3023
3087
  });
@@ -3029,13 +3093,15 @@ var require_ref_error = __commonJS({
3029
3093
  Object.defineProperty(exports, "__esModule", { value: true });
3030
3094
  var resolve_1 = require_resolve();
3031
3095
  var MissingRefError = class extends Error {
3096
+ static {
3097
+ __name(this, "MissingRefError");
3098
+ }
3032
3099
  constructor(resolver, baseId, ref, msg) {
3033
3100
  super(msg || `can't resolve reference ${ref} from id ${baseId}`);
3034
3101
  this.missingRef = (0, resolve_1.resolveUrl)(resolver, baseId, ref);
3035
3102
  this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(resolver, this.missingRef));
3036
3103
  }
3037
3104
  };
3038
- __name(MissingRefError, "MissingRefError");
3039
3105
  exports.default = MissingRefError;
3040
3106
  }
3041
3107
  });
@@ -3053,6 +3119,9 @@ var require_compile = __commonJS({
3053
3119
  var util_1 = require_util();
3054
3120
  var validate_1 = require_validate();
3055
3121
  var SchemaEnv = class {
3122
+ static {
3123
+ __name(this, "SchemaEnv");
3124
+ }
3056
3125
  constructor(env) {
3057
3126
  var _a;
3058
3127
  this.refs = {};
@@ -3071,7 +3140,6 @@ var require_compile = __commonJS({
3071
3140
  this.refs = {};
3072
3141
  }
3073
3142
  };
3074
- __name(SchemaEnv, "SchemaEnv");
3075
3143
  exports.SchemaEnv = SchemaEnv;
3076
3144
  function compileSchema(sch) {
3077
3145
  const _sch = getCompilingSchema.call(this, sch);
@@ -4479,6 +4547,9 @@ var require_core = __commonJS({
4479
4547
  }
4480
4548
  __name(requiredOptions, "requiredOptions");
4481
4549
  var Ajv = class {
4550
+ static {
4551
+ __name(this, "Ajv");
4552
+ }
4482
4553
  constructor(opts = {}) {
4483
4554
  this.schemas = {};
4484
4555
  this.refs = {};
@@ -4854,7 +4925,6 @@ var require_core = __commonJS({
4854
4925
  }
4855
4926
  }
4856
4927
  };
4857
- __name(Ajv, "Ajv");
4858
4928
  exports.default = Ajv;
4859
4929
  Ajv.ValidationError = validation_error_1.default;
4860
4930
  Ajv.MissingRefError = ref_error_1.default;
@@ -7027,6 +7097,9 @@ var require_ajv = __commonJS({
7027
7097
  var META_SUPPORT_DATA = ["/properties"];
7028
7098
  var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
7029
7099
  var Ajv = class extends core_1.default {
7100
+ static {
7101
+ __name(this, "Ajv");
7102
+ }
7030
7103
  _addVocabularies() {
7031
7104
  super._addVocabularies();
7032
7105
  draft7_1.default.forEach((v) => this.addVocabulary(v));
@@ -7045,7 +7118,6 @@ var require_ajv = __commonJS({
7045
7118
  return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
7046
7119
  }
7047
7120
  };
7048
- __name(Ajv, "Ajv");
7049
7121
  module.exports = exports = Ajv;
7050
7122
  Object.defineProperty(exports, "__esModule", { value: true });
7051
7123
  exports.default = Ajv;
@@ -7625,50 +7697,126 @@ var require_schema = __commonJS({
7625
7697
  }
7626
7698
  });
7627
7699
 
7628
- // src/schemas/switch.json
7629
- var require_switch = __commonJS({
7630
- "src/schemas/switch.json"(exports, module) {
7700
+ // src/schemas/reservation.json
7701
+ var require_reservation = __commonJS({
7702
+ "src/schemas/reservation.json"(exports, module) {
7631
7703
  module.exports = {
7632
7704
  $schema: "http://json-schema.org/draft-07/schema",
7633
- $id: "https://api.kohost.io/schemas/v3/switch.json",
7634
- title: "Switch",
7635
- description: "Any smart switch",
7705
+ $id: "https://api.kohost.io/schemas/v3/reservation.json",
7706
+ title: "Reservation",
7636
7707
  type: "object",
7708
+ required: ["type", "status", "checkInDateTime", "checkOutDateTime"],
7637
7709
  properties: {
7638
7710
  id: {
7639
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
7711
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
7640
7712
  },
7641
- name: {
7713
+ driver: {
7714
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
7715
+ },
7716
+ primaryGuest: {
7642
7717
  type: "string"
7643
7718
  },
7644
7719
  type: {
7645
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
7720
+ type: "string"
7646
7721
  },
7647
- subType: {
7648
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/subType"
7722
+ sharedGuests: {
7723
+ type: "array",
7724
+ items: {
7725
+ type: "string"
7726
+ }
7649
7727
  },
7650
- supportedNotifications: {
7651
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
7728
+ spaceType: {
7729
+ type: "string"
7652
7730
  },
7653
- notification: {
7654
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
7731
+ space: {
7732
+ type: "string"
7655
7733
  },
7656
- driver: {
7657
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
7734
+ status: {
7735
+ type: "string",
7736
+ enum: [
7737
+ "reserved",
7738
+ "checkedIn",
7739
+ "checkedOut",
7740
+ "cancelled",
7741
+ "noShow",
7742
+ "enquired",
7743
+ "requested",
7744
+ "optional"
7745
+ ],
7746
+ description: " reserved - confirmed by both parties, before check-in\n checkedIn - checked in\n checkedOut - checked out\n cancelled - Cancelled\n noShow - No show\n enquired - Confirmed neither by the customer nor enterprise\n requested - Confirmed by the customer but not the enterprise (waitlist)\n optional - Confirmed by the enterprise but not the customer (holding)"
7658
7747
  },
7659
- state: {
7748
+ mobileCheckInStatus: {
7660
7749
  type: "string",
7661
- enum: ["on", "off"]
7750
+ enum: [
7751
+ "ready",
7752
+ "blocked",
7753
+ "preArrivalStepsRequired",
7754
+ "spaceNotAssigned",
7755
+ "spaceNotReady",
7756
+ "checkInTimeNotStarted"
7757
+ ]
7758
+ },
7759
+ mobileCheckInStatusMessage: {
7760
+ type: "string"
7761
+ },
7762
+ confirmationNumber: {
7763
+ type: "string"
7764
+ },
7765
+ checkInDateTime: {
7766
+ type: ["string", "object"],
7767
+ format: "date-time"
7768
+ },
7769
+ checkOutDateTime: {
7770
+ type: ["string", "object"],
7771
+ format: "date-time"
7772
+ },
7773
+ adultCount: {
7774
+ type: "number",
7775
+ default: 1,
7776
+ minimum: 1
7777
+ },
7778
+ childCount: {
7779
+ type: "number",
7780
+ default: 0
7781
+ },
7782
+ revenue: {
7783
+ type: "array",
7784
+ items: {
7785
+ type: "object",
7786
+ properties: {
7787
+ date: {
7788
+ type: "string",
7789
+ format: "date-time"
7790
+ },
7791
+ amount: {
7792
+ type: "number"
7793
+ },
7794
+ type: {
7795
+ type: "string",
7796
+ enum: ["service", "product"]
7797
+ }
7798
+ }
7799
+ }
7800
+ },
7801
+ rateSuppressed: {
7802
+ type: "boolean"
7803
+ },
7804
+ payment: {
7805
+ type: "string"
7806
+ },
7807
+ company: {
7808
+ type: "string"
7809
+ },
7810
+ travelAgent: {
7811
+ type: "string"
7662
7812
  },
7663
7813
  systemData: {
7664
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
7814
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
7665
7815
  },
7666
- watts: {
7667
- $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
7816
+ metadata: {
7817
+ ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/metadata"
7668
7818
  }
7669
- },
7670
- additionalProperties: false,
7671
- required: ["id", "type", "systemData", "state", "driver"]
7819
+ }
7672
7820
  };
7673
7821
  }
7674
7822
  });
@@ -7676,14 +7824,17 @@ var require_switch = __commonJS({
7676
7824
  // src/Errors/AppError.js
7677
7825
  var require_AppError = __commonJS({
7678
7826
  "src/Errors/AppError.js"(exports, module) {
7679
- module.exports = /* @__PURE__ */ __name(class AppError extends Error {
7827
+ module.exports = class AppError extends Error {
7828
+ static {
7829
+ __name(this, "AppError");
7830
+ }
7680
7831
  constructor(message = "Internal Server Error", options) {
7681
7832
  super(message, options);
7682
7833
  this.type = this.constructor.name;
7683
7834
  this.statusCode = 500;
7684
7835
  Object.setPrototypeOf(this, AppError.prototype);
7685
7836
  }
7686
- }, "AppError");
7837
+ };
7687
7838
  }
7688
7839
  });
7689
7840
 
@@ -7691,13 +7842,16 @@ var require_AppError = __commonJS({
7691
7842
  var require_AuthenticationError = __commonJS({
7692
7843
  "src/Errors/AuthenticationError.js"(exports, module) {
7693
7844
  var AppError = require_AppError();
7694
- module.exports = /* @__PURE__ */ __name(class AuthenticationError extends AppError {
7845
+ module.exports = class AuthenticationError extends AppError {
7846
+ static {
7847
+ __name(this, "AuthenticationError");
7848
+ }
7695
7849
  constructor(message = "Authentication Error", options = {}) {
7696
7850
  super(message, options);
7697
7851
  this.statusCode = 401;
7698
7852
  Object.setPrototypeOf(this, AuthenticationError.prototype);
7699
7853
  }
7700
- }, "AuthenticationError");
7854
+ };
7701
7855
  }
7702
7856
  });
7703
7857
 
@@ -7705,13 +7859,16 @@ var require_AuthenticationError = __commonJS({
7705
7859
  var require_AuthorizationError = __commonJS({
7706
7860
  "src/Errors/AuthorizationError.js"(exports, module) {
7707
7861
  var AppError = require_AppError();
7708
- module.exports = /* @__PURE__ */ __name(class AuthorizationError extends AppError {
7862
+ module.exports = class AuthorizationError extends AppError {
7863
+ static {
7864
+ __name(this, "AuthorizationError");
7865
+ }
7709
7866
  constructor(message = "Authorization Error", options = {}) {
7710
7867
  super(message, options);
7711
7868
  this.statusCode = 403;
7712
7869
  Object.setPrototypeOf(this, AuthorizationError.prototype);
7713
7870
  }
7714
- }, "AuthorizationError");
7871
+ };
7715
7872
  }
7716
7873
  });
7717
7874
 
@@ -7719,13 +7876,16 @@ var require_AuthorizationError = __commonJS({
7719
7876
  var require_DeviceCommError = __commonJS({
7720
7877
  "src/Errors/DeviceCommError.js"(exports, module) {
7721
7878
  var AppError = require_AppError();
7722
- module.exports = /* @__PURE__ */ __name(class DeviceCommError extends AppError {
7879
+ module.exports = class DeviceCommError extends AppError {
7880
+ static {
7881
+ __name(this, "DeviceCommError");
7882
+ }
7723
7883
  constructor(message = "Device Communication Error", options = {}) {
7724
7884
  super(message, options);
7725
7885
  this.statusCode = 503;
7726
7886
  Object.setPrototypeOf(this, DeviceCommError.prototype);
7727
7887
  }
7728
- }, "DeviceCommError");
7888
+ };
7729
7889
  }
7730
7890
  });
7731
7891
 
@@ -7733,13 +7893,16 @@ var require_DeviceCommError = __commonJS({
7733
7893
  var require_LoginError = __commonJS({
7734
7894
  "src/Errors/LoginError.js"(exports, module) {
7735
7895
  var AppError = require_AppError();
7736
- module.exports = /* @__PURE__ */ __name(class LoginError extends AppError {
7896
+ module.exports = class LoginError extends AppError {
7897
+ static {
7898
+ __name(this, "LoginError");
7899
+ }
7737
7900
  constructor(message = "Invalid Login information provided", options = {}) {
7738
7901
  super(message, options);
7739
7902
  this.statusCode = 401;
7740
7903
  Object.setPrototypeOf(this, LoginError.prototype);
7741
7904
  }
7742
- }, "LoginError");
7905
+ };
7743
7906
  }
7744
7907
  });
7745
7908
 
@@ -7747,13 +7910,16 @@ var require_LoginError = __commonJS({
7747
7910
  var require_NotFoundError = __commonJS({
7748
7911
  "src/Errors/NotFoundError.js"(exports, module) {
7749
7912
  var AppError = require_AppError();
7750
- module.exports = /* @__PURE__ */ __name(class NotFoundError extends AppError {
7913
+ module.exports = class NotFoundError extends AppError {
7914
+ static {
7915
+ __name(this, "NotFoundError");
7916
+ }
7751
7917
  constructor(message = "Resource Not Found", options = {}) {
7752
7918
  super(message, options);
7753
7919
  this.statusCode = 404;
7754
7920
  Object.setPrototypeOf(this, NotFoundError.prototype);
7755
7921
  }
7756
- }, "NotFoundError");
7922
+ };
7757
7923
  }
7758
7924
  });
7759
7925
 
@@ -7761,13 +7927,16 @@ var require_NotFoundError = __commonJS({
7761
7927
  var require_RequestError = __commonJS({
7762
7928
  "src/Errors/RequestError.js"(exports, module) {
7763
7929
  var AppError = require_AppError();
7764
- module.exports = /* @__PURE__ */ __name(class RequestError extends AppError {
7930
+ module.exports = class RequestError extends AppError {
7931
+ static {
7932
+ __name(this, "RequestError");
7933
+ }
7765
7934
  constructor(message = "Bad Request", options = {}) {
7766
7935
  super(message, options);
7767
7936
  this.statusCode = 400;
7768
7937
  Object.setPrototypeOf(this, RequestError.prototype);
7769
7938
  }
7770
- }, "RequestError");
7939
+ };
7771
7940
  }
7772
7941
  });
7773
7942
 
@@ -7775,13 +7944,16 @@ var require_RequestError = __commonJS({
7775
7944
  var require_SystemCommError = __commonJS({
7776
7945
  "src/Errors/SystemCommError.js"(exports, module) {
7777
7946
  var AppError = require_AppError();
7778
- module.exports = /* @__PURE__ */ __name(class SystemCommError extends AppError {
7947
+ module.exports = class SystemCommError extends AppError {
7948
+ static {
7949
+ __name(this, "SystemCommError");
7950
+ }
7779
7951
  constructor(message = "System Communication Error", options = {}) {
7780
7952
  super(message, options);
7781
7953
  this.statusCode = 503;
7782
7954
  Object.setPrototypeOf(this, SystemCommError.prototype);
7783
7955
  }
7784
- }, "SystemCommError");
7956
+ };
7785
7957
  }
7786
7958
  });
7787
7959
 
@@ -7789,13 +7961,16 @@ var require_SystemCommError = __commonJS({
7789
7961
  var require_TokenExpiredError = __commonJS({
7790
7962
  "src/Errors/TokenExpiredError.js"(exports, module) {
7791
7963
  var AppError = require_AppError();
7792
- module.exports = /* @__PURE__ */ __name(class TokenExpiredError extends AppError {
7964
+ module.exports = class TokenExpiredError extends AppError {
7965
+ static {
7966
+ __name(this, "TokenExpiredError");
7967
+ }
7793
7968
  constructor(message = "Token Expired", options = {}) {
7794
7969
  super(message, options);
7795
7970
  this.statusCode = 401;
7796
7971
  Object.setPrototypeOf(this, TokenExpiredError.prototype);
7797
7972
  }
7798
- }, "TokenExpiredError");
7973
+ };
7799
7974
  }
7800
7975
  });
7801
7976
 
@@ -7803,13 +7978,16 @@ var require_TokenExpiredError = __commonJS({
7803
7978
  var require_UnprocessableRequestError = __commonJS({
7804
7979
  "src/Errors/UnprocessableRequestError.js"(exports, module) {
7805
7980
  var AppError = require_AppError();
7806
- module.exports = /* @__PURE__ */ __name(class UnprocessableRequestError extends AppError {
7981
+ module.exports = class UnprocessableRequestError extends AppError {
7982
+ static {
7983
+ __name(this, "UnprocessableRequestError");
7984
+ }
7807
7985
  constructor(message = "Unprocessable Request Error", options = {}) {
7808
7986
  super(message, options);
7809
7987
  this.statusCode = 422;
7810
7988
  Object.setPrototypeOf(this, UnprocessableRequestError.prototype);
7811
7989
  }
7812
- }, "UnprocessableRequestError");
7990
+ };
7813
7991
  }
7814
7992
  });
7815
7993
 
@@ -7817,13 +7995,16 @@ var require_UnprocessableRequestError = __commonJS({
7817
7995
  var require_ValidationError = __commonJS({
7818
7996
  "src/Errors/ValidationError.js"(exports, module) {
7819
7997
  var AppError = require_AppError();
7820
- module.exports = /* @__PURE__ */ __name(class ValidationError extends AppError {
7998
+ module.exports = class ValidationError extends AppError {
7999
+ static {
8000
+ __name(this, "ValidationError");
8001
+ }
7821
8002
  constructor(message = "Validation Error", options = {}) {
7822
8003
  super(message, options);
7823
8004
  this.statusCode = 400;
7824
8005
  Object.setPrototypeOf(this, ValidationError.prototype);
7825
8006
  }
7826
- }, "ValidationError");
8007
+ };
7827
8008
  }
7828
8009
  });
7829
8010
 
@@ -7908,6 +8089,9 @@ var require_kohost = __commonJS({
7908
8089
  var { ValidationError } = require_Errors();
7909
8090
  var { customAlphabet: generate } = (init_index_browser(), __toCommonJS(index_browser_exports));
7910
8091
  var Kohost = class {
8092
+ static {
8093
+ __name(this, "Kohost");
8094
+ }
7911
8095
  constructor(data) {
7912
8096
  if (!this.schema) {
7913
8097
  throw new Error("Schema is not defined");
@@ -7982,38 +8166,281 @@ var require_kohost = __commonJS({
7982
8166
  return obj;
7983
8167
  }
7984
8168
  };
7985
- __name(Kohost, "Kohost");
7986
8169
  module.exports = Kohost;
7987
8170
  }
7988
8171
  });
7989
8172
 
7990
- // src/Models/switch.js
7991
- var require_switch2 = __commonJS({
7992
- "src/Models/switch.js"(exports, module) {
8173
+ // src/Models/reservation.js
8174
+ var require_reservation2 = __commonJS({
8175
+ "src/Models/reservation.js"(exports, module) {
7993
8176
  var schemas = require_schema();
7994
- var schema = require_switch();
8177
+ var schema = require_reservation();
7995
8178
  var Kohost = require_kohost();
7996
8179
  schemas.add(schema);
7997
8180
  var validator = schemas.compile(schema);
7998
- var Switch = class extends Kohost {
8181
+ var Reservation = class extends Kohost {
8182
+ static {
8183
+ __name(this, "Reservation");
8184
+ }
7999
8185
  constructor(data) {
8000
8186
  super(data);
8001
8187
  }
8188
+ get peopleCount() {
8189
+ return this.adultCount + this.childCount;
8190
+ }
8191
+ get hasPayment() {
8192
+ return this.paymentId?.length > 0;
8193
+ }
8194
+ range(tz) {
8195
+ const start = new Date(this.checkInDateTime);
8196
+ const end = new Date(this.checkOutDateTime);
8197
+ if (start.getDate() === end.getDate() && start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
8198
+ return `${start.toLocaleString("default", {
8199
+ month: "short",
8200
+ timeZone: tz
8201
+ })} ${start.toLocaleString("default", {
8202
+ timeZone: tz,
8203
+ day: "numeric"
8204
+ })}`;
8205
+ }
8206
+ if (start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
8207
+ return `${start.toLocaleString("default", {
8208
+ month: "short",
8209
+ timeZone: tz
8210
+ })} ${start.toLocaleString("default", {
8211
+ timeZone: tz,
8212
+ day: "numeric"
8213
+ })}-${end.toLocaleString("default", {
8214
+ timeZone: tz,
8215
+ day: "numeric"
8216
+ })}`;
8217
+ }
8218
+ return `${start.toLocaleString("default", {
8219
+ month: "short",
8220
+ timeZone: tz
8221
+ })} ${start.getDate()} - ${end.toLocaleString("default", {
8222
+ month: "short",
8223
+ timeZone: tz
8224
+ })} ${end.getDate()}`;
8225
+ }
8226
+ checkInTime(tz) {
8227
+ return new Date(this.checkInDateTime).toLocaleString("default", {
8228
+ hour: "numeric",
8229
+ minute: "numeric",
8230
+ timeZone: tz
8231
+ });
8232
+ }
8233
+ checkOutTime(tz) {
8234
+ return new Date(this.checkOutDateTime).toLocaleString("default", {
8235
+ hour: "numeric",
8236
+ minute: "numeric",
8237
+ timeZone: tz
8238
+ });
8239
+ }
8002
8240
  };
8003
- __name(Switch, "Switch");
8004
- Object.defineProperty(Switch.prototype, "schema", {
8241
+ Object.defineProperty(Reservation.prototype, "schema", {
8005
8242
  value: schema
8006
8243
  });
8007
- Object.defineProperty(Switch.prototype, "validator", {
8244
+ Object.defineProperty(Reservation.prototype, "validator", {
8008
8245
  get: function() {
8009
8246
  return validator;
8010
8247
  }
8011
8248
  });
8012
- Object.defineProperty(Switch, "validProperties", {
8249
+ Object.defineProperty(Reservation, "validProperties", {
8013
8250
  value: Object.keys(schema.properties)
8014
8251
  });
8015
- Object.defineProperty(Switch, "actionProperties", {
8016
- value: ["state"]
8252
+ module.exports = Reservation;
8253
+ }
8254
+ });
8255
+
8256
+ // src/schemas/mediaFile.json
8257
+ var require_mediaFile = __commonJS({
8258
+ "src/schemas/mediaFile.json"(exports, module) {
8259
+ module.exports = {
8260
+ $schema: "http://json-schema.org/draft-07/schema",
8261
+ $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
8262
+ title: "Media File",
8263
+ description: "Any media file",
8264
+ type: "object",
8265
+ properties: {
8266
+ id: {
8267
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
8268
+ },
8269
+ type: {
8270
+ type: "string",
8271
+ default: "mediaFile"
8272
+ },
8273
+ fileHash: {
8274
+ type: "string"
8275
+ },
8276
+ mimeType: {
8277
+ type: "string",
8278
+ enum: [
8279
+ "image/*",
8280
+ "image/jpeg",
8281
+ "image/png",
8282
+ "image/gif",
8283
+ "image/webp",
8284
+ "image/avif",
8285
+ "image/svg+xml",
8286
+ "application/pdf"
8287
+ ]
8288
+ },
8289
+ data: {
8290
+ type: "string"
8291
+ },
8292
+ url: {
8293
+ type: "string",
8294
+ format: "uri"
8295
+ },
8296
+ width: {
8297
+ type: "integer",
8298
+ minimum: 0
8299
+ },
8300
+ height: {
8301
+ type: "integer",
8302
+ minimum: 0
8303
+ },
8304
+ size: {
8305
+ type: "integer",
8306
+ minimum: 0,
8307
+ description: "Size in bytes"
8308
+ },
8309
+ uploadUrl: {
8310
+ type: "string",
8311
+ format: "uri"
8312
+ },
8313
+ uploadUrlExpires: {
8314
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
8315
+ },
8316
+ createdBy: {
8317
+ type: "string"
8318
+ },
8319
+ systemData: {
8320
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
8321
+ }
8322
+ },
8323
+ additionalProperties: false,
8324
+ required: ["id", "type"]
8325
+ };
8326
+ }
8327
+ });
8328
+
8329
+ // src/Models/mediaFile.js
8330
+ var require_mediaFile2 = __commonJS({
8331
+ "src/Models/mediaFile.js"(exports, module) {
8332
+ var schemas = require_schema();
8333
+ var schema = require_mediaFile();
8334
+ var Kohost = require_kohost();
8335
+ var { RequestError } = require_Errors();
8336
+ schemas.add(schema);
8337
+ var validator = schemas.compile(schema);
8338
+ var MediaFile = class extends Kohost {
8339
+ static {
8340
+ __name(this, "MediaFile");
8341
+ }
8342
+ constructor(data) {
8343
+ super(data);
8344
+ }
8345
+ createImageVariant(params) {
8346
+ if (this.mimeType != "image/*")
8347
+ throw new RequestError("Only dynamic images can have variants");
8348
+ const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
8349
+ return this.url.replace(/\/public$/, `/${query}`);
8350
+ }
8351
+ };
8352
+ Object.defineProperty(MediaFile.prototype, "schema", {
8353
+ value: schema
8354
+ });
8355
+ Object.defineProperty(MediaFile.prototype, "validator", {
8356
+ get: function() {
8357
+ return validator;
8358
+ }
8359
+ });
8360
+ Object.defineProperty(MediaFile, "validProperties", {
8361
+ value: Object.keys(schema.properties)
8362
+ });
8363
+ module.exports = MediaFile;
8364
+ }
8365
+ });
8366
+
8367
+ // src/schemas/switch.json
8368
+ var require_switch = __commonJS({
8369
+ "src/schemas/switch.json"(exports, module) {
8370
+ module.exports = {
8371
+ $schema: "http://json-schema.org/draft-07/schema",
8372
+ $id: "https://api.kohost.io/schemas/v3/switch.json",
8373
+ title: "Switch",
8374
+ description: "Any smart switch",
8375
+ type: "object",
8376
+ properties: {
8377
+ id: {
8378
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/id"
8379
+ },
8380
+ name: {
8381
+ type: "string"
8382
+ },
8383
+ type: {
8384
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/type"
8385
+ },
8386
+ subType: {
8387
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/subType"
8388
+ },
8389
+ supportedNotifications: {
8390
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
8391
+ },
8392
+ notification: {
8393
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/notification"
8394
+ },
8395
+ driver: {
8396
+ $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
8397
+ },
8398
+ state: {
8399
+ type: "string",
8400
+ enum: ["on", "off"]
8401
+ },
8402
+ systemData: {
8403
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/systemData"
8404
+ },
8405
+ watts: {
8406
+ $ref: "https://api.kohost.io/schemas/v3/definitions/device.json#/definitions/watts"
8407
+ }
8408
+ },
8409
+ additionalProperties: false,
8410
+ required: ["id", "type", "systemData", "state", "driver"]
8411
+ };
8412
+ }
8413
+ });
8414
+
8415
+ // src/Models/switch.js
8416
+ var require_switch2 = __commonJS({
8417
+ "src/Models/switch.js"(exports, module) {
8418
+ var schemas = require_schema();
8419
+ var schema = require_switch();
8420
+ var Kohost = require_kohost();
8421
+ schemas.add(schema);
8422
+ var validator = schemas.compile(schema);
8423
+ var Switch = class extends Kohost {
8424
+ static {
8425
+ __name(this, "Switch");
8426
+ }
8427
+ constructor(data) {
8428
+ super(data);
8429
+ }
8430
+ };
8431
+ Object.defineProperty(Switch.prototype, "schema", {
8432
+ value: schema
8433
+ });
8434
+ Object.defineProperty(Switch.prototype, "validator", {
8435
+ get: function() {
8436
+ return validator;
8437
+ }
8438
+ });
8439
+ Object.defineProperty(Switch, "validProperties", {
8440
+ value: Object.keys(schema.properties)
8441
+ });
8442
+ Object.defineProperty(Switch, "actionProperties", {
8443
+ value: ["state"]
8017
8444
  });
8018
8445
  module.exports = Switch;
8019
8446
  }
@@ -8137,11 +8564,13 @@ var require_alarm2 = __commonJS({
8137
8564
  schemas.add(schema);
8138
8565
  var validator = schemas.compile(schema);
8139
8566
  var Alarm = class extends Kohost {
8567
+ static {
8568
+ __name(this, "Alarm");
8569
+ }
8140
8570
  constructor(data) {
8141
8571
  super(data);
8142
8572
  }
8143
8573
  };
8144
- __name(Alarm, "Alarm");
8145
8574
  Object.defineProperty(Alarm.prototype, "schema", {
8146
8575
  value: schema
8147
8576
  });
@@ -8215,6 +8644,9 @@ var require_dimmer2 = __commonJS({
8215
8644
  schemas.add(schema);
8216
8645
  var validator = schemas.compile(schema);
8217
8646
  var Dimmer = class extends Kohost {
8647
+ static {
8648
+ __name(this, "Dimmer");
8649
+ }
8218
8650
  constructor(data) {
8219
8651
  super(data);
8220
8652
  }
@@ -8234,7 +8666,6 @@ var require_dimmer2 = __commonJS({
8234
8666
  return delta;
8235
8667
  }
8236
8668
  };
8237
- __name(Dimmer, "Dimmer");
8238
8669
  Object.defineProperty(Dimmer.prototype, "schema", {
8239
8670
  value: schema
8240
8671
  });
@@ -8313,11 +8744,13 @@ var require_lock2 = __commonJS({
8313
8744
  schemas.add(schema);
8314
8745
  var validator = schemas.compile(schema);
8315
8746
  var Lock = class extends Kohost {
8747
+ static {
8748
+ __name(this, "Lock");
8749
+ }
8316
8750
  constructor(data) {
8317
8751
  super(data);
8318
8752
  }
8319
8753
  };
8320
- __name(Lock, "Lock");
8321
8754
  Object.defineProperty(Lock.prototype, "schema", {
8322
8755
  value: schema
8323
8756
  });
@@ -8504,6 +8937,9 @@ var require_thermostat2 = __commonJS({
8504
8937
  schemas.add(schema);
8505
8938
  var validator = schemas.compile(schema);
8506
8939
  var Thermostat = class extends Kohost {
8940
+ static {
8941
+ __name(this, "Thermostat");
8942
+ }
8507
8943
  constructor(data) {
8508
8944
  super(data);
8509
8945
  }
@@ -8549,7 +8985,6 @@ var require_thermostat2 = __commonJS({
8549
8985
  return delta;
8550
8986
  }
8551
8987
  };
8552
- __name(Thermostat, "Thermostat");
8553
8988
  Object.defineProperty(Thermostat.prototype, "schema", {
8554
8989
  value: schema
8555
8990
  });
@@ -8626,6 +9061,9 @@ var require_windowCovering2 = __commonJS({
8626
9061
  schemas.add(schema);
8627
9062
  var validator = schemas.compile(schema);
8628
9063
  var WindowCovering = class extends Kohost {
9064
+ static {
9065
+ __name(this, "WindowCovering");
9066
+ }
8629
9067
  constructor(data) {
8630
9068
  super(data);
8631
9069
  }
@@ -8645,7 +9083,6 @@ var require_windowCovering2 = __commonJS({
8645
9083
  return delta;
8646
9084
  }
8647
9085
  };
8648
- __name(WindowCovering, "WindowCovering");
8649
9086
  Object.defineProperty(WindowCovering.prototype, "schema", {
8650
9087
  value: schema
8651
9088
  });
@@ -8672,7 +9109,15 @@ var require_identification = __commonJS({
8672
9109
  $id: "https://api.kohost.io/schemas/v3/identification.json",
8673
9110
  title: "Identification",
8674
9111
  type: "object",
8675
- required: ["type", "number"],
9112
+ required: ["type"],
9113
+ oneOf: [
9114
+ {
9115
+ required: ["number"]
9116
+ },
9117
+ {
9118
+ required: ["encryptedNumber"]
9119
+ }
9120
+ ],
8676
9121
  properties: {
8677
9122
  id: {
8678
9123
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
@@ -8684,6 +9129,12 @@ var require_identification = __commonJS({
8684
9129
  number: {
8685
9130
  string: "string"
8686
9131
  },
9132
+ maskedNumber: {
9133
+ string: "string"
9134
+ },
9135
+ encryptedNumber: {
9136
+ string: "string"
9137
+ },
8687
9138
  issued: {
8688
9139
  type: ["string", "object"],
8689
9140
  format: "date-time"
@@ -8726,6 +9177,9 @@ var require_identification2 = __commonJS({
8726
9177
  schemas.add(schema);
8727
9178
  var validator = schemas.compile(schema);
8728
9179
  var Identification = class extends Kohost {
9180
+ static {
9181
+ __name(this, "Identification");
9182
+ }
8729
9183
  constructor(data) {
8730
9184
  super(data);
8731
9185
  }
@@ -8733,7 +9187,6 @@ var require_identification2 = __commonJS({
8733
9187
  return new Date(this.expirationDate) < /* @__PURE__ */ new Date();
8734
9188
  }
8735
9189
  };
8736
- __name(Identification, "Identification");
8737
9190
  Object.defineProperty(Identification.prototype, "schema", {
8738
9191
  value: schema
8739
9192
  });
@@ -8793,7 +9246,7 @@ var require_user = __commonJS({
8793
9246
  type: "string"
8794
9247
  },
8795
9248
  photo: {
8796
- type: "string"
9249
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
8797
9250
  },
8798
9251
  jobTitle: {
8799
9252
  type: "string"
@@ -8847,7 +9300,7 @@ var require_user = __commonJS({
8847
9300
  files: {
8848
9301
  type: "array",
8849
9302
  items: {
8850
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/file"
9303
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
8851
9304
  }
8852
9305
  },
8853
9306
  identifications: {
@@ -8881,6 +9334,15 @@ var require_user = __commonJS({
8881
9334
  }
8882
9335
  }
8883
9336
  },
9337
+ reservations: {
9338
+ type: "array",
9339
+ items: {
9340
+ $ref: "https://api.kohost.io/schemas/v3/reservation.json"
9341
+ }
9342
+ },
9343
+ spaceName: {
9344
+ type: "string"
9345
+ },
8884
9346
  createdAt: {
8885
9347
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
8886
9348
  },
@@ -8927,6 +9389,10 @@ var require_payment = __commonJS({
8927
9389
  "vpay"
8928
9390
  ]
8929
9391
  },
9392
+ enabled: {
9393
+ type: "boolean",
9394
+ default: true
9395
+ },
8930
9396
  storageData: {
8931
9397
  type: ["string", "null"]
8932
9398
  },
@@ -9001,12 +9467,21 @@ var require_user2 = __commonJS({
9001
9467
  var schema = require_user();
9002
9468
  var paymentSchema = require_payment();
9003
9469
  var Kohost = require_kohost();
9470
+ var MediaFile = require_mediaFile2();
9471
+ var Reservation = require_reservation2();
9004
9472
  var { nanoid: nanoid3 } = (init_index_browser2(), __toCommonJS(index_browser_exports2));
9005
9473
  schemas.add(paymentSchema);
9006
9474
  schemas.add(schema);
9007
9475
  var validator = schemas.compile(schema);
9008
9476
  var User = class extends Kohost {
9477
+ static {
9478
+ __name(this, "User");
9479
+ }
9009
9480
  constructor(data) {
9481
+ if (data.photo)
9482
+ data.photo = new MediaFile(data.photo);
9483
+ if (data.reservations)
9484
+ data.reservations = data.reservations.map((res) => new Reservation(res));
9010
9485
  super(data);
9011
9486
  }
9012
9487
  static validatePhone(phoneNumber) {
@@ -9021,7 +9496,6 @@ var require_user2 = __commonJS({
9021
9496
  return await nanoid3(len);
9022
9497
  }
9023
9498
  };
9024
- __name(User, "User");
9025
9499
  Object.defineProperty(User.prototype, "schema", {
9026
9500
  value: schema
9027
9501
  });
@@ -9125,7 +9599,7 @@ var require_systemUser = __commonJS({
9125
9599
  files: {
9126
9600
  type: "array",
9127
9601
  items: {
9128
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/file"
9602
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json#"
9129
9603
  }
9130
9604
  },
9131
9605
  identifications: {
@@ -9163,6 +9637,9 @@ var require_systemUser2 = __commonJS({
9163
9637
  schemas.add(schema);
9164
9638
  var validator = schemas.compile(schema);
9165
9639
  var SystemUser = class extends Kohost {
9640
+ static {
9641
+ __name(this, "SystemUser");
9642
+ }
9166
9643
  constructor(data) {
9167
9644
  super(data);
9168
9645
  }
@@ -9175,7 +9652,6 @@ var require_systemUser2 = __commonJS({
9175
9652
  return regex.test(email);
9176
9653
  }
9177
9654
  };
9178
- __name(SystemUser, "SystemUser");
9179
9655
  Object.defineProperty(SystemUser.prototype, "schema", {
9180
9656
  value: schema
9181
9657
  });
@@ -9257,11 +9733,13 @@ var require_courtesy2 = __commonJS({
9257
9733
  schemas.add(schema);
9258
9734
  var validator = schemas.compile(schema);
9259
9735
  var Courtesy = class extends Kohost {
9736
+ static {
9737
+ __name(this, "Courtesy");
9738
+ }
9260
9739
  constructor(data) {
9261
9740
  super(data);
9262
9741
  }
9263
9742
  };
9264
- __name(Courtesy, "Courtesy");
9265
9743
  Object.defineProperty(Courtesy.prototype, "schema", {
9266
9744
  value: schema
9267
9745
  });
@@ -9345,11 +9823,13 @@ var require_camera2 = __commonJS({
9345
9823
  schemas.add(schema);
9346
9824
  var validator = schemas.compile(schema);
9347
9825
  var Camera = class extends Kohost {
9826
+ static {
9827
+ __name(this, "Camera");
9828
+ }
9348
9829
  constructor(data) {
9349
9830
  super(data);
9350
9831
  }
9351
9832
  };
9352
- __name(Camera, "Camera");
9353
9833
  Object.defineProperty(Camera.prototype, "schema", {
9354
9834
  value: schema
9355
9835
  });
@@ -9412,11 +9892,13 @@ var require_motionSensor2 = __commonJS({
9412
9892
  schemas.add(schema);
9413
9893
  var validator = schemas.compile(schema);
9414
9894
  var MotionSensor = class extends Kohost {
9895
+ static {
9896
+ __name(this, "MotionSensor");
9897
+ }
9415
9898
  constructor(data) {
9416
9899
  super(data);
9417
9900
  }
9418
9901
  };
9419
- __name(MotionSensor, "MotionSensor");
9420
9902
  Object.defineProperty(MotionSensor.prototype, "schema", {
9421
9903
  value: schema
9422
9904
  });
@@ -9631,11 +10113,13 @@ var require_mediaSource2 = __commonJS({
9631
10113
  schemas.add(schema);
9632
10114
  var validator = schemas.compile(schema);
9633
10115
  var MediaSource = class extends Kohost {
10116
+ static {
10117
+ __name(this, "MediaSource");
10118
+ }
9634
10119
  constructor(data) {
9635
10120
  super(data);
9636
10121
  }
9637
10122
  };
9638
- __name(MediaSource, "MediaSource");
9639
10123
  Object.defineProperty(MediaSource.prototype, "schema", {
9640
10124
  value: schema
9641
10125
  });
@@ -9740,21 +10224,6 @@ var require_room = __commonJS({
9740
10224
  $ref: "https://api.kohost.io/schemas/v3/alarm.json"
9741
10225
  }
9742
10226
  },
9743
- scenes: {
9744
- type: "array",
9745
- default: [],
9746
- items: {
9747
- description: "A list of scene IDs for later population, or entire scene objects",
9748
- oneOf: [
9749
- {
9750
- $ref: "https://api.kohost.io/schemas/v3/scene.json"
9751
- },
9752
- {
9753
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
9754
- }
9755
- ]
9756
- }
9757
- },
9758
10227
  occupiedAt: {
9759
10228
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/createdAt"
9760
10229
  },
@@ -10551,12 +11020,15 @@ var require_scene = __commonJS({
10551
11020
  },
10552
11021
  fanMode: {
10553
11022
  $ref: "https://api.kohost.io/schemas/v3/thermostat.json#/properties/fanMode"
11023
+ },
11024
+ setpointDelta: {
11025
+ type: "number"
10554
11026
  }
10555
11027
  }
10556
11028
  },
10557
11029
  default: []
10558
11030
  },
10559
- media: {
11031
+ mediaSources: {
10560
11032
  type: "array",
10561
11033
  items: {
10562
11034
  type: "object",
@@ -10595,21 +11067,187 @@ var require_scene = __commonJS({
10595
11067
  }
10596
11068
  });
10597
11069
 
11070
+ // src/Commands/Command.js
11071
+ var require_Command = __commonJS({
11072
+ "src/Commands/Command.js"(exports, module) {
11073
+ var Command = class {
11074
+ static {
11075
+ __name(this, "Command");
11076
+ }
11077
+ constructor(data) {
11078
+ this.data = {};
11079
+ if (!data)
11080
+ throw new Error("Command data is required");
11081
+ if (typeof data !== "object")
11082
+ throw new Error("Command data must be an object");
11083
+ for (const key in data) {
11084
+ this.data[key] = data[key];
11085
+ }
11086
+ }
11087
+ get name() {
11088
+ throw new Error("Command name is required");
11089
+ }
11090
+ get type() {
11091
+ return "Command";
11092
+ }
11093
+ get routingKey() {
11094
+ return "";
11095
+ }
11096
+ get exchange() {
11097
+ return "Commands";
11098
+ }
11099
+ build() {
11100
+ return { data: { ...this.data } };
11101
+ }
11102
+ };
11103
+ module.exports = Command;
11104
+ }
11105
+ });
11106
+
11107
+ // src/Commands/SetSceneCommand.js
11108
+ var require_SetSceneCommand = __commonJS({
11109
+ "src/Commands/SetSceneCommand.js"(exports, module) {
11110
+ var Command = require_Command();
11111
+ var SetSceneCommand = class extends Command {
11112
+ static {
11113
+ __name(this, "SetSceneCommand");
11114
+ }
11115
+ constructor({ id, devices, ...rest }) {
11116
+ super({ id, devices, ...rest });
11117
+ }
11118
+ get name() {
11119
+ return "SetScene";
11120
+ }
11121
+ get routingKey() {
11122
+ return `scene.${this.data.id}.set`;
11123
+ }
11124
+ };
11125
+ module.exports = SetSceneCommand;
11126
+ }
11127
+ });
11128
+
10598
11129
  // src/Models/scene.js
10599
11130
  var require_scene2 = __commonJS({
10600
11131
  "src/Models/scene.js"(exports, module) {
10601
11132
  var schemas = require_schema();
10602
11133
  var schema = require_scene();
10603
11134
  var Kohost = require_kohost();
11135
+ var SetSceneCommand = require_SetSceneCommand();
10604
11136
  schemas.add(schema);
10605
11137
  var validator = schemas.compile(schema);
10606
11138
  var Scene = class extends Kohost {
11139
+ static {
11140
+ __name(this, "Scene");
11141
+ }
10607
11142
  constructor(data) {
10608
11143
  super(data);
10609
11144
  }
10610
- };
10611
- __name(Scene, "Scene");
10612
- Object.defineProperty(Scene.prototype, "schema", {
11145
+ static createSceneCommandPayload(room, scene) {
11146
+ const commandsByDriver = [];
11147
+ const sceneDevices = scene?.devices || {};
11148
+ const sceneId = scene.id;
11149
+ for (const deviceType in sceneDevices) {
11150
+ const sceneData = sceneDevices[deviceType];
11151
+ const roomDevices = room[deviceType];
11152
+ for (const data of sceneData) {
11153
+ const { id, ...deviceProps } = data;
11154
+ if (id === "*") {
11155
+ for (const device of roomDevices) {
11156
+ const driver = device.driver;
11157
+ const deviceCmd = {
11158
+ id: device.systemData?.id
11159
+ };
11160
+ for (const prop in deviceProps) {
11161
+ if (prop === "setpointDelta") {
11162
+ const delta = deviceProps[prop];
11163
+ const currentMode = device.hvacMode;
11164
+ const setpoints = device.setpoints;
11165
+ const minAutoDelta = device.minAutoDelta;
11166
+ const currentSetpoint = setpoints[currentMode];
11167
+ if (currentMode === "heat") {
11168
+ const setpointValue = Math.min(
11169
+ currentSetpoint.min,
11170
+ currentSetpoint.value - delta
11171
+ );
11172
+ deviceCmd.setpoints = {
11173
+ heat: {
11174
+ value: setpointValue
11175
+ }
11176
+ };
11177
+ }
11178
+ if (currentMode === "cool") {
11179
+ const setpointValue = Math.max(
11180
+ currentSetpoint.max,
11181
+ currentSetpoint.value + delta
11182
+ );
11183
+ deviceCmd.setpoints = {
11184
+ cool: {
11185
+ value: setpointValue
11186
+ }
11187
+ };
11188
+ }
11189
+ if (currentMode === "auto") {
11190
+ if (!currentSetpoint && setpoints.cool && setpoints.heat) {
11191
+ const heatSetpoint = Math.min(
11192
+ setpoints.heat.min,
11193
+ setpoints.heat.value - delta
11194
+ );
11195
+ const coolSetpoint = Math.max(
11196
+ setpoints.cool.max,
11197
+ setpoints.cool.value + delta
11198
+ );
11199
+ if (Math.abs(heatSetpoint - coolSetpoint) < minAutoDelta) {
11200
+ continue;
11201
+ }
11202
+ deviceCmd.setpoints = {
11203
+ heat: {
11204
+ value: heatSetpoint
11205
+ },
11206
+ cool: {
11207
+ value: coolSetpoint
11208
+ }
11209
+ };
11210
+ }
11211
+ }
11212
+ if (currentMode === "off") {
11213
+ continue;
11214
+ }
11215
+ } else {
11216
+ deviceCmd[prop] = deviceProps[prop];
11217
+ }
11218
+ }
11219
+ if (Object.keys(deviceCmd).length === 1) {
11220
+ continue;
11221
+ }
11222
+ const driverIndex = commandsByDriver.findIndex(
11223
+ (c) => c.driver === driver
11224
+ );
11225
+ if (driverIndex >= 0) {
11226
+ commandsByDriver[driverIndex].command.devices.push(deviceCmd);
11227
+ } else {
11228
+ commandsByDriver.push({
11229
+ driver,
11230
+ command: {
11231
+ id: sceneId,
11232
+ devices: [deviceCmd]
11233
+ }
11234
+ });
11235
+ }
11236
+ }
11237
+ }
11238
+ }
11239
+ }
11240
+ const commands = commandsByDriver.map((c) => {
11241
+ const command = new SetSceneCommand(c.command);
11242
+ return {
11243
+ driver: c.driver,
11244
+ command
11245
+ };
11246
+ });
11247
+ return commands;
11248
+ }
11249
+ };
11250
+ Object.defineProperty(Scene.prototype, "schema", {
10613
11251
  value: schema
10614
11252
  });
10615
11253
  Object.defineProperty(Scene.prototype, "validator", {
@@ -10646,6 +11284,9 @@ var require_room2 = __commonJS({
10646
11284
  schemas.add(schema);
10647
11285
  var validator = schemas.compile(schema);
10648
11286
  var Room = class extends Kohost {
11287
+ static {
11288
+ __name(this, "Room");
11289
+ }
10649
11290
  constructor(data) {
10650
11291
  const roomData = mapRoomData(data);
10651
11292
  super(roomData);
@@ -10707,329 +11348,123 @@ var require_room2 = __commonJS({
10707
11348
  get hasShade() {
10708
11349
  return this.hasWindowCovering;
10709
11350
  }
10710
- get hasThermostat() {
10711
- return this.thermostats?.length > 0;
10712
- }
10713
- get hasClimate() {
10714
- return this.hasThermostat;
10715
- }
10716
- get hasLock() {
10717
- return this.locks?.length > 0;
10718
- }
10719
- get hasCourtesy() {
10720
- return this.courtesy?.length > 0;
10721
- }
10722
- get hasCamera() {
10723
- return this.cameras?.length > 0;
10724
- }
10725
- get hasAlarm() {
10726
- return this.alarms?.length > 0;
10727
- }
10728
- get hasMedia() {
10729
- return this.mediaSources?.length > 0;
10730
- }
10731
- get hasLight() {
10732
- const hasSubTypeLight = this.switches?.some((sw) => {
10733
- return sw.subType === "light" || sw.subType === "fan";
10734
- });
10735
- return this.hasDimmer || hasSubTypeLight;
10736
- }
10737
- get occupied() {
10738
- const now = /* @__PURE__ */ new Date();
10739
- const lastOccupied = new Date(this.occupiedAt);
10740
- const diff = now - lastOccupied;
10741
- return diff < 60 * 60 * 1e3;
10742
- }
10743
- };
10744
- __name(Room, "Room");
10745
- Object.defineProperty(Room.prototype, "schema", {
10746
- value: schema
10747
- });
10748
- Object.defineProperty(Room.prototype, "validator", {
10749
- get: function() {
10750
- return validator;
10751
- }
10752
- });
10753
- Object.defineProperty(Room, "validProperties", {
10754
- value: Object.keys(schema.properties)
10755
- });
10756
- function mapRoomData(data) {
10757
- const roomData = cloneDeep(data);
10758
- roomData.dimmers?.map((dimmer) => {
10759
- if (dimmer instanceof Dimmer)
10760
- return dimmer;
10761
- else
10762
- return new Dimmer(dimmer);
10763
- });
10764
- roomData.switches?.map((switch_) => {
10765
- if (switch_ instanceof Switch)
10766
- return switch_;
10767
- else
10768
- return new Switch(switch_);
10769
- });
10770
- roomData.windowCoverings?.map((windowCovering) => {
10771
- if (windowCovering instanceof WindowCovering)
10772
- return windowCovering;
10773
- else
10774
- return new WindowCovering(windowCovering);
10775
- });
10776
- roomData.thermostats?.map((thermostat) => {
10777
- if (thermostat instanceof Thermostat)
10778
- return thermostat;
10779
- else
10780
- return new Thermostat(thermostat);
10781
- });
10782
- roomData.locks?.map((lock) => {
10783
- if (lock instanceof Lock)
10784
- return lock;
10785
- else
10786
- return new Lock(lock);
10787
- });
10788
- roomData.courtesy?.map((courtesy) => {
10789
- if (courtesy instanceof Courtesy)
10790
- return courtesy;
10791
- else
10792
- return new Courtesy(courtesy);
10793
- });
10794
- roomData.mediaSources?.map((source) => {
10795
- if (source instanceof MediaSource)
10796
- return source;
10797
- else
10798
- return new MediaSource(source);
10799
- });
10800
- roomData.cameras?.map((camera) => {
10801
- if (camera instanceof Camera)
10802
- return camera;
10803
- else
10804
- return new Camera(camera);
10805
- });
10806
- roomData.alarms?.map((alarm) => {
10807
- if (alarm instanceof Alarm)
10808
- return alarm;
10809
- else
10810
- return new Alarm(alarm);
10811
- });
10812
- roomData.motionSensors?.map((motionSensor) => {
10813
- if (motionSensor instanceof MotionSensor)
10814
- return motionSensor;
10815
- else
10816
- return new MotionSensor(motionSensor);
10817
- });
10818
- roomData.scenes?.map((scene) => {
10819
- if (scene instanceof Scene)
10820
- return scene;
10821
- else
10822
- return new Scene(scene);
10823
- });
10824
- return roomData;
10825
- }
10826
- __name(mapRoomData, "mapRoomData");
10827
- module.exports = Room;
10828
- }
10829
- });
10830
-
10831
- // src/schemas/reservation.json
10832
- var require_reservation = __commonJS({
10833
- "src/schemas/reservation.json"(exports, module) {
10834
- module.exports = {
10835
- $schema: "http://json-schema.org/draft-07/schema",
10836
- $id: "https://api.kohost.io/schemas/v3/reservation.json",
10837
- title: "Reservation",
10838
- type: "object",
10839
- required: ["type", "status", "checkInDateTime", "checkOutDateTime"],
10840
- properties: {
10841
- id: {
10842
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
10843
- },
10844
- driver: {
10845
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/driver"
10846
- },
10847
- primaryGuest: {
10848
- type: "string"
10849
- },
10850
- type: {
10851
- type: "string"
10852
- },
10853
- sharedGuests: {
10854
- type: "array",
10855
- items: {
10856
- type: "string"
10857
- }
10858
- },
10859
- spaceType: {
10860
- type: "string"
10861
- },
10862
- space: {
10863
- type: "string"
10864
- },
10865
- status: {
10866
- type: "string",
10867
- enum: [
10868
- "reserved",
10869
- "checkedIn",
10870
- "checkedOut",
10871
- "cancelled",
10872
- "noShow",
10873
- "enquired",
10874
- "requested",
10875
- "optional"
10876
- ],
10877
- description: " reserved - confirmed by both parties, before check-in\n checkedIn - checked in\n checkedOut - checked out\n cancelled - Cancelled\n noShow - No show\n enquired - Confirmed neither by the customer nor enterprise\n requested - Confirmed by the customer but not the enterprise (waitlist)\n optional - Confirmed by the enterprise but not the customer (holding)"
10878
- },
10879
- mobileCheckInStatus: {
10880
- type: "string",
10881
- enum: [
10882
- "ready",
10883
- "blocked",
10884
- "preArrivalStepsRequired",
10885
- "spaceNotAssigned",
10886
- "spaceNotReady",
10887
- "checkInTimeNotStarted"
10888
- ]
10889
- },
10890
- mobileCheckInStatusMessage: {
10891
- type: "string"
10892
- },
10893
- confirmationNumber: {
10894
- type: "string"
10895
- },
10896
- checkInDateTime: {
10897
- type: ["string", "object"],
10898
- format: "date-time"
10899
- },
10900
- checkOutDateTime: {
10901
- type: ["string", "object"],
10902
- format: "date-time"
10903
- },
10904
- adultCount: {
10905
- type: "number",
10906
- default: 1,
10907
- minimum: 1
10908
- },
10909
- childCount: {
10910
- type: "number",
10911
- default: 0
10912
- },
10913
- revenue: {
10914
- type: "array",
10915
- items: {
10916
- type: "object",
10917
- properties: {
10918
- date: {
10919
- type: "string",
10920
- format: "date-time"
10921
- },
10922
- amount: {
10923
- type: "number"
10924
- },
10925
- type: {
10926
- type: "string",
10927
- enum: ["service", "product"]
10928
- }
10929
- }
10930
- }
10931
- },
10932
- rateSuppressed: {
10933
- type: "boolean"
10934
- },
10935
- payment: {
10936
- type: "string"
10937
- },
10938
- company: {
10939
- type: "string"
10940
- },
10941
- travelAgent: {
10942
- type: "string"
10943
- },
10944
- systemData: {
10945
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
10946
- },
10947
- metadata: {
10948
- ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/metadata"
10949
- }
10950
- }
10951
- };
10952
- }
10953
- });
10954
-
10955
- // src/Models/reservation.js
10956
- var require_reservation2 = __commonJS({
10957
- "src/Models/reservation.js"(exports, module) {
10958
- var schemas = require_schema();
10959
- var schema = require_reservation();
10960
- var Kohost = require_kohost();
10961
- schemas.add(schema);
10962
- var validator = schemas.compile(schema);
10963
- var Reservation = class extends Kohost {
10964
- constructor(data) {
10965
- super(data);
10966
- }
10967
- get peopleCount() {
10968
- return this.adultCount + this.childCount;
10969
- }
10970
- get hasPayment() {
10971
- return this.paymentId?.length > 0;
10972
- }
10973
- range(tz) {
10974
- const start = new Date(this.checkInDateTime);
10975
- const end = new Date(this.checkOutDateTime);
10976
- if (start.getDate() === end.getDate() && start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
10977
- return `${start.toLocaleString("default", {
10978
- month: "short",
10979
- timeZone: tz
10980
- })} ${start.toLocaleString("default", {
10981
- timeZone: tz,
10982
- day: "numeric"
10983
- })}`;
10984
- }
10985
- if (start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
10986
- return `${start.toLocaleString("default", {
10987
- month: "short",
10988
- timeZone: tz
10989
- })} ${start.toLocaleString("default", {
10990
- timeZone: tz,
10991
- day: "numeric"
10992
- })}-${end.toLocaleString("default", {
10993
- timeZone: tz,
10994
- day: "numeric"
10995
- })}`;
10996
- }
10997
- return `${start.toLocaleString("default", {
10998
- month: "short",
10999
- timeZone: tz
11000
- })} ${start.getDate()} - ${end.toLocaleString("default", {
11001
- month: "short",
11002
- timeZone: tz
11003
- })} ${end.getDate()}`;
11004
- }
11005
- checkInTime(tz) {
11006
- return new Date(this.checkInDateTime).toLocaleString("default", {
11007
- hour: "numeric",
11008
- minute: "numeric",
11009
- timeZone: tz
11010
- });
11351
+ get hasThermostat() {
11352
+ return this.thermostats?.length > 0;
11011
11353
  }
11012
- checkOutTime(tz) {
11013
- return new Date(this.checkOutDateTime).toLocaleString("default", {
11014
- hour: "numeric",
11015
- minute: "numeric",
11016
- timeZone: tz
11354
+ get hasClimate() {
11355
+ return this.hasThermostat;
11356
+ }
11357
+ get hasLock() {
11358
+ return this.locks?.length > 0;
11359
+ }
11360
+ get hasCourtesy() {
11361
+ return this.courtesy?.length > 0;
11362
+ }
11363
+ get hasCamera() {
11364
+ return this.cameras?.length > 0;
11365
+ }
11366
+ get hasAlarm() {
11367
+ return this.alarms?.length > 0;
11368
+ }
11369
+ get hasMedia() {
11370
+ return this.mediaSources?.length > 0;
11371
+ }
11372
+ get hasLight() {
11373
+ const hasSubTypeLight = this.switches?.some((sw) => {
11374
+ return sw.subType === "light" || sw.subType === "fan";
11017
11375
  });
11376
+ return this.hasDimmer || hasSubTypeLight;
11377
+ }
11378
+ get occupied() {
11379
+ const now = /* @__PURE__ */ new Date();
11380
+ const lastOccupied = new Date(this.occupiedAt);
11381
+ const diff = now - lastOccupied;
11382
+ return diff < 60 * 60 * 1e3;
11018
11383
  }
11019
11384
  };
11020
- __name(Reservation, "Reservation");
11021
- Object.defineProperty(Reservation.prototype, "schema", {
11385
+ Object.defineProperty(Room.prototype, "schema", {
11022
11386
  value: schema
11023
11387
  });
11024
- Object.defineProperty(Reservation.prototype, "validator", {
11388
+ Object.defineProperty(Room.prototype, "validator", {
11025
11389
  get: function() {
11026
11390
  return validator;
11027
11391
  }
11028
11392
  });
11029
- Object.defineProperty(Reservation, "validProperties", {
11393
+ Object.defineProperty(Room, "validProperties", {
11030
11394
  value: Object.keys(schema.properties)
11031
11395
  });
11032
- module.exports = Reservation;
11396
+ function mapRoomData(data) {
11397
+ const roomData = cloneDeep(data);
11398
+ roomData.dimmers?.map((dimmer) => {
11399
+ if (dimmer instanceof Dimmer)
11400
+ return dimmer;
11401
+ else
11402
+ return new Dimmer(dimmer);
11403
+ });
11404
+ roomData.switches?.map((switch_) => {
11405
+ if (switch_ instanceof Switch)
11406
+ return switch_;
11407
+ else
11408
+ return new Switch(switch_);
11409
+ });
11410
+ roomData.windowCoverings?.map((windowCovering) => {
11411
+ if (windowCovering instanceof WindowCovering)
11412
+ return windowCovering;
11413
+ else
11414
+ return new WindowCovering(windowCovering);
11415
+ });
11416
+ roomData.thermostats?.map((thermostat) => {
11417
+ if (thermostat instanceof Thermostat)
11418
+ return thermostat;
11419
+ else
11420
+ return new Thermostat(thermostat);
11421
+ });
11422
+ roomData.locks?.map((lock) => {
11423
+ if (lock instanceof Lock)
11424
+ return lock;
11425
+ else
11426
+ return new Lock(lock);
11427
+ });
11428
+ roomData.courtesy?.map((courtesy) => {
11429
+ if (courtesy instanceof Courtesy)
11430
+ return courtesy;
11431
+ else
11432
+ return new Courtesy(courtesy);
11433
+ });
11434
+ roomData.mediaSources?.map((source) => {
11435
+ if (source instanceof MediaSource)
11436
+ return source;
11437
+ else
11438
+ return new MediaSource(source);
11439
+ });
11440
+ roomData.cameras?.map((camera) => {
11441
+ if (camera instanceof Camera)
11442
+ return camera;
11443
+ else
11444
+ return new Camera(camera);
11445
+ });
11446
+ roomData.alarms?.map((alarm) => {
11447
+ if (alarm instanceof Alarm)
11448
+ return alarm;
11449
+ else
11450
+ return new Alarm(alarm);
11451
+ });
11452
+ roomData.motionSensors?.map((motionSensor) => {
11453
+ if (motionSensor instanceof MotionSensor)
11454
+ return motionSensor;
11455
+ else
11456
+ return new MotionSensor(motionSensor);
11457
+ });
11458
+ roomData.scenes?.map((scene) => {
11459
+ if (scene instanceof Scene)
11460
+ return scene;
11461
+ else
11462
+ return new Scene(scene);
11463
+ });
11464
+ return roomData;
11465
+ }
11466
+ __name(mapRoomData, "mapRoomData");
11467
+ module.exports = Room;
11033
11468
  }
11034
11469
  });
11035
11470
 
@@ -11078,6 +11513,9 @@ var require_space = __commonJS({
11078
11513
  type: "string"
11079
11514
  }
11080
11515
  },
11516
+ occupied: {
11517
+ type: "boolean"
11518
+ },
11081
11519
  eco: {
11082
11520
  type: "object",
11083
11521
  additionalProperties: false,
@@ -11167,6 +11605,9 @@ var require_space2 = __commonJS({
11167
11605
  schemas.add(schema);
11168
11606
  var validator = schemas.compile(schema);
11169
11607
  var Space = class extends Kohost {
11608
+ static {
11609
+ __name(this, "Space");
11610
+ }
11170
11611
  constructor(data) {
11171
11612
  const spaceData = mapSpaceData(data);
11172
11613
  super(spaceData);
@@ -11206,11 +11647,7 @@ var require_space2 = __commonJS({
11206
11647
  get hasMedia() {
11207
11648
  return this.rooms.some((room) => room.hasMedia);
11208
11649
  }
11209
- get occupied() {
11210
- return this.rooms.some((room) => room.occupied);
11211
- }
11212
11650
  };
11213
- __name(Space, "Space");
11214
11651
  Object.defineProperty(Space.prototype, "schema", {
11215
11652
  value: schema
11216
11653
  });
@@ -11265,9 +11702,8 @@ var require_spaceType = __commonJS({
11265
11702
  description: {
11266
11703
  type: "string"
11267
11704
  },
11268
- imageUrl: {
11269
- format: "uri",
11270
- pattern: "^https?://"
11705
+ image: {
11706
+ $ref: "https://api.kohost.io/schemas/v3/mediaFile.json"
11271
11707
  },
11272
11708
  systemData: {
11273
11709
  $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
@@ -11286,11 +11722,13 @@ var require_spaceType2 = __commonJS({
11286
11722
  schemas.add(schema);
11287
11723
  var validator = schemas.compile(schema);
11288
11724
  var SpaceType = class extends Kohost {
11725
+ static {
11726
+ __name(this, "SpaceType");
11727
+ }
11289
11728
  constructor(data) {
11290
11729
  super(data);
11291
11730
  }
11292
11731
  };
11293
- __name(SpaceType, "SpaceType");
11294
11732
  Object.defineProperty(SpaceType.prototype, "schema", {
11295
11733
  value: schema
11296
11734
  });
@@ -11306,112 +11744,6 @@ var require_spaceType2 = __commonJS({
11306
11744
  }
11307
11745
  });
11308
11746
 
11309
- // src/schemas/mediaFile.json
11310
- var require_mediaFile = __commonJS({
11311
- "src/schemas/mediaFile.json"(exports, module) {
11312
- module.exports = {
11313
- $schema: "http://json-schema.org/draft-07/schema",
11314
- $id: "https://api.kohost.io/schemas/v3/mediaFile.json",
11315
- title: "Media File",
11316
- description: "Any media file",
11317
- type: "object",
11318
- properties: {
11319
- id: {
11320
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/id"
11321
- },
11322
- type: {
11323
- type: "string",
11324
- default: "mediaFile"
11325
- },
11326
- fileHash: {
11327
- type: "string"
11328
- },
11329
- mimeType: {
11330
- type: "string",
11331
- enum: [
11332
- "image/*",
11333
- "image/jpeg",
11334
- "image/png",
11335
- "image/gif",
11336
- "image/webp",
11337
- "image/avif",
11338
- "image/svg+xml",
11339
- "application/pdf"
11340
- ]
11341
- },
11342
- url: {
11343
- type: "string",
11344
- format: "uri"
11345
- },
11346
- width: {
11347
- type: "integer",
11348
- minimum: 0
11349
- },
11350
- height: {
11351
- type: "integer",
11352
- minimum: 0
11353
- },
11354
- size: {
11355
- type: "integer",
11356
- minimum: 0,
11357
- description: "Size in bytes"
11358
- },
11359
- uploadUrl: {
11360
- type: "string",
11361
- format: "uri"
11362
- },
11363
- uploadUrlExpires: {
11364
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/date"
11365
- },
11366
- createdBy: {
11367
- type: "string"
11368
- },
11369
- systemData: {
11370
- $ref: "https://api.kohost.io/schemas/v3/definitions/common.json#/definitions/systemData"
11371
- }
11372
- },
11373
- additionalProperties: false,
11374
- required: ["id", "type"]
11375
- };
11376
- }
11377
- });
11378
-
11379
- // src/Models/mediaFile.js
11380
- var require_mediaFile2 = __commonJS({
11381
- "src/Models/mediaFile.js"(exports, module) {
11382
- var schemas = require_schema();
11383
- var schema = require_mediaFile();
11384
- var Kohost = require_kohost();
11385
- var { RequestError } = require_Errors();
11386
- schemas.add(schema);
11387
- var validator = schemas.compile(schema);
11388
- var MediaFile = class extends Kohost {
11389
- constructor(data) {
11390
- super(data);
11391
- }
11392
- createImageVariant(params) {
11393
- if (this.mimeType != "image/*")
11394
- throw new RequestError("Only dynamic images can have variants");
11395
- const query = Object.keys(params).map((key) => `${key}=${params[key]}`).join(",");
11396
- return this.url.replace(/\/public$/, `/${query}`);
11397
- }
11398
- };
11399
- __name(MediaFile, "MediaFile");
11400
- Object.defineProperty(MediaFile.prototype, "schema", {
11401
- value: schema
11402
- });
11403
- Object.defineProperty(MediaFile.prototype, "validator", {
11404
- get: function() {
11405
- return validator;
11406
- }
11407
- });
11408
- Object.defineProperty(MediaFile, "validProperties", {
11409
- value: Object.keys(schema.properties)
11410
- });
11411
- module.exports = MediaFile;
11412
- }
11413
- });
11414
-
11415
11747
  // src/schemas/ticket.json
11416
11748
  var require_ticket = __commonJS({
11417
11749
  "src/schemas/ticket.json"(exports, module) {
@@ -13592,6 +13924,9 @@ var require_ticket2 = __commonJS({
13592
13924
  schemas.add(schema);
13593
13925
  var validator = schemas.compile(schema);
13594
13926
  var Ticket = class extends Kohost {
13927
+ static {
13928
+ __name(this, "Ticket");
13929
+ }
13595
13930
  constructor(data) {
13596
13931
  const ticketData = mapConversationData(data);
13597
13932
  super(ticketData);
@@ -13600,7 +13935,6 @@ var require_ticket2 = __commonJS({
13600
13935
  return nanoid3(len);
13601
13936
  }
13602
13937
  };
13603
- __name(Ticket, "Ticket");
13604
13938
  Object.defineProperty(Ticket.prototype, "schema", {
13605
13939
  value: schema
13606
13940
  });
@@ -13722,11 +14056,13 @@ var require_gateway2 = __commonJS({
13722
14056
  schemas.add(schema);
13723
14057
  var validator = schemas.compile(schema);
13724
14058
  var Gateway = class extends Kohost {
14059
+ static {
14060
+ __name(this, "Gateway");
14061
+ }
13725
14062
  constructor(data) {
13726
14063
  super(data);
13727
14064
  }
13728
14065
  };
13729
- __name(Gateway, "Gateway");
13730
14066
  Object.defineProperty(Gateway.prototype, "schema", {
13731
14067
  value: schema
13732
14068
  });
@@ -13797,11 +14133,13 @@ var require_product2 = __commonJS({
13797
14133
  schemas.add(schema);
13798
14134
  var validator = schemas.compile(schema);
13799
14135
  var Product = class extends Kohost {
14136
+ static {
14137
+ __name(this, "Product");
14138
+ }
13800
14139
  constructor(data) {
13801
14140
  super(data);
13802
14141
  }
13803
14142
  };
13804
- __name(Product, "Product");
13805
14143
  Object.defineProperty(Product.prototype, "schema", {
13806
14144
  value: schema
13807
14145
  });
@@ -13863,11 +14201,13 @@ var require_discoveredDevice2 = __commonJS({
13863
14201
  schemas.add(schema);
13864
14202
  var validator = schemas.compile(schema);
13865
14203
  var DiscoveredDevice = class extends Kohost {
14204
+ static {
14205
+ __name(this, "DiscoveredDevice");
14206
+ }
13866
14207
  constructor(data) {
13867
14208
  super(data);
13868
14209
  }
13869
14210
  };
13870
- __name(DiscoveredDevice, "DiscoveredDevice");
13871
14211
  Object.defineProperty(DiscoveredDevice.prototype, "schema", {
13872
14212
  value: schema
13873
14213
  });
@@ -13929,11 +14269,13 @@ var require_credential2 = __commonJS({
13929
14269
  schemas.add(schema);
13930
14270
  var validator = schemas.compile(schema);
13931
14271
  var Credential = class extends Kohost {
14272
+ static {
14273
+ __name(this, "Credential");
14274
+ }
13932
14275
  constructor(data) {
13933
14276
  super(data);
13934
14277
  }
13935
14278
  };
13936
- __name(Credential, "Credential");
13937
14279
  Object.defineProperty(Credential.prototype, "schema", {
13938
14280
  value: schema
13939
14281
  });
@@ -13994,11 +14336,13 @@ var require_shortLink2 = __commonJS({
13994
14336
  schemas.add(schema);
13995
14337
  var validator = schemas.compile(schema);
13996
14338
  var ShortLink = class extends Kohost {
14339
+ static {
14340
+ __name(this, "ShortLink");
14341
+ }
13997
14342
  constructor(data) {
13998
14343
  super(data);
13999
14344
  }
14000
14345
  };
14001
- __name(ShortLink, "ShortLink");
14002
14346
  Object.defineProperty(ShortLink.prototype, "schema", {
14003
14347
  value: schema
14004
14348
  });
@@ -14104,11 +14448,13 @@ var require_energyReportShard2 = __commonJS({
14104
14448
  schemas.add(schema);
14105
14449
  var validator = schemas.compile(schema);
14106
14450
  var EnergyReportShard = class extends Kohost {
14451
+ static {
14452
+ __name(this, "EnergyReportShard");
14453
+ }
14107
14454
  constructor(data) {
14108
14455
  super(data);
14109
14456
  }
14110
14457
  };
14111
- __name(EnergyReportShard, "EnergyReportShard");
14112
14458
  Object.defineProperty(EnergyReportShard.prototype, "schema", {
14113
14459
  value: schema
14114
14460
  });
@@ -14225,11 +14571,13 @@ var require_energyReport2 = __commonJS({
14225
14571
  schemas.add(schema);
14226
14572
  var validator = schemas.compile(schema);
14227
14573
  var EnergyReport = class extends Kohost {
14574
+ static {
14575
+ __name(this, "EnergyReport");
14576
+ }
14228
14577
  constructor(data) {
14229
14578
  super(data);
14230
14579
  }
14231
14580
  };
14232
- __name(EnergyReport, "EnergyReport");
14233
14581
  Object.defineProperty(EnergyReport.prototype, "schema", {
14234
14582
  value: schema
14235
14583
  });
@@ -14321,11 +14669,13 @@ var require_smsMessage2 = __commonJS({
14321
14669
  schemas.add(schema);
14322
14670
  var validator = schemas.compile(schema);
14323
14671
  var SMSMessage = class extends Kohost {
14672
+ static {
14673
+ __name(this, "SMSMessage");
14674
+ }
14324
14675
  constructor(data) {
14325
14676
  super(data);
14326
14677
  }
14327
14678
  };
14328
- __name(SMSMessage, "SMSMessage");
14329
14679
  Object.defineProperty(SMSMessage.prototype, "schema", {
14330
14680
  value: schema
14331
14681
  });
@@ -14427,11 +14777,13 @@ var require_emailMessage2 = __commonJS({
14427
14777
  schemas.add(schema);
14428
14778
  var validator = schemas.compile(schema);
14429
14779
  var EmailMessage = class extends Kohost {
14780
+ static {
14781
+ __name(this, "EmailMessage");
14782
+ }
14430
14783
  constructor(data) {
14431
14784
  super(data);
14432
14785
  }
14433
14786
  };
14434
- __name(EmailMessage, "EmailMessage");
14435
14787
  Object.defineProperty(EmailMessage.prototype, "schema", {
14436
14788
  value: schema
14437
14789
  });
@@ -14621,10 +14973,18 @@ var require_property = __commonJS({
14621
14973
  payment: {},
14622
14974
  identification: {},
14623
14975
  earlyCheckIn: {
14976
+ type: "object",
14977
+ required: ["dynamic", "checkInTime", "checkOutTime"],
14624
14978
  properties: {
14625
14979
  dynamic: {
14626
14980
  type: "boolean",
14627
14981
  default: false
14982
+ },
14983
+ checkInTime: {
14984
+ type: "string"
14985
+ },
14986
+ checkOutTime: {
14987
+ type: "string"
14628
14988
  }
14629
14989
  }
14630
14990
  },
@@ -14699,11 +15059,13 @@ var require_property2 = __commonJS({
14699
15059
  schemas.add(schema);
14700
15060
  var validator = schemas.compile(schema);
14701
15061
  var Property = class extends Kohost {
15062
+ static {
15063
+ __name(this, "Property");
15064
+ }
14702
15065
  constructor(data) {
14703
15066
  super(data);
14704
15067
  }
14705
15068
  };
14706
- __name(Property, "Property");
14707
15069
  Object.defineProperty(Property.prototype, "schema", {
14708
15070
  value: schema
14709
15071
  });
@@ -14770,11 +15132,13 @@ var require_organization2 = __commonJS({
14770
15132
  schemas.add(schema);
14771
15133
  var validator = schemas.compile(schema);
14772
15134
  var Organization = class extends Kohost {
15135
+ static {
15136
+ __name(this, "Organization");
15137
+ }
14773
15138
  constructor(data) {
14774
15139
  super(data);
14775
15140
  }
14776
15141
  };
14777
- __name(Organization, "Organization");
14778
15142
  Object.defineProperty(Organization.prototype, "schema", {
14779
15143
  value: schema
14780
15144
  });
@@ -14793,6 +15157,8 @@ var require_organization2 = __commonJS({
14793
15157
  // src/Models/index.js
14794
15158
  var require_Models = __commonJS({
14795
15159
  "src/Models/index.js"(exports, module) {
15160
+ var Reservation = require_reservation2();
15161
+ var MediaFile = require_mediaFile2();
14796
15162
  var Switch = require_switch2();
14797
15163
  var Alarm = require_alarm2();
14798
15164
  var Dimmer = require_dimmer2();
@@ -14807,10 +15173,8 @@ var require_Models = __commonJS({
14807
15173
  var MotionSensor = require_motionSensor2();
14808
15174
  var MediaSource = require_mediaSource2();
14809
15175
  var Room = require_room2();
14810
- var Reservation = require_reservation2();
14811
15176
  var Space = require_space2();
14812
15177
  var SpaceType = require_spaceType2();
14813
- var MediaFile = require_mediaFile2();
14814
15178
  var Ticket = require_ticket2();
14815
15179
  var Scene = require_scene2();
14816
15180
  var Gateway = require_gateway2();
@@ -14827,6 +15191,7 @@ var require_Models = __commonJS({
14827
15191
  module.exports = {
14828
15192
  Organization,
14829
15193
  Property,
15194
+ MediaFile,
14830
15195
  Gateway,
14831
15196
  Switch,
14832
15197
  Alarm,
@@ -14854,8 +15219,7 @@ var require_Models = __commonJS({
14854
15219
  EnergyReportShard,
14855
15220
  EnergyReport,
14856
15221
  SMSMessage,
14857
- EmailMessage,
14858
- MediaFile
15222
+ EmailMessage
14859
15223
  };
14860
15224
  }
14861
15225
  });