@kohost/api-client 1.0.0-alpha.4 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/bitbucket-pipelines.yml +18 -8
  2. package/commands/CheckInReservationCommand.js +23 -0
  3. package/commands/DiscoverReservationsCommand.js +24 -0
  4. package/commands/DiscoverRoomsCommand.js +21 -0
  5. package/commands/DiscoverUsersCommand.js +2 -2
  6. package/commands/{VerifyDocumentCommand.js → OCRDocumentCommand.js} +4 -8
  7. package/commands/SendEmailCommand.js +24 -0
  8. package/commands/SendSMSCommand.js +21 -0
  9. package/commands/index.js +10 -4
  10. package/defs/http.js +1 -1
  11. package/events/EmailSentEvent.js +17 -0
  12. package/events/Event.js +20 -1
  13. package/events/SMSSentEvent.js +17 -0
  14. package/events/ShortLinkCreatedEvent.js +17 -0
  15. package/events/index.js +7 -0
  16. package/http/handleResponseError.js +9 -29
  17. package/http/index.js +12 -8
  18. package/models/credential.js +29 -0
  19. package/models/gateway.js +0 -8
  20. package/models/identification.js +32 -0
  21. package/models/index.js +9 -9
  22. package/models/kohost.js +4 -3
  23. package/models/product.js +30 -0
  24. package/models/reservation.js +47 -0
  25. package/models/room.js +1 -12
  26. package/models/shortLink.js +29 -0
  27. package/models/space.js +1 -1
  28. package/models/thermostat.js +3 -3
  29. package/models/user.js +0 -2
  30. package/models/windowCovering.js +1 -1
  31. package/package.json +1 -1
  32. package/schemas/admin/property.json +7 -1
  33. package/schemas/camera.json +3 -3
  34. package/schemas/courtesy.json +3 -3
  35. package/schemas/credential.json +28 -0
  36. package/schemas/definitions/common.json +53 -0
  37. package/schemas/definitions/device.json +13 -2
  38. package/schemas/dimmer.json +3 -3
  39. package/schemas/gateway.json +16 -47
  40. package/schemas/identification.json +18 -4
  41. package/schemas/lock.json +6 -3
  42. package/schemas/mediaSource.json +3 -3
  43. package/schemas/motionSensor.json +3 -3
  44. package/schemas/payment.json +3 -1
  45. package/schemas/product.json +36 -0
  46. package/schemas/reservation.json +8 -3
  47. package/schemas/room.json +1 -8
  48. package/schemas/shortLink.json +30 -0
  49. package/schemas/switch.json +3 -3
  50. package/schemas/thermostat.json +11 -10
  51. package/schemas/user.json +57 -5
  52. package/schemas/windowCovering.json +3 -3
  53. package/useCases/http.json +152 -44
  54. package/utils/schema.js +2 -2
  55. package/models/iotGateway.js +0 -29
  56. package/models/sceneController.js +0 -29
  57. package/schemas/iotGateway.json +0 -29
  58. package/schemas/sceneController.json +0 -58
  59. package/vite.config.js +0 -22
@@ -20,12 +20,13 @@
20
20
  "type": "string"
21
21
  }
22
22
  },
23
- "group": {
23
+ "space": {
24
24
  "type": "string"
25
25
  },
26
26
  "status": {
27
- "type": "string",
28
- "enum": ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow"]
27
+ "type": "string",
28
+ "enum": ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow", "enquired", "requested", "optional"],
29
+ "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)"
29
30
  },
30
31
  "confirmationNumber": {
31
32
  "type": "string"
@@ -61,6 +62,10 @@
61
62
  },
62
63
  "systemData": {
63
64
  "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
65
+ },
66
+ "metadata": {
67
+ "ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/metadata"
64
68
  }
65
69
  }
66
70
  }
71
+
package/schemas/room.json CHANGED
@@ -56,18 +56,11 @@
56
56
  "$ref": "https://api.kohost.app/schemas/v3/courtesy.json"
57
57
  }
58
58
  },
59
- "sceneControllers": {
60
- "type": "array",
61
- "default": [],
62
- "items": {
63
- "$ref": "https://api.kohost.app/schemas/v3/sceneController.json"
64
- }
65
- },
66
59
  "cameras": {
67
60
  "type": "array",
68
61
  "default": [],
69
62
  "items": {
70
- "$ref": "https://api.kohost.app/schemas/v3/camera.json"
63
+ "$ref": "https://api.kohost.app/schemas/v3/camera.json"
71
64
  }
72
65
  },
