@kohost/api-client 1.0.0-beta.2 → 1.0.0-beta.4

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 (255) hide show
  1. package/dist/Client.js +19632 -0
  2. package/dist/commands.js +568 -0
  3. package/dist/defs.js +196 -0
  4. package/dist/errors.js +174 -0
  5. package/dist/events.js +375 -0
  6. package/dist/models.js +3584 -0
  7. package/dist/useCases/AddDefaultScenesToRooms.js +39 -0
  8. package/dist/useCases/AddScenesToRoom.js +39 -0
  9. package/dist/useCases/AdminCreateProperty.js +39 -0
  10. package/dist/useCases/AdminDescribeProperty.js +39 -0
  11. package/dist/useCases/AdminListCustomers.js +39 -0
  12. package/dist/useCases/AdminListProperties.js +39 -0
  13. package/dist/useCases/AdminUpdateProperty.js +39 -0
  14. package/dist/useCases/BatchNotifyPreArrival.js +39 -0
  15. package/dist/useCases/CheckInReservation.js +39 -0
  16. package/dist/useCases/CheckVerificationCode.js +39 -0
  17. package/dist/useCases/CreateAlarm.js +39 -0
  18. package/dist/useCases/CreateCamera.js +39 -0
  19. package/dist/useCases/CreateCourtesy.js +39 -0
  20. package/dist/useCases/CreateDefaultScenes.js +39 -0
  21. package/dist/useCases/CreateDimmer.js +39 -0
  22. package/dist/useCases/CreateDiscoveredDevice.js +39 -0
  23. package/dist/useCases/CreateDiscoveredDeviceAssociation.js +39 -0
  24. package/dist/useCases/CreateIntegration.js +39 -0
  25. package/dist/useCases/CreateIntegrationDeviceMapEntry.js +39 -0
  26. package/dist/useCases/CreateLock.js +39 -0
  27. package/dist/useCases/CreateReservation.js +39 -0
  28. package/dist/useCases/CreateRoom.js +39 -0
  29. package/dist/useCases/CreateRoomInSpace.js +39 -0
  30. package/dist/useCases/CreateSource.js +39 -0
  31. package/dist/useCases/CreateSpace.js +39 -0
  32. package/dist/useCases/CreateSwitch.js +39 -0
  33. package/dist/useCases/CreateThermostat.js +39 -0
  34. package/dist/useCases/CreateTicket.js +39 -0
  35. package/dist/useCases/CreateTicketMessage.js +39 -0
  36. package/dist/useCases/CreateUser.js +39 -0
  37. package/dist/useCases/CreateWindowCovering.js +39 -0
  38. package/dist/useCases/DeleteAlarm.js +39 -0
  39. package/dist/useCases/DeleteCamera.js +39 -0
  40. package/dist/useCases/DeleteCourtesy.js +39 -0
  41. package/dist/useCases/DeleteDimmer.js +39 -0
  42. package/dist/useCases/DeleteDiscoveredDevice.js +39 -0
  43. package/dist/useCases/DeleteIntegration.js +39 -0
  44. package/dist/useCases/DeleteLock.js +39 -0
  45. package/dist/useCases/DeleteReservation.js +39 -0
  46. package/dist/useCases/DeleteRoom.js +39 -0
  47. package/dist/useCases/DeleteSource.js +39 -0
  48. package/dist/useCases/DeleteSpace.js +39 -0
  49. package/dist/useCases/DeleteSwitch.js +39 -0
  50. package/dist/useCases/DeleteThermostat.js +39 -0
  51. package/dist/useCases/DeleteTicket.js +39 -0
  52. package/dist/useCases/DeleteUser.js +39 -0
  53. package/dist/useCases/DeleteWindowCovering.js +39 -0
  54. package/dist/useCases/DescribeAlarm.js +39 -0
  55. package/dist/useCases/DescribeCamera.js +39 -0
  56. package/dist/useCases/DescribeCourtesy.js +39 -0
  57. package/dist/useCases/DescribeDimmer.js +39 -0
  58. package/dist/useCases/DescribeDiscoveredDevice.js +39 -0
  59. package/dist/useCases/DescribeIntegration.js +39 -0
  60. package/dist/useCases/DescribeLock.js +39 -0
  61. package/dist/useCases/DescribeMyProperty.js +39 -0
  62. package/dist/useCases/DescribeReservation.js +39 -0
  63. package/dist/useCases/DescribeReservationCheckinStatus.js +39 -0
  64. package/dist/useCases/DescribeRoom.js +39 -0
  65. package/dist/useCases/DescribeSelf.js +39 -0
  66. package/dist/useCases/DescribeSource.js +39 -0
  67. package/dist/useCases/DescribeSpace.js +39 -0
  68. package/dist/useCases/DescribeSwitch.js +39 -0
  69. package/dist/useCases/DescribeThermostat.js +39 -0
  70. package/dist/useCases/DescribeTicket.js +39 -0
  71. package/dist/useCases/DescribeUser.js +39 -0
  72. package/dist/useCases/DescribeWindowCovering.js +39 -0
  73. package/dist/useCases/DiscoverReservations.js +39 -0
  74. package/dist/useCases/EmailUserAccountSetup.js +39 -0
  75. package/dist/useCases/ListAlarms.js +39 -0
  76. package/dist/useCases/ListCameras.js +39 -0
  77. package/dist/useCases/ListCourtesy.js +39 -0
  78. package/dist/useCases/ListDimmers.js +39 -0
  79. package/dist/useCases/ListDiscoveredDevices.js +39 -0
  80. package/dist/useCases/ListIntegrations.js +39 -0
  81. package/dist/useCases/ListLocks.js +39 -0
  82. package/dist/useCases/ListMyReservations.js +39 -0
  83. package/dist/useCases/ListMySpaces.js +39 -0
  84. package/dist/useCases/ListReservations.js +39 -0
  85. package/dist/useCases/ListRooms.js +39 -0
  86. package/dist/useCases/ListRoomsInSpace.js +39 -0
  87. package/dist/useCases/ListSources.js +39 -0
  88. package/dist/useCases/ListSpaces.js +39 -0
  89. package/dist/useCases/ListSwitches.js +39 -0
  90. package/dist/useCases/ListThermostats.js +39 -0
  91. package/dist/useCases/ListTickets.js +39 -0
  92. package/dist/useCases/ListUserReservations.js +39 -0
  93. package/dist/useCases/ListUsers.js +39 -0
  94. package/dist/useCases/ListWindowCoverings.js +39 -0
  95. package/dist/useCases/LoginGateway.js +39 -0
  96. package/dist/useCases/LoginUser.js +39 -0
  97. package/dist/useCases/MatchUserIdentification.js +39 -0
  98. package/dist/useCases/OCRDocument.js +39 -0
  99. package/dist/useCases/RefreshToken.js +39 -0
  100. package/dist/useCases/RequestLoginLink.js +39 -0
  101. package/dist/useCases/SendPreArrivalEmail.js +39 -0
  102. package/dist/useCases/SendPreArrivalSMS.js +39 -0
  103. package/dist/useCases/SendVerificationCode.js +39 -0
  104. package/dist/useCases/SetCamera.js +39 -0
  105. package/dist/useCases/SetCourtesy.js +39 -0
  106. package/dist/useCases/SetLock.js +39 -0
  107. package/dist/useCases/SetSource.js +39 -0
  108. package/dist/useCases/SetSwitch.js +39 -0
  109. package/dist/useCases/SetThermostat.js +39 -0
  110. package/dist/useCases/SetWindowCovering.js +39 -0
  111. package/dist/useCases/UpdateAlarm.js +39 -0
  112. package/dist/useCases/UpdateCamera.js +39 -0
  113. package/dist/useCases/UpdateCourtesy.js +39 -0
  114. package/dist/useCases/UpdateDimmer.js +39 -0
  115. package/dist/useCases/UpdateDiscoveredDevice.js +39 -0
  116. package/dist/useCases/UpdateIntegration.js +39 -0
  117. package/dist/useCases/UpdateLock.js +39 -0
  118. package/dist/useCases/UpdateMessageReadStatus.js +39 -0
  119. package/dist/useCases/UpdateReservation.js +39 -0
  120. package/dist/useCases/UpdateRoom.js +39 -0
  121. package/dist/useCases/UpdateSelf.js +39 -0
  122. package/dist/useCases/UpdateSource.js +39 -0
  123. package/dist/useCases/UpdateSpace.js +39 -0
  124. package/dist/useCases/UpdateSwitch.js +39 -0
  125. package/dist/useCases/UpdateThermostat.js +39 -0
  126. package/dist/useCases/UpdateTicket.js +39 -0
  127. package/dist/useCases/UpdateTicketStatus.js +39 -0
  128. package/dist/useCases/UpdateUser.js +39 -0
  129. package/dist/useCases/UpdateWindowCovering.js +39 -0
  130. package/dist/useCases/UpsertDiscoveredDevice.js +39 -0
  131. package/dist/utils.js +53 -0
  132. package/package.json +8 -2
  133. package/.eslintrc.js +0 -10
  134. package/bitbucket-pipelines.yml +0 -65
  135. package/commands/CheckInReservationCommand.js +0 -23
  136. package/commands/Command.js +0 -38
  137. package/commands/DiscoverReservationsCommand.js +0 -24
  138. package/commands/DiscoverRoomsCommand.js +0 -21
  139. package/commands/DiscoverUsersCommand.js +0 -21
  140. package/commands/OCRDocumentCommand.js +0 -20
  141. package/commands/SendEmailCommand.js +0 -24
  142. package/commands/SendSMSCommand.js +0 -21
  143. package/commands/SetAlarmCommand.js +0 -21
  144. package/commands/SetCourtesyCommand.js +0 -21
  145. package/commands/SetDimmerCommand.js +0 -21
  146. package/commands/SetLockCommand.js +0 -21
  147. package/commands/SetSceneControllerCommand.js +0 -21
  148. package/commands/SetSwitchCommand.js +0 -21
  149. package/commands/SetThermostatCommand.js +0 -21
  150. package/commands/SetWindowCoveringCommand.js +0 -21
  151. package/commands/index.js +0 -31
  152. package/defs/deviceTypes.js +0 -15
  153. package/defs/formalDeviceTypes.js +0 -6
  154. package/defs/http.js +0 -7
  155. package/defs/index.js +0 -11
  156. package/errors/AppError.js +0 -8
  157. package/errors/AuthenticationError.js +0 -9
  158. package/errors/AuthorizationError.js +0 -9
  159. package/errors/DeviceCommError.js +0 -9
  160. package/errors/LoginError.js +0 -9
  161. package/errors/NotFoundError.js +0 -9
  162. package/errors/RequestError.js +0 -9
  163. package/errors/SystemCommError.js +0 -9
  164. package/errors/TokenExpiredError.js +0 -9
  165. package/errors/UnprocessableRequestError.js +0 -9
  166. package/errors/ValidationError.js +0 -9
  167. package/errors/index.js +0 -15
  168. package/events/EmailSentEvent.js +0 -17
  169. package/events/Event.js +0 -52
  170. package/events/SMSSentEvent.js +0 -17
  171. package/events/ShortLinkCreatedEvent.js +0 -17
  172. package/events/SystemCameraUpdatedEvent.js +0 -17
  173. package/events/SystemCourtesyUpdatedEvent.js +0 -17
  174. package/events/SystemDimmerUpdatedEvent.js +0 -17
  175. package/events/SystemLockUpdatedEvent.js +0 -17
  176. package/events/SystemReservationUpdatedEvent.js +0 -17
  177. package/events/SystemSceneControllerUpdatedEvent.js +0 -17
  178. package/events/SystemSourceUpdatedEvent.js +0 -17
  179. package/events/SystemSpaceUpdatedEvent.js +0 -17
  180. package/events/SystemSwitchUpdatedEvent.js +0 -17
  181. package/events/SystemThermostatUpdatedEvent.js +0 -17
  182. package/events/SystemUserUpdatedEvent.js +0 -17
  183. package/events/SystemWindowCoveringUpdatedEvent.js +0 -17
  184. package/events/index.js +0 -35
  185. package/http/handleResponseError.js +0 -33
  186. package/http/handleResponseSuccess.js +0 -15
  187. package/http/index.js +0 -169
  188. package/index.js +0 -23
  189. package/models/acl.js +0 -29
  190. package/models/admin/customer.js +0 -28
  191. package/models/admin/property.js +0 -28
  192. package/models/alarm.js +0 -29
  193. package/models/application.js +0 -28
  194. package/models/camera.js +0 -29
  195. package/models/courtesy.js +0 -33
  196. package/models/credential.js +0 -29
  197. package/models/dimmer.js +0 -49
  198. package/models/discoveredDevice.js +0 -30
  199. package/models/gateway.js +0 -29
  200. package/models/identification.js +0 -32
  201. package/models/index.js +0 -56
  202. package/models/integration.js +0 -76
  203. package/models/kohost.js +0 -96
  204. package/models/lock.js +0 -33
  205. package/models/mediaSource.js +0 -29
  206. package/models/motionSensor.js +0 -29
  207. package/models/product.js +0 -30
  208. package/models/reservation.js +0 -83
  209. package/models/room.js +0 -174
  210. package/models/scene.js +0 -28
  211. package/models/shortLink.js +0 -29
  212. package/models/space.js +0 -99
  213. package/models/switch.js +0 -33
  214. package/models/thermostat.js +0 -80
  215. package/models/ticket.js +0 -91
  216. package/models/user.js +0 -56
  217. package/models/windowCovering.js +0 -49
  218. package/prepare.js +0 -4
  219. package/schemas/acl.json +0 -111
  220. package/schemas/admin/customer.json +0 -32
  221. package/schemas/admin/property.json +0 -180
  222. package/schemas/alarm.json +0 -93
  223. package/schemas/application.json +0 -24
  224. package/schemas/camera.json +0 -41
  225. package/schemas/courtesy.json +0 -37
  226. package/schemas/credential.json +0 -28
  227. package/schemas/definitions/common.json +0 -74
  228. package/schemas/definitions/device.json +0 -76
  229. package/schemas/dimmer.json +0 -34
  230. package/schemas/discoveredDevice.json +0 -43
  231. package/schemas/gateway.json +0 -30
  232. package/schemas/identification.json +0 -49
  233. package/schemas/integration.json +0 -94
  234. package/schemas/lock.json +0 -36
  235. package/schemas/mediaSource.json +0 -151
  236. package/schemas/motionSensor.json +0 -26
  237. package/schemas/payment.json +0 -40
  238. package/schemas/product.json +0 -36
  239. package/schemas/reservation.json +0 -71
  240. package/schemas/room.json +0 -131
  241. package/schemas/scene.json +0 -118
  242. package/schemas/shortLink.json +0 -30
  243. package/schemas/space.json +0 -111
  244. package/schemas/switch.json +0 -33
  245. package/schemas/thermostat.json +0 -139
  246. package/schemas/ticket.json +0 -82
  247. package/schemas/user.json +0 -176
  248. package/schemas/windowCovering.json +0 -34
  249. package/tests/unit/models/space.test.js +0 -31
  250. package/tests/unit/models/thermostat.test.js +0 -146
  251. package/tests/unit/models/user.test.js +0 -28
  252. package/useCases/http.json +0 -1206
  253. package/utils/getDeviceTypes.js +0 -7
  254. package/utils/getFormalDeviceType.js +0 -5
  255. package/utils/schema.js +0 -28
