@spytecgps/nova-orm 0.0.223 → 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.d.ts +2 -2
- 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,53 @@
|
|
|
1
|
+
import { Boundary } from '../../entities';
|
|
2
|
+
export const updateBoundary = async (novaDataSource, params, logger) => {
|
|
3
|
+
// boundaryId is required
|
|
4
|
+
if (!params?.filters?.boundaryId) {
|
|
5
|
+
logger.warn({ params }, 'BoundariesRepository::updateBoundary - missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
// status
|
|
9
|
+
const status = params?.values?.status > 0 && params?.values?.status < 4 ? params.values.status : undefined;
|
|
10
|
+
// radius
|
|
11
|
+
let buffer = params?.values?.buffer;
|
|
12
|
+
if (buffer) {
|
|
13
|
+
const bufferFloat = parseFloat(params.values.buffer);
|
|
14
|
+
if (Number.isNaN(bufferFloat)) {
|
|
15
|
+
buffer = undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// at least one field to update is required
|
|
19
|
+
if (!params?.values?.name &&
|
|
20
|
+
!params?.values?.type &&
|
|
21
|
+
!params?.values?.location &&
|
|
22
|
+
!buffer &&
|
|
23
|
+
!params?.values?.radiusDisplayUnit &&
|
|
24
|
+
!params?.values?.color &&
|
|
25
|
+
!params?.values?.geometry &&
|
|
26
|
+
!status &&
|
|
27
|
+
!params?.values?.area) {
|
|
28
|
+
logger.warn({ params }, 'BoundariesRepository::updateBoundary - missing required parameters');
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
32
|
+
const boundariesRepository = dataSource.getRepository(Boundary);
|
|
33
|
+
const now = new Date();
|
|
34
|
+
const result = await boundariesRepository
|
|
35
|
+
.createQueryBuilder()
|
|
36
|
+
.update(Boundary)
|
|
37
|
+
.set({
|
|
38
|
+
name: params.values.name,
|
|
39
|
+
type: params.values.type,
|
|
40
|
+
modifiedBy: params.values.modifiedBy,
|
|
41
|
+
location: params.values.location,
|
|
42
|
+
buffer,
|
|
43
|
+
radiusDisplayUnit: params.values.radiusDisplayUnit,
|
|
44
|
+
color: params.values.color,
|
|
45
|
+
geometry: params.values.geometry,
|
|
46
|
+
status,
|
|
47
|
+
modifiedAt: now,
|
|
48
|
+
})
|
|
49
|
+
.where('id = :id', { id: params.filters.boundaryId })
|
|
50
|
+
.execute();
|
|
51
|
+
return result.affected > 0;
|
|
52
|
+
}, 'BoundariesRepository::updateBoundary');
|
|
53
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BoundaryEvent } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const upsertBoundaryEvent = async (novaDataSource, params, logger) => {
|
|
4
|
+
if (!params?.id || !params?.boundaryId || !params?.deviceId || !params?.imei) {
|
|
5
|
+
logger.warn({ params }, 'BoundariesRepository::upsertBoundaryEvent missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const userIdBinaryBuffer = uuidStringToBinaryBuffer(params.userId);
|
|
9
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
10
|
+
const boundaryEventRepository = dataSource.getRepository(BoundaryEvent);
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const boundaryEvent = {
|
|
13
|
+
...params,
|
|
14
|
+
userId: userIdBinaryBuffer,
|
|
15
|
+
createdAt: params.createdAt ?? now,
|
|
16
|
+
modifiedAt: params.modifiedAt ?? now,
|
|
17
|
+
};
|
|
18
|
+
const result = await boundaryEventRepository.upsert(boundaryEvent, {
|
|
19
|
+
conflictPaths: ['id'],
|
|
20
|
+
});
|
|
21
|
+
return result?.raw?.affectedRows > 0;
|
|
22
|
+
}, 'BoundariesRepository::upsertBoundaryEvent');
|
|
23
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Client } from '../../entities';
|
|
2
|
+
import { HapnClientType } from '../../types/enums';
|
|
3
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
4
|
+
export const createClient = async (novaDataSource, params, logger) => {
|
|
5
|
+
if (!params?.name || !params?.email || !params?.uuid) {
|
|
6
|
+
logger.warn({ params }, 'ClientsRepository::createClient - missing required parameters');
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
10
|
+
const clientsRepository = dataSource.getRepository(Client);
|
|
11
|
+
const now = new Date();
|
|
12
|
+
const newClient = {
|
|
13
|
+
id: params.clientId,
|
|
14
|
+
name: params.name,
|
|
15
|
+
email: params.email,
|
|
16
|
+
clientTypeId: params.clientTypeId ?? HapnClientType.b2c,
|
|
17
|
+
createdAt: now,
|
|
18
|
+
modifiedAt: now,
|
|
19
|
+
createdBy: 0,
|
|
20
|
+
modifiedBy: 0,
|
|
21
|
+
uuid: uuidStringToBinaryBuffer(params.uuid),
|
|
22
|
+
dataSourceTypeId: params.dataSourceTypeId,
|
|
23
|
+
sievaUserName: params.sievaUserName,
|
|
24
|
+
sievaBatchId: params.sievaBatchId,
|
|
25
|
+
salesforceId: params.salesforceId,
|
|
26
|
+
accumaticaId: params.accumaticaId,
|
|
27
|
+
expirationDate: params.expirationDate,
|
|
28
|
+
useType: params.useType,
|
|
29
|
+
btCustomerId: params.btCustomerId,
|
|
30
|
+
activationCampaign: params.activationCampaign,
|
|
31
|
+
organizationId: params.organizationId,
|
|
32
|
+
};
|
|
33
|
+
return await clientsRepository.save(newClient);
|
|
34
|
+
}, 'ClientsRepository::createClient');
|
|
35
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ClientConfiguration } from '../../entities';
|
|
2
|
+
export const createClientConfiguration = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.clientId) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::createClientConfiguration - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientConfigurationRepository = dataSource.getRepository(ClientConfiguration);
|
|
9
|
+
const newClientConfiguration = {
|
|
10
|
+
clientId: params.clientId,
|
|
11
|
+
movementTripThreshold: params.movementTripThreshold,
|
|
12
|
+
stopTripThreshold: params.stopTripThreshold,
|
|
13
|
+
mapUpdateMode: params.mapUpdateMode,
|
|
14
|
+
maxUsersAllowed: params.maxUsersAllowed,
|
|
15
|
+
};
|
|
16
|
+
return await clientConfigurationRepository.save(newClientConfiguration);
|
|
17
|
+
}, 'ClientsRepository::createClientConfiguration');
|
|
18
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CustomerAttribute } from '../../entities/customerAttribute';
|
|
2
|
+
export const createCustomerAttribute = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.clientId) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::createCustomerAttribute - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientConfigurationRepository = dataSource.getRepository(CustomerAttribute);
|
|
9
|
+
const newCustomerAttribute = {
|
|
10
|
+
clientId: params.clientId,
|
|
11
|
+
enterprise: params.enterprise,
|
|
12
|
+
maintenanceModule: params.maintenanceModule,
|
|
13
|
+
};
|
|
14
|
+
return await clientConfigurationRepository.save(newCustomerAttribute);
|
|
15
|
+
}, 'ClientsRepository::createCustomerAttribute');
|
|
16
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Client, ClientConfiguration } from '../../entities';
|
|
2
|
+
export const deleteClientAndConfiguration = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::deleteClientAndConfiguration - missing required parameters');
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
await novaDataSource.connect();
|
|
8
|
+
const queryRunner = novaDataSource.createQueryRunner();
|
|
9
|
+
try {
|
|
10
|
+
await queryRunner.startTransaction();
|
|
11
|
+
await queryRunner.manager.delete(ClientConfiguration, params.filters.clientId);
|
|
12
|
+
const deleteResult = await queryRunner.manager.delete(Client, params.filters.clientId);
|
|
13
|
+
await queryRunner.commitTransaction();
|
|
14
|
+
return deleteResult.affected > 0;
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
await queryRunner.rollbackTransaction();
|
|
18
|
+
logger.error({ error }, 'ClientsRepository::deleteClientAndConfigurations error');
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await queryRunner.release();
|
|
23
|
+
await novaDataSource.disconnect();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Client } from '../../entities';
|
|
2
|
+
export const getClient = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId && !params.filters.email) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::getClient - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientsRepository = dataSource.getRepository(Client);
|
|
9
|
+
let queryBuilder = clientsRepository.createQueryBuilder('client').comment(`test=value`);
|
|
10
|
+
if (params.projectionOptions?.withCustomerAttribute) {
|
|
11
|
+
queryBuilder = queryBuilder.leftJoinAndSelect('client.customerAttribute', 'customerAttribute');
|
|
12
|
+
}
|
|
13
|
+
if (params.projectionOptions?.withOrganization) {
|
|
14
|
+
queryBuilder = queryBuilder.leftJoinAndSelect('client.organization', 'organization');
|
|
15
|
+
}
|
|
16
|
+
if (params.filters.clientId) {
|
|
17
|
+
queryBuilder = queryBuilder.where('client.id = :id', {
|
|
18
|
+
id: params.filters.clientId,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (params.filters.email) {
|
|
22
|
+
queryBuilder = queryBuilder.andWhere('LOWER(client.email) = LOWER(:email)', {
|
|
23
|
+
email: params.filters.email,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const client = await queryBuilder
|
|
27
|
+
.leftJoinAndSelect('client.clientType', 'clientType')
|
|
28
|
+
.select()
|
|
29
|
+
.getOne();
|
|
30
|
+
return client;
|
|
31
|
+
}, 'ClientsRepository::getClient');
|
|
32
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientConfiguration } from '../../entities';
|
|
2
|
+
export const getClientConfiguration = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::getClientConfiguration - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientConfigurationRepository = dataSource.getRepository(ClientConfiguration);
|
|
9
|
+
const clientConfiguration = await clientConfigurationRepository.findOne({
|
|
10
|
+
where: { clientId: params.filters.clientId },
|
|
11
|
+
});
|
|
12
|
+
return clientConfiguration;
|
|
13
|
+
}, 'ClientsRepository::getClientConfiguration');
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Client } from '../../entities';
|
|
2
|
+
export const getClients = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.email) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::getClients - missing required parameters');
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientsRepository = dataSource.getRepository(Client);
|
|
9
|
+
let queryBuilder = clientsRepository
|
|
10
|
+
.createQueryBuilder('client')
|
|
11
|
+
.where('LOWER(client.email) = LOWER(:email)', {
|
|
12
|
+
email: params.filters.email,
|
|
13
|
+
});
|
|
14
|
+
if (params.projectionOptions?.withCustomerAttribute) {
|
|
15
|
+
queryBuilder = queryBuilder.leftJoinAndSelect('client.customerAttribute', 'customerAttribute');
|
|
16
|
+
}
|
|
17
|
+
if (params.projectionOptions?.withOrganization) {
|
|
18
|
+
queryBuilder = queryBuilder.leftJoinAndSelect('client.organization', 'organization');
|
|
19
|
+
}
|
|
20
|
+
const clients = await queryBuilder
|
|
21
|
+
.leftJoinAndSelect('client.clientType', 'clientType')
|
|
22
|
+
.select()
|
|
23
|
+
.getMany();
|
|
24
|
+
return clients;
|
|
25
|
+
}, 'ClientsRepository::getClients');
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { CustomerAttribute } from '../../entities';
|
|
2
|
+
export const getCustomerAttribute = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params.filters.clientId) {
|
|
4
|
+
logger.warn({ params }, 'ClientsRepository::getCustomerAttribute - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const clientConfigurationRepository = dataSource.getRepository(CustomerAttribute);
|
|
9
|
+
const clientConfiguration = await clientConfigurationRepository.findOne({
|
|
10
|
+
where: { clientId: params.filters.clientId },
|
|
11
|
+
});
|
|
12
|
+
return clientConfiguration;
|
|
13
|
+
}, 'ClientsRepository::getCustomerAttribute');
|
|
14
|
+
};
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { createClient } from './createClient';
|
|
4
|
+
import { createClientConfiguration } from './createClientConfiguration';
|
|
5
|
+
import { createCustomerAttribute } from './createCustomerAttribute';
|
|
6
|
+
import { deleteClientAndConfiguration } from './deleteClientAndConfiguration';
|
|
7
|
+
import { getClient } from './getClient';
|
|
8
|
+
import { getClientConfiguration } from './getClientConfiguration';
|
|
9
|
+
import { getClients } from './getClients';
|
|
10
|
+
import { getCustomerAttribute } from './getCustomerAttribute';
|
|
11
|
+
import { updateClient } from './updateClient';
|
|
12
|
+
import { updateClientConfiguration } from './updateClientConfiguration';
|
|
13
|
+
import { updateCustomerAttribute } from './updateCustomerAttribute';
|
|
14
|
+
export class ClientsRepository extends BaseRepository {
|
|
15
|
+
/**
|
|
16
|
+
* Get a client with filters. If multiple clients are found, the first one is returned.
|
|
17
|
+
* @param {GetClientParams} params containing information to get a client
|
|
18
|
+
* - filters.clientId: The client id, optional
|
|
19
|
+
* - filters.email: The email, optional
|
|
20
|
+
*/
|
|
21
|
+
async getClient(params) {
|
|
22
|
+
this.logger.trace(params, 'ClientsRepository::getClient started with params');
|
|
23
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
24
|
+
const result = await getClient(novaDataSource, params, this.logger);
|
|
25
|
+
this.logger.trace(result, 'ClientsRepository::getClient result');
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Get clients with filters. If multiple clients are found, all are returned.
|
|
30
|
+
* @param {GetClientsParams} params containing information to get clients
|
|
31
|
+
* - filters.email: The email filter
|
|
32
|
+
*/
|
|
33
|
+
async getClients(params) {
|
|
34
|
+
this.logger.trace(params, 'ClientsRepository::getClients started with params');
|
|
35
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
36
|
+
const result = await getClients(novaDataSource, params, this.logger);
|
|
37
|
+
this.logger.trace(result, 'ClientsRepository::getClients result');
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Create client
|
|
42
|
+
* @param {CreateClientParams} params containing information to create a client
|
|
43
|
+
* - name: client name
|
|
44
|
+
* - email: client email
|
|
45
|
+
* - uuid: client uuid
|
|
46
|
+
* - clientTypeId: client type id, optional
|
|
47
|
+
* - dataSourceTypeId: data source type id, optional
|
|
48
|
+
* - sievaUserName: sieva user name, optional
|
|
49
|
+
* - sievaBatchId: sieva batch id, optional
|
|
50
|
+
* - salesforceId: salesforce id, optional
|
|
51
|
+
* - accumaticaId: accumatica id, optional
|
|
52
|
+
* - expirationDate: expiration date, optional
|
|
53
|
+
* - useType: use type, optional
|
|
54
|
+
* - btCustomerId: bt customer id, optional
|
|
55
|
+
* - activationCampaign: activation campaign, optional
|
|
56
|
+
* - organizationId: organization id, optional
|
|
57
|
+
* @returns {Promise<Client>} The created client
|
|
58
|
+
*/
|
|
59
|
+
async createClient(params) {
|
|
60
|
+
this.logger.trace(params, 'ClientsRepository::createClient started with params');
|
|
61
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
62
|
+
const result = await createClient(novaDataSource, params, this.logger);
|
|
63
|
+
this.logger.trace(result, 'ClientsRepository::createClient result');
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create client
|
|
68
|
+
* @param {UpdateClientParams} params containing information to update a client
|
|
69
|
+
* - filters.clientId: The id of the client to update
|
|
70
|
+
* - values.name: client name, optional
|
|
71
|
+
* - values.email: client email, optional
|
|
72
|
+
* - values.uuid: client uuid, optional
|
|
73
|
+
* - values.clientTypeId: client type id, optional
|
|
74
|
+
* - values.dataSourceTypeId: data source type id, optional
|
|
75
|
+
* - values.sievaUserName: sieva user name, optional
|
|
76
|
+
* - values.sievaBatchId: sieva batch id, optional
|
|
77
|
+
* - values.salesforceId: salesforce id, optional
|
|
78
|
+
* - values.accumaticaId: accumatica id, optional
|
|
79
|
+
* - values.expirationDate: expiration date, optional
|
|
80
|
+
* - values.useType: use type, optional
|
|
81
|
+
* - values.btCustomerId: bt customer id, optional
|
|
82
|
+
* - values.activationCampaign: activation campaign, optional
|
|
83
|
+
* - values.organizationId: organization id, optional
|
|
84
|
+
* @returns {Promise<boolean>} True if the client was updated, false otherwise
|
|
85
|
+
*/
|
|
86
|
+
async updateClient(params) {
|
|
87
|
+
this.logger.trace(params, 'ClientsRepository::updateClient started with params');
|
|
88
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
89
|
+
const result = await updateClient(novaDataSource, params, this.logger);
|
|
90
|
+
this.logger.trace({ result }, 'ClientsRepository::updateClient result');
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Delete a client and its configurations
|
|
95
|
+
* @param {DeleteClientParams} params containing information to delete a client
|
|
96
|
+
* - filters.clientId: The id of the client to delete
|
|
97
|
+
* @returns {Promise<boolean>} True if the client was deleted, false otherwise
|
|
98
|
+
*/
|
|
99
|
+
async deleteClientAndConfigurations(params) {
|
|
100
|
+
this.logger.trace(params, 'ClientsRepository::deleteClientAndConfigurations started with params');
|
|
101
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
102
|
+
const result = await deleteClientAndConfiguration(novaDataSource, params, this.logger);
|
|
103
|
+
this.logger.trace({ result }, 'ClientsRepository::deleteClientAndConfigurations result');
|
|
104
|
+
return result;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Get a client configuration
|
|
108
|
+
* @param {GetClientConfigurationParams} params containing information to get a client configuration
|
|
109
|
+
* - filters.clientId: The client id
|
|
110
|
+
*/
|
|
111
|
+
async getClientConfiguration(params) {
|
|
112
|
+
this.logger.trace(params, 'ClientsRepository::getClientConfiguration started with params');
|
|
113
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
114
|
+
const result = await getClientConfiguration(novaDataSource, params, this.logger);
|
|
115
|
+
this.logger.trace(result, 'ClientsRepository::getClientConfiguration result');
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Create a client configuration
|
|
120
|
+
* @param {CreateClientConfigurationParams} params containing information to create a client configuration
|
|
121
|
+
* - clientId: The client id
|
|
122
|
+
* - movementTripThreshold: The movement trip threshold
|
|
123
|
+
* - stopTripThreshold: The stop trip threshold
|
|
124
|
+
* - mapUpdateMode: The map update mode
|
|
125
|
+
* - maxUsersAllowed: The max users allowed
|
|
126
|
+
*/
|
|
127
|
+
async createClientConfiguration(params) {
|
|
128
|
+
this.logger.trace(params, 'ClientsRepository::createClientConfiguration started with params');
|
|
129
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
130
|
+
const result = await createClientConfiguration(novaDataSource, params, this.logger);
|
|
131
|
+
this.logger.trace(result, 'ClientsRepository::createClientConfiguration result');
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Update a client configuration
|
|
136
|
+
* @param {UpdateClientConfigurationParams} params containing information to update a client configuration
|
|
137
|
+
* - filters.clientId: The client id
|
|
138
|
+
* - values.movementTripThreshold: The movement trip threshold, optional
|
|
139
|
+
* - values.stopTripThreshold: The stop trip threshold, optional
|
|
140
|
+
* - values.mapUpdateMode: The map update mode, optional
|
|
141
|
+
* - values.maxUsersAllowed: The max users allowed, optional
|
|
142
|
+
* @returns {Promise<boolean>} True if the client configuration was updated, false otherwise
|
|
143
|
+
*/
|
|
144
|
+
async updateClientConfiguration(params) {
|
|
145
|
+
this.logger.trace(params, 'ClientsRepository::updateClientConfiguration started with params');
|
|
146
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
147
|
+
const result = await updateClientConfiguration(novaDataSource, params, this.logger);
|
|
148
|
+
this.logger.trace({ result }, 'ClientsRepository::updateClientConfiguration result');
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Create a customer attribute for a client
|
|
153
|
+
* @param {CreateCustomerAttributeParams} params containing information to create a customer attribute
|
|
154
|
+
* - clientId: The client id
|
|
155
|
+
* - enterprise: The enterprise, optional
|
|
156
|
+
* - maintenanceModule: The maintenance module, optional
|
|
157
|
+
*/
|
|
158
|
+
async createCustomerAttribute(params) {
|
|
159
|
+
this.logger.trace(params, 'ClientsRepository::createCustomerAttribute started with params');
|
|
160
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
161
|
+
const result = await createCustomerAttribute(novaDataSource, params, this.logger);
|
|
162
|
+
this.logger.trace(result, 'ClientsRepository::createCustomerAttribute result');
|
|
163
|
+
return result;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Update a customer attribute for a client
|
|
167
|
+
* @param {UpdateCustomerAttributeParams} params containing information to update a customer attribute
|
|
168
|
+
* - filters.clientId: The client id
|
|
169
|
+
* - enterprise: The enterprise, optional
|
|
170
|
+
* - maintenanceModule: The maintenance module, optional
|
|
171
|
+
* @returns {Promise<boolean>} True if the customer attribute was updated, false otherwise
|
|
172
|
+
*/
|
|
173
|
+
async updateCustomerAttribute(params) {
|
|
174
|
+
this.logger.trace(params, 'ClientsRepository::updateCustomerAttribute started with params');
|
|
175
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
176
|
+
const result = await updateCustomerAttribute(novaDataSource, params, this.logger);
|
|
177
|
+
this.logger.trace({ result }, 'ClientsRepository::updateCustomerAttribute result');
|
|
178
|
+
return result;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get a costumer attribute for a client
|
|
182
|
+
* @param {GetCustomerAttributeParams} params containing information to get a customer attribute
|
|
183
|
+
* - filters.clientId: The client id
|
|
184
|
+
*/
|
|
185
|
+
async getCustomerAttribute(params) {
|
|
186
|
+
this.logger.trace(params, 'ClientsRepository::getCustomerAttribute started with params');
|
|
187
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
188
|
+
const result = await getCustomerAttribute(novaDataSource, params, this.logger);
|
|
189
|
+
this.logger.trace(result, 'ClientsRepository::getCustomerAttribute result');
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Client } from '../../entities';
|
|
2
|
+
import { uuidStringToBinaryBuffer } from '../../utils/uuidHelpers';
|
|
3
|
+
export const updateClient = async (novaDataSource, params, logger) => {
|
|
4
|
+
// clientId is required
|
|
5
|
+
if (!params?.filters?.clientId) {
|
|
6
|
+
logger.warn({ params }, 'ClientsRepository::updateClient - missing required parameters');
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
// at least one field to update is required
|
|
10
|
+
if (!params?.values?.name &&
|
|
11
|
+
!params?.values?.uuid &&
|
|
12
|
+
!params?.values?.email &&
|
|
13
|
+
!params?.values?.clientTypeId &&
|
|
14
|
+
!params?.values?.dataSourceTypeId &&
|
|
15
|
+
!params?.values?.sievaUserName &&
|
|
16
|
+
!params?.values?.sievaBatchId &&
|
|
17
|
+
!params?.values?.salesforceId &&
|
|
18
|
+
!params?.values?.accumaticaId &&
|
|
19
|
+
!params?.values?.expirationDate &&
|
|
20
|
+
!params?.values?.useType &&
|
|
21
|
+
!params?.values?.btCustomerId &&
|
|
22
|
+
!params?.values?.activationCampaign &&
|
|
23
|
+
!params?.values?.organizationId) {
|
|
24
|
+
logger.warn({ params }, 'ClientsRepository::updateClient - missing required parameters');
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
28
|
+
const clientsRepository = dataSource.getRepository(Client);
|
|
29
|
+
const now = new Date();
|
|
30
|
+
const result = await clientsRepository
|
|
31
|
+
.createQueryBuilder()
|
|
32
|
+
.update(Client)
|
|
33
|
+
.set({
|
|
34
|
+
name: params.values.name,
|
|
35
|
+
uuid: params.values.uuid ? uuidStringToBinaryBuffer(params.values.uuid) : undefined,
|
|
36
|
+
email: params.values.email,
|
|
37
|
+
clientTypeId: params.values.clientTypeId,
|
|
38
|
+
dataSourceTypeId: params.values.dataSourceTypeId,
|
|
39
|
+
salesforceId: params.values.salesforceId,
|
|
40
|
+
accumaticaId: params.values.accumaticaId,
|
|
41
|
+
expirationDate: params.values.expirationDate,
|
|
42
|
+
useType: params.values.useType,
|
|
43
|
+
btCustomerId: params.values.btCustomerId,
|
|
44
|
+
activationCampaign: params.values.activationCampaign,
|
|
45
|
+
organizationId: params.values.organizationId,
|
|
46
|
+
modifiedAt: now,
|
|
47
|
+
})
|
|
48
|
+
.where('id = :id', { id: params.filters.clientId })
|
|
49
|
+
.execute();
|
|
50
|
+
return result.affected > 0;
|
|
51
|
+
}, 'ClientsRepository::updateClient');
|
|
52
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ClientConfiguration } from '../../entities';
|
|
2
|
+
export const updateClientConfiguration = async (novaDataSource, params, logger) => {
|
|
3
|
+
// clientId is required
|
|
4
|
+
if (!params?.filters?.clientId) {
|
|
5
|
+
logger.warn({ params }, 'ClientsRepository::updateClientConfiguration - missing required parameters');
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
// at least one field to update is required
|
|
9
|
+
if (!params?.values?.movementTripThreshold &&
|
|
10
|
+
!params?.values?.stopTripThreshold &&
|
|
11
|
+
!params?.values?.mapUpdateMode &&
|
|
12
|
+
!params?.values?.maxUsersAllowed) {
|
|
13
|
+
logger.warn({ params }, 'ClientsRepository::updateClientConfiguration - missing required parameters');
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
17
|
+
const clientConfigurationRepository = dataSource.getRepository(ClientConfiguration);
|
|
18
|
+
const result = await clientConfigurationRepository
|
|
19
|
+
.createQueryBuilder()
|
|
20
|
+
.update(ClientConfiguration)
|
|
21
|
+
.set({
|
|
22
|
+
movementTripThreshold: params.values.movementTripThreshold,
|
|
23
|
+
stopTripThreshold: params.values.stopTripThreshold,
|
|
24
|
+
mapUpdateMode: params.values.mapUpdateMode,
|
|
25
|
+
maxUsersAllowed: params.values.maxUsersAllowed,
|
|
26
|
+
})
|
|
27
|
+
.where('clientId = :clientId', { clientId: params.filters.clientId })
|
|
28
|
+
.execute();
|
|
29
|
+
return result.affected > 0;
|
|
30
|
+
}, 'ClientsRepository::updateClientConfiguration');
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ClientConfiguration } from '../../entities';
|
|
2
|
+
import { CustomerAttribute } from '../../entities/customerAttribute';
|
|
3
|
+
export const updateCustomerAttribute = async (novaDataSource, params, logger) => {
|
|
4
|
+
// clientId is required
|
|
5
|
+
if (!params?.filters?.clientId) {
|
|
6
|
+
logger.warn({ params }, 'ClientsRepository::updateClientConfiguration - missing required parameters');
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
// at least one field to update is required
|
|
10
|
+
if (params?.values?.enterprise == null && params?.values?.maintenanceModule == null) {
|
|
11
|
+
logger.warn({ params }, 'ClientsRepository::updateClientConfiguration - missing required parameters');
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
15
|
+
const clientConfigurationRepository = dataSource.getRepository(ClientConfiguration);
|
|
16
|
+
const result = await clientConfigurationRepository
|
|
17
|
+
.createQueryBuilder()
|
|
18
|
+
.update(CustomerAttribute)
|
|
19
|
+
.set({
|
|
20
|
+
enterprise: params.values.enterprise,
|
|
21
|
+
maintenanceModule: params.values.maintenanceModule,
|
|
22
|
+
})
|
|
23
|
+
.where('clientId = :clientId', { clientId: params.filters.clientId })
|
|
24
|
+
.execute();
|
|
25
|
+
return result.affected > 0;
|
|
26
|
+
}, 'ClientsRepository::updateCustomerAttribute');
|
|
27
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Country } from '../../entities';
|
|
2
|
+
export const getCountries = async (novaDataSource, params) => {
|
|
3
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
4
|
+
const countriesRepository = dataSource.getRepository(Country);
|
|
5
|
+
let queryBuilder = countriesRepository.createQueryBuilder('country');
|
|
6
|
+
if (params?.filters?.idList?.length) {
|
|
7
|
+
queryBuilder = queryBuilder.where('country.id IN (:...idList)', {
|
|
8
|
+
idList: params.filters.idList,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
const result = await queryBuilder.getMany();
|
|
12
|
+
return result;
|
|
13
|
+
}, 'CountriesRepository::getCountries');
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Country } from '../../entities';
|
|
2
|
+
export const getCountry = async (novaDataSource, params, logger) => {
|
|
3
|
+
if (!params?.filters?.id && !params?.filters?.alpha2Code) {
|
|
4
|
+
logger.warn({ params }, 'CountriesRepository::getCountry - missing required parameters');
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
return novaDataSource.safeQuery(async (dataSource) => {
|
|
8
|
+
const countriesRepository = dataSource.getRepository(Country);
|
|
9
|
+
let queryBuilder = countriesRepository.createQueryBuilder('country');
|
|
10
|
+
if (params.filters.id) {
|
|
11
|
+
queryBuilder = queryBuilder.where('country.id = :id', {
|
|
12
|
+
id: params.filters.id,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
if (params.filters.alpha2Code) {
|
|
16
|
+
queryBuilder = queryBuilder.where('country.alpha2Code = :alpha2Code', {
|
|
17
|
+
alpha2Code: params.filters.alpha2Code,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const result = await queryBuilder.getOne();
|
|
21
|
+
return result;
|
|
22
|
+
}, 'CountriesRepository::getCountry');
|
|
23
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { NovaDataSource } from '../../novaDataSource';
|
|
2
|
+
import { BaseRepository } from '../baseRepository';
|
|
3
|
+
import { getCountries } from './getCountries';
|
|
4
|
+
import { getCountry } from './getCountry';
|
|
5
|
+
export class CountriesRepository extends BaseRepository {
|
|
6
|
+
/**
|
|
7
|
+
* Get country
|
|
8
|
+
* @param {GetCountryParams} params containing information to get a country
|
|
9
|
+
* - filters.id: The country id
|
|
10
|
+
* - filters.alpha2Code: The country alpha2Code
|
|
11
|
+
* @returns The country information
|
|
12
|
+
*/
|
|
13
|
+
async getCountry(params) {
|
|
14
|
+
this.logger.trace(params, 'CountriesRepository::getCountry started with params');
|
|
15
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
16
|
+
const result = await getCountry(novaDataSource, params, this.logger);
|
|
17
|
+
this.logger.trace(result, 'CountriesRepository::getCountry result');
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get countries
|
|
22
|
+
* @param {GetCountriesParams} params containing information to get countries
|
|
23
|
+
* - filters.idList: The country id list. If not provided, all countries will be returned
|
|
24
|
+
* @returns The countries information
|
|
25
|
+
*/
|
|
26
|
+
async getCountries(params) {
|
|
27
|
+
this.logger.trace(params, 'CountriesRepository::getCountries started with params');
|
|
28
|
+
const novaDataSource = new NovaDataSource(this.novaDataSourceConfig, this.logger);
|
|
29
|
+
const result = await getCountries(novaDataSource, params);
|
|
30
|
+
this.logger.trace(result, 'CountriesRepository::getCountries result');
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|