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

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.
Files changed (32) hide show
  1. package/dist/cjs/Client.js +337 -680
  2. package/dist/cjs/Commands.js +74 -3
  3. package/dist/cjs/Models.js +24 -2
  4. package/dist/cjs/defs.js +8 -31
  5. package/dist/esm/Client.js +337 -680
  6. package/dist/esm/Client.js.map +3 -3
  7. package/dist/esm/Commands.js +74 -3
  8. package/dist/esm/Commands.js.map +3 -3
  9. package/dist/esm/Models.js +23 -2
  10. package/dist/esm/Models.js.map +2 -2
  11. package/dist/esm/defs.js +8 -31
  12. package/dist/esm/defs.js.map +2 -2
  13. package/dist/useCases/AdminUpdateCustomer.js +1 -1
  14. package/dist/useCases/{AdminListCustomers.js → CreateOrganization.js} +3 -3
  15. package/dist/useCases/{AdminLoginUser.js → CreateProperty.js} +2 -2
  16. package/dist/useCases/{AdminCreateAdminUser.js → DescribeOrganization.js} +4 -4
  17. package/dist/useCases/{ListIntegrations.js → DescribeProperty.js} +3 -3
  18. package/dist/useCases/{AdminRefreshToken.js → ListOrganizations.js} +3 -3
  19. package/dist/useCases/{AdminListAdminUsers.js → ListProperties.js} +2 -2
  20. package/dist/useCases/{DeleteIntegration.js → LogoutUser.js} +3 -3
  21. package/dist/useCases/{CreateIntegration.js → RequestMyKeyToken.js} +2 -2
  22. package/dist/useCases/{CreateIntegrationDeviceMapEntry.js → SendCheckInSMS.js} +2 -2
  23. package/dist/useCases/{UpdateIntegration.js → UpdateProperty.js} +2 -2
  24. package/package.json +1 -1
  25. package/dist/useCases/AdminCreateCustomer.js +0 -32
  26. package/dist/useCases/AdminCreateProperty.js +0 -32
  27. package/dist/useCases/AdminDescribeCustomer.js +0 -32
  28. package/dist/useCases/AdminDescribeProperty.js +0 -32
  29. package/dist/useCases/AdminListProperties.js +0 -32
  30. package/dist/useCases/AdminRequestLoginLink.js +0 -32
  31. package/dist/useCases/AdminUpdateProperty.js +0 -32
  32. package/dist/useCases/DescribeIntegration.js +0 -32