@@ -0,0 +1,39 @@
1
+ module.exports = function UpdateTicket(requestData, options = {}) {
2
+ if (!this._init) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => {
5
+ resolve(UpdateTicket.call(this, requestData));
6
+ }, 500);
7
+ });
8
+ }
9
+ if (!requestData)
10
+ requestData = {};
11
+ const pathParams = [":id"];
12
+ const { data, query, headers } = requestData;
13
+ let url = "/tickets/:id";
14
+ if (pathParams && data) {
15
+ for (const param of pathParams) {
16
+ const paramName = param.replace(":", "");
17
+ url = url.replace(param, data[paramName]);
18
+ }
19
+ }
20
+ if (url.match(/:[a-zA-Z0-9]+/g)) {
21
+ const missingParams = url.match(/:[a-zA-Z0-9]+/g);
22
+ const missing = missingParams.map((param) => param.replace(":", ""));
23
+ return Promise.reject(
24
+ new Error("Missing parameters: " + missing.join(", "))
25
+ );
26
+ }
27
+ const config = {
28
+ method: "put",
29
+ url,
30
+ ...options
31
+ };
32
+ if (data)
33
+ config.data = data;
34
+ if (query)
35
+ config.params = query;
36
+ if (headers)
37
+ config.headers = headers;
38
+ return this._http.request(config);
39
+ };
@@ -0,0 +1,39 @@
1
+ module.exports = function UpdateTicketStatus(requestData, options = {}) {
2
+ if (!this._init) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => {
5
+ resolve(UpdateTicketStatus.call(this, requestData));
6
+ }, 500);
7
+ });
8
+ }
9
+ if (!requestData)
10
+ requestData = {};
11
+ const pathParams = [":id"];
12
+ const { data, query, headers } = requestData;
13
+ let url = "/tickets/:id/status";
14
+ if (pathParams && data) {
15
+ for (const param of pathParams) {
16
+ const paramName = param.replace(":", "");
17
+ url = url.replace(param, data[paramName]);
18
+ }
19
+ }
20
+ if (url.match(/:[a-zA-Z0-9]+/g)) {
21
+ const missingParams = url.match(/:[a-zA-Z0-9]+/g);
22
+ const missing = missingParams.map((param) => param.replace(":", ""));
23
+ return Promise.reject(
24
+ new Error("Missing parameters: " + missing.join(", "))
25
+ );
26
+ }
27
+ const config = {
28
+ method: "put",
29
+ url,
30
+ ...options
31
+ };
32
+ if (data)
33
+ config.data = data;
34
+ if (query)
35
+ config.params = query;
36
+ if (headers)
37
+ config.headers = headers;
38
+ return this._http.request(config);
39
+ };
@@ -0,0 +1,39 @@
1
+ module.exports = function UpdateUser(requestData, options = {}) {
2
+ if (!this._init) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => {
5
+ resolve(UpdateUser.call(this, requestData));
6
+ }, 500);
7
+ });
8
+ }
9
+ if (!requestData)
10
+ requestData = {};
11
+ const pathParams = [":id"];
12
+ const { data, query, headers } = requestData;
13
+ let url = "/users/:id";
14
+ if (pathParams && data) {
15
+ for (const param of pathParams) {
16
+ const paramName = param.replace(":", "");
17
+ url = url.replace(param, data[paramName]);
18
+ }
19
+ }
20
+ if (url.match(/:[a-zA-Z0-9]+/g)) {
21
+ const missingParams = url.match(/:[a-zA-Z0-9]+/g);
22
+ const missing = missingParams.map((param) => param.replace(":", ""));
23
+ return Promise.reject(
24
+ new Error("Missing parameters: " + missing.join(", "))
25
+ );
26
+ }
27
+ const config = {
28
+ method: "put",
29
+ url,
30
+ ...options
31
+ };
32
+ if (data)
33
+ config.data = data;
34
+ if (query)
35
+ config.params = query;
36
+ if (headers)
37
+ config.headers = headers;
38
+ return this._http.request(config);
39
+ };
@@ -0,0 +1,39 @@
1
+ module.exports = function UpdateWindowCovering(requestData, options = {}) {
2
+ if (!this._init) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => {
5
+ resolve(UpdateWindowCovering.call(this, requestData));
6
+ }, 500);
7
+ });
8
+ }
9
+ if (!requestData)
10
+ requestData = {};
11
+ const pathParams = [":roomId", ":id"];
12
+ const { data, query, headers } = requestData;
13
+ let url = "/rooms/:roomId/windowCoverings/:id";
14
+ if (pathParams && data) {
15
+ for (const param of pathParams) {
16
+ const paramName = param.replace(":", "");
17
+ url = url.replace(param, data[paramName]);
18
+ }
19
+ }
20
+ if (url.match(/:[a-zA-Z0-9]+/g)) {
21
+ const missingParams = url.match(/:[a-zA-Z0-9]+/g);
22
+ const missing = missingParams.map((param) => param.replace(":", ""));
23
+ return Promise.reject(
24
+ new Error("Missing parameters: " + missing.join(", "))
25
+ );
26
+ }
27
+ const config = {
28
+ method: "put",
29
+ url,
30
+ ...options
31
+ };
32
+ if (data)
33
+ config.data = data;
34
+ if (query)
35
+ config.params = query;
36
+ if (headers)
37
+ config.headers = headers;
38
+ return this._http.request(config);
39
+ };
@@ -0,0 +1,39 @@
1
+ module.exports = function UpsertDiscoveredDevice(requestData, options = {}) {
2
+ if (!this._init) {
3
+ return new Promise((resolve) => {
4
+ setTimeout(() => {
5
+ resolve(UpsertDiscoveredDevice.call(this, requestData));
6
+ }, 500);
7
+ });
8
+ }
9
+ if (!requestData)
10
+ requestData = {};
11
+ const pathParams = null;
12
+ const { data, query, headers } = requestData;
13
+ let url = "/discoveredDevices/upsert";
14
+ if (pathParams && data) {
15
+ for (const param of pathParams) {
16
+ const paramName = param.replace(":", "");
17
+ url = url.replace(param, data[paramName]);
18
+ }
19
+ }
20
+ if (url.match(/:[a-zA-Z0-9]+/g)) {
21
+ const missingParams = url.match(/:[a-zA-Z0-9]+/g);
22
+ const missing = missingParams.map((param) => param.replace(":", ""));
23
+ return Promise.reject(
24
+ new Error("Missing parameters: " + missing.join(", "))
25
+ );
26
+ }
27
+ const config = {
28
+ method: "post",
29
+ url,
30
+ ...options
31
+ };
32
+ if (data)
33
+ config.data = data;
34
+ if (query)
35
+ config.params = query;
36
+ if (headers)
37
+ config.headers = headers;
38
+ return this._http.request(config);
39
+ };
package/dist/utils.js ADDED
@@ -0,0 +1,53 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+
6
+ // src/utils/getFormalDeviceType.js
7
+ var require_getFormalDeviceType = __commonJS({
8
+ "src/utils/getFormalDeviceType.js"(exports2, module2) {
9
+ function getFormalDeviceType2(deviceType) {
10
+ return deviceType.charAt(0).toUpperCase() + deviceType.slice(1);
11
+ }
12
+ module2.exports = getFormalDeviceType2;
13
+ }
14
+ });
15
+
16
+ // src/defs/deviceTypes.js
17
+ var require_deviceTypes = __commonJS({
18
+ "src/defs/deviceTypes.js"(exports2, module2) {
19
+ var types = [
20
+ "dimmer",
21
+ "switch",
22
+ "thermostat",
23
+ "lock",
24
+ "windowCovering",
25
+ "sceneController",
26
+ "courtesy",
27
+ "alarm",
28
+ "camera",
29
+ "source",
30
+ "motionSensor"
31
+ ];
32
+ module2.exports = types;
33
+ }
34
+ });
35
+
36
+ // src/utils/getDeviceTypes.js
37
+ var require_getDeviceTypes = __commonJS({
38
+ "src/utils/getDeviceTypes.js"(exports2, module2) {
39
+ var deviceTypes = require_deviceTypes();
40
+ function getDeviceTypes2() {
41
+ return deviceTypes;
42
+ }
43
+ module2.exports = getDeviceTypes2;
44
+ }
45
+ });
46
+
47
+ // src/utils/index.js
48
+ var getFormalDeviceType = require_getFormalDeviceType();
49
+ var getDeviceTypes = require_getDeviceTypes();
50
+ module.exports = {
51
+ getFormalDeviceType,
52
+ getDeviceTypes
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kohost/api-client",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.4",
4
4
  "description": "API client for Kohost utils",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -9,12 +9,18 @@
9
9
  "test:watch": "jest --watchAll",
10
10
  "lint": "eslint ./",
11
11
  "lint:fix": "eslint --fix ./",
12
- "prepare": "node prepare.js"
12
+ "prepare": "node prepare.js",
13
+ "build": "node scripts/build.js",
14
+ "clean": "rm -rf ./dist"
13
15
  },
