@spytecgps/nova-orm 0.0.224 → 0.0.226
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/dist/entities/acumaticaAmazonProduct.js +46 -0
- package/dist/entities/acumaticaImeiIccidData.js +91 -0
- package/dist/entities/acumaticaOrderShipmentDetails.js +61 -0
- package/dist/entities/acumaticaShipment.js +31 -0
- package/dist/entities/acumaticaShipmentAmazon.js +26 -0
- package/dist/entities/aempToken.js +47 -0
- package/dist/entities/alert.js +129 -0
- package/dist/entities/alertMigration.js +115 -0
- package/dist/entities/alertMigrationBatch.js +21 -0
- package/dist/entities/alertTimeWindowConfiguration.js +61 -0
- package/dist/entities/alertType.js +83 -0
- package/dist/entities/appFeatureType.js +36 -0
- package/dist/entities/assetCategory.js +32 -0
- package/dist/entities/billing.js +108 -0
- package/dist/entities/billingCustomerBraintree.js +62 -0
- package/dist/entities/billingDeviceHistory.js +61 -0
- package/dist/entities/billingHubspotPaymentLog.js +256 -0
- package/dist/entities/billingKlarnaCustomer.js +76 -0
- package/dist/entities/billingKlarnaOrder.js +114 -0
- package/dist/entities/billingStatusHistoryBraintree.js +63 -0
- package/dist/entities/billingSubscriptionBraintree.js +229 -0
- package/dist/entities/blacklist.js +51 -0
- package/dist/entities/blacklistType.js +31 -0
- package/dist/entities/boundary.js +119 -0
- package/dist/entities/boundaryEvent.js +105 -0
- package/dist/entities/cellTower.js +66 -0
- package/dist/entities/client.js +153 -0
- package/dist/entities/clientAppFeature.js +47 -0
- package/dist/entities/clientConfiguration.js +47 -0
- package/dist/entities/clientDeviceSetting.js +90 -0
- package/dist/entities/clientType.js +36 -0
- package/dist/entities/country.js +90 -0
- package/dist/entities/customerAttribute.js +52 -0
- package/dist/entities/dataSourceType.js +31 -0
- package/dist/entities/deactivation.js +83 -0
- package/dist/entities/deactivationReason.js +40 -0
- package/dist/entities/device.js +160 -0
- package/dist/entities/deviceAlertConfiguration.js +71 -0
- package/dist/entities/deviceBehavior.js +147 -0
- package/dist/entities/deviceCustomConfiguration.js +67 -0
- package/dist/entities/deviceHistory.js +46 -0
- package/dist/entities/deviceModelListener.js +46 -0
- package/dist/entities/devicePairing.js +67 -0
- package/dist/entities/devicePromotion.js +104 -0
- package/dist/entities/deviceReplacement.js +57 -0
- package/dist/entities/deviceTask.js +44 -0
- package/dist/entities/deviceType.js +149 -0
- package/dist/entities/deviceTypeEvent.js +32 -0
- package/dist/entities/deviceTypeFeature.js +32 -0
- package/dist/entities/deviceTypeFirmware.js +117 -0
- package/dist/entities/entityTag.js +48 -0
- package/dist/entities/entityType.js +31 -0
- package/dist/entities/event.js +36 -0
- package/dist/entities/feature.js +36 -0
- package/dist/entities/firmwareAutoUpgradeBlacklist.js +35 -0
- package/dist/entities/firmwareUpgradeTask.js +105 -0
- package/dist/entities/iccidStatus.js +49 -0
- package/dist/entities/imeiIccidCarrier.js +125 -0
- package/dist/entities/imeiIccidHistory.js +43 -0
- package/dist/entities/index.js +99 -0
- package/dist/entities/industry.js +46 -0
- package/dist/entities/latestPosition.js +100 -0
- package/dist/entities/latestPositionMigration.js +96 -0
- package/dist/entities/latestPositionMigrationBatch.js +21 -0
- package/dist/entities/magento2Gps.js +256 -0
- package/dist/entities/magento2Plan.js +41 -0
- package/dist/entities/mobileNetwork.js +51 -0
- package/dist/entities/notificationRecipient.js +100 -0
- package/dist/entities/organization.js +46 -0
- package/dist/entities/plan.js +86 -0
- package/dist/entities/position.js +102 -0
- package/dist/entities/positionMigration.js +96 -0
- package/dist/entities/positionMigrationBatch.js +21 -0
- package/dist/entities/promotion.js +134 -0
- package/dist/entities/securityRole.js +41 -0
- package/dist/entities/serviceProvider.js +41 -0
- package/dist/entities/serviceProviderProduct.js +61 -0
- package/dist/entities/serviceProviderProductNetwork.js +31 -0
- package/dist/entities/serviceProviderProductType.js +31 -0
- package/dist/entities/sim.js +92 -0
- package/dist/entities/task.js +146 -0
- package/dist/entities/taskSchedule.js +141 -0
- package/dist/entities/trip.js +127 -0
- package/dist/entities/tripCompletionStatus.js +36 -0
- package/dist/entities/tripPosition.js +26 -0
- package/dist/entities/user.js +196 -0
- package/dist/entities/userActivation.js +52 -0
- package/dist/entities/userActivationDevice.js +164 -0
- package/dist/entities/userActivationEvent.js +61 -0
- package/dist/entities/userActivationMetric.js +208 -0
- package/dist/entities/userAlertComplain.js +78 -0
- package/dist/entities/userAlertConfiguration.js +109 -0
- package/dist/entities/userAppFeedback.js +52 -0
- package/dist/entities/userAppIncident.js +176 -0
- package/dist/entities/userConfiguration.js +109 -0
- package/dist/entities/userDataDeletionRequest.js +56 -0
- package/dist/entities/userDeviceBehaviorTask.js +80 -0
- package/dist/entities/userInvitation.js +89 -0
- package/dist/entities/userRatingRequest.js +75 -0
- package/dist/entities/userRegistrationAttempt.js +177 -0
- package/dist/entities/userSecurityRole.js +33 -0
- package/dist/index.js +1 -2
- package/dist/migration/1684483704434-addLowerCaseIndex.js +16 -0
- package/dist/novaDataSource.js +111 -0
- package/dist/repositories/acumatica/getAcumaticaImeiIccidData.js +35 -0
- package/dist/repositories/acumatica/getAcumaticaShipmentDetails.js +50 -0
- package/dist/repositories/acumatica/getLastAcumaticaShipmentDetails.js +27 -0
- package/dist/repositories/acumatica/index.js +52 -0
- package/dist/repositories/aempToken/createAempToken.js +26 -0
- package/dist/repositories/aempToken/deleteAempTokens.js +30 -0
- package/dist/repositories/aempToken/getAempTokens.js +27 -0
- package/dist/repositories/aempToken/index.js +53 -0
- package/dist/repositories/alertTypes/getAlertTypes.js +13 -0
- package/dist/repositories/alertTypes/index.js +18 -0
- package/dist/repositories/alerts/createAlert.js +94 -0
- package/dist/repositories/alerts/createUserAlertComplain.js +26 -0
- package/dist/repositories/alerts/getAlertsReportByClient.js +65 -0
- package/dist/repositories/alerts/getAlertsReportByUser.js +127 -0
- package/dist/repositories/alerts/index.js +104 -0
- package/dist/repositories/appFeatures/createAppFeatureType.js +15 -0
- package/dist/repositories/appFeatures/createClientAppFeature.js +15 -0
- package/dist/repositories/appFeatures/getClientAppFeatures.js +39 -0
- package/dist/repositories/appFeatures/index.js +57 -0
- package/dist/repositories/assetCategories/getAssetCategories.js +8 -0
- package/dist/repositories/assetCategories/index.js +16 -0
- package/dist/repositories/baseRepository.js +9 -0
- package/dist/repositories/billing/createBilling.js +37 -0
- package/dist/repositories/billing/createBillingDeviceHistory.js +30 -0
- package/dist/repositories/billing/createBillingHubspotPaymentLog.js +61 -0
- package/dist/repositories/billing/createBillingStatusHistoryBraintree.js +32 -0
- package/dist/repositories/billing/getBillingCustomerBraintreeById.js +18 -0
- package/dist/repositories/billing/getBillingKlarnaOrderByImei.js +18 -0
- package/dist/repositories/billing/getBillingSubscriptionBraintreeByImei.js +18 -0
- package/dist/repositories/billing/getBillingSubscriptionsBraintree.js +25 -0
- package/dist/repositories/billing/getBillings.js +42 -0
- package/dist/repositories/billing/getCanceledImeis.js +84 -0
- package/dist/repositories/billing/getCanceledImeisMatchingMagentoData.js +100 -0
- package/dist/repositories/billing/getChurnStatusByClientId.js +27 -0
- package/dist/repositories/billing/getClientIdFromBraintreeCustomer.js +20 -0
- package/dist/repositories/billing/getMagentoPlan.js +21 -0
- package/dist/repositories/billing/getUserByBraintreeCustomerId.js +22 -0
- package/dist/repositories/billing/index.js +353 -0
- package/dist/repositories/billing/updateBilling.js +43 -0
- package/dist/repositories/billing/updateBillingCustomerBraintree.js +37 -0
- package/dist/repositories/billing/upsertBillingCustomerBraintree.js +39 -0
- package/dist/repositories/billing/upsertBillingKlarnaCustomer.js +52 -0
- package/dist/repositories/billing/upsertBillingKlarnaOrder.js +58 -0
- package/dist/repositories/billing/upsertBillingSubscriptionBraintree.js +20 -0
- package/dist/repositories/blacklist/getBlacklists.js +19 -0
- package/dist/repositories/blacklist/index.js +19 -0
- package/dist/repositories/boundaries/createBoundary.js +52 -0
- package/dist/repositories/boundaries/deleteBoundary.js +23 -0
- package/dist/repositories/boundaries/getBoundariesByClientId.js +17 -0
- package/dist/repositories/boundaries/getBoundariesIdsByClientId.js +19 -0
- package/dist/repositories/boundaries/getBoundariesReport.js +141 -0
- package/dist/repositories/boundaries/getBoundaryById.js +14 -0
- package/dist/repositories/boundaries/index.js +178 -0
- package/dist/repositories/boundaries/processBoundaryEvent.js +211 -0
- package/dist/repositories/boundaries/updateBoundary.js +53 -0
- package/dist/repositories/boundaries/upsertBoundaryEvent.js +23 -0
- package/dist/repositories/clients/createClient.js +35 -0
- package/dist/repositories/clients/createClientConfiguration.js +18 -0
- package/dist/repositories/clients/createCustomerAttribute.js +16 -0
- package/dist/repositories/clients/deleteClientAndConfiguration.js +25 -0
- package/dist/repositories/clients/getClient.js +32 -0
- package/dist/repositories/clients/getClientConfiguration.js +14 -0
- package/dist/repositories/clients/getClients.js +26 -0
- package/dist/repositories/clients/getCustomerAttribute.js +14 -0
- package/dist/repositories/clients/index.js +192 -0
- package/dist/repositories/clients/updateClient.js +52 -0
- package/dist/repositories/clients/updateClientConfiguration.js +31 -0
- package/dist/repositories/clients/updateCustomerAttribute.js +27 -0
- package/dist/repositories/countries/getCountries.js +14 -0
- package/dist/repositories/countries/getCountry.js +23 -0
- package/dist/repositories/countries/index.js +33 -0
- package/dist/repositories/deactivations/createDeactivation.js +16 -0
- package/dist/repositories/deactivations/getDeactivationReasons.js +24 -0
- package/dist/repositories/deactivations/getLatestDeactivationByImei.js +19 -0
- package/dist/repositories/deactivations/index.js +58 -0
- package/dist/repositories/deviceBehaviors/createDeviceBehaviorTask.js +48 -0
- package/dist/repositories/deviceBehaviors/getDeviceBehaviorTasks.js +40 -0
- package/dist/repositories/deviceBehaviors/getDeviceBehaviors.js +41 -0
- package/dist/repositories/deviceBehaviors/getDeviceBehaviorsByIds.js +16 -0
- package/dist/repositories/deviceBehaviors/getDevicesLastBehaviorTask.js +42 -0
- package/dist/repositories/deviceBehaviors/getLatestDeviceBehaviorTasks.js +40 -0
- package/dist/repositories/deviceBehaviors/index.js +147 -0
- package/dist/repositories/deviceBehaviors/updateDeviceBehaviorTask.js +27 -0
- package/dist/repositories/deviceBehaviors/upsertDeviceBehavior.js +20 -0
- package/dist/repositories/devicePairings/createDevicePairing.js +21 -0
- package/dist/repositories/devicePairings/deleteDevicePairing.js +16 -0
- package/dist/repositories/devicePairings/getDevicePairings.js +36 -0
- package/dist/repositories/devicePairings/getDevicePairingsByImei.js +20 -0
- package/dist/repositories/devicePairings/index.js +90 -0
- package/dist/repositories/devicePairings/updateDevicePairing.js +32 -0
- package/dist/repositories/devices/createClientDeviceSetting.js +25 -0
- package/dist/repositories/devices/createDevice.js +30 -0
- package/dist/repositories/devices/createDeviceReplacement.js +34 -0
- package/dist/repositories/devices/createDeviceType.js +15 -0
- package/dist/repositories/devices/deleteDevice.js +16 -0
- package/dist/repositories/devices/generateDeviceIdentifierKey.js +18 -0
- package/dist/repositories/devices/getCanceledDevicesWithActiveSimCards.js +40 -0
- package/dist/repositories/devices/getCarrierStatusUpdatedBefore.js +40 -0
- package/dist/repositories/devices/getClientDeviceSetting.js +20 -0
- package/dist/repositories/devices/getClientDeviceSettings.js +17 -0
- package/dist/repositories/devices/getDevice.js +33 -0
- package/dist/repositories/devices/getDeviceCustomConfig.js +37 -0
- package/dist/repositories/devices/getDeviceTypeByImei.js +18 -0
- package/dist/repositories/devices/getDeviceTypes.js +30 -0
- package/dist/repositories/devices/getDeviceTypesModelsOrderedByDeviceCount.js +27 -0
- package/dist/repositories/devices/getDeviceWithUsersInfo.js +59 -0
- package/dist/repositories/devices/getDevices.js +46 -0
- package/dist/repositories/devices/getFilteredImeisWithStatus.js +20 -0
- package/dist/repositories/devices/getIccidStatus.js +17 -0
- package/dist/repositories/devices/getImeiIccidCarrier.js +23 -0
- package/dist/repositories/devices/getImeiIccidCarriers.js +17 -0
- package/dist/repositories/devices/index.js +464 -0
- package/dist/repositories/devices/updateClientDeviceSetting.js +38 -0
- package/dist/repositories/devices/updateDevice.js +56 -0
- package/dist/repositories/devices/updateDeviceType.js +43 -0
- package/dist/repositories/devices/updateIccidStatus.js +28 -0
- package/dist/repositories/devices/updateImeiIccidCarrier.js +43 -0
- package/dist/repositories/devices/upsertIccidStatus.js +36 -0
- package/dist/repositories/firmwares/createDeviceFirmware.js +37 -0
- package/dist/repositories/firmwares/createFirmwareAutoUpgradeBlacklist.js +16 -0
- package/dist/repositories/firmwares/createFirmwareUpgradeTask.js +36 -0
- package/dist/repositories/firmwares/getDeviceFirmwares.js +21 -0
- package/dist/repositories/firmwares/getFirmwareAutoUpgradeBlacklist.js +23 -0
- package/dist/repositories/firmwares/getFirmwareUpgradeTasks.js +105 -0
- package/dist/repositories/firmwares/getFirmwareUpgradeTasksCount.js +56 -0
- package/dist/repositories/firmwares/index.js +194 -0
- package/dist/repositories/firmwares/updateDeviceFirmware.js +41 -0
- package/dist/repositories/firmwares/updateFirmwareUpgradeTasks.js +37 -0
- package/dist/repositories/index.js +31 -0
- package/dist/repositories/notificationRecipients/createNotificationRecipient.js +37 -0
- package/dist/repositories/notificationRecipients/deleteNotificationRecipients.js +26 -0
- package/dist/repositories/notificationRecipients/deleteNotificationRecipientsByEmailOrPhone.js +28 -0
- package/dist/repositories/notificationRecipients/getNotificationRecipients.js +16 -0
- package/dist/repositories/notificationRecipients/index.js +131 -0
- package/dist/repositories/notificationRecipients/updateNotificationRecipient.js +37 -0
- package/dist/repositories/notificationRecipients/updateUsersNotificationsUnsubscribedInfoStatus.js +98 -0
- package/dist/repositories/notificationRecipients/updateUsersNotificationsUnsuscribedStatus.js +35 -0
- package/dist/repositories/positions/createPosition.js +100 -0
- package/dist/repositories/positions/getLatestPositionByImei.js +26 -0
- package/dist/repositories/positions/getPositionsByImei.js +23 -0
- package/dist/repositories/positions/getPositionsReportByClient.js +87 -0
- package/dist/repositories/positions/index.js +101 -0
- package/dist/repositories/positions/upsertLatestPosition.js +41 -0
- package/dist/repositories/security/createUserRole.js +30 -0
- package/dist/repositories/security/getAllRoles.js +8 -0
- package/dist/repositories/security/getUserRoles.js +15 -0
- package/dist/repositories/security/getUserRolesByClientId.js +17 -0
- package/dist/repositories/security/index.js +111 -0
- package/dist/repositories/security/removeUserRoles.js +21 -0
- package/dist/repositories/security/updateUserRole.js +27 -0
- package/dist/repositories/security/userIsAdminOrOwner.js +20 -0
- package/dist/repositories/security/userIsInRole.js +18 -0
- package/dist/repositories/tasks/addTaskScheduleDevices.js +37 -0
- package/dist/repositories/tasks/completeTask.js +25 -0
- package/dist/repositories/tasks/createTask.js +22 -0
- package/dist/repositories/tasks/createTaskSchedule.js +33 -0
- package/dist/repositories/tasks/deleteTask.js +22 -0
- package/dist/repositories/tasks/deleteTaskSchedule.js +22 -0
- package/dist/repositories/tasks/deleteTaskScheduleDevices.js +17 -0
- package/dist/repositories/tasks/getDeviceTasks.js +28 -0
- package/dist/repositories/tasks/getTaskSchedule.js +31 -0
- package/dist/repositories/tasks/getTaskSchedules.js +75 -0
- package/dist/repositories/tasks/getTaskSchedulesCount.js +23 -0
- package/dist/repositories/tasks/getTasks.js +29 -0
- package/dist/repositories/tasks/getTasksCount.js +20 -0
- package/dist/repositories/tasks/index.js +441 -0
- package/dist/repositories/tasks/setTaskAsPastDue.js +23 -0
- package/dist/repositories/tasks/setTaskScheduleDevices.js +43 -0
- package/dist/repositories/tasks/updateTask.js +21 -0
- package/dist/repositories/tasks/updateTaskSchedule.js +35 -0
- package/dist/repositories/trips/createTrip.js +29 -0
- package/dist/repositories/trips/getTripById.js +15 -0
- package/dist/repositories/trips/getTrips.js +65 -0
- package/dist/repositories/trips/index.js +69 -0
- package/dist/repositories/trips/updateTripEndValues.js +36 -0
- package/dist/repositories/trips/upsertTrip.js +31 -0
- package/dist/repositories/userActivations/createUserActivation.js +26 -0
- package/dist/repositories/userActivations/createUserActivationDevice.js +35 -0
- package/dist/repositories/userActivations/createUserActivationEvent.js +34 -0
- package/dist/repositories/userActivations/createUserActivationMetric.js +28 -0
- package/dist/repositories/userActivations/deleteUserActivation.js +22 -0
- package/dist/repositories/userActivations/getLastActivationDevice.js +26 -0
- package/dist/repositories/userActivations/getUserActivationDevices.js +24 -0
- package/dist/repositories/userActivations/getUserActivationDevicesByClientId.js +26 -0
- package/dist/repositories/userActivations/getUserActivationMetrics.js +24 -0
- package/dist/repositories/userActivations/getUserActivations.js +29 -0
- package/dist/repositories/userActivations/index.js +229 -0
- package/dist/repositories/userActivations/updateUserActivationDevice.js +39 -0
- package/dist/repositories/userActivations/updateUserActivationMetrics.js +61 -0
- package/dist/repositories/userAppFeedback/createUserAppFeedback.js +26 -0
- package/dist/repositories/userAppFeedback/index.js +23 -0
- package/dist/repositories/userAppIncidents/getUserAppIncidents.js +28 -0
- package/dist/repositories/userAppIncidents/index.js +63 -0
- package/dist/repositories/userAppIncidents/upsertUserAppIncident.js +53 -0
- package/dist/repositories/userConfigurations/bulkCreateUserAlertConfigurations.js +46 -0
- package/dist/repositories/userConfigurations/createDeviceAlertTimeWindows.js +36 -0
- package/dist/repositories/userConfigurations/createUserAlertTimeWindows.js +33 -0
- package/dist/repositories/userConfigurations/createUserConfiguration.js +34 -0
- package/dist/repositories/userConfigurations/deleteDeviceAlertTimeWindows.js +17 -0
- package/dist/repositories/userConfigurations/deleteUserAlertConfigurations.js +24 -0
- package/dist/repositories/userConfigurations/deleteUserAlertTimeWindows.js +17 -0
- package/dist/repositories/userConfigurations/deleteUserConfiguration.js +23 -0
- package/dist/repositories/userConfigurations/getDeviceAlertTimeWindows.js +43 -0
- package/dist/repositories/userConfigurations/getUserAlertConfigurations.js +25 -0
- package/dist/repositories/userConfigurations/getUserAlertTimeWindows.js +35 -0
- package/dist/repositories/userConfigurations/getUserConfigurations.js +31 -0
- package/dist/repositories/userConfigurations/index.js +298 -0
- package/dist/repositories/userConfigurations/updateDeviceAlertTimeWindows.js +29 -0
- package/dist/repositories/userConfigurations/updateUserAlertConfigurations.js +46 -0
- package/dist/repositories/userConfigurations/updateUserAlertTimeWindows.js +28 -0
- package/dist/repositories/userConfigurations/updateUserConfiguration.js +49 -0
- package/dist/repositories/userDataDeletionRequests/createUserDataDeletionRequest.js +28 -0
- package/dist/repositories/userDataDeletionRequests/getUserDataDeletionRequest.js +29 -0
- package/dist/repositories/userDataDeletionRequests/index.js +66 -0
- package/dist/repositories/userDataDeletionRequests/removeUserDataDeletionRequest.js +17 -0
- package/dist/repositories/userDataDeletionRequests/updateUserDataDeletionRequest.js +38 -0
- package/dist/repositories/userInvitations/createUserInvitation.js +43 -0
- package/dist/repositories/userInvitations/getUserInvitationById.js +22 -0
- package/dist/repositories/userInvitations/getUserInvitations.js +31 -0
- package/dist/repositories/userInvitations/index.js +82 -0
- package/dist/repositories/userInvitations/updateUserInvitation.js +50 -0
- package/dist/repositories/userRatingRequests/createUserRatingRequest.js +34 -0
- package/dist/repositories/userRatingRequests/getUserRatingRequests.js +23 -0
- package/dist/repositories/userRatingRequests/index.js +41 -0
- package/dist/repositories/userRegistrationAttempts/createUserRegistrationAttempt.js +40 -0
- package/dist/repositories/userRegistrationAttempts/getUserRegistrationAttempts.js +29 -0
- package/dist/repositories/userRegistrationAttempts/index.js +70 -0
- package/dist/repositories/userRegistrationAttempts/updateUserRegistrationAttempt.js +40 -0
- package/dist/repositories/users/createUser.js +47 -0
- package/dist/repositories/users/deleteAccount.js +98 -0
- package/dist/repositories/users/deleteUser.js +22 -0
- package/dist/repositories/users/getUserById.js +22 -0
- package/dist/repositories/users/getUserData.js +66 -0
- package/dist/repositories/users/getUsers.js +49 -0
- package/dist/repositories/users/getUsersConfigurationByImei.js +29 -0
- package/dist/repositories/users/getUsersIdByPhoneAndCountryCode.js +21 -0
- package/dist/repositories/users/getUsersWithRoles.js +32 -0
- package/dist/repositories/users/index.js +195 -0
- package/dist/repositories/users/updateUser.js +109 -0
- package/dist/subscribers/allEntitiesSubscriber.js +52 -0
- package/dist/subscribers/index.js +2 -0
- package/dist/types/acumatica.js +1 -0
- package/dist/types/aempToken.js +1 -0
- package/dist/types/alert.js +1 -0
- package/dist/types/alertTypes.js +1 -0
- package/dist/types/appFeatures.js +1 -0
- package/dist/types/billing.js +1 -0
- package/dist/types/blacklist.js +1 -0
- package/dist/types/boundaries.js +1 -0
- package/dist/types/clients.js +1 -0
- package/dist/types/common.js +1 -0
- package/dist/types/countries.js +1 -0
- package/dist/types/deactivations.js +1 -0
- package/dist/types/deviceBehaviors.js +1 -0
- package/dist/types/devicePairings.js +1 -0
- package/dist/types/devices.js +1 -0
- package/dist/types/enums.js +74 -0
- package/dist/types/firmwares.js +17 -0
- package/dist/types/index.js +30 -0
- package/dist/types/logger.js +9 -0
- package/dist/types/notificationRecipients.js +1 -0
- package/dist/types/position.js +1 -0
- package/dist/types/security.js +1 -0
- package/dist/types/tasks.js +1 -0
- package/dist/types/trip.js +29 -0
- package/dist/types/user.js +1 -0
- package/dist/types/userActivations.js +1 -0
- package/dist/types/userAppFeedback.js +1 -0
- package/dist/types/userAppIncidents.js +1 -0
- package/dist/types/userConfigurations.js +1 -0
- package/dist/types/userDataDeletionRequests.js +1 -0
- package/dist/types/userInvitations.js +1 -0
- package/dist/types/userRatingRequests.js +1 -0
- package/dist/types/userRegistrationAttempts.js +1 -0
- package/dist/utils/anyAttributeHasValue.js +20 -0
- package/dist/utils/anyAttributeIsNull.js +12 -0
- package/dist/utils/boolToNumberTransformer.js +23 -0
- package/dist/utils/consoleLogger.js +42 -0
- package/dist/utils/filterTools.js +299 -0
- package/dist/utils/mapRawEntityToEntity.js +12 -0
- package/dist/utils/queryLogger.js +48 -0
- package/dist/utils/randomizer.js +39 -0
- package/dist/utils/stringToDateTransformer.js +16 -0
- package/dist/utils/uuidHelpers.js +30 -0
- package/package.json +10 -8
- package/dist/index.js.LICENSE.txt +0 -41
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Deactivation } from '../../entities';
|
|
2
|
+
export const createDeactivation = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.imei || !params?.clientId || !params?.createdBy) {
|
|
4
|
+
logger.warn({ params }, 'DeactivationsRepository::createDeactivation - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const deactivationsRepository = dataSource.getRepository(Deactivation);
|
|
9
|
+
const now = new Date();
|
|
10
|
+
const newDeactivation = {
|
|
11
|
+
...params,
|
|
12
|
+
createdAt: now,
|
|
13
|
+
};
|
|
14
|
+
return await deactivationsRepository.save(newDeactivation);
|
|
15
|
+
}, 'DeactivationsRepository::createDeactivation');
|
|
16
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DeactivationReason } from '../../entities';
|
|
2
|
+
export const getDeactivationReasons = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.code && params?.filters?.customerVisible == null) {
|
|
4
|
+
logger.warn({ params }, 'DeactivationsRepository::getDeactivationReasons - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const deactivationReasonsRepository = dataSource.getRepository(DeactivationReason);
|
|
9
|
+
let queryBuilder = deactivationReasonsRepository.createQueryBuilder('deactivationReason');
|
|
10
|
+
if (params.filters.code) {
|
|
11
|
+
queryBuilder = queryBuilder.andWhere('deactivationReason.code = :code', {
|
|
12
|
+
code: params.filters.code,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (params.filters.customerVisible != null) {
|
|
16
|
+
queryBuilder = queryBuilder.andWhere('deactivationReason.customerVisible = :customerVisible', {
|
|
17
|
+
customerVisible: params.filters.customerVisible,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
queryBuilder = queryBuilder.orderBy('deactivationReason.id');
|
|
21
|
+
const result = await queryBuilder.getMany();
|
|
22
|
+
return result;
|
|
23
|
+
}, 'DeactivationsRepository::getDeactivationReasons');
|
|
24
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Deactivation } from '../../entities';
|
|
2
|
+
export const getLatestDeactivationByImei = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.imei) {
|
|
4
|
+
logger.warn({ params }, 'DeactivationsRepository::getLatestDeactivationByImei - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const deactivationsRepository = dataSource.getRepository(Deactivation);
|
|
9
|
+
const queryBuilder = deactivationsRepository
|
|
10
|
+
.createQueryBuilder('deactivation')
|
|
11
|
+
.where('deactivation.imei = :imei', {
|
|
12
|
+
imei: params.filters.imei,
|
|
13
|
+
})
|
|
14
|
+
.orderBy('deactivation.createdAt', 'DESC')
|
|
15
|
+
.limit(1);
|
|
16
|
+
const result = await queryBuilder.getOne();
|
|
17
|
+
return result;
|
|
18
|
+
}, 'DeactivationsRepository::getLatestDeactivationByImei');
|
|
19
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createDeactivation } from './createDeactivation';
|
|
4
|
+
import { getDeactivationReasons } from './getDeactivationReasons';
|
|
5
|
+
import { getLatestDeactivationByImei } from './getLatestDeactivationByImei';
|
|
6
|
+
export class DeactivationsRepository extends BaseRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Get deactivation reasons
|
|
9
|
+
* @param {GetDeactivationReasonsParams} params containing information to get deactivation reasons
|
|
10
|
+
* One of the following filters is required:
|
|
11
|
+
* - filters.code: The code
|
|
12
|
+
* - filters.customerVisible: The customer visible
|
|
13
|
+
* @returns The deactivation reasons list
|
|
14
|
+
*/
|
|
15
|
+
async getDeactivationReasons(params) {
|
|
16
|
+
this.logger.trace(params, 'DeactivationsRepository::getDeactivationReasons started with params');
|
|
17
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
18
|
+
const result = await getDeactivationReasons(novaDataSource, params, this.logger);
|
|
19
|
+
this.logger.trace(result, 'DeactivationsRepository::getDeactivationReasons result');
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get latest deactivation by imei
|
|
24
|
+
* @param {GetLatestDeactivationByImeiParams} params containing information to get latest deactivation by imei
|
|
25
|
+
* - filters.imei: The imei
|
|
26
|
+
* @returns The deactivation
|
|
27
|
+
*/
|
|
28
|
+
async getLatestDeactivationByImei(params) {
|
|
29
|
+
this.logger.trace(params, 'DeactivationsRepository::getLatestDeactivationByImei started with params');
|
|
30
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
31
|
+
const result = await getLatestDeactivationByImei(novaDataSource, params, this.logger);
|
|
32
|
+
this.logger.trace(result, 'DeactivationsRepository::getLatestDeactivationByImei result');
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create deactivation
|
|
37
|
+
* @param {CreateDeactivationParams} params containing information to create deactivation
|
|
38
|
+
* - params.id: The id, optional
|
|
39
|
+
* - params.imei: The imei, required
|
|
40
|
+
* - params.clientId: The client id, required
|
|
41
|
+
* - params.createdBy: The created by, required
|
|
42
|
+
* - params.billingSubscriptionId: The billing subscription id, optional
|
|
43
|
+
* - params.planId: The plan id, optional
|
|
44
|
+
* - params.billingPlatform: The billing platform, optional
|
|
45
|
+
* - params.deactivationReason: The deactivation reason, optional
|
|
46
|
+
* - params.deactivationReasonId: The deactivation reason id, optional
|
|
47
|
+
* - params.scheduledDate: The scheduled date, optional
|
|
48
|
+
* - params.displayOrder: The display order, optional
|
|
49
|
+
* @returns The deactivation
|
|
50
|
+
*/
|
|
51
|
+
async createDeactivation(params) {
|
|
52
|
+
this.logger.trace(params, 'DeactivationsRepository::createDeactivation started with params');
|
|
53
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
54
|
+
const result = await createDeactivation(novaDataSource, params, this.logger);
|
|
55
|
+
this.logger.trace(result, 'DeactivationsRepository::createDeactivation result');
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { UserDeviceBehaviorTask } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const createDeviceBehaviorTask = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.taskId ||
|
|
5
|
+
!params?.deviceBehaviorId ||
|
|
6
|
+
!params?.clientId ||
|
|
7
|
+
!params?.userId ||
|
|
8
|
+
!params?.imei ||
|
|
9
|
+
!params?.behaviorName ||
|
|
10
|
+
!params?.status) {
|
|
11
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::createDeviceBehaviorTask - missing required parameters');
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const taskIdBinaryBuffer = uuidStringToBinaryBuffer(params?.taskId);
|
|
15
|
+
if (!taskIdBinaryBuffer?.length) {
|
|
16
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::createDeviceBehaviorTask - taskId should be a valid UUID');
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const userIdBinaryBuffer = uuidStringToBinaryBuffer(params?.userId);
|
|
20
|
+
if (!userIdBinaryBuffer?.length) {
|
|
21
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::createDeviceBehaviorTask - user id should be a valid UUID');
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const commandTaskIdBinaryBuffer = uuidStringToBinaryBuffer(params?.commandTaskId);
|
|
25
|
+
if (params.commandTaskId && !commandTaskIdBinaryBuffer) {
|
|
26
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::createDeviceBehaviorTask - command task id should be a valid UUID');
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
30
|
+
const userDeviceBehaviorTaskRepository = dataSource.getRepository(UserDeviceBehaviorTask);
|
|
31
|
+
const now = new Date();
|
|
32
|
+
const newUserDeviceBehaviorTask = {
|
|
33
|
+
id: taskIdBinaryBuffer,
|
|
34
|
+
deviceBehaviorId: params.deviceBehaviorId,
|
|
35
|
+
clientId: params.clientId,
|
|
36
|
+
userId: userIdBinaryBuffer,
|
|
37
|
+
imei: params.imei,
|
|
38
|
+
behaviorName: params.behaviorName,
|
|
39
|
+
behaviorParams: params.behaviorParams,
|
|
40
|
+
status: params.status,
|
|
41
|
+
extraParams: params.extraParams,
|
|
42
|
+
commandTaskId: commandTaskIdBinaryBuffer,
|
|
43
|
+
createdAt: now,
|
|
44
|
+
modifiedAt: now,
|
|
45
|
+
};
|
|
46
|
+
return await userDeviceBehaviorTaskRepository.save(newUserDeviceBehaviorTask);
|
|
47
|
+
}, 'DeviceBehaviorsRepository::createDeviceBehaviorTask');
|
|
48
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UserDeviceBehaviorTask } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const getDeviceBehaviorTasks = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.taskId && !params?.filters?.imeiList?.length) {
|
|
5
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::getDeviceBehaviorTasks - missing required parameters');
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const deviceBehaviorsRepository = dataSource.getRepository(UserDeviceBehaviorTask);
|
|
10
|
+
let queryBuilder = deviceBehaviorsRepository.createQueryBuilder('userDeviceBehaviorTask');
|
|
11
|
+
if (params.filters.taskId) {
|
|
12
|
+
const taskIdBinaryBuffer = uuidStringToBinaryBuffer(params?.filters?.taskId);
|
|
13
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.id = :taskId', {
|
|
14
|
+
taskId: taskIdBinaryBuffer,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (params.filters.imeiList?.length) {
|
|
18
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.imei IN (:...imeiList)', {
|
|
19
|
+
imeiList: params.filters.imeiList,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (params.filters.status) {
|
|
23
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.status = :status', {
|
|
24
|
+
status: params.filters.status,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (params.filters.deviceBehaviorIdList?.length) {
|
|
28
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.deviceBehaviorId IN (:...deviceBehaviorIdList)', {
|
|
29
|
+
deviceBehaviorIdList: params.filters.deviceBehaviorIdList,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
queryBuilder = queryBuilder.orderBy('userDeviceBehaviorTask.modifiedAt', 'DESC');
|
|
33
|
+
if (params?.pagingOptions?.offset) {
|
|
34
|
+
queryBuilder = queryBuilder.offset(params?.pagingOptions?.offset);
|
|
35
|
+
}
|
|
36
|
+
queryBuilder = queryBuilder.limit(params?.pagingOptions?.limit ?? 100);
|
|
37
|
+
const result = await queryBuilder.getMany();
|
|
38
|
+
return result;
|
|
39
|
+
}, 'DeviceBehaviorsRepository::getDeviceBehaviorTasks');
|
|
40
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DeviceBehavior } from '../../entities';
|
|
2
|
+
export const getDeviceBehaviors = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.status ||
|
|
4
|
+
!params?.filters?.imeiList?.length ||
|
|
5
|
+
!params?.filters?.deviceTypeIdList?.length) {
|
|
6
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::getDeviceBehaviors - missing required parameters');
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
10
|
+
const deviceBehaviorsRepository = dataSource.getRepository(DeviceBehavior);
|
|
11
|
+
let queryBuilder = deviceBehaviorsRepository.createQueryBuilder('deviceBehavior');
|
|
12
|
+
queryBuilder = queryBuilder.andWhere('deviceBehavior.status = :status', {
|
|
13
|
+
status: params.filters.status,
|
|
14
|
+
});
|
|
15
|
+
queryBuilder = queryBuilder.andWhere('deviceBehavior.imei IN (:...imeiList)', {
|
|
16
|
+
imeiList: params.filters.imeiList,
|
|
17
|
+
});
|
|
18
|
+
queryBuilder = queryBuilder.andWhere('deviceBehavior.deviceTypeId IN (:...deviceTypeIdList)', {
|
|
19
|
+
deviceTypeIdList: params.filters.deviceTypeIdList,
|
|
20
|
+
});
|
|
21
|
+
queryBuilder = queryBuilder.andWhere(`(deviceBehavior.stage IS NULL OR deviceBehavior.stage = '' OR deviceBehavior.stage = :stage)`, {
|
|
22
|
+
stage: params.filters.stage,
|
|
23
|
+
});
|
|
24
|
+
if (params.filters.clientId) {
|
|
25
|
+
queryBuilder = queryBuilder.andWhere('(deviceBehavior.clientId IS NULL OR deviceBehavior.clientId <= 0 OR deviceBehavior.clientId = :clientId)', {
|
|
26
|
+
clientId: params.filters.clientId,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
queryBuilder = queryBuilder.andWhere('(deviceBehavior.clientId IS NULL OR deviceBehavior.clientId <= 0)');
|
|
31
|
+
}
|
|
32
|
+
if (params.filters.type) {
|
|
33
|
+
queryBuilder = queryBuilder.andWhere('deviceBehavior.type = :type', {
|
|
34
|
+
type: params.filters.type,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
queryBuilder = queryBuilder.orderBy('deviceBehavior.ordinalPosition');
|
|
38
|
+
const result = await queryBuilder.getMany();
|
|
39
|
+
return result;
|
|
40
|
+
}, 'DeviceBehaviorsRepository::getDeviceBehaviors');
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DeviceBehavior } from '../../entities';
|
|
2
|
+
export const getDeviceBehaviorsByIds = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.deviceBehaviorIdList?.length) {
|
|
4
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::getDeviceBehaviorsByIds - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const deviceBehaviorsRepository = dataSource.getRepository(DeviceBehavior);
|
|
9
|
+
let queryBuilder = deviceBehaviorsRepository.createQueryBuilder('deviceBehavior');
|
|
10
|
+
queryBuilder = queryBuilder.andWhere('deviceBehavior.id IN (:...deviceBehaviorIdList)', {
|
|
11
|
+
deviceBehaviorIdList: params.filters.deviceBehaviorIdList,
|
|
12
|
+
});
|
|
13
|
+
const result = await queryBuilder.getMany();
|
|
14
|
+
return result;
|
|
15
|
+
}, 'DeviceBehaviorsRepository::getDeviceBehaviorsByIds');
|
|
16
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UserDeviceBehaviorTask } from '../../entities';
|
|
2
|
+
export const getDevicesLastBehaviorTask = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.imeiList?.length) {
|
|
4
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::getDevicesLastBehaviorTask - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const deviceBehaviorsRepository = dataSource.getRepository(UserDeviceBehaviorTask);
|
|
9
|
+
let queryBuilder = deviceBehaviorsRepository.createQueryBuilder('userDeviceBehaviorTask');
|
|
10
|
+
if (params.filters.imeiList?.length) {
|
|
11
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.imei IN (:...imeiList)', {
|
|
12
|
+
imeiList: params.filters.imeiList,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (params.filters.status) {
|
|
16
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.status = :status', {
|
|
17
|
+
status: params.filters.status,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (params.filters.deviceBehaviorIdList?.length) {
|
|
21
|
+
queryBuilder = queryBuilder.andWhere('userDeviceBehaviorTask.deviceBehaviorId IN (:...deviceBehaviorIdList)', {
|
|
22
|
+
deviceBehaviorIdList: params.filters.deviceBehaviorIdList,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
queryBuilder.andWhere(subQuery => {
|
|
26
|
+
const subQueryAlias = subQuery
|
|
27
|
+
.subQuery()
|
|
28
|
+
.select('MAX(modifiedAt)')
|
|
29
|
+
.from(UserDeviceBehaviorTask, 'subTask')
|
|
30
|
+
.where('subTask.imei = userDeviceBehaviorTask.imei')
|
|
31
|
+
.getQuery();
|
|
32
|
+
return `userDeviceBehaviorTask.modifiedAt = (${subQueryAlias})`;
|
|
33
|
+
});
|
|
34
|
+
queryBuilder = queryBuilder.orderBy('userDeviceBehaviorTask.modifiedAt', 'DESC');
|
|
35
|
+
if (params?.pagingOptions?.offset) {
|
|
36
|
+
queryBuilder = queryBuilder.offset(params?.pagingOptions?.offset);
|
|
37
|
+
}
|
|
38
|
+
queryBuilder = queryBuilder.limit(params?.pagingOptions?.limit ?? 100);
|
|
39
|
+
const result = await queryBuilder.getMany();
|
|
40
|
+
return result;
|
|
41
|
+
}, 'DeviceBehaviorsRepository::getDevicesLastBehaviorTask');
|
|
42
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UserDeviceBehaviorTask } from '../../entities';
|
|
2
|
+
import { binaryBufferToUuidString } from '../../utils/uuidHelpers';
|
|
3
|
+
export const getLatestDeviceBehaviorTasks = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.clientId && !params?.filters?.type && !params?.filters?.status) {
|
|
5
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::getLatestDeviceBehaviorTasks - missing required parameters');
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const deviceBehaviorsRepository = dataSource.getRepository(UserDeviceBehaviorTask);
|
|
10
|
+
const query = `SELECT sub.imei AS imei,
|
|
11
|
+
sub.name AS name,
|
|
12
|
+
sub.description AS description,
|
|
13
|
+
sub.modifiedAt AS modifiedAt,
|
|
14
|
+
sub.taskId AS taskId
|
|
15
|
+
FROM (
|
|
16
|
+
SELECT userDeviceBehaviorTask.imei AS imei,
|
|
17
|
+
deviceBehavior.name as name,
|
|
18
|
+
deviceBehavior.description as description,
|
|
19
|
+
userDeviceBehaviorTask.modifiedAt AS modifiedAt,
|
|
20
|
+
userDeviceBehaviorTask.id AS taskId,
|
|
21
|
+
RANK() OVER (PARTITION BY userDeviceBehaviorTask.imei ORDER BY userDeviceBehaviorTask.modifiedAt DESC) AS rk
|
|
22
|
+
FROM userDeviceBehaviorTask
|
|
23
|
+
INNER JOIN deviceBehavior ON userDeviceBehaviorTask.deviceBehaviorId = deviceBehavior.id AND deviceBehavior.type = ?
|
|
24
|
+
WHERE userDeviceBehaviorTask.clientId = ? AND userDeviceBehaviorTask.status = ?
|
|
25
|
+
) AS sub
|
|
26
|
+
WHERE sub.rk = 1`;
|
|
27
|
+
const result = await deviceBehaviorsRepository.query(query, [
|
|
28
|
+
params.filters.type,
|
|
29
|
+
params.filters.clientId,
|
|
30
|
+
params.filters.status,
|
|
31
|
+
]);
|
|
32
|
+
return result.map(item => ({
|
|
33
|
+
imei: item.imei,
|
|
34
|
+
name: item.name,
|
|
35
|
+
description: item.description,
|
|
36
|
+
modifiedAt: item.modifiedAt,
|
|
37
|
+
taskId: binaryBufferToUuidString(item.taskId),
|
|
38
|
+
}));
|
|
39
|
+
}, 'DeviceBehaviorsRepository::getLatestDeviceBehaviorTasks');
|
|
40
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createDeviceBehaviorTask } from './createDeviceBehaviorTask';
|
|
4
|
+
import { getDeviceBehaviors } from './getDeviceBehaviors';
|
|
5
|
+
import { getDeviceBehaviorsByIds } from './getDeviceBehaviorsByIds';
|
|
6
|
+
import { getDeviceBehaviorTasks } from './getDeviceBehaviorTasks';
|
|
7
|
+
import { getDevicesLastBehaviorTask } from './getDevicesLastBehaviorTask';
|
|
8
|
+
import { getLatestDeviceBehaviorTasks } from './getLatestDeviceBehaviorTasks';
|
|
9
|
+
import { updateDeviceBehaviorTask } from './updateDeviceBehaviorTask';
|
|
10
|
+
import { upsertDeviceBehavior } from './upsertDeviceBehavior';
|
|
11
|
+
export class DeviceBehaviorsRepository extends BaseRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Get user rating requests
|
|
14
|
+
* @param {GetDeviceBehaviorsParams} params containing information to get device behaviors
|
|
15
|
+
* - filters.status: The status
|
|
16
|
+
* - filters.imeiList: The imei list
|
|
17
|
+
* - filters.deviceTypeIdList: The device type id list
|
|
18
|
+
* - filters.stage: The stage
|
|
19
|
+
* - filters.clientId: The client id, optional
|
|
20
|
+
* - filters.type: The type, optional
|
|
21
|
+
* @returns The device behaviors list
|
|
22
|
+
*/
|
|
23
|
+
async getDeviceBehaviors(params) {
|
|
24
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::getDeviceBehaviors started with params');
|
|
25
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
26
|
+
const result = await getDeviceBehaviors(novaDataSource, params, this.logger);
|
|
27
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::getDeviceBehaviors result');
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get device behaviors by ids
|
|
32
|
+
* @params {GetDeviceBehaviorsByIdsParams} params containing information to get device behaviors by ids
|
|
33
|
+
* - filters.deviceBehaviorIdList: The device behavior id list, required
|
|
34
|
+
* @returns The device behaviors list
|
|
35
|
+
*/
|
|
36
|
+
async getDeviceBehaviorsByIds(params) {
|
|
37
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::getDeviceBehaviorsByIds started with params');
|
|
38
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
39
|
+
const result = await getDeviceBehaviorsByIds(novaDataSource, params, this.logger);
|
|
40
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::getDeviceBehaviorsByIds result');
|
|
41
|
+
return result;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get device behavior tasks
|
|
45
|
+
* @param {GetDeviceBehaviorTasksParams} params containing information to get device behavior tasks
|
|
46
|
+
* Filters (One of taskId or imeiList is required):
|
|
47
|
+
* - filters.taskId: The task id
|
|
48
|
+
* - filters.imeiList: The imei list
|
|
49
|
+
* - filters.status: The status, optional
|
|
50
|
+
* - filters.deviceBehaviorIdList: The device behavior id list, optional
|
|
51
|
+
* Paging options:
|
|
52
|
+
* - pagingOptions.offset: The offset, optional. Default is 0
|
|
53
|
+
* - pagingOptions.limit: The limit, optional. Default is 100
|
|
54
|
+
* @returns The device behavior tasks list
|
|
55
|
+
*/
|
|
56
|
+
async getDeviceBehaviorTasks(params) {
|
|
57
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::getDeviceBehaviorTasks started with params');
|
|
58
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
59
|
+
const result = await getDeviceBehaviorTasks(novaDataSource, params, this.logger);
|
|
60
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::getDeviceBehaviorTasks result');
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the devices last behavior task
|
|
65
|
+
* @param {GettDevicesLastBehaviorTaskParams} params containing information to get device behavior tasks
|
|
66
|
+
* Filters (One of taskId or imeiList is required):
|
|
67
|
+
* - filters.imeiList: The imei list
|
|
68
|
+
* - filters.status: The status, optional
|
|
69
|
+
* - filters.deviceBehaviorIdList: The device behavior id list, optional
|
|
70
|
+
* Paging options:
|
|
71
|
+
* - pagingOptions.offset: The offset, optional. Default is 0
|
|
72
|
+
* - pagingOptions.limit: The limit, optional. Default is 100
|
|
73
|
+
* @returns The device behavior tasks list
|
|
74
|
+
*/
|
|
75
|
+
async getDevicesLastBehaviorTask(params) {
|
|
76
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::getDevicesLastBehaviorTask started with params');
|
|
77
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
78
|
+
const result = await getDevicesLastBehaviorTask(novaDataSource, params, this.logger);
|
|
79
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::getDevicesLastBehaviorTask result');
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create device behavior task
|
|
84
|
+
* @param {CreateDeviceBehaviorTaskParams} params containing information to create a device behavior task
|
|
85
|
+
* - params.taskId: The task id
|
|
86
|
+
* - params.deviceBehaviorId: The device behavior id
|
|
87
|
+
* - params.clientId: The client id
|
|
88
|
+
* - params.userId: The user id
|
|
89
|
+
* - params.imei: The imei
|
|
90
|
+
* - params.behaviorName: The behavior name
|
|
91
|
+
* - params.behaviorParams: The behavior params, optional
|
|
92
|
+
* - params.status: The status
|
|
93
|
+
* - params.extraParams: The extra params, optional
|
|
94
|
+
* - params.commandTaskId: The common command task if the behavior is part of a bulk action, optional
|
|
95
|
+
* @returns The device behavior task
|
|
96
|
+
*/
|
|
97
|
+
async createDeviceBehaviorTask(params) {
|
|
98
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::createDeviceBehaviorTasks started with params');
|
|
99
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
100
|
+
const result = await createDeviceBehaviorTask(novaDataSource, params, this.logger);
|
|
101
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::createDeviceBehaviorTasks result');
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Update device behavior task
|
|
106
|
+
* @param {UpdateDeviceBehaviorTaskParams} params containing information to update a device behavior task
|
|
107
|
+
* Filters:
|
|
108
|
+
* - params.filters.taskId: The task id
|
|
109
|
+
* Values:
|
|
110
|
+
* - params.values.status: The status
|
|
111
|
+
* @returns Whether the device behavior task was updated
|
|
112
|
+
*/
|
|
113
|
+
async updateDeviceBehaviorTask(params) {
|
|
114
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::updateDeviceBehaviorTask started with params');
|
|
115
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
116
|
+
const result = await updateDeviceBehaviorTask(novaDataSource, params, this.logger);
|
|
117
|
+
this.logger.trace({ result }, 'DeviceBehaviorsRepository::updateDeviceBehaviorTask result');
|
|
118
|
+
return result;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get latest device behavior tasks
|
|
122
|
+
* @param {GetLatestDeviceBehaviorTasksParams} params containing information to get latest device behavior tasks
|
|
123
|
+
* - params.filters.clientId: The client id
|
|
124
|
+
* - params.filters.type: The device behavior type
|
|
125
|
+
* - params.filters.status: The task status
|
|
126
|
+
* @returns The latest device behavior tasks list
|
|
127
|
+
*/
|
|
128
|
+
async getLatestDeviceBehaviorTasks(params) {
|
|
129
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::getLatestDeviceBehaviorTasks started with params');
|
|
130
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
131
|
+
const result = await getLatestDeviceBehaviorTasks(novaDataSource, params, this.logger);
|
|
132
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::getLatestDeviceBehaviorTasks result');
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Upsert device behavior
|
|
137
|
+
* @param {UpsertDeviceBehaviorParams} params containing information to upsert a device behavior
|
|
138
|
+
* @returns The device behavior
|
|
139
|
+
*/
|
|
140
|
+
async upsertDeviceBehavior(params) {
|
|
141
|
+
this.logger.trace(params, 'DeviceBehaviorsRepository::upsertDeviceBehavior started with params');
|
|
142
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
143
|
+
const result = await upsertDeviceBehavior(novaDataSource, params, this.logger);
|
|
144
|
+
this.logger.trace(result, 'DeviceBehaviorsRepository::upsertDeviceBehavior result');
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UserDeviceBehaviorTask } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const updateDeviceBehaviorTask = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.taskId || !params?.values?.status) {
|
|
5
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::updateDeviceBehaviorTask - missing required parameters');
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const taskIdBinaryBuffer = uuidStringToBinaryBuffer(params?.filters.taskId);
|
|
9
|
+
if (!taskIdBinaryBuffer?.length) {
|
|
10
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::updateDeviceBehaviorTask - taskId should be a valid UUID');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
14
|
+
const userDeviceBehaviorTaskRepository = dataSource.getRepository(UserDeviceBehaviorTask);
|
|
15
|
+
const now = new Date();
|
|
16
|
+
let queryBuilder = userDeviceBehaviorTaskRepository
|
|
17
|
+
.createQueryBuilder()
|
|
18
|
+
.update(UserDeviceBehaviorTask)
|
|
19
|
+
.set({
|
|
20
|
+
status: params.values.status,
|
|
21
|
+
modifiedAt: now,
|
|
22
|
+
});
|
|
23
|
+
queryBuilder = queryBuilder.where('id = :id', { id: taskIdBinaryBuffer });
|
|
24
|
+
const result = await queryBuilder.execute();
|
|
25
|
+
return result.affected > 0;
|
|
26
|
+
}, 'DeviceBehaviorsRepository::updateDeviceBehaviorTask');
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DeviceBehavior } from '../../entities';
|
|
2
|
+
export const upsertDeviceBehavior = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.deviceTypeId ||
|
|
4
|
+
!params?.name ||
|
|
5
|
+
!params?.description ||
|
|
6
|
+
!params?.status ||
|
|
7
|
+
!params?.behaviorName) {
|
|
8
|
+
logger.warn({ params }, 'DeviceBehaviorsRepository::upsertDeviceBehavior - missing required parameters');
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
12
|
+
const deviceBehaviorRepository = dataSource.getRepository(DeviceBehavior);
|
|
13
|
+
const newDeviceBehavior = {
|
|
14
|
+
...params,
|
|
15
|
+
ordinalPosition: params.ordinalPosition || 1,
|
|
16
|
+
blocking: params.blocking ?? true,
|
|
17
|
+
};
|
|
18
|
+
return await deviceBehaviorRepository.save(newDeviceBehavior);
|
|
19
|
+
}, 'DeviceBehaviorsRepository::upsertDeviceBehavior');
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DevicePairing } from '../../entities';
|
|
2
|
+
export const createDevicePairing = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.imeiMain ||
|
|
4
|
+
!params?.imeiSecondary ||
|
|
5
|
+
!params?.btmacMain ||
|
|
6
|
+
!params?.btmacSecondary) {
|
|
7
|
+
logger.warn({ params }, 'DevicePairingsRepository::createDevicePairing missing required parameters');
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
11
|
+
const devicePaitingsRepository = dataSource.getRepository(DevicePairing);
|
|
12
|
+
const now = new Date();
|
|
13
|
+
const newDevicePairing = {
|
|
14
|
+
...params,
|
|
15
|
+
createdAt: now,
|
|
16
|
+
modifiedAt: now,
|
|
17
|
+
};
|
|
18
|
+
const result = await devicePaitingsRepository.save(newDevicePairing);
|
|
19
|
+
return result;
|
|
20
|
+
}, 'DevicePairingsRepository::createDevicePairing');
|
|
21
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DevicePairing } from '../../entities';
|
|
2
|
+
export const deleteDevicePairing = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.id) {
|
|
4
|
+
logger.warn({ params }, 'DevicePairingsRepository::deleteDevicePairing - missing required parameters');
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const devicePairingsRepository = dataSource.getRepository(DevicePairing);
|
|
9
|
+
const queryBuilder = devicePairingsRepository
|
|
10
|
+
.createQueryBuilder()
|
|
11
|
+
.delete()
|
|
12
|
+
.where('id = :id', { id: params.filters.id });
|
|
13
|
+
const result = await queryBuilder.execute();
|
|
14
|
+
return result.affected > 0;
|
|
15
|
+
}, 'DevicePairingsRepository::deleteDevicePairing');
|
|
16
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DevicePairing } from '../../entities';
|
|
2
|
+
export const getDevicePairings = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.imeiMain &&
|
|
4
|
+
!params?.filters?.imeiSecondary &&
|
|
5
|
+
!params?.filters?.btmacMain &&
|
|
6
|
+
!params?.filters?.btmacSecondary) {
|
|
7
|
+
logger.warn({ params }, 'DevicePairingsRepository::getDevicePairings missing required parameters');
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
11
|
+
const devicePairingsRepository = dataSource.getRepository(DevicePairing);
|
|
12
|
+
let queryBuilder = devicePairingsRepository.createQueryBuilder('devicePairing');
|
|
13
|
+
if (params.filters.imeiMain) {
|
|
14
|
+
queryBuilder = queryBuilder.where('devicePairing.imeiMain = :imeiMain', {
|
|
15
|
+
imeiMain: params.filters.imeiMain,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (params.filters.imeiSecondary) {
|
|
19
|
+
queryBuilder = queryBuilder.andWhere('devicePairing.imeiSecondary = :imeiSecondary', {
|
|
20
|
+
imeiSecondary: params.filters.imeiSecondary,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (params.filters.btmacMain) {
|
|
24
|
+
queryBuilder = queryBuilder.andWhere('devicePairing.btmacMain = :btmacMain', {
|
|
25
|
+
btmacMain: params.filters.btmacMain,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (params.filters.btmacSecondary) {
|
|
29
|
+
queryBuilder = queryBuilder.andWhere('devicePairing.btmacSecondary = :btmacSecondary', {
|
|
30
|
+
btmacSecondary: params.filters.btmacSecondary,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
const devicePairings = await queryBuilder.getMany();
|
|
34
|
+
return devicePairings;
|
|
35
|
+
}, 'DevicePairingsRepository::getDevicePairings');
|
|
36
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DevicePairing } from '../../entities';
|
|
2
|
+
export const getDevicePairingsByImei = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.imei) {
|
|
4
|
+
logger.warn({ params }, 'DevicePairingsRepository::getDevicePairingsByImei missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const devicePairingsRepository = dataSource.getRepository(DevicePairing);
|
|
9
|
+
const queryBuilder = devicePairingsRepository
|
|
10
|
+
.createQueryBuilder('devicePairing')
|
|
11
|
+
.where('devicePairing.imeiMain = :imeiMain', {
|
|
12
|
+
imeiMain: params.filters.imei,
|
|
13
|
+
})
|
|
14
|
+
.orWhere('devicePairing.imeiSecondary = :imeiSecondary', {
|
|
15
|
+
imeiSecondary: params.filters.imei,
|
|
16
|
+
});
|
|
17
|
+
const devicePairings = await queryBuilder.getMany();
|
|
18
|
+
return devicePairings;
|
|
19
|
+
}, 'DevicePairingsRepository::getDevicePairingsByImei');
|
|
20
|
+
};
|