@@ -289,8 +289,6 @@ var require_OCRDocumentCommand = __commonJS({
289
289
  var RequestError = require_RequestError();
290
290
  var OCRDocumentCommand2 = class extends Command {
291
291
  constructor({ type, image }) {
292
- if (!type)
293
- throw new RequestError("document type is required");
294
292
  if (!image)
295
293
  throw new RequestError("document image is required");
296
294
  super({ type, image });
@@ -674,6 +672,75 @@ var require_UpdateReservationCommand = __commonJS({
674
672
  }
675
673
  });
676
674
 
675
+ // src/Commands/UpdateUserCommand.js
676
+ var require_UpdateUserCommand = __commonJS({
677
+ "src/Commands/UpdateUserCommand.js"(exports2, module2) {
678
+ var Command = require_Command();
679
+ var RequestError = require_RequestError();
680
+ var UpdateUserCommand2 = class extends Command {
681
+ constructor({
682
+ id,
683
+ email,
684
+ phone,
685
+ identification,
686
+ address,
687
+ note,
688
+ nationality,
689
+ file,
690
+ payment
691
+ }) {
692
+ if (!id)
693
+ throw new RequestError("document type is required");
694
+ super({
695
+ id,
696
+ email,
697
+ phone,
698
+ identification,
699
+ address,
700
+ note,
701
+ nationality,
702
+ file,
703
+ payment
704
+ });
705
+ }
706
+ get name() {
707
+ return "UpdateUser";
708
+ }
709
+ get routingKey() {
710
+ return `user.${this.data.id}.update`;
711
+ }
712
+ get replyTo() {
713
+ return "system.response.users";
714
+ }
715
+ };
716
+ __name(UpdateUserCommand2, "UpdateUserCommand");
717
+ module2.exports = UpdateUserCommand2;
718
+ }
719
+ });
720
+
721
+ // src/Commands/GetMobileKeyCommand.js
722
+ var require_GetMobileKeyCommand = __commonJS({
723
+ "src/Commands/GetMobileKeyCommand.js"(exports2, module2) {
724
+ var Command = require_Command();
725
+ var GetMobileKeyCommand2 = class extends Command {
726
+ constructor({ id, startDate, endDate }) {
727
+ super({ id, startDate, endDate });
728
+ }
729
+ get name() {
730
+ return "GetMobileKey";
731
+ }
732
+ get routingKey() {
733
+ return `lock.${this.data.id}.set`;
734
+ }
735
+ get replyTo() {
736
+ return "system.response.devices";
737
+ }
738
+ };
739
+ __name(GetMobileKeyCommand2, "GetMobileKeyCommand");
740
+ module2.exports = GetMobileKeyCommand2;
741
+ }
742
+ });
743
+
677
744
  // src/Commands/index.js
678
745
  var SetAlarmCommand = require_SetAlarmCommand();
679
746
  var SetDimmerCommand = require_SetDimmerCommand();
@@ -693,6 +760,8 @@ var DiscoverRoomsCommand = require_DiscoverRoomsCommand();
693
760
  var DiscoverRoomTypesCommand = require_DiscoverRoomTypesCommand();
694
761
  var CreateShortLinkCommand = require_CreateShortLinkCommand();
695
762
  var UpdateReservationCommand = require_UpdateReservationCommand();
763
+ var UpdateUserCommand = require_UpdateUserCommand();
764
+ var GetMobileKeyCommand = require_GetMobileKeyCommand();
696
765
  module.exports = {
697
766
  SetAlarmCommand,
698
767
  SetDimmerCommand,
@@ -711,5 +780,7 @@ module.exports = {
711
780
  DiscoverRoomsCommand,
712
781
  DiscoverRoomTypesCommand,
713
782
  CreateShortLinkCommand,
714
- UpdateReservationCommand
783
+ UpdateReservationCommand,
784
+ UpdateUserCommand,
785
+ GetMobileKeyCommand
715
786
  };
@@ -846,6 +846,9 @@ var require_thermostat = __commonJS({
846
846
  subType: {
847
847
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
848
848
  },
849
+ offline: {
850
+ type: "boolean"
851
+ },
849
852
  supportedNotifications: {
850
853
  $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
851
854
  },
@@ -1398,6 +1401,9 @@ var require_payment = __commonJS({
1398
1401
  "vpay"
1399
1402
  ]
1400
1403
  },
1404
+ storageData: {
1405
+ type: ["string", "null"]
1406
+ },
1401
1407
  maskedNumber: {
1402
1408
  string: "string"
1403
1409
  },
@@ -2390,10 +2396,16 @@ var require_room2 = __commonJS({
2390
2396
  var _a;
2391
2397
  return ((_a = this.windowCoverings) == null ? void 0 : _a.length) > 0;
2392
2398
  }
2399
+ get hasShade() {
2400
+ return this.hasWindowCovering;
2401
+ }
2393
2402
  get hasThermostat() {
2394
2403
  var _a;
2395
2404
  return ((_a = this.thermostats) == null ? void 0 : _a.length) > 0;
2396
2405
  }
2406
+ get hasClimate() {
2407
+ return this.hasThermostat;
2408
+ }
2397
2409
  get hasLock() {
2398
2410
  var _a;
2399
2411
  return ((_a = this.locks) == null ? void 0 : _a.length) > 0;
@@ -2414,6 +2426,13 @@ var require_room2 = __commonJS({
2414
2426
  var _a;
2415
2427
  return ((_a = this.sources) == null ? void 0 : _a.length) > 0;
2416
2428
  }
2429
+ get hasLight() {
2430
+ var _a;
2431
+ const hasSubTypeLight = (_a = this.switches) == null ? void 0 : _a.some((sw) => {
2432
+ return sw.subType === "light" || sw.subType === "fan";
2433
+ });
2434
+ return this.hasDimmer || hasSubTypeLight;
2435
+ }
2417
2436
  get occupied() {
2418
2437
  const now = /* @__PURE__ */ new Date();
2419
2438
  const lastOccupied = new Date(this.occupiedAt);
@@ -3354,7 +3373,7 @@ var require_discoveredDevice = __commonJS({
3354
3373
  title: "Discovered Device",
3355
3374
  description: "A device that has been discovered by Kohost, but not yet added to the Kohost system.",
3356
3375
  type: "object",
3357
- required: ["name", "deviceId", "driver", "deviceData"],
3376
+ required: ["name", "deviceId", "deviceData"],
3358
3377
  properties: {
3359
3378
  id: {
3360
3379
  $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
@@ -3438,7 +3457,7 @@ var require_credential = __commonJS({
3438
3457
  },
3439
3458
  type: {
3440
3459
  type: "string",
3441
- enum: ["verificationCode", "token"]
3460
+ enum: ["verificationCode", "token", "mobileKey"]
3442
3461
  },
3443
3462
  credential: {
3444
3463
  type: "string"
@@ -3451,6 +3470,9 @@ var require_credential = __commonJS({
3451
3470
  },
3452
3471
  expires: {
3453
3472
  string: "string"
3473
+ },
3474
+ systemData: {
3475
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
3454
3476
  }
3455
3477
  }
3456
3478
  };
package/dist/cjs/defs.js CHANGED
@@ -52,6 +52,7 @@ var require_Client = __commonJS({
52
52
  constructor(options = {
53
53
  url: "",
54
54
  propertyId: "",
55
+ apiKey: "",
55
56
  headers: {}
56
57
  }) {
57
58
  super();
@@ -61,7 +62,7 @@ var require_Client = __commonJS({
61
62
  throw new Error("options.property is required");
62
63
  this.options = options;
63
64
  this.isBrowser = typeof window !== "undefined";
64
- this._http = axios.create({
65
+ const config = {
65
66
  baseURL: options.url,
66
67
  responseType: "json",
67
68
  withCredentials: true,
@@ -71,22 +72,19 @@ var require_Client = __commonJS({
71
72
  [KohostApiClient.defs.propertyHeader]: options.propertyId,
72
73
  ...options.headers
73
74
  }
74
- });
75
+ };
76
+ if (options.apiKey) {
77
+ config.headers[KohostApiClient.defs.apiKeyHeader] = options.apiKey;
78
+ }
79
+ this._http = axios.create(config);
75
80
  this._http.interceptors.response.use(
76
81
  this._handleResponse.bind(this),
77
82
  this._handleResponseError.bind(this)
78
83
  );
79
- this._http.interceptors.request.use((config) => {
80
- if (!this.isBrowser) {
81
- config.headers[KohostApiClient.defs.authTokenHeader] = this.authToken;
82
- }
83
- return config;
84
- });
85
84
  }
86
85
  static get defs() {
87
86
  return {
88
- authTokenHeader: "X-Auth-Token",
89
- refreshTokenHeader: "X-Refresh-Token",
87
+ apiKeyHeader: "X-Api-Key",
90
88
  propertyHeader: "X-Property-Id"
91
89
  };
92
90
  }
@@ -98,12 +96,6 @@ var require_Client = __commonJS({
98
96
  response.pagination = response.data.pagination;
99
97
  response.data = response.data.data;
100
98
  }
101
- if (!this.isBrowser && response.headers[this.authTokenHeaderKey]) {
102
- this.authToken = response.headers[this.authTokenHeaderKey];
103
- }
104
- if (!this.isBrowser && response.headers[this.refreshTokenHeaderKey]) {
105
- this.refreshToken = response.headers[this.refreshTokenHeaderKey];
106
- }
107
99
  return response;
108
100
  } catch (error) {
109
101
  return Promise.reject(error);
@@ -142,25 +134,10 @@ var require_Client = __commonJS({
142
134
  }
143
135
  return Promise.reject(error);
144
136
  }
145
- get authTokenHeaderKey() {
146
- return KohostApiClient.defs.authTokenHeader.toLowerCase();
147
- }
148
- get refreshTokenHeaderKey() {
149
- return KohostApiClient.defs.refreshTokenHeader.toLowerCase();
150
- }
151
- get lsTokenKey() {
152
- return `${this.options.propertyId}_${KohostApiClient.defs.authTokenHeader}`;
153
- }
154
- get authToken() {
155
- return this._authToken;
156
- }
157
137
  /*
158
138
  @param {String} token - The token to set
159
139
  @returns undefined
160
140
  */
161
- set authToken(token) {
162
- this._authToken = token;
163
- }
164
141
  _onLoginRequired() {
165
142
  this.emit("LoginRequired");
166
143
  }