73
66
  "sources": {
@@ -0,0 +1,30 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "$id": "https://api.kohost.app/schemas/v3/shortLink.json",
4
+ "title": "Short Link",
5
+ "type": "object",
6
+ "required": ["destination", "url"],
7
+ "properties": {
8
+ "id": {
9
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
10
+ },
11
+ "type": {
12
+ "type": "string",
13
+ "default": "shortLink"
14
+ },
15
+ "title": {
16
+ "type": "string"
17
+ },
18
+ "destination": {
19
+ "string": "string",
20
+ "format": "uri"
21
+ },
22
+ "url": {
23
+ "string": "string",
24
+ "format": "uri"
25
+ },
26
+ "systemData": {
27
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
28
+ }
29
+ }
30
+ }
@@ -14,9 +14,6 @@
14
14
  "subType": {
15
15
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
16
16
  },
17
- "systemData": {
18
- "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
19
- },
20
17
  "supportedNotifications": {
21
18
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
22
19
  },
@@ -26,6 +23,9 @@
26
23
  "state": {
27
24
  "type": "string",
28
25
  "enum": ["on", "off"]
26
+ },
27
+ "systemData": {
28
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
29
29
  }
30
30
  },
31
31
  "additionalProperties": false,
@@ -18,10 +18,6 @@
18
18
  "subType": {
19
19
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
20
20
  },
21
- "systemData": {
22
- "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData",
23
- "default": {}
24
- },
25
21
  "supportedNotifications": {
26
22
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
27
23
  },
@@ -29,12 +25,10 @@
29
25
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
30
26
  },
31
27
  "currentTemperature": {
32
- "type": "number",
33
- "minimum": 0,
34
- "maximum": 130
28
+ "type": "number"
35
29
  },
36
30
  "currentHumidity": {
37
- "type": ["number", "null"],
31
+ "type": "number",
38
32
  "minimum": 0,
39
33
  "maximum": 99
40
34
  },
@@ -80,6 +74,7 @@
80
74
  },
81
75
  "setpoints": {
82
76
  "type": "object",
77
+ "additionalProperties": false,
83
78
  "properties": {
84
79
  "cool": {
85
80
  "$ref": "#/$defs/setpoint"
@@ -91,6 +86,13 @@
91
86
  "$ref": "#/$defs/setpoint"
92
87
  }
93
88
  }
89
+ },
90
+ "batteryLevel": {
91
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/batteryLevel"
92
+ },
93
+ "systemData": {
94
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData",
95
+ "default": {}
94
96
  }
95
97
  },
96
98
  "additionalProperties": false,
@@ -125,7 +127,6 @@
125
127
  "id",
126
128
  "type",
127
129
  "systemData",
128
- "currentTemperature",
129
130
  "hvacMode",
130
131
  "fanMode",
131
132
  "hvacState",
@@ -133,6 +134,6 @@
133
134
  "setpoints",
134
135
  "temperatureScale",
135
136
  "supportedHvacModes",
136
- "supportedFanModes"
137
+ "supportedFanModes"
137
138
  ]
138
139
  }
package/schemas/user.json CHANGED
@@ -24,13 +24,22 @@
24
24
  },
25
25
  "phone": {
26
26
  "type": ["string", "null"],
27
- "pattern": "^\\+?[0-9]{1,14}$"
27
+ "pattern": "^\\+[0-9]{1,14}$"
28
+ },
29
+ "phoneVerified": {
30
+ "type": "boolean"
28
31
  },
29
32
  "email": {
30
33
  "type": ["string", "null"],
31
34
  "format": "email"
32
35
  },
33
- "hashedPassword": {
36
+ "emailVerified": {
37
+ "type": "boolean"
38
+ },
39
+ "address": {
40
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/address"
41
+ },
42
+ "secretKey": {
34
43
  "type": "string"
35
44
  },
36
45
  "photo": {
@@ -43,7 +52,25 @@
43
52
  "type": "string"
44
53
  },
45
54
  "gender": {
46
- "type": "string"
55
+ "type": "string",
56
+ "enum": ["male", "female"]
57
+ },
58
+ "nationality": {
59
+ "type": "string",
60
+ "minLength": 2,
61
+ "maxLength": 2
62
+ },
63
+ "notes": {
64
+ "type": "array",
65
+ "items": {
66
+ "type": "string"
67
+ }
68
+ },
69
+ "files": {
70
+ "type": "array",
71
+ "items": {
72
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
73
+ }
47
74
  },
48
75
  "roles": {
49
76
  "type": "array",
@@ -64,13 +91,13 @@
64
91
  "identifications": {
65
92
  "type": "array",
66
93
  "items": {
67
- "$ref": "https://api.kohost.app/schemas/v3/identification.json"
94
+ "$ref": "https://api.kohost.app/schemas/v3/identification.json#"
68
95
  }
69
96
  },
70
97
  "payments": {
71
98
  "type": "array",
72
99
  "items": {
73
- "$ref": "https://api.kohost.app/schemas/v3/payment.json"
100
+ "$ref": "https://api.kohost.app/schemas/v3/payment.json#"
74
101
  }
75
102
  },
76
103
  "preferences": {
@@ -111,6 +138,31 @@
111
138
  }
112
139
  }
113
140
  },