16
+ "files": [
17
+ "dist"
18
+ ],
14
19
  "author": "Ian Rogers",
15
20
  "license": "ISC",
16
21
  "devDependencies": {
17
22
  "@kohost/eslint-config": "^1.0.0",
23
+ "esbuild": "^0.17.2",
18
24
  "eslint": "^8.6.0",
19
25
  "eslint-plugin-jest": "^27.1.3",
20
26
  "husky": "^8.0.1",
package/.eslintrc.js DELETED
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- env: {
3
- "jest/globals": true,
4
- },
5
- plugins: ["jest"],
6
- extends: ["@kohost"],
7
- parserOptions: {
8
- ecmaVersion: 2020,
9
- },
10
- };
@@ -1,65 +0,0 @@
1
- image: node:16.17.1
2
-
3
- pipelines:
4
- custom:
5
- publish-use-cases:
6
- - step:
7
- image: amazon/aws-cli
8
- name: Fetch use cases
9
- script:
10
- ## fetch use cases from s3
11
- - aws s3 cp s3://cloud-v3-data/useCases/useCases-${USE_CASE_HASH}.json ./useCases/http.json
12
- - npm install
13
- - npm version prerelease --preid=beta -m "Upgrade to %s [skip ci]"
14
- - git push && git push --tags
15
- - pipe: atlassian/npm-publish:0.3.2
16
- variables:
17
- NPM_TOKEN: $NPM_TOKEN
18
- EXTRA_ARGS: --tag next-v1
19
-
20
- pull-requests:
21
- "**":
22
- - step:
23
- name: Install dependencies and build
24
- caches:
25
- - node
26
- script:
27
- - npm ci
28
- branches:
29
- master:
30
- - step:
31
- name: Build and publish to NPM
32
- caches:
33
- - node
34
- script:
35
- - npm ci
36
- - pipe: atlassian/npm-publish:0.3.2
37
- variables:
38
- NPM_TOKEN: $NPM_TOKEN
39
- dev:
40
- - step:
41
- name: Build and publish to NPM
42
- caches:
43
- - node
44
- script:
45
- - npm ci
46
- - npm version prerelease --preid=beta -m "Upgrade to %s [skip ci]"
47
- - git push && git push --tags
48
- - pipe: atlassian/npm-publish:0.3.2
49
- variables:
50
- NPM_TOKEN: $NPM_TOKEN
51
- EXTRA_ARGS: --tag next
52
-
53
- v1:
54
- - step:
55
- name: Build and publish to NPM
56
- caches:
57
- - node
58
- script:
59
- - npm ci
60
- - npm version prerelease --preid=beta -m "Upgrade to %s [skip ci]"
61
- - git push && git push --tags
62
- - pipe: atlassian/npm-publish:0.3.2
63
- variables:
64
- NPM_TOKEN: $NPM_TOKEN
65
- EXTRA_ARGS: --tag next-v1
@@ -1,23 +0,0 @@
1
- const Command = require("./Command");
2
- const RequestError = require("../errors/RequestError");
3
-
4
- class CheckInReservationCommand extends Command {
5
- constructor({ id }) {
6
- if (!id) throw new RequestError("document type is required");
7
- super({ id });
8
- }
9
-
10
- get name() {
11
- return "CheckInReservation";
12
- }
13
-
14
- get routingKey() {
15
- return `reservation.${this.data.id}.checkin`;
16
- }
17
-
18
- get replyTo() {
19
- return "system.response.reservations";
20
- }
21
- }
22
-
23
- module.exports = CheckInReservationCommand;
@@ -1,38 +0,0 @@
1
- class Command {
2
- constructor(data) {
3
- this.data = {};
4
- if (!data) throw new Error("Command data is required");
5
- if (typeof data !== "object")
6
- throw new Error("Command data must be an object");
7
-
8
- for (const key in data) {
9
- this.data[key] = data[key];
10
- }
11
- }
12
-
13
- get name() {
14
- throw new Error("Command name is required");
15
- }
16
-
17
- get type() {
18
- return "Command";
19
- }
20
-
21
- get routingKey() {
22
- return "";
23
- }
24
-
25
- get exchange() {
26
- return "Commands";
27
- }
28
-
29
- get replyTo() {
30
- return "amq.rabbitmq.reply-to";
31
- }
32
-
33
- build() {
34
- return { data: { ...this.data } };
35
- }
36
- }
37
-
38
- module.exports = Command;
@@ -1,24 +0,0 @@
1
- const { RequestError } = require("../errors");
2
- const Command = require("./Command");
3
-
4
- class DiscoverReservationsCommand extends Command {
5
- constructor(options) {
6
- if (!options) throw new RequestError("options are required");
7
- const { id, startDate, endDate, status } = options;
8
- super({ id, startDate, endDate, status });
9
- }
10
-
11
- get name() {
12
- return "DiscoverReservations";
13
- }
14
-
15
- get routingKey() {
16
- return "reservation.discover";
17
- }
18
-
19
- get replyTo() {
20
- return "system.response.reservations";
21
- }
22
- }
23
-
24
- module.exports = DiscoverReservationsCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class DiscoverRoomsCommand extends Command {
4
- constructor({ id }) {
5
- super({ id });
6
- }
7
-
8
- get name() {
9
- return "DiscoverRooms";
10
- }
11
-
12
- get routingKey() {
13
- return `rooms.${this.data.id}.get`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.users";
18
- }
19
- }
20
-
21
- module.exports = DiscoverRoomsCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class DiscoverUsersCommand extends Command {
4
- constructor({ id }) {
5
- super({ id });
6
- }
7
-
8
- get name() {
9
- return "DiscoverUsers";
10
- }
11
-
12
- get routingKey() {
13
- return `users.${this.data.id}.get`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.users";
18
- }
19
- }
20
-
21
- module.exports = DiscoverUsersCommand;
@@ -1,20 +0,0 @@
1
- const Command = require("./Command");
2
- const RequestError = require("../errors/RequestError");
3
-
4
- class OCRDocumentCommand extends Command {
5
- constructor({ type, image }) {
6
- if (!type) throw new RequestError("document type is required");
7
- if (!image) throw new RequestError("document image is required");
8
- super({ type, image });
9
- }
10
-
11
- get name() {
12
- return "OCRDocument";
13
- }
14
-
15
- get routingKey() {
16
- return `document.${this.data.type}.ocr`;
17
- }
18
- }
19
-
20
- module.exports = OCRDocumentCommand;
@@ -1,24 +0,0 @@
1
- const Command = require("./Command");
2
- const RequestError = require("../errors/RequestError");
3
-
4
- class SendEmailCommand extends Command {
5
- constructor({ text, html, to, from, subject, eventData }) {
6
- if (!to) throw new RequestError("email to is required");
7
- if (!from) throw new RequestError("email from is required");
8
- if (!subject) throw new RequestError("email subject is required");
9
- if (!text && !html)
10
- throw new RequestError("email text or html is required");
11
-
12
- super({ text, html, to, from, subject, eventData });
13
- }
14
-
15
- get name() {
16
- return "SendEmail";
17
- }
18
-
19
- get routingKey() {
20
- return "comm.email.send";
21
- }
22
- }
23
-
24
- module.exports = SendEmailCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
- const RequestError = require("../errors/RequestError");
3
-
4
- class SendSMSCommand extends Command {
5
- constructor({ body, to, from, metaData }) {
6
- if (!body) throw new RequestError("sms body is required");
7
- if (!to) throw new RequestError("sms to is required");
8
- if (!from) throw new RequestError("sms from is required");
9
- super({ body, to, from, metaData });
10
- }
11
-
12
- get name() {
13
- return "SendSMS";
14
- }
15
-
16
- get routingKey() {
17
- return "comm.sms.send";
18
- }
19
- }
20
-
21
- module.exports = SendSMSCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class SetAlarmCommand extends Command {
4
- constructor({ id, zones, areas }) {
5
- super({ id, zones, areas });
6
- }
7
-
8
- get name() {
9
- return "SetAlarm";
10
- }
11
-
12
- get routingKey() {
13
- return `alarm.${this.data.id}.set`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.devices";
18
- }
19
- }
20
-
21
- module.exports = SetAlarmCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class SetCourtesyCommand extends Command {
4
- constructor({ id, state }) {
5
- super({ id, state });
6
- }
7
-
8
- get name() {
9
- return "SetCourtesy";
10
- }
11
-
12
- get routingKey() {
13
- return `courtesy.${this.data.id}.set`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.devices";
18
- }
19
- }
20
-
21
- module.exports = SetCourtesyCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class SetDimmerCommand extends Command {
4
- constructor({ id, level }) {
5
- super({ id, level });
6
- }
7
-
8
- get name() {
9
- return "SetDimmer";
10
- }
11
-
12
- get routingKey() {
13
- return `dimmer.${this.data.id}.set`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.devices";
18
- }
19
- }
20
-
21
- module.exports = SetDimmerCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class SetLockCommand extends Command {
4
- constructor({ id, state }) {
5
- super({ id, state });
6
- }
7
-
8
- get name() {
9
- return "SetLock";
10
- }
11
-
12
- get routingKey() {
13
- return `lock.${this.data.id}.set`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.devices";
18
- }
19
- }
20
-
21
- module.exports = SetLockCommand;
@@ -1,21 +0,0 @@
1
- const Command = require("./Command");
2
-
3
- class SetSceneControllerCommand extends Command {
4
- constructor({ id, scene }) {
5
- super({ id, scene });
6
- }
7
-
8
- get name() {
9
- return "SetSceneController";
10
- }
11
-
12
- get routingKey() {
13
- return `sceneController.${this.data.id}.set`;
14
- }
15
-
16
- get replyTo() {
17
- return "system.response.devices";
18
- }
19
- }
20
-
21
- module.exports = SetSceneControllerCommand;