@spytecgps/nova-orm 0.0.224 → 0.0.225
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 +110 -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
|
+
export class addLowerCaseIndex1684483704434 {
|
|
2
|
+
async up(queryRunner) {
|
|
3
|
+
await queryRunner.query('ALTER TABLE `client` ADD KEY `ixClientEmailLower` ((lower(`email`)))');
|
|
4
|
+
await queryRunner.query('ALTER TABLE `device` ADD KEY `ixDeviceImeiLower` ((lower(`imei`)))');
|
|
5
|
+
await queryRunner.query('ALTER TABLE `user` ADD KEY `ixUserEmailLower` ((lower(`email`)))');
|
|
6
|
+
await queryRunner.query('ALTER TABLE `user` ADD KEY `ixUserNameLower` ((lower(`userName`)))');
|
|
7
|
+
await queryRunner.query('ALTER TABLE `user` ADD KEY `ixPreferredUserNameLower` ((lower(`preferredUserName`)))');
|
|
8
|
+
}
|
|
9
|
+
async down(queryRunner) {
|
|
10
|
+
await queryRunner.query('ALTER TABLE `client` DROP KEY `ixClientEmailLower`');
|
|
11
|
+
await queryRunner.query('ALTER TABLE `device` DROP KEY `ixDeviceImeiLower`');
|
|
12
|
+
await queryRunner.query('ALTER TABLE `user` DROP KEY `ixUserEmailLower`');
|
|
13
|
+
await queryRunner.query('ALTER TABLE `user` DROP KEY `ixUserNameLower`');
|
|
14
|
+
await queryRunner.query('ALTER TABLE `user` DROP KEY `ixPreferredUserNameLower`');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { DataSource, } from 'typeorm';
|
|
2
|
+
import { Entities } from '.';
|
|
3
|
+
import * as Subscribers from './subscribers';
|
|
4
|
+
import { QueryLogger } from './utils/queryLogger';
|
|
5
|
+
export class NovaDataSource {
|
|
6
|
+
dataSource;
|
|
7
|
+
logger;
|
|
8
|
+
constructor(config, logger) {
|
|
9
|
+
this.logger = logger;
|
|
10
|
+
const entities = [];
|
|
11
|
+
for (const key in Entities) {
|
|
12
|
+
if (Entities.hasOwnProperty(key)) {
|
|
13
|
+
const entity = Entities[key];
|
|
14
|
+
entities.push(entity);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const subscribers = [];
|
|
18
|
+
for (const key in Subscribers) {
|
|
19
|
+
if (Subscribers.hasOwnProperty(key)) {
|
|
20
|
+
const subscriber = Subscribers[key];
|
|
21
|
+
subscribers.push(subscriber);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
this.dataSource = new DataSource({
|
|
25
|
+
type: 'mysql',
|
|
26
|
+
host: 'aws.connect.psdb.cloud',
|
|
27
|
+
port: 3306,
|
|
28
|
+
database: 'nova',
|
|
29
|
+
ssl: {
|
|
30
|
+
rejectUnauthorized: true,
|
|
31
|
+
},
|
|
32
|
+
synchronize: false,
|
|
33
|
+
logging: true,
|
|
34
|
+
logger: new QueryLogger(this.logger, config.logging),
|
|
35
|
+
entities,
|
|
36
|
+
subscribers,
|
|
37
|
+
supportBigNumbers: true,
|
|
38
|
+
bigNumberStrings: false,
|
|
39
|
+
extra: {
|
|
40
|
+
decimalNumbers: true,
|
|
41
|
+
},
|
|
42
|
+
...config,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Performs connection to the database.
|
|
47
|
+
*/
|
|
48
|
+
async connect() {
|
|
49
|
+
await this.dataSource.initialize();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Closes connection with the database.
|
|
53
|
+
* Once connection is closed, you cannot use repositories or perform any operations except opening connection again.
|
|
54
|
+
*/
|
|
55
|
+
async disconnect() {
|
|
56
|
+
try {
|
|
57
|
+
if (this.dataSource.isInitialized) {
|
|
58
|
+
await this.dataSource.destroy();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.logger.error({ error }, 'Failed to close connection to database');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets repository for the given entity.
|
|
67
|
+
*/
|
|
68
|
+
getRepository(target) {
|
|
69
|
+
return this.dataSource.getRepository(target);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Executes raw SQL query and returns raw database results.
|
|
73
|
+
*/
|
|
74
|
+
async query(query, parameters) {
|
|
75
|
+
return this.dataSource.query(query, parameters, null);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Creates a new query builder that can be used to build a SQL query.
|
|
79
|
+
*/
|
|
80
|
+
async createQueryBuilder(entityClass, alias) {
|
|
81
|
+
return this.dataSource.createQueryBuilder(entityClass, alias, null);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a query runner used for perform queries on a single database connection.
|
|
85
|
+
* Using query runners you can control your queries to execute using single database connection and
|
|
86
|
+
* manually control your database transaction.
|
|
87
|
+
*
|
|
88
|
+
* Mode is used in replication mode and indicates whatever you want to connect
|
|
89
|
+
* to master database or any of slave databases.
|
|
90
|
+
* If you perform writes you must use master database,
|
|
91
|
+
* if you perform reads you can use slave databases.
|
|
92
|
+
*/
|
|
93
|
+
createQueryRunner(mode) {
|
|
94
|
+
return this.dataSource.createQueryRunner(mode);
|
|
95
|
+
}
|
|
96
|
+
async safeQuery(queryBuilderHandler, tag) {
|
|
97
|
+
try {
|
|
98
|
+
await this.connect();
|
|
99
|
+
const result = await queryBuilderHandler(this);
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.logger.error({ error }, tag ? tag + ' ' : '' + 'Error while executing query');
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
finally {
|
|
107
|
+
await this.disconnect();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AcumaticaImeiIccidData } from '../../entities';
|
|
2
|
+
export const getAcumaticaImeiIccidData = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.imei &&
|
|
4
|
+
params.filters.excludeNullAsin == null &&
|
|
5
|
+
params.filters.excludeNullCountyCode == null &&
|
|
6
|
+
!params.filters.excludeCountries?.length) {
|
|
7
|
+
logger.warn({ params }, 'AcumaticaRepository::getAcumaticaImeiIccidData - missing required parameters');
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
11
|
+
const acumaticaImeiIccidDataRepository = dataSource.getRepository(AcumaticaImeiIccidData);
|
|
12
|
+
const queryBuilder = acumaticaImeiIccidDataRepository.createQueryBuilder('acumaticaImeiIccidData');
|
|
13
|
+
if (params.filters.imei) {
|
|
14
|
+
queryBuilder.where('acumaticaImeiIccidData.imei = :imei', {
|
|
15
|
+
imei: params.filters.imei,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
if (params.filters.excludeNullAsin) {
|
|
19
|
+
queryBuilder.andWhere('acumaticaImeiIccidData.asin IS NOT NULL');
|
|
20
|
+
}
|
|
21
|
+
if (params.filters.excludeNullCountyCode) {
|
|
22
|
+
queryBuilder.andWhere('acumaticaImeiIccidData.countryCode IS NOT NULL');
|
|
23
|
+
}
|
|
24
|
+
if (params.filters.excludeCountries?.length) {
|
|
25
|
+
queryBuilder.andWhere('acumaticaImeiIccidData.countryCode NOT IN (:...excludeCountries)', {
|
|
26
|
+
excludeCountries: params.filters.excludeCountries,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (params.sortOptions?.sortField) {
|
|
30
|
+
queryBuilder.orderBy(`acumaticaImeiIccidData.${params.sortOptions.sortField}`, params.sortOptions.sortOrder === 'ASC' ? 'ASC' : 'DESC');
|
|
31
|
+
}
|
|
32
|
+
const result = await queryBuilder.getMany();
|
|
33
|
+
return result;
|
|
34
|
+
}, 'AcumaticaRepository::getAcumaticaImeiIccidData');
|
|
35
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { AcumaticaAmazonProduct, AcumaticaImeiIccidData, AcumaticaOrderShipmentDetails, } from '../../entities';
|
|
2
|
+
export const getAcumaticaShipmentDetails = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.imeiList?.length) {
|
|
4
|
+
logger.warn({ params }, 'AcumaticaRepository::getAcumaticaShipmentDetails - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const acumaticaOrderShipmentDetailsRepository = dataSource.getRepository(AcumaticaOrderShipmentDetails);
|
|
9
|
+
const queryBuilder1 = acumaticaOrderShipmentDetailsRepository
|
|
10
|
+
.createQueryBuilder('acumaticaOrderShipmentDetails')
|
|
11
|
+
.where('acumaticaOrderShipmentDetails.imei IN (:imeiList)', {
|
|
12
|
+
imeiList: params.filters.imeiList,
|
|
13
|
+
})
|
|
14
|
+
.select([
|
|
15
|
+
'acumaticaOrderShipmentDetails.imei as imei',
|
|
16
|
+
'acumaticaOrderShipmentDetails.iccid as iccid',
|
|
17
|
+
`acumaticaOrderShipmentDetails.orderType as orderType`,
|
|
18
|
+
'acumaticaOrderShipmentDetails.shipmentDate as shipmentDate',
|
|
19
|
+
'NULL as reviewUrl',
|
|
20
|
+
'NULL as productUrl',
|
|
21
|
+
]);
|
|
22
|
+
const query1WithParams = queryBuilder1.getQueryAndParameters();
|
|
23
|
+
const acumaticaImeiIccidDataRepository = dataSource.getRepository(AcumaticaImeiIccidData);
|
|
24
|
+
const queryBuilder2 = acumaticaImeiIccidDataRepository
|
|
25
|
+
.createQueryBuilder('acumaticaImeiIccidData')
|
|
26
|
+
.leftJoin(AcumaticaAmazonProduct, 'acumaticaAmazonProduct', 'acumaticaAmazonProduct.asin = acumaticaImeiIccidData.asin')
|
|
27
|
+
.where('acumaticaImeiIccidData.imei IN (:imeiList)', {
|
|
28
|
+
imeiList: params.filters.imeiList,
|
|
29
|
+
})
|
|
30
|
+
.select([
|
|
31
|
+
'acumaticaImeiIccidData.imei as imei',
|
|
32
|
+
'acumaticaImeiIccidData.iccid as iccid',
|
|
33
|
+
`'AZ' as orderType`,
|
|
34
|
+
'acumaticaImeiIccidData.shipDate as shipmentDate',
|
|
35
|
+
'acumaticaAmazonProduct.reviewUrl as reviewUrl',
|
|
36
|
+
'acumaticaAmazonProduct.productUrl as productUrl',
|
|
37
|
+
]);
|
|
38
|
+
const query2WithParams = queryBuilder2.getQueryAndParameters();
|
|
39
|
+
const unionQueryParams = [...query1WithParams[1], ...query2WithParams[1]];
|
|
40
|
+
const result = await acumaticaOrderShipmentDetailsRepository.query(`(${query1WithParams[0]}) UNION (${query2WithParams[0]})`, unionQueryParams);
|
|
41
|
+
return result.map(item => ({
|
|
42
|
+
imei: item.imei,
|
|
43
|
+
iccid: item.iccid,
|
|
44
|
+
shipmentDate: item.shipmentDate instanceof Date ? item.shipmentDate : new Date(item.shipmentDate),
|
|
45
|
+
orderType: item.orderType,
|
|
46
|
+
reviewUrl: item.reviewUrl,
|
|
47
|
+
productUrl: item.productUrl,
|
|
48
|
+
}));
|
|
49
|
+
}, 'AcumaticaRepository::getAcumaticaShipmentDetails');
|
|
50
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AcumaticaImeiIccidData, Device } from '../../entities';
|
|
2
|
+
export const getLastAcumaticaShipmentDetails = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId) {
|
|
4
|
+
logger.warn({ params }, 'AcumaticaRepository::getLastAcumaticaShipmentDetails - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const acumaticaImeiIccidDataRepository = dataSource.getRepository(AcumaticaImeiIccidData);
|
|
9
|
+
const queryBuilder = acumaticaImeiIccidDataRepository
|
|
10
|
+
.createQueryBuilder('acumaticaImeiIccidData')
|
|
11
|
+
.innerJoin(Device, 'device', 'device.imei = acumaticaImeiIccidData.imei')
|
|
12
|
+
.where('device.clientId = :clientId', { clientId: params.filters.clientId })
|
|
13
|
+
.orderBy('acumaticaImeiIccidData.shipDate', 'DESC')
|
|
14
|
+
.limit(1);
|
|
15
|
+
const result = await queryBuilder.getOne();
|
|
16
|
+
return result
|
|
17
|
+
? {
|
|
18
|
+
imei: result.imei,
|
|
19
|
+
iccid: result.iccid,
|
|
20
|
+
shipmentDate: new Date(result.shipDate),
|
|
21
|
+
orderType: 'AZ',
|
|
22
|
+
reviewUrl: null,
|
|
23
|
+
productUrl: null,
|
|
24
|
+
}
|
|
25
|
+
: null;
|
|
26
|
+
}, 'AcumaticaRepository::getLastAcumaticaShipmentDetails');
|
|
27
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { getAcumaticaImeiIccidData } from './getAcumaticaImeiIccidData';
|
|
4
|
+
import { getAcumaticaShipmentDetails } from './getAcumaticaShipmentDetails';
|
|
5
|
+
import { getLastAcumaticaShipmentDetails } from './getLastAcumaticaShipmentDetails';
|
|
6
|
+
export class AcumaticaRepository extends BaseRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Get Acumatica IMEI/ICCID data
|
|
9
|
+
* @param params containing information to get magento plan
|
|
10
|
+
* One of the following filters is required:
|
|
11
|
+
* - params.filters.imei IMEI to filter by
|
|
12
|
+
* - params.filters.excludeNullAsin Exclude IMEI/ICCID data with null ASIN
|
|
13
|
+
* - params.filters.excludeNullCountyCode Exclude IMEI/ICCID data with null country code
|
|
14
|
+
* - params.filters.excludeCountries Exclude IMEI/ICCID data with country code in this list
|
|
15
|
+
* - params.sortOptions.sortField Sort field
|
|
16
|
+
* - params.sortOptions.sortOrder Sort order
|
|
17
|
+
* @returns Acumatica IMEI/ICCID data list
|
|
18
|
+
*/
|
|
19
|
+
async getAcumaticaImeiIccidData(params) {
|
|
20
|
+
this.logger.trace(params, `AcumaticaRepository::getAcumaticaImeiIccidData started with params`);
|
|
21
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
22
|
+
const result = await getAcumaticaImeiIccidData(novaDataSource, params, this.logger);
|
|
23
|
+
this.logger.trace(result, 'AcumaticaRepository::getAcumaticaImeiIccidData result');
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get last Acumatica shipment details
|
|
28
|
+
* @param params containing information to get last Acumatica shipment details
|
|
29
|
+
* - params.filters.clientId Client ID to filter by
|
|
30
|
+
* @returns last Amazon device shipment details
|
|
31
|
+
*/
|
|
32
|
+
async getLastAcumaticaShipmentDetails(params) {
|
|
33
|
+
this.logger.trace(params, `AcumaticaRepository::getLastAcumaticaShipmentDetails started with params`);
|
|
34
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
35
|
+
const result = await getLastAcumaticaShipmentDetails(novaDataSource, params, this.logger);
|
|
36
|
+
this.logger.trace(result, 'AcumaticaRepository::getLastAcumaticaShipmentDetails result');
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get Acumatica shipment details list
|
|
41
|
+
* @param params containing information to get Acumatica shipment details list
|
|
42
|
+
* - params.filters.imeiList IMEI list to filter by
|
|
43
|
+
* @returns Acumatica shipment details list
|
|
44
|
+
*/
|
|
45
|
+
async getAcumaticaShipmentDetails(params) {
|
|
46
|
+
this.logger.trace(params, `AcumaticaRepository::getAcumaticaShipmentDetails started with params`);
|
|
47
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
48
|
+
const result = await getAcumaticaShipmentDetails(novaDataSource, params, this.logger);
|
|
49
|
+
this.logger.trace(result, 'AcumaticaRepository::getAcumaticaShipmentDetails result');
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AempToken } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const createAempToken = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.clientId || !params?.token) {
|
|
5
|
+
logger.warn({ params }, 'AempTokenRepository::createAempToken - missing required parameters');
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const binaryBuffer = uuidStringToBinaryBuffer(params?.token);
|
|
9
|
+
if (!binaryBuffer?.length) {
|
|
10
|
+
logger.warn({ params }, 'AempTokenRepository::createAempToken - token should be a valid UUID');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
14
|
+
const aempTokensRepository = dataSource.getRepository(AempToken);
|
|
15
|
+
const now = new Date();
|
|
16
|
+
const newAempToken = {
|
|
17
|
+
id: params?.id,
|
|
18
|
+
clientId: params?.clientId,
|
|
19
|
+
token: binaryBuffer,
|
|
20
|
+
createdAt: now,
|
|
21
|
+
updatedAt: now,
|
|
22
|
+
expiresAt: params?.expiresAt,
|
|
23
|
+
};
|
|
24
|
+
return await aempTokensRepository.save(newAempToken);
|
|
25
|
+
}, 'AempTokenRepository::createAempToken');
|
|
26
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { AempToken } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const deleteAempTokens = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.id && !params?.filters?.clientId && !params?.filters?.token) {
|
|
5
|
+
logger.warn({ params }, 'AempTokenRepository::deleteAempTokens - missing required parameters');
|
|
6
|
+
return null;
|
|
7
|
+
}
|
|
8
|
+
const binaryBuffer = uuidStringToBinaryBuffer(params?.filters?.token);
|
|
9
|
+
if (params?.filters?.token && !binaryBuffer?.length) {
|
|
10
|
+
logger.warn({ params }, 'AempTokenRepository::deleteAempTokens - token should be a valid UUID');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
14
|
+
const AempTokensRepository = dataSource.getRepository(AempToken);
|
|
15
|
+
let queryBuilder = AempTokensRepository.createQueryBuilder().delete();
|
|
16
|
+
if (params.filters.id) {
|
|
17
|
+
queryBuilder = queryBuilder.where('id = :id', { id: params.filters.id });
|
|
18
|
+
}
|
|
19
|
+
if (params.filters.clientId) {
|
|
20
|
+
queryBuilder = queryBuilder.where('clientId = :clientId', {
|
|
21
|
+
clientId: params.filters.clientId,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
if (params.filters.token) {
|
|
25
|
+
queryBuilder = queryBuilder.where('token = :token', { token: binaryBuffer });
|
|
26
|
+
}
|
|
27
|
+
const result = await queryBuilder.execute();
|
|
28
|
+
return result.affected > 0;
|
|
29
|
+
}, 'AempTokenRepository::deleteAempTokens');
|
|
30
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AempToken } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const getAempTokens = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.clientId && !params?.filters?.token) {
|
|
5
|
+
logger.warn({ params }, 'AempTokenRepository::getAempTokens - missing required parameters');
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const tokenBinaryBuffer = uuidStringToBinaryBuffer(params?.filters?.token);
|
|
9
|
+
if (params?.filters?.token && !tokenBinaryBuffer?.length) {
|
|
10
|
+
logger.warn({ params }, 'AempTokenRepository::getClientIdForToken - token should be a valid UUID');
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
14
|
+
const AempTokensRepository = dataSource.getRepository(AempToken);
|
|
15
|
+
let queryBuilder = AempTokensRepository.createQueryBuilder('AempToken');
|
|
16
|
+
if (params?.filters?.clientId) {
|
|
17
|
+
queryBuilder = queryBuilder.where('AempToken.clientId = :clientId', {
|
|
18
|
+
clientId: params?.filters?.clientId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (params?.filters?.token) {
|
|
22
|
+
queryBuilder = queryBuilder.where('AempToken.token = :token', { token: tokenBinaryBuffer });
|
|
23
|
+
}
|
|
24
|
+
const result = await queryBuilder.getMany();
|
|
25
|
+
return result;
|
|
26
|
+
}, 'AempTokenRepository::getAempTokens');
|
|
27
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createAempToken } from './createAempToken';
|
|
4
|
+
import { deleteAempTokens } from './deleteAempTokens';
|
|
5
|
+
import { getAempTokens } from './getAempTokens';
|
|
6
|
+
export class AempTokenRepository extends BaseRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Get AMP tokens by client ID
|
|
9
|
+
* @param params - GetAempTokensParams
|
|
10
|
+
* One of the following is required:
|
|
11
|
+
* - filters.clientId: The client id
|
|
12
|
+
* - filters.token: The token
|
|
13
|
+
* @returns AempToken[]
|
|
14
|
+
*/
|
|
15
|
+
async getAempTokens(params) {
|
|
16
|
+
this.logger.trace(params, 'AempTokenRepository::getAempTokens started with params');
|
|
17
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
18
|
+
const result = await getAempTokens(novaDataSource, params, this.logger);
|
|
19
|
+
this.logger.trace(result, 'AempTokenRepository::getAempTokens result');
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Create an AMP token
|
|
24
|
+
* @param params - CreateAempTokenParams
|
|
25
|
+
* - clientId: The client id, required
|
|
26
|
+
* - token: The token, required
|
|
27
|
+
* - expiresAt: The expiration date, optional
|
|
28
|
+
* @returns AempToken
|
|
29
|
+
*/
|
|
30
|
+
async createAempToken(params) {
|
|
31
|
+
this.logger.trace(params, 'AempTokenRepository::createAempToken started with params');
|
|
32
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
33
|
+
const result = await createAempToken(novaDataSource, params, this.logger);
|
|
34
|
+
this.logger.trace(result, 'AempTokenRepository::createAempToken result');
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Delete AMP tokens
|
|
39
|
+
* @param params - DeleteAempTokensParams
|
|
40
|
+
* One of the following is required:
|
|
41
|
+
* - filters.id: The id
|
|
42
|
+
* - filters.clientId: The client id
|
|
43
|
+
* - filters.token: The token
|
|
44
|
+
* @returns True if the token was deleted, false otherwise
|
|
45
|
+
*/
|
|
46
|
+
async deleteAempTokens(params) {
|
|
47
|
+
this.logger.trace(params, 'AempTokenRepository::deleteAempTokens started with params');
|
|
48
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
49
|
+
const result = await deleteAempTokens(novaDataSource, params, this.logger);
|
|
50
|
+
this.logger.trace({ result }, 'AempTokenRepository::deleteAempTokens result');
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AlertType } from '../../entities';
|
|
2
|
+
export const getAlertTypes = async (novaDataSource, params) => {
|
|
3
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
4
|
+
const alertTypesRepository = dataSource.getRepository(AlertType);
|
|
5
|
+
let queryBuilder = alertTypesRepository.createQueryBuilder('alertType');
|
|
6
|
+
const includeBeta = params?.filters?.includeBeta ?? false;
|
|
7
|
+
if (!includeBeta) {
|
|
8
|
+
queryBuilder = queryBuilder.where(`alertType.stage = 'prod'`);
|
|
9
|
+
}
|
|
10
|
+
const result = await queryBuilder.getMany();
|
|
11
|
+
return result;
|
|
12
|
+
}, 'AlertTypesRepository::getAlertTypes');
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { getAlertTypes } from './getAlertTypes';
|
|
4
|
+
export class AlertTypesRepository extends BaseRepository {
|
|
5
|
+
/*
|
|
6
|
+
* Get alert types
|
|
7
|
+
* @param {GetAlertTypesParams} params containing information to get alert types
|
|
8
|
+
* - filters.includeBeta: Whether to include beta alert types, optional. If not provided, defaults to false
|
|
9
|
+
* @returns The alert types list
|
|
10
|
+
*/
|
|
11
|
+
async getAlertTypes(params) {
|
|
12
|
+
this.logger.trace(params, 'AlertTypesRepository::getAlertTypes started with params');
|
|
13
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
14
|
+
const result = await getAlertTypes(novaDataSource, params);
|
|
15
|
+
this.logger.trace(result, 'AlertTypesRepository::getAlertTypes result');
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Alert } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const createAlert = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.clientId ||
|
|
5
|
+
params.clientId === 0 ||
|
|
6
|
+
!params?.alertTypeId ||
|
|
7
|
+
params.alertTypeId === 0 ||
|
|
8
|
+
!params?.messageId ||
|
|
9
|
+
!params?.imei ||
|
|
10
|
+
!params?.sendTime) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
await novaDataSource.connect();
|
|
15
|
+
const alertRepository = novaDataSource.getRepository(Alert);
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const newAlert = {
|
|
18
|
+
id: params.id,
|
|
19
|
+
alertTypeId: params.alertTypeId,
|
|
20
|
+
value: params.value,
|
|
21
|
+
userId: uuidStringToBinaryBuffer(params.userId),
|
|
22
|
+
messageId: uuidStringToBinaryBuffer(params.messageId),
|
|
23
|
+
imei: params.imei,
|
|
24
|
+
sendTime: params.sendTime,
|
|
25
|
+
lat: params.lat,
|
|
26
|
+
lon: params.lon,
|
|
27
|
+
address: params.address,
|
|
28
|
+
clientId: params.clientId,
|
|
29
|
+
isBuffer: params.isBuffer,
|
|
30
|
+
isNotification: params.isNotification,
|
|
31
|
+
gpsUtcTime: params.gpsUtcTime,
|
|
32
|
+
relevantAddress: params.relevantAddress,
|
|
33
|
+
gpsMessageId: uuidStringToBinaryBuffer(params.gpsMessageId),
|
|
34
|
+
cellTowerRelevantAddress: params.cellTowerRelevantAddress,
|
|
35
|
+
createdAt: params.createdAt ?? now,
|
|
36
|
+
};
|
|
37
|
+
return await alertRepository.save(newAlert);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
logger.error(error, 'AlertRepository::createAlert error');
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
finally {
|
|
44
|
+
await novaDataSource.disconnect();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export const createAlerts = async (novaDataSource, params, logger) => {
|
|
48
|
+
try {
|
|
49
|
+
await novaDataSource.connect();
|
|
50
|
+
const alertRepository = novaDataSource.getRepository(Alert);
|
|
51
|
+
const alerts = [];
|
|
52
|
+
params.forEach(param => {
|
|
53
|
+
if (!param?.clientId ||
|
|
54
|
+
param.clientId === 0 ||
|
|
55
|
+
!param?.alertTypeId ||
|
|
56
|
+
param.alertTypeId === 0 ||
|
|
57
|
+
!param?.messageId ||
|
|
58
|
+
!param?.imei ||
|
|
59
|
+
!param?.sendTime) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
const now = new Date();
|
|
63
|
+
const newAlert = {
|
|
64
|
+
id: param.id,
|
|
65
|
+
alertTypeId: param.alertTypeId,
|
|
66
|
+
value: param.value,
|
|
67
|
+
userId: uuidStringToBinaryBuffer(param.userId),
|
|
68
|
+
messageId: uuidStringToBinaryBuffer(param.messageId),
|
|
69
|
+
imei: param.imei,
|
|
70
|
+
sendTime: param.sendTime,
|
|
71
|
+
lat: param.lat,
|
|
72
|
+
lon: param.lon,
|
|
73
|
+
address: param.address,
|
|
74
|
+
clientId: param.clientId,
|
|
75
|
+
isBuffer: param.isBuffer,
|
|
76
|
+
isNotification: param.isNotification,
|
|
77
|
+
gpsUtcTime: param.gpsUtcTime,
|
|
78
|
+
relevantAddress: param.relevantAddress,
|
|
79
|
+
gpsMessageId: uuidStringToBinaryBuffer(param.gpsMessageId),
|
|
80
|
+
cellTowerRelevantAddress: param.cellTowerRelevantAddress,
|
|
81
|
+
createdAt: param.createdAt ?? now,
|
|
82
|
+
};
|
|
83
|
+
alerts.push(newAlert);
|
|
84
|
+
});
|
|
85
|
+
return await alertRepository.save(alerts);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
logger.error(error, 'AlertRepository::createAlert error');
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
await novaDataSource.disconnect();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UserAlertComplain } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const createUserAlertComplain = async (novaDataSource, params) => {
|
|
4
|
+
if (!params?.clientId ||
|
|
5
|
+
params.clientId === 0 ||
|
|
6
|
+
!params?.alertTypeId ||
|
|
7
|
+
params.alertTypeId === 0 ||
|
|
8
|
+
!params?.userId ||
|
|
9
|
+
!params?.email ||
|
|
10
|
+
!params?.reason) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
14
|
+
const alertComplaintRepository = dataSource.getRepository(UserAlertComplain);
|
|
15
|
+
const now = new Date();
|
|
16
|
+
const newUserAlertComplaint = {
|
|
17
|
+
alertTypeId: params.alertTypeId,
|
|
18
|
+
userId: uuidStringToBinaryBuffer(params.userId),
|
|
19
|
+
clientId: params.clientId,
|
|
20
|
+
createdAt: params.createdAt ?? now,
|
|
21
|
+
email: params.email,
|
|
22
|
+
reason: params.reason,
|
|
23
|
+
};
|
|
24
|
+
return await alertComplaintRepository.save(newUserAlertComplaint);
|
|
25
|
+
}, 'AlertRepository::createUserAlertComplain');
|
|
26
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Alert } from '../../entities';
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated The method should not be used
|
|
4
|
+
*/
|
|
5
|
+
export const getAlertsReportByClient = async (novaDataSource, params, logger) => {
|
|
6
|
+
if (!params.filters.clientId) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
await novaDataSource.connect();
|
|
11
|
+
const alertRepository = novaDataSource.getRepository(Alert);
|
|
12
|
+
const alertQuery = alertRepository
|
|
13
|
+
.createQueryBuilder('a')
|
|
14
|
+
.where('a.clientId = :clientId', { clientId: params.filters.clientId });
|
|
15
|
+
if (params.filters.imei) {
|
|
16
|
+
alertQuery.andWhere('a.imei = :imei', { imei: params.filters.imei });
|
|
17
|
+
}
|
|
18
|
+
if (params.filters.alertTypeId) {
|
|
19
|
+
alertQuery.andWhere('a.alertTypeId = :alertTypeId', {
|
|
20
|
+
alertTypeId: params.filters.alertTypeId,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
if (params.filters.sendTimeFrom) {
|
|
24
|
+
alertQuery.andWhere('a.sendTime >= :sendTimeFrom', {
|
|
25
|
+
sendTimeFrom: params.filters.sendTimeFrom,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (params.filters.sendTimeTo) {
|
|
29
|
+
alertQuery.andWhere('a.sendTime <= :sendTimeTo', {
|
|
30
|
+
sendTimeTo: params.filters.sendTimeTo,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//get first the total count of the query without the paging
|
|
34
|
+
const totalCount = await alertQuery.getCount();
|
|
35
|
+
if (params.sortOptions?.sortField) {
|
|
36
|
+
alertQuery.orderBy(params.sortOptions.sortField, params.sortOptions.sortOrder);
|
|
37
|
+
}
|
|
38
|
+
const alerts = await alertQuery
|
|
39
|
+
.select([
|
|
40
|
+
'a.id as id',
|
|
41
|
+
'a.alertTypeId as alertTypeId',
|
|
42
|
+
'a.value as value',
|
|
43
|
+
'a.createdAt as createdAt',
|
|
44
|
+
'a.userId as userId',
|
|
45
|
+
'a.messageId as messageId',
|
|
46
|
+
'a.imei as imei',
|
|
47
|
+
'a.sendTime as sendTime',
|
|
48
|
+
'a.lat as lat',
|
|
49
|
+
'a.lon as lon',
|
|
50
|
+
'a.address as address',
|
|
51
|
+
`${totalCount} as totalCount`,
|
|
52
|
+
])
|
|
53
|
+
.limit(params.pagingOptions.pageSize)
|
|
54
|
+
.offset(params.pagingOptions.pageSize * (params.pagingOptions.pageIndex - 1))
|
|
55
|
+
.getRawMany();
|
|
56
|
+
return alerts;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
logger.error(error, 'AlertRepository::getAlertsReportByClient error');
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
await novaDataSource.disconnect();
|
|
64
|
+
}
|
|
65
|
+
};
|