@kohost/api-client 3.0.0-beta.12 → 3.0.0-beta.17

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.
@@ -8327,7 +8327,7 @@ var require_thermostat = __commonJS({
8327
8327
  type: "array",
8328
8328
  uniqueItems: true,
8329
8329
  items: {
8330
- enum: ["auto", "low", "medium", "high", "off"]
8330
+ enum: ["auto", "low", "medium", "high", "off", "on"]
8331
8331
  }
8332
8332
  },
8333
8333
  setpoints: {
@@ -8345,6 +8345,9 @@ var require_thermostat = __commonJS({
8345
8345
  }
8346
8346
  }
8347
8347
  },
8348
+ minAutoDelta: {
8349
+ type: "number"
8350
+ },
8348
8351
  batteryLevel: {
8349
8352
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/batteryLevel"
8350
8353
  },
@@ -8654,7 +8657,7 @@ var require_user = __commonJS({
8654
8657
  $id: "https://api.kohost.app/schemas/v3/user.json",
8655
8658
  title: "User",
8656
8659
  type: "object",
8657
- required: ["active", "lastName", "roles"],
8660
+ required: ["firstName", "lastName"],
8658
8661
  properties: {
8659
8662
  id: {
8660
8663
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
@@ -8663,10 +8666,6 @@ var require_user = __commonJS({
8663
8666
  type: "string",
8664
8667
  default: "user"
8665
8668
  },
8666
- active: {
8667
- type: "boolean",
8668
- default: true
8669
- },
8670
8669
  firstName: {
8671
8670
  type: "string"
8672
8671
  },
@@ -8711,32 +8710,44 @@ var require_user = __commonJS({
8711
8710
  minLength: 2,
8712
8711
  maxLength: 2
8713
8712
  },
8714
- notes: {
8713
+ permissions: {
8715
8714
  type: "array",
8715
+ default: [],
8716
8716
  items: {
8717
- type: "string"
8717
+ type: "object",
8718
+ required: ["organization", "property", "role"],
8719
+ properties: {
8720
+ organization: {
8721
+ type: "string",
8722
+ description: "The ID of the organization the permission is applies to."
8723
+ },
8724
+ property: {
8725
+ type: "string",
8726
+ description: "The ID of the property the permission is applies to."
8727
+ },
8728
+ role: {
8729
+ type: "string",
8730
+ enum: ["Guest", "User", "Manager", "Administrator", "SuperAdmin"]
8731
+ },
8732
+ customPermissions: {
8733
+ type: "array",
8734
+ items: {
8735
+ type: "string"
8736
+ }
8737
+ }
8738
+ }
8718
8739
  }
8719
8740
  },
8720
- files: {
8741
+ notes: {
8721
8742
  type: "array",
8722
8743
  items: {
8723
- $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
8744
+ type: "string"
8724
8745
  }
8725
8746
  },
8726
- roles: {
8747
+ files: {
8727
8748
  type: "array",
8728
8749
  items: {
8729
- type: "string",
8730
- enum: [
8731
- "Guest",
8732
- "Staff",
8733
- "Faculty",
8734
- "Student",
8735
- "Visitor",
8736
- "Manager",
8737
- "Administrator",
8738
- "SuperAdmin"
8739
- ]
8750
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
8740
8751
  }
8741
8752
  },
8742
8753
  identifications: {
@@ -8751,25 +8762,6 @@ var require_user = __commonJS({
8751
8762
  $ref: "https://api.kohost.app/schemas/v3/payment.json#"
8752
8763
  }
8753
8764
  },
8754
- preferences: {
8755
- type: "object",
8756
- additionalProperties: false,
8757
- properties: {
8758
- notifications: {
8759
- type: "array",
8760
- items: {
8761
- type: "string"
8762
- },
8763
- examples: [["roomControl", "marketing"]]
8764
- },
8765
- location: {
8766
- title: "The location Schema",
8767
- type: "boolean",
8768
- default: false,
8769
- examples: [true]
8770
- }
8771
- }
8772
- },
8773
8765
  location: {
8774
8766
  type: "object",
8775
8767
  required: ["accuracy", "latitude", "longitude", "timestamp"],
@@ -8789,31 +8781,6 @@ var require_user = __commonJS({
8789
8781
  }
8790
8782
  }
8791
8783
  },
8792
- registeredDevices: {
8793
- type: "array",
8794
- items: {
8795
- type: "object",
8796
- properties: {
8797
- userAgent: {
8798
- type: "string"
8799
- },
8800
- fingerPrint: {
8801
- type: "string"
8802
- },
8803
- ip: {
8804
- type: "string"
8805
- },
8806
- registeredAt: {
8807
- type: "string",
8808
- format: "date-time"
8809
- },
8810
- expiresAt: {
8811
- type: "string",
8812
- format: "date-time"
8813
- }
8814
- }
8815
- }
8816
- },
8817
8784
  createdAt: {
8818
8785
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
8819
8786
  },
@@ -8821,7 +8788,10 @@ var require_user = __commonJS({
8821
8788
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
8822
8789
  },
8823
8790
  systemData: {
8824
- $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
8791
+ type: "array",
8792
+ items: {
8793
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
8794
+ }
8825
8795
  }
8826
8796
  }
8827
8797
  };
@@ -8965,10 +8935,161 @@ var require_user2 = __commonJS({
8965
8935
  return `${this.firstName} ${this.lastName}`;
8966
8936
  }
8967
8937
  });
8938
+ Object.defineProperty(User.prototype, "roles", {
8939
+ get: function() {
8940
+ const roles = /* @__PURE__ */ new Set();
8941
+ if (this.permissions) {
8942
+ for (const permission of this.permissions) {
8943
+ roles.add(permission.role);
8944
+ }
8945
+ }
8946
+ return Array.from(roles);
8947
+ }
8948
+ });
8968
8949
  module.exports = User;
8969
8950
  }
8970
8951
  });
8971
8952
 
8953
+ // src/schemas/systemUser.json
8954
+ var require_systemUser = __commonJS({
8955
+ "src/schemas/systemUser.json"(exports, module) {
8956
+ module.exports = {
8957
+ $schema: "http://json-schema.org/draft-07/schema",
8958
+ $id: "https://api.kohost.app/schemas/v3/systemUser.json",
8959
+ title: "System User",
8960
+ description: "A system user is a user that originated from an external 3rd party system.",
8961
+ type: "object",
8962
+ required: ["firstName", "lastName"],
8963
+ properties: {
8964
+ id: {
8965
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
8966
+ },
8967
+ type: {
8968
+ type: "string",
8969
+ default: "systemUser"
8970
+ },
8971
+ firstName: {
8972
+ type: "string"
8973
+ },
8974
+ lastName: {
8975
+ type: "string"
8976
+ },
8977
+ phone: {
8978
+ type: ["string", "null"],
8979
+ pattern: "^\\+[0-9]{1,14}$"
8980
+ },
8981
+ email: {
8982
+ type: ["string", "null"],
8983
+ format: "email"
8984
+ },
8985
+ address: {
8986
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/address"
8987
+ },
8988
+ photo: {
8989
+ type: "string"
8990
+ },
8991
+ jobTitle: {
8992
+ type: "string"
8993
+ },
8994
+ dob: {
8995
+ type: "string"
8996
+ },
8997
+ gender: {
8998
+ type: "string",
8999
+ enum: ["male", "female"]
9000
+ },
9001
+ roles: {
9002
+ type: "array",
9003
+ items: {
9004
+ type: "string",
9005
+ enum: ["Guest", "User", "Manager", "Administrator", "SuperAdmin"]
9006
+ }
9007
+ },
9008
+ nationality: {
9009
+ type: "string",
9010
+ minLength: 2,
9011
+ maxLength: 2
9012
+ },
9013
+ notes: {
9014
+ type: "array",
9015
+ items: {
9016
+ type: "string"
9017
+ }
9018
+ },
9019
+ files: {
9020
+ type: "array",
9021
+ items: {
9022
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
9023
+ }
9024
+ },
9025
+ identifications: {
9026
+ type: "array",
9027
+ items: {
9028
+ $ref: "https://api.kohost.app/schemas/v3/identification.json#"
9029
+ }
9030
+ },
9031
+ payments: {
9032
+ type: "array",
9033
+ items: {
9034
+ $ref: "https://api.kohost.app/schemas/v3/payment.json#"
9035
+ }
9036
+ },
9037
+ createdAt: {
9038
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
9039
+ },
9040
+ updatedAt: {
9041
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
9042
+ },
9043
+ systemData: {
9044
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
9045
+ }
9046
+ }
9047
+ };
9048
+ }
9049
+ });
9050
+
9051
+ // src/Models/systemUser.js
9052
+ var require_systemUser2 = __commonJS({
9053
+ "src/Models/systemUser.js"(exports, module) {
9054
+ var schemas = require_schema();
9055
+ var schema = require_systemUser();
9056
+ var Kohost = require_kohost();
9057
+ schemas.add(schema);
9058
+ var validator = schemas.compile(schema);
9059
+ var SystemUser = class extends Kohost {
9060
+ constructor(data) {
9061
+ super(data);
9062
+ }
9063
+ static validatePhone(phoneNumber) {
9064
+ const regex = /^\+?[1-9]\d{1,14}$/;
9065
+ return regex.test(phoneNumber);
9066
+ }
9067
+ static validateEmail(email) {
9068
+ const regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
9069
+ return regex.test(email);
9070
+ }
9071
+ };
9072
+ __name(SystemUser, "SystemUser");
9073
+ Object.defineProperty(SystemUser.prototype, "schema", {
9074
+ value: schema
9075
+ });
9076
+ Object.defineProperty(SystemUser.prototype, "validator", {
9077
+ get: function() {
9078
+ return validator;
9079
+ }
9080
+ });
9081
+ Object.defineProperty(SystemUser, "validProperties", {
9082
+ value: Object.keys(schema.properties)
9083
+ });
9084
+ Object.defineProperty(SystemUser.prototype, "fullName", {
9085
+ get: function() {
9086
+ return `${this.firstName} ${this.lastName}`;
9087
+ }
9088
+ });
9089
+ module.exports = SystemUser;
9090
+ }
9091
+ });
9092
+
8972
9093
  // src/schemas/courtesy.json
8973
9094
  var require_courtesy = __commonJS({
8974
9095
  "src/schemas/courtesy.json"(exports, module) {
@@ -10410,6 +10531,30 @@ var require_room2 = __commonJS({
10410
10531
  return `${type}s`;
10411
10532
  }
10412
10533
  }
10534
+ static getDeviceTypeFromPath(path) {
10535
+ const validPaths = [
10536
+ "dimmers",
10537
+ "switches",
10538
+ "thermostats",
10539
+ "locks",
10540
+ "windowCoverings",
10541
+ "courtesy",
10542
+ "cameras",
10543
+ "sources",
10544
+ "motionSensors",
10545
+ "alarms"
10546
+ ];
10547
+ if (!validPaths.includes(path))
10548
+ throw new Error("Invalid device path:" + path);
10549
+ switch (path) {
10550
+ case "courtesy":
10551
+ return path;
10552
+ case "switches":
10553
+ return "switch";
10554
+ default:
10555
+ return path.slice(0, -1);
10556
+ }
10557
+ }
10413
10558
  get hasDimmer() {
10414
10559
  return this.dimmers?.length > 0;
10415
10560
  }
@@ -13362,7 +13507,7 @@ var require_product = __commonJS({
13362
13507
  $id: "https://api.kohost.app/schemas/v3/product.json",
13363
13508
  title: "Product",
13364
13509
  type: "object",
13365
- required: ["name", "description", "price", "currency"],
13510
+ required: ["name", "price", "currency"],
13366
13511
  properties: {
13367
13512
  id: {
13368
13513
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
@@ -13388,6 +13533,10 @@ var require_product = __commonJS({
13388
13533
  image: {
13389
13534
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
13390
13535
  },
13536
+ imageUrl: {
13537
+ format: "uri",
13538
+ pattern: "^https?://"
13539
+ },
13391
13540
  systemData: {
13392
13541
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
13393
13542
  }
@@ -13631,83 +13780,16 @@ var require_shortLink2 = __commonJS({
13631
13780
  }
13632
13781
  });
13633
13782
 
13634
- // src/schemas/admin/customer.json
13635
- var require_customer = __commonJS({
13636
- "src/schemas/admin/customer.json"(exports, module) {
13637
- module.exports = {
13638
- $schema: "http://json-schema.org/draft-07/schema",
13639
- $id: "https://api.kohost.app/schemas/v3/admin/customer.json",
13640
- title: "Customer",
13641
- type: "object",
13642
- description: "A Kohost customer",
13643
- required: ["accountNumber", "name"],
13644
- properties: {
13645
- id: {
13646
- $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
13647
- },
13648
- accountNumber: {
13649
- type: "number",
13650
- minimum: 1e4
13651
- },
13652
- name: {
13653
- type: "string"
13654
- },
13655
- properties: {
13656
- type: "array",
13657
- items: {
13658
- type: "string"
13659
- }
13660
- },
13661
- createdAt: {
13662
- $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
13663
- },
13664
- updatedAt: {
13665
- $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
13666
- }
13667
- }
13668
- };
13669
- }
13670
- });
13671
-
13672
- // src/Models/admin/customer.js
13673
- var require_customer2 = __commonJS({
13674
- "src/Models/admin/customer.js"(exports, module) {
13675
- var schemas = require_schema();
13676
- var schema = require_customer();
13677
- var Kohost = require_kohost();
13678
- schemas.add(schema);
13679
- var validator = schemas.compile(schema);
13680
- var Customer = class extends Kohost {
13681
- constructor(data) {
13682
- super(data);
13683
- }
13684
- };
13685
- __name(Customer, "Customer");
13686
- Object.defineProperty(Customer.prototype, "schema", {
13687
- value: schema
13688
- });
13689
- Object.defineProperty(Customer.prototype, "validator", {
13690
- get: function() {
13691
- return validator;
13692
- }
13693
- });
13694
- Object.defineProperty(Customer, "validProperties", {
13695
- value: Object.keys(schema.properties)
13696
- });
13697
- module.exports = Customer;
13698
- }
13699
- });
13700
-
13701
- // src/schemas/admin/property.json
13783
+ // src/schemas/property.json
13702
13784
  var require_property = __commonJS({
13703
- "src/schemas/admin/property.json"(exports, module) {
13785
+ "src/schemas/property.json"(exports, module) {
13704
13786
  module.exports = {
13705
13787
  $schema: "http://json-schema.org/draft-07/schema",
13706
13788
  $id: "https://api.kohost.app/schemas/v3/admin/property.json",
13707
13789
  title: "Property",
13708
13790
  type: "object",
13709
13791
  description: "A property is a physical asset or building",
13710
- required: ["id", "name", "type", "hostname"],
13792
+ required: ["id", "name", "type", "hostname", "organization"],
13711
13793
  properties: {
13712
13794
  id: {
13713
13795
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
@@ -13728,6 +13810,10 @@ var require_property = __commonJS({
13728
13810
  hostname: {
13729
13811
  type: "string"
13730
13812
  },
13813
+ organization: {
13814
+ type: "string",
13815
+ description: "Reference to the organization that owns this property"
13816
+ },
13731
13817
  address: {
13732
13818
  type: "object",
13733
13819
  properties: {
@@ -13883,9 +13969,9 @@ var require_property = __commonJS({
13883
13969
  }
13884
13970
  });
13885
13971
 
13886
- // src/Models/admin/property.js
13972
+ // src/Models/property.js
13887
13973
  var require_property2 = __commonJS({
13888
- "src/Models/admin/property.js"(exports, module) {
13974
+ "src/Models/property.js"(exports, module) {
13889
13975
  var schemas = require_schema();
13890
13976
  var schema = require_property();
13891
13977
  var Kohost = require_kohost();
@@ -13912,6 +13998,77 @@ var require_property2 = __commonJS({
13912
13998
  }
13913
13999
  });
13914
14000
 
14001
+ // src/schemas/organization.json
14002
+ var require_organization = __commonJS({
14003
+ "src/schemas/organization.json"(exports, module) {
14004
+ module.exports = {
14005
+ $schema: "http://json-schema.org/draft-07/schema",
14006
+ $id: "https://api.kohost.app/schemas/v3/admin/organization.json",
14007
+ title: "Organization",
14008
+ type: "object",
14009
+ description: "An organization is a group or entity that subscribes to Kohost software.",
14010
+ required: ["accountNumber", "name"],
14011
+ properties: {
14012
+ id: {
14013
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
14014
+ },
14015
+ accountNumber: {
14016
+ type: "number",
14017
+ minimum: 1e4
14018
+ },
14019
+ name: {
14020
+ type: "string"
14021
+ },
14022
+ properties: {
14023
+ type: "array",
14024
+ items: {
14025
+ type: "string"
14026
+ }
14027
+ },
14028
+ credentials: {
14029
+ type: "object",
14030
+ additionalProperties: true
14031
+ },
14032
+ createdAt: {
14033
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
14034
+ },
14035
+ updatedAt: {
14036
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
14037
+ }
14038
+ }
14039
+ };
14040
+ }
14041
+ });
14042
+
14043
+ // src/Models/organization.js
14044
+ var require_organization2 = __commonJS({
14045
+ "src/Models/organization.js"(exports, module) {
14046
+ var schemas = require_schema();
14047
+ var schema = require_organization();
14048
+ var Kohost = require_kohost();
14049
+ schemas.add(schema);
14050
+ var validator = schemas.compile(schema);
14051
+ var Organization = class extends Kohost {
14052
+ constructor(data) {
14053
+ super(data);
14054
+ }
14055
+ };
14056
+ __name(Organization, "Organization");
14057
+ Object.defineProperty(Organization.prototype, "schema", {
14058
+ value: schema
14059
+ });
14060
+ Object.defineProperty(Organization.prototype, "validator", {
14061
+ get: function() {
14062
+ return validator;
14063
+ }
14064
+ });
14065
+ Object.defineProperty(Organization, "validProperties", {
14066
+ value: Object.keys(schema.properties)
14067
+ });
14068
+ module.exports = Organization;
14069
+ }
14070
+ });
14071
+
13915
14072
  // src/Models/index.js
13916
14073
  var require_Models = __commonJS({
13917
14074
  "src/Models/index.js"(exports, module) {
@@ -13923,6 +14080,7 @@ var require_Models = __commonJS({
13923
14080
  var WindowCovering = require_windowCovering2();
13924
14081
  var Identification = require_identification2();
13925
14082
  var User = require_user2();
14083
+ var SystemUser = require_systemUser2();
13926
14084
  var Courtesy = require_courtesy2();
13927
14085
  var Camera = require_camera2();
13928
14086
  var MotionSensor = require_motionSensor2();
@@ -13939,13 +14097,11 @@ var require_Models = __commonJS({
13939
14097
  var DiscoveredDevice = require_discoveredDevice2();
13940
14098
  var Credential = require_credential2();
13941
14099
  var ShortLink = require_shortLink2();
13942
- var AdminCustomer = require_customer2();
13943
- var AdminProperty = require_property2();
14100
+ var Property = require_property2();
14101
+ var Organization = require_organization2();
13944
14102
  module.exports = {
13945
- Admin: {
13946
- Customer: AdminCustomer,
13947
- Property: AdminProperty
13948
- },
14103
+ Organization,
14104
+ Property,
13949
14105
  Gateway,
13950
14106
  Switch,
13951
14107
  Alarm,
@@ -13960,6 +14116,7 @@ var require_Models = __commonJS({
13960
14116
  Identification,
13961
14117
  Product,
13962
14118
  User,
14119
+ SystemUser,
13963
14120
  Room,
13964
14121
  Application,
13965
14122
  Space,