@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,23 @@
|
|
|
1
|
+
import { Position } from '../../entities';
|
|
2
|
+
export const getPositionsByImei = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.imei) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
await novaDataSource.connect();
|
|
8
|
+
const positionsRepository = novaDataSource.getRepository(Position);
|
|
9
|
+
const filterCondition = { where: { imei: params.filters.imei } };
|
|
10
|
+
const positions = await positionsRepository.find(filterCondition);
|
|
11
|
+
return (positions?.map(p => ({
|
|
12
|
+
...p,
|
|
13
|
+
id: Number(p.id),
|
|
14
|
+
})) ?? []);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
logger.error({ error }, 'PositionsRepository::getPositionsByImei error');
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
await novaDataSource.disconnect();
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Position } from '../../entities/position';
|
|
2
|
+
export const getPositionsReportByClient = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId) {
|
|
4
|
+
return [];
|
|
5
|
+
}
|
|
6
|
+
try {
|
|
7
|
+
await novaDataSource.connect();
|
|
8
|
+
const positionsRepository = novaDataSource.getRepository(Position);
|
|
9
|
+
let positionsQuery = positionsRepository
|
|
10
|
+
.createQueryBuilder('p')
|
|
11
|
+
.where('p.clientId = :clientId', { clientId: params.filters.clientId });
|
|
12
|
+
if (params.filters.imeis) {
|
|
13
|
+
positionsQuery = positionsQuery.andWhere('p.imei IN (:...imeis)', {
|
|
14
|
+
imeis: params.filters.imeis,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
if (params.filters.actualDateFrom) {
|
|
18
|
+
positionsQuery = positionsQuery.andWhere('p.actualDate >= :actualDateFrom', {
|
|
19
|
+
actualDateFrom: params.filters.actualDateFrom,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (params.filters.actualDateTo) {
|
|
23
|
+
positionsQuery = positionsQuery.andWhere('p.actualDate <= :actualDateTo', {
|
|
24
|
+
actualDateTo: params.filters.actualDateTo,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (params.filters.speedMin) {
|
|
28
|
+
positionsQuery = positionsQuery.andWhere('p.speed >= :speedMin', {
|
|
29
|
+
speedMin: params.filters.speedMin,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (params.filters.speedMax) {
|
|
33
|
+
positionsQuery = positionsQuery.andWhere('p.speed <= :speedMax', {
|
|
34
|
+
speedMax: params.filters.speedMax,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (params.filters.odometerMin) {
|
|
38
|
+
positionsQuery = positionsQuery.andWhere('p.odometer >= :odometerMin', {
|
|
39
|
+
odometerMin: params.filters.odometerMin,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
if (params.filters.odometerMax) {
|
|
43
|
+
positionsQuery = positionsQuery.andWhere('p.odometer <= :odometerMax', {
|
|
44
|
+
odometerMax: params.filters.odometerMax,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const subQuery = positionsQuery.clone().select('COUNT(p.id)', 'totalCount');
|
|
48
|
+
if (params.filters.imeis?.length) {
|
|
49
|
+
positionsQuery.useIndex('ixPositionClientId_Imei_ActualDate');
|
|
50
|
+
subQuery.useIndex('ixPositionClientId_Imei_ActualDate');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
positionsQuery.useIndex('ixPositionClientId_ActualDate');
|
|
54
|
+
subQuery.useIndex('ixPositionClientId_ActualDate');
|
|
55
|
+
}
|
|
56
|
+
positionsQuery.innerJoin(`(${subQuery.getQuery()})`, 'sub');
|
|
57
|
+
if (params.sortOptions?.sortField) {
|
|
58
|
+
positionsQuery.orderBy(params.sortOptions.sortField, params.sortOptions.sortOrder);
|
|
59
|
+
}
|
|
60
|
+
const positions = await positionsQuery
|
|
61
|
+
.select([
|
|
62
|
+
'p.imei as imei',
|
|
63
|
+
'p.createdAt as createdAt',
|
|
64
|
+
'p.actualDate as actualDate',
|
|
65
|
+
'p.lat as lat',
|
|
66
|
+
'p.lon as lon',
|
|
67
|
+
'p.address as address',
|
|
68
|
+
'p.speed as speed',
|
|
69
|
+
'p.odometer as odometer',
|
|
70
|
+
'p.batteryPercentage as batteryPercentage',
|
|
71
|
+
'p.externalPowerVoltage as externalPowerVoltage',
|
|
72
|
+
'p.externalBatteryPercentage as externalBatteryPercentage',
|
|
73
|
+
`sub.totalCount as totalCount`,
|
|
74
|
+
])
|
|
75
|
+
.limit(params.pagingOptions.pageSize)
|
|
76
|
+
.offset(params.pagingOptions.pageSize * params.pagingOptions.pageIndex)
|
|
77
|
+
.getRawMany();
|
|
78
|
+
return positions;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
logger.error({ error }, 'PositionsRepository::GetPositionsReportByClientId error');
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
await novaDataSource.disconnect();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createPosition, upsertPositions } from './createPosition';
|
|
4
|
+
import { getLatestPositionByImei } from './getLatestPositionByImei';
|
|
5
|
+
import { getPositionsByImei } from './getPositionsByImei';
|
|
6
|
+
import { getPositionsReportByClient } from './getPositionsReportByClient';
|
|
7
|
+
export class PositionRepository extends BaseRepository {
|
|
8
|
+
/**
|
|
9
|
+
* Create a position
|
|
10
|
+
* @param {CreatePositionParams} params containing information to create a position
|
|
11
|
+
* - id: position id. if null will be generated
|
|
12
|
+
* - imei: imei of the device reporting the position
|
|
13
|
+
* - lat: the latitude of the position
|
|
14
|
+
* - lon: the longitude of the position
|
|
15
|
+
* - actualDate: the actual date of the message
|
|
16
|
+
* - speed: the speed reported by the device
|
|
17
|
+
* - odometer: the odometer reported by the device
|
|
18
|
+
* - messageId: the id of the message
|
|
19
|
+
* - batteryPercentage: the battery percentage reported by the device
|
|
20
|
+
* - clientId: the client id of owner of the device
|
|
21
|
+
* - address: the address of the position
|
|
22
|
+
* - sendTime: the time the message was sent
|
|
23
|
+
* - gpsUtcTime: the time the gps was set
|
|
24
|
+
* - externalBatteryPercentage: the external battery percentage reported by the device
|
|
25
|
+
*/
|
|
26
|
+
async createPosition(params) {
|
|
27
|
+
this.logger.trace(params, `PositionsRepository::this.createPosition started with params`);
|
|
28
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
29
|
+
const result = await createPosition(novaDataSource, params, this.logger);
|
|
30
|
+
this.logger.trace(result, 'PositionsRepository::insertPositions result');
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a position
|
|
35
|
+
* @param {CreatePositionParams[]} params array containing information to create a positions
|
|
36
|
+
* - id: position id. if null will be generated
|
|
37
|
+
* - imei: imei of the device reporting the position
|
|
38
|
+
* - lat: the latitude of the position
|
|
39
|
+
* - lon: the longitude of the position
|
|
40
|
+
* - actualDate: the actual date of the message
|
|
41
|
+
* - speed: the speed reported by the device
|
|
42
|
+
* - odometer: the odometer reported by the device
|
|
43
|
+
* - messageId: the id of the message
|
|
44
|
+
* - batteryPercentage: the battery percentage reported by the device
|
|
45
|
+
* - clientId: the client id of owner of the device
|
|
46
|
+
* - address: the address of the position
|
|
47
|
+
* - sendTime: the time the message was sent
|
|
48
|
+
* - gpsUtcTime: the time the gps was set
|
|
49
|
+
* - externalBatteryPercentage: the external battery percentage reported by the device
|
|
50
|
+
* @returns {Position[]} the created positions
|
|
51
|
+
*/
|
|
52
|
+
async upsertPositions(params) {
|
|
53
|
+
this.logger.trace(params, `PositionsRepository::this.createPosition started with params`);
|
|
54
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
55
|
+
const result = await upsertPositions(novaDataSource, params, this.logger);
|
|
56
|
+
this.logger.trace(result, 'PositionsRepository::insertPositions result');
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get positions by imei
|
|
61
|
+
* @param {GetPositionsByImeiParams} params containing information to get positions
|
|
62
|
+
* - filters.imei: filters by imei to get positions
|
|
63
|
+
*/
|
|
64
|
+
async getPositionsByImei(params) {
|
|
65
|
+
this.logger.trace(params, `PositionsRepository::this.getPositionsByImei started with params`);
|
|
66
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
67
|
+
const result = await getPositionsByImei(novaDataSource, params, this.logger);
|
|
68
|
+
this.logger.trace(result, 'PositionsRepository::getPositionsByImei result');
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Get positions report by client id
|
|
73
|
+
* @param {GetPositionsReportByClientParams} params containing information to get positions
|
|
74
|
+
* - filters.clientId: filters by client id to get positions
|
|
75
|
+
* - filters.imeis: filters by imeis to get positions
|
|
76
|
+
* - filters.actualDateFrom: filters by actual date from to get positions
|
|
77
|
+
* - filters.actualDateTo: filters by actual date to to get positions
|
|
78
|
+
* - filters.speedMin: filters by speed min to get positions
|
|
79
|
+
* - filters.speedMax: filters by speed max to get positions
|
|
80
|
+
* - filters.odometerMin: filters by odometer min to get positions
|
|
81
|
+
* - filters.odometerMax: filters by odometer max to get positions
|
|
82
|
+
* - pagingOptions.pageSize: the page size
|
|
83
|
+
* - pagingOptions.pageIndex: the page index
|
|
84
|
+
* - sortOptions.sortField: the sort field
|
|
85
|
+
* - sortOptions.sortOrder: the sort order
|
|
86
|
+
*/
|
|
87
|
+
async getPositionsReportByClient(params) {
|
|
88
|
+
this.logger.trace(params, `PositionsRepository::getPositionsReportByClientId started with params`);
|
|
89
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
90
|
+
const result = await getPositionsReportByClient(novaDataSource, params, this.logger);
|
|
91
|
+
this.logger.trace(result, 'PositionsRepository::getPositionsReportByClientId result');
|
|
92
|
+
return result;
|
|
93
|
+
}
|
|
94
|
+
async getLatestPositionByImei(params) {
|
|
95
|
+
this.logger.trace(params, `PositionsRepository::this.getLatestPositionByImei started with params`);
|
|
96
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
97
|
+
const result = await getLatestPositionByImei(novaDataSource, params, this.logger);
|
|
98
|
+
this.logger.trace(result, 'PositionsRepository::getLatestPositionByImei result');
|
|
99
|
+
return result;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { LatestPosition } from '../../entities';
|
|
2
|
+
export const upsertLatestPosition = async (novaDataSource, position, logger) => {
|
|
3
|
+
if (!position?.id || !position?.imei) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const latestPositionsRepository = novaDataSource.getRepository(LatestPosition);
|
|
7
|
+
try {
|
|
8
|
+
const { id, ...rest } = position;
|
|
9
|
+
const queryBuilder = latestPositionsRepository.createQueryBuilder();
|
|
10
|
+
const insertResult = await queryBuilder
|
|
11
|
+
.insert()
|
|
12
|
+
.into(LatestPosition)
|
|
13
|
+
.values({
|
|
14
|
+
...rest,
|
|
15
|
+
positionId: id,
|
|
16
|
+
})
|
|
17
|
+
.orIgnore()
|
|
18
|
+
.execute();
|
|
19
|
+
if (insertResult.raw.affectedRows > 0) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
const updateResult = await queryBuilder
|
|
23
|
+
.update(LatestPosition)
|
|
24
|
+
.set({
|
|
25
|
+
...rest,
|
|
26
|
+
positionId: id,
|
|
27
|
+
})
|
|
28
|
+
.where(`imei = :imei`, {
|
|
29
|
+
imei: position.imei,
|
|
30
|
+
})
|
|
31
|
+
.andWhere(`positionId < :positionId`, {
|
|
32
|
+
positionId: position.id,
|
|
33
|
+
})
|
|
34
|
+
.execute();
|
|
35
|
+
return updateResult.affected > 0;
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
logger.warn(error, `PositionsRepository::upsertLatestPosition error`);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const createUserRole = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.userId) {
|
|
5
|
+
logger.warn({ params }, 'SecurityRepository::createUserRole - missing required parameters');
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
10
|
+
const userRole = await userSecurityRolesRepository.findOne({
|
|
11
|
+
where: {
|
|
12
|
+
userId: uuidStringToBinaryBuffer(params.userId),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
if (!userRole) {
|
|
16
|
+
const newUserRole = {
|
|
17
|
+
userId: uuidStringToBinaryBuffer(params.userId),
|
|
18
|
+
clientId: params.clientId,
|
|
19
|
+
securityRoleId: params.roleId,
|
|
20
|
+
};
|
|
21
|
+
return await userSecurityRolesRepository.save(newUserRole);
|
|
22
|
+
}
|
|
23
|
+
if (userRole.clientId === params.clientId && userRole.securityRoleId === params.roleId) {
|
|
24
|
+
return userRole; // nothing to create, role already exists
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error('User role cannot be created because another role already exists');
|
|
28
|
+
}
|
|
29
|
+
}, 'SecurityRepository::createUserRole');
|
|
30
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SecurityRole } from '../../entities';
|
|
2
|
+
export const getAllRoles = async (novaDataSource) => {
|
|
3
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
4
|
+
const rolesRepository = dataSource.getRepository(SecurityRole);
|
|
5
|
+
const roles = await rolesRepository.find();
|
|
6
|
+
return roles;
|
|
7
|
+
}, 'SecurityRepository::getAllRoles');
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const getUserRoles = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.userId) {
|
|
5
|
+
logger.warn({ params }, 'SecurityRepository::getUserRoles - missing required parameters');
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
10
|
+
const userRoles = await userSecurityRolesRepository.find({
|
|
11
|
+
where: { userId: uuidStringToBinaryBuffer(params.filters.userId) },
|
|
12
|
+
});
|
|
13
|
+
return userRoles;
|
|
14
|
+
}, 'SecurityRepository::getUserRoles');
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
export const getUserRolesByClientId = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.clientId) {
|
|
4
|
+
logger.warn({ params }, 'SecurityRepository::getUserRolesByClientId - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
9
|
+
const filterCondition = params.filters.role
|
|
10
|
+
? { where: { clientId: params.filters.clientId, securityRoleId: params.filters.role } }
|
|
11
|
+
: {
|
|
12
|
+
where: { clientId: params.filters.clientId },
|
|
13
|
+
};
|
|
14
|
+
const userRoles = await userSecurityRolesRepository.find(filterCondition);
|
|
15
|
+
return userRoles;
|
|
16
|
+
}, 'SecurityRepository::getUserRolesByClientId');
|
|
17
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createUserRole } from './createUserRole';
|
|
4
|
+
import { getAllRoles } from './getAllRoles';
|
|
5
|
+
import { getUserRoles } from './getUserRoles';
|
|
6
|
+
import { getUserRolesByClientId } from './getUserRolesByClientId';
|
|
7
|
+
import { removeUserRoles } from './removeUserRoles';
|
|
8
|
+
import { updateUserRole } from './updateUserRole';
|
|
9
|
+
import { userIsAdminOrOwner } from './userIsAdminOrOwner';
|
|
10
|
+
import { userIsInRole } from './userIsInRole';
|
|
11
|
+
export class SecurityRepository extends BaseRepository {
|
|
12
|
+
/**
|
|
13
|
+
* Get all security roles
|
|
14
|
+
*/
|
|
15
|
+
async getAllRoles() {
|
|
16
|
+
this.logger.trace('SecurityRepository::getAllRoles started');
|
|
17
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
18
|
+
const result = await getAllRoles(novaDataSource);
|
|
19
|
+
this.logger.trace(result, 'SecurityRepository::getAllRoles result');
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get roles of the user
|
|
24
|
+
* @param {GetUserRolesParams} params containing information to get roles of the user
|
|
25
|
+
* - filters.userId: The user id
|
|
26
|
+
*/
|
|
27
|
+
async getUserRoles(params) {
|
|
28
|
+
this.logger.trace(params, 'SecurityRepository::getUserRoles started with params');
|
|
29
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
30
|
+
const result = await getUserRoles(novaDataSource, params, this.logger);
|
|
31
|
+
this.logger.trace(result, 'SecurityRepository::getUserRoles result');
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Get user roles by clientId
|
|
36
|
+
* @param {GetUserRolesByClientIdParams} params containing information to get user roles by clientId
|
|
37
|
+
* - filters.clientId: The client id
|
|
38
|
+
* - filters.role: The role to only obtain user roles with that role, optional
|
|
39
|
+
*/
|
|
40
|
+
async getUserRolesByClientId(params) {
|
|
41
|
+
this.logger.trace(params, 'SecurityRepository::getUserRolesByClientId started with params');
|
|
42
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
43
|
+
const result = await getUserRolesByClientId(novaDataSource, params, this.logger);
|
|
44
|
+
this.logger.trace(result, 'SecurityRepository::getUserRolesByClientId result');
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether the user is in role
|
|
49
|
+
* @param {UserIsInRoleParams} params containing information to know if the user is in role
|
|
50
|
+
* - filters.userId: The user id
|
|
51
|
+
* - filters.role: The role to check if the user is in that role
|
|
52
|
+
*/
|
|
53
|
+
async userIsInRole(params) {
|
|
54
|
+
this.logger.trace(params, 'SecurityRepository::userIsInRole started with params');
|
|
55
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
56
|
+
const result = await userIsInRole(novaDataSource, params, this.logger);
|
|
57
|
+
this.logger.trace({ result }, 'SecurityRepository::userIsInRole result');
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether the user is admin or owner
|
|
62
|
+
* @param {UserIsAdminOrOwnerParams} params containing information to know if the user is admin or owner
|
|
63
|
+
* - filters.userId: The user id
|
|
64
|
+
*/
|
|
65
|
+
async userIsAdminOrOwner(params) {
|
|
66
|
+
this.logger.trace(params, 'SecurityRepository::userIsAdminOrOwner started with params');
|
|
67
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
68
|
+
const result = await userIsAdminOrOwner(novaDataSource, params, this.logger);
|
|
69
|
+
this.logger.trace({ result }, 'SecurityRepository::userIsAdminOrOwner result');
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Create user role
|
|
74
|
+
* @param {CreateUserRoleParams} params containing information to create user role
|
|
75
|
+
* - userId: The user id
|
|
76
|
+
* - clientId: The client id
|
|
77
|
+
* - roleId: The role to assign to the user
|
|
78
|
+
*/
|
|
79
|
+
async createUserRole(params) {
|
|
80
|
+
this.logger.trace(params, 'SecurityRepository::createUserRole started with params');
|
|
81
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
82
|
+
const result = await createUserRole(novaDataSource, params, this.logger);
|
|
83
|
+
this.logger.trace(result, 'SecurityRepository::createUserRole result');
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update user role
|
|
88
|
+
* @param {UpdateUserRoleParams} params containing information to update user role
|
|
89
|
+
* - filters.userId: The user id to update role
|
|
90
|
+
* - values.roleId: The role to assign to the user
|
|
91
|
+
*/
|
|
92
|
+
async updateUserRole(params) {
|
|
93
|
+
this.logger.trace(params, 'SecurityRepository::updateUserRole started with params');
|
|
94
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
95
|
+
const result = await updateUserRole(novaDataSource, params, this.logger);
|
|
96
|
+
this.logger.trace({ result }, 'SecurityRepository::updateUserRole result');
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Remove user roles
|
|
101
|
+
* @param {RemoveUserRolesParams} params containing information to remove user roles
|
|
102
|
+
* - filters.userId: The user id to remove roles from
|
|
103
|
+
*/
|
|
104
|
+
async removeUserRoles(params) {
|
|
105
|
+
this.logger.trace(params, 'SecurityRepository::removeUserRoles started with params');
|
|
106
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
107
|
+
const result = await removeUserRoles(novaDataSource, params, this.logger);
|
|
108
|
+
this.logger.trace({ result }, 'SecurityRepository::removeUserRoles result');
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const removeUserRoles = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.userId) {
|
|
5
|
+
logger.warn({ params }, 'SecurityRepository::removeUserRoles - missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
10
|
+
const userRoles = await userSecurityRolesRepository.find({
|
|
11
|
+
where: {
|
|
12
|
+
userId: uuidStringToBinaryBuffer(params.filters.userId),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
if (!userRoles.length) {
|
|
16
|
+
return true; // nothing to remove
|
|
17
|
+
}
|
|
18
|
+
await userSecurityRolesRepository.remove(userRoles);
|
|
19
|
+
return true;
|
|
20
|
+
}, 'SecurityRepository::removeUserRoles');
|
|
21
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const updateUserRole = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.userId) {
|
|
5
|
+
logger.warn({ params }, 'SecurityRepository::updateUserRole - missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
10
|
+
const userId = uuidStringToBinaryBuffer(params.filters.userId);
|
|
11
|
+
const userRole = await userSecurityRolesRepository.findOne({
|
|
12
|
+
where: {
|
|
13
|
+
userId,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
if (!userRole) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
if (userRole.securityRoleId === params.values.roleId) {
|
|
20
|
+
return true; // nothing to update
|
|
21
|
+
}
|
|
22
|
+
const oldRoleId = userRole.securityRoleId;
|
|
23
|
+
userRole.securityRoleId = params.values.roleId;
|
|
24
|
+
const result = await userSecurityRolesRepository.update({ userId, securityRoleId: oldRoleId }, userRole);
|
|
25
|
+
return result.affected > 0;
|
|
26
|
+
}, 'SecurityRepository::updateUserRole');
|
|
27
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { In } from 'typeorm';
|
|
2
|
+
import { UserSecurityRole } from '../../entities';
|
|
3
|
+
import { HapnSecurityRole } from '../../types/enums';
|
|
4
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
5
|
+
export const userIsAdminOrOwner = async (novaDataSource, params, logger) => {
|
|
6
|
+
if (!params?.filters?.userId) {
|
|
7
|
+
logger.warn({ params }, 'SecurityRepository::userIsAdminOrOwner - missing required parameters');
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
11
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
12
|
+
const userRole = await userSecurityRolesRepository.findOne({
|
|
13
|
+
where: {
|
|
14
|
+
userId: uuidStringToBinaryBuffer(params.filters.userId),
|
|
15
|
+
securityRoleId: In([HapnSecurityRole.Admin, HapnSecurityRole.Owner]),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
return userRole !== null;
|
|
19
|
+
}, 'SecurityRepository::userIsAdminOrOwner');
|
|
20
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { UserSecurityRole } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const userIsInRole = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.userId) {
|
|
5
|
+
logger.warn({ params }, 'SecurityRepository::userIsInRole - missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
9
|
+
const userSecurityRolesRepository = dataSource.getRepository(UserSecurityRole);
|
|
10
|
+
const userRole = await userSecurityRolesRepository.findOne({
|
|
11
|
+
where: {
|
|
12
|
+
userId: uuidStringToBinaryBuffer(params.filters.userId),
|
|
13
|
+
securityRoleId: params.filters.role,
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
return userRole !== null;
|
|
17
|
+
}, 'SecurityRepository::userIsInRole');
|
|
18
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { DeviceTask, TaskSchedule } from '../../entities';
|
|
2
|
+
export const addTaskScheduleDevices = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.taskScheduleId || !params?.imeis?.length) {
|
|
4
|
+
logger.error('TasksRepository::addTaskScheduleDevices - missing required parameters');
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const taskSchedulesRepository = dataSource.getRepository(TaskSchedule);
|
|
9
|
+
const existentTaskSchedule = await taskSchedulesRepository.findOne({
|
|
10
|
+
where: { id: params.taskScheduleId },
|
|
11
|
+
});
|
|
12
|
+
if (!existentTaskSchedule) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const deviceTaskRepository = dataSource.getRepository(DeviceTask);
|
|
16
|
+
// We split the devices in groups of 50 to avoid having a query with too many items to insert
|
|
17
|
+
const maxDevicesPerQuery = 50;
|
|
18
|
+
const partitionedImeis = [];
|
|
19
|
+
for (let i = 0; i < params.imeis.length; i += maxDevicesPerQuery) {
|
|
20
|
+
partitionedImeis.push(params.imeis.slice(i, i + maxDevicesPerQuery));
|
|
21
|
+
}
|
|
22
|
+
for (const imeis of partitionedImeis) {
|
|
23
|
+
const deviceTasks = imeis.map(imei => ({
|
|
24
|
+
taskScheduleId: params.taskScheduleId,
|
|
25
|
+
imei,
|
|
26
|
+
clientId: existentTaskSchedule.clientId,
|
|
27
|
+
}));
|
|
28
|
+
const result = await deviceTaskRepository.upsert(deviceTasks, {
|
|
29
|
+
conflictPaths: ['taskScheduleId', 'imei'],
|
|
30
|
+
});
|
|
31
|
+
if (!result?.raw?.affectedRows) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return true;
|
|
36
|
+
}, 'TasksRepository::addTaskScheduleDevices');
|
|
37
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Task } from '../../entities';
|
|
2
|
+
export const completeTask = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.id || !params?.completedBy) {
|
|
4
|
+
logger.warn({ params }, 'TasksRepository::completeTask missing required parameters');
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const taskRepository = dataSource.getRepository(Task);
|
|
9
|
+
const now = new Date();
|
|
10
|
+
const result = await taskRepository
|
|
11
|
+
.createQueryBuilder()
|
|
12
|
+
.update(Task)
|
|
13
|
+
.set({
|
|
14
|
+
status: 'completed',
|
|
15
|
+
completedBy: params.completedBy,
|
|
16
|
+
completedAt: now,
|
|
17
|
+
completionNotes: params.completionNotes,
|
|
18
|
+
completionOdometer: params.completionOdometer,
|
|
19
|
+
completionActiveHours: params.completionActiveHours,
|
|
20
|
+
})
|
|
21
|
+
.where('id = :id', { id: params.id })
|
|
22
|
+
.execute();
|
|
23
|
+
return result.affected > 0;
|
|
24
|
+
}, 'TasksRepository::completeTask');
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Task } from '../../entities';
|
|
2
|
+
export const createTask = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.taskScheduleId || !params?.imei || !params?.clientId) {
|
|
4
|
+
logger.warn({ params }, 'TasksRepository::createTask missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
if (!params.dueDate && !params.dueOdometer && !params.dueActiveHours) {
|
|
8
|
+
logger.warn({ params }, 'TasksRepository::createTask missing required parameters');
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
12
|
+
const tasksRepository = dataSource.getRepository(Task);
|
|
13
|
+
const now = new Date();
|
|
14
|
+
const newTask = {
|
|
15
|
+
...params,
|
|
16
|
+
createdAt: now,
|
|
17
|
+
status: 'pending',
|
|
18
|
+
};
|
|
19
|
+
const result = await tasksRepository.save(newTask);
|
|
20
|
+
return result;
|
|
21
|
+
}, 'TasksRepository::createTask');
|
|
22
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TaskSchedule } from '../../entities';
|
|
2
|
+
export const createTaskSchedule = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.clientId ||
|
|
4
|
+
!params?.title ||
|
|
5
|
+
!params?.description ||
|
|
6
|
+
params?.repeats == null ||
|
|
7
|
+
!params?.createdBy) {
|
|
8
|
+
logger.warn({ params }, 'TasksRepository::createTaskSchedule missing required parameters');
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
if (!params.repeats && !params.dueDate && !params.dueOdometer && !params.dueActiveHours) {
|
|
12
|
+
logger.warn({ params }, 'TasksRepository::createTaskSchedule missing required parameters');
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
if (params.repeats &&
|
|
16
|
+
!params.intervalDays &&
|
|
17
|
+
!params.intervalOdometer &&
|
|
18
|
+
!params.intervalActiveHours) {
|
|
19
|
+
logger.warn({ params }, 'TasksRepository::createTaskSchedule missing required parameters');
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
23
|
+
const taskScheduleRepository = dataSource.getRepository(TaskSchedule);
|
|
24
|
+
const now = new Date();
|
|
25
|
+
const newTaskSchedule = {
|
|
26
|
+
...params,
|
|
27
|
+
createdAt: now,
|
|
28
|
+
status: 'active',
|
|
29
|
+
};
|
|
30
|
+
const result = await taskScheduleRepository.save(newTaskSchedule);
|
|
31
|
+
return result;
|
|
32
|
+
}, 'TasksRepository::createTaskSchedule');
|
|
33
|
+
};
|