@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,127 @@
|
|
|
1
|
+
import { Alert, AlertType } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const getAlertsReportByUser = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.filters?.userId) {
|
|
5
|
+
logger.warn({ params }, 'AlertRepository::getAlertsReportByUser - missing required parameters');
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
const userIdBinaryBuffer = uuidStringToBinaryBuffer(params?.filters?.userId);
|
|
9
|
+
if (!userIdBinaryBuffer?.length) {
|
|
10
|
+
logger.warn({ params }, 'AlertRepository::getAlertsReportByUser - user id should be a valid UUID');
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
await novaDataSource.connect();
|
|
15
|
+
const alertRepository = novaDataSource.getRepository(Alert);
|
|
16
|
+
const alertQuery = alertRepository
|
|
17
|
+
.createQueryBuilder('a')
|
|
18
|
+
.innerJoin('a.alertType', 'aty')
|
|
19
|
+
.where('a.userId = :userId', { userId: uuidStringToBinaryBuffer(params.filters.userId) });
|
|
20
|
+
// When is test environment, we want to show all alerts including the ones with stage = test
|
|
21
|
+
if (params.filters.isTestEnvironment) {
|
|
22
|
+
alertQuery.andWhere('( aty.stage = :stage_test or aty.stage = :stage )', {
|
|
23
|
+
stage: 'prod',
|
|
24
|
+
stage_test: 'test',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else
|
|
28
|
+
alertQuery.andWhere('aty.stage = :stage', { stage: 'prod' });
|
|
29
|
+
if (params.filters.imeis?.length) {
|
|
30
|
+
alertQuery.andWhere('a.imei IN (:...imeis)', { imeis: params.filters.imeis });
|
|
31
|
+
}
|
|
32
|
+
if (params.filters.clientId) {
|
|
33
|
+
alertQuery.andWhere('a.clientId = :clientId', { clientId: params.filters.clientId });
|
|
34
|
+
}
|
|
35
|
+
let alertTypeIds = params.filters.alertTypeIds;
|
|
36
|
+
if (!alertTypeIds?.length && params.filters.alertTypeNames?.length) {
|
|
37
|
+
const alertTypesRepo = novaDataSource.getRepository(AlertType);
|
|
38
|
+
const filteredAlertTypesIds = await alertTypesRepo
|
|
39
|
+
.createQueryBuilder('aty')
|
|
40
|
+
.where('LOWER(aty.name) IN (:...alertTypeNames)', {
|
|
41
|
+
alertTypeNames: params.filters.alertTypeNames.map(x => x.toLowerCase()),
|
|
42
|
+
})
|
|
43
|
+
.select('aty.id')
|
|
44
|
+
.getMany();
|
|
45
|
+
if (filteredAlertTypesIds?.length) {
|
|
46
|
+
alertTypeIds = filteredAlertTypesIds.map(x => x.id);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (alertTypeIds?.length) {
|
|
50
|
+
alertQuery.andWhere('a.alertTypeId IN (:alertTypeIds)', {
|
|
51
|
+
alertTypeIds,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
if (params.filters.boundaryId) {
|
|
55
|
+
alertQuery.andWhere('a.boundaryId = :boundaryId', {
|
|
56
|
+
boundaryId: params.filters.boundaryId,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
if (params.filters.sendTimeFrom) {
|
|
60
|
+
alertQuery.andWhere('a.sendTime >= :sendTimeFrom', {
|
|
61
|
+
sendTimeFrom: params.filters.sendTimeFrom,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (params.filters.sendTimeTo) {
|
|
65
|
+
alertQuery.andWhere('a.sendTime <= :sendTimeTo', {
|
|
66
|
+
sendTimeTo: params.filters.sendTimeTo,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (params.filters.createdFrom) {
|
|
70
|
+
alertQuery.andWhere('a.createdAt >= :createdFrom', {
|
|
71
|
+
createdFrom: params.filters.createdFrom,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (params.filters.createdTo) {
|
|
75
|
+
alertQuery.andWhere('a.createdAt <= :createdTo', {
|
|
76
|
+
createdTo: params.filters.createdTo,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
const subQuery = alertQuery.clone().select('COUNT(a.id)', 'totalCount');
|
|
80
|
+
if (params.filters.imeis?.length) {
|
|
81
|
+
alertQuery.useIndex('ixAlertUserId_Imei_AlertTypeId_SendTime');
|
|
82
|
+
subQuery.useIndex('ixAlertUserId_Imei_AlertTypeId_SendTime');
|
|
83
|
+
}
|
|
84
|
+
else if (alertTypeIds?.length) {
|
|
85
|
+
alertQuery.useIndex('ixAlertUserId_AlertTypeId_SendTime');
|
|
86
|
+
subQuery.useIndex('ixAlertUserId_AlertTypeId_SendTime');
|
|
87
|
+
}
|
|
88
|
+
alertQuery.innerJoin(`(${subQuery.getQuery()})`, 'sub');
|
|
89
|
+
if (params.sortOptions?.sortField) {
|
|
90
|
+
alertQuery.orderBy(params.sortOptions.sortField, params.sortOptions.sortOrder);
|
|
91
|
+
}
|
|
92
|
+
const alerts = await alertQuery
|
|
93
|
+
.select([
|
|
94
|
+
'a.id as id',
|
|
95
|
+
'a.alertTypeId as alertTypeId',
|
|
96
|
+
'aty.name as alertTypeName',
|
|
97
|
+
'a.value as value',
|
|
98
|
+
'a.createdAt as createdAt',
|
|
99
|
+
'a.userId as userId',
|
|
100
|
+
'a.clientId as clientId',
|
|
101
|
+
'a.messageId as messageId',
|
|
102
|
+
'a.boundaryId as boundaryId',
|
|
103
|
+
'a.imei as imei',
|
|
104
|
+
'a.sendTime as sendTime',
|
|
105
|
+
'a.lat as lat',
|
|
106
|
+
'a.lon as lon',
|
|
107
|
+
'a.address as address',
|
|
108
|
+
'a.isBuffer as isBuffer',
|
|
109
|
+
'a.isNotification as isNotification',
|
|
110
|
+
'a.gpsMessageId as gpsMessageId',
|
|
111
|
+
'a.gpsUTCTime as gpsUTCTime',
|
|
112
|
+
'aty.stage as stage',
|
|
113
|
+
`sub.totalCount as totalCount`,
|
|
114
|
+
])
|
|
115
|
+
.limit(params.pagingOptions.pageSize)
|
|
116
|
+
.offset(params.pagingOptions.pageSize * params.pagingOptions.pageIndex)
|
|
117
|
+
.getRawMany();
|
|
118
|
+
return alerts;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
logger.error(error, 'AlertRepository::getAlertsReportByUserId error');
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
await novaDataSource.disconnect();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createAlert, createAlerts } from './createAlert';
|
|
4
|
+
import { createUserAlertComplain } from './createUserAlertComplain';
|
|
5
|
+
import { getAlertsReportByUser } from './getAlertsReportByUser';
|
|
6
|
+
export class AlertRepository extends BaseRepository {
|
|
7
|
+
/** Create an alert record
|
|
8
|
+
* @param {CreateAlertParams} params containing information to create an alert
|
|
9
|
+
* id: The alert id. if null will be generated
|
|
10
|
+
* clientId: The client id of the owner of the device generating the alert
|
|
11
|
+
* deviceId: The device id of the device generating the alert
|
|
12
|
+
* alertTypeId: The alert type id
|
|
13
|
+
* value: The alert value
|
|
14
|
+
* userId: The user id of the user associated with the alert
|
|
15
|
+
* messageId: The message id of the message that generated the alert
|
|
16
|
+
* boundaryId: The boundary id of the boundary if the alert is related to a boundary
|
|
17
|
+
* imei: The imei of the device generating the alert
|
|
18
|
+
* sendTime: The time the alert was sent
|
|
19
|
+
* lat: The latitude of the device when the alert was generated
|
|
20
|
+
* lon: The longitude of the device when the alert was generated
|
|
21
|
+
* address: The address of the device when the alert was generated
|
|
22
|
+
* isBuffer: The is buffer flag
|
|
23
|
+
* isNotification: The is notification flag
|
|
24
|
+
* gpsUtcTime: The time the gps utc time was set
|
|
25
|
+
* relevantAddress: The relevant address
|
|
26
|
+
* gpsMessageId: The gps message id
|
|
27
|
+
* cellTowerRelevantAddress: The cell tower relevant address
|
|
28
|
+
*/
|
|
29
|
+
async createAlert(params) {
|
|
30
|
+
this.logger.trace(params, `AlertRepository::createAlert started with params`);
|
|
31
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
32
|
+
const result = await createAlert(novaDataSource, params, this.logger);
|
|
33
|
+
this.logger.trace(result, 'AlertRepository::createAlert result');
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
/** Create alert records
|
|
37
|
+
* @param {CreateAlertParams[]} params containing information to create alert records
|
|
38
|
+
* id: The alert id. if null will be generated
|
|
39
|
+
* clientId: The client id of the owner of the device generating the alert
|
|
40
|
+
* deviceId: The device id of the device generating the alert
|
|
41
|
+
* alertTypeId: The alert type id
|
|
42
|
+
* value: The alert value
|
|
43
|
+
* userId: The user id of the user associated with the alert
|
|
44
|
+
* messageId: The message id of the message that generated the alert
|
|
45
|
+
* boundaryId: The boundary id of the boundary if the alert is related to a boundary
|
|
46
|
+
* imei: The imei of the device generating the alert
|
|
47
|
+
* sendTime: The time the alert was sent
|
|
48
|
+
* lat: The latitude of the device when the alert was generated
|
|
49
|
+
* lon: The longitude of the device when the alert was generated
|
|
50
|
+
* address: The address of the device when the alert was generated
|
|
51
|
+
* isBuffer: The is buffer flag
|
|
52
|
+
* isNotification: The is notification flag
|
|
53
|
+
* gpsUtcTime: The time the gps utc time was set
|
|
54
|
+
* relevantAddress: The relevant address
|
|
55
|
+
* gpsMessageId: The gps message id
|
|
56
|
+
* cellTowerRelevantAddress: The cell tower relevant address
|
|
57
|
+
*/
|
|
58
|
+
async createAlerts(params) {
|
|
59
|
+
this.logger.trace(params, `AlertRepository::createAlerts started with params`);
|
|
60
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
61
|
+
const result = await createAlerts(novaDataSource, params, this.logger);
|
|
62
|
+
this.logger.trace(result, 'AlertRepository::createAlerts result');
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/** Get alerts report by user id
|
|
66
|
+
* @param {GetAlertReportByUserParams} params containing information to filter alerts report by user id
|
|
67
|
+
* params.filters.userId: The user id of the user associated with the alert
|
|
68
|
+
* params.filters.imeis: The imeis of the devices generating the alert
|
|
69
|
+
* params.filters.alertTypeId: The alert type id
|
|
70
|
+
* params.filters.boundaryId: The boundary id of the boundary if the alert is related to a boundary
|
|
71
|
+
* params.filters.sendTimeFrom: The time the alert was sent from
|
|
72
|
+
* params.filters.sendTimeTo: The time the alert was sent to
|
|
73
|
+
* params.pagingOptions.pageSize: The number of alerts to return
|
|
74
|
+
* params.pagingOptions.pageIndex: The page index of the alerts to return
|
|
75
|
+
* params.sortOptions.sortField: The field to sort the alerts by
|
|
76
|
+
* params.sortOptions.sortOrder: The order to sort the alerts by desc | asc
|
|
77
|
+
* @returns Promise<AlertReport[]>
|
|
78
|
+
*/
|
|
79
|
+
async getAlertsReportByUser(params) {
|
|
80
|
+
this.logger.trace(params, `AlertRepository::getAlertsReportByUserId started with params`);
|
|
81
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
82
|
+
const result = await getAlertsReportByUser(novaDataSource, params, this.logger);
|
|
83
|
+
this.logger.trace(result, 'AlertRepository::getAlertsReportByUserId result');
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Insert a new user alert complain
|
|
88
|
+
* @param {CreateUserAlertComplaintParams} params containing information to create a user alert complain
|
|
89
|
+
* params.alertTypeId: The alert type id that has been disabled
|
|
90
|
+
* params.userId: The user id of the user associated with the alert
|
|
91
|
+
* params.clientId: The client id of the owner of the device generating the alert
|
|
92
|
+
* params.email: The email of the user
|
|
93
|
+
* params.reason: The reason for disabling the alert
|
|
94
|
+
* params.createdAt: The datetime the complaint was received, it will default to now if not provided
|
|
95
|
+
* @returns {Promise<UserAlertComplain>} The created user alert complain
|
|
96
|
+
*/
|
|
97
|
+
async createUserAlertComplain(params) {
|
|
98
|
+
this.logger.trace(params, `AlertRepository::createUserAlertComplain started with params`);
|
|
99
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
100
|
+
const result = await createUserAlertComplain(novaDataSource, params);
|
|
101
|
+
this.logger.trace(result, 'AlertRepository::createUserAlertComplain result');
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppFeatureType } from '../../entities';
|
|
2
|
+
export const createAppFeatureType = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.description || !params?.name) {
|
|
4
|
+
logger.warn({ params }, 'AppFeaturesRepository::createAppFeatureType - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const appFeatureTypeRepository = dataSource.getRepository(AppFeatureType);
|
|
9
|
+
const newAppFeature = {
|
|
10
|
+
...params,
|
|
11
|
+
statusId: params.statusId ?? 1,
|
|
12
|
+
};
|
|
13
|
+
return await appFeatureTypeRepository.save(newAppFeature);
|
|
14
|
+
}, 'AppFeaturesRepository::createAppFeatureType');
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ClientAppFeature } from '../../entities';
|
|
2
|
+
export const createClientAppFeature = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.clientId || !params?.appFeatureTypeId || !params.entityId) {
|
|
4
|
+
logger.warn({ params }, 'AppFeaturesRepository::createClientAppFeature - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientAppFeatureRepository = dataSource.getRepository(ClientAppFeature);
|
|
9
|
+
const newClientAppFeature = {
|
|
10
|
+
...params,
|
|
11
|
+
statusId: params.statusId ?? 1,
|
|
12
|
+
};
|
|
13
|
+
return await clientAppFeatureRepository.save(newClientAppFeature);
|
|
14
|
+
}, 'AppFeaturesRepository::createClientAppFeature');
|
|
15
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { ClientAppFeature } from '../../entities';
|
|
2
|
+
export const getClientAppFeatures = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.clientId &&
|
|
4
|
+
!params?.filters?.appFeatureTypeId &&
|
|
5
|
+
!params.filters?.entityId &&
|
|
6
|
+
!params.filters?.statusId) {
|
|
7
|
+
logger.warn({ params }, 'AppFeaturesRepository::getClientAppFeatures - missing required parameters');
|
|
8
|
+
return [];
|
|
9
|
+
}
|
|
10
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
11
|
+
const clientAppFeaturesRepository = dataSource.getRepository(ClientAppFeature);
|
|
12
|
+
let queryBuilder = clientAppFeaturesRepository.createQueryBuilder('clientAppFeature');
|
|
13
|
+
if (params.projectionOptions?.withAppFeatureType) {
|
|
14
|
+
queryBuilder = queryBuilder.leftJoinAndSelect('clientAppFeature.appFeatureType', 'appFeatureType');
|
|
15
|
+
}
|
|
16
|
+
if (params.filters.clientId) {
|
|
17
|
+
queryBuilder = queryBuilder.andWhere(`clientAppFeature.clientId = :clientId`, {
|
|
18
|
+
clientId: params.filters.clientId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (params.filters.appFeatureTypeId) {
|
|
22
|
+
queryBuilder = queryBuilder.andWhere(`clientAppFeature.appFeatureTypeId = :appFeatureTypeId`, {
|
|
23
|
+
appFeatureTypeId: params.filters.appFeatureTypeId,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (params.filters.entityId) {
|
|
27
|
+
queryBuilder = queryBuilder.andWhere(`clientAppFeature.entityId = :entityId`, {
|
|
28
|
+
entityId: params.filters.entityId,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (params.filters.statusId) {
|
|
32
|
+
queryBuilder = queryBuilder.andWhere(`clientAppFeature.statusId = :statusId`, {
|
|
33
|
+
statusId: params.filters.statusId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
const result = await queryBuilder.getMany();
|
|
37
|
+
return result;
|
|
38
|
+
}, 'AppFeaturesRepository::getClientAppFeatures');
|
|
39
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createAppFeatureType } from './createAppFeatureType';
|
|
4
|
+
import { createClientAppFeature } from './createClientAppFeature';
|
|
5
|
+
import { getClientAppFeatures } from './getClientAppFeatures';
|
|
6
|
+
export class AppFeaturesRepository extends BaseRepository {
|
|
7
|
+
/**
|
|
8
|
+
* Create a new app feature type
|
|
9
|
+
* @param params - The parameters to create the app feature type
|
|
10
|
+
* params.id - The id of the app feature type, optional. If not provided, it will be auto-generated
|
|
11
|
+
* params.name - The name of the app feature type, required
|
|
12
|
+
* params.description - The description of the app feature type, required
|
|
13
|
+
* params.statusId - The status id of the app feature type, optional, default to 1
|
|
14
|
+
* @returns The created app feature type
|
|
15
|
+
*/
|
|
16
|
+
async createAppFeatureType(params) {
|
|
17
|
+
this.logger.trace('AppFeaturesRepository::createAppFeatureType started with params');
|
|
18
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
19
|
+
const result = await createAppFeatureType(novaDataSource, params, this.logger);
|
|
20
|
+
this.logger.trace(result, 'AppFeaturesRepository::createAppFeatureType result');
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create a new client app feature
|
|
25
|
+
* @param params - The parameters to create the client app feature
|
|
26
|
+
* params.clientId: The client id of the client app feature, required
|
|
27
|
+
* params.appFeatureTypeId: The app feature type id of the client app feature, required
|
|
28
|
+
* params.entityId: The entity id of the client app feature, required
|
|
29
|
+
* params.statusId: The status id of the client app feature, optional, default to 1
|
|
30
|
+
* @returns The created client app feature
|
|
31
|
+
*/
|
|
32
|
+
async createClientAppFeature(params) {
|
|
33
|
+
this.logger.trace('AppFeaturesRepository::createClientAppFeature started with params');
|
|
34
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
35
|
+
const result = await createClientAppFeature(novaDataSource, params, this.logger);
|
|
36
|
+
this.logger.trace(result, 'AppFeaturesRepository::createClientAppFeature result');
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get client app features
|
|
41
|
+
* @param params - The parameters to get client app features
|
|
42
|
+
* One of the following filters is required:
|
|
43
|
+
* params.filters.clientId: The client id to filter, optional
|
|
44
|
+
* params.filters.appFeatureTypeId: The app feature type id to filter, optional
|
|
45
|
+
* params.filters.entityId: The entity id to filter, optional
|
|
46
|
+
* params.filters.statusId: The status id to filter, optional
|
|
47
|
+
* params.projectionOptions.withAppFeatureType: Whether to include app feature type relation in the result
|
|
48
|
+
* @returns The client app features
|
|
49
|
+
*/
|
|
50
|
+
async getClientAppFeatures(params) {
|
|
51
|
+
this.logger.trace('AppFeaturesRepository::getClientAppFeatures started with params');
|
|
52
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
53
|
+
const result = await getClientAppFeatures(novaDataSource, params, this.logger);
|
|
54
|
+
this.logger.trace(result, 'AppFeaturesRepository::getClientAppFeatures result');
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AssetCategory } from '../../entities';
|
|
2
|
+
export const getAssetCategories = async (novaDataSource) => {
|
|
3
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
4
|
+
const assetCategoriesRepository = dataSource.getRepository(AssetCategory);
|
|
5
|
+
const result = await assetCategoriesRepository.find();
|
|
6
|
+
return result;
|
|
7
|
+
}, 'AssetcategoriesRepository::getAssetCategories');
|
|
8
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { getAssetCategories } from './getAssetCategories';
|
|
4
|
+
export class AssetCategoriesRepository extends BaseRepository {
|
|
5
|
+
/**
|
|
6
|
+
* Get all asset categories
|
|
7
|
+
* @returns {Promise<AssetCategory[]>} The asset categories
|
|
8
|
+
*/
|
|
9
|
+
async getAssetCategories() {
|
|
10
|
+
this.logger.trace('AssetCategoriesRepository::getAssetCategories started with params');
|
|
11
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
12
|
+
const result = await getAssetCategories(novaDataSource);
|
|
13
|
+
this.logger.trace(result, 'AssetCategoriesRepository::getAssetCategories result');
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Billing } from '../../entities';
|
|
2
|
+
export const createBilling = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.id &&
|
|
4
|
+
!params?.deviceId &&
|
|
5
|
+
!params?.clientId &&
|
|
6
|
+
!params?.subscriptionId &&
|
|
7
|
+
!params?.imei &&
|
|
8
|
+
!params?.planId &&
|
|
9
|
+
!params?.platform &&
|
|
10
|
+
!params?.status &&
|
|
11
|
+
!params?.subscriptionValue &&
|
|
12
|
+
!params?.subscriptionPeriodMonths &&
|
|
13
|
+
!params?.subscriptionValueMonthly) {
|
|
14
|
+
logger.warn({ params }, 'BillingRepository::createBilling - missing required parameters');
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
18
|
+
const billingRepository = dataSource.getRepository(Billing);
|
|
19
|
+
const now = new Date();
|
|
20
|
+
const newBilling = {
|
|
21
|
+
id: params.id,
|
|
22
|
+
deviceId: params.deviceId,
|
|
23
|
+
imei: params.imei,
|
|
24
|
+
planId: params.planId,
|
|
25
|
+
subscriptionId: params.subscriptionId,
|
|
26
|
+
platform: params.platform,
|
|
27
|
+
status: params.status,
|
|
28
|
+
subscriptionValue: params.subscriptionValue,
|
|
29
|
+
subscriptionPeriodMonths: params.subscriptionPeriodMonths,
|
|
30
|
+
subscriptionValueMonthly: params.subscriptionValueMonthly,
|
|
31
|
+
clientId: params.clientId,
|
|
32
|
+
createdAt: now,
|
|
33
|
+
updatedAt: now,
|
|
34
|
+
};
|
|
35
|
+
return await billingRepository.save(newBilling);
|
|
36
|
+
}, 'BillingRepository::createBilling');
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BillingDeviceHistory } from '../../entities';
|
|
2
|
+
export const createBillingDeviceHistory = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.id &&
|
|
4
|
+
!params?.clientId &&
|
|
5
|
+
!params?.deviceId &&
|
|
6
|
+
!params?.subscriptionId &&
|
|
7
|
+
!params?.imei &&
|
|
8
|
+
!params?.planId &&
|
|
9
|
+
!params?.platform &&
|
|
10
|
+
!params?.status) {
|
|
11
|
+
logger.warn({ params }, 'BillingRepository::createBillingDeviceHistory - missing required parameters');
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
15
|
+
const billingRepository = dataSource.getRepository(BillingDeviceHistory);
|
|
16
|
+
const now = new Date();
|
|
17
|
+
const newBillingDeviceHistory = {
|
|
18
|
+
id: params.id,
|
|
19
|
+
deviceId: params.deviceId,
|
|
20
|
+
clientId: params.clientId,
|
|
21
|
+
imei: params.imei,
|
|
22
|
+
planId: params.planId,
|
|
23
|
+
subscriptionId: params.subscriptionId,
|
|
24
|
+
platform: params.platform,
|
|
25
|
+
status: params.status,
|
|
26
|
+
createAt: now,
|
|
27
|
+
};
|
|
28
|
+
return await billingRepository.save(newBillingDeviceHistory);
|
|
29
|
+
}, 'BillingRepository::createBillingDeviceHistory');
|
|
30
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BillingHubspotPaymentLog } from '../../entities';
|
|
2
|
+
export const createBillingHubspotPaymentLog = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.amountPaid) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::createBillingHubspotPaymentLog - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const BillingHubspotPaymentLogRepository = dataSource.getRepository(BillingHubspotPaymentLog);
|
|
9
|
+
const newBillingHubspotPaymentLog = {
|
|
10
|
+
id: params.id,
|
|
11
|
+
amountPaid: params.amountPaid,
|
|
12
|
+
owner: params.owner,
|
|
13
|
+
bankOfIssuer: params.bankOfIssuer,
|
|
14
|
+
billingAddress: params.billingAddress,
|
|
15
|
+
billingAddressCity: params.billingAddressCity,
|
|
16
|
+
billingAddressCountry: params.billingAddressCountry,
|
|
17
|
+
billingAddressLine1: params.billingAddressLine1,
|
|
18
|
+
billingAddressLine2: params.billingAddressLine2,
|
|
19
|
+
billingAddressState: params.billingAddressState,
|
|
20
|
+
billingAddressZip: params.billingAddressZip,
|
|
21
|
+
createdByUserId: params.createdByUserId,
|
|
22
|
+
currencyCode: params.currencyCode,
|
|
23
|
+
customer: params.customer,
|
|
24
|
+
grossAmount: params.grossAmount,
|
|
25
|
+
lastFourDigits: params.lastFourDigits,
|
|
26
|
+
lineItemDiscountAmount: params.lineItemDiscountAmount,
|
|
27
|
+
netAmount: params.netAmount,
|
|
28
|
+
objectCreateDateTime: params.objectCreateDateTime,
|
|
29
|
+
objectId: params.objectId,
|
|
30
|
+
objectLastModifiedDateTime: params.objectLastModifiedDateTime,
|
|
31
|
+
orderDiscountAmount: params.orderDiscountAmount,
|
|
32
|
+
orderDiscountCode: params.orderDiscountCode,
|
|
33
|
+
orderDiscountPercentage: params.orderDiscountPercentage,
|
|
34
|
+
ownerAssignedDateTime: params.ownerAssignedDateTime,
|
|
35
|
+
paymentDateTime: params.paymentDateTime,
|
|
36
|
+
paymentId: params.paymentId,
|
|
37
|
+
paymentMethod: params.paymentMethod,
|
|
38
|
+
paymentSourceName: params.paymentSourceName,
|
|
39
|
+
paymentType: params.paymentType,
|
|
40
|
+
processingFees: params.processingFees,
|
|
41
|
+
refunded: params.refunded,
|
|
42
|
+
shippingAddress: params.shippingAddress,
|
|
43
|
+
shippingAddressCity: params.shippingAddressCity,
|
|
44
|
+
shippingAddressCountry: params.shippingAddressCountry,
|
|
45
|
+
shippingAddressLine1: params.shippingAddressLine1,
|
|
46
|
+
shippingAddressLine2: params.shippingAddressLine2,
|
|
47
|
+
shippingAddressState: params.shippingAddressState,
|
|
48
|
+
shippingAddressZip: params.shippingAddressZip,
|
|
49
|
+
source: params.source,
|
|
50
|
+
sourceId: params.sourceId,
|
|
51
|
+
sourceUrl: params.sourceUrl,
|
|
52
|
+
status: params.status,
|
|
53
|
+
statusUpdatedOn: params.statusUpdatedOn,
|
|
54
|
+
totalDiscountAmount: params.totalDiscountAmount,
|
|
55
|
+
totalFees: params.totalFees,
|
|
56
|
+
totalTaxes: params.totalTaxes,
|
|
57
|
+
updatedByUserId: params.updatedByUserId,
|
|
58
|
+
};
|
|
59
|
+
return await BillingHubspotPaymentLogRepository.save(newBillingHubspotPaymentLog);
|
|
60
|
+
}, 'BillingRepository::createBillingHubspotPaymentLog');
|
|
61
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BillingStatusHistoryBraintree } from '../../entities';
|
|
2
|
+
export const createBillingStatusHistoryBraintree = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.subscriptionId || !params?.subscriptionHistories?.length) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::createBillingStatusHistoryBraintree - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const billingStatusHistoryBraintreeRepository = dataSource.getRepository(BillingStatusHistoryBraintree);
|
|
9
|
+
const existingHistoriesRaw = await billingStatusHistoryBraintreeRepository
|
|
10
|
+
.createQueryBuilder('billingStatusHistoryBraintree')
|
|
11
|
+
.where('billingStatusHistoryBraintree.subscriptionId = :subscriptionId', {
|
|
12
|
+
subscriptionId: params.subscriptionId,
|
|
13
|
+
})
|
|
14
|
+
.andWhere('billingStatusHistoryBraintree.timestamp IN (:...timestamps)', {
|
|
15
|
+
timestamps: params.subscriptionHistories.map(history => history.timestamp),
|
|
16
|
+
})
|
|
17
|
+
.select('billingStatusHistoryBraintree.timestamp', 'timestamp')
|
|
18
|
+
.getRawMany();
|
|
19
|
+
const existingTimestamps = existingHistoriesRaw.map(history => history.timestamp);
|
|
20
|
+
const historiesToCreate = [];
|
|
21
|
+
for (const history of params.subscriptionHistories) {
|
|
22
|
+
if (!existingTimestamps.find(existingTimestamp => existingTimestamp === history.timestamp)) {
|
|
23
|
+
historiesToCreate.push({
|
|
24
|
+
...history,
|
|
25
|
+
subscriptionId: params.subscriptionId,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const insertResult = await billingStatusHistoryBraintreeRepository.save(historiesToCreate);
|
|
30
|
+
return insertResult;
|
|
31
|
+
}, 'BillingRepository::createBillingStatusHistoryBraintree');
|
|
32
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BillingCustomerBraintree } from '../../entities';
|
|
2
|
+
export const getBillingCustomerBraintreeById = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.id) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::getBillingCustomerBraintreeById - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const billingCustomerBraintreeRepository = dataSource.getRepository(BillingCustomerBraintree);
|
|
9
|
+
const queryBuilder = billingCustomerBraintreeRepository
|
|
10
|
+
.createQueryBuilder('billingCustomerBraintree')
|
|
11
|
+
.where(`billingCustomerBraintree.id = :id`, {
|
|
12
|
+
id: params.filters.id,
|
|
13
|
+
})
|
|
14
|
+
.limit(1);
|
|
15
|
+
const result = await queryBuilder.getOne();
|
|
16
|
+
return result;
|
|
17
|
+
}, 'BillingRepository::getBillingCustomerBraintreeById');
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Billing, BillingKlarnaOrder } from '../../entities';
|
|
2
|
+
export const getBillingKlarnaOrderByImei = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.imei) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::getBillingKlarnaOrderByImei - missing imei parameter');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const billingKlarnaOrderRepository = dataSource.getRepository(BillingKlarnaOrder);
|
|
9
|
+
const queryBuilder = billingKlarnaOrderRepository
|
|
10
|
+
.createQueryBuilder('billingKlarnaOrder')
|
|
11
|
+
.innerJoin(Billing, 'billing', 'billingKlarnaOrder.orderId = billing.subscriptionId')
|
|
12
|
+
.where(`billing.imei = :imei`, {
|
|
13
|
+
imei: params.imei,
|
|
14
|
+
});
|
|
15
|
+
const result = await queryBuilder.getOne();
|
|
16
|
+
return result;
|
|
17
|
+
}, 'BillingRepository::getBillingKlarnaOrderByImei');
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Billing, BillingSubscriptionBraintree } from '../../entities';
|
|
2
|
+
export const getBillingSubscriptionsBraintreeByImei = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.imei) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::getBillingSubscriptionsBraintreeByImei - missing imei parameter');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const billingSubscriptionBraintreeRepository = dataSource.getRepository(BillingSubscriptionBraintree);
|
|
9
|
+
const queryBuilder = billingSubscriptionBraintreeRepository
|
|
10
|
+
.createQueryBuilder('billingSubscriptionBraintree')
|
|
11
|
+
.innerJoin(Billing, 'billing', 'billingSubscriptionBraintree.subscriptionId = billing.subscriptionId')
|
|
12
|
+
.where(`billing.imei = :imei`, {
|
|
13
|
+
imei: params.imei,
|
|
14
|
+
});
|
|
15
|
+
const result = await queryBuilder.getOne();
|
|
16
|
+
return result;
|
|
17
|
+
}, 'BillingRepository::getBillingSubscriptionsBraintreeByImei');
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Billing, BillingSubscriptionBraintree } from '../../entities';
|
|
2
|
+
export const getBillingSubscriptionsBraintree = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.subscriptionId && !params?.filters?.clientId) {
|
|
4
|
+
logger.warn({ params }, 'BillingRepository::getBillingSubscriptionsBraintree - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const billingSubscriptionBraintreeRepository = dataSource.getRepository(BillingSubscriptionBraintree);
|
|
9
|
+
let queryBuilder = billingSubscriptionBraintreeRepository.createQueryBuilder('billingSubscriptionBraintree');
|
|
10
|
+
if (params?.filters?.subscriptionId) {
|
|
11
|
+
queryBuilder = queryBuilder.where(`billingSubscriptionBraintree.subscriptionId = :subscriptionId`, {
|
|
12
|
+
subscriptionId: params.filters.subscriptionId,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (params?.filters?.clientId) {
|
|
16
|
+
queryBuilder = queryBuilder
|
|
17
|
+
.innerJoin(Billing, 'billing', 'billingSubscriptionBraintree.subscriptionId = billing.subscriptionId')
|
|
18
|
+
.where(`billing.clientId = :clientId`, {
|
|
19
|
+
clientId: params.filters.clientId,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const result = await queryBuilder.getMany();
|
|
23
|
+
return result;
|
|
24
|
+
}, 'BillingRepository::getBillingSubscriptionsBraintree');
|
|
25
|
+
};
|