141
+ "registeredDevices": {
142
+ "type": "array",
143
+ "items": {
144
+ "type": "object",
145
+ "properties": {
146
+ "userAgent": {
147
+ "type": "string"
148
+ },
149
+ "fingerPrint": {
150
+ "type": "string"
151
+ },
152
+ "ip": {
153
+ "type": "string"
154
+ },
155
+ "registeredAt": {
156
+ "type": "string",
157
+ "format": "date-time"
158
+ },
159
+ "expiresAt": {
160
+ "type": "string",
161
+ "format": "date-time"
162
+ }
163
+ }
164
+ }
165
+ },
114
166
  "createdAt": {
115
167
  "$ref": "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
116
168
  },
@@ -14,9 +14,6 @@
14
14
  "subType": {
15
15
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
16
16
  },
17
- "systemData": {
18
- "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
19
- },
20
17
  "supportedNotifications": {
21
18
  "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
22
19
  },
@@ -27,6 +24,9 @@
27
24
  "type": "number",
28
25
  "minimum": 0,
29
26
  "maximum": 100
27
+ },
28
+ "systemData": {
29
+ "$ref": "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
30
30
  }
31
31
  },
32
32
  "additionalProperties": false,
@@ -17,6 +17,33 @@
17
17
  }
18
18
  }
19
19
  ],
20
+ [
21
+ "AdminUpdateProperty",
22
+ {
23
+ "http": {
24
+ "method": "PUT",
25
+ "path": "/admin/properties/:id"
26
+ }
27
+ }
28
+ ],
29
+ [
30
+ "AdminDescribeProperty",
31
+ {
32
+ "http": {
33
+ "method": "GET",
34
+ "path": "/admin/properties/:id"
35
+ }
36
+ }
37
+ ],
38
+ [
39
+ "AdminCreateProperty",
40
+ {
41
+ "http": {
42
+ "method": "POST",
43
+ "path": "/admin/properties"
44
+ }
45
+ }
46
+ ],
20
47
  [
21
48
  "LoginUser",
22
49
  {
@@ -47,6 +74,16 @@
47
74
  }
48
75
  }
49
76
  ],
77
+ [
78
+ "RequestLoginLink",
79
+ {
80
+ "http": {
81
+ "disableAuth": true,
82
+ "method": "POST",
83
+ "path": "/auth/loginToken"
84
+ }
85
+ }
86
+ ],
50
87
  [
51
88
  "DescribeSelf",
52
89
  {
@@ -84,83 +121,84 @@
84
121
  }
85
122
  ],
86
123
  [
87
- "UpdateUser",
124
+ "UpdateSelf",
88
125
  {
89
126
  "http": {
90
127
  "method": "PUT",
91
- "path": "/users/:id"
128
+ "path": "/users/me"
92
129
  }
93
130
  }
94
131
  ],
95
132
  [
96
- "DeleteUser",
133
+ "UpdateUser",
97
134
  {
98
135
  "http": {
99
- "method": "DELETE",
136
+ "method": "PUT",
100
137
  "path": "/users/:id"
101
138
  }
102
139
  }
103
140
  ],
104
141
  [
105
- "DescribeGateway",
142
+ "DeleteUser",
106
143
  {
107
144
  "http": {
108
- "method": "GET",
109
- "path": "/gateways/:gatewayId"
145
+ "method": "DELETE",
146
+ "path": "/users/:id"
110
147
  }
111
148
  }
112
149
  ],
113
150
  [
114
- "ListGateways",
151
+ "SendVerificationCode",
115
152
  {
116
153
  "http": {
117
- "method": "GET",
118
- "path": "/gateways"
154
+ "method": "POST",
155
+ "path": "/users/:id/sendVerificationCode"
119
156
  }
120
157
  }
121
158
  ],
122
159
  [
123
- "CreateGateway",
160
+ "CheckVerificationCode",
124
161
  {
125
162
  "http": {
126
163
  "method": "POST",
127
- "path": "/gateways"
164
+ "path": "/users/:id/checkVerificationCode"
128
165
  }
129
166
  }
130
167
  ],
