@kohost/api-client 1.0.0-beta.5 → 3.0.0-beta.100
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.
- package/README.md +71 -0
- package/dist/cjs/AMQPClient/index.js +296 -0
- package/dist/cjs/{Client.js → Client/index.js} +2729 -1137
- package/dist/cjs/Commands/CheckInReservationCommand.js +19 -0
- package/dist/cjs/Commands/CheckOutReservationCommand.js +20 -0
- package/dist/cjs/Commands/Command.js +34 -0
- package/dist/cjs/Commands/CreateImageUploadEndpointCommand.js +17 -0
- package/dist/cjs/Commands/CreateShortLinkCommand.js +20 -0
- package/dist/cjs/Commands/DiscoverCategoriesCommand.js +20 -0
- package/dist/cjs/Commands/DiscoverReservationSpaceCategoryAvailabilitiesCommand.js +20 -0
- package/dist/cjs/Commands/DiscoverReservationsCommand.js +20 -0
- package/dist/cjs/Commands/DiscoverRoomsCommand.js +37 -0
- package/dist/cjs/Commands/DiscoverUsersCommand.js +19 -0
- package/dist/cjs/Commands/GetMobileKeyCommand.js +24 -0
- package/dist/cjs/Commands/GetProductsCommand.js +17 -0
- package/dist/cjs/Commands/OCRDocumentCommand.js +15 -0
- package/dist/cjs/Commands/SellProductsCommand.js +17 -0
- package/dist/cjs/Commands/SendEmailCommand.js +24 -0
- package/dist/cjs/Commands/SendSMSCommand.js +22 -0
- package/dist/cjs/Commands/SetAlarmCommand.js +17 -0
- package/dist/cjs/Commands/SetCourtesyCommand.js +17 -0
- package/dist/cjs/Commands/SetDimmerCommand.js +17 -0
- package/dist/cjs/Commands/SetLockCommand.js +17 -0
- package/dist/cjs/Commands/SetMediaCommand.js +17 -0
- package/dist/cjs/Commands/SetSceneCommand.js +17 -0
- package/dist/cjs/Commands/SetSwitchCommand.js +17 -0
- package/dist/cjs/Commands/SetThermostatCommand.js +17 -0
- package/dist/cjs/Commands/SetWindowCoveringCommand.js +17 -0
- package/dist/cjs/Commands/UpdateReservationCommand.js +19 -0
- package/dist/cjs/Commands/UpdateUserCommand.js +41 -0
- package/dist/cjs/Commands/UploadImageCommand.js +17 -0
- package/dist/cjs/Commands/index.js +57 -0
- package/dist/cjs/Errors/AppError.js +8 -0
- package/dist/cjs/Errors/AuthenticationError.js +9 -0
- package/dist/cjs/Errors/AuthorizationError.js +9 -0
- package/dist/cjs/Errors/ConflictError.js +9 -0
- package/dist/cjs/Errors/DeviceCommError.js +9 -0
- package/dist/cjs/Errors/LoginError.js +9 -0
- package/dist/cjs/Errors/NotFoundError.js +9 -0
- package/dist/cjs/Errors/RequestError.js +9 -0
- package/dist/cjs/Errors/SystemCommError.js +9 -0
- package/dist/cjs/Errors/TokenExpiredError.js +9 -0
- package/dist/cjs/Errors/UnprocessableRequestError.js +9 -0
- package/dist/cjs/Errors/ValidationError.js +9 -0
- package/dist/cjs/Errors/index.js +16 -0
- package/dist/cjs/Events/ApplicationInUseEvent.js +25 -0
- package/dist/cjs/Events/ApplicationOutOfUseEvent.js +25 -0
- package/dist/cjs/Events/EmailEvent.js +18 -0
- package/dist/cjs/Events/Event.js +55 -0
- package/dist/cjs/Events/SMSEvent.js +18 -0
- package/dist/cjs/Events/SMSSentEvent.js +17 -0
- package/dist/cjs/Events/SceneSetEvent.js +17 -0
- package/dist/cjs/Events/ShortLinkCreatedEvent.js +17 -0
- package/dist/cjs/Events/SystemAlarmUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemCameraUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemCategoryUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemCourtesyUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemCredentialUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemDimmerUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemEntityDeletedEvent.js +17 -0
- package/dist/cjs/Events/SystemGatewayUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemLockUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemMediaSourceUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemMotionSensorUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemOrganizationUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemProductUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemPropertyUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemReservationUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemSceneControllerUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemSpaceUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemSwitchUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemThermostatUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemUserUpdatedEvent.js +17 -0
- package/dist/cjs/Events/SystemWindowCoveringUpdatedEvent.js +17 -0
- package/dist/cjs/Events/index.js +65 -0
- package/dist/cjs/Models/Alarm.js +35 -0
- package/dist/cjs/Models/Announcement.js +34 -0
- package/dist/cjs/Models/Camera.js +35 -0
- package/dist/cjs/Models/Category.js +36 -0
- package/dist/cjs/Models/Courtesy.js +39 -0
- package/dist/cjs/Models/Credential.js +35 -0
- package/dist/cjs/Models/DeviceRouter.js +36 -0
- package/dist/cjs/Models/Dimmer.js +61 -0
- package/dist/cjs/Models/DiscoveredDevice.js +36 -0
- package/dist/cjs/Models/EmailMessage.js +35 -0
- package/dist/cjs/Models/EnergyReport.js +35 -0
- package/dist/cjs/Models/EnergyReportShard.js +35 -0
- package/dist/cjs/Models/Entity.js +96 -0
- package/dist/cjs/Models/Gateway.js +35 -0
- package/dist/cjs/Models/Identification.js +38 -0
- package/dist/cjs/Models/Lock.js +39 -0
- package/dist/cjs/Models/MediaFile.js +48 -0
- package/dist/cjs/Models/MediaSource.js +35 -0
- package/dist/cjs/Models/MotionSensor.js +35 -0
- package/dist/cjs/Models/Order.js +97 -0
- package/dist/cjs/Models/Organization.js +34 -0
- package/dist/cjs/Models/Product.js +35 -0
- package/dist/cjs/Models/Property.js +34 -0
- package/dist/cjs/Models/Reservation.js +114 -0
- package/dist/cjs/Models/Room.js +217 -0
- package/dist/cjs/Models/Scene.js +169 -0
- package/dist/cjs/Models/ShortLink.js +35 -0
- package/dist/cjs/Models/SmsMessage.js +35 -0
- package/dist/cjs/Models/Space.js +97 -0
- package/dist/cjs/Models/Switch.js +39 -0
- package/dist/cjs/Models/SystemUser.js +55 -0
- package/dist/cjs/Models/Thermostat.js +86 -0
- package/dist/cjs/Models/Ticket.js +55 -0
- package/dist/cjs/Models/User.js +115 -0
- package/dist/cjs/Models/WindowCovering.js +55 -0
- package/dist/cjs/Models/index.js +77 -0
- package/dist/cjs/SocketIoClient/index.js +74 -0
- package/dist/cjs/defs/deviceTypes.js +15 -0
- package/dist/cjs/defs/formalDeviceTypes.js +6 -0
- package/dist/cjs/defs/index.js +11 -0
- package/dist/cjs/{index.cjs.js → index.js} +7 -1
- package/dist/cjs/schemas/AlarmSchema.d.ts +158 -0
- package/dist/cjs/schemas/AnnouncementSchema.d.ts +61 -0
- package/dist/cjs/schemas/CameraSchema.d.ts +149 -0
- package/dist/cjs/schemas/CategorySchema.d.ts +82 -0
- package/dist/cjs/schemas/CourtesySchema.d.ts +148 -0
- package/dist/cjs/schemas/CredentialSchema.d.ts +53 -0
- package/dist/cjs/schemas/DefinitionsSchema.d.ts +10 -0
- package/dist/cjs/schemas/DeviceRouterSchema.d.ts +23 -0
- package/dist/cjs/schemas/DimmerSchema.d.ts +147 -0
- package/dist/cjs/schemas/DiscoveredDeviceSchema.d.ts +43 -0
- package/dist/cjs/schemas/EmailMessageSchema.d.ts +49 -0
- package/dist/cjs/schemas/EnergyReportSchema.d.ts +57 -0
- package/dist/cjs/schemas/EnergyReportShardSchema.d.ts +61 -0
- package/dist/cjs/schemas/GatewaySchema.d.ts +145 -0
- package/dist/cjs/schemas/IdentificationSchema.d.ts +45 -0
- package/dist/cjs/schemas/LockSchema.d.ts +152 -0
- package/dist/cjs/schemas/MediaFileSchema.d.ts +43 -0
- package/dist/cjs/schemas/MediaSourceSchema.d.ts +244 -0
- package/dist/cjs/schemas/MotionSensorSchema.d.ts +143 -0
- package/dist/cjs/schemas/OrderSchema.d.ts +91 -0
- package/dist/cjs/schemas/OrganizationSchema.d.ts +34 -0
- package/dist/cjs/schemas/PaymentSchema.d.ts +33 -0
- package/dist/cjs/schemas/ProductSchema.d.ts +66 -0
- package/dist/cjs/schemas/PropertySchema.d.ts +144 -0
- package/dist/cjs/schemas/ReservationSchema.d.ts +119 -0
- package/dist/cjs/schemas/RoomSchema.d.ts +1103 -0
- package/dist/cjs/schemas/SceneSchema.d.ts +57 -0
- package/dist/cjs/schemas/ShortLinkSchema.d.ts +20 -0
- package/dist/cjs/schemas/SmsMessageSchema.d.ts +40 -0
- package/dist/cjs/schemas/SpaceSchema.d.ts +73 -0
- package/dist/cjs/schemas/SwitchSchema.d.ts +148 -0
- package/dist/cjs/schemas/SystemUserSchema.d.ts +194 -0
- package/dist/cjs/schemas/ThermostatSchema.d.ts +178 -0
- package/dist/cjs/schemas/TicketSchema.d.ts +90 -0
- package/dist/cjs/schemas/UserSchema.d.ts +287 -0
- package/dist/cjs/schemas/WindowCoveringSchema.d.ts +147 -0
- package/dist/cjs/schemas/alarm.json +81 -0
- package/dist/cjs/schemas/announcement.json +47 -0
- package/dist/cjs/schemas/camera.json +50 -0
- package/dist/cjs/schemas/category.json +42 -0
- package/dist/cjs/schemas/courtesy.json +48 -0
- package/dist/cjs/schemas/credential.json +51 -0
- package/dist/cjs/schemas/definitions.json +223 -0
- package/dist/cjs/schemas/deviceRouter.json +28 -0
- package/dist/cjs/schemas/dimmer.json +42 -0
- package/dist/cjs/schemas/discoveredDevice.json +35 -0
- package/dist/cjs/schemas/emailMessage.json +71 -0
- package/dist/cjs/schemas/energyReport.json +86 -0
- package/dist/cjs/schemas/energyReportShard.json +75 -0
- package/dist/cjs/schemas/gateway.json +34 -0
- package/dist/cjs/schemas/identification.json +61 -0
- package/dist/cjs/schemas/lock.json +50 -0
- package/dist/cjs/schemas/mediaFile.json +70 -0
- package/dist/cjs/schemas/mediaSource.json +187 -0
- package/dist/cjs/schemas/motionSensor.json +32 -0
- package/dist/cjs/schemas/order.json +182 -0
- package/dist/cjs/schemas/organization.json +40 -0
- package/dist/cjs/schemas/payment.json +47 -0
- package/dist/cjs/schemas/product.json +41 -0
- package/dist/cjs/schemas/property.json +347 -0
- package/dist/cjs/schemas/reservation.json +137 -0
- package/dist/cjs/schemas/room.json +98 -0
- package/dist/cjs/schemas/scene.json +121 -0
- package/dist/cjs/schemas/shortLink.json +30 -0
- package/dist/cjs/schemas/smsMessage.json +61 -0
- package/dist/cjs/schemas/space.json +129 -0
- package/dist/cjs/schemas/switch.json +44 -0
- package/dist/cjs/schemas/systemUser.json +98 -0
- package/dist/cjs/schemas/thermostat.json +150 -0
- package/dist/cjs/schemas/ticket.json +181 -0
- package/dist/cjs/schemas/user.json +170 -0
- package/dist/cjs/schemas/windowCovering.json +42 -0
- package/dist/cjs/utils/errorFactory.js +8 -0
- package/dist/cjs/utils/eventFactory.js +10 -0
- package/dist/cjs/utils/getDeviceTypes.js +7 -0
- package/dist/cjs/utils/getFormalDeviceType.js +5 -0
- package/dist/cjs/utils/index.js +11 -0
- package/dist/cjs/utils/schema.js +25 -0
- package/dist/esm/Client.js +3112 -1369
- package/dist/esm/Client.js.map +4 -4
- package/dist/esm/Commands.js +551 -97
- package/dist/esm/Commands.js.map +3 -3
- package/dist/esm/Errors.js +53 -0
- package/dist/esm/Errors.js.map +3 -3
- package/dist/esm/Events.js +425 -64
- package/dist/esm/Events.js.map +3 -3
- package/dist/esm/Models.js +3737 -3621
- package/dist/esm/Models.js.map +4 -4
- package/dist/esm/SocketIoClient.js +4846 -0
- package/dist/esm/SocketIoClient.js.map +7 -0
- package/dist/esm/defs.js +444 -301
- package/dist/esm/defs.js.map +4 -4
- package/dist/esm/index.js +18 -11
- package/dist/esm/utils.js +804 -87
- package/dist/esm/utils.js.map +3 -3
- package/dist/useCases/AddDefaultScenesToRooms.js +2 -2
- package/dist/useCases/AddScenesToRoom.js +2 -2
- package/dist/useCases/AdminUpdateCustomer.js +32 -0
- package/dist/useCases/AssignSpaceToReservation.js +32 -0
- package/dist/useCases/BatchNotifyCheckIn.js +32 -0
- package/dist/useCases/BatchNotifyCheckOut.js +32 -0
- package/dist/useCases/BatchNotifyMissedCheckOut.js +32 -0
- package/dist/useCases/BatchNotifyPreArrival.js +2 -2
- package/dist/useCases/CheckInReservation.js +2 -2
- package/dist/useCases/CheckOutReservation.js +32 -0
- package/dist/useCases/CheckVerificationCode.js +2 -2
- package/dist/useCases/CreateAlarm.js +2 -2
- package/dist/useCases/{LoginGateway.js → CreateAnnouncement.js} +3 -3
- package/dist/useCases/CreateCamera.js +2 -2
- package/dist/useCases/{AdminCreateProperty.js → CreateCateory.js} +3 -3
- package/dist/useCases/CreateCourtesy.js +2 -2
- package/dist/useCases/CreateDefaultScenes.js +2 -2
- package/dist/useCases/CreateDimmer.js +2 -2
- package/dist/useCases/CreateDiscoveredDevice.js +2 -2
- package/dist/useCases/CreateDiscoveredDeviceAssociation.js +2 -2
- package/dist/useCases/CreateImageUploadEndpoint.js +32 -0
- package/dist/useCases/CreateLock.js +2 -2
- package/dist/useCases/{CreateSource.js → CreateMediaSource.js} +3 -3
- package/dist/useCases/CreateOrganization.js +32 -0
- package/dist/useCases/{CreateIntegration.js → CreateProperty.js} +3 -3
- package/dist/useCases/CreateReservation.js +2 -2
- package/dist/useCases/CreateRoom.js +2 -2
- package/dist/useCases/CreateRoomInSpace.js +2 -2
- package/dist/useCases/CreateSpace.js +2 -2
- package/dist/useCases/CreateSwitch.js +2 -2
- package/dist/useCases/CreateThermostat.js +2 -2
- package/dist/useCases/CreateTicket.js +2 -2
- package/dist/useCases/CreateTicketMessage.js +2 -2
- package/dist/useCases/CreateUser.js +2 -2
- package/dist/useCases/CreateWindowCovering.js +2 -2
- package/dist/useCases/DeleteAlarm.js +2 -2
- package/dist/useCases/DeleteAnnouncement.js +32 -0
- package/dist/useCases/DeleteCamera.js +2 -2
- package/dist/useCases/DeleteCategory.js +32 -0
- package/dist/useCases/DeleteCourtesy.js +2 -2
- package/dist/useCases/DeleteDimmer.js +2 -2
- package/dist/useCases/DeleteDiscoveredDevice.js +2 -2
- package/dist/useCases/DeleteLock.js +2 -2
- package/dist/useCases/DeleteMediaFile.js +32 -0
- package/dist/useCases/{DeleteSource.js → DeleteMediaSource.js} +3 -3
- package/dist/useCases/DeleteReservation.js +2 -2
- package/dist/useCases/DeleteRoom.js +2 -2
- package/dist/useCases/DeleteSpace.js +2 -2
- package/dist/useCases/DeleteSwitch.js +2 -2
- package/dist/useCases/DeleteThermostat.js +2 -2
- package/dist/useCases/DeleteTicket.js +2 -2
- package/dist/useCases/DeleteUser.js +2 -2
- package/dist/useCases/DeleteWindowCovering.js +2 -2
- package/dist/useCases/DescribeAlarm.js +2 -2
- package/dist/useCases/DescribeAnnouncement.js +32 -0
- package/dist/useCases/DescribeCamera.js +2 -2
- package/dist/useCases/{AdminDescribeProperty.js → DescribeCategory.js} +3 -3
- package/dist/useCases/DescribeCourtesy.js +2 -2
- package/dist/useCases/DescribeDimmer.js +2 -2
- package/dist/useCases/DescribeDiscoveredDevice.js +2 -2
- package/dist/useCases/DescribeLock.js +2 -2
- package/dist/useCases/DescribeLockCredential.js +32 -0
- package/dist/useCases/{DescribeSource.js → DescribeMediaSource.js} +3 -3
- package/dist/useCases/DescribeMyAccessCredentials.js +32 -0
- package/dist/useCases/DescribeMyProperty.js +2 -2
- package/dist/useCases/DescribeOrganization.js +32 -0
- package/dist/useCases/{DescribeIntegration.js → DescribeProduct.js} +3 -3
- package/dist/useCases/{DescribeReservationCheckinStatus.js → DescribeProperty.js} +3 -3
- package/dist/useCases/DescribeReservation.js +2 -2
- package/dist/useCases/DescribeReservationEarlyCheckInProducts.js +32 -0
- package/dist/useCases/DescribeReservationLateCheckOutProducts.js +32 -0
- package/dist/useCases/DescribeReservationRoomUpgrades.js +32 -0
- package/dist/useCases/DescribeRoom.js +2 -2
- package/dist/useCases/DescribeSelf.js +2 -2
- package/dist/useCases/DescribeSpace.js +2 -2
- package/dist/useCases/DescribeSwitch.js +2 -2
- package/dist/useCases/DescribeThermostat.js +2 -2
- package/dist/useCases/DescribeTicket.js +2 -2
- package/dist/useCases/DescribeUser.js +2 -2
- package/dist/useCases/DescribeWindowCovering.js +2 -2
- package/dist/useCases/DiscoverReservations.js +2 -2
- package/dist/useCases/EmailUserAccountSetup.js +2 -2
- package/dist/useCases/ListAlarms.js +2 -2
- package/dist/useCases/ListAnnouncements.js +32 -0
- package/dist/useCases/ListCameras.js +2 -2
- package/dist/useCases/ListCategories.js +32 -0
- package/dist/useCases/ListCourtesy.js +2 -2
- package/dist/useCases/ListDimmers.js +2 -2
- package/dist/useCases/ListDiscoveredDevices.js +2 -2
- package/dist/useCases/ListLocks.js +2 -2
- package/dist/useCases/{ListSources.js → ListMediaSources.js} +3 -3
- package/dist/useCases/ListMyOrders.js +32 -0
- package/dist/useCases/ListMyReservations.js +2 -2
- package/dist/useCases/ListMySpaces.js +2 -2
- package/dist/useCases/ListMyTickets.js +32 -0
- package/dist/useCases/{AdminListCustomers.js → ListOrders.js} +3 -3
- package/dist/useCases/ListOrganizations.js +32 -0
- package/dist/useCases/ListProperties.js +32 -0
- package/dist/useCases/ListReservations.js +2 -2
- package/dist/useCases/ListRooms.js +2 -2
- package/dist/useCases/ListRoomsInSpace.js +2 -2
- package/dist/useCases/{AdminListProperties.js → ListScenes.js} +3 -3
- package/dist/useCases/ListSpaces.js +2 -2
- package/dist/useCases/ListSwitches.js +2 -2
- package/dist/useCases/{ListIntegrations.js → ListTeam.js} +3 -3
- package/dist/useCases/ListThermostats.js +2 -2
- package/dist/useCases/ListTickets.js +2 -2
- package/dist/useCases/{DeleteIntegration.js → ListUserOrders.js} +3 -3
- package/dist/useCases/ListUserReservations.js +2 -2
- package/dist/useCases/ListUserSpaces.js +32 -0
- package/dist/useCases/ListUsers.js +2 -2
- package/dist/useCases/ListWindowCoverings.js +2 -2
- package/dist/useCases/LoginUser.js +2 -2
- package/dist/useCases/LogoutUser.js +32 -0
- package/dist/useCases/MatchUserIdentification.js +2 -2
- package/dist/useCases/OCRDocument.js +2 -2
- package/dist/useCases/PurchaseReservationEarlyCheckInProducts.js +32 -0
- package/dist/useCases/PurchaseReservationLateCheckOutProducts.js +32 -0
- package/dist/useCases/PurchaseReservationRoomUpgrades.js +32 -0
- package/dist/useCases/RefreshToken.js +2 -2
- package/dist/useCases/RequestLoginLink.js +3 -3
- package/dist/useCases/RequestMyKeyToken.js +32 -0
- package/dist/useCases/RequestPWAToken.js +32 -0
- package/dist/useCases/SendCheckInSMS.js +32 -0
- package/dist/useCases/SendCheckOutSMS.js +32 -0
- package/dist/useCases/SendPreArrivalEmail.js +2 -2
- package/dist/useCases/SendPreArrivalSMS.js +2 -2
- package/dist/useCases/SendRoomControlSMS.js +32 -0
- package/dist/useCases/SendVerificationCode.js +2 -2
- package/dist/useCases/SetCamera.js +2 -2
- package/dist/useCases/SetCourtesy.js +2 -2
- package/dist/useCases/{SetSource.js → SetDimmer.js} +3 -3
- package/dist/useCases/SetLock.js +2 -2
- package/dist/useCases/SetMediaSource.js +32 -0
- package/dist/useCases/SetRoomScene.js +32 -0
- package/dist/useCases/SetSpaceScene.js +32 -0
- package/dist/useCases/SetSwitch.js +2 -2
- package/dist/useCases/SetThermostat.js +2 -2
- package/dist/useCases/SetWindowCovering.js +2 -2
- package/dist/useCases/{CreateIntegrationDeviceMapEntry.js → TipUser.js} +3 -3
- package/dist/useCases/UpdateAlarm.js +2 -2
- package/dist/useCases/UpdateAnnouncement.js +32 -0
- package/dist/useCases/UpdateCamera.js +2 -2
- package/dist/useCases/{AdminUpdateProperty.js → UpdateCategory.js} +3 -3
- package/dist/useCases/UpdateCourtesy.js +2 -2
- package/dist/useCases/UpdateDimmer.js +2 -2
- package/dist/useCases/UpdateDiscoveredDevice.js +2 -2
- package/dist/useCases/UpdateLock.js +2 -2
- package/dist/useCases/{UpdateSource.js → UpdateMediaSource.js} +3 -3
- package/dist/useCases/UpdateMessageReadStatus.js +2 -2
- package/dist/useCases/{UpdateIntegration.js → UpdateProperty.js} +3 -3
- package/dist/useCases/UpdateReservation.js +2 -2
- package/dist/useCases/UpdateReservationExpectedArrivalTime.js +32 -0
- package/dist/useCases/UpdateRoom.js +2 -2
- package/dist/useCases/UpdateSelf.js +2 -2
- package/dist/useCases/UpdateSpace.js +2 -2
- package/dist/useCases/UpdateSwitch.js +2 -2
- package/dist/useCases/UpdateThermostat.js +2 -2
- package/dist/useCases/UpdateTicket.js +2 -2
- package/dist/useCases/UpdateTicketStatus.js +2 -2
- package/dist/useCases/UpdateUser.js +2 -2
- package/dist/useCases/UpdateWindowCovering.js +2 -2
- package/dist/useCases/UploadImage.js +32 -0
- package/dist/useCases/UpsertDiscoveredDevice.js +2 -2
- package/package.json +38 -14
- package/dist/cjs/Commands.js +0 -568
- package/dist/cjs/Errors.js +0 -174
- package/dist/cjs/Events.js +0 -375
- package/dist/cjs/Models.js +0 -3584
- package/dist/cjs/defs.js +0 -175
- package/dist/cjs/utils.js +0 -246
package/README.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
[](https://badge.fury.io/js/@kohost%2Fapi-client) [](https://github.com/kohost/api-client/actions/workflows/sync-use-cases.yml)
|
|
2
|
+
|
|
3
|
+
# Kohost API Client
|
|
4
|
+
|
|
5
|
+
Kohost API Client is a Node.js and Browser library for interacting with the Kohost API. It provides a simple and convenient way to access the API, as well as standard models, schemas, commands, and events.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @kohost/api-client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
The library consists of several modules, including:
|
|
16
|
+
|
|
17
|
+
- Models: Defines the models used in the API.
|
|
18
|
+
- Errors: Defines the error objects returned by the API.
|
|
19
|
+
- Commands: Defines the available commands for managing hosting resources.
|
|
20
|
+
- Events: Defines the events emitted by the API.
|
|
21
|
+
- defs: Defines the API endpoint definitions.
|
|
22
|
+
- utils: Contains utility functions.
|
|
23
|
+
- Client: The main http client for interacting with the API
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
import { Client } from "@kohost/api-client";
|
|
27
|
+
|
|
28
|
+
const kohost = new Client({
|
|
29
|
+
url: "https://localhost:8080/v3",
|
|
30
|
+
propertyId: "development",
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Authentication
|
|
35
|
+
|
|
36
|
+
Currently, the only supported mode of Authentication with the API is via an HTTP Only cookie. You can login a user via the following command to get a cookie.
|
|
37
|
+
|
|
38
|
+
### Requesting a Login Token
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
const email = "help@kohost.io";
|
|
42
|
+
|
|
43
|
+
await kohost.RequestLoginLink({
|
|
44
|
+
data: { email },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** OR via Phone **/
|
|
48
|
+
|
|
49
|
+
const phone = "+17025555555";
|
|
50
|
+
|
|
51
|
+
await kohost.RequestLoginLink({
|
|
52
|
+
data: { phone },
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Click the link in the email or SMS to authenticate.
|
|
57
|
+
|
|
58
|
+
### Using a Token
|
|
59
|
+
|
|
60
|
+
Simply use the `LoginUser` use case to provide a user ID via the `sub` parameter, along with the `token` parameter.
|
|
61
|
+
|
|
62
|
+
```javascript
|
|
63
|
+
const sub = "user-id-from-api";
|
|
64
|
+
const token = "token-provided-by-api";
|
|
65
|
+
|
|
66
|
+
await kohost.LoginUser({
|
|
67
|
+
data: { sub, token },
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
A successful response will set an HTTP only cookie in the browser.
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
const Errors = require("../Errors");
|
|
2
|
+
const amqp = require("amqplib");
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const isFatalError = require("amqplib/lib/connection").isFatalError;
|
|
5
|
+
const debug = require("debug")("kohost:amqp-client");
|
|
6
|
+
|
|
7
|
+
const HEADER_KEY_ORGANIZATION_ID = "X-Organization-Id";
|
|
8
|
+
const HEADER_KEY_PROPERTY_ID = "X-Property-Id";
|
|
9
|
+
const HEADER_KEY_DRIVER = "X-Driver";
|
|
10
|
+
const HEADER_KEY_COMMAND_NAME = "X-Command-Name";
|
|
11
|
+
const HEADER_KEY_EVENT_NAME = "X-Event-Name";
|
|
12
|
+
|
|
13
|
+
const exchanges = {
|
|
14
|
+
// routes commands based on `command-name` header and in many cases `property-id` header
|
|
15
|
+
Commands: {
|
|
16
|
+
name: "kohost.commands",
|
|
17
|
+
type: "headers",
|
|
18
|
+
options: {
|
|
19
|
+
durable: true,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
// routes events based on routing keys
|
|
23
|
+
DriverEvents: {
|
|
24
|
+
name: "kohost.events.drivers",
|
|
25
|
+
type: "topic",
|
|
26
|
+
options: {
|
|
27
|
+
durable: true,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
AppEvents: {
|
|
31
|
+
name: "kohost.events.app",
|
|
32
|
+
type: "topic",
|
|
33
|
+
options: {
|
|
34
|
+
durable: true,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
Direct: {
|
|
38
|
+
name: "kohost.direct",
|
|
39
|
+
type: "direct",
|
|
40
|
+
options: {
|
|
41
|
+
durable: true,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
Replies: {
|
|
45
|
+
name: "kohost.replies",
|
|
46
|
+
type: "topic",
|
|
47
|
+
options: {
|
|
48
|
+
durable: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
// dead letter exchange
|
|
52
|
+
dlx: {
|
|
53
|
+
name: "kohost.dlx",
|
|
54
|
+
type: "direct",
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
class KohostAMQPClient {
|
|
59
|
+
static get Message() {
|
|
60
|
+
return Message;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static get exchanges() {
|
|
64
|
+
return exchanges;
|
|
65
|
+
}
|
|
66
|
+
static generateCorrelationId() {
|
|
67
|
+
return crypto.randomUUID();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static validateMessage(message) {
|
|
71
|
+
if (!message) throw new Error("Message is required");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
static parseError(err) {
|
|
75
|
+
let type;
|
|
76
|
+
let message;
|
|
77
|
+
let options = {};
|
|
78
|
+
if (err.message && err.type) {
|
|
79
|
+
const { message: errMessage, type: errType, ...rest } = err;
|
|
80
|
+
type = errType;
|
|
81
|
+
message = errMessage;
|
|
82
|
+
options = rest;
|
|
83
|
+
} else {
|
|
84
|
+
message = "Unknown Error";
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
debug("parseError", type, message, options);
|
|
88
|
+
|
|
89
|
+
switch (type) {
|
|
90
|
+
case "RequestError":
|
|
91
|
+
return new Errors.RequestError(message, options);
|
|
92
|
+
|
|
93
|
+
case "AuthenticationError":
|
|
94
|
+
return new Errors.AuthenticationError(message, options);
|
|
95
|
+
|
|
96
|
+
case "ValidationError":
|
|
97
|
+
return new Errors.ValidationError(message, options);
|
|
98
|
+
|
|
99
|
+
case "NotFoundError":
|
|
100
|
+
return new Errors.NotFoundError(message, options);
|
|
101
|
+
|
|
102
|
+
case "UnprocessableRequestError":
|
|
103
|
+
return new Errors.UnprocessableRequestError(message, options);
|
|
104
|
+
|
|
105
|
+
default:
|
|
106
|
+
return new Error(message, options);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
static parseMessage(message) {
|
|
111
|
+
let error = null;
|
|
112
|
+
let data = {};
|
|
113
|
+
let query = {};
|
|
114
|
+
let context = {};
|
|
115
|
+
let headers = {};
|
|
116
|
+
|
|
117
|
+
const isCommand = message?.properties?.type === "Command";
|
|
118
|
+
const isEvent = message?.properties?.type === "Event";
|
|
119
|
+
|
|
120
|
+
const messageHeaders = message?.properties?.headers || {};
|
|
121
|
+
|
|
122
|
+
const commandName = messageHeaders[HEADER_KEY_COMMAND_NAME] || null;
|
|
123
|
+
const eventName = messageHeaders[HEADER_KEY_EVENT_NAME] || null;
|
|
124
|
+
|
|
125
|
+
if (message.content) {
|
|
126
|
+
try {
|
|
127
|
+
const payload =
|
|
128
|
+
message.properties?.contentType === "application/json"
|
|
129
|
+
? JSON.parse(message.content.toString())
|
|
130
|
+
: message.content.toString();
|
|
131
|
+
data = payload?.data || {};
|
|
132
|
+
error = payload?.error;
|
|
133
|
+
query = payload?.query || {};
|
|
134
|
+
context = payload?.context || {};
|
|
135
|
+
} catch (error) {
|
|
136
|
+
data = message.content.toString();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (message?.properties?.headers) {
|
|
141
|
+
const orgHeader = message.properties.headers[HEADER_KEY_ORGANIZATION_ID];
|
|
142
|
+
const propertyHeader = message.properties.headers[HEADER_KEY_PROPERTY_ID];
|
|
143
|
+
const driverHeader = message.properties.headers[HEADER_KEY_DRIVER];
|
|
144
|
+
|
|
145
|
+
if (orgHeader) {
|
|
146
|
+
context.organizationId = orgHeader;
|
|
147
|
+
headers[HEADER_KEY_ORGANIZATION_ID] = orgHeader;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (propertyHeader) {
|
|
151
|
+
context.propertyId = propertyHeader;
|
|
152
|
+
headers[HEADER_KEY_PROPERTY_ID] = propertyHeader;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (driverHeader) {
|
|
156
|
+
context.driver = driverHeader;
|
|
157
|
+
headers[HEADER_KEY_DRIVER] = driverHeader;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const parsed = {};
|
|
162
|
+
|
|
163
|
+
if (error) parsed.error = this.parseError(error);
|
|
164
|
+
|
|
165
|
+
parsed.data = data;
|
|
166
|
+
parsed.query = query;
|
|
167
|
+
parsed.context = context;
|
|
168
|
+
parsed.headers = headers;
|
|
169
|
+
|
|
170
|
+
if (isEvent && eventName) parsed.event = eventName;
|
|
171
|
+
else if (isCommand && commandName) parsed.command = commandName;
|
|
172
|
+
|
|
173
|
+
debug("amqp parsed %o", parsed);
|
|
174
|
+
|
|
175
|
+
return parsed;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static getMessage(message) {
|
|
179
|
+
if (!message?.content) return null;
|
|
180
|
+
const payload = JSON.parse(message.content.toString());
|
|
181
|
+
const data = payload?.data;
|
|
182
|
+
return data;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
static isFatalError(err) {
|
|
186
|
+
return isFatalError(err);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async createConnection(connection, options = {}) {
|
|
190
|
+
return await amqp.connect(connection, options);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
static createMessage(content) {
|
|
194
|
+
return new Message(content);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
async createChannel(connection) {
|
|
198
|
+
const channel = await connection.createChannel();
|
|
199
|
+
return channel;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async assertExchange(channel, { exchange, type, options }) {
|
|
203
|
+
return await channel.assertExchange(exchange, type, options);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
async assertQueue(channel, { queue, options }) {
|
|
207
|
+
return await channel.assertQueue(queue, options);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
async bindQueue(channel, { queue, exchange, routingKey, args }) {
|
|
211
|
+
return await channel.bindQueue(queue, exchange, routingKey, args);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async bindExchange(channel, { source, destination, routingKey, args }) {
|
|
215
|
+
return await channel.bindExchange(destination, source, routingKey, args);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async subscribeToQueue(channel, { queue, cb, options }) {
|
|
219
|
+
return await channel.consume(queue, cb, options);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
publishToExchange(channel, { exchange, routingKey, content, options }) {
|
|
223
|
+
return channel.publish(exchange, routingKey, content, options);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
class Message {
|
|
228
|
+
constructor(content) {
|
|
229
|
+
this.toExchange = null;
|
|
230
|
+
this.content = content;
|
|
231
|
+
this.options = {
|
|
232
|
+
contentType: "application/json",
|
|
233
|
+
timestamp: Date.now(),
|
|
234
|
+
};
|
|
235
|
+
this.routingKey = "";
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
get correlationId() {
|
|
239
|
+
return this.options.correlationId || null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
to({ exchange }) {
|
|
243
|
+
if (typeof exchange === "undefined")
|
|
244
|
+
throw new Error("Exchange is required");
|
|
245
|
+
this.toExchange = exchange;
|
|
246
|
+
return this;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
withType(type) {
|
|
250
|
+
this.options.type = type;
|
|
251
|
+
return this;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
withRoutingKey(routingKey) {
|
|
255
|
+
this.routingKey = routingKey;
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
withHeaders(headers) {
|
|
260
|
+
if (!this.options.headers) this.options.headers = {};
|
|
261
|
+
this.options.headers = { ...this.options.headers, ...headers };
|
|
262
|
+
return this;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
withContext(context) {
|
|
266
|
+
for (let key in context) {
|
|
267
|
+
this.withHeaders({ [key]: context[key] });
|
|
268
|
+
}
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
withCorrelationId(correlationId) {
|
|
273
|
+
this.options.correlationId = correlationId;
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
withReplyTo(queue) {
|
|
278
|
+
this.options.replyTo = queue;
|
|
279
|
+
return this;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
build() {
|
|
283
|
+
let content = this.content;
|
|
284
|
+
if (content.build && typeof content.build === "function")
|
|
285
|
+
content = content.build();
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
exchange: this.toExchange,
|
|
289
|
+
content: Buffer.from(JSON.stringify(content)),
|
|
290
|
+
options: this.options,
|
|
291
|
+
routingKey: this.routingKey,
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
module.exports = KohostAMQPClient;
|