131
168
  [
132
- "UpdateGateway",
169
+ "MatchUserIdentification",
133
170
  {
134
171
  "http": {
135
- "method": "PUT",
136
- "path": "/gateways/:gatewayId"
172
+ "method": "POST",
173
+ "path": "/users/:id/identifications/match",
174
+ "maxSize": "2mb"
137
175
  }
138
176
  }
139
177
  ],
140
178
  [
141
- "DeleteGateway",
179
+ "ListSpaces",
142
180
  {
143
181
  "http": {
144
- "method": "DELETE",
145
- "path": "/gateways/:gatewayId"
182
+ "method": "GET",
183
+ "path": "/spaces"
146
184
  }
147
185
  }
148
186
  ],
149
187
  [
150
- "EmailUserAccountSetup",
188
+ "ListMySpaces",
151
189
  {
152
190
  "http": {
153
- "method": "POST",
154
- "path": "/users/:id/email/setup"
191
+ "method": "GET",
192
+ "path": "/spaces/mine"
155
193
  }
156
194
  }
157
195
  ],
158
196
  [
159
- "ListSpaces",
197
+ "ListRoomsInSpace",
160
198
  {
161
199
  "http": {
162
200
  "method": "GET",
163
- "path": "/spaces"
201
+ "path": "/spaces/:id/rooms"
164
202
  }
165
203
  }
166
204
  ],
@@ -300,7 +338,7 @@
300
338
  }
301
339
  ],
302
340
  [
303
- "SetLocks",
341
+ "SetLock",
304
342
  {
305
343
  "http": {
306
344
  "method": "POST",
@@ -354,7 +392,7 @@
354
392
  }
355
393
  ],
356
394
  [
357
- "SetCameras",
395
+ "SetCamera",
358
396
  {
359
397
  "http": {
360
398
  "method": "POST",
@@ -552,7 +590,7 @@
552
590
  }
553
591
  ],
554
592
  [
555
- "SetSwitches",
593
+ "SetSwitch",
556
594
  {
557
595
  "http": {
558
596
  "method": "POST",
@@ -606,7 +644,7 @@
606
644
  }
607
645
  ],
608
646
  [
609
- "SetSceneControllers",
647
+ "SetSceneController",
610
648
  {
611
649
  "http": {
612
650
  "method": "POST",
@@ -660,7 +698,7 @@
660
698
  }
661
699
  ],
662
700
  [
663
- "SetSources",
701
+ "SetSource",
664
702
  {
665
703
  "http": {
666
704
  "method": "POST",
@@ -714,7 +752,7 @@
714
752
  }
715
753
  ],
716
754
  [
717
- "SetThermostats",
755
+ "SetThermostat",
718
756
  {
719
757
  "http": {
720
758
  "method": "POST",
@@ -768,7 +806,7 @@
768
806
  }
769
807
  ],
770
808
  [
771
- "SetWindowCoverings",
809
+ "SetWindowCovering",
772
810
  {
773
811
  "http": {
774
812
  "method": "POST",
@@ -781,7 +819,7 @@
781
819
  {
782
820
  "http": {
783
821
  "method": "POST",
784
- "path": "/rooms/:roomId/scenes"
822
+ "path": "/rooms/:id/scenes"
785
823
  }
786
824
  }
787
825
  ],
@@ -808,7 +846,7 @@
808
846
  {
809
847
  "http": {
810
848
  "method": "POST",
811
- "path": "/tickets/:ticketId/messages"
849
+ "path": "/tickets/:id/messages"
812
850
  }
813
851
  }
814
852
  ],
@@ -817,7 +855,7 @@
817
855
  {
818
856
  "http": {
819
857
  "method": "DELETE",
820
- "path": "/tickets/:ticketId"
858
+ "path": "/tickets/:id"
821
859
  }
822
860
  }
823
861
  ],
@@ -826,7 +864,7 @@
826
864
  {
827
865
  "http": {
828
866
  "method": "GET",
829
- "path": "/tickets/:ticketId"
867
+ "path": "/tickets/:id"
830
868
  }
831
869
  }
832
870
  ],
@@ -844,7 +882,7 @@
844
882
  {
845
883
  "http": {
846
884
  "method": "POST",
847
- "path": "/tickets/:ticketId/readAll"
885
+ "path": "/tickets/:id/readAll"
848
886
  }
849
887
  }
850
888
  ],
@@ -853,7 +891,7 @@
853
891
  {
854
892
  "http": {
855
893
  "method": "PUT",
856
- "path": "/tickets/:ticketId"
894
+ "path": "/tickets/:id"
857
895
  }
858
896
  }
859
897
  ],
@@ -862,7 +900,7 @@
862
900
  {
863
901
  "http": {
864
902
  "method": "PUT",
865
- "path": "/tickets/:ticketId/status"
903
+ "path": "/tickets/:id/status"
866
904
  }
867
905
  }
868
906
  ],
@@ -1005,21 +1043,24 @@
1005
1043
  }
1006
1044
  ],
1007
1045
  [
1008
- "UpsertSystemReservation",
1046
+ "UpsertSystemSpace",
1009
1047
  {
1010
1048
  "http": false
1011
1049
  }
1012
1050
  ],
1013
1051
  [
1014
- "UpsertSystemSpace",
1052
+ "UpsertSystemUser",
1015
1053
  {
1016
1054
  "http": false
1017
1055
  }
1018
1056
  ],
1019
1057
  [
1020
- "UpsertSystemUser",
1058
+ "DiscoverReservations",
1021
1059
  {
1022
- "http": false
1060
+ "http": {
1061
+ "method": "GET",
1062
+ "path": "/reservations/discover"
1063
+ }
1023
1064
  }
1024
1065
  ],
1025
1066
  [
@@ -1077,11 +1118,62 @@
1077
1118
  }
1078
1119
  ],
1079
1120
  [
1080
- "VerifyDocument",
1121
+ "DescribeReservationCheckinStatus",
1122
+ {
1123
+ "http": {
1124
+ "method": "GET",
1125
+ "path": "/reservations/:id/checkinStatus"
1126
+ }
1127
+ }
1128
+ ],
1129
+ [
1130
+ "CheckInReservation",
1131
+ {
1132
+ "http": {
1133
+ "method": "POST",
1134
+ "path": "/reservations/:id/checkin"
1135
+ }
1136
+ }
1137
+ ],
1138
+ [
1139
+ "SendPreArrivalSMS",
1140
+ {
1141
+ "http": {
1142
+ "method": "POST",
1143
+ "path": "/reservations/:id/sendPreArrivalSMS"
1144
+ }
1145
+ }
1146
+ ],
1147
+ [
1148
+ "SendPreArrivalEmail",
1149
+ {
1150
+ "http": {
1151
+ "method": "POST",
1152
+ "path": "/reservations/:id/sendPreArrivalEmail"
1153
+ }
1154
+ }
1155
+ ],
1156
+ [
1157
+ "BatchNotifyPreArrival",
1158
+ {
1159
+ "http": {
1160
+ "method": "POST",
1161
+ "path": "/reservations/batchNotifyPreArrival"
1162
+ }
1163
+ }
1164
+ ],
1165
+ [
1166
+ "UpsertSystemReservation",
1167
+ {
1168
+ "http": false
1169
+ }
1170
+ ],
1171
+ [
1172
+ "OCRDocument",
1081
1173
  {
1082
1174
  "http": {
1083
1175
  "method": "POST",
1084
- "path": "/documents/verify",
1176
+ "path": "/documents/ocr",
1085
1177
  "maxSize": "2mb"
1086
1178
  }
1087
1179
  }
@@ -1091,8 +1183,24 @@
1091
1183
  {
1092
1184
  "http": {
1093
1185
  "method": "GET",
1094
- "path": "/properties/mine"
1186
+ "path": "/properties/mine",
1187
+ "disableAuth": true
1095
1188
  }
1096
1189
  }
1190
+ ],
1191
+ [
1192
+ "EmailUserAccountSetup",
1193
+ {
1194
+ "http": {
1195
+ "method": "POST",
1196
+ "path": "/users/:id/email/setup"
1197
+ }
1198
+ }
1199
+ ],
1200
+ [
1201
+ "LogEvent",
1202
+ {
1203
+ "http": false
1204
+ }
1097
1205
  ]
1098
1206
  ]
package/utils/schema.js CHANGED
@@ -16,13 +16,13 @@ addFormats(ajv);
16
16
 
17
17
  ajv.addSchema(commonDefs);
18
18
 
19
- ajv.addSchema(deviceDefs);
19
+ ajv.addSchema(deviceDefs);
20
20
 
21
21
  module.exports = {
22
22
  add: function add(schema) {
23
23
  ajv.addSchema(schema);
24
24
  },
25
- compile: function compile(schema) {
25
+ compile: function compile(schema) {
26
26
  return ajv.compile(schema);
27
27
  },
28
28
  };