From 00657d5eff885e2bb456ed74cd50f15b6fa91306 Mon Sep 17 00:00:00 2001 From: Nawaz Dhandala Date: Thu, 14 Apr 2022 21:37:07 +0100 Subject: [PATCH] fix --- Accounts/src/Pages/index.ts | 22 ++- AdminDashboard/src/Actions/license.ts | 2 +- AdminDashboard/src/Actions/probe.ts | 2 +- AdminDashboard/src/Actions/version.ts | 12 +- AdminDashboard/src/Pages/index.ts | 22 +-- AdminDashboard/src/Utils/keybinding.ts | 2 +- ApplicationScanner/index.ts | 4 +- ApplicationScanner/utils/api.ts | 8 +- .../utils/applicationService.ts | 98 +++++++------ ApplicationScanner/utils/fsHandlers.ts | 10 +- Backend/api/Alert.ts | 2 +- Backend/api/ApplicationScanner.ts | 96 ++++++------ Backend/api/Base.ts | 20 +-- Backend/api/Component.ts | 7 +- Backend/api/ContainerScanner.ts | 2 +- Backend/api/EmailSmtp.ts | 2 +- Backend/api/ErrorTracker.ts | 4 +- Backend/api/Incident.ts | 20 +-- Backend/api/Invoice.ts | 4 +- Backend/api/Lighthouse.ts | 2 +- Backend/api/Monitor.ts | 2 +- Backend/api/PerformanceTracker.ts | 2 +- Backend/api/Project.ts | 10 +- Backend/api/Schedule.ts | 2 +- Backend/api/Search.ts | 8 +- Backend/api/SiteManager.ts | 2 +- Backend/api/Slack.ts | 2 +- Backend/api/StatusPage.ts | 36 ++--- Backend/api/Stripe.ts | 2 +- Backend/api/SubscriberAlert.ts | 2 +- Backend/api/User.ts | 10 +- Backend/api/Zapier.ts | 4 +- .../applicationScannerAuthorization.ts | 2 +- Backend/middlewares/auditLogs.ts | 5 +- Backend/middlewares/clusterAuthorization.ts | 2 +- .../containerScannerAuthorization.ts | 2 +- Backend/middlewares/ipHandler.ts | 8 +- Backend/middlewares/probeAuthorization.ts | 2 +- Backend/middlewares/project.ts | 12 +- Backend/middlewares/user.ts | 10 +- Backend/test/disableSignup.test.ts | 2 +- Backend/test/incident.test.ts | 2 +- Backend/test/incidentAlerts.test.ts | 4 +- Backend/test/invoice.test.ts | 2 +- Backend/test/rateLimit.test.ts | 2 +- Backend/test/resourceCategory.test.ts | 4 +- Backend/test/schedule.test.ts | 2 +- Backend/test/scheduledEvent.test.ts | 2 +- Backend/test/scheduledEventNote.test.ts | 2 +- Backend/test/utils/string.ts | 8 +- Backend/utils/DateTime.ts | 4 +- Backend/utils/api.ts | 2 +- Backend/utils/randomChar.ts | 4 +- Backend/utils/services.ts | 6 +- Backend/utils/stripeHandlers.ts | 2 +- Backend/workers/subscription.ts | 4 +- Common/Types/API/URL.ts | 2 +- Common/Utils/Slug.ts | 2 +- CommonServer/Infrastructure/ORM.ts | 2 +- .../Middleware/ClusterKeyAuthorization.ts | 2 +- CommonServer/Middleware/ProbeAuthorization.ts | 2 +- CommonServer/Services/AirtableService.ts | 8 +- CommonServer/Services/AlertService.ts | 98 ++++++------- .../Services/ApplicationSecurityLogService.ts | 2 +- .../Services/ApplicationSecurityService.ts | 4 +- .../Services/AutomatedScriptService.ts | 6 +- CommonServer/Services/CallLogsService.ts | 2 +- CommonServer/Services/CallRoutingService.ts | 18 +-- CommonServer/Services/ComponentService.ts | 14 +- .../Services/ContainerSecurityService.ts | 2 +- CommonServer/Services/DatabaseService.ts | 6 +- .../Services/DomainVerificationService.ts | 4 +- CommonServer/Services/ErrorEventService.ts | 4 +- CommonServer/Services/ErrorTrackerService.ts | 2 +- CommonServer/Services/EscalationService.ts | 8 +- CommonServer/Services/FeedbackService.ts | 2 +- CommonServer/Services/GroupService.ts | 4 +- .../IncidentCommunicationSlaService.ts | 6 +- .../Services/IncidentMessageService.ts | 2 +- .../Services/IncidentNoteTemplateService.ts | 2 +- CommonServer/Services/IncidentService.ts | 99 +++++++------ .../Services/IncidentTimelineService.ts | 2 +- .../Services/IncomingRequestService.ts | 60 ++++---- CommonServer/Services/IntegrationService.ts | 2 +- CommonServer/Services/IssueService.ts | 2 +- CommonServer/Services/LeadService.ts | 2 +- CommonServer/Services/LogService.ts | 6 +- .../Services/MonitorCriteriaService.ts | 10 +- CommonServer/Services/MonitorLogService.ts | 2 +- CommonServer/Services/MonitorService.ts | 60 ++++---- CommonServer/Services/MonitorSlaService.ts | 4 +- CommonServer/Services/MsTeamsService.ts | 2 +- CommonServer/Services/NotificationService.ts | 2 +- .../Services/OnCallScheduleStatusService.ts | 2 +- CommonServer/Services/PaymentService.ts | 8 +- .../PerformanceTrackerMetricService.ts | 8 +- .../Services/PerformanceTrackerService.ts | 4 +- CommonServer/Services/ProbeService.ts | 76 +++++----- CommonServer/Services/ProjectService.ts | 30 ++-- CommonServer/Services/ScheduleService.ts | 6 +- .../Services/ScheduledEventService.ts | 4 +- CommonServer/Services/SlackService.ts | 2 +- CommonServer/Services/SsoService.ts | 2 +- CommonServer/Services/StatusPageService.ts | 32 ++-- CommonServer/Services/StripeService.ts | 6 +- CommonServer/Services/SubscriberService.ts | 4 +- CommonServer/Services/TeamService.ts | 68 ++++----- CommonServer/Services/TwilioService.ts | 40 ++--- CommonServer/Services/UserService.ts | 24 +-- CommonServer/Services/WebHookService.ts | 6 +- CommonServer/Services/ZapierService.ts | 24 ++- CommonUI/src/utils/pricingPlan.ts | 2 +- ContainerScanner/utils/containerService.ts | 6 +- Dashboard/index.ts | 4 +- Dashboard/src/Actions/Base/base.ts | 2 +- Dashboard/src/Actions/alert.ts | 2 +- Dashboard/src/Actions/incident.ts | 18 +-- Dashboard/src/Actions/invoice.ts | 2 +- Dashboard/src/Actions/monitor.ts | 2 +- Dashboard/src/Actions/msteamsWebhook.ts | 4 +- Dashboard/src/Actions/probe.ts | 2 +- Dashboard/src/Actions/project.ts | 4 +- Dashboard/src/Actions/reports.ts | 8 +- Dashboard/src/Actions/resourceCategories.ts | 2 +- Dashboard/src/Actions/schedule.ts | 6 +- Dashboard/src/Actions/scheduledEvent.ts | 4 +- Dashboard/src/Actions/slack.ts | 2 +- Dashboard/src/Actions/slackWebhook.ts | 4 +- Dashboard/src/Actions/tutorial.ts | 4 +- Dashboard/src/Actions/version.ts | 2 +- Dashboard/src/Actions/webHook.ts | 4 +- Dashboard/src/Pages/index.ts | 138 +++++++++++------- Dashboard/src/Reducers/credential.ts | 2 +- Dashboard/src/Reducers/customField.ts | 2 +- Dashboard/src/Reducers/incident.ts | 12 +- Dashboard/src/Reducers/incomingRequest.ts | 8 +- Dashboard/src/Reducers/monitor.ts | 10 +- Dashboard/src/Reducers/monitorCustomField.ts | 2 +- Dashboard/src/Reducers/monitorSla.ts | 2 +- Dashboard/src/Reducers/scheduledEvent.ts | 14 +- Dashboard/src/Reducers/statusPage.ts | 18 ++- Dashboard/src/Utils/ErrorEventUtil.ts | 8 +- Dashboard/src/Utils/formatNumber.ts | 8 +- Dashboard/src/Utils/getParentRoute.ts | 2 +- Dashboard/src/Utils/isMainProjectViewer.ts | 6 +- Dashboard/src/Utils/keybinding.ts | 2 +- .../src/components/Common/countryCode.ts | 4 +- .../src/components/basic/RenderIfAdmin.ts | 2 +- .../src/components/basic/RenderIfMember.ts | 2 +- .../src/components/basic/RenderIfOwner.ts | 2 +- .../basic/RenderIfSubProjectAdmin.ts | 2 +- .../basic/RenderIfSubProjectMember.ts | 2 +- .../basic/RenderIfSubProjectOwner.ts | 2 +- .../basic/RenderIfUserInSubProject.ts | 2 +- .../src/components/basic/RenderIfViewer.ts | 2 +- Dashboard/src/useNotification.ts | 2 +- .../middlewares/probeAuthorization.ts | 2 +- .../services/automatedScriptService.ts | 6 +- .../services/incidentTimelineService.ts | 2 +- DataIngestor/services/monitorLogService.ts | 2 +- DataIngestor/services/probeService.ts | 76 +++++----- Home/index.ts | 24 +-- InitScript/index.ts | 2 +- InitScript/scripts/3.0.1979.ts | 4 +- InitScript/scripts/3.0.2470.ts | 2 +- InitScript/scripts/3.0.3061.ts | 4 +- InitScript/scripts/3.0.4342.ts | 4 +- InitScript/scripts/3.0.7311.ts | 2 +- InitScript/scripts/3.0.8310.ts | 2 +- InitScript/scripts/3.0.8390.ts | 2 +- InitScript/scripts/3.0.8395.ts | 2 +- InitScript/scripts/3.0.8396.ts | 2 +- InitScript/scripts/3.0.8397.ts | 2 +- InitScript/scripts/3.0.8400.ts | 2 +- InitScript/scripts/3.0.8500.ts | 2 +- InitScript/scripts/3.0.8600.ts | 2 +- InitScript/scripts/3.0.8700.ts | 2 +- InitScript/scripts/3.0.8800.ts | 2 +- InitScript/scripts/3.0.8900.ts | 2 +- InitScript/scripts/3.0.8910.ts | 12 +- InitScript/scripts/3.0.9000.ts | 2 +- InitScript/scripts/3.0.9100.ts | 2 +- InitScript/scripts/3.0.9200.ts | 2 +- InitScript/scripts/3.0.9300.ts | 2 +- InitScript/scripts/3.0.9301.ts | 2 +- InitScript/scripts/3.0.9305.ts | 2 +- InitScript/scripts/3.0.9309.ts | 2 +- InitScript/scripts/3.0.9316.ts | 2 +- InitScript/scripts/3.0.9318.ts | 4 +- InitScript/scripts/3.0.9323.ts | 20 +-- InitScript/scripts/3.0.9326.ts | 6 +- InitScript/scripts/3.0.9368.ts | 4 +- InitScript/util/encryptDecrypt.ts | 4 +- InitScript/util/getSlug.ts | 2 +- InitScript/util/randomChar.ts | 4 +- .../src/cli/server-monitor/bin/index.ts | 10 +- .../src/cli/server-monitor/lib/api.ts | 7 +- .../src/cli/server-monitor/lib/logger.ts | 2 +- .../server-monitor/out/scripts/linenumber.ts | 6 +- .../out/scripts/prettify/prettify.ts | 38 ++--- .../test/server-monitor.test.ts | 38 ++--- JavaScriptSDK/src/listener.ts | 45 +++--- .../src/listeners/incomingListener.ts | 19 ++- JavaScriptSDK/src/listeners/mongoose.ts | 18 +-- .../src/listeners/outgoingListener.ts | 18 +-- JavaScriptSDK/src/logger.ts | 6 +- JavaScriptSDK/src/performanceTracker.ts | 21 ++- JavaScriptSDK/src/tracker.ts | 31 ++-- JavaScriptSDK/src/util.ts | 76 ++++++---- JavaScriptSDK/src/utils/dataStore.ts | 18 +-- JavaScriptSDK/src/utils/hrTimer.ts | 4 +- JavaScriptSDK/src/utils/perfTimer.ts | 6 +- JavaScriptSDK/test/logger.test.ts | 34 +++-- JavaScriptSDK/test/tracker.test.ts | 110 +++++++------- Licensing/src/Services/LicenseService.ts | 2 +- LighthouseRunner/utils/urlService.ts | 2 +- LighthouseRunner/workers/urlMonitors.ts | 2 +- Mail/API/Mail.ts | 4 +- Probe/utils/apiService.ts | 2 +- Probe/workers/apiMonitors.ts | 4 +- Probe/workers/incomingHttpRequestMonitors.ts | 6 +- Probe/workers/ipMonitors.ts | 10 +- Probe/workers/kubernetesMonitors.ts | 16 +- Probe/workers/main.ts | 2 +- Probe/workers/urlMonitors.ts | 4 +- ScriptRunner/utils/scriptSandbox.ts | 2 +- StatusPage/index.ts | 14 +- StatusPage/src/Actions/probe.ts | 2 +- StatusPage/src/Reducer/status.ts | 50 +++---- StatusPage/src/config.ts | 16 +- .../accounts/accounts.test.ts | 8 +- Tests/enterprise-tests/accounts/login.test.ts | 8 +- .../accounts/register.test.ts | 14 +- .../admin-dashboard/About.test.ts | 16 +- .../admin-dashboard/AuditLog.test.ts | 18 +-- .../admin-dashboard/CreateUser.test.ts | 19 ++- .../admin-dashboard/EmailLog.test.ts | 14 +- .../admin-dashboard/KeyboardShortcut.test.ts | 28 ++-- .../admin-dashboard/License.test.ts | 4 +- .../admin-dashboard/Project.test.ts | 27 ++-- .../admin-dashboard/Settings.test.ts | 16 +- .../admin-dashboard/SmsLog.test.ts | 14 +- .../admin-dashboard/TwilioSettings.test.ts | 30 ++-- .../admin-dashboard/Users.test.ts | 14 +- .../admin-dashboard/admin-dashboard.test.ts | 6 +- .../dashboard/Billing.test.ts | 6 +- .../dashboard/CreateProject.test.ts | 16 +- .../dashboard/Monitor.test.ts | 2 +- .../dashboard/MonitorSubProject.test.ts | 2 +- .../dashboard/SubProject.test.ts | 2 +- .../dashboard/TeamSubProject.test.ts | 2 +- Tests/enterprise-tests/dashboard/User.test.ts | 14 +- .../dashboard/UserLogout.test.ts | 2 +- .../http-test-server/homePage.test.ts | 2 +- .../http-test-server/settings.test.ts | 8 +- .../http-test-server/test-utils.ts | 2 +- .../licensing/license.test.ts | 2 +- Tests/enterprise-tests/server/server.test.ts | 2 +- Tests/saas-tests/accounts/accounts.test.ts | 6 +- .../accounts/changePassword.test.ts | 6 +- Tests/saas-tests/accounts/login.test.ts | 21 +-- Tests/saas-tests/accounts/register.test.ts | 10 +- .../saas-tests/accounts/resetPassword.test.ts | 4 +- .../accounts/userRedirectRegister.test.ts | 4 +- .../admin-dashboard/Project.test.ts | 24 ++- .../admin-dashboard/SMTPSettings.test.ts | 8 +- Tests/saas-tests/admin-dashboard/Sso.test.ts | 49 ++++--- Tests/saas-tests/admin-dashboard/User.test.ts | 17 ++- Tests/saas-tests/api-docs/api-docs.test.ts | 2 +- Tests/saas-tests/backend/backend.test.ts | 2 +- Tests/saas-tests/backend/env-var.test.ts | 4 +- .../dashboard/ApplicationLog2.test.ts | 2 +- .../dashboard/ApplicationSecurity.test.ts | 63 ++++---- .../ApplicationSecurityReload.test.ts | 21 +-- Tests/saas-tests/dashboard/Billing.test.ts | 22 +-- .../dashboard/BillingReload.test.ts | 4 +- .../dashboard/CallRoutingReload.test.ts | 4 +- Tests/saas-tests/dashboard/Component2.test.ts | 41 +++--- Tests/saas-tests/dashboard/Component3.test.ts | 14 +- .../dashboard/ComponentReload.test.ts | 2 +- .../dashboard/ContainerSecurity.test.ts | 41 +++--- .../dashboard/CreateProject.test.ts | 16 +- Tests/saas-tests/dashboard/Credential.test.ts | 17 ++- .../saas-tests/dashboard/Credential2.test.ts | 39 ++--- .../dashboard/DashboardReload.test.ts | 2 +- .../dashboard/DeleteAccount.test.ts | 12 +- .../dashboard/DomainsReload.test.ts | 4 +- .../dashboard/EmailSettingsReload.test.ts | 4 +- .../saas-tests/dashboard/ErrorTracker.test.ts | 2 +- .../dashboard/GitCredentialsReload.test.ts | 8 +- .../dashboard/IncidentNotification.test.ts | 44 +++--- .../dashboard/IncidentSubProject.test.ts | 39 ++--- .../dashboard/IncidentTimeline.test.ts | 28 ++-- .../dashboard/IncomingRequest.test.ts | 17 ++- .../dashboard/IntegrationsReload.test.ts | 6 +- Tests/saas-tests/dashboard/Monitor.test.ts | 4 +- Tests/saas-tests/dashboard/Monitor6.test.ts | 2 +- Tests/saas-tests/dashboard/Monitor7.test.ts | 2 +- Tests/saas-tests/dashboard/Monitor9.test.ts | 37 +++-- .../dashboard/MonitorDetail.test.ts | 12 +- .../dashboard/MonitorDetail2.test.ts | 39 +++-- .../dashboard/MonitorDetail3.test.ts | 4 +- .../dashboard/MonitorDetail4.test.ts | 10 +- .../dashboard/MonitorDetail5.test.ts | 16 +- .../dashboard/MonitorDetail6.test.ts | 12 +- .../dashboard/MonitorReload.test.ts | 2 +- .../dashboard/MonitorSubProject.test.ts | 14 +- .../dashboard/MonitorSubscribeBySms.test.ts | 6 +- .../dashboard/MonitorSubscribers.test.ts | 8 +- Tests/saas-tests/dashboard/NewMonitor.test.ts | 6 +- .../saas-tests/dashboard/NewMonitor2.test.ts | 2 +- .../saas-tests/dashboard/NewMonitor3.test.ts | 4 +- .../saas-tests/dashboard/OneUptimeApi.test.ts | 2 +- Tests/saas-tests/dashboard/Probe.test.ts | 4 +- .../saas-tests/dashboard/ProbeReload.test.ts | 4 +- Tests/saas-tests/dashboard/Profile.test.ts | 2 +- .../dashboard/ResolvedIncident.test.ts | 2 +- .../dashboard/ResourceCategory.test.ts | 30 ++-- .../dashboard/ResourceCategoryReload.test.ts | 4 +- Tests/saas-tests/dashboard/Schedule.test.ts | 17 ++- .../dashboard/ScheduleSubProject.test.ts | 32 ++-- .../dashboard/Scheduled-maintenance.test.ts | 8 +- .../dashboard/ScheduledEventDetails.test.ts | 2 +- .../dashboard/SmsCallReload.test.ts | 4 +- .../saas-tests/dashboard/SmtpSettings.test.ts | 24 +-- .../saas-tests/dashboard/StatusPage2.test.ts | 86 ++++++----- .../saas-tests/dashboard/StatusPage3.test.ts | 24 +-- .../dashboard/StatusPageSubProject.test.ts | 4 +- .../dashboard/SwitchProject.test.ts | 32 ++-- .../dashboard/TeamGroupsReload.test.ts | 4 +- .../dashboard/TeamMemberReload.test.ts | 4 +- .../dashboard/TeamSubProject.test.ts | 32 ++-- .../dashboard/TwoFactorAuthentication.test.ts | 16 +- .../saas-tests/dashboard/UserFeedback.test.ts | 4 +- .../dashboard/incidentPriority.test.ts | 14 +- .../home/downloadWhitepaper.test.ts | 10 +- Tests/saas-tests/home/home.test.ts | 10 +- Tests/saas-tests/home/requestDemo.test.ts | 10 +- .../status-page/status-page.test.ts | 10 +- .../status-page/status-probeBar.test.ts | 4 +- Tests/test-init.ts | 46 +++--- Tests/test-utils.ts | 4 +- _test/error-tracker-js/index.ts | 2 +- _test/logger-js/index.ts | 4 +- _test/performance-tracker/app.ts | 2 +- _test/script-monitor/scriptSandbox.test.ts | 14 +- _test/script-monitor/scriptSandbox.ts | 16 +- 347 files changed, 2213 insertions(+), 1891 deletions(-) diff --git a/Accounts/src/Pages/index.ts b/Accounts/src/Pages/index.ts index 6182c52e13..1445753d81 100755 --- a/Accounts/src/Pages/index.ts +++ b/Accounts/src/Pages/index.ts @@ -1,13 +1,19 @@ import { lazy } from 'react'; -const Login = lazy((): $TSFixMe => import('./Login')); -const SsoLogin = lazy((): $TSFixMe => import('./SsoLogin')); -const Register = lazy((): $TSFixMe => import('./Register')); -const ResetPassword = lazy((): $TSFixMe => import('./ResetPassword')); -const ChangePassword = lazy((): $TSFixMe => import('./ChangePassword')); -const ResendToken = lazy((): $TSFixMe => import('./ResendToken')); -const VerifyAuthToken = lazy((): $TSFixMe => import('./VerifyAuthToken')); -const VerifyBackupCode = lazy((): $TSFixMe => import('./VerifyBackupCode')); +const Login: $TSFixMe = lazy((): $TSFixMe => import('./Login')); +const SsoLogin: $TSFixMe = lazy((): $TSFixMe => import('./SsoLogin')); +const Register: $TSFixMe = lazy((): $TSFixMe => import('./Register')); +const ResetPassword: $TSFixMe = lazy((): $TSFixMe => import('./ResetPassword')); +const ChangePassword: $TSFixMe = lazy( + (): $TSFixMe => import('./ChangePassword') +); +const ResendToken: $TSFixMe = lazy((): $TSFixMe => import('./ResendToken')); +const VerifyAuthToken: $TSFixMe = lazy( + (): $TSFixMe => import('./VerifyAuthToken') +); +const VerifyBackupCode: $TSFixMe = lazy( + (): $TSFixMe => import('./VerifyBackupCode') +); export default { ResetPassword, diff --git a/AdminDashboard/src/Actions/license.ts b/AdminDashboard/src/Actions/license.ts index fec7d0ec4d..723364fcbe 100644 --- a/AdminDashboard/src/Actions/license.ts +++ b/AdminDashboard/src/Actions/license.ts @@ -106,7 +106,7 @@ export const confirmLicense: $TSFixMe = true ); - let data = response.data; + let data: $TSFixMe = response.data; if (data.token) { const response: $TSFixMe = await BackendAPI.post( new Route('globalConfig/'), diff --git a/AdminDashboard/src/Actions/probe.ts b/AdminDashboard/src/Actions/probe.ts index f4de81cb15..75db9c8711 100644 --- a/AdminDashboard/src/Actions/probe.ts +++ b/AdminDashboard/src/Actions/probe.ts @@ -38,7 +38,7 @@ export const getProbes: Function = (skip = 0, limit = 10): void => { limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get(`probe/?skip=${skip}&limit=${limit}`); dispatch(probeRequest(promise)); diff --git a/AdminDashboard/src/Actions/version.ts b/AdminDashboard/src/Actions/version.ts index b458eaa5d9..dffef16b02 100644 --- a/AdminDashboard/src/Actions/version.ts +++ b/AdminDashboard/src/Actions/version.ts @@ -36,11 +36,11 @@ export const resetGetVersion: Function = (): void => { export const getVersion: Function = (): void => { return function (dispatch: Dispatch): void { - let promise = null; - let backendPromise = null; - let helmChartPromise = null; - let docsPromise = null; - let dashboardPromise = null; + let promise: $TSFixMe = null; + let backendPromise: $TSFixMe = null; + let helmChartPromise: $TSFixMe = null; + let docsPromise: $TSFixMe = null; + let dashboardPromise: $TSFixMe = null; backendPromise = BackendAPI.get(new Route('/version')); helmChartPromise = HelmAPI.get(new Route('/version')); @@ -58,7 +58,7 @@ export const getVersion: Function = (): void => { promise.then( (versions): void => { - let versionsObject = {}; + let versionsObject: $TSFixMe = {}; versions.forEach(version => { versionsObject = { ...versionsObject, ...version.data }; }); diff --git a/AdminDashboard/src/Pages/index.ts b/AdminDashboard/src/Pages/index.ts index 8abf628d4d..add6124038 100644 --- a/AdminDashboard/src/Pages/index.ts +++ b/AdminDashboard/src/Pages/index.ts @@ -1,16 +1,16 @@ import { lazy } from 'react'; -const Users = lazy((): $TSFixMe => import('./Users')); -const User = lazy((): $TSFixMe => import('./User')); -const Projects = lazy((): $TSFixMe => import('./Projects')); -const Project = lazy((): $TSFixMe => import('./Project')); -const Probes = lazy((): $TSFixMe => import('./Probes')); -const AuditLogs = lazy((): $TSFixMe => import('./AuditLogs')); -const EmailLogs = lazy((): $TSFixMe => import('./EmailLogs')); -const CallLogs = lazy((): $TSFixMe => import('./CallLogs')); -const SmsLogs = lazy((): $TSFixMe => import('./SmsLogs')); -const Settings = lazy((): $TSFixMe => import('./Settings')); -const License = lazy((): $TSFixMe => import('./License')); +const Users: $TSFixMe = lazy((): $TSFixMe => import('./Users')); +const User: $TSFixMe = lazy((): $TSFixMe => import('./User')); +const Projects: $TSFixMe = lazy((): $TSFixMe => import('./Projects')); +const Project: $TSFixMe = lazy((): $TSFixMe => import('./Project')); +const Probes: $TSFixMe = lazy((): $TSFixMe => import('./Probes')); +const AuditLogs: $TSFixMe = lazy((): $TSFixMe => import('./AuditLogs')); +const EmailLogs: $TSFixMe = lazy((): $TSFixMe => import('./EmailLogs')); +const CallLogs: $TSFixMe = lazy((): $TSFixMe => import('./CallLogs')); +const SmsLogs: $TSFixMe = lazy((): $TSFixMe => import('./SmsLogs')); +const Settings: $TSFixMe = lazy((): $TSFixMe => import('./Settings')); +const License: $TSFixMe = lazy((): $TSFixMe => import('./License')); export default { Users, diff --git a/AdminDashboard/src/Utils/keybinding.ts b/AdminDashboard/src/Utils/keybinding.ts index 7c99d6cd3e..69a605fbf7 100644 --- a/AdminDashboard/src/Utils/keybinding.ts +++ b/AdminDashboard/src/Utils/keybinding.ts @@ -17,7 +17,7 @@ const keyBind: Function = ( keys: $TSFixMe, resetKeys: $TSFixMe ): void => { - let shortcut = []; + let shortcut: $TSFixMe = []; // ensure the target is always body and not inside any other element (input, textarea, etc) if (route.shortcut && event.target.localName === 'body' && event.key) { shortcut = route.shortcut.split('+'); diff --git a/ApplicationScanner/index.ts b/ApplicationScanner/index.ts index b6923f2e84..d1c10e018d 100644 --- a/ApplicationScanner/index.ts +++ b/ApplicationScanner/index.ts @@ -6,7 +6,9 @@ import Main from './worker/main'; import cron from 'node-cron'; -const cronApplicationSecurityStartTime = Math.floor(Math.random() * 50); +const cronApplicationSecurityStartTime: $TSFixMe = Math.floor( + Math.random() * 50 +); app.get( ['/application/status', '/status'], diff --git a/ApplicationScanner/utils/api.ts b/ApplicationScanner/utils/api.ts index 6031a8ae80..829f48f295 100755 --- a/ApplicationScanner/utils/api.ts +++ b/ApplicationScanner/utils/api.ts @@ -14,7 +14,7 @@ const _this: $TSFixMe = { }; }, post: (url: URL, data: $TSFixMe) => { - const headers = this.getHeaders(); + const headers: $TSFixMe = this.getHeaders(); return new Promise((resolve, reject) => { axios({ @@ -39,7 +39,7 @@ const _this: $TSFixMe = { }, get: (url: URL) => { - const headers = this.getHeaders(); + const headers: $TSFixMe = this.getHeaders(); return new Promise((resolve, reject) => { axios({ method: 'GET', @@ -62,7 +62,7 @@ const _this: $TSFixMe = { }, put: (url: URL, data: $TSFixMe) => { - const headers = this.getHeaders(); + const headers: $TSFixMe = this.getHeaders(); return new Promise((resolve, reject) => { axios({ method: 'PUT', @@ -86,7 +86,7 @@ const _this: $TSFixMe = { }, delete: (url: URL, data: $TSFixMe) => { - const headers = this.getHeaders(); + const headers: $TSFixMe = this.getHeaders(); return new Promise((resolve, reject) => { axios({ method: 'DELETE', diff --git a/ApplicationScanner/utils/applicationService.ts b/ApplicationScanner/utils/applicationService.ts index 4353e6b077..707d6e0854 100644 --- a/ApplicationScanner/utils/applicationService.ts +++ b/ApplicationScanner/utils/applicationService.ts @@ -1,8 +1,8 @@ import crypto from 'crypto'; import logger from 'CommonServer/utils/Logger'; import EncryptionKeys from './encryptionKeys'; -const algorithm = EncryptionKeys.algorithm; -const key = EncryptionKeys.key; +const algorithm: $TSFixMe = EncryptionKeys.algorithm; +const key: $TSFixMe = EncryptionKeys.key; import git from 'simple-git/promise'; import { v1 as uuidv1 } from 'uuid'; @@ -10,9 +10,9 @@ import Path from 'path'; import ErrorService from './errorService'; import fs from 'fs'; import { promisify } from 'util'; -const readdir = promisify(fs.readdir); -const rmdir = promisify(fs.rmdir); -const unlink = promisify(fs.unlink); +const readdir: $TSFixMe = promisify(fs.readdir); +const rmdir: $TSFixMe = promisify(fs.rmdir); +const unlink: $TSFixMe = promisify(fs.unlink); import { spawn } from 'child_process'; import { updateApplicationSecurityToScanning, @@ -28,7 +28,9 @@ export default { security.gitCredential.gitUsername && security.gitCredential.gitPassword ) { - const decryptedSecurity = await this.decryptPassword(security); + const decryptedSecurity: $TSFixMe = await this.decryptPassword( + security + ); await this.scanApplicationSecurity(decryptedSecurity); } if ( @@ -40,11 +42,11 @@ export default { }, decryptPassword: async function (security): void { - const values = []; - for (let i = 0; i <= 15; i++) { + const values: $TSFixMe = []; + for (let i: $TSFixMe = 0; i <= 15; i++) { values.push(security.gitCredential.iv[i]); } - const iv = Buffer.from(values); + const iv: $TSFixMe = Buffer.from(values); security.gitCredential.gitPassword = await this.decrypt( security.gitCredential.gitPassword, iv @@ -55,8 +57,12 @@ export default { decrypt: (encText, iv) => { const promise: Promise = new Promise((resolve, reject) => { try { - const decipher = crypto.createDecipheriv(algorithm, key, iv); - let decoded = decipher.update(encText, 'hex', 'utf8'); + const decipher: $TSFixMe = crypto.createDecipheriv( + algorithm, + key, + iv + ); + let decoded: $TSFixMe = decipher.update(encText, 'hex', 'utf8'); decoded += decipher.final('utf8'); resolve(decoded); } catch (error) { @@ -67,14 +73,16 @@ export default { }, sshScanApplicationSecurity: async security => { - let securityDir = 'application_security_dir'; + let securityDir: $TSFixMe = 'application_security_dir'; securityDir = await createDir(securityDir); const cloneDirectory: string = `${uuidv1()}security`; // always create unique paths - const repoPath = Path.resolve(securityDir, cloneDirectory); - const conn = new Client(); + const repoPath: $TSFixMe = Path.resolve(securityDir, cloneDirectory); + const conn: $TSFixMe = new Client(); - const url = security.gitRepositoryUrl.split('https://github.com/')[1]; + const url: $TSFixMe = security.gitRepositoryUrl.split( + 'https://github.com/' + )[1]; conn.on('ready', () => { logger.info('SSH Client :: ready'); @@ -83,7 +91,7 @@ export default { .silent(true) .clone(`git@github.com:${url}.git`, cloneDirectory) .then(() => { - const output = spawn('npm', ['install'], { + const output: $TSFixMe = spawn('npm', ['install'], { cwd: repoPath, }); output.on('error', error => { @@ -92,10 +100,14 @@ export default { }); output.on('close', () => { - let auditOutput = ''; - const audit = spawn('npm', ['audit', '--json'], { - cwd: repoPath, - }); + let auditOutput: $TSFixMe = ''; + const audit: $TSFixMe = spawn( + 'npm', + ['audit', '--json'], + { + cwd: repoPath, + } + ); audit.on('error', error => { error.code = 500; @@ -103,12 +115,12 @@ export default { }); audit.stdout.on('data', data => { - const strData = data.toString(); + const strData: $TSFixMe = data.toString(); auditOutput += strData; }); audit.on('close', async () => { - let advisories = []; + let advisories: $TSFixMe = []; auditOutput = JSON.parse(auditOutput); // parse the stringified json for (const key in auditOutput.vulnerabilities) { @@ -117,7 +129,7 @@ export default { ); } - const criticalArr = [], + const criticalArr: $TSFixMe = [], highArr = [], moderateArr = [], lowArr = []; @@ -163,7 +175,7 @@ export default { advisories, }; - const resolvedLog = + const resolvedLog: $TSFixMe = await updateApplicationSecurityLogService({ securityId: security._id, componentId: security.componentId._id, @@ -199,17 +211,17 @@ export default { }, scanApplicationSecurity: async security => { - let securityDir = 'application_security_dir'; + let securityDir: $TSFixMe = 'application_security_dir'; securityDir = await createDir(securityDir); - const USER = security.gitCredential.gitUsername; - const PASS = security.gitCredential.gitPassword; + const USER: $TSFixMe = security.gitCredential.gitUsername; + const PASS: $TSFixMe = security.gitCredential.gitPassword; // format the url - const REPO = formatUrl(security.gitRepositoryUrl); + const REPO: $TSFixMe = formatUrl(security.gitRepositoryUrl); const remote: string = `https://${USER}:${PASS}@${REPO}`; const cloneDirectory: string = `${uuidv1()}security`; // always create unique paths - const repoPath = Path.resolve(securityDir, cloneDirectory); + const repoPath: $TSFixMe = Path.resolve(securityDir, cloneDirectory); // update application security to scanning true // to prevent pulling an applicaiton security multiple times by running cron job @@ -221,7 +233,7 @@ export default { .silent(true) .clone(remote, cloneDirectory) .then(() => { - const output = spawn('npm', ['install'], { + const output: $TSFixMe = spawn('npm', ['install'], { cwd: repoPath, }); output.on('error', error => { @@ -230,10 +242,14 @@ export default { }); output.on('close', () => { - let auditOutput = ''; - const audit = spawn('npm', ['audit', '--json'], { - cwd: repoPath, - }); + let auditOutput: $TSFixMe = ''; + const audit: $TSFixMe = spawn( + 'npm', + ['audit', '--json'], + { + cwd: repoPath, + } + ); audit.on('error', error => { error.code = 500; @@ -241,12 +257,12 @@ export default { }); audit.stdout.on('data', data => { - const strData = data.toString(); + const strData: $TSFixMe = data.toString(); auditOutput += strData; }); audit.on('close', async () => { - let advisories = []; + let advisories: $TSFixMe = []; auditOutput = JSON.parse(auditOutput); // parse the stringified json for (const key in auditOutput.vulnerabilities) { @@ -255,7 +271,7 @@ export default { ); } - const criticalArr = [], + const criticalArr: $TSFixMe = [], highArr = [], moderateArr = [], lowArr = []; @@ -299,7 +315,7 @@ export default { advisories, }; - const resolvedLog = + const resolvedLog: $TSFixMe = await updateApplicationSecurityLogService({ securityId: security._id, componentId: security.componentId._id, @@ -331,10 +347,10 @@ export default { async function deleteFolderRecursive(dir): void { if (fs.existsSync(dir)) { - const entries = await readdir(dir, { withFileTypes: true }); + const entries: $TSFixMe = await readdir(dir, { withFileTypes: true }); await Promise.all( entries.map(entry => { - const fullPath = Path.join(dir, entry.name); + const fullPath: $TSFixMe = Path.join(dir, entry.name); return entry.isDirectory() ? deleteFolderRecursive(fullPath) : unlink(fullPath); @@ -371,7 +387,7 @@ function formatUrl(url): void { function createDir(dirPath): void { return new Promise((resolve, reject) => { - const workPath = Path.resolve(process.cwd(), dirPath); + const workPath: $TSFixMe = Path.resolve(process.cwd(), dirPath); if (fs.existsSync(workPath)) { resolve(workPath); } diff --git a/ApplicationScanner/utils/fsHandlers.ts b/ApplicationScanner/utils/fsHandlers.ts index f6724437ac..926dcf34f8 100644 --- a/ApplicationScanner/utils/fsHandlers.ts +++ b/ApplicationScanner/utils/fsHandlers.ts @@ -1,9 +1,9 @@ import fs from 'fs'; import Path from 'path'; import { promisify } from 'util'; -const readdir = promisify(fs.readdir); -const rmdir = promisify(fs.rmdir); -const unlink = promisify(fs.unlink); +const readdir: $TSFixMe = promisify(fs.readdir); +const rmdir: $TSFixMe = promisify(fs.rmdir); +const unlink: $TSFixMe = promisify(fs.unlink); /** * @description a promise based utility to read content of a file @@ -38,10 +38,10 @@ async function deleteFile(file: $TSFixMe): void { */ async function deleteFolderRecursive(dir: $TSFixMe): void { if (fs.existsSync(dir)) { - const entries = await readdir(dir, { withFileTypes: true }); + const entries: $TSFixMe = await readdir(dir, { withFileTypes: true }); await Promise.all( entries.map(entry => { - const fullPath = Path.join(dir, entry.name); + const fullPath: $TSFixMe = Path.join(dir, entry.name); return entry.isDirectory() ? deleteFolderRecursive(fullPath) : unlink(fullPath); diff --git a/Backend/api/Alert.ts b/Backend/api/Alert.ts index 6258108dc0..f8147478ed 100755 --- a/Backend/api/Alert.ts +++ b/Backend/api/Alert.ts @@ -119,7 +119,7 @@ router.get( const skip: $TSFixMe = req.query['skip'] || 0; const limit: $TSFixMe = req.query['limit'] || 10; - let alerts = [], + let alerts: $TSFixMe = [], count = 0; if (incidentId) { incidentId = incidentId._id; diff --git a/Backend/api/ApplicationScanner.ts b/Backend/api/ApplicationScanner.ts index 1792dbdabe..ca2d702531 100644 --- a/Backend/api/ApplicationScanner.ts +++ b/Backend/api/ApplicationScanner.ts @@ -145,30 +145,32 @@ router.post( const low: $TSFixMe = findLog.data.advisories .filter((e: $TSFixMe) => e.severity === 'low') .slice(0, 10); - const criticalWithTitle = critical.map((advisories: $TSFixMe) => { - const filter: $TSFixMe = advisories.via.filter( - (e: $TSFixMe) => e.severity === advisories.severity - ); - let filterBySeverity; - let filterByTitle; - //This is used to get the library name and description - if (filter.length > 0) { - filterBySeverity = advisories.via.find( + const criticalWithTitle: $TSFixMe = critical.map( + (advisories: $TSFixMe) => { + const filter: $TSFixMe = advisories.via.filter( (e: $TSFixMe) => e.severity === advisories.severity - ).severity; - filterByTitle = advisories.via.find( - (e: $TSFixMe) => e.severity === advisories.severity - ).title; - } else { - filterBySeverity = 'Nil'; - filterByTitle = 'Nil'; + ); + let filterBySeverity; + let filterByTitle; + //This is used to get the library name and description + if (filter.length > 0) { + filterBySeverity = advisories.via.find( + (e: $TSFixMe) => e.severity === advisories.severity + ).severity; + filterByTitle = advisories.via.find( + (e: $TSFixMe) => e.severity === advisories.severity + ).title; + } else { + filterBySeverity = 'Nil'; + filterByTitle = 'Nil'; + } + advisories.severity === filterBySeverity + ? (advisories.title = filterByTitle) + : (advisories.title = 'Nil'); + return advisories; } - advisories.severity === filterBySeverity - ? (advisories.title = filterByTitle) - : (advisories.title = 'Nil'); - return advisories; - }); - const highWithTitle = high.map((advisories: $TSFixMe) => { + ); + const highWithTitle: $TSFixMe = high.map((advisories: $TSFixMe) => { const filter: $TSFixMe = advisories.via.filter( (e: $TSFixMe) => e.severity === advisories.severity ); @@ -192,31 +194,33 @@ router.post( : (advisories.title = 'Nil'); return advisories; }); - const moderateWithTitle = moderate.map((advisories: $TSFixMe) => { - const filter: $TSFixMe = advisories.via.filter( - (e: $TSFixMe) => e.severity === advisories.severity - ); - let filterBySeverity; - let filterByTitle; - //This is used to get the library name and description - if (filter.length > 0) { - filterBySeverity = advisories.via.find( + const moderateWithTitle: $TSFixMe = moderate.map( + (advisories: $TSFixMe) => { + const filter: $TSFixMe = advisories.via.filter( (e: $TSFixMe) => e.severity === advisories.severity - ).severity; - filterByTitle = advisories.via.find( - (e: $TSFixMe) => e.severity === advisories.severity - ).title; - } else { - filterBySeverity = 'Nil'; - filterByTitle = 'Nil'; - } + ); + let filterBySeverity; + let filterByTitle; + //This is used to get the library name and description + if (filter.length > 0) { + filterBySeverity = advisories.via.find( + (e: $TSFixMe) => e.severity === advisories.severity + ).severity; + filterByTitle = advisories.via.find( + (e: $TSFixMe) => e.severity === advisories.severity + ).title; + } else { + filterBySeverity = 'Nil'; + filterByTitle = 'Nil'; + } - advisories.severity === filterBySeverity - ? (advisories.title = filterByTitle) - : (advisories.title = 'Nil'); - return advisories; - }); - const lowWithTitle = low.map((advisories: $TSFixMe) => { + advisories.severity === filterBySeverity + ? (advisories.title = filterByTitle) + : (advisories.title = 'Nil'); + return advisories; + } + ); + const lowWithTitle: $TSFixMe = low.map((advisories: $TSFixMe) => { const filter: $TSFixMe = advisories.via.filter( (e: $TSFixMe) => e.severity === advisories.severity ); @@ -246,7 +250,7 @@ router.post( project.moderateIssues = moderateWithTitle; project.lowIssues = lowWithTitle; - for (let i = 0; i < userIds.length; i++) { + for (let i: $TSFixMe = 0; i < userIds.length; i++) { const userId: $TSFixMe = userIds[i].id; const user: $TSFixMe = await UserService.findOneBy({ query: { _id: userId }, diff --git a/Backend/api/Base.ts b/Backend/api/Base.ts index bc04934b0a..54a80437f9 100644 --- a/Backend/api/Base.ts +++ b/Backend/api/Base.ts @@ -33,7 +33,7 @@ export default ({ res: ExpressResponse ): void => { try { - let item = null; + let item: $TSFixMe = null; if (req.role === 'member') { item = await service.getItemForMember({ @@ -72,10 +72,10 @@ export default ({ res: ExpressResponse ): void => { try { - let query = req.data.query; - let skip = req.data.skip; - let sort = req.data.sort; - let limit = req.data.limit; + let query: $TSFixMe = req.data.query; + let skip: $TSFixMe = req.data.skip; + let sort: $TSFixMe = req.data.sort; + let limit: $TSFixMe = req.data.limit; if (!query) { query = {}; @@ -255,7 +255,7 @@ export default ({ // Create API. if (createApiProps && createApiProps.enabled) { - let createApiPath = '/create'; + let createApiPath: $TSFixMe = '/create'; if (isResourceInProject) { createApiPath = '/:projectId/create'; @@ -269,7 +269,7 @@ export default ({ } if (getApiProps && getApiProps.enabled) { - let getApiProps = '/:id'; + let getApiProps: $TSFixMe = '/:id'; if (isResourceInProject) { getApiProps = '/:projectId/:id'; @@ -283,7 +283,7 @@ export default ({ } if (listApiProps && listApiProps.enabled) { - let listApiProps = '/list'; + let listApiProps: $TSFixMe = '/list'; if (isResourceInProject) { listApiProps = '/:projectId/list'; @@ -297,7 +297,7 @@ export default ({ } if (updateApiProps && updateApiProps.enabled) { - let updateApiProps = '/:id'; + let updateApiProps: $TSFixMe = '/:id'; if (isResourceInProject) { updateApiProps = '/:projectId/:id'; @@ -312,7 +312,7 @@ export default ({ } if (deleteApiProps && deleteApiProps.enabled) { - let deleteApiProps = '/:id'; + let deleteApiProps: $TSFixMe = '/:id'; if (isResourceInProject) { deleteApiProps = '/:projectId/:id'; diff --git a/Backend/api/Component.ts b/Backend/api/Component.ts index 6cccd55e55..b0b3a3fa80 100755 --- a/Backend/api/Component.ts +++ b/Backend/api/Component.ts @@ -595,7 +595,7 @@ router.get( await Promise.all( applicationLogObj.applicationLogs.map( async (elem: $TSFixMe) => { - let logStatus = 'No logs yet'; + let logStatus: $TSFixMe = 'No logs yet'; // confirm if the application log has started collecting logs or not const logs: $TSFixMe = await LogService.getLogsByApplicationLogId( @@ -626,7 +626,7 @@ router.get( await Promise.all( errorTrackerObj.errorTrackers.map( async (errorTracker: $TSFixMe) => { - let errorStatus = 'No Errors yet'; + let errorStatus: $TSFixMe = 'No Errors yet'; const populateIssue: $TSFixMe = [ { path: 'errorTrackerId', select: 'name' }, @@ -666,7 +666,8 @@ router.get( await Promise.all( performanceTrackers.map( async (performanceTracker: $TSFixMe) => { - let trackerStatus = 'Not monitoring performance'; + let trackerStatus: $TSFixMe = + 'Not monitoring performance'; const metrics: $TSFixMe = await PerformanceTrackerMetricService.findBy({ query: { diff --git a/Backend/api/ContainerScanner.ts b/Backend/api/ContainerScanner.ts index aea44e8c19..4196c029c1 100644 --- a/Backend/api/ContainerScanner.ts +++ b/Backend/api/ContainerScanner.ts @@ -138,7 +138,7 @@ router.post( project.moderateIssues = moderate; project.lowIssues = low; - for (let i = 0; i < userIds.length; i++) { + for (let i: $TSFixMe = 0; i < userIds.length; i++) { const userId: $TSFixMe = userIds[i].id; const user: $TSFixMe = await UserService.findOneBy({ query: { _id: userId }, diff --git a/Backend/api/EmailSmtp.ts b/Backend/api/EmailSmtp.ts index fb359dd5cd..56d5efe36a 100755 --- a/Backend/api/EmailSmtp.ts +++ b/Backend/api/EmailSmtp.ts @@ -25,7 +25,7 @@ router.post( isUserMasterAdmin, async (req: ExpressRequest, res: ExpressResponse) => { try { - let data = req.body; + let data: $TSFixMe = req.body; if (data.smtpToUse === 'customSmtp') { if (!data.user) { return sendErrorResponse(req, res, { diff --git a/Backend/api/ErrorTracker.ts b/Backend/api/ErrorTracker.ts index 12544a5ea1..d5163478ce 100644 --- a/Backend/api/ErrorTracker.ts +++ b/Backend/api/ErrorTracker.ts @@ -644,7 +644,7 @@ router.post( }); } - let updateData = {}; + let updateData: $TSFixMe = {}; switch (action) { case 'ignore': @@ -695,7 +695,7 @@ router.post( } const issues: $TSFixMe = []; - for (let index = 0; index < issueId.length; index++) { + for (let index: $TSFixMe = 0; index < issueId.length; index++) { const currentIssueId: $TSFixMe = issueId[index]; const query: $TSFixMe = { _id: currentIssueId, diff --git a/Backend/api/Incident.ts b/Backend/api/Incident.ts index d3523f72b2..f1f60c445d 100755 --- a/Backend/api/Incident.ts +++ b/Backend/api/Incident.ts @@ -144,12 +144,12 @@ router.post( ? null : req.user.id : null; - let createdByApi = false; + let createdByApi: $TSFixMe = false; if (req.user && req.user.id === 'API') { createdByApi = true; } - let oldIncidentsCount = null; + let oldIncidentsCount: $TSFixMe = null; // monitors should be an array containing id of monitor(s) if (monitors && !Array.isArray(monitors)) { @@ -254,7 +254,7 @@ router.post( // include date range try { const { startDate, endDate }: $TSFixMe = req.body; - let query = { + let query: $TSFixMe = { 'monitors.monitorId': { $in: [monitorId] }, }; @@ -415,7 +415,9 @@ router.get( query: { projectId }, select: '_id', }); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor._id + ); const query: $TSFixMe = { 'monitors.monitorId': { $in: monitorIds }, @@ -562,7 +564,7 @@ router.post( ? null : req.user.id : null; - let acknowledgedByApi = false; + let acknowledgedByApi: $TSFixMe = false; if (req.user && req.user.id === 'API') { acknowledgedByApi = true; @@ -728,7 +730,7 @@ router.post( ? null : req.user.id : null; - let resolvedByApi = false; + let resolvedByApi: $TSFixMe = false; if (req.user && req.user.id === 'API') { resolvedByApi = true; @@ -1062,7 +1064,7 @@ router.post( }); } } - let incidentMessage = null; + let incidentMessage: $TSFixMe = null; if (incident && incident._id) { data.incidentId = incidentId; @@ -1542,7 +1544,7 @@ router.get( getUser, isAuthorized, async (req: ExpressRequest, res: ExpressResponse) => { - let type = 'investigation'; + let type: $TSFixMe = 'investigation'; if (req.query.type && req.query.type === 'internal') { type = 'internal'; } @@ -1558,7 +1560,7 @@ router.get( }); if (incidentId) { incidentId = incidentId._id; - let skip = 0, + let skip: $TSFixMe = 0, limit = 0; if (type === 'investigation') { skip = req.query['skip'] || 0; diff --git a/Backend/api/Invoice.ts b/Backend/api/Invoice.ts index 87c42b807b..7530c57de9 100755 --- a/Backend/api/Invoice.ts +++ b/Backend/api/Invoice.ts @@ -16,8 +16,8 @@ import { sendListResponse } from 'CommonServer/Utils/response'; router.post('/:userId', async (req: ExpressRequest, res: ExpressResponse) => { try { const userId: $TSFixMe = req.params.userId; - let startingAfter = req.query.startingAfter; - let endingBefore = req.query.endingBefore; + let startingAfter: $TSFixMe = req.query.startingAfter; + let endingBefore: $TSFixMe = req.query.endingBefore; if (startingAfter === 'undefined') { startingAfter = {}; diff --git a/Backend/api/Lighthouse.ts b/Backend/api/Lighthouse.ts index 37a1c5fc46..59f534f6d1 100644 --- a/Backend/api/Lighthouse.ts +++ b/Backend/api/Lighthouse.ts @@ -243,7 +243,7 @@ router.post( project.seoIssues = seoIssues; project.pwaIssues = pwaIssues; - for (let i = 0; i < userIds.length; i++) { + for (let i: $TSFixMe = 0; i < userIds.length; i++) { const userId: $TSFixMe = userIds[i].id; const user: $TSFixMe = await UserService.findOneBy({ query: { _id: userId }, diff --git a/Backend/api/Monitor.ts b/Backend/api/Monitor.ts index e898ab8462..e2ac7fdd03 100755 --- a/Backend/api/Monitor.ts +++ b/Backend/api/Monitor.ts @@ -476,7 +476,7 @@ router.get( try { // const { projectId }: $TSFixMe = req.params; const { skip, limit, componentSlug }: $TSFixMe = req.query; - let componentId = req.query.componentId; + let componentId: $TSFixMe = req.query.componentId; let component; if (!componentId) { diff --git a/Backend/api/PerformanceTracker.ts b/Backend/api/PerformanceTracker.ts index b3c6f0dd99..c0e4af4848 100644 --- a/Backend/api/PerformanceTracker.ts +++ b/Backend/api/PerformanceTracker.ts @@ -112,7 +112,7 @@ router.get( const { performanceTrackerId }: $TSFixMe = req.params; const { slug }: $TSFixMe = req.query; try { - let performanceTracker = null; + let performanceTracker: $TSFixMe = null; const select: $TSFixMe = 'componentId name slug key showQuickStart createdById'; const populate: $TSFixMe = [ diff --git a/Backend/api/Project.ts b/Backend/api/Project.ts index 11f98711fe..61e776d514 100755 --- a/Backend/api/Project.ts +++ b/Backend/api/Project.ts @@ -243,8 +243,8 @@ router.get( query: { 'users.userId': userId }, select: 'parentProjectId _id', }); - let parentProjectIds = []; - let projectIds = []; + let parentProjectIds: $TSFixMe = []; + let projectIds: $TSFixMe = []; if (userProjects.length > 0) { const subProjects: $TSFixMe = userProjects .map((project: $TSFixMe) => @@ -445,7 +445,7 @@ router.put( }); } - let data = req.body; + let data: $TSFixMe = req.body; const minimumBalance: $TSFixMe = Number(data.minimumBalance); const rechargeToBalance: $TSFixMe = Number(data.rechargeToBalance); @@ -602,7 +602,7 @@ router.delete( }); } - let userId = null; + let userId: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: projectId }, @@ -1127,7 +1127,7 @@ router.put( async (req: ExpressRequest, res: ExpressResponse) => { try { const projectId: $TSFixMe = req.params.projectId; - let limit = req.body.alertLimit; + let limit: $TSFixMe = req.body.alertLimit; if (!limit) { return sendErrorResponse(req, res, { code: 400, diff --git a/Backend/api/Schedule.ts b/Backend/api/Schedule.ts index 03c96147e7..ca0b18e015 100755 --- a/Backend/api/Schedule.ts +++ b/Backend/api/Schedule.ts @@ -260,7 +260,7 @@ router.post( const userId: $TSFixMe = req.user ? req.user.id : null; const scheduleId: $TSFixMe = req.params.scheduleId; const escalations: $TSFixMe = []; - let escalationPolicyCount = 0; + let escalationPolicyCount: $TSFixMe = 0; for (const value of req.body) { escalationPolicyCount++; const storagevalue: $TSFixMe = {}; diff --git a/Backend/api/Search.ts b/Backend/api/Search.ts index 45e9f7d99a..5e370f99de 100644 --- a/Backend/api/Search.ts +++ b/Backend/api/Search.ts @@ -260,7 +260,7 @@ const getUsers: Function = async (projectIds: $TSFixMe, val: $TSFixMe): void => projects.forEach((project: $TSFixMe) => { projectUsers.push(project.users); }); - const userIds = projectUsers.flat().map((user: $TSFixMe) => user.userId); + const userIds: $TSFixMe = projectUsers.flat().map((user: $TSFixMe) => user.userId); const users: $TSFixMe = await UserService.findBy({ query: { _id: { $in: userIds }, @@ -466,7 +466,7 @@ const getErrorTrackers: $TSFixMe: Function = async ( query: { projectId: { $in: projectIds }, deleted: false }, select: '_id', }); - const componentIds = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); const select: $TSFixMe = 'componentId name slug key showQuickStart resourceCategory createdById createdAt'; const populate: $TSFixMe = [ @@ -518,7 +518,7 @@ const getLogContainers: $TSFixMe: Function = async ( query: { projectId: { $in: projectIds }, deleted: false }, select: '_id', }); - const componentIds = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); const populateAppLogs: $TSFixMe = [ { path: 'componentId', @@ -575,7 +575,7 @@ const getPerformanceTrackers: $TSFixMe: Function = async ( select: 'id', }); - const componentIds = components.map((component: $TSFixMe) => component._id); + const componentIds: $TSFixMe = components.map((component: $TSFixMe) => component._id); const selectPerfTracker: $TSFixMe = 'componentId name slug key showQuickStart createdById'; diff --git a/Backend/api/SiteManager.ts b/Backend/api/SiteManager.ts index 3e38c195c1..d49fab4d49 100644 --- a/Backend/api/SiteManager.ts +++ b/Backend/api/SiteManager.ts @@ -129,7 +129,7 @@ router.delete('/site', async (req: ExpressRequest, res: ExpressResponse) => { const { subject }: $TSFixMe = req.query; // still handle this for legacy code const { domains }: $TSFixMe = req.body; - let site = null; + let site: $TSFixMe = null; if (subject && subject.trim()) { site = await SiteManagerService.hardDelete({ subject }); diff --git a/Backend/api/Slack.ts b/Backend/api/Slack.ts index b9353a3df8..292b8757b1 100755 --- a/Backend/api/Slack.ts +++ b/Backend/api/Slack.ts @@ -24,7 +24,7 @@ const router: $TSFixMe = express.getRouter(); router.get('/auth/redirect', (req: ExpressRequest, res: ExpressResponse) => { // get oneuptime project id from slack auth state query params - let state = req.query.state; + let state: $TSFixMe = req.query.state; const slackCode: $TSFixMe = req.query.code; if (!slackCode) { diff --git a/Backend/api/StatusPage.ts b/Backend/api/StatusPage.ts index 321f0df8e7..cfac17beb0 100755 --- a/Backend/api/StatusPage.ts +++ b/Backend/api/StatusPage.ts @@ -455,7 +455,7 @@ router.get( ], }); - let domainObj = {}; + let domainObj: $TSFixMe = {}; statusPage && statusPage.domains && statusPage.domains.forEach((eachDomain: $TSFixMe) => { @@ -550,7 +550,7 @@ router.put( }); } - for (let i = 0; i < data.links.length; i++) { + for (let i: $TSFixMe = 0; i < data.links.length; i++) { if (!data.links[i].name) { return sendErrorResponse(req, res, { code: 400, @@ -913,7 +913,7 @@ router.get( const url: $TSFixMe = req.query.url; const user: $TSFixMe = req.user; - let statusPage = {}; + let statusPage: $TSFixMe = {}; const populateStatusPage: $TSFixMe = [ { path: 'projectId', @@ -991,8 +991,8 @@ router.post( }); } - let statusPageProjectId = projectId; - let filterMonitors = false; + let statusPageProjectId: $TSFixMe = projectId; + let filterMonitors: $TSFixMe = false; if (subProjectId) { statusPageProjectId = subProjectId; filterMonitors = true; @@ -1020,7 +1020,7 @@ router.get( const url: $TSFixMe = req.query.url; const user: $TSFixMe = req.user; - let statusPage = {}; + let statusPage: $TSFixMe = {}; try { // Call the StatusPageService. @@ -1226,7 +1226,7 @@ router.get( '/:projectId/:monitorId/individualnotes', checkUser, async (req, res): void => { - let date = req.query.date; + let date: $TSFixMe = req.query.date; date = new Date(date); const theme: $TSFixMe = req.query.theme; @@ -1266,7 +1266,7 @@ router.get( skip, limit ); - let notes = response.investigationNotes; + let notes: $TSFixMe = response.investigationNotes; if ((theme && typeof theme === 'boolean') || theme === 'true') { const updatedNotes: $TSFixMe = []; if (notes.length > 0) { @@ -1319,7 +1319,7 @@ router.get( theme ); - let events = response.events; + let events: $TSFixMe = response.events; const count: $TSFixMe = response.count; if ((theme && typeof theme === 'boolean') || theme === 'true') { const results: $TSFixMe = await fetchNotes(events, limit); @@ -1435,7 +1435,7 @@ router.get( '/:projectId/:monitorId/individualevents', checkUser, async (req, res): void => { - let date = req.query.date; + let date: $TSFixMe = req.query.date; date = moment(date).endOf('day').format(); @@ -1461,7 +1461,7 @@ router.get( skip, limit ); - let events = response.scheduledEvents; + let events: $TSFixMe = response.scheduledEvents; const count: $TSFixMe = response.count; if ((theme && typeof theme === 'boolean') || theme === 'true') { const updatedEvents: $TSFixMe = []; @@ -2173,7 +2173,7 @@ router.get( statusPageId, }), ]); - let announcementLogs = logs; + let announcementLogs: $TSFixMe = logs; if ((theme && typeof theme === 'boolean') || theme === 'true') { const updatedLogs: $TSFixMe = []; @@ -2297,7 +2297,7 @@ const formatNotes: Function = (data = [], days: $TSFixMe): void => { const result: $TSFixMe = []; const limit: $TSFixMe = days - 1; - for (let i = 0; i <= limit; i++) { + for (let i: $TSFixMe = 0; i <= limit; i++) { const date: $TSFixMe = new Date(); date.setDate(date.getDate() - i); @@ -2646,7 +2646,7 @@ async function getStatusPage( ): void { const url: $TSFixMe = req.query.url; const user: $TSFixMe = req.user; - let statusPage = {}; + let statusPage: $TSFixMe = {}; const populateStatusPage: $TSFixMe = [ { path: 'projectId', @@ -2719,7 +2719,7 @@ async function getOngoingScheduledEvents( theme ); - let events = response.events; + let events: $TSFixMe = response.events; const count: $TSFixMe = response.count; if ((theme && typeof theme === 'boolean') || theme === 'true') { const results: $TSFixMe = await fetchNotes(events, limit); @@ -2897,7 +2897,7 @@ async function getStatusPageNote( const skip: $TSFixMe = req.query['skip'] || 0; const limit: $TSFixMe = req.query['limit'] || 10; const days: $TSFixMe = req.query.days || 14; - const newTheme = theme: $TSFixMe === 'Clean Theme'; + const newTheme: $TSFixMe = theme: $TSFixMe === 'Clean Theme'; // Call the StatusPageService. const response: $TSFixMe = await StatusPageService.getNotes( { slug: statusPageSlug }, @@ -2938,7 +2938,7 @@ async function getAnnouncementLogs( limit = 5, skip = 0 ): void { - const theme = statusPage.theme: $TSFixMe === 'Clean Theme'; + const theme: $TSFixMe = statusPage.theme: $TSFixMe === 'Clean Theme'; if (theme) { limit = statusPage.announcementLogsHistory || 14; } @@ -2981,7 +2981,7 @@ async function calculateTime( ): void { const result: $TSFixMe = {}; const start: $TSFixMe = Date.now(); - const theme = statusPage.theme: $TSFixMe === 'Clean Theme'; + const theme: $TSFixMe = statusPage.theme: $TSFixMe === 'Clean Theme'; if (!theme) { range = 90; } diff --git a/Backend/api/Stripe.ts b/Backend/api/Stripe.ts index c09b264dc0..5d2aa4441e 100755 --- a/Backend/api/Stripe.ts +++ b/Backend/api/Stripe.ts @@ -32,7 +32,7 @@ router.post('/events', async (req: ExpressRequest, res: ExpressResponse) => { try { const event: $TSFixMe = req.body; const customerId: $TSFixMe = event.data.object.customer; - let subscriptionId = event.data.object.subscription; + let subscriptionId: $TSFixMe = event.data.object.subscription; const chargeAttemptCount: $TSFixMe = event.data.object.attempt_count; const invoiceUrl: $TSFixMe = event.data.object.hosted_invoice_url; const webhookType: $TSFixMe = event.type; diff --git a/Backend/api/SubscriberAlert.ts b/Backend/api/SubscriberAlert.ts index a8042485d8..b6ad0dd5a9 100755 --- a/Backend/api/SubscriberAlert.ts +++ b/Backend/api/SubscriberAlert.ts @@ -129,7 +129,7 @@ router.get( const skip: $TSFixMe = req.query['skip'] || 0; const limit: $TSFixMe = req.query['limit'] || 10; - let subscriberAlerts = [], + let subscriberAlerts: $TSFixMe = [], count = 0; if (incidentId) { incidentId = incidentId._id; diff --git a/Backend/api/User.ts b/Backend/api/User.ts index 2a03031863..e052efd968 100755 --- a/Backend/api/User.ts +++ b/Backend/api/User.ts @@ -166,8 +166,8 @@ router.post('/signup', async (req: ExpressRequest, res: ExpressResponse) => { token: req.query.token, }), ]); - let user = userData; - let verified = true; + let user: $TSFixMe = userData; + let verified: $TSFixMe = true; if (token) { user = await UserModel.findOne({ _id: token.userId, @@ -665,7 +665,7 @@ router.post( try { const data: $TSFixMe = req.body; const token: $TSFixMe = data.token; - let userId = data.userId; + let userId: $TSFixMe = data.userId; if (data.email && !data.userId) { const foundUser: $TSFixMe = await UserService.findOneBy({ query: { email: data.email }, @@ -855,7 +855,7 @@ router.post( ); } const numberOfCodes: $TSFixMe = 8; - let firstCounter = 0; + let firstCounter: $TSFixMe = 0; if (Array.isArray(backupCodes) && backupCodes.length) { firstCounter = backupCodes[backupCodes.length - 1].counter + 1; } @@ -1415,7 +1415,7 @@ router.get( global.accountsHost + '/login?status=already-verified' ); } - let dataUpdate = { isVerified: true }; + let dataUpdate: $TSFixMe = { isVerified: true }; if (user.tempEmail && user.tempEmail !== user.email) { dataUpdate = { isVerified: true, diff --git a/Backend/api/Zapier.ts b/Backend/api/Zapier.ts index 199618a479..e98148a23d 100755 --- a/Backend/api/Zapier.ts +++ b/Backend/api/Zapier.ts @@ -48,7 +48,9 @@ router.get( }, select: '_id', }); - const projectIds = projects.map((project: $TSFixMe) => project._id); + const projectIds: $TSFixMe = projects.map( + (project: $TSFixMe) => project._id + ); let monitors: $TSFixMe = await MonitorService.findBy({ query: { projectId: { $in: projectIds } }, select: '_id name', diff --git a/Backend/middlewares/applicationScannerAuthorization.ts b/Backend/middlewares/applicationScannerAuthorization.ts index 0b62c81f75..e6784f1a25 100644 --- a/Backend/middlewares/applicationScannerAuthorization.ts +++ b/Backend/middlewares/applicationScannerAuthorization.ts @@ -75,7 +75,7 @@ export default { applicationScannerVersion = req.body.applicationscannerversion; } - let applicationScanner = null; + let applicationScanner: $TSFixMe = null; if (clusterKey && clusterKey === CLUSTER_KEY) { // if cluster key matches then just query by applicationScanner name, diff --git a/Backend/middlewares/auditLogs.ts b/Backend/middlewares/auditLogs.ts index 091e8f57be..3848f66d4e 100644 --- a/Backend/middlewares/auditLogs.ts +++ b/Backend/middlewares/auditLogs.ts @@ -39,10 +39,11 @@ export default { // - To access 'res.logBody' which is added in 'response' middlewares. // - Also for some resason when run inside docker container only req.end and res.finish get emmited. res.on('finish', async () => { - let userId = req.user && req.user.id ? req.user.id : null; + let userId: $TSFixMe = + req.user && req.user.id ? req.user.id : null; userId = isValidMongoObjectId(userId) ? userId : null; - let projectId = getProjectId(req, res); + let projectId: $TSFixMe = getProjectId(req, res); projectId = isValidMongoObjectId(projectId) ? projectId : null; if (shouldStoreLogs === null) { diff --git a/Backend/middlewares/clusterAuthorization.ts b/Backend/middlewares/clusterAuthorization.ts index 2726ad479e..1845f807d7 100755 --- a/Backend/middlewares/clusterAuthorization.ts +++ b/Backend/middlewares/clusterAuthorization.ts @@ -12,7 +12,7 @@ export default { res: ExpressResponse, next: NextFunction ): void { - let masterAdmin = false; + let masterAdmin: $TSFixMe = false; if (req.authorizationType === 'MASTER-ADMIN') { masterAdmin = true; diff --git a/Backend/middlewares/containerScannerAuthorization.ts b/Backend/middlewares/containerScannerAuthorization.ts index 73385af319..8143dfa5cd 100644 --- a/Backend/middlewares/containerScannerAuthorization.ts +++ b/Backend/middlewares/containerScannerAuthorization.ts @@ -73,7 +73,7 @@ export default { containerScannerVersion = req.body.containerscannerversion; } - let containerScanner = null; + let containerScanner: $TSFixMe = null; if (clusterKey && clusterKey === CLUSTER_KEY) { // if cluster key matches then just query by containerScanner name, diff --git a/Backend/middlewares/ipHandler.ts b/Backend/middlewares/ipHandler.ts index 4074c6bbb9..85da6a26a9 100644 --- a/Backend/middlewares/ipHandler.ts +++ b/Backend/middlewares/ipHandler.ts @@ -64,7 +64,7 @@ const _this: $TSFixMe = { ); } - let clientIp = this.getClientIp(req); // returns client ip or null + let clientIp: $TSFixMe = this.getClientIp(req); // returns client ip or null if (Array.isArray(clientIp)) { clientIp = clientIp[0]; // get the first item on the list } @@ -78,9 +78,9 @@ const _this: $TSFixMe = { } clientIp = clientIp.trim(); - const ipFound = ipWhitelist.some(ip: $TSFixMe => { + const ipFound: $TSFixMe = ipWhitelist.some(ip: $TSFixMe => { if (ip.indexOf('-') !== -1) { - const ipRange = ip.split('-').map((ip: $TSFixMe) => ip.trim()); + const ipRange: $TSFixMe = ip.split('-').map((ip: $TSFixMe) => ip.trim()); return this.inRange(clientIp, ipRange); } @@ -104,7 +104,7 @@ const _this: $TSFixMe = { getClientIp: function (req: $TSFixMe): void { // Cloudflare Connecting Ip. // https://support.cloudflare.com/hc/en-us/articles/200170786-Restoring-original-visitor-IPs-Logging-visitor-IP-addresses - let ip = + let ip: $TSFixMe = req.headers['cf-connecting-ip'] || req.headers['x-original-forwarded-for'] || req.headers['x-forwarded-for'] || diff --git a/Backend/middlewares/probeAuthorization.ts b/Backend/middlewares/probeAuthorization.ts index 09600ecffd..db2c21c4d4 100755 --- a/Backend/middlewares/probeAuthorization.ts +++ b/Backend/middlewares/probeAuthorization.ts @@ -90,7 +90,7 @@ export default { probeVersion = req.body.probeVersion; } - let probeId = null; + let probeId: $TSFixMe = null; const selectProbe: string = '_id probeKey version probeName'; if (clusterKey && clusterKey === CLUSTER_KEY) { diff --git a/Backend/middlewares/project.ts b/Backend/middlewares/project.ts index 01357f44f4..034326cf6f 100755 --- a/Backend/middlewares/project.ts +++ b/Backend/middlewares/project.ts @@ -46,12 +46,12 @@ export default { select: '_id users', }); - let isUserPresentInProject = false; + let isUserPresentInProject: $TSFixMe = false; if (project) { const projectUsers: $TSFixMe = project.users; - for (let i = 0; i < projectUsers.length; i++) { + for (let i: $TSFixMe = 0; i < projectUsers.length; i++) { if (projectUsers[i].userId === userId) { isUserPresentInProject = true; return next(); @@ -68,9 +68,13 @@ export default { if (subProjects && subProjects.length > 0) { for (const subProject of subProjects) { // 'for in' iterate over the keys while 'for of' iterate over the values - const subProjectUsers = subProject.users; // Using 'for in' made subProject.users: $TSFixMe === undefined + const subProjectUsers: $TSFixMe = subProject.users; // Using 'for in' made subProject.users: $TSFixMe === undefined - for (let i = 0; i < subProjectUsers.length; i++) { + for ( + let i: $TSFixMe = 0; + i < subProjectUsers.length; + i++ + ) { if (subProjectUsers[i].userId === userId) { isUserPresentInProject = true; return next(); diff --git a/Backend/middlewares/user.ts b/Backend/middlewares/user.ts index 451df28afe..09206617cf 100755 --- a/Backend/middlewares/user.ts +++ b/Backend/middlewares/user.ts @@ -69,7 +69,7 @@ const _this: $TSFixMe = { const token: $TSFixMe = accessToken.split(' ')[1] || accessToken; //Decode the token - let decoded = null; + let decoded: $TSFixMe = null; try { decoded = await jwt.verify(token, jwtSecretKey); } catch (err) { @@ -214,9 +214,13 @@ const _this: $TSFixMe = { { lastActive: Date.now() } ), ]); - let isUserPresentInProject = false; + let isUserPresentInProject: $TSFixMe = false; if (project) { - for (let i = 0; i < project.users.length; i++) { + for ( + let i: $TSFixMe = 0; + i < project.users.length; + i++ + ) { if (project.users[i].userId === userId) { isUserPresentInProject = true; break; diff --git a/Backend/test/disableSignup.test.ts b/Backend/test/disableSignup.test.ts index 33ec3a7f8e..c34547f1dd 100644 --- a/Backend/test/disableSignup.test.ts +++ b/Backend/test/disableSignup.test.ts @@ -21,7 +21,7 @@ const stripe: $TSFixMe = Stripe(payment.paymentPrivateKey); describe('Disable Sign up test', function (): void { this.timeout(200000); - let token = null; + let token: $TSFixMe = null; this.beforeAll(async function (): void { this.timeout(400000); diff --git a/Backend/test/incident.test.ts b/Backend/test/incident.test.ts index e7881e98e2..d2e45d81aa 100644 --- a/Backend/test/incident.test.ts +++ b/Backend/test/incident.test.ts @@ -527,7 +527,7 @@ describe('Incident API', function (): void { expect(res.body).to.have.property('count'); expect(res.body.count).to.be.equal(1); - const sameType = res.body.data.filter((e: $TSFixMe): void => { + const sameType: $TSFixMe = res.body.data.filter((e: $TSFixMe): void => { return e.type === 'internal'; }); expect(sameType[0].type).to.be.equal(type); diff --git a/Backend/test/incidentAlerts.test.ts b/Backend/test/incidentAlerts.test.ts index f6de8b16c9..f8744e3ddb 100644 --- a/Backend/test/incidentAlerts.test.ts +++ b/Backend/test/incidentAlerts.test.ts @@ -2145,7 +2145,7 @@ describe('SMS/Calls Incident Alerts', function (): void { expect(billingEndpointResponse).to.have.status(200); // create multiple subscribers - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { const newSubscriber: $TSFixMe = await addSubscriberToMonitor({ request, authorization, @@ -2202,7 +2202,7 @@ describe('SMS/Calls Incident Alerts', function (): void { ); expect(alertCharges).to.be.an('array'); - let calculatedBalance = originalProjectBalance; + let calculatedBalance: $TSFixMe = originalProjectBalance; // calculate balance for each alert charge amount and compare it with // alert charge's closing balance const allAlertChargesCorrect: $TSFixMe = alertCharges.every( diff --git a/Backend/test/invoice.test.ts b/Backend/test/invoice.test.ts index 7dadabcd9e..dd795c135f 100644 --- a/Backend/test/invoice.test.ts +++ b/Backend/test/invoice.test.ts @@ -135,7 +135,7 @@ describe('Invoice API', function (): void { }); it('should paginate invoices', async (): void => { - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { await stripe.subscriptions.create({ customer: stripeCustomerId, items: [ diff --git a/Backend/test/rateLimit.test.ts b/Backend/test/rateLimit.test.ts index c698b38049..0f3cbc52fb 100644 --- a/Backend/test/rateLimit.test.ts +++ b/Backend/test/rateLimit.test.ts @@ -27,7 +27,7 @@ describe('API limit rate', function (): void { }); it('should get too many requests response after 3 requests', async (): void => { - for (let i = 1; i <= 3; i++) { + for (let i: $TSFixMe = 1; i <= 3; i++) { requests.push(request.get('/')); } await Promise.all(requests); diff --git a/Backend/test/resourceCategory.test.ts b/Backend/test/resourceCategory.test.ts index fdc1805964..8daeda8704 100644 --- a/Backend/test/resourceCategory.test.ts +++ b/Backend/test/resourceCategory.test.ts @@ -272,8 +272,8 @@ describe('User from other project have access to read / write and delete API.', describe('Non-admin user access to create, delete and access resource category.', function (): void { this.timeout(60000); - let projectIdSecondUser = ''; - let emailToBeInvited = ''; + let projectIdSecondUser: $TSFixMe = ''; + let emailToBeInvited: $TSFixMe = ''; before(function (done): void { this.timeout(40000); diff --git a/Backend/test/schedule.test.ts b/Backend/test/schedule.test.ts index 239809e19f..72324243fc 100644 --- a/Backend/test/schedule.test.ts +++ b/Backend/test/schedule.test.ts @@ -11,7 +11,7 @@ import GlobalConfig from './utils/globalConfig'; const request: $TSFixMe = chai.request.agent(app); import { createUser } from './utils/userSignUp'; -// let log = require('./data/log'); +// let log: $TSFixMe = require('./data/log'); import UserService from '../backend/services/userService'; import ProjectService from '../backend/services/projectService'; import ScheduleService from '../backend/services/scheduleService'; diff --git a/Backend/test/scheduledEvent.test.ts b/Backend/test/scheduledEvent.test.ts index 2518766890..78183deebe 100644 --- a/Backend/test/scheduledEvent.test.ts +++ b/Backend/test/scheduledEvent.test.ts @@ -114,7 +114,7 @@ describe('Scheduled event API', function (): void { []; for ( - let i = 0; + let i: $TSFixMe = 0; i < 12; i++ ) { diff --git a/Backend/test/scheduledEventNote.test.ts b/Backend/test/scheduledEventNote.test.ts index 589d1c3da2..238e511d0e 100644 --- a/Backend/test/scheduledEventNote.test.ts +++ b/Backend/test/scheduledEventNote.test.ts @@ -154,7 +154,7 @@ describe('Scheduled Event Note', function (): void { []; for ( - let i = 0; + let i: $TSFixMe = 0; i < 12; i++ diff --git a/Backend/test/utils/string.ts b/Backend/test/utils/string.ts index 7319a1c6ec..19311abda6 100644 --- a/Backend/test/utils/string.ts +++ b/Backend/test/utils/string.ts @@ -3,11 +3,11 @@ export default { if (!length) { length = 10; } - let result = ''; + let result: $TSFixMe = ''; const characters: $TSFixMe = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; const charactersLength: $TSFixMe = characters.length; - for (let i = 0; i < length; i++) { + for (let i: $TSFixMe = 0; i < length; i++) { result += characters.charAt( Math.floor(Math.random() * charactersLength) ); @@ -16,8 +16,8 @@ export default { }, generateBulkEmails: function (numberOfEmails = 10): void { - let emails = ''; - for (let i = 0; i < numberOfEmails; i++) { + let emails: $TSFixMe = ''; + for (let i: $TSFixMe = 0; i < numberOfEmails; i++) { emails += this.generateRandomString(10) + '@oneuptime.com,'; } // remove the last comma diff --git a/Backend/utils/DateTime.ts b/Backend/utils/DateTime.ts index 8ff1124f05..c952b229bd 100644 --- a/Backend/utils/DateTime.ts +++ b/Backend/utils/DateTime.ts @@ -45,7 +45,9 @@ const _this: $TSFixMe = { : new Date( new Date(new Date().getTime()).setHours(endHour, endMin) ).getTime(); - let current = new Date(new Date().setHours(nowHour, nowMin)).getTime(); + let current: $TSFixMe = new Date( + new Date().setHours(nowHour, nowMin) + ).getTime(); current = current < start && isDifferentDay diff --git a/Backend/utils/api.ts b/Backend/utils/api.ts index 45bc63c5c5..58ea4ceb29 100644 --- a/Backend/utils/api.ts +++ b/Backend/utils/api.ts @@ -16,7 +16,7 @@ export default { }, body: async (val: $TSFixMe, type: $TSFixMe) => { - let bodyContent = {}; + let bodyContent: $TSFixMe = {}; if (type && type === 'formData' && val && val[0] && val[0].key) { val.forEach((bod: $TSFixMe) => { bodyContent[bod.key] = bod.value; diff --git a/Backend/utils/randomChar.ts b/Backend/utils/randomChar.ts index e1c8365fa7..78e07b1e42 100644 --- a/Backend/utils/randomChar.ts +++ b/Backend/utils/randomChar.ts @@ -7,8 +7,8 @@ export default (num = 15): void => { const input: $TSFixMe = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - let output = ''; - for (let i = 0; i < num; i++) { + let output: $TSFixMe = ''; + for (let i: $TSFixMe = 0; i < num; i++) { output += input.charAt(Math.floor(Math.random() * input.length)); } return output; diff --git a/Backend/utils/services.ts b/Backend/utils/services.ts index 07a041de7d..20657f9535 100644 --- a/Backend/utils/services.ts +++ b/Backend/utils/services.ts @@ -4,7 +4,7 @@ export default { let curr; - for (let i = 0; i < arr.length; i++) { + for (let i: $TSFixMe = 0; i < arr.length; i++) { curr = arr[i]; if (!map[curr.identification]) { @@ -20,7 +20,7 @@ export default { rearrangeDuty: async (main = []) => { let closeStringId; - for (let i = 0; i < main.length; i++) { + for (let i: $TSFixMe = 0; i < main.length; i++) { if (typeof main[i].schedule == 'object') { closeStringId = i - 1; } @@ -34,7 +34,7 @@ export default { }, checkCallSchedule: async (arr: $TSFixMe) => { - const isAllFalse = arr.every((a: $TSFixMe) => !a.isOnDuty); + const isAllFalse: $TSFixMe = arr.every((a: $TSFixMe) => !a.isOnDuty); if (isAllFalse) { return arr[0] ? [arr[0]] : []; diff --git a/Backend/utils/stripeHandlers.ts b/Backend/utils/stripeHandlers.ts index 2cd8b90fdb..ebd275d9b6 100644 --- a/Backend/utils/stripeHandlers.ts +++ b/Backend/utils/stripeHandlers.ts @@ -10,7 +10,7 @@ export default { code: $TSFixMe, invoiceUrl: URL ) => { - let data = { + let data: $TSFixMe = { blocks: [ { type: 'header', diff --git a/Backend/workers/subscription.ts b/Backend/workers/subscription.ts index 7daff2419b..10812f433d 100644 --- a/Backend/workers/subscription.ts +++ b/Backend/workers/subscription.ts @@ -25,7 +25,7 @@ const handleFetchingUnpaidSubscriptions: Function = async ( } }; -let data = []; +let data: $TSFixMe = []; const _this: $TSFixMe = { /** * use stripe sdk to check for unpaid subscriptions (saas mode) @@ -57,7 +57,7 @@ const _this: $TSFixMe = { for (const unpaidSubscription of unpaidSubscriptions) { const stripeCustomerId: $TSFixMe = unpaidSubscription.customer; const stripeSubscriptionId: $TSFixMe = unpaidSubscription.id; - let subscriptionEndDate = unpaidSubscription.ended_at; // unix timestamp + let subscriptionEndDate: $TSFixMe = unpaidSubscription.ended_at; // unix timestamp subscriptionEndDate = moment(subscriptionEndDate * 1000); const timeDiff: $TSFixMe = moment().diff( subscriptionEndDate, diff --git a/Common/Types/API/URL.ts b/Common/Types/API/URL.ts index 612aa316b0..aa481ed740 100644 --- a/Common/Types/API/URL.ts +++ b/Common/Types/API/URL.ts @@ -46,7 +46,7 @@ export default class URL { } static fromString(url: string): URL { - let protocol = Protocol.HTTPS; + let protocol: $TSFixMe = Protocol.HTTPS; if (url.startsWith('https://')) { protocol = Protocol.HTTPS; diff --git a/Common/Utils/Slug.ts b/Common/Utils/Slug.ts index 311bce5a67..75dfd827fa 100644 --- a/Common/Utils/Slug.ts +++ b/Common/Utils/Slug.ts @@ -9,7 +9,7 @@ export default class Slug { return ''; } - let slug = slugify(name, { remove: /[&*+~.,\\/()|'"!:@]+/g }); + let slug: $TSFixMe = slugify(name, { remove: /[&*+~.,\\/()|'"!:@]+/g }); slug = `${slug}-${customAlphabet(numbers, 10)}`; slug = slug.toLowerCase(); diff --git a/CommonServer/Infrastructure/ORM.ts b/CommonServer/Infrastructure/ORM.ts index da8b7c791a..13e72d9023 100644 --- a/CommonServer/Infrastructure/ORM.ts +++ b/CommonServer/Infrastructure/ORM.ts @@ -3,7 +3,7 @@ import logger from '../Utils/Logger'; import { DatabaseUrl, IsMongoReplicaSet } from '../Config'; -let options = {}; +let options: $TSFixMe = {}; if (IsMongoReplicaSet) { options = { diff --git a/CommonServer/Middleware/ClusterKeyAuthorization.ts b/CommonServer/Middleware/ClusterKeyAuthorization.ts index 9f15c08df8..129efdcbfb 100644 --- a/CommonServer/Middleware/ClusterKeyAuthorization.ts +++ b/CommonServer/Middleware/ClusterKeyAuthorization.ts @@ -36,7 +36,7 @@ export default class ClusterKeyAuthorization { ); } - const isAuthorized = clusterKey: $TSFixMe === CLUSTER_KEY; + const isAuthorized: $TSFixMe = clusterKey: $TSFixMe === CLUSTER_KEY; if (!isAuthorized) { return sendErrorResponse( diff --git a/CommonServer/Middleware/ProbeAuthorization.ts b/CommonServer/Middleware/ProbeAuthorization.ts index 0ec5814f6d..beb6875723 100644 --- a/CommonServer/Middleware/ProbeAuthorization.ts +++ b/CommonServer/Middleware/ProbeAuthorization.ts @@ -89,7 +89,7 @@ export default { probeVersion = req.body.probeVersion; } - let probeId = null; + let probeId: $TSFixMe = null; if (clusterKey && clusterKey === CLUSTER_KEY) { // if cluster key matches then just query by probe name, diff --git a/CommonServer/Services/AirtableService.ts b/CommonServer/Services/AirtableService.ts index ba698d7055..9aacdc9806 100644 --- a/CommonServer/Services/AirtableService.ts +++ b/CommonServer/Services/AirtableService.ts @@ -130,9 +130,11 @@ export default class Service { .firstPage(); if (records && records.length > 0) { - const recordIds = records.map((record: $TSFixMe): void => { - return record.id; - }); + const recordIds: $TSFixMe = records.map( + (record: $TSFixMe): void => { + return record.id; + } + ); return await base(tableName).destroy(recordIds); } diff --git a/CommonServer/Services/AlertService.ts b/CommonServer/Services/AlertService.ts index 405f07757d..289b0a2a50 100755 --- a/CommonServer/Services/AlertService.ts +++ b/CommonServer/Services/AlertService.ts @@ -70,7 +70,7 @@ export default class Service { query: { _id: monitorId }, select: 'lastMatchedCriterion', }); - let schedules = []; + let schedules: $TSFixMe = []; const populate: $TSFixMe = [ { path: 'userIds', select: 'name' }, { path: 'createdById', select: 'name' }, @@ -131,7 +131,7 @@ export default class Service { select: 'alertOptions', }); const alertOptions: $TSFixMe = project.alertOptions; - let countryType = getCountryType(alertPhoneNumber); + let countryType: $TSFixMe = getCountryType(alertPhoneNumber); if (countryType === 'us') { countryType = 'billingUS'; } else if (countryType === 'non-us') { @@ -327,7 +327,7 @@ export default class Service { populate, }), ]); - let incidentMessages = incidentMsgs; + let incidentMessages: $TSFixMe = incidentMsgs; const [subAlerts, callStatus]: $TSFixMe = await Promise.all([ Services.deduplicate(subscriberAlerts), OnCallScheduleStatusService.findBy({ @@ -355,7 +355,7 @@ export default class Service { (a: $TSFixMe, b: $TSFixMe) => typeof a.schedule !== 'object' && b.createdAt - a.createdAt ); - let filteredMsg = incidentMessages.filter( + let filteredMsg: $TSFixMe = incidentMessages.filter( (a: $TSFixMe) => a.status !== 'internal notes added' && a.status !== 'internal notes updated' @@ -527,9 +527,9 @@ export default class Service { }), ]); - let onCallScheduleStatus = null; - let escalationId = null; - let currentEscalationStatus = null; + let onCallScheduleStatus: $TSFixMe = null; + let escalationId: $TSFixMe = null; + let currentEscalationStatus: $TSFixMe = null; if (callScheduleStatuses.length === 0) { //start with first ecalation policy, and then escalationPolicy will take care of others in escalation policy. escalationId = schedule.escalationIds[0]; @@ -589,10 +589,10 @@ export default class Service { populate: populateEscalation, }); - let shouldSendSMSReminder = false; - let shouldSendCallReminder = false; - let shouldSendEmailReminder = false; - let shouldSendPushReminder = false; + let shouldSendSMSReminder: $TSFixMe = false; + let shouldSendCallReminder: $TSFixMe = false; + let shouldSendEmailReminder: $TSFixMe = false; + let shouldSendPushReminder: $TSFixMe = false; if (!escalation) { return; @@ -705,10 +705,10 @@ export default class Service { return; } - let nextEscalationPolicy = null; + let nextEscalationPolicy: $TSFixMe = null; //find next escalationPolicy. - let found = false; + let found: $TSFixMe = false; for (let escalationId of schedule.escalationIds) { if (found) { nextEscalationPolicy = escalationId; @@ -821,11 +821,11 @@ export default class Service { }); } - const groupUsers = teamGroup.map(group: $TSFixMe => group.teams); + const groupUsers: $TSFixMe = teamGroup.map(group: $TSFixMe => group.teams); const groupUserIds: $TSFixMe = [].concat .apply([], groupUsers) .map(id => ({ userId: id })); - const filterdUserIds = groupUserIds.filter(user: $TSFixMe => + const filterdUserIds: $TSFixMe = groupUserIds.filter(user: $TSFixMe => activeTeam.teamMembers.some( (team: $TSFixMe) => team.userId !== user.userId ) @@ -1166,7 +1166,7 @@ export default class Service { }: $TSFixMe): void { const probeName: $TSFixMe = incident.probes.length > 0 && incident.probes[0].probeId.probeName; - let date = new Date(); + let date: $TSFixMe = new Date(); const monitorId: $TSFixMe = monitor._id; try { const accessToken: $TSFixMe = UserService.getAccessToken({ @@ -1347,7 +1347,7 @@ export default class Service { // const incidentUrl:string: $TSFixMe = `${global.dashboardHost}/project/${monitor.projectId.slug}/component/${componentSlug}/incidents/${incident.slug}`; const incidentUrl: string = `${global.dashboardHost}/project/${projectSlug}/incidents/${incident.slug}`; - let incidentSlaTimeline = incidentCommunicationSla.duration * 60; + let incidentSlaTimeline: $TSFixMe = incidentCommunicationSla.duration * 60; incidentSlaTimeline = secondsToHms(incidentSlaTimeline); const incidentSlaRemaining: $TSFixMe = secondsToHms(alertTime); @@ -1882,7 +1882,7 @@ export default class Service { const monitors: $TSFixMe = incident.monitors.map( (monitor: $TSFixMe) => monitor.monitorId ); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map((monitor: $TSFixMe) => monitor._id); const subscribers: $TSFixMe = await SubscriberService.subscribersForAlert({ subscribed: true, $or: [{ monitorId: { $in: monitorIds } }, { monitorId: null }], @@ -1916,7 +1916,7 @@ export default class Service { for (const monitor of monitors) { if (incident) { for (const subscriber of subscribers) { - let statusPageSlug = null; + let statusPageSlug: $TSFixMe = null; if (subscriber.statusPageId) { const statusPage: $TSFixMe = await StatusPageService.findOneBy({ @@ -2120,9 +2120,9 @@ export default class Service { select: selectOnCallScheduleStatus, populate: populateOnCallScheduleStatus, }); - let onCallScheduleStatus = null; - let escalationId = null; - let currentEscalationStatus = null; + let onCallScheduleStatus: $TSFixMe = null; + let escalationId: $TSFixMe = null; + let currentEscalationStatus: $TSFixMe = null; if (callScheduleStatuses.length === 0) { escalationId = schedule.escalationIds[0]; @@ -2255,7 +2255,7 @@ export default class Service { }: $TSFixMe): void { const projectId: $TSFixMe = incident.projectId._id || incident.projectId; try { - let date = new Date(); + let date: $TSFixMe = new Date(); const accessToken: $TSFixMe = UserService.getAccessToken({ userId: user._id, expiresIn: 12 * 60 * 60 * 1000, @@ -2470,9 +2470,9 @@ export default class Service { select: selectOnCallScheduleStatus, populate: populateOnCallScheduleStatus, }); - let onCallScheduleStatus = null; - let escalationId = null; - let currentEscalationStatus = null; + let onCallScheduleStatus: $TSFixMe = null; + let escalationId: $TSFixMe = null; + let currentEscalationStatus: $TSFixMe = null; if (callScheduleStatuses.length === 0) { escalationId = schedule.escalationIds[0]; @@ -2609,7 +2609,7 @@ export default class Service { const projectId: $TSFixMe = incident.projectId._id || incident.projectId; try { - let date = new Date(); + let date: $TSFixMe = new Date(); const accessToken: $TSFixMe = UserService.getAccessToken({ userId: user._id, expiresIn: 12 * 60 * 60 * 1000, @@ -3066,7 +3066,7 @@ export default class Service { incident: { customFields: incidentCustomFields }, }; - let webhookNotificationSent = true; + let webhookNotificationSent: $TSFixMe = true; const sendAlerts: Function = async (): void => { if (subscriber.alertVia === AlertType.Webhook) { @@ -3108,7 +3108,7 @@ export default class Service { incident.createdAt ); - let alertStatus = 'Pending'; + let alertStatus: $TSFixMe = 'Pending'; try { webhookNotificationSent = @@ -3157,7 +3157,7 @@ export default class Service { } } - let length = getIncidentLength( + let length: $TSFixMe = getIncidentLength( incident.createdAt, incident.acknowledgedAt ); @@ -3265,7 +3265,7 @@ export default class Service { const trackEmailAsViewedUrl: string = `${global.apiHost}/subscriberAlert/${projectId}/${alertId}/viewed`; const unsubscribeUrl: string = `${global.homeHost}/unsubscribe/${monitor._id}/${subscriber._id}`; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if (templateType === 'Subscriber Incident Acknowledged') { if (project.sendAcknowledgedIncidentNotificationEmail) { @@ -3509,7 +3509,7 @@ export default class Service { const countryCode: $TSFixMe = await this.mapCountryShortNameToCountryCode( subscriber.countryCode ); - let contactPhone = subscriber.contactPhone; + let contactPhone: $TSFixMe = subscriber.contactPhone; if (countryCode) { contactPhone = countryCode + contactPhone; } @@ -3631,7 +3631,7 @@ export default class Service { }); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if (templateType === 'Subscriber Incident Acknowledged') { if (project.sendAcknowledgedIncidentNotificationSms) { @@ -3835,7 +3835,7 @@ export default class Service { } }; - let incidentAlert = subscriber.notificationType?.incident; + let incidentAlert: $TSFixMe = subscriber.notificationType?.incident; const statusPageId: $TSFixMe = subscriber?.statusPageId; // if there is no notification type, then set incidentAlert to true. @@ -3990,7 +3990,7 @@ export default class Service { }), TwilioService.getSettings(), ]); - let limit = + let limit: $TSFixMe = project && project.alertLimit ? project.alertLimit : twilioSettings['alert-limit']; @@ -4240,7 +4240,7 @@ export default class Service { ? true : false; - let errorMessageText = null; + let errorMessageText: $TSFixMe = null; if ( (!areEmailAlertsEnabledInGlobalSettings && @@ -4290,7 +4290,7 @@ export default class Service { }); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { const createdBy: $TSFixMe = message.createdById ? message.createdById.name @@ -4406,7 +4406,7 @@ export default class Service { subscriber.countryCode ); - let contactPhone = subscriber.contactPhone; + let contactPhone: $TSFixMe = subscriber.contactPhone; if (countryCode) { contactPhone = countryCode + contactPhone; } @@ -4495,7 +4495,7 @@ export default class Service { }); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if ( project.sendNewScheduledEventInvestigationNoteNotificationSms @@ -4686,7 +4686,7 @@ export default class Service { const unsubscribeUrl: string = `${global.homeHost}/unsubscribe/${subscriber.monitorId}/${subscriber._id}`; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if ( templateType === @@ -4820,7 +4820,7 @@ export default class Service { const countryCode: $TSFixMe = await this.mapCountryShortNameToCountryCode( subscriber.countryCode ); - let contactPhone = subscriber.contactPhone; + let contactPhone: $TSFixMe = subscriber.contactPhone; if (countryCode) { contactPhone = countryCode + contactPhone; } @@ -4900,7 +4900,7 @@ export default class Service { }); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if ( templateType === @@ -5023,7 +5023,7 @@ export default class Service { } }; - let scheduledEventAlert = subscriber.notificationType?.scheduledEvent; + let scheduledEventAlert: $TSFixMe = subscriber.notificationType?.scheduledEvent; const statusPageId: $TSFixMe = subscriber?.statusPageId; if (!subscriber.notificationType) { @@ -5090,7 +5090,7 @@ export default class Service { ? true : false; - let errorMessageText = null; + let errorMessageText: $TSFixMe = null; if ( (!areEmailAlertsEnabledInGlobalSettings && @@ -5136,7 +5136,7 @@ export default class Service { ); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { const replyAddress: $TSFixMe = project.replyAddress ? project.replyAddress @@ -5231,7 +5231,7 @@ export default class Service { await this.mapCountryShortNameToCountryCode( subscriber.countryCode ); - let contactPhone = subscriber.contactPhone; + let contactPhone: $TSFixMe = subscriber.contactPhone; if (countryCode) { contactPhone = countryCode + contactPhone; } @@ -5317,7 +5317,7 @@ export default class Service { ); const alertId: $TSFixMe = subscriberAlert._id; - let alertStatus = null; + let alertStatus: $TSFixMe = null; try { if (project.sendAnnouncementNotificationSms) { sendResult = @@ -5420,7 +5420,7 @@ export default class Service { const unsubscribeUrl: string = `${global.homeHost}/unsubscribe/${subscriber.monitorId}/${subscriber._id}`; - let announcementAlert = + let announcementAlert: $TSFixMe = subscriber.notificationType?.announcement; const statusPageId: $TSFixMe = subscriber?.statusPageId; @@ -5482,7 +5482,7 @@ export default class Service { * @returns an interger */ function calcSmsSegments(sms: $TSFixMe): void { - let smsLength = sms.length; + let smsLength: $TSFixMe = sms.length; smsLength = Number(smsLength); return Math.ceil(smsLength / 160); } diff --git a/CommonServer/Services/ApplicationSecurityLogService.ts b/CommonServer/Services/ApplicationSecurityLogService.ts index 05bcd251ab..2b645c5b8f 100644 --- a/CommonServer/Services/ApplicationSecurityLogService.ts +++ b/CommonServer/Services/ApplicationSecurityLogService.ts @@ -112,7 +112,7 @@ export default class Service { } async deleteBy(query: Query): void { - let securityLog = this.findOneBy({ query, select: '_id' }); + let securityLog: $TSFixMe = this.findOneBy({ query, select: '_id' }); if (!securityLog) { const error: $TSFixMe = new Error( diff --git a/CommonServer/Services/ApplicationSecurityService.ts b/CommonServer/Services/ApplicationSecurityService.ts index 9db18af713..ace009f674 100644 --- a/CommonServer/Services/ApplicationSecurityService.ts +++ b/CommonServer/Services/ApplicationSecurityService.ts @@ -127,7 +127,7 @@ export default class Service { if (data && data.name) { data.slug = getSlug(data.name); } - let applicationSecurity = + let applicationSecurity: $TSFixMe = await ApplicationSecurityModel.findOneAndUpdate( query, { @@ -264,7 +264,7 @@ export default class Service { async decryptPassword(security: $TSFixMe): void { const values: $TSFixMe = []; - for (let i = 0; i <= 15; i++) { + for (let i: $TSFixMe = 0; i <= 15; i++) { values.push(security.gitCredential.iv[i]); } const iv: $TSFixMe = Buffer.from(values); diff --git a/CommonServer/Services/AutomatedScriptService.ts b/CommonServer/Services/AutomatedScriptService.ts index a4755ebf3c..c750ac7575 100644 --- a/CommonServer/Services/AutomatedScriptService.ts +++ b/CommonServer/Services/AutomatedScriptService.ts @@ -225,8 +225,8 @@ export default class Service { if (stackSize > 2) { return; } - const events = Array.isArray(resources) ? resources : [resources]; // object property => {callSchedule?, automatedScript?} - const eventPromises = events.map(event: $TSFixMe => { + const events: $TSFixMe = Array.isArray(resources) ? resources : [resources]; // object property => {callSchedule?, automatedScript?} + const eventPromises: $TSFixMe = events.map(event: $TSFixMe => { let resourceType; if (event.automatedScript) { resourceType = 'automatedScript'; @@ -266,7 +266,7 @@ export default class Service { select: selectScript, populate: populateScript, }); - let data = null; + let data: $TSFixMe = null; if (scriptType === 'JavaScript') { const result: $TSFixMe = await BackendAPI.post(`${scriptBaseUrl}/script/js`, { script, diff --git a/CommonServer/Services/CallLogsService.ts b/CommonServer/Services/CallLogsService.ts index 66799620fc..60ea8f1b14 100644 --- a/CommonServer/Services/CallLogsService.ts +++ b/CommonServer/Services/CallLogsService.ts @@ -24,7 +24,7 @@ export default class Service { status: $TSFixMe, error: $TSFixMe ): void { - let item = new CallLogsModel(); + let item: $TSFixMe = new CallLogsModel(); item.from = from; diff --git a/CommonServer/Services/CallRoutingService.ts b/CommonServer/Services/CallRoutingService.ts index ef9832c731..28a63e2b74 100644 --- a/CommonServer/Services/CallRoutingService.ts +++ b/CommonServer/Services/CallRoutingService.ts @@ -102,7 +102,7 @@ class Service extends DatabaseService { } async reserveNumber(data: $TSFixMe, projectId: ObjectID): void { - let confirmBuy = null; + let confirmBuy: $TSFixMe = null; const hasCustomTwilioSettings: $TSFixMe = await TwilioService.hasCustomSettings(projectId); if (IS_SAAS_SERVICE && !hasCustomTwilioSettings) { @@ -110,7 +110,7 @@ class Service extends DatabaseService { query: { _id: projectId }, select: 'users', }); - let owner = project.users.filter( + let owner: $TSFixMe = project.users.filter( (user: $TSFixMe) => user.role === 'Owner' ); owner = owner && owner.length ? owner[0] : owner; @@ -213,7 +213,7 @@ class Service extends DatabaseService { activeTeam.teamMembers && activeTeam.teamMembers.length ) { - let dutyCheck = 0; + let dutyCheck: $TSFixMe = 0; for (const teamMember of activeTeam.teamMembers) { const [isOnDuty, user]: $TSFixMe = await Promise.all([ AlertService.checkIsOnDuty( @@ -285,7 +285,7 @@ class Service extends DatabaseService { ); if (callDetails && callDetails.price) { const duration: $TSFixMe = callDetails.duration; - let price = callDetails.price; + let price: $TSFixMe = callDetails.price; if (price && price.includes('-')) { price = price.replace('-', ''); } @@ -297,7 +297,7 @@ class Service extends DatabaseService { query: { _id: projectId }, select: 'users', }); - let owner = project.users.filter( + let owner: $TSFixMe = project.users.filter( (user: $TSFixMe) => user.role === 'Owner' ); owner = owner && owner.length ? owner[0] : owner; @@ -313,7 +313,7 @@ class Service extends DatabaseService { select: 'callSid dialTo _id', }); if (callRoutingLog && callRoutingLog.callSid) { - let dialTo = + let dialTo: $TSFixMe = callRoutingLog.dialTo && callRoutingLog.dialTo.length ? callRoutingLog.dialTo : []; @@ -379,7 +379,7 @@ class Service extends DatabaseService { data && data.routingSchema && data.routingSchema.type ? data.routingSchema : {}; - let memberId = null; + let memberId: $TSFixMe = null; const response: $TSFixMe = new twilio.twiml.VoiceResponse(); let forwardingNumber, error, userId, scheduleId; @@ -514,7 +514,7 @@ class Service extends DatabaseService { select: '_id dialTo callSid', }); if (callRoutingLog && callRoutingLog.callSid) { - let dialTo = + let dialTo: $TSFixMe = callRoutingLog.dialTo && callRoutingLog.dialTo.length ? callRoutingLog.dialTo : []; @@ -678,7 +678,7 @@ class Service extends DatabaseService { if (callRouting && callRouting.length) { const select: $TSFixMe = 'callRoutingId callSid price calledFrom calledTo duration dialTo'; - for (let i = 0; i < callRouting.length; i++) { + for (let i: $TSFixMe = 0; i < callRouting.length; i++) { const callRoutingId: $TSFixMe = callRouting[i]._id; const callLogs: $TSFixMe = await CallRoutingLogService.findBy({ query: { callRoutingId }, diff --git a/CommonServer/Services/ComponentService.ts b/CommonServer/Services/ComponentService.ts index 35f4680cb4..6a6f118438 100755 --- a/CommonServer/Services/ComponentService.ts +++ b/CommonServer/Services/ComponentService.ts @@ -55,7 +55,7 @@ export default class Service { select: '_id stripePlanId seats', }); } - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; const subProjects: $TSFixMe = await ProjectService.findBy({ query: { parentProjectId: project._id }, @@ -68,12 +68,12 @@ export default class Service { const count: $TSFixMe = await this.countBy({ projectId: { $in: subProjectIds }, }); - let plan = Plans.getPlanById(project.stripePlanId); + let plan: $TSFixMe = Plans.getPlanById(project.stripePlanId); // null plan => enterprise plan plan = plan && plan.category ? plan : { category: 'Enterprise' }; - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -298,7 +298,7 @@ export default class Service { ).populate('deletedById', 'name'); if (component) { - let subProject = null; + let subProject: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: component.projectId }, @@ -313,7 +313,7 @@ export default class Service { }); } - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; const subProjects: $TSFixMe = await ProjectService.findBy({ query: { parentProjectId: project._id }, @@ -328,7 +328,7 @@ export default class Service { const componentsCount: $TSFixMe = await this.countBy({ projectId: { $in: subProjectIds }, }); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -454,7 +454,7 @@ export default class Service { query, select: 'seats stripeSubscriptionId _id', }); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } diff --git a/CommonServer/Services/ContainerSecurityService.ts b/CommonServer/Services/ContainerSecurityService.ts index 9565853ee0..fbf1a1e46e 100644 --- a/CommonServer/Services/ContainerSecurityService.ts +++ b/CommonServer/Services/ContainerSecurityService.ts @@ -263,7 +263,7 @@ export default class Service { async decryptPassword(security: $TSFixMe): void { const values: $TSFixMe = []; - for (let i = 0; i <= 15; i++) { + for (let i: $TSFixMe = 0; i <= 15; i++) { values.push(security.dockerCredential.iv[i]); } const iv: $TSFixMe = Buffer.from(values); diff --git a/CommonServer/Services/DatabaseService.ts b/CommonServer/Services/DatabaseService.ts index 722d486d0d..416bbeea98 100644 --- a/CommonServer/Services/DatabaseService.ts +++ b/CommonServer/Services/DatabaseService.ts @@ -262,7 +262,7 @@ class DatabaseService { data: createBy.data, }); - let data = _createdBy.data; + let data: $TSFixMe = _createdBy.data; this.checkRequiredFields(data); @@ -323,7 +323,7 @@ class DatabaseService { try { query['deleted'] = false; const count: $TSFixMe = await this.model.countDocuments(query); - let countPositive = new PositiveNumber(count); + let countPositive: $TSFixMe = new PositiveNumber(count); countPositive = await this.onCountSuccess(countPositive); return countPositive; } catch (error) { @@ -575,7 +575,7 @@ class DatabaseService { query['deleted'] = false; - let dbQuery = null; + let dbQuery: $TSFixMe = null; if (!multiple) { dbQuery = this.model.findOne(onBeforeFind.query); diff --git a/CommonServer/Services/DomainVerificationService.ts b/CommonServer/Services/DomainVerificationService.ts index 0b81662f8d..dee43a8559 100644 --- a/CommonServer/Services/DomainVerificationService.ts +++ b/CommonServer/Services/DomainVerificationService.ts @@ -161,8 +161,8 @@ export default class Service { query: { _id: projectId }, select: '_id parentProjectId', }); - let projectList = [project._id]; - let subProjects = []; + let projectList: $TSFixMe = [project._id]; + let subProjects: $TSFixMe = []; if (project.parentProjectId) { projectList.push( project.parentProjectId._id || project.parentProjectId diff --git a/CommonServer/Services/ErrorEventService.ts b/CommonServer/Services/ErrorEventService.ts index 5f7d595d4e..554dd4779f 100644 --- a/CommonServer/Services/ErrorEventService.ts +++ b/CommonServer/Services/ErrorEventService.ts @@ -139,7 +139,7 @@ export default class Service { }); const totalErrorEvents: $TSFixMe = []; - let index = 0; + let index: $TSFixMe = 0; // if the next index is available in the issue tracker, proceed while ( @@ -213,7 +213,7 @@ export default class Service { totalErrorEvents.sort((eventA, eventB) => moment(eventB.latestOccurennce).isAfter(eventA.latestOccurennce) ); - let dateRange = { startDate: '', endDate: '' }; + let dateRange: $TSFixMe = { startDate: '', endDate: '' }; // set the date time range if (query.createdAt) { dateRange = { diff --git a/CommonServer/Services/ErrorTrackerService.ts b/CommonServer/Services/ErrorTrackerService.ts index 9e962e8a00..8d67b16e68 100644 --- a/CommonServer/Services/ErrorTrackerService.ts +++ b/CommonServer/Services/ErrorTrackerService.ts @@ -38,7 +38,7 @@ export default class Service { _id: data.resourceCategory, }); // prepare error tracker model - let errorTracker = new ErrorTrackerModel(); + let errorTracker: $TSFixMe = new ErrorTrackerModel(); errorTracker.name = data.name; diff --git a/CommonServer/Services/EscalationService.ts b/CommonServer/Services/EscalationService.ts index 155bb4de2a..b14d9a56fd 100755 --- a/CommonServer/Services/EscalationService.ts +++ b/CommonServer/Services/EscalationService.ts @@ -316,12 +316,12 @@ function computeActiveTeams(escalation: $TSFixMe): void { rotationTimezone, }: $TSFixMe = escalation; - let firstRotationOn = escalation.firstRotationOn; + let firstRotationOn: $TSFixMe = escalation.firstRotationOn; const currentDate: $TSFixMe = new Date(); if (rotateBy && rotateBy != '') { - let intervalDifference = 0; + let intervalDifference: $TSFixMe = 0; //convert rotation switch time to timezone. firstRotationOn = DateTime.changeDateTimezone( @@ -355,7 +355,7 @@ function computeActiveTeams(escalation: $TSFixMe): void { intervalDifference, rotationInterval ); - let activeTeamRotationStartTime = null; + let activeTeamRotationStartTime: $TSFixMe = null; //if the first rotation hasn't kicked in yet. if (DateTime.lessThan(currentDate, firstRotationOn)) { @@ -377,7 +377,7 @@ function computeActiveTeams(escalation: $TSFixMe): void { rotationEndTime: activeTeamRotationEndTime, }; - let nextActiveTeamIndex = activeTeamIndex + 1; + let nextActiveTeamIndex: $TSFixMe = activeTeamIndex + 1; if (!teams[nextActiveTeamIndex]) { nextActiveTeamIndex = 0; diff --git a/CommonServer/Services/FeedbackService.ts b/CommonServer/Services/FeedbackService.ts index 71c6599afa..5552d36bde 100755 --- a/CommonServer/Services/FeedbackService.ts +++ b/CommonServer/Services/FeedbackService.ts @@ -17,7 +17,7 @@ export default class Service { page: $TSFixMe, createdById: $TSFixMe ): void { - let feedback = new FeedbackModel(); + let feedback: $TSFixMe = new FeedbackModel(); feedback.message = message; diff --git a/CommonServer/Services/GroupService.ts b/CommonServer/Services/GroupService.ts index 810219778a..acfba92c15 100644 --- a/CommonServer/Services/GroupService.ts +++ b/CommonServer/Services/GroupService.ts @@ -152,7 +152,9 @@ export default class Service { async removeGroupMember(groupId: $TSFixMe, memberId: $TSFixMe): void { const group: $TSFixMe = await this.findOneBy({ _id: groupId }); const teamMembers: $TSFixMe = group.teams; - const data = teamMembers.filter((id: $TSFixMe) => id !== memberId); + const data: $TSFixMe = teamMembers.filter( + (id: $TSFixMe) => id !== memberId + ); const newGroup: $TSFixMe = await this.updateOneBy( { _id: groupId }, diff --git a/CommonServer/Services/IncidentCommunicationSlaService.ts b/CommonServer/Services/IncidentCommunicationSlaService.ts index 7040023791..bc3d8b57a2 100644 --- a/CommonServer/Services/IncidentCommunicationSlaService.ts +++ b/CommonServer/Services/IncidentCommunicationSlaService.ts @@ -37,7 +37,7 @@ export default class Service { await IncidentCommunicationSlaModel.create(data); if (data.monitors && data.monitors.length > 0) { - let monitorIds = [...data.monitors]; + let monitorIds: $TSFixMe = [...data.monitors]; monitorIds = [...new Set(monitorIds)]; await MonitorService.updateManyIncidentCommunicationSla( monitorIds, @@ -130,7 +130,7 @@ export default class Service { const removedMonitors: $TSFixMe = []; if (data.monitors && data.monitors.length > 0) { - let monitorIds = [...data.monitors]; + let monitorIds: $TSFixMe = [...data.monitors]; monitorIds = [...new Set(monitorIds)]; monitorIds = monitorIds.map(id => String(id)); initialMonitorIds.forEach((monitorId: $TSFixMe) => { @@ -176,7 +176,7 @@ export default class Service { ); } - let updatedIncidentCommunicationSla = + let updatedIncidentCommunicationSla: $TSFixMe = await IncidentCommunicationSlaModel.findOneAndUpdate( query, { diff --git a/CommonServer/Services/IncidentMessageService.ts b/CommonServer/Services/IncidentMessageService.ts index 46265e9143..28688ad4cb 100644 --- a/CommonServer/Services/IncidentMessageService.ts +++ b/CommonServer/Services/IncidentMessageService.ts @@ -1,6 +1,6 @@ export default class Service { async create(data: $TSFixMe): void { - let incidentMessage = new IncidentMessageModel(); + let incidentMessage: $TSFixMe = new IncidentMessageModel(); incidentMessage.content = data.content; diff --git a/CommonServer/Services/IncidentNoteTemplateService.ts b/CommonServer/Services/IncidentNoteTemplateService.ts index be7a876ce3..4692742360 100644 --- a/CommonServer/Services/IncidentNoteTemplateService.ts +++ b/CommonServer/Services/IncidentNoteTemplateService.ts @@ -73,7 +73,7 @@ export default class Service { } const { projectId, _id }: $TSFixMe = query; - let incidentNoteTemplate = null; + let incidentNoteTemplate: $TSFixMe = null; if (data.name) { incidentNoteTemplate = await this.findOneBy({ projectId, diff --git a/CommonServer/Services/IncidentService.ts b/CommonServer/Services/IncidentService.ts index 2eea03245a..fe75ee8a49 100755 --- a/CommonServer/Services/IncidentService.ts +++ b/CommonServer/Services/IncidentService.ts @@ -83,7 +83,9 @@ export default class Service { error.code = 400; throw error; } - const monitorNames = monitors.map((monitor: $TSFixMe) => monitor.name); + const monitorNames: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor.name + ); monitors = monitors .filter((monitor: $TSFixMe) => !monitor.shouldNotMonitor) .map((monitor: $TSFixMe) => ({ @@ -144,8 +146,8 @@ export default class Service { throw error; } - let incident = new IncidentModel(); - let parentCount = 0, + let incident: $TSFixMe = new IncidentModel(); + let parentCount: $TSFixMe = 0, deletedParentCount = 0; if (project && project.parentProjectId) { const [pCount, dpCount]: $TSFixMe = await Promise.all([ @@ -289,7 +291,7 @@ export default class Service { // notification is an array of notifications // *************************** - let populate = [ + let populate: $TSFixMe = [ { path: 'monitors.monitorId', select: 'name slug componentId projectId type', @@ -304,7 +306,7 @@ export default class Service { { path: 'acknowledgedBy', select: 'name' }, { path: 'incidentPriority', select: 'name' }, ]; - let select = + let select: $TSFixMe = 'slug idNumber notifications _id monitors createdById projectId createdByIncomingHttpRequest incidentType resolved resolvedBy acknowledged acknowledgedBy title description incidentPriority criterionCause probes acknowledgedAt resolvedAt manuallyCreated deleted'; const populatedIncident: $TSFixMe = await this.findOneBy({ query: { _id: incident._id }, @@ -612,7 +614,7 @@ export default class Service { for (const monitor of monitors) { AlertService.sendCreatedIncident(incident, monitor); - let notification = {}; + let notification: $TSFixMe = {}; // send slack notification SlackService.sendNotification( @@ -1103,7 +1105,9 @@ export default class Service { query: { projectId }, select: '_id', }); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor._id + ); const query: $TSFixMe = { 'monitors.monitorId': { $in: monitorIds }, @@ -1131,7 +1135,9 @@ export default class Service { query: { projectId, componentId }, select: '_id', }); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor._id + ); const query: $TSFixMe = { 'monitors.monitorId': { $in: monitorIds }, @@ -1182,7 +1188,9 @@ export default class Service { query: { componentId: componentId }, select: '_id', }); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor._id + ); const query: $TSFixMe = { projectId, @@ -1392,7 +1400,7 @@ export default class Service { String(monitor.monitorId) !== String(monitorId) ); - let updatedIncident = null; + let updatedIncident: $TSFixMe = null; if (monitors.length === 0) { // no more monitor in monitors array // delete incident @@ -1498,10 +1506,10 @@ export default class Service { if (!currentIncident.breachedCommunicationSla) { const slaList: $TSFixMe = {}; - let fetchedDefault = false; + let fetchedDefault: $TSFixMe = false; for (const monitor of monitorList) { - let sla = monitor.incidentCommunicationSla; + let sla: $TSFixMe = monitor.incidentCommunicationSla; // don't fetch default communication sla twice if (!sla && !fetchedDefault) { sla = await IncidentCommunicationSlaService.findOneBy({ @@ -1517,7 +1525,7 @@ export default class Service { } // grab the lowest sla and apply to the incident - let lowestSla = {}; + let lowestSla: $TSFixMe = {}; for (const [, value] of Object.entries(slaList)) { if (!lowestSla.duration) { lowestSla = value; @@ -1536,7 +1544,8 @@ export default class Service { incidentCommunicationSla && !incidentCommunicationSla.deleted ) { - let countDown = incidentCommunicationSla.duration * 60; + let countDown: $TSFixMe = + incidentCommunicationSla.duration * 60; const alertTime: $TSFixMe = incidentCommunicationSla.alertTime * 60; @@ -1549,39 +1558,45 @@ export default class Service { }; // count down every second - const intervalId = setInterval(async (): $TSFixMe => { - countDown -= 1; + const intervalId: $TSFixMe = setInterval( + async (): $TSFixMe => { + countDown -= 1; - // const minutes: $TSFixMe = Math.floor(countDown / 60); - // let seconds = countDown % 60; - // seconds = - // seconds < 10 && seconds !== 0 ? `0${seconds}` : seconds; + // const minutes: $TSFixMe = Math.floor(countDown / 60); + // let seconds: $TSFixMe = countDown % 60; + // seconds = + // seconds < 10 && seconds !== 0 ? `0${seconds}` : seconds; - // await was left out here because we care about the slaCountDown - // and also to ensure that it was delivered successfully + // await was left out here because we care about the slaCountDown + // and also to ensure that it was delivered successfully - RealTimeService.sendSlaCountDown( - currentIncident, - `${countDown}` - ); - - if (countDown === alertTime) { - // send mail to team - AlertService.sendSlaEmailToTeamMembers(data); - } - - if (countDown === 0) { - this.clearInterval(currentIncident._id); - - await this.updateOneBy( - { _id: currentIncident._id }, - { breachedCommunicationSla: true } + RealTimeService.sendSlaCountDown( + currentIncident, + `${countDown}` ); - // send mail to team - AlertService.sendSlaEmailToTeamMembers(data, true); - } - }, 1000); + if (countDown === alertTime) { + // send mail to team + AlertService.sendSlaEmailToTeamMembers(data); + } + + if (countDown === 0) { + this.clearInterval(currentIncident._id); + + await this.updateOneBy( + { _id: currentIncident._id }, + { breachedCommunicationSla: true } + ); + + // send mail to team + AlertService.sendSlaEmailToTeamMembers( + data, + true + ); + } + }, + 1000 + ); intervals.push({ incidentId: currentIncident._id, diff --git a/CommonServer/Services/IncidentTimelineService.ts b/CommonServer/Services/IncidentTimelineService.ts index d2195d8d6f..d580f70389 100644 --- a/CommonServer/Services/IncidentTimelineService.ts +++ b/CommonServer/Services/IncidentTimelineService.ts @@ -1,6 +1,6 @@ export default class Service { async create(data: $TSFixMe): void { - let incidentTimeline = new IncidentTimelineModel(); + let incidentTimeline: $TSFixMe = new IncidentTimelineModel(); incidentTimeline.incidentId = data.incidentId; if (data.createdById) { diff --git a/CommonServer/Services/IncomingRequestService.ts b/CommonServer/Services/IncomingRequestService.ts index 666fb5beb1..21780d591d 100644 --- a/CommonServer/Services/IncomingRequestService.ts +++ b/CommonServer/Services/IncomingRequestService.ts @@ -165,7 +165,7 @@ export default class Service { data: $TSFixMe, excludeMonitors: $TSFixMe ): void { - let unsetData = {}; + let unsetData: $TSFixMe = {}; if (!query) { query = {}; } @@ -315,7 +315,7 @@ export default class Service { })); } - let updatedIncomingRequest = + let updatedIncomingRequest: $TSFixMe = await IncomingRequestModel.findOneAndUpdate( { _id: query.requestId }, { @@ -501,7 +501,7 @@ export default class Service { ); if (incomingRequest.monitors.length > 0) { - let updatedIncomingRequest = + let updatedIncomingRequest: $TSFixMe = await IncomingRequestModel.findOneAndUpdate( { _id: incomingRequest._id }, { $set: { monitors: incomingRequest.monitors } }, @@ -521,7 +521,7 @@ export default class Service { // 1. No monitor is remaining in the monitors array // 2. It does not select all monitors if (!incomingRequest.selectAllMonitors) { - let deletedIncomingRequest = + let deletedIncomingRequest: $TSFixMe = await IncomingRequestModel.findOneAndUpdate( { _id: incomingRequest._id }, { @@ -627,7 +627,7 @@ export default class Service { data.manuallyCreated = true; } - let monitors = []; + let monitors: $TSFixMe = []; if (incomingRequest.selectAllMonitors) { const projectIds: $TSFixMe = await ProjectService.findBy({ query: { parentProjectId: data.projectId }, @@ -651,21 +651,23 @@ export default class Service { if (filters && filters.length > 0) { // if template variables are used // update the values for filterText - const updatedFilters = filters.map((filter: $TSFixMe) => { - if (filter.filterText) { - const dataConfig: $TSFixMe = { - request: data.request, - }; - filter.filterText = analyseVariable( - filter.filterText, - dataConfig - ); + const updatedFilters: $TSFixMe = filters.map( + (filter: $TSFixMe) => { + if (filter.filterText) { + const dataConfig: $TSFixMe = { + request: data.request, + }; + filter.filterText = analyseVariable( + filter.filterText, + dataConfig + ); + } + return filter; } - return filter; - }); + ); const newMonitorList: $TSFixMe = []; monitors.forEach((monitor: $TSFixMe) => { - let matchedFields = 0; + let matchedFields: $TSFixMe = 0; const monitorCustomFields: $TSFixMe = monitor.customFields || []; @@ -964,7 +966,7 @@ export default class Service { (incomingRequest.updateIncidentNote || incomingRequest.updateInternalNote) ) { - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; const subProjects: $TSFixMe = await ProjectService.findBy({ query: { @@ -990,7 +992,7 @@ export default class Service { : 'internal'; data.content = incomingRequest.noteContent; - let incidents = [], + let incidents: $TSFixMe = [], updatedFilters: $TSFixMe = []; const populate: $TSFixMe = [ { @@ -1068,7 +1070,7 @@ export default class Service { data.fieldValue = filterText; } - let incidents = []; + let incidents: $TSFixMe = []; if (filterCondition === 'equalTo') { if ( data.incidentId && @@ -1301,7 +1303,7 @@ export default class Service { if (filters || filters.length > 0) { const newIncidentList: $TSFixMe = []; incidents.forEach((incident: $TSFixMe) => { - let matchedFields = 0; + let matchedFields: $TSFixMe = 0; const incidentCustomFields: $TSFixMe = incident.customFields || []; // automatically create incident id custom field @@ -1499,7 +1501,7 @@ export default class Service { (incomingRequest.acknowledgeIncident || incomingRequest.resolveIncident) ) { - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; const subProjects: $TSFixMe = await ProjectService.findBy({ query: { @@ -1521,7 +1523,7 @@ export default class Service { resolvedIncidents: $TSFixMe = [], acknowledgedIncidents: $TSFixMe = []; - let incidentQuery = {}; + let incidentQuery: $TSFixMe = {}; if (incomingRequest.resolveIncident) { incidentQuery = { resolvedAt: { $exists: false } }; } @@ -1531,7 +1533,7 @@ export default class Service { }; } - let incidents = [], + let incidents: $TSFixMe = [], updatedFilters: $TSFixMe = []; const populate: $TSFixMe = [ { @@ -1610,7 +1612,7 @@ export default class Service { data.fieldValue = filterText; } - let incidents = []; + let incidents: $TSFixMe = []; if (filterCondition === 'equalTo') { if (data.incidentId) { incidents = await IncidentService.findBy({ @@ -1846,7 +1848,7 @@ export default class Service { if (filters || filters.length > 0) { const newIncidentList: $TSFixMe = []; incidents.forEach((incident: $TSFixMe) => { - let matchedFields = 0; + let matchedFields: $TSFixMe = 0; const incidentCustomFields: $TSFixMe = incident.customFields || []; // automatically create incident id custom field @@ -2094,10 +2096,10 @@ function analyseVariable(variable: $TSFixMe, data: $TSFixMe): void { return variable; } - let ctx = Object.create(null); // fix against prototype vulnerability + let ctx: $TSFixMe = Object.create(null); // fix against prototype vulnerability ctx = { ...data }; - const processedValues = matched.map((item: $TSFixMe) => + const processedValues: $TSFixMe = matched.map((item: $TSFixMe) => vm.runInNewContext(item, ctx) ); @@ -2114,7 +2116,7 @@ function analyseVariable(variable: $TSFixMe, data: $TSFixMe): void { }); // replace variable with processedValues - let currentValue = variable; + let currentValue: $TSFixMe = variable; matched.forEach((item: $TSFixMe, index: $TSFixMe) => { currentValue = currentValue.replace(item, processedValues[index]); }); diff --git a/CommonServer/Services/IntegrationService.ts b/CommonServer/Services/IntegrationService.ts index 2738788ebd..efb5a5ccaa 100755 --- a/CommonServer/Services/IntegrationService.ts +++ b/CommonServer/Services/IntegrationService.ts @@ -198,7 +198,7 @@ export default class Service { } async removeMonitor(monitorId: $TSFixMe, userId: ObjectID): void { - let query = {}; + let query: $TSFixMe = {}; if (monitorId) { query = { monitorId: monitorId }; } diff --git a/CommonServer/Services/IssueService.ts b/CommonServer/Services/IssueService.ts index 3c88452428..a18e6e47fc 100644 --- a/CommonServer/Services/IssueService.ts +++ b/CommonServer/Services/IssueService.ts @@ -12,7 +12,7 @@ import Query from '../Types/DB/Query'; export default class Service { async create(data: $TSFixMe): void { // prepare issue model - let issue = new IssueModel(); + let issue: $TSFixMe = new IssueModel(); issue.name = data.exception ? data.exception.type : 'Unknown Error'; diff --git a/CommonServer/Services/LeadService.ts b/CommonServer/Services/LeadService.ts index bd04211399..e40dbda837 100755 --- a/CommonServer/Services/LeadService.ts +++ b/CommonServer/Services/LeadService.ts @@ -10,7 +10,7 @@ export default class Service { //Param 3: userId: User Id. //Returns: promise async create(data: $TSFixMe): void { - let lead = new LeadsModel(); + let lead: $TSFixMe = new LeadsModel(); lead.type = data.type; diff --git a/CommonServer/Services/LogService.ts b/CommonServer/Services/LogService.ts index 20113830a0..9cd77b6910 100644 --- a/CommonServer/Services/LogService.ts +++ b/CommonServer/Services/LogService.ts @@ -9,7 +9,7 @@ import PositiveNumber from 'Common/Types/PositiveNumber'; export default class Service { async create(data: $TSFixMe): void { // prepare log model - let log = new LogModel(); + let log: $TSFixMe = new LogModel(); let content; try { @@ -18,7 +18,7 @@ export default class Service { content = data.content; } - let stringifiedTags = ''; + let stringifiedTags: $TSFixMe = ''; if (data.tags) { typeof data.tags === 'string' ? (stringifiedTags = data.tags) @@ -228,7 +228,7 @@ export default class Service { if (!query['deleted']) { query['deleted'] = false; } - let dateRange = { startDate: '', endDate: '' }; + let dateRange: $TSFixMe = { startDate: '', endDate: '' }; // if date range is given, it returns it if (query.createdAt) { dateRange = { diff --git a/CommonServer/Services/MonitorCriteriaService.ts b/CommonServer/Services/MonitorCriteriaService.ts index ec4e927895..20080ef56e 100644 --- a/CommonServer/Services/MonitorCriteriaService.ts +++ b/CommonServer/Services/MonitorCriteriaService.ts @@ -490,7 +490,7 @@ const MonitorCriteriaService: $TSFixMe = { const val2: $TSFixMe = {}; const criteria: $TSFixMe = []; - for (let i = 0; i < val.length; i++) { + for (let i: $TSFixMe = 0; i < val.length; i++) { const val3: $TSFixMe = {}; if (val[i].responseType && val[i].responseType.length) { val3.responseType = val[i].responseType; @@ -536,7 +536,7 @@ const MonitorCriteriaService: $TSFixMe = { innerCriteria(val: $TSFixMe, nestVal: $TSFixMe) { nestVal = [...nestVal]; if (val.criteria && val.criteria.length) { - for (let j = 0; j < val.criteria.length; j++) { + for (let j: $TSFixMe = 0; j < val.criteria.length; j++) { const innerVal: $TSFixMe = {}; if ( val.criteria[j].responseType && @@ -588,7 +588,7 @@ const MonitorCriteriaService: $TSFixMe = { mapCriteria(val: $TSFixMe) { const val2: $TSFixMe = []; if (val && val.criteria && val.criteria.condition === 'and') { - for (let i = 0; i < val.criteria.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < val.criteria.criteria.length; i++) { const val3: $TSFixMe = {}; if ( val.criteria.criteria[i].responseType && @@ -639,7 +639,7 @@ const MonitorCriteriaService: $TSFixMe = { } return val2; } else if (val && val.criteria && val.criteria.condition === 'or') { - for (let i = 0; i < val.criteria.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < val.criteria.criteria.length; i++) { const val3: $TSFixMe = {}; if ( val.criteria.criteria[i].responseType && @@ -698,7 +698,7 @@ const MonitorCriteriaService: $TSFixMe = { cr: $TSFixMe ) { innerContainer = [...innerContainer]; - for (let j = 0; j < criteriaObj.criteria.length; j++) { + for (let j: $TSFixMe = 0; j < criteriaObj.criteria.length; j++) { const innerVal: $TSFixMe = {}; if ( criteriaObj.criteria[j].responseType && diff --git a/CommonServer/Services/MonitorLogService.ts b/CommonServer/Services/MonitorLogService.ts index 7dfcd0eb1d..5032909574 100644 --- a/CommonServer/Services/MonitorLogService.ts +++ b/CommonServer/Services/MonitorLogService.ts @@ -13,7 +13,7 @@ import moment from 'moment'; export default class Service { async create(data: $TSFixMe): void { const Log: $TSFixMe = new MonitorLogModel(); - let responseBody = ''; + let responseBody: $TSFixMe = ''; if (data.resp && data.resp.body) { if (typeof data.resp.body === 'object') { responseBody = JSON.stringify(data.resp.body); diff --git a/CommonServer/Services/MonitorService.ts b/CommonServer/Services/MonitorService.ts index 974645c0d9..5d977c12a0 100755 --- a/CommonServer/Services/MonitorService.ts +++ b/CommonServer/Services/MonitorService.ts @@ -41,7 +41,7 @@ export default class Service { //Param 1: data: MonitorModal. //Returns: promise with monitor model or error. async create(data: $TSFixMe): void { - let subProject = null; + let subProject: $TSFixMe = null; const query: $TSFixMe = { name: data.name, @@ -89,7 +89,7 @@ export default class Service { select: selectResourceCat, }), ]); - let userCount = 0; + let userCount: $TSFixMe = 0; if (subProjects && subProjects.length > 0) { const userId: ObjectID = []; subProjectIds = subProjects.map((project: $TSFixMe) => project._id); @@ -107,7 +107,7 @@ export default class Service { userCount = project.users.length; } subProjectIds.push(project._id); - let plan = Plans.getPlanById(project.stripePlanId); + let plan: $TSFixMe = Plans.getPlanById(project.stripePlanId); // null plan => enterprise plan plan = plan && plan.category ? plan : { category: 'Enterprise' }; @@ -647,7 +647,7 @@ export default class Service { ).populate('deletedById', 'name'); if (monitor) { - let subProject = null; + let subProject: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: monitor.projectId._id || monitor.projectId }, @@ -664,7 +664,7 @@ export default class Service { }); } - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; const subProjects: $TSFixMe = await ProjectService.findBy({ query: { parentProjectId: project._id }, @@ -685,7 +685,7 @@ export default class Service { parentProjectId: project._id, }), ]); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -1461,7 +1461,7 @@ export default class Service { query, select: 'seats stripeSubscriptionId _id', }); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -1537,7 +1537,7 @@ export default class Service { }), ]); const dateNow: $TSFixMe = moment().utc(); - let days = moment(dateNow) + let days: $TSFixMe = moment(dateNow) .utc() .startOf('day') .diff(moment(monitorTime.createdAt).utc().startOf('day'), 'days'); @@ -1546,10 +1546,10 @@ export default class Service { days = 89; } const times: $TSFixMe = []; - for (let i = days; i >= 0; i--) { - let incidents = []; + for (let i: $TSFixMe = days; i >= 0; i--) { + let incidents: $TSFixMe = []; const temp: $TSFixMe = {}; - let status = 'online'; + let status: $TSFixMe = 'online'; temp.date = moment(dateNow).utc().subtract(i, 'days'); @@ -1689,7 +1689,7 @@ export default class Service { // then update the monitor => breachedMonitorSla async updateMonitorSlaStat(query: Query): void { const currentDate: $TSFixMe = moment().format(); - let startDate = moment(currentDate).subtract(30, 'days'); // default frequency + let startDate: $TSFixMe = moment(currentDate).subtract(30, 'days'); // default frequency const populate: $TSFixMe = [ { path: 'monitorSla', select: 'frequency monitorUptime' }, ]; @@ -1778,14 +1778,14 @@ export default class Service { calculateTime(statuses: $TSFixMe, start: $TSFixMe, range: $TSFixMe): void { const timeBlock: $TSFixMe = []; - let totalUptime = 0; - let totalTime = 0; + let totalUptime: $TSFixMe = 0; + let totalTime: $TSFixMe = 0; - let dayStart = moment(start).startOf('day'); + let dayStart: $TSFixMe = moment(start).startOf('day'); const reversedStatuses: $TSFixMe = statuses.slice().reverse(); - for (let i = 0; i < range; i++) { + for (let i: $TSFixMe = 0; i < range; i++) { const dayStartIn: $TSFixMe = dayStart; const dayEnd: $TSFixMe = i && i > 0 ? dayStart.clone().endOf('day') : moment(Date.now()); @@ -1850,7 +1850,11 @@ export default class Service { : -1 ); //Third step - for (let i = 0; i < incidentsHappenedDuringTheDay.length - 1; i++) { + for ( + let i: $TSFixMe = 0; + i < incidentsHappenedDuringTheDay.length - 1; + i++ + ) { const firstIncidentIndex: $TSFixMe = i; const nextIncidentIndex: $TSFixMe = i + 1; const firstIncident: $TSFixMe = @@ -1892,7 +1896,7 @@ export default class Service { nextIncidentIndex, 1 ); - let j = nextIncidentIndex; + let j: $TSFixMe = nextIncidentIndex; while (j < incidentsHappenedDuringTheDay.length) { if ( moment(nextIncident.start).isBefore( @@ -1928,7 +1932,7 @@ export default class Service { status: firstIncident.status, }; firstIncident.end = nextIncident.start; - let j = nextIncidentIndex + 1; + let j: $TSFixMe = nextIncidentIndex + 1; while (j < incidentsHappenedDuringTheDay.length) { if ( moment(newIncident.start).isBefore( @@ -2044,14 +2048,14 @@ export default class Service { calcTime(statuses: $TSFixMe, start: $TSFixMe, range: $TSFixMe): void { const timeBlock: $TSFixMe = []; - let totalUptime = 0; - let totalTime = 0; + let totalUptime: $TSFixMe = 0; + let totalTime: $TSFixMe = 0; - let dayStart = moment(start).startOf('day'); + let dayStart: $TSFixMe = moment(start).startOf('day'); const reversedStatuses: $TSFixMe = statuses.slice().reverse(); - for (let i = 0; i < range; i++) { + for (let i: $TSFixMe = 0; i < range; i++) { const dayStartIn: $TSFixMe = dayStart; const dayEnd: $TSFixMe = i && i > 0 ? dayStart.clone().endOf('day') : moment(Date.now()); @@ -2147,7 +2151,11 @@ export default class Service { : -1 ); //Third step - for (let i = 0; i < incidentsHappenedDuringTheDay.length - 1; i++) { + for ( + let i: $TSFixMe = 0; + i < incidentsHappenedDuringTheDay.length - 1; + i++ + ) { const firstIncidentIndex: $TSFixMe = i; const nextIncidentIndex: $TSFixMe = i + 1; const firstIncident: $TSFixMe = @@ -2191,7 +2199,7 @@ export default class Service { nextIncidentIndex, 1 ); - let j = nextIncidentIndex; + let j: $TSFixMe = nextIncidentIndex; while (j < incidentsHappenedDuringTheDay.length) { if ( moment(nextIncident.start).isBefore( @@ -2227,7 +2235,7 @@ export default class Service { status: firstIncident.status, }; firstIncident.end = nextIncident.start; - let j = nextIncidentIndex + 1; + let j: $TSFixMe = nextIncidentIndex + 1; while (j < incidentsHappenedDuringTheDay.length) { if ( moment(newIncident.start).isBefore( diff --git a/CommonServer/Services/MonitorSlaService.ts b/CommonServer/Services/MonitorSlaService.ts index 693aba8c95..0381e3623b 100644 --- a/CommonServer/Services/MonitorSlaService.ts +++ b/CommonServer/Services/MonitorSlaService.ts @@ -35,7 +35,7 @@ export default class Service { const createdMonitorSla: $TSFixMe = await MonitorSlaModel.create(data); if (data.monitors && data.monitors.length > 0) { - let monitorIds = [...data.monitors]; + let monitorIds: $TSFixMe = [...data.monitors]; monitorIds = [...new Set(monitorIds)]; await MonitorService.updateManyMonitorSla( @@ -142,7 +142,7 @@ export default class Service { const removedMonitors: $TSFixMe = []; if (data.monitors && data.monitors.length > 0) { - let monitorIds = [...data.monitors]; + let monitorIds: $TSFixMe = [...data.monitors]; monitorIds = [...new Set(monitorIds)]; monitorIds = monitorIds.map(id => String(id)); initialMonitorIds.forEach((monitorId: $TSFixMe) => { diff --git a/CommonServer/Services/MsTeamsService.ts b/CommonServer/Services/MsTeamsService.ts index 0d9b17c34a..8c9b870af3 100644 --- a/CommonServer/Services/MsTeamsService.ts +++ b/CommonServer/Services/MsTeamsService.ts @@ -28,7 +28,7 @@ export default class Service { if (project && project.parentProjectId) { projectId = project.parentProjectId._id || project.parentProjectId; } - let query = { + let query: $TSFixMe = { projectId: projectId, integrationType: 'msteams', monitors: { $elemMatch: { monitorId: monitor._id } }, diff --git a/CommonServer/Services/NotificationService.ts b/CommonServer/Services/NotificationService.ts index 8bff65a5f4..2059291441 100755 --- a/CommonServer/Services/NotificationService.ts +++ b/CommonServer/Services/NotificationService.ts @@ -30,7 +30,7 @@ export default class Service { const selectNotification: $TSFixMe = 'projectId createdAt createdBy message read closed icon meta deleted deletedAt deletedById'; - let notification = new NotificationModel(); + let notification: $TSFixMe = new NotificationModel(); notification.projectId = projectId; diff --git a/CommonServer/Services/OnCallScheduleStatusService.ts b/CommonServer/Services/OnCallScheduleStatusService.ts index e6adef2c50..9602d53cae 100644 --- a/CommonServer/Services/OnCallScheduleStatusService.ts +++ b/CommonServer/Services/OnCallScheduleStatusService.ts @@ -52,7 +52,7 @@ export default class Service { escalations, incidentAcknowledged, }: $TSFixMe): void { - let item = new OnCallScheduleStatusModel(); + let item: $TSFixMe = new OnCallScheduleStatusModel(); item.project = project; diff --git a/CommonServer/Services/PaymentService.ts b/CommonServer/Services/PaymentService.ts index efe506f63a..f410a6b291 100755 --- a/CommonServer/Services/PaymentService.ts +++ b/CommonServer/Services/PaymentService.ts @@ -255,7 +255,7 @@ export default class Service { quantity: 1, }); - let subscriptionObj = {}; + let subscriptionObj: $TSFixMe = {}; if (coupon) { subscriptionObj = { @@ -295,7 +295,7 @@ export default class Service { subscriptionId ); - let plan = null; + let plan: $TSFixMe = null; const items: $TSFixMe = []; if ( !subscription || @@ -315,7 +315,7 @@ export default class Service { trial_end_date = subscription.trial_end; } - for (let i = 0; i < subscription.items.data.length; i++) { + for (let i: $TSFixMe = 0; i < subscription.items.data.length; i++) { plan = await Plans.getPlanById( subscription.items.data[i].plan.id ); @@ -376,7 +376,7 @@ export default class Service { } async changePlan(subscriptionId, planId, seats): void { - let subscriptionObj = {}; + let subscriptionObj: $TSFixMe = {}; const subscription: $TSFixMe = await stripe.subscriptions.retrieve( subscriptionId diff --git a/CommonServer/Services/PerformanceTrackerMetricService.ts b/CommonServer/Services/PerformanceTrackerMetricService.ts index 54e17c06ce..c16a51be5a 100644 --- a/CommonServer/Services/PerformanceTrackerMetricService.ts +++ b/CommonServer/Services/PerformanceTrackerMetricService.ts @@ -121,7 +121,7 @@ export default class Service { method, }; - let avgTime = 0, + let avgTime: $TSFixMe = 0, maxTime = 0, throughput = 0, errorCount = 0; @@ -415,7 +415,7 @@ export default class Service { function calcAvgTime(metric: $TSFixMe): void { const length: $TSFixMe = metric.length; - let avgTimeCount = 0, + let avgTimeCount: $TSFixMe = 0, avgMaxTimeCount = 0; metric.forEach((data: $TSFixMe) => { avgTimeCount += data.metrics.avgTime; @@ -431,7 +431,7 @@ function calcAvgTime(metric: $TSFixMe): void { function calcAvgThroughput(metric: $TSFixMe): void { const length: $TSFixMe = metric.length; - let sum = 0; + let sum: $TSFixMe = 0; metric.forEach((data: $TSFixMe) => { sum += data.metrics.throughput; }); @@ -444,7 +444,7 @@ function calcAvgThroughput(metric: $TSFixMe): void { function calcAvgError(metric: $TSFixMe): void { const length: $TSFixMe = metric.length; - let cumulative = 0; + let cumulative: $TSFixMe = 0; metric.forEach((data: $TSFixMe) => { cumulative += data.metrics.errorCount; }); diff --git a/CommonServer/Services/PerformanceTrackerService.ts b/CommonServer/Services/PerformanceTrackerService.ts index 1e15592bed..0f2aad31d1 100644 --- a/CommonServer/Services/PerformanceTrackerService.ts +++ b/CommonServer/Services/PerformanceTrackerService.ts @@ -48,7 +48,7 @@ export default class Service { data.key = uuid.v4(); // handle the slug - let name = data.name; + let name: $TSFixMe = data.name; name = slugify(name); name = `${name}-${generate('1234567890', 8)}`; data.slug = name.toLowerCase(); @@ -236,7 +236,7 @@ export default class Service { } if (data && data.name) { - let name = data.name; + let name: $TSFixMe = data.name; name = slugify(name); name = `${name}-${generate('1234567890', 8)}`; data.slug = name.toLowerCase(); diff --git a/CommonServer/Services/ProbeService.ts b/CommonServer/Services/ProbeService.ts index 69abec7d7c..701d20acb5 100755 --- a/CommonServer/Services/ProbeService.ts +++ b/CommonServer/Services/ProbeService.ts @@ -205,7 +205,7 @@ class Service extends DatabaseService { select: '_id', }); - const incidentIds = incidents.map(incident: $TSFixMe => incident._id); + const incidentIds: $TSFixMe = incidents.map(incident: $TSFixMe => incident._id); if (incidentIds && incidentIds.length) { log = await MonitorLogService.updateOneBy( @@ -285,8 +285,8 @@ class Service extends DatabaseService { }), ]); const { matchedCriterion }: $TSFixMe = data; - let incidentIds = []; - let scripts = []; + let incidentIds: $TSFixMe = []; + let scripts: $TSFixMe = []; if ( matchedCriterion && @@ -310,7 +310,7 @@ class Service extends DatabaseService { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -385,7 +385,7 @@ class Service extends DatabaseService { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -459,7 +459,7 @@ class Service extends DatabaseService { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -563,7 +563,7 @@ class Service extends DatabaseService { let autoAcknowledge, autoResolve; if (incidents && incidents.length > 0) { incidents.forEach(incident => { - let criteriaId = null; + let criteriaId: $TSFixMe = null; if ( incident && incident.criterionCause && @@ -624,7 +624,7 @@ class Service extends DatabaseService { incident.probes.length > 0 && monitor.type !== 'incomingHttpRequest' ) { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -718,11 +718,11 @@ class Service extends DatabaseService { const failedReasons: $TSFixMe = []; - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (con && con.length) { eventOccurred = con.some(condition => { - let stat = true; + let stat: $TSFixMe = true; if ( condition && condition.criteria && @@ -789,12 +789,12 @@ class Service extends DatabaseService { const failedReasons: $TSFixMe = []; - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (con && con.length) { eventOccurred = some(con, condition => { - let stat = true; + let stat: $TSFixMe = true; if ( condition && condition.criteria && @@ -860,12 +860,12 @@ class Service extends DatabaseService { } incomingCondition(payload, conditions): void { - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (conditions && conditions.length) { eventOccurred = some(conditions, condition => { - let response = false; - let respAnd = false, + let response: $TSFixMe = false; + let respAnd: $TSFixMe = false, respOr = false, countAnd = 0, countOr = 0; @@ -1079,8 +1079,8 @@ class Service extends DatabaseService { ), ]) : false; - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; let tempReason: string = `${payload} min`; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); @@ -1168,11 +1168,11 @@ import CreateBy from '../Types/DB/CreateBy'; import UUID from 'Common/Utils/UUID'; const incomingCheckAnd: Function = (payload, condition): void => { - let validity = false; - let val = 0; - let incomingVal = 0; + let validity: $TSFixMe = false; + let val: $TSFixMe = 0; + let incomingVal: $TSFixMe = 0; if (condition && condition.criteria && condition.criteria.length > 0) { - for (let i = 0; i < condition.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < condition.criteria.length; i++) { if ( condition.criteria[i].criteria && condition.criteria[i].criteria.length > 0 @@ -1318,11 +1318,11 @@ const incomingCheckAnd: Function = (payload, condition): void => { }; const incomingCheckOr: Function = (payload, condition): void => { - let validity = false; - let val = 0; - let incomingVal = 0; + let validity: $TSFixMe = false; + let val: $TSFixMe = 0; + let incomingVal: $TSFixMe = 0; if (condition && condition.criteria && condition.criteria.length > 0) { - for (let i = 0; i < condition.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < condition.criteria.length; i++) { if ( condition.criteria[i].criteria && condition.criteria[i].criteria.length > 0 @@ -1489,9 +1489,9 @@ const checkAnd: Function = ( headers ): void => { - let validity = true; + let validity: $TSFixMe = true; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -1549,8 +1549,8 @@ const checkAnd: Function = ( con.criteria[i].responseType && con.criteria[i].responseType === 'incomingTime' ) { - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); timeMinutes = Math.floor(timeMinutes % 60); @@ -3863,9 +3863,9 @@ const checkOr: Function = ( headers ): void => { - let validity = false; + let validity: $TSFixMe = false; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -3920,8 +3920,8 @@ const checkOr: Function = ( con.criteria[i].responseType && con.criteria[i].responseType === 'incomingTime' ) { - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); timeMinutes = Math.floor(timeMinutes % 60); @@ -6207,9 +6207,9 @@ const checkScriptAnd: Function = ( successReasons, failedReasons ): void => { - let valid = true; + let valid: $TSFixMe = true; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -6267,9 +6267,9 @@ const checkScriptOr: Function = ( successReasons, failedReasons ): void => { - let valid = false; + let valid: $TSFixMe = false; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -6363,7 +6363,7 @@ const formatDecimal: Function = (value, decimalPlaces, roundType): void => { }; const formatBytes: Function = (a, b, c, d, e): void => { - let value = a; + let value: $TSFixMe = a; let decimalPlaces; let roundType; if (typeof a === 'object') { diff --git a/CommonServer/Services/ProjectService.ts b/CommonServer/Services/ProjectService.ts index e99264d14e..b8c65feb5d 100755 --- a/CommonServer/Services/ProjectService.ts +++ b/CommonServer/Services/ProjectService.ts @@ -291,7 +291,7 @@ export default class Service { const project: $TSFixMe = await ProjectModel.findById(projectId).lean(); const currentBalance: $TSFixMe = project.balance; const { minimumBalance, rechargeToBalance }: $TSFixMe = data.alertOptions; - let updatedProject = {}; + let updatedProject: $TSFixMe = {}; if (!data.alertEnable) { updatedProject = await ProjectModel.findByIdAndUpdate( @@ -355,7 +355,7 @@ export default class Service { const projects: $TSFixMe = await this.findBy({ query, select: '_id' }); const projectsId: $TSFixMe = []; - for (let i = 0; i < projects.length; i++) { + for (let i: $TSFixMe = 0; i < projects.length; i++) { projectsId.push(projects[i]._id); } return projectsId; @@ -439,13 +439,13 @@ export default class Service { select: '_id', }); - const subProjectId = subProject.map(sub: $TSFixMe => String(sub._id)); + const subProjectId: $TSFixMe = subProject.map(sub: $TSFixMe => String(sub._id)); const projectIdArr: $TSFixMe = [projectId, ...subProjectId]; return projectIdArr; } async getUniqueMembersIndividualProject({ isFlatenArr, members }): void { - let result = []; + let result: $TSFixMe = []; if (!isFlatenArr) { for (const member of members) { const track: $TSFixMe = {}, @@ -473,7 +473,7 @@ export default class Service { async exitProject(projectId, userId, deletedById, saveUserSeat): void { const returnVal: string = 'User successfully exited the project'; - let teamMember = {}; + let teamMember: $TSFixMe = {}; const userProject: $TSFixMe = await this.findOneBy({ query: { _id: projectId }, @@ -482,8 +482,8 @@ export default class Service { teamMember = userProject.users.find( user => String(user.userId) === String(userId) ); - let subProject = null; - let subProjects = null; + let subProject: $TSFixMe = null; + let subProjects: $TSFixMe = null; let project: $TSFixMe = await this.findOneBy({ query: { _id: projectId, 'users.userId': userId }, @@ -504,7 +504,7 @@ export default class Service { }); const allMembers: $TSFixMe = subProjects.concat(project); - let subMembers = subProjects.map(user => user.users); + let subMembers: $TSFixMe = subProjects.map(user => user.users); subMembers = await this.getUniqueMembersIndividualProject({ members: subMembers, isFlatenArr: false, @@ -523,7 +523,7 @@ export default class Service { const teamByUserId: $TSFixMe = teams.filter( user => String(user.userId) === String(userId) ); - const isViewer = filteredTeam.every(data => data.role: $TSFixMe === 'Viewer'); + const isViewer: $TSFixMe = filteredTeam.every(data => data.role: $TSFixMe === 'Viewer'); if (project) { const users: $TSFixMe = subProject ? subProject.users : project.users; projectId = subProject ? subProject._id : project._id; @@ -550,7 +550,7 @@ export default class Service { select: '_id', }); if (!saveUserSeat) { - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -558,7 +558,7 @@ export default class Service { countUserInSubProjects && countUserInSubProjects.length < 1 ) { - let count = 0; + let count: $TSFixMe = 0; const user_member: $TSFixMe = await UserService.findOneBy({ query: { _id: userId }, select: 'email', @@ -568,7 +568,7 @@ export default class Service { count++; } }); - let subProjectIds = []; + let subProjectIds: $TSFixMe = []; if (subProjects && subProjects.length > 0) { subProjectIds = subProjects.map(project => project._id); } @@ -655,8 +655,8 @@ export default class Service { query: { 'users.userId': userId, deleted: { $ne: null } }, select: 'parentProjectId', }); - let parentProjectIds = []; - let projectIds = []; + let parentProjectIds: $TSFixMe = []; + let projectIds: $TSFixMe = []; if (userProjects.length > 0) { const subProjects: $TSFixMe = userProjects @@ -703,7 +703,7 @@ export default class Service { const projects: $TSFixMe = await Promise.all( allProjects.map(async project => { // get both sub-project users and project users - let users = []; + let users: $TSFixMe = []; if (project.parentProjectId) { users = await TeamService.getTeamMembersBy({ parentProjectId: diff --git a/CommonServer/Services/ScheduleService.ts b/CommonServer/Services/ScheduleService.ts index ab0c6a0f16..ee30b30039 100755 --- a/CommonServer/Services/ScheduleService.ts +++ b/CommonServer/Services/ScheduleService.ts @@ -174,7 +174,7 @@ export default class Service { query, select: '_id userIds monitorIds', }); - let userIds = []; + let userIds: $TSFixMe = []; if (data.userIds) { for (const userId of data.userIds) { userIds.push(userId); @@ -183,7 +183,7 @@ export default class Service { userIds = schedule.userIds; } data.userIds = userIds; - let monitorIds = []; + let monitorIds: $TSFixMe = []; if (data.monitorIds) { for (const monitorId of data.monitorIds) { monitorIds.push(monitorId); @@ -307,7 +307,7 @@ export default class Service { ): void { const escalationIds: $TSFixMe = []; for (const data of escalations) { - let escalation = {}; + let escalation: $TSFixMe = {}; if (!data._id) { escalation = await EscalationService.create(data); } else { diff --git a/CommonServer/Services/ScheduledEventService.ts b/CommonServer/Services/ScheduledEventService.ts index c887568949..a73b0790b3 100755 --- a/CommonServer/Services/ScheduledEventService.ts +++ b/CommonServer/Services/ScheduledEventService.ts @@ -507,7 +507,7 @@ export default class Service { ); if (event.monitors.length > 0) { - let updatedEvent = + let updatedEvent: $TSFixMe = await ScheduledEventModel.findOneAndUpdate( { _id: event._id }, { $set: { monitors: event.monitors } }, @@ -523,7 +523,7 @@ export default class Service { RealTimeService.updateScheduledEvent(updatedEvent); } else { // delete the scheduled event when no monitor is remaining - let deletedEvent = + let deletedEvent: $TSFixMe = await ScheduledEventModel.findOneAndUpdate( { _id: event._id }, { diff --git a/CommonServer/Services/SlackService.ts b/CommonServer/Services/SlackService.ts index 649ada809a..5213af7687 100755 --- a/CommonServer/Services/SlackService.ts +++ b/CommonServer/Services/SlackService.ts @@ -28,7 +28,7 @@ export default class Service { if (project && project.parentProjectId) { projectId = project.parentProjectId._id || project.parentProjectId; } - let query = { + let query: $TSFixMe = { projectId: projectId, integrationType: 'slack', monitors: { $elemMatch: { monitorId: monitor._id } }, diff --git a/CommonServer/Services/SsoService.ts b/CommonServer/Services/SsoService.ts index 356fed5958..a6d70a2777 100644 --- a/CommonServer/Services/SsoService.ts +++ b/CommonServer/Services/SsoService.ts @@ -101,7 +101,7 @@ export default class Service { } query['deleted'] = false; - let domainExists = null; + let domainExists: $TSFixMe = null; if (data.domain) { domainExists = await this.findOneBy({ query: { domain: data.domain, _id: { $ne: query._id } }, diff --git a/CommonServer/Services/StatusPageService.ts b/CommonServer/Services/StatusPageService.ts index 5118d643d6..4604457cbd 100755 --- a/CommonServer/Services/StatusPageService.ts +++ b/CommonServer/Services/StatusPageService.ts @@ -190,7 +190,7 @@ export default class Service { enableHttps: $TSFixMe, autoProvisioning: $TSFixMe ): void { - let createdDomain = {}; + let createdDomain: $TSFixMe = {}; // check if domain already exist // only one domain in the db is allowed @@ -228,7 +228,7 @@ export default class Service { if (statusPage) { // attach the domain id to statuspage collection and update it - const domain = statusPage.domains.find((domain: $TSFixMe) => + const domain: $TSFixMe = statusPage.domains.find((domain: $TSFixMe) => domain.domain === subDomain ? true : false ); if (domain) { @@ -339,7 +339,7 @@ export default class Service { enableHttps: $TSFixMe, autoProvisioning: $TSFixMe ): void { - let createdDomain = {}; + let createdDomain: $TSFixMe = {}; const existingBaseDomain: $TSFixMe = await DomainVerificationService.findOneBy({ query: { domain: newDomain }, @@ -375,7 +375,7 @@ export default class Service { ); } - let doesDomainExist = false; + let doesDomainExist: $TSFixMe = false; const domainList: $TSFixMe = [...statusPage.domains]; const updatedDomainList: $TSFixMe = []; @@ -807,7 +807,7 @@ export default class Service { }); const checkHideResolved: $TSFixMe = statuspages[0].hideResolvedIncident; - let option = {}; + let option: $TSFixMe = {}; if (checkHideResolved) { option = { resolved: false, @@ -990,7 +990,7 @@ export default class Service { IncidentService.countBy(query), ]); - const investigationNotes = incidents.map((incident: $TSFixMe) => { + const investigationNotes: $TSFixMe = incidents.map((incident: $TSFixMe) => { // return all the incident object return incident; }); @@ -1149,7 +1149,7 @@ export default class Service { (statusPage: $TSFixMe) => statusPage.monitors.length ); const statuspage: $TSFixMe = withMonitors[0]; - let monitorIds = statuspage + let monitorIds: $TSFixMe = statuspage ? statuspage.monitors.map((m: $TSFixMe) => m.monitor) : []; monitorIds = monitorIds.map( @@ -1454,7 +1454,7 @@ export default class Service { const statusPages: $TSFixMe = await statusPagesQuery; - let statusPage = null; + let statusPage: $TSFixMe = null; if ( query && @@ -1496,7 +1496,7 @@ export default class Service { throw error; } - const monitorIds = statusPage.monitors.map((monitorObj: $TSFixMe) => + const monitorIds: $TSFixMe = statusPage.monitors.map((monitorObj: $TSFixMe) => String(monitorObj.monitor._id || monitorObj.monitor) ); const projectId: $TSFixMe = statusPage.projectId._id || statusPage.projectId; @@ -1515,7 +1515,7 @@ export default class Service { 0, 0 ); - const filteredMonitorData = monitors.map(subProject: $TSFixMe => { + const filteredMonitorData: $TSFixMe = monitors.map(subProject: $TSFixMe => { return subProject.monitors.filter((monitor: $TSFixMe) => monitorIds.includes(monitor._id.toString()) ); @@ -1709,8 +1709,8 @@ export default class Service { 'monitors.monitorId' ); - let statusPages = []; - let count = 0; + let statusPages: $TSFixMe = []; + let count: $TSFixMe = 0; if (monitors) { monitors = monitors.map( (monitor: $TSFixMe) => @@ -1756,7 +1756,7 @@ export default class Service { }) ); const bubble: $TSFixMe = await getServiceStatus(statuses, probes); - let statusMessage = ''; + let statusMessage: $TSFixMe = ''; if (bubble === 'all') { statusMessage = 'All services are online'; } else if (bubble === 'some') { @@ -2152,7 +2152,7 @@ export default class Service { ); const userId: $TSFixMe = userData?.data?.data?.id || false; - let response = ''; + let response: $TSFixMe = ''; if (userId) { const tweetData: $TSFixMe = await axios.get( @@ -2220,8 +2220,8 @@ const getServiceStatus: Function = ( const probesLength: $TSFixMe = probes && probes.length; const totalServices: $TSFixMe = monitorsLength * probesLength; - let onlineServices = totalServices; - let degraded = 0; + let onlineServices: $TSFixMe = totalServices; + let degraded: $TSFixMe = 0; monitorsData.forEach((monitor: $TSFixMe) => { probes.forEach((probe: $TSFixMe) => { diff --git a/CommonServer/Services/StripeService.ts b/CommonServer/Services/StripeService.ts index 398abbef8d..e81704f065 100755 --- a/CommonServer/Services/StripeService.ts +++ b/CommonServer/Services/StripeService.ts @@ -105,7 +105,7 @@ export default class StripeService { ]); if (project) { - let userId = user._id; + let userId: $TSFixMe = user._id; if (user && user._id) { await ProjectService.deleteBy( { @@ -153,7 +153,7 @@ export default class StripeService { this.get(userId), ]); - let duplicateCard = false; + let duplicateCard: $TSFixMe = false; if ( cards && @@ -338,7 +338,7 @@ export default class StripeService { ).lean(); const currentBalance: $TSFixMe = project.balance; const newbalance: $TSFixMe = currentBalance + amountRecharged; - let updateObject = {}; + let updateObject: $TSFixMe = {}; if (!minimumBalance || !rechargeToBalance) { updateObject = { balance: newbalance, diff --git a/CommonServer/Services/SubscriberService.ts b/CommonServer/Services/SubscriberService.ts index 37723c1944..ed15a9871f 100755 --- a/CommonServer/Services/SubscriberService.ts +++ b/CommonServer/Services/SubscriberService.ts @@ -246,7 +246,7 @@ export default class Service { ); } - const success = monitors.map(async (monitor: $TSFixMe) => { + const success: $TSFixMe = monitors.map(async (monitor: $TSFixMe) => { const newSubscriber: $TSFixMe = Object.assign({}, data, { monitorId: monitor._id ?? monitor, }); @@ -293,7 +293,7 @@ export default class Service { async subscribeFromCSVFile(subscribers: $TSFixMe): void { const { data, projectId, monitorId }: $TSFixMe = subscribers; - const success = data.map(async (subscriber: $TSFixMe) => { + const success: $TSFixMe = data.map(async (subscriber: $TSFixMe) => { const newSubscriber: $TSFixMe = Object.assign({}, subscriber, { monitorId, projectId, diff --git a/CommonServer/Services/TeamService.ts b/CommonServer/Services/TeamService.ts index 03e5f8c83f..54cf571cd9 100755 --- a/CommonServer/Services/TeamService.ts +++ b/CommonServer/Services/TeamService.ts @@ -50,7 +50,7 @@ export default class Service { }); const response: $TSFixMe = []; - for (let i = 0; i < users.length; i++) { + for (let i: $TSFixMe = 0; i < users.length; i++) { const memberDetail: $TSFixMe = projectMembers.filter( member => member.userId === users[i]._id.toString() )[0]; @@ -72,7 +72,7 @@ export default class Service { teamMemberUserId: ObjectID ): void { let index; - let subProject = null; + let subProject: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: projectId }, @@ -87,7 +87,7 @@ export default class Service { }); } if (subProject) { - for (let i = 0; i < subProject.users.length; i++) { + for (let i: $TSFixMe = 0; i < subProject.users.length; i++) { if (teamMemberUserId == subProject.users[i].userId) { index = i; break; @@ -96,7 +96,7 @@ export default class Service { } } } else { - for (let i = 0; i < project.users.length; i++) { + for (let i: $TSFixMe = 0; i < project.users.length; i++) { if (teamMemberUserId == project.users[i].userId) { index = i; break; @@ -120,8 +120,8 @@ export default class Service { } async getSeats(members: $TSFixMe): void { - let seats = members.filter(async (user: $TSFixMe) => { - let count = 0; + let seats: $TSFixMe = members.filter(async (user: $TSFixMe) => { + let count: $TSFixMe = 0; const user_member: $TSFixMe = await UserService.findOneBy({ query: { _id: user.userId }, select: 'email', @@ -160,10 +160,10 @@ export default class Service { }); emails = emails.toLowerCase().split(','); - let subProject = null; + let subProject: $TSFixMe = null; //Checks if users to be added to project are not duplicate. - let duplicateEmail = false; + let duplicateEmail: $TSFixMe = false; emails.forEach((element: $TSFixMe, index: $TSFixMe): void => { // Find if there is a duplicate or not if (emails.indexOf(element, index + 1) > -1) { @@ -189,7 +189,7 @@ export default class Service { }); } const teamMembers: $TSFixMe = await this.getTeamMembers(projectId); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -215,7 +215,7 @@ export default class Service { (proj: $TSFixMe) => proj._id.toString() === projectId.toString() ); - let isHiddenAdminUser = false; + let isHiddenAdminUser: $TSFixMe = false; if (isAdminInProject) { isHiddenAdminUser = isAdminInProject[0]?.users.filter( @@ -276,9 +276,9 @@ export default class Service { } isValidBusinessEmails(emails: $TSFixMe): void { - let valid = true; + let valid: $TSFixMe = true; if (emails && emails.length > 0) { - for (let i = 0; i < emails.length; i++) { + for (let i: $TSFixMe = 0; i < emails.length; i++) { if (!emaildomains.test(emails[i])) { valid = false; break; @@ -291,7 +291,7 @@ export default class Service { async checkUser(teamMembers: $TSFixMe, emails: $TSFixMe): void { const teamMembersEmail: $TSFixMe = []; - for (let i = 0; i < teamMembers.length; i++) { + for (let i: $TSFixMe = 0; i < teamMembers.length; i++) { const user: $TSFixMe = await UserService.findOneBy({ query: { _id: teamMembers[i].userId }, select: 'email', @@ -299,7 +299,7 @@ export default class Service { teamMembersEmail.push(user.email); } - for (let i = 0; i < teamMembersEmail.length; i++) { + for (let i: $TSFixMe = 0; i < teamMembersEmail.length; i++) { if ( emails.filter( (email: $TSFixMe) => email === teamMembersEmail[i] @@ -327,9 +327,9 @@ export default class Service { extraUsersToAdd: $TSFixMe ): void { const invitedTeamMembers: $TSFixMe = []; - let projectUsers = []; + let projectUsers: $TSFixMe = []; - let subProject = null; + let subProject: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: projectId }, @@ -344,7 +344,7 @@ export default class Service { }); } - for (let i = 0; i < emails.length; i++) { + for (let i: $TSFixMe = 0; i < emails.length; i++) { const email: $TSFixMe = emails[i]; if (!email) { continue; @@ -366,7 +366,7 @@ export default class Service { } } await Promise.all(invitedTeamMembers); - let members = []; + let members: $TSFixMe = []; for (const member of invitedTeamMembers) { let registerUrl: string = `${global.accountsHost}/register`; @@ -508,7 +508,7 @@ export default class Service { parentProjectId: project._id, }); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); } @@ -520,7 +520,7 @@ export default class Service { extraUsersToAdd = extraUsersToAdd - 1; } } - let newProjectSeats = projectSeats; + let newProjectSeats: $TSFixMe = projectSeats; if (role !== 'Viewer') { newProjectSeats = projectSeats + extraUsersToAdd; @@ -538,9 +538,9 @@ export default class Service { { seats: newProjectSeats.toString() } ); - let response = []; + let response: $TSFixMe = []; let team: $TSFixMe = await this.getTeamMembersBy({ _id: project._id }); - let teamusers = { + let teamusers: $TSFixMe = { projectId: project._id, team: team, }; @@ -581,7 +581,7 @@ export default class Service { teamMemberUserId: ObjectID ): void { let index; - let subProject = null; + let subProject: $TSFixMe = null; if (userId === teamMemberUserId) { throw new BadDataException('Admin User cannot delete himself'); @@ -599,7 +599,7 @@ export default class Service { }); } if (subProject) { - for (let i = 0; i < subProject.users.length; i++) { + for (let i: $TSFixMe = 0; i < subProject.users.length; i++) { if (teamMemberUserId == subProject.users[i].userId) { index = i; break; @@ -608,7 +608,7 @@ export default class Service { } } } else { - for (let i = 0; i < project.users.length; i++) { + for (let i: $TSFixMe = 0; i < project.users.length; i++) { if (teamMemberUserId == project.users[i].userId) { index = i; break; @@ -709,8 +709,8 @@ export default class Service { }); // send response - let response = []; - let teamusers = { + let response: $TSFixMe = []; + let teamusers: $TSFixMe = { projectId: project._id, team: team, }; @@ -761,11 +761,11 @@ export default class Service { teamMemberUserId: ObjectID, role: $TSFixMe ): void { - let previousRole = ''; + let previousRole: $TSFixMe = ''; const nextRole: $TSFixMe = role; let index; - let subProject = null; - let subProjects = null; + let subProject: $TSFixMe = null; + let subProjects: $TSFixMe = null; let project: $TSFixMe = await ProjectService.findOneBy({ query: { _id: projectId }, @@ -886,11 +886,11 @@ export default class Service { } // send response - let response = []; + let response: $TSFixMe = []; let team: $TSFixMe = await this.getTeamMembersBy({ _id: project._id, }); - let teamusers = { + let teamusers: $TSFixMe = { projectId: project._id, team: team, }; @@ -924,7 +924,7 @@ export default class Service { teamMembers: team, projectId, }); - const teams = response.map(res: $TSFixMe => res.team); + const teams: $TSFixMe = response.map(res: $TSFixMe => res.team); const flatTeams: $TSFixMe = flatten(teams); const teamArr: $TSFixMe = flatTeams.filter( team => String(team.userId) === String(teamMemberUserId) @@ -932,7 +932,7 @@ export default class Service { const checkCurrentViewer: $TSFixMe = teamArr.every( data => data.role === 'Viewer' ); - let projectSeats = project.seats; + let projectSeats: $TSFixMe = project.seats; if (typeof projectSeats === 'string') { projectSeats = parseInt(projectSeats); diff --git a/CommonServer/Services/TwilioService.ts b/CommonServer/Services/TwilioService.ts index b9b39847ec..4b45bc20d1 100755 --- a/CommonServer/Services/TwilioService.ts +++ b/CommonServer/Services/TwilioService.ts @@ -259,7 +259,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -393,7 +393,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -527,7 +527,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -661,7 +661,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -736,7 +736,7 @@ export default class TwilioService { return message; } catch (error) { - let err = Object.assign({}, error); + let err: $TSFixMe = Object.assign({}, error); if ( (err && err.status) || error.message === 'accountSid must start with AC' @@ -826,7 +826,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -952,7 +952,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -1074,7 +1074,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -1196,7 +1196,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -1319,7 +1319,7 @@ export default class TwilioService { creds['account-sid'], creds['authentication-token'] ); - let alertLimit = true; + let alertLimit: $TSFixMe = true; alertLimit = await AlertService.checkPhoneAlertsLimit( projectId @@ -1537,7 +1537,7 @@ export default class TwilioService { const defaultTemplate: $TSFixMe = defaultSmsTemplates.filter( template => template.smsType === smsTemplateType )[0]; - let smsContent = defaultTemplate.body; + let smsContent: $TSFixMe = defaultTemplate.body; if ( smsTemplate != null && smsTemplate != undefined && @@ -1675,8 +1675,8 @@ export default class TwilioService { countryCode: $TSFixMe, numberType: $TSFixMe ): void { - let accountSid = null; - let authToken = null; + let accountSid: $TSFixMe = null; + let authToken: $TSFixMe = null; let numbers; const data: $TSFixMe = { phoneNumber: '', @@ -1773,8 +1773,8 @@ export default class TwilioService { } async buyPhoneNumber(projectId: ObjectID, phoneNumber: $TSFixMe): void { - let accountSid = null; - let authToken = null; + let accountSid: $TSFixMe = null; + let authToken: $TSFixMe = null; const customTwilioSettings: $TSFixMe = await this.findByOne({ query: { projectId, enabled: true }, select: 'accountSid authToken', @@ -1803,8 +1803,8 @@ export default class TwilioService { } async releasePhoneNumber(projectId: ObjectID, sid: $TSFixMe): void { - let accountSid = null; - let authToken = null; + let accountSid: $TSFixMe = null; + let authToken: $TSFixMe = null; const customTwilioSettings: $TSFixMe = await this.findByOne({ query: { projectId, enabled: true }, select: 'accountSid authToken', @@ -1826,8 +1826,8 @@ export default class TwilioService { } async getCallDetails(projectId: ObjectID, CallSid: $TSFixMe): void { - let accountSid = null; - let authToken = null; + let accountSid: $TSFixMe = null; + let authToken: $TSFixMe = null; const customTwilioSettings: $TSFixMe = await this.findByOne({ query: { projectId, enabled: true }, select: 'accountSid authToken', @@ -1847,7 +1847,7 @@ export default class TwilioService { } async calculatePrice(currentPrice: $TSFixMe, basePrice: $TSFixMe): void { - let price = + let price: $TSFixMe = currentPrice && basePrice ? currentPrice > basePrice ? currentPrice * 10 diff --git a/CommonServer/Services/UserService.ts b/CommonServer/Services/UserService.ts index 2908bc6882..cd6be1a81c 100755 --- a/CommonServer/Services/UserService.ts +++ b/CommonServer/Services/UserService.ts @@ -341,7 +341,7 @@ class Service extends DatabaseService { hotp.options = { digits: 8 }; const backupCodes: $TSFixMe = []; - for (let i = 0; i < numberOfCodes; i++) { + for (let i: $TSFixMe = 0; i < numberOfCodes; i++) { const counter: $TSFixMe = firstCounter + i; const token: $TSFixMe = hotp.generate(secretKey, counter); backupCodes.push({ code: token, counter }); @@ -364,12 +364,14 @@ class Service extends DatabaseService { query: { twoFactorSecretCode: secretKey }, select, }); - const backupCodes = user.backupCodes.map((backupCode: $TSFixMe) => { - if (backupCode.code === code) { - backupCode.used = true; + const backupCodes: $TSFixMe = user.backupCodes.map( + (backupCode: $TSFixMe) => { + if (backupCode.code === code) { + backupCode.used = true; + } + return backupCode; } - return backupCode; - }); + ); await this.updateOneBy( { twoFactorSecretCode: secretKey }, { backupCodes } @@ -432,7 +434,7 @@ class Service extends DatabaseService { clientIP: $TSFixMe, userAgent: $TSFixMe ): void { - let user = null; + let user: $TSFixMe = null; if (util.isEmailValid(email)) { // find user if present in db. @@ -835,8 +837,8 @@ class Service extends DatabaseService { query: { 'users.userId': user._id }, select: 'parentProjectId', }); - let parentProjectIds = []; - let projectIds = []; + let parentProjectIds: $TSFixMe = []; + let projectIds: $TSFixMe = []; if (userProjects.length > 0) { const subProjects: $TSFixMe = userProjects .map((project: $TSFixMe) => @@ -941,8 +943,8 @@ class Service extends DatabaseService { query: { 'users.userId': user._id }, select: 'parentProjectId', }); - let parentProjectIds = []; - let projectIds = []; + let parentProjectIds: $TSFixMe = []; + let projectIds: $TSFixMe = []; if (userProjects.length > 0) { const subProjects: $TSFixMe = userProjects .map((project: $TSFixMe) => diff --git a/CommonServer/Services/WebHookService.ts b/CommonServer/Services/WebHookService.ts index b1456e4f8f..caa687858b 100755 --- a/CommonServer/Services/WebHookService.ts +++ b/CommonServer/Services/WebHookService.ts @@ -71,7 +71,7 @@ export default class Service { if (project && project.parentProjectId) { projectId = project.parentProjectId._id || project.parentProjectId; } - let query = { + let query: $TSFixMe = { projectId: projectId, integrationType: 'webhook', monitors: { $elemMatch: { monitorId: monitor._id } }, @@ -156,8 +156,8 @@ export default class Service { let httpMethod; const isStatusPageNoteNotification: $TSFixMe = note && incidentState && statusNoteStatus; - let notificationTitle = ''; - let notificationText = ''; + let notificationTitle: $TSFixMe = ''; + let notificationText: $TSFixMe = ''; const criterionCauseName: $TSFixMe = incident.criterionCause ? incident.criterionCause.name : 'Unnamed Criterion'; diff --git a/CommonServer/Services/ZapierService.ts b/CommonServer/Services/ZapierService.ts index ef31926569..6fbaa63856 100755 --- a/CommonServer/Services/ZapierService.ts +++ b/CommonServer/Services/ZapierService.ts @@ -66,7 +66,9 @@ export default class Service { }, select: '_id', }); - const projectIds = projects.map((project: $TSFixMe) => project._id); + const projectIds: $TSFixMe = projects.map( + (project: $TSFixMe) => project._id + ); const findquery: $TSFixMe = { projectId: { $in: projectIds }, acknowledged: false, @@ -123,7 +125,9 @@ export default class Service { }, select: '_id', }); - const projectIds = projects.map((project: $TSFixMe) => project._id); + const projectIds: $TSFixMe = projects.map( + (project: $TSFixMe) => project._id + ); const findquery: $TSFixMe = { projectId: { $in: projectIds }, }; @@ -184,7 +188,7 @@ export default class Service { '_id updated postOnStatusPage createdAt content incidentId createdById type incident_state'; await Promise.all( data.incidents.map(async (incidentId: $TSFixMe) => { - let incidentMessage = new IncidentMessageModel(); + let incidentMessage: $TSFixMe = new IncidentMessageModel(); incidentMessage.incidentId = incidentId; @@ -231,7 +235,9 @@ export default class Service { }, select: '_id', }); - const projectIds = projects.map((project: $TSFixMe) => project._id); + const projectIds: $TSFixMe = projects.map( + (project: $TSFixMe) => project._id + ); const findquery: $TSFixMe = { projectId: { $in: projectIds }, acknowledged: true, @@ -287,7 +293,9 @@ export default class Service { }, select: '_id', }); - const projectIds = projects.map((project: $TSFixMe) => project._id); + const projectIds: $TSFixMe = projects.map( + (project: $TSFixMe) => project._id + ); const findquery: $TSFixMe = { projectId: { $in: projectIds }, acknowledged: true, @@ -334,7 +342,7 @@ export default class Service { select: 'name projectId _id', populate: [{ path: 'projectId', select: '_id' }], }); - let incident = new IncidentModel(); + let incident: $TSFixMe = new IncidentModel(); incident.projectId = monitorObj.projectId._id; @@ -881,7 +889,7 @@ export default class Service { select: 'parentProjectId _id name', }); - let zap = []; + let zap: $TSFixMe = []; if (project) { if (project.parentProjectId) { project = await ProjectService.findOneBy({ @@ -909,7 +917,7 @@ export default class Service { if (zap && zap.length) { for (const z of zap) { - let zapierResponse = {}; + let zapierResponse: $TSFixMe = {}; if (project) { zapierResponse.projectName = project.name; diff --git a/CommonUI/src/utils/pricingPlan.ts b/CommonUI/src/utils/pricingPlan.ts index 1e0f37c2a9..4c37b970e7 100644 --- a/CommonUI/src/utils/pricingPlan.ts +++ b/CommonUI/src/utils/pricingPlan.ts @@ -102,7 +102,7 @@ export default class PricingPlan { public static getPlanById(id: string): PricingPlanType { const plans: $TSFixMe = this.getPlans(); - const plan = plans.find(plan => plan.planId: $TSFixMe === id); + const plan: $TSFixMe = plans.find(plan => plan.planId: $TSFixMe === id); if (plan) { return plan; diff --git a/ContainerScanner/utils/containerService.ts b/ContainerScanner/utils/containerService.ts index 33f34d9830..e743a33596 100644 --- a/ContainerScanner/utils/containerService.ts +++ b/ContainerScanner/utils/containerService.ts @@ -27,7 +27,7 @@ export default { decryptPassword: async function (security): void { const values: $TSFixMe = []; - for (let i = 0; i <= 15; i++) { + for (let i: $TSFixMe = 0; i <= 15; i++) { values.push(security.dockerCredential.iv[i]); } const iv: $TSFixMe = Buffer.from(values); @@ -46,7 +46,7 @@ export default { key, iv ); - let decoded = decipher.update(encText, 'hex', 'utf8'); + let decoded: $TSFixMe = decipher.update(encText, 'hex', 'utf8'); decoded += decipher.final('utf8'); resolve(decoded); } catch (error) { @@ -62,7 +62,7 @@ export default { ? `${imagePath}:${imageTags}` : imagePath; const outputFile: string = `${uuidv1()}result.json`; - let securityDir = 'container_security_dir'; + let securityDir: $TSFixMe = 'container_security_dir'; securityDir = await createDir(securityDir); const exactFilePath: $TSFixMe = Path.resolve(securityDir, outputFile); diff --git a/Dashboard/index.ts b/Dashboard/index.ts index 6ff096659b..ec69a8bb93 100755 --- a/Dashboard/index.ts +++ b/Dashboard/index.ts @@ -107,7 +107,7 @@ app.use('/dashboard', ExpressStatic(path.join(__dirname, 'build'))); // app.use( // /^\/dashboard\/static\/js\/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\.(.+)\.chunk\.js$/, // function(req:Request, res: ExpressResponse, next: NextFunction) { -// let baseUrls = req.baseUrl; +// let baseUrls: $TSFixMe = req.baseUrl; // baseUrls = baseUrls.split('/'); // const fileName: $TSFixMe = baseUrls[baseUrls.length - 1]; @@ -125,7 +125,7 @@ app.use('/dashboard', ExpressStatic(path.join(__dirname, 'build'))); // res, // next // ) { -// let baseUrls = req.baseUrl; +// let baseUrls: $TSFixMe = req.baseUrl; // baseUrls = baseUrls.split('/'); // const fileName: $TSFixMe = baseUrls[baseUrls.length - 1]; diff --git a/Dashboard/src/Actions/Base/base.ts b/Dashboard/src/Actions/Base/base.ts index 28f83a12f0..cbe0183eab 100644 --- a/Dashboard/src/Actions/Base/base.ts +++ b/Dashboard/src/Actions/Base/base.ts @@ -130,7 +130,7 @@ class BaseAction { } dispatch(actions[this.actionKeys.request]()); - let response = null; + let response: $TSFixMe = null; try { if (this.actionType === 'create') { response = await BackendAPI.post(path, data); diff --git a/Dashboard/src/Actions/alert.ts b/Dashboard/src/Actions/alert.ts index 84aec85bae..4bd253559a 100755 --- a/Dashboard/src/Actions/alert.ts +++ b/Dashboard/src/Actions/alert.ts @@ -206,7 +206,7 @@ export function fetchSubscriberAlert( return function (dispatch: Dispatch): void { skip = skip < 0 ? 0 : skip; limit = limit < 0 ? 0 : limit; - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `subscriberAlert/${projectId}/incident/${incidentSlug}?skip=${skip}&limit=${limit}` diff --git a/Dashboard/src/Actions/incident.ts b/Dashboard/src/Actions/incident.ts index 4fadb28ba2..8843144ed3 100755 --- a/Dashboard/src/Actions/incident.ts +++ b/Dashboard/src/Actions/incident.ts @@ -45,7 +45,7 @@ export function getProjectIncidents( limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `incident/${projectId}/incident?skip=${skip}&limit=${limit}` @@ -79,7 +79,7 @@ export function getProjectComponentIncidents( limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `incident/${projectId}/incidents/${componentId}?skip=${skip}&limit=${limit}` @@ -328,7 +328,7 @@ export const getIncident: Function = ( ): void => { //This fucntion will switch to incidentSlug of the params beig passed. return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `incident/${projectId}/incident/${incidentSlug}` ); @@ -360,7 +360,7 @@ export function getIncidentTimeline( limit: PositiveNumber ) { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `incident/${projectId}/timeline/${incidentId}?skip=${skip}&limit=${limit}` ); @@ -414,7 +414,7 @@ export function acknowledgeIncident( ) { //This fucntion will switch to incidentId of the params beig passed. return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; const data: $TSFixMe = { decoded: userId, projectId, @@ -512,7 +512,7 @@ export function resolveIncident( ) { //This function will switch to incidentId of the params being passed. return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; const data: $TSFixMe = { decoded: userId, projectId, @@ -687,7 +687,7 @@ export const fetchUnresolvedIncidents: Function = ( ): void => { //This fucntion will switch to incidentId of the params beig passed. return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `incident/${projectId}/unresolvedincidents?isHome=${isHome}` @@ -751,7 +751,7 @@ export function setInvestigationNote( body: $TSFixMe ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.post( `incident/${projectId}/incident/${incidentId}/message`, @@ -807,7 +807,7 @@ export function setInternalNote( body: $TSFixMe ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.post( `incident/${projectId}/incident/${incidentId}/message`, body diff --git a/Dashboard/src/Actions/invoice.ts b/Dashboard/src/Actions/invoice.ts index 5f8eff8106..9267834552 100755 --- a/Dashboard/src/Actions/invoice.ts +++ b/Dashboard/src/Actions/invoice.ts @@ -51,7 +51,7 @@ export function getInvoice( endingBefore: $TSFixMe ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; const reqFornext: $TSFixMe = Boolean(startingAfter) && !endingBefore; const reqForPrev: $TSFixMe = Boolean(endingBefore) && Boolean(startingAfter); diff --git a/Dashboard/src/Actions/monitor.ts b/Dashboard/src/Actions/monitor.ts index 88819f480d..65bbe42746 100755 --- a/Dashboard/src/Actions/monitor.ts +++ b/Dashboard/src/Actions/monitor.ts @@ -620,7 +620,7 @@ export const changeMonitorComponent: Function = ( return monitor; } catch (err) { - let error = { ...err }; + let error: $TSFixMe = { ...err }; if (error && error.response && error.response.data) { error = error.response.data; } diff --git a/Dashboard/src/Actions/msteamsWebhook.ts b/Dashboard/src/Actions/msteamsWebhook.ts index 63b7b09307..5784e937e5 100644 --- a/Dashboard/src/Actions/msteamsWebhook.ts +++ b/Dashboard/src/Actions/msteamsWebhook.ts @@ -89,7 +89,7 @@ export function getMsTeams( limit: PositiveNumber ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks?skip=${skip || 0}&limit=${ limit || 10 @@ -117,7 +117,7 @@ export function getMsTeamsMonitor( limit: PositiveNumber ) { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks/${monitorId}?skip=${skip || 0}&limit=${ limit || 10 diff --git a/Dashboard/src/Actions/probe.ts b/Dashboard/src/Actions/probe.ts index 755966be97..e49ba57fb0 100644 --- a/Dashboard/src/Actions/probe.ts +++ b/Dashboard/src/Actions/probe.ts @@ -43,7 +43,7 @@ export function getProbes( limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `probe/${projectId}/probes?skip=${skip}&limit=${limit}` diff --git a/Dashboard/src/Actions/project.ts b/Dashboard/src/Actions/project.ts index 0ab6b3b374..5a4f4a764c 100755 --- a/Dashboard/src/Actions/project.ts +++ b/Dashboard/src/Actions/project.ts @@ -156,9 +156,9 @@ export const getProjects: Function = (switchToProjectId: ObjectID): void => { dispatch(switchProject(dispatch, projects[0])); } } else { - let projectSwitched = false; + let projectSwitched: $TSFixMe = false; - for (let i = 0; i < projects.length; i++) { + for (let i: $TSFixMe = 0; i < projects.length; i++) { if (projects[i]._id === switchToProjectId) { dispatch(switchProject(dispatch, projects[i])); projectSwitched = true; diff --git a/Dashboard/src/Actions/reports.ts b/Dashboard/src/Actions/reports.ts index fb6947a61f..b8ffbe8c59 100755 --- a/Dashboard/src/Actions/reports.ts +++ b/Dashboard/src/Actions/reports.ts @@ -45,7 +45,7 @@ export const getActiveMembers: $TSFixMe = dispatch(getActiveMembersSuccess(members.data)); } catch (error) { - let newerror = error; + let newerror: $TSFixMe = error; if (newerror && newerror.response && newerror.response.data) { newerror = newerror.response.data; } @@ -104,7 +104,7 @@ export const getActiveMonitors: $TSFixMe = dispatch(getActiveMonitorsSuccess(monitors.data)); } catch (error) { - let newerror = error; + let newerror: $TSFixMe = error; if (newerror && newerror.response && newerror.response.data) { newerror = newerror.response.data; } @@ -158,7 +158,7 @@ export const getIncidents: $TSFixMe = dispatch(getIncidentsSuccess(reports.data)); } catch (error) { - let newerror = error; + let newerror: $TSFixMe = error; if (newerror && newerror.response && newerror.response.data) { newerror = newerror.response.data; } @@ -212,7 +212,7 @@ export const getResolveTime: $TSFixMe = dispatch(getResolveTimeSuccess(reports.data)); } catch (error) { - let newerror = error; + let newerror: $TSFixMe = error; if (newerror && newerror.response && newerror.response.data) { newerror = newerror.response.data; } diff --git a/Dashboard/src/Actions/resourceCategories.ts b/Dashboard/src/Actions/resourceCategories.ts index 0c1ef97c70..68fea99c50 100755 --- a/Dashboard/src/Actions/resourceCategories.ts +++ b/Dashboard/src/Actions/resourceCategories.ts @@ -12,7 +12,7 @@ export function fetchResourceCategories( skip = parseInt(skip); limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `resourceCategory/${projectId}?skip=${skip}&limit=${limit}` diff --git a/Dashboard/src/Actions/schedule.ts b/Dashboard/src/Actions/schedule.ts index 4063f349dd..c1814b5e90 100755 --- a/Dashboard/src/Actions/schedule.ts +++ b/Dashboard/src/Actions/schedule.ts @@ -41,7 +41,7 @@ export function fetchSchedules( limit: PositiveNumber ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `schedule/${projectId}?skip=${skip || 0}&limit=${limit || 10}` ); @@ -99,7 +99,7 @@ export const fetchSubProjectSchedules: Function = ( projectId: ObjectID ): void => { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get(`schedule/${projectId}/schedules`); dispatch(subProjectScheduleRequest()); @@ -151,7 +151,7 @@ export function fetchProjectSchedule( limit: PositiveNumber ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `schedule/${projectId}/schedule?skip=${skip}&limit=${limit}` ); diff --git a/Dashboard/src/Actions/scheduledEvent.ts b/Dashboard/src/Actions/scheduledEvent.ts index 3e0df0551b..9b6d8e95df 100755 --- a/Dashboard/src/Actions/scheduledEvent.ts +++ b/Dashboard/src/Actions/scheduledEvent.ts @@ -67,7 +67,7 @@ export const fetchscheduledEvents: $TSFixMe = dispatch(fetchscheduledEventsRequest()); try { - let response = {}; + let response: $TSFixMe = {}; if (!skip && !limit) { response = await BackendAPI.get( `scheduledEvent/${projectId}?skip=${0}&limit=${10}` @@ -490,7 +490,7 @@ export const fetchScheduledEventNotesInternal: $TSFixMe = skip = Number(skip); limit = Number(limit); - let response = {}; + let response: $TSFixMe = {}; if (skip >= 0 && limit >= 0) { response = await BackendAPI.get( `scheduledEvent/${projectId}/${scheduledEventId}/notes?limit=${limit}&skip=${skip}&type=${type}` diff --git a/Dashboard/src/Actions/slack.ts b/Dashboard/src/Actions/slack.ts index fa5f32d5ee..0ca151b69e 100755 --- a/Dashboard/src/Actions/slack.ts +++ b/Dashboard/src/Actions/slack.ts @@ -91,7 +91,7 @@ export function getSlackTeams( limit: PositiveNumber ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip && limit) { promise = BackendAPI.get( `slack/${projectId}/teams?skip=${skip}&limit=${limit}` diff --git a/Dashboard/src/Actions/slackWebhook.ts b/Dashboard/src/Actions/slackWebhook.ts index a01f07fc33..6e6a441075 100644 --- a/Dashboard/src/Actions/slackWebhook.ts +++ b/Dashboard/src/Actions/slackWebhook.ts @@ -88,7 +88,7 @@ export const getSlack: Function = ( limit: PositiveNumber ): void => { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks?skip=${skip || 0}&limit=${ limit || 10 @@ -116,7 +116,7 @@ export function getSlackMonitor( limit: PositiveNumber ) { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks/${monitorId}?skip=${skip || 0}&limit=${ limit || 10 diff --git a/Dashboard/src/Actions/tutorial.ts b/Dashboard/src/Actions/tutorial.ts index 29b8faeb7d..be3d2753de 100644 --- a/Dashboard/src/Actions/tutorial.ts +++ b/Dashboard/src/Actions/tutorial.ts @@ -60,7 +60,7 @@ export const resetCloseTutorial: Function = (): void => { export const fetchTutorial: Function = (): void => { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get(new Route('tutorial')); dispatch(fetchTutorialRequest(promise)); @@ -83,7 +83,7 @@ export const closeTutorial: Function = ( projectId: ObjectID ): void => { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.put('tutorial', { type, projectId }); dispatch(closeTutorialRequest(promise)); diff --git a/Dashboard/src/Actions/version.ts b/Dashboard/src/Actions/version.ts index 0d4d67b19f..81a0a1aba4 100644 --- a/Dashboard/src/Actions/version.ts +++ b/Dashboard/src/Actions/version.ts @@ -32,7 +32,7 @@ export const resetGetVersion: Function = (): void => { export const getVersion: Function = (): void => { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get(new Route('version')); dispatch(getVersionRequest(promise)); diff --git a/Dashboard/src/Actions/webHook.ts b/Dashboard/src/Actions/webHook.ts index 94e7f7ff1c..7b439b2719 100755 --- a/Dashboard/src/Actions/webHook.ts +++ b/Dashboard/src/Actions/webHook.ts @@ -89,7 +89,7 @@ export function getWebHook( limit: PositiveNumber ): void { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks?skip=${skip || 0}&limit=${limit || 10}` ); @@ -115,7 +115,7 @@ export function getWebHookMonitor( limit: PositiveNumber ) { return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; promise = BackendAPI.get( `webhook/${projectId}/hooks/${monitorId}?skip=${skip || 0}&limit=${ limit || 10 diff --git a/Dashboard/src/Pages/index.ts b/Dashboard/src/Pages/index.ts index 896ffbcab2..b6eec9b4d1 100755 --- a/Dashboard/src/Pages/index.ts +++ b/Dashboard/src/Pages/index.ts @@ -1,78 +1,114 @@ import { lazy } from 'react'; -const Home = lazy((): $TSFixMe => import('./Home')); +const Home: $TSFixMe = lazy((): $TSFixMe => import('./Home')); -const Monitor = lazy((): $TSFixMe => import('./Monitor')); -const IncidentLog = lazy((): $TSFixMe => import('./IncidentLog')); -const Incident = lazy((): $TSFixMe => import('./Incident')); -const IncidentSettings = lazy((): $TSFixMe => import('./IncidentSettings')); -const MonitorSettings = lazy((): $TSFixMe => import('./MonitorSettings')); +const Monitor: $TSFixMe = lazy((): $TSFixMe => import('./Monitor')); +const IncidentLog: $TSFixMe = lazy((): $TSFixMe => import('./IncidentLog')); +const Incident: $TSFixMe = lazy((): $TSFixMe => import('./Incident')); +const IncidentSettings: $TSFixMe = lazy( + (): $TSFixMe => import('./IncidentSettings') +); +const MonitorSettings: $TSFixMe = lazy( + (): $TSFixMe => import('./MonitorSettings') +); -const StatusPage = lazy((): $TSFixMe => import('./StatusPage')); -const StatusPagesList = lazy((): $TSFixMe => import('./StatusPage/list')); +const StatusPage: $TSFixMe = lazy((): $TSFixMe => import('./StatusPage')); +const StatusPagesList: $TSFixMe = lazy( + (): $TSFixMe => import('./StatusPage/list') +); -const OnCall = lazy((): $TSFixMe => import('./OnCall')); -const AlertLog = lazy((): $TSFixMe => import('./AlertLog')); -const Schedule = lazy((): $TSFixMe => import('./Schedule')); +const OnCall: $TSFixMe = lazy((): $TSFixMe => import('./OnCall')); +const AlertLog: $TSFixMe = lazy((): $TSFixMe => import('./AlertLog')); +const Schedule: $TSFixMe = lazy((): $TSFixMe => import('./Schedule')); -const ScheduledEvent = lazy((): $TSFixMe => import('./ScheduledEvent')); -const ScheduledEventDetail = lazy( +const ScheduledEvent: $TSFixMe = lazy( + (): $TSFixMe => import('./ScheduledEvent') +); +const ScheduledEventDetail: $TSFixMe = lazy( (): $TSFixMe => import('./ScheduledEventDetail') ); -const ChangePassword = lazy((): $TSFixMe => import('./ChangePassword')); +const ChangePassword: $TSFixMe = lazy( + (): $TSFixMe => import('./ChangePassword') +); -const TeamMembers = lazy((): $TSFixMe => import('./TeamMembers')); -const TeamMemberProfile = lazy((): $TSFixMe => import('./TeamMemberProfile')); -const Profile = lazy((): $TSFixMe => import('./Profile')); -const Settings = lazy((): $TSFixMe => import('./Settings')); +const TeamMembers: $TSFixMe = lazy((): $TSFixMe => import('./TeamMembers')); +const TeamMemberProfile: $TSFixMe = lazy( + (): $TSFixMe => import('./TeamMemberProfile') +); +const Profile: $TSFixMe = lazy((): $TSFixMe => import('./Profile')); +const Settings: $TSFixMe = lazy((): $TSFixMe => import('./Settings')); -const Billing = lazy((): $TSFixMe => import('./Billing')); -const Resources = lazy((): $TSFixMe => import('./Resources')); -const Component = lazy((): $TSFixMe => import('./Component')); -const Integrations = lazy((): $TSFixMe => import('./Integrations')); +const Billing: $TSFixMe = lazy((): $TSFixMe => import('./Billing')); +const Resources: $TSFixMe = lazy((): $TSFixMe => import('./Resources')); +const Component: $TSFixMe = lazy((): $TSFixMe => import('./Component')); +const Integrations: $TSFixMe = lazy((): $TSFixMe => import('./Integrations')); -const EmailTemplates = lazy((): $TSFixMe => import('./EmailTemplates')); -const SmsTemplates = lazy((): $TSFixMe => import('./SmsTemplates')); +const EmailTemplates: $TSFixMe = lazy( + (): $TSFixMe => import('./EmailTemplates') +); +const SmsTemplates: $TSFixMe = lazy((): $TSFixMe => import('./SmsTemplates')); -const MonitorView = lazy((): $TSFixMe => import('./MonitorView')); -const WebsiteMonitorIssues = lazy( +const MonitorView: $TSFixMe = lazy((): $TSFixMe => import('./MonitorView')); +const WebsiteMonitorIssues: $TSFixMe = lazy( (): $TSFixMe => import('./WebsiteMonitorIssues') ); -const Reports = lazy((): $TSFixMe => import('./Reports')); +const Reports: $TSFixMe = lazy((): $TSFixMe => import('./Reports')); -const Probe = lazy((): $TSFixMe => import('./Probe')); -const ProfileBilling = lazy((): $TSFixMe => import('./ProfileBilling')); +const Probe: $TSFixMe = lazy((): $TSFixMe => import('./Probe')); +const ProfileBilling: $TSFixMe = lazy( + (): $TSFixMe => import('./ProfileBilling') +); -const ApplicationLog = lazy((): $TSFixMe => import('./ApplicationLog')); -const ApplicationLogView = lazy((): $TSFixMe => import('./ApplicationLogView')); -const Container = lazy((): $TSFixMe => import('./Container')); -const Application = lazy((): $TSFixMe => import('./Application')); -const ApplicationDetail = lazy((): $TSFixMe => import('./ApplicationDetail')); -const ContainerDetail = lazy((): $TSFixMe => import('./ContainerDetail')); -const GitCredential = lazy((): $TSFixMe => import('./GitCredential')); -const DockerCredential = lazy((): $TSFixMe => import('./DockerCredential')); -const OneUptimeApi = lazy((): $TSFixMe => import('./OneUptimeApi')); -const ChangePasswordSetting = lazy( +const ApplicationLog: $TSFixMe = lazy( + (): $TSFixMe => import('./ApplicationLog') +); +const ApplicationLogView: $TSFixMe = lazy( + (): $TSFixMe => import('./ApplicationLogView') +); +const Container: $TSFixMe = lazy((): $TSFixMe => import('./Container')); +const Application: $TSFixMe = lazy((): $TSFixMe => import('./Application')); +const ApplicationDetail: $TSFixMe = lazy( + (): $TSFixMe => import('./ApplicationDetail') +); +const ContainerDetail: $TSFixMe = lazy( + (): $TSFixMe => import('./ContainerDetail') +); +const GitCredential: $TSFixMe = lazy((): $TSFixMe => import('./GitCredential')); +const DockerCredential: $TSFixMe = lazy( + (): $TSFixMe => import('./DockerCredential') +); +const OneUptimeApi: $TSFixMe = lazy((): $TSFixMe => import('./OneUptimeApi')); +const ChangePasswordSetting: $TSFixMe = lazy( (): $TSFixMe => import('./ChangePasswordSetting') ); -const DeleteAccountPage = lazy((): $TSFixMe => import('./DeleteAccountPage')); -const Consulting = lazy((): $TSFixMe => import('./Consulting')); -const ErrorTracking = lazy((): $TSFixMe => import('./ErrorTracking')); -const Advanced = lazy((): $TSFixMe => import('./Advanced')); -const ComponentSettings = lazy((): $TSFixMe => import('./ComponentSettings')); +const DeleteAccountPage: $TSFixMe = lazy( + (): $TSFixMe => import('./DeleteAccountPage') +); +const Consulting: $TSFixMe = lazy((): $TSFixMe => import('./Consulting')); +const ErrorTracking: $TSFixMe = lazy((): $TSFixMe => import('./ErrorTracking')); +const Advanced: $TSFixMe = lazy((): $TSFixMe => import('./Advanced')); +const ComponentSettings: $TSFixMe = lazy( + (): $TSFixMe => import('./ComponentSettings') +); const ComponentSettingsAdvanced: $TSFixMe = lazy( () => import('./ComponentSettingsAdvanced') ); -const CallRouting = lazy((): $TSFixMe => import('./CallRouting')); -const DomainSettings = lazy((): $TSFixMe => import('./DomainSettings')); -const Groups = lazy((): $TSFixMe => import('./Group')); -const PerformanceTrackerView = lazy( +const CallRouting: $TSFixMe = lazy((): $TSFixMe => import('./CallRouting')); +const DomainSettings: $TSFixMe = lazy( + (): $TSFixMe => import('./DomainSettings') +); +const Groups: $TSFixMe = lazy((): $TSFixMe => import('./Group')); +const PerformanceTrackerView: $TSFixMe = lazy( (): $TSFixMe => import('./PerformanceTrackerView') ); -const PerformanceTracker = lazy((): $TSFixMe => import('./PerformanceTracker')); -const AutomationScript = lazy((): $TSFixMe => import('./AutomationScript')); -const SsoPage = lazy((): $TSFixMe => import('./Sso')); +const PerformanceTracker: $TSFixMe = lazy( + (): $TSFixMe => import('./PerformanceTracker') +); +const AutomationScript: $TSFixMe = lazy( + (): $TSFixMe => import('./AutomationScript') +); +const SsoPage: $TSFixMe = lazy((): $TSFixMe => import('./Sso')); export default { ChangePassword, diff --git a/Dashboard/src/Reducers/credential.ts b/Dashboard/src/Reducers/credential.ts index ea8607c17d..881c31b255 100644 --- a/Dashboard/src/Reducers/credential.ts +++ b/Dashboard/src/Reducers/credential.ts @@ -60,7 +60,7 @@ export default function credential(state = initialState, action: Action): void { }; case types.UPDATE_GIT_CREDENTIAL_SUCCESS: { - const gitCredentials = state.gitCredentials.map(gitCredential: $TSFixMe => { + const gitCredentials: $TSFixMe = state.gitCredentials.map(gitCredential: $TSFixMe => { if (String(gitCredential._id) === String(action.payload._id)) { gitCredential = action.payload; } diff --git a/Dashboard/src/Reducers/customField.ts b/Dashboard/src/Reducers/customField.ts index 089367d196..c206eba7f8 100644 --- a/Dashboard/src/Reducers/customField.ts +++ b/Dashboard/src/Reducers/customField.ts @@ -150,7 +150,7 @@ export default function customField( }; case types.UPDATE_CUSTOM_FIELD_SUCCESS: { - const fields = state.customFields.fields.map(field: $TSFixMe => { + const fields: $TSFixMe = state.customFields.fields.map(field: $TSFixMe => { if (String(field._id) === String(action.payload._id)) { field = action.payload; } diff --git a/Dashboard/src/Reducers/incident.ts b/Dashboard/src/Reducers/incident.ts index b9f188d616..4477d944cd 100755 --- a/Dashboard/src/Reducers/incident.ts +++ b/Dashboard/src/Reducers/incident.ts @@ -480,7 +480,7 @@ export default function incident(state = initialState, action: Action): void { }); case 'UPDATE_INCIDENT_TIMELINE': { - // let idNumber = + // let idNumber: $TSFixMe = // action.payload.incidentId && action.payload.incidentId.idNumber; // idNumber = idNumber - 1; const incidentSlug: $TSFixMe = action.payload.incidentId.slug; @@ -886,7 +886,7 @@ export default function incident(state = initialState, action: Action): void { }); case types.INVESTIGATION_NOTE_SUCCESS: { - let noteFound = false; + let noteFound: $TSFixMe = false; incidentMessages = state.incidentMessages[action.payload.incidentId._id][ action.payload.type @@ -979,11 +979,11 @@ export default function incident(state = initialState, action: Action): void { }); case 'ADD_INCIDENT_NOTE': { - let incidentFound = false; - let incidentMessages = []; + let incidentFound: $TSFixMe = false; + let incidentMessages: $TSFixMe = []; if (state.incidentMessages[action.payload.incidentId.slug]) { - let msg = + let msg: $TSFixMe = state.incidentMessages[action.payload.incidentId.slug]; msg = msg ? msg[action.payload.type] : null; msg = msg ? msg.incidentMessages : null; @@ -1192,7 +1192,7 @@ export default function incident(state = initialState, action: Action): void { ...state.unresolvedincidents, incidents: state.unresolvedincidents.incidents.map( incident => { - let monitors = incident.monitors; + let monitors: $TSFixMe = incident.monitors; if (monitors && monitors.length > 0) { monitors = monitors.map((monitor: $TSFixMe) => { if ( diff --git a/Dashboard/src/Reducers/incomingRequest.ts b/Dashboard/src/Reducers/incomingRequest.ts index 0e580b2814..cd175bb133 100644 --- a/Dashboard/src/Reducers/incomingRequest.ts +++ b/Dashboard/src/Reducers/incomingRequest.ts @@ -83,7 +83,9 @@ export default function incomingRequest( }; case types.CREATE_INCOMING_REQUEST_SUCCESS: { - let incomingRequests = [...state.incomingRequests.incomingRequests]; + let incomingRequests: $TSFixMe = [ + ...state.incomingRequests.incomingRequests, + ]; if (action.payload.isDefault) { incomingRequests = incomingRequests.map(request => { if (request.isDefault) { @@ -129,7 +131,9 @@ export default function incomingRequest( }; case types.EDIT_INCOMING_REQUEST_SUCCESS: { - let incomingRequests = [...state.incomingRequests.incomingRequests]; + let incomingRequests: $TSFixMe = [ + ...state.incomingRequests.incomingRequests, + ]; if (action.payload.isDefault) { incomingRequests = incomingRequests.map(request => { if (request.isDefault) { diff --git a/Dashboard/src/Reducers/monitor.ts b/Dashboard/src/Reducers/monitor.ts index 53f3c359af..d7ea3b6cda 100755 --- a/Dashboard/src/Reducers/monitor.ts +++ b/Dashboard/src/Reducers/monitor.ts @@ -239,9 +239,9 @@ export default function monitor(state = INITIAL_STATE, action: Action): void { case CREATE_MONITOR_SUCCESS: case 'CREATE_MONITOR': { - let monitorFound = false; - const monitors = state.monitorsList.monitors.map(monitorData: $TSFixMe => { - let output = { + let monitorFound: $TSFixMe = false; + const monitors: $TSFixMe = state.monitorsList.monitors.map(monitorData: $TSFixMe => { + let output: $TSFixMe = { ...monitorData, monitors: monitorData.monitors.map(monitor => { if ( @@ -1946,7 +1946,7 @@ export default function monitor(state = INITIAL_STATE, action: Action): void { if ( monitor._id === monitorObj._id ) { - let incidents = + let incidents: $TSFixMe = monitor.incidents || []; if ( @@ -1961,7 +1961,7 @@ export default function monitor(state = INITIAL_STATE, action: Action): void { 1 ); } - let found = false; + let found: $TSFixMe = false; for (const incident of incidents) { if ( String( diff --git a/Dashboard/src/Reducers/monitorCustomField.ts b/Dashboard/src/Reducers/monitorCustomField.ts index 49042787e7..022f6895a5 100644 --- a/Dashboard/src/Reducers/monitorCustomField.ts +++ b/Dashboard/src/Reducers/monitorCustomField.ts @@ -148,7 +148,7 @@ export default function monitorCustomField( }; case types.UPDATE_CUSTOM_FIELD_SUCCESS: { - const fields = state.monitorCustomFields.fields.map(field: $TSFixMe => { + const fields: $TSFixMe = state.monitorCustomFields.fields.map(field: $TSFixMe => { if (String(field._id) === String(action.payload._id)) { field = action.payload; } diff --git a/Dashboard/src/Reducers/monitorSla.ts b/Dashboard/src/Reducers/monitorSla.ts index a3f6897f48..b24f74a2cf 100644 --- a/Dashboard/src/Reducers/monitorSla.ts +++ b/Dashboard/src/Reducers/monitorSla.ts @@ -184,7 +184,7 @@ export default function monitorSla(state = initialState, action: Action): void { }; case types.UPDATE_MONITOR_SLA_SUCCESS: { - const slas = state.monitorSlas.slas.map(sla: $TSFixMe => { + const slas: $TSFixMe = state.monitorSlas.slas.map(sla: $TSFixMe => { if ( action.payload.isDefault && String(sla._id) !== String(action.payload._id) diff --git a/Dashboard/src/Reducers/scheduledEvent.ts b/Dashboard/src/Reducers/scheduledEvent.ts index 9f20540562..4f6dc5c17a 100755 --- a/Dashboard/src/Reducers/scheduledEvent.ts +++ b/Dashboard/src/Reducers/scheduledEvent.ts @@ -171,8 +171,8 @@ export default function scheduledEvent( ): void { switch (action.type) { case CREATE_SCHEDULED_EVENT_SUCCESS: { - let existingPayload = false; - let existingOngoingEvent = false; + let existingPayload: $TSFixMe = false; + let existingOngoingEvent: $TSFixMe = false; const currentDate: $TSFixMe = moment().format(); const startDate: $TSFixMe = moment( action.payload.startDate @@ -189,7 +189,9 @@ export default function scheduledEvent( ? [] : [action.payload]; - let events = [...state.subProjectOngoingScheduledEvent.events]; + let events: $TSFixMe = [ + ...state.subProjectOngoingScheduledEvent.events, + ]; state.subProjectOngoingScheduledEvent.events.forEach(eventData => { if ( @@ -524,7 +526,7 @@ export default function scheduledEvent( }; case DELETE_SCHEDULED_EVENT_SUCCESS: { - let deleted = true; + let deleted: $TSFixMe = true; const scheduledEvents: $TSFixMe = state.subProjectScheduledEventList.scheduledEvents.map( @@ -887,11 +889,11 @@ export default function scheduledEvent( }; case CREATE_SCHEDULED_EVENT_NOTE_SUCCESS: { - let scheduledEventInternalList = { + let scheduledEventInternalList: $TSFixMe = { ...state.scheduledEventInternalList, }; - let existingPayload = false; + let existingPayload: $TSFixMe = false; scheduledEventInternalList.scheduledEventNotes.map(note => { if (String(note._id) === String(action.payload._id)) { existingPayload = true; diff --git a/Dashboard/src/Reducers/statusPage.ts b/Dashboard/src/Reducers/statusPage.ts index f03333044e..2b4094f2a8 100755 --- a/Dashboard/src/Reducers/statusPage.ts +++ b/Dashboard/src/Reducers/statusPage.ts @@ -1209,14 +1209,16 @@ export default function statusPage( }); case UPDATE_STATUSPAGE_SUCCESS: { - const monitors = action.payload.monitors.map((mon: $TSFixMe) => { - return { - ...mon, - _id: mon._id, - monitor: mon.monitor._id, - description: mon.description, - }; - }); + const monitors: $TSFixMe = action.payload.monitors.map( + (mon: $TSFixMe) => { + return { + ...mon, + _id: mon._id, + monitor: mon.monitor._id, + description: mon.description, + }; + } + ); const monitorNames: $TSFixMe = action.payload.monitors.map( ({ monitor }: $TSFixMe) => monitor.name ); diff --git a/Dashboard/src/Utils/ErrorEventUtil.ts b/Dashboard/src/Utils/ErrorEventUtil.ts index 76b95b3f08..fdb9aa2df2 100644 --- a/Dashboard/src/Utils/ErrorEventUtil.ts +++ b/Dashboard/src/Utils/ErrorEventUtil.ts @@ -1,6 +1,6 @@ const _this: $TSFixMe = { getExceptionColor: function (type: $TSFixMe): void { - let indicator = '#ff0000'; + let indicator: $TSFixMe = '#ff0000'; if (type === 'exception') { indicator = '#ffa500'; } @@ -14,7 +14,11 @@ const _this: $TSFixMe = { if (!unformattedFilters) { return option; } - for (let index = 0; index < unformattedFilters.length; index++) { + for ( + let index: $TSFixMe = 0; + index < unformattedFilters.length; + index++ + ) { const element: $TSFixMe = unformattedFilters[index]; switch (element.value) { case 'is:resolved': diff --git a/Dashboard/src/Utils/formatNumber.ts b/Dashboard/src/Utils/formatNumber.ts index 08a7bde827..c9e3323bea 100644 --- a/Dashboard/src/Utils/formatNumber.ts +++ b/Dashboard/src/Utils/formatNumber.ts @@ -4,8 +4,8 @@ const format: Function = (number: $TSFixMe): void => { if (!isNumber(number)) { return null; } - let formattedValue = ''; - let index = 0; + let formattedValue: $TSFixMe = ''; + let index: $TSFixMe = 0; const formats: $TSFixMe = [ { index: 'T', value: 1e12 }, { index: 'B', value: 1e9 }, @@ -20,11 +20,11 @@ const format: Function = (number: $TSFixMe): void => { while (formattedValue === '' && formats[index]) { const currentFormat: $TSFixMe = formats[index]; - let val = (number / currentFormat.value).toFixed(2); + let val: $TSFixMe = (number / currentFormat.value).toFixed(2); const remainder: $TSFixMe = number % currentFormat.value; const isValueLessThanOne: $TSFixMe = val < 1; - let formattedRemainder = ''; + let formattedRemainder: $TSFixMe = ''; if (!isValueLessThanOne) { // this is a success we try to format the value and the remainder diff --git a/Dashboard/src/Utils/getParentRoute.ts b/Dashboard/src/Utils/getParentRoute.ts index 4131a83182..de36029c35 100644 --- a/Dashboard/src/Utils/getParentRoute.ts +++ b/Dashboard/src/Utils/getParentRoute.ts @@ -118,7 +118,7 @@ function getParentRoute( const urlParts: $TSFixMe = childRoute.split('/'); urlParts.pop(); urlParts.pop(); - let url = ''; + let url: $TSFixMe = ''; childRoute.includes('events') ? (url = urlParts.join('/')) : (url = urlParts.join('/').concat('/error-tracker')); diff --git a/Dashboard/src/Utils/isMainProjectViewer.ts b/Dashboard/src/Utils/isMainProjectViewer.ts index 0b14fac529..32c6123bbe 100644 --- a/Dashboard/src/Utils/isMainProjectViewer.ts +++ b/Dashboard/src/Utils/isMainProjectViewer.ts @@ -12,7 +12,7 @@ const isMainProjectViewer: Function = ( subProjects: $TSFixMe, currentProject: $TSFixMe ): void => { - let user = currentProject + let user: $TSFixMe = currentProject ? currentProject.users.find((user: $TSFixMe) => user.userId === userId) : null; if (user) { @@ -30,7 +30,9 @@ const isMainProjectViewer: Function = ( ) : null; if (user && user.length > 0) { - const member = user.find((user: $TSFixMe) => user.role !== 'Viewer'); + const member: $TSFixMe = user.find( + (user: $TSFixMe) => user.role !== 'Viewer' + ); if (member && member._id) { return false; } diff --git a/Dashboard/src/Utils/keybinding.ts b/Dashboard/src/Utils/keybinding.ts index 7b9f0927a1..6a88496925 100644 --- a/Dashboard/src/Utils/keybinding.ts +++ b/Dashboard/src/Utils/keybinding.ts @@ -19,7 +19,7 @@ const keyBind: Function = ( keys: $TSFixMe, resetKeys: $TSFixMe ): void => { - let shortcut = []; + let shortcut: $TSFixMe = []; // ensure the target is always body and not inside any other element (input, textarea, etc) if (route.shortcut && event.target.localName === 'body' && event.key) { shortcut = route.shortcut.split('+'); diff --git a/Dashboard/src/components/Common/countryCode.ts b/Dashboard/src/components/Common/countryCode.ts index b67fa2de0b..2cd62403f5 100644 --- a/Dashboard/src/components/Common/countryCode.ts +++ b/Dashboard/src/components/Common/countryCode.ts @@ -253,9 +253,9 @@ const codes: $TSFixMe = { export const countryCode: Function = (): void => { const invertedObject: $TSFixMe = _.invert(codes); - let keys = Object.keys(invertedObject); + let keys: $TSFixMe = Object.keys(invertedObject); keys = keys.sort(); - const data = keys.map(k: $TSFixMe => ({ label: k, value: invertedObject[k] })); + const data: $TSFixMe = keys.map(k: $TSFixMe => ({ label: k, value: invertedObject[k] })); data.unshift({ value: '', label: 'Select a country' }); return data; }; diff --git a/Dashboard/src/components/basic/RenderIfAdmin.ts b/Dashboard/src/components/basic/RenderIfAdmin.ts index 67f27498ac..abe4d0da93 100755 --- a/Dashboard/src/components/basic/RenderIfAdmin.ts +++ b/Dashboard/src/components/basic/RenderIfAdmin.ts @@ -9,7 +9,7 @@ import { RootState } from '../../store'; export const RenderIfAdmin: Function = (props: $TSFixMe): void => { const { currentProject, children }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && currentProject && diff --git a/Dashboard/src/components/basic/RenderIfMember.ts b/Dashboard/src/components/basic/RenderIfMember.ts index cc085acb31..403c1086b8 100755 --- a/Dashboard/src/components/basic/RenderIfMember.ts +++ b/Dashboard/src/components/basic/RenderIfMember.ts @@ -9,7 +9,7 @@ function RenderIfMember(props: $TSFixMe): void { const { currentProject, children, currentUserId }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && userId === currentUserId && diff --git a/Dashboard/src/components/basic/RenderIfOwner.ts b/Dashboard/src/components/basic/RenderIfOwner.ts index a9e57163e2..7ed2849dcf 100755 --- a/Dashboard/src/components/basic/RenderIfOwner.ts +++ b/Dashboard/src/components/basic/RenderIfOwner.ts @@ -8,7 +8,7 @@ import { RootState } from '../../store'; export const RenderIfOwner: Function = (props: $TSFixMe): void => { const { currentProject, children }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && currentProject && diff --git a/Dashboard/src/components/basic/RenderIfSubProjectAdmin.ts b/Dashboard/src/components/basic/RenderIfSubProjectAdmin.ts index 4ddc55cd09..5016dbe3f8 100755 --- a/Dashboard/src/components/basic/RenderIfSubProjectAdmin.ts +++ b/Dashboard/src/components/basic/RenderIfSubProjectAdmin.ts @@ -10,7 +10,7 @@ export const RenderIfSubProjectAdmin: Function = (props: $TSFixMe): void => { const { children, currentProject, subProjects, subProjectId }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && currentProject && diff --git a/Dashboard/src/components/basic/RenderIfSubProjectMember.ts b/Dashboard/src/components/basic/RenderIfSubProjectMember.ts index db405b1c76..055a04e986 100755 --- a/Dashboard/src/components/basic/RenderIfSubProjectMember.ts +++ b/Dashboard/src/components/basic/RenderIfSubProjectMember.ts @@ -10,7 +10,7 @@ function RenderIfSubProjectMember(props: $TSFixMe): void { props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && userId === currentUserId && diff --git a/Dashboard/src/components/basic/RenderIfSubProjectOwner.ts b/Dashboard/src/components/basic/RenderIfSubProjectOwner.ts index 4b5d9a0ab7..2dcdd328e8 100755 --- a/Dashboard/src/components/basic/RenderIfSubProjectOwner.ts +++ b/Dashboard/src/components/basic/RenderIfSubProjectOwner.ts @@ -8,7 +8,7 @@ import { RootState } from '../../store'; export const RenderIfSubProjectOwner: Function = (props: $TSFixMe): void => { const { currentProject, subProjects, children }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && currentProject && diff --git a/Dashboard/src/components/basic/RenderIfUserInSubProject.ts b/Dashboard/src/components/basic/RenderIfUserInSubProject.ts index 2e067be651..bff8ab3e8d 100755 --- a/Dashboard/src/components/basic/RenderIfUserInSubProject.ts +++ b/Dashboard/src/components/basic/RenderIfUserInSubProject.ts @@ -9,7 +9,7 @@ export const RenderIfUserInSubProject: Function = (props: $TSFixMe): void => { const { children, currentProject, subProjectId, subProjects }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( currentProject && currentProject.users.filter( diff --git a/Dashboard/src/components/basic/RenderIfViewer.ts b/Dashboard/src/components/basic/RenderIfViewer.ts index 3c05261c9a..e206d94906 100644 --- a/Dashboard/src/components/basic/RenderIfViewer.ts +++ b/Dashboard/src/components/basic/RenderIfViewer.ts @@ -4,7 +4,7 @@ import { RootState } from '../../store'; export const RenderIfViewer: Function = (props: $TSFixMe): void => { const { currentProject, children }: $TSFixMe = props; const userId: $TSFixMe = User.getUserId(); - let renderItems = null; + let renderItems: $TSFixMe = null; if ( userId && currentProject && diff --git a/Dashboard/src/useNotification.ts b/Dashboard/src/useNotification.ts index bef5138f94..edddff8055 100644 --- a/Dashboard/src/useNotification.ts +++ b/Dashboard/src/useNotification.ts @@ -32,7 +32,7 @@ function urlBase64ToUint8Array(base64String: $TSFixMe): void { const rawData: $TSFixMe = window.atob(base64); const outputArray: $TSFixMe = new Uint8Array(rawData.length); - for (let i = 0; i < rawData.length; ++i) { + for (let i: $TSFixMe = 0; i < rawData.length; ++i) { outputArray[i] = rawData.charCodeAt(i); } return outputArray; diff --git a/DataIngestor/middlewares/probeAuthorization.ts b/DataIngestor/middlewares/probeAuthorization.ts index 63c80ce22a..567d1d7ce6 100755 --- a/DataIngestor/middlewares/probeAuthorization.ts +++ b/DataIngestor/middlewares/probeAuthorization.ts @@ -88,7 +88,7 @@ export default { probeVersion = req.body.probeVersion; } - let probeId = null; + let probeId: $TSFixMe = null; if (clusterKey && clusterKey === CLUSTER_KEY) { // if cluster key matches then just query by probe name, diff --git a/DataIngestor/services/automatedScriptService.ts b/DataIngestor/services/automatedScriptService.ts index 3669552d4d..f8d153db30 100644 --- a/DataIngestor/services/automatedScriptService.ts +++ b/DataIngestor/services/automatedScriptService.ts @@ -109,8 +109,8 @@ export default { if (stackSize > 2) { return; } - const events = Array.isArray(resources) ? resources : [resources]; // object property => {callSchedule?, automatedScript?} - const eventPromises = events.map(event: $TSFixMe => { + const events: $TSFixMe = Array.isArray(resources) ? resources : [resources]; // object property => {callSchedule?, automatedScript?} + const eventPromises: $TSFixMe = events.map(event: $TSFixMe => { let resourceType; if (event.automatedScript) { resourceType = 'automatedScript'; @@ -144,7 +144,7 @@ export default { await this.findOneBy({ _id: ObjectId(automatedScriptId), }); - let data = null; + let data: $TSFixMe = null; if (scriptType === 'JavaScript') { const result: $TSFixMe = await BackendAPI.post( `${scriptBaseUrl}/script/js`, diff --git a/DataIngestor/services/incidentTimelineService.ts b/DataIngestor/services/incidentTimelineService.ts index 469014bc78..cf9205e6c5 100644 --- a/DataIngestor/services/incidentTimelineService.ts +++ b/DataIngestor/services/incidentTimelineService.ts @@ -14,7 +14,7 @@ const realtimeBaseUrl: string = `${realtimeUrl}/realtime`; export default { create: async function (data: $TSFixMe): void { - let incidentTimeline = {}; + let incidentTimeline: $TSFixMe = {}; incidentTimeline.incidentId = data.incidentId; if (data.createdById) { diff --git a/DataIngestor/services/monitorLogService.ts b/DataIngestor/services/monitorLogService.ts index 4293117552..f0414b4e37 100644 --- a/DataIngestor/services/monitorLogService.ts +++ b/DataIngestor/services/monitorLogService.ts @@ -18,7 +18,7 @@ const realtimeBaseUrl: string = `${realtimeUrl}/realtime`; export default { create: async function (data: $TSFixMe): void { const Log: $TSFixMe = {}; - let responseBody = ''; + let responseBody: $TSFixMe = ''; if (data.resp && data.resp.body) { if (typeof data.resp.body === 'object') { responseBody = JSON.stringify(data.resp.body); diff --git a/DataIngestor/services/probeService.ts b/DataIngestor/services/probeService.ts index ce62690371..1ee6ac0202 100755 --- a/DataIngestor/services/probeService.ts +++ b/DataIngestor/services/probeService.ts @@ -205,7 +205,7 @@ export default { }, }); - const incidentIds = incidents.map(incident: $TSFixMe => incident._id); + const incidentIds: $TSFixMe = incidents.map(incident: $TSFixMe => incident._id); if (incidentIds && incidentIds.length) { log = await MonitorLogService.updateOneBy( @@ -242,8 +242,8 @@ export default { }), ]); const { matchedCriterion }: $TSFixMe = data; - let incidentIds = []; - let scripts = []; + let incidentIds: $TSFixMe = []; + let scripts: $TSFixMe = []; if ( matchedCriterion && @@ -267,7 +267,7 @@ export default { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -347,7 +347,7 @@ export default { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -426,7 +426,7 @@ export default { const internalIncidents: $TSFixMe = []; for (let incident of incidents) { if (monitor.type !== 'incomingHttpRequest') { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -522,7 +522,7 @@ export default { let autoAcknowledge, autoResolve; if (incidents && incidents.length > 0) { incidents.forEach(incident => { - let criteriaId = null; + let criteriaId: $TSFixMe = null; if ( incident && incident.criterionCause && @@ -582,7 +582,7 @@ export default { incident.probes.length > 0 && monitor.type !== 'incomingHttpRequest' ) { - const initialProbes = incident.probes.map(probe: $TSFixMe => ({ + const initialProbes: $TSFixMe = incident.probes.map(probe: $TSFixMe => ({ probeId: probe.probeId._id || probe.probeId, updatedAt: probe.updatedAt, status: probe.status, @@ -692,11 +692,11 @@ export default { const failedReasons: $TSFixMe = []; - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (con && con.length) { eventOccurred = con.some(condition => { - let stat = true; + let stat: $TSFixMe = true; if ( condition && condition.criteria && @@ -763,12 +763,12 @@ export default { const failedReasons: $TSFixMe = []; - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (con && con.length) { for (const condition of con) { - let stat = true; + let stat: $TSFixMe = true; if ( condition && condition.criteria && @@ -839,12 +839,12 @@ export default { }, incomingCondition: (payload, conditions) => { - let eventOccurred = false; + let eventOccurred: $TSFixMe = false; let matchedCriterion; if (conditions && conditions.length) { eventOccurred = some(conditions, condition => { - let response = false; - let respAnd = false, + let response: $TSFixMe = false; + let respAnd: $TSFixMe = false, respOr = false, countAnd = 0, countOr = 0; @@ -927,8 +927,8 @@ export default { ), ]) : false; - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; let tempReason: string = `${payload} min`; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); @@ -1017,11 +1017,11 @@ export default { import _ from 'lodash'; const incomingCheckAnd: Function = (payload, condition): void => { - let validity = false; - let val = 0; - let incomingVal = 0; + let validity: $TSFixMe = false; + let val: $TSFixMe = 0; + let incomingVal: $TSFixMe = 0; if (condition && condition.criteria && condition.criteria.length > 0) { - for (let i = 0; i < condition.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < condition.criteria.length; i++) { if ( condition.criteria[i].criteria && condition.criteria[i].criteria.length > 0 @@ -1167,11 +1167,11 @@ const incomingCheckAnd: Function = (payload, condition): void => { }; const incomingCheckOr: Function = (payload, condition): void => { - let validity = false; - let val = 0; - let incomingVal = 0; + let validity: $TSFixMe = false; + let val: $TSFixMe = 0; + let incomingVal: $TSFixMe = 0; if (condition && condition.criteria && condition.criteria.length > 0) { - for (let i = 0; i < condition.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < condition.criteria.length; i++) { if ( condition.criteria[i].criteria && condition.criteria[i].criteria.length > 0 @@ -1338,9 +1338,9 @@ const checkAnd: Function = ( headers ): void => { - let validity = true; + let validity: $TSFixMe = true; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -1398,8 +1398,8 @@ const checkAnd: Function = ( con.criteria[i].responseType && con.criteria[i].responseType === 'incomingTime' ) { - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); timeMinutes = Math.floor(timeMinutes % 60); @@ -3702,9 +3702,9 @@ const checkOr: Function = ( headers ): void => { - let validity = false; + let validity: $TSFixMe = false; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -3759,8 +3759,8 @@ const checkOr: Function = ( con.criteria[i].responseType && con.criteria[i].responseType === 'incomingTime' ) { - let timeHours = 0; - let timeMinutes = payload; + let timeHours: $TSFixMe = 0; + let timeMinutes: $TSFixMe = payload; if (timeMinutes > 60) { timeHours = Math.floor(timeMinutes / 60); timeMinutes = Math.floor(timeMinutes % 60); @@ -6034,9 +6034,9 @@ const checkScriptAnd: Function = ( successReasons, failedReasons ): void => { - let valid = true; + let valid: $TSFixMe = true; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -6094,9 +6094,9 @@ const checkScriptOr: Function = ( successReasons, failedReasons ): void => { - let valid = false; + let valid: $TSFixMe = false; if (con && con.criteria && con.criteria.length > 0) { - for (let i = 0; i < con.criteria.length; i++) { + for (let i: $TSFixMe = 0; i < con.criteria.length; i++) { if ( con.criteria[i].criteria && con.criteria[i].criteria.length > 0 @@ -6190,7 +6190,7 @@ const formatDecimal: Function = (value, decimalPlaces, roundType): void => { }; const formatBytes: Function = (a, b, c, d, e): void => { - let value = a; + let value: $TSFixMe = a; let decimalPlaces; let roundType; if (typeof a === 'object') { diff --git a/Home/index.ts b/Home/index.ts index 78424f9e77..731274c6f9 100755 --- a/Home/index.ts +++ b/Home/index.ts @@ -185,7 +185,7 @@ app.get( } try { - const subscriptions = await axios({ + const subscriptions: $TSFixMe = await axios({ method: 'GET', url: `${apiHost}/subscriber/monitorList/${subscriberId}`, }); @@ -707,7 +707,9 @@ app.get( ); app.get('/table/:product', (req: ExpressRequest, res: ExpressResponse) => { - const productConfig = productCompare(req.params['product'] as string); + const productConfig: $TSFixMe = productCompare( + req.params['product'] as string + ); if (!productConfig) { res.status(404); @@ -732,7 +734,9 @@ app.get('/table/:product', (req: ExpressRequest, res: ExpressResponse) => { }); app.get('/compare/:product', (req: ExpressRequest, res: ExpressResponse) => { - const productConfig = productCompare(req.params['product'] as string); + const productConfig: $TSFixMe = productCompare( + req.params['product'] as string + ); if (!productConfig) { res.status(404); @@ -807,7 +811,7 @@ app.get( // generate sitemap app.get('/sitemap.xml', async (_req: ExpressRequest, res: ExpressResponse) => { - const siteUrls = [ + const siteUrls: $TSFixMe = [ 'https://oneuptime.com/', 'https://oneuptime.com/pricing', 'https://oneuptime.com/support', @@ -860,7 +864,7 @@ app.get('/sitemap.xml', async (_req: ExpressRequest, res: ExpressResponse) => { ]; // build xml - const urlsetAttr = [ + const urlsetAttr: $TSFixMe = [ { xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9' }, { 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance' }, { @@ -870,12 +874,12 @@ app.get('/sitemap.xml', async (_req: ExpressRequest, res: ExpressResponse) => { ]; // get previous day's date/timestamp - const today = new Date(); + const today: $TSFixMe = new Date(); today.setDate(today.getDate() - 1); - const timestamp = today.toISOString(); + const timestamp: $TSFixMe = today.toISOString(); - const urlset = builder.create().ele('urlset'); + const urlset: $TSFixMe = builder.create().ele('urlset'); // apply attributes to root element urlsetAttr.forEach(attr => { @@ -884,13 +888,13 @@ app.get('/sitemap.xml', async (_req: ExpressRequest, res: ExpressResponse) => { //append urls to root element siteUrls.forEach(url => { - const urlElement = urlset.ele('url'); + const urlElement: $TSFixMe = urlset.ele('url'); urlElement.ele('loc').txt(url); urlElement.ele('lastmod').txt(timestamp); }); // generate xml file - const xml = urlset.end({ prettyPrint: true }); + const xml: $TSFixMe = urlset.end({ prettyPrint: true }); res.setHeader('Content-Type', 'text/xml'); res.send(xml); diff --git a/InitScript/index.ts b/InitScript/index.ts index 42a840044e..75dc26f361 100644 --- a/InitScript/index.ts +++ b/InitScript/index.ts @@ -89,7 +89,7 @@ async function run(): void { ); // Switched to for loop, forEach does not await the callback - for (let i = 0; i < files.length; i++) { + for (let i: $TSFixMe = 0; i < files.length; i++) { const file: $TSFixMe = files[i]; logger.info(file + ': Running script.'); diff --git a/InitScript/scripts/3.0.1979.ts b/InitScript/scripts/3.0.1979.ts index 321176b9a4..ded023a6af 100644 --- a/InitScript/scripts/3.0.1979.ts +++ b/InitScript/scripts/3.0.1979.ts @@ -7,7 +7,7 @@ const monitorCollection: string = 'monitors'; async function run(): void { const projects: $TSFixMe = await find(projectCollection, {}); - for (let i = 0; i < projects.length; i++) { + for (let i: $TSFixMe = 0; i < projects.length; i++) { const project: $TSFixMe = projects[i]; // Find monitors without a component const monitors: $TSFixMe = await find(monitorCollection, { @@ -15,7 +15,7 @@ async function run(): void { componentId: undefined, }); - for (let i = 0; i < monitors.length; i++) { + for (let i: $TSFixMe = 0; i < monitors.length; i++) { const { _id, name }: $TSFixMe = monitors[i]; // Create a component for this monitor const { ops = [{}] }: $TSFixMe = await save(componentCollection, [ diff --git a/InitScript/scripts/3.0.2470.ts b/InitScript/scripts/3.0.2470.ts index 78bc0235d3..61e21d6a5c 100644 --- a/InitScript/scripts/3.0.2470.ts +++ b/InitScript/scripts/3.0.2470.ts @@ -10,7 +10,7 @@ async function run(): void { domain: { $type: 'string' }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; const token: string = `oneuptime=${randomChar()}`; const now: $TSFixMe = new Date().toISOString(); diff --git a/InitScript/scripts/3.0.3061.ts b/InitScript/scripts/3.0.3061.ts index 568611ed8b..0f9f83be67 100644 --- a/InitScript/scripts/3.0.3061.ts +++ b/InitScript/scripts/3.0.3061.ts @@ -6,10 +6,10 @@ async function run(): void { const statusPages: $TSFixMe = await find(statusPageCollection, { monitorIds: { $exists: true }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; const monitors: $TSFixMe = []; - for (let j = 0; j < statusPage.monitorIds.length; j++) { + for (let j: $TSFixMe = 0; j < statusPage.monitorIds.length; j++) { monitors.push({ monitor: statusPage.monitorIds[j], description: '', diff --git a/InitScript/scripts/3.0.4342.ts b/InitScript/scripts/3.0.4342.ts index a438c1142b..56219aceb5 100644 --- a/InitScript/scripts/3.0.4342.ts +++ b/InitScript/scripts/3.0.4342.ts @@ -9,7 +9,7 @@ async function run(): void { const monitors: $TSFixMe = await find(monitorCollection, { pollTime: { $type: 'date' }, }); - for (let i = 0; i < monitors.length; i++) { + for (let i: $TSFixMe = 0; i < monitors.length; i++) { const monitor: $TSFixMe = monitors[i]; await update(monitorCollection, { _id: monitor._id }, { pollTime: [] }); } @@ -34,7 +34,7 @@ async function run(): void { .find(query) .sort('createdAt', 1) .toArray(); - for (let i = 0; i < incidents.length; i++) { + for (let i: $TSFixMe = 0; i < incidents.length; i++) { await update( incidentsCollection, { _id: incidents[i]._id }, diff --git a/InitScript/scripts/3.0.7311.ts b/InitScript/scripts/3.0.7311.ts index bd97bdd745..053f466b71 100644 --- a/InitScript/scripts/3.0.7311.ts +++ b/InitScript/scripts/3.0.7311.ts @@ -9,7 +9,7 @@ async function run(): void { statusBubbleId: { $exists: false }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; const statusBubbleId: $TSFixMe = uuid.v4(); await update( diff --git a/InitScript/scripts/3.0.8310.ts b/InitScript/scripts/3.0.8310.ts index 15d76411f1..e0bf96ec33 100644 --- a/InitScript/scripts/3.0.8310.ts +++ b/InitScript/scripts/3.0.8310.ts @@ -7,7 +7,7 @@ async function run(): void { theme: { $exists: false }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; await update( statusPageCollection, diff --git a/InitScript/scripts/3.0.8390.ts b/InitScript/scripts/3.0.8390.ts index 360eae642d..3105bb0c1f 100644 --- a/InitScript/scripts/3.0.8390.ts +++ b/InitScript/scripts/3.0.8390.ts @@ -7,7 +7,7 @@ async function run(): void { pushReminders: { $exists: false }, }); - for (let i = 0; i < escalations.length; i++) { + for (let i: $TSFixMe = 0; i < escalations.length; i++) { const escalation: $TSFixMe = escalations[i]; await update( escalationsCollection, diff --git a/InitScript/scripts/3.0.8395.ts b/InitScript/scripts/3.0.8395.ts index 5df7b60ee7..df1a1307c6 100644 --- a/InitScript/scripts/3.0.8395.ts +++ b/InitScript/scripts/3.0.8395.ts @@ -7,7 +7,7 @@ async function run(): void { hideUptime: { $exists: false }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; await update( statusPageCollection, diff --git a/InitScript/scripts/3.0.8396.ts b/InitScript/scripts/3.0.8396.ts index df2f05d926..81aa0e9775 100644 --- a/InitScript/scripts/3.0.8396.ts +++ b/InitScript/scripts/3.0.8396.ts @@ -7,7 +7,7 @@ async function run(): void { hideResolvedIncident: { $exists: false }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; await update( statusPageCollection, diff --git a/InitScript/scripts/3.0.8397.ts b/InitScript/scripts/3.0.8397.ts index a0eef43c53..deff8ab233 100644 --- a/InitScript/scripts/3.0.8397.ts +++ b/InitScript/scripts/3.0.8397.ts @@ -7,7 +7,7 @@ async function run(): void { hideIncident: { $exists: false }, }); - for (let i = 0; i < incidents.length; i++) { + for (let i: $TSFixMe = 0; i < incidents.length; i++) { const incident: $TSFixMe = incidents[i]; await update( incidentsCollection, diff --git a/InitScript/scripts/3.0.8400.ts b/InitScript/scripts/3.0.8400.ts index cd829dc306..b73f9dbb59 100644 --- a/InitScript/scripts/3.0.8400.ts +++ b/InitScript/scripts/3.0.8400.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < monitors.length; i++) { + for (let i: $TSFixMe = 0; i < monitors.length; i++) { const { name }: $TSFixMe = monitors[i]; monitors[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8500.ts b/InitScript/scripts/3.0.8500.ts index 8a75b5d6ca..e2e32f6510 100644 --- a/InitScript/scripts/3.0.8500.ts +++ b/InitScript/scripts/3.0.8500.ts @@ -12,7 +12,7 @@ async function run(): void { ], } ); - for (let i = 0; i < applicationSecurities.length; i++) { + for (let i: $TSFixMe = 0; i < applicationSecurities.length; i++) { const { name }: $TSFixMe = applicationSecurities[i]; applicationSecurities[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8600.ts b/InitScript/scripts/3.0.8600.ts index bf0e2e9c2e..036200acab 100644 --- a/InitScript/scripts/3.0.8600.ts +++ b/InitScript/scripts/3.0.8600.ts @@ -12,7 +12,7 @@ async function run(): void { ], } ); - for (let i = 0; i < containerSecurities.length; i++) { + for (let i: $TSFixMe = 0; i < containerSecurities.length; i++) { const { name }: $TSFixMe = containerSecurities[i]; containerSecurities[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8700.ts b/InitScript/scripts/3.0.8700.ts index 60ec324653..fd2702e3ac 100644 --- a/InitScript/scripts/3.0.8700.ts +++ b/InitScript/scripts/3.0.8700.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < logContainers.length; i++) { + for (let i: $TSFixMe = 0; i < logContainers.length; i++) { const { name }: $TSFixMe = logContainers[i]; logContainers[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8800.ts b/InitScript/scripts/3.0.8800.ts index ee24969841..74ef093a2c 100644 --- a/InitScript/scripts/3.0.8800.ts +++ b/InitScript/scripts/3.0.8800.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < errorTrackers.length; i++) { + for (let i: $TSFixMe = 0; i < errorTrackers.length; i++) { const { name }: $TSFixMe = errorTrackers[i]; errorTrackers[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8900.ts b/InitScript/scripts/3.0.8900.ts index 69f52022bc..6f67003030 100644 --- a/InitScript/scripts/3.0.8900.ts +++ b/InitScript/scripts/3.0.8900.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < components.length; i++) { + for (let i: $TSFixMe = 0; i < components.length; i++) { const { name }: $TSFixMe = components[i]; components[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.8910.ts b/InitScript/scripts/3.0.8910.ts index b4bc5703ed..e65a403679 100644 --- a/InitScript/scripts/3.0.8910.ts +++ b/InitScript/scripts/3.0.8910.ts @@ -11,12 +11,14 @@ async function run(): void { }); for (const statusPage of statusPages) { - const domains = statusPage.domains.map((eachDomain: $TSFixMe) => { - if (eachDomain.cert && eachDomain.privateKey) { - eachDomain.enableHttps = true; + const domains: $TSFixMe = statusPage.domains.map( + (eachDomain: $TSFixMe) => { + if (eachDomain.cert && eachDomain.privateKey) { + eachDomain.enableHttps = true; + } + return eachDomain; } - return eachDomain; - }); + ); await update( statusPageCollection, { _id: statusPage._id }, diff --git a/InitScript/scripts/3.0.9000.ts b/InitScript/scripts/3.0.9000.ts index 1bd791a519..d4d802bc0b 100644 --- a/InitScript/scripts/3.0.9000.ts +++ b/InitScript/scripts/3.0.9000.ts @@ -7,7 +7,7 @@ async function run(): void { subscribed: { $exists: false }, }); - for (let i = 0; i < subscribers.length; i++) { + for (let i: $TSFixMe = 0; i < subscribers.length; i++) { const subscriber: $TSFixMe = subscribers[i]; await update( subscriberCollection, diff --git a/InitScript/scripts/3.0.9100.ts b/InitScript/scripts/3.0.9100.ts index ab6963bb24..26b983346e 100644 --- a/InitScript/scripts/3.0.9100.ts +++ b/InitScript/scripts/3.0.9100.ts @@ -8,7 +8,7 @@ async function run(): void { interval: { $exists: false }, }); - for (let i = 0; i < events.length; i++) { + for (let i: $TSFixMe = 0; i < events.length; i++) { const event: $TSFixMe = events[i]; await update( scheduledCollection, diff --git a/InitScript/scripts/3.0.9200.ts b/InitScript/scripts/3.0.9200.ts index ef0a64953f..663020e020 100644 --- a/InitScript/scripts/3.0.9200.ts +++ b/InitScript/scripts/3.0.9200.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const { name }: $TSFixMe = statusPages[i]; statusPages[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.9300.ts b/InitScript/scripts/3.0.9300.ts index 572e3edf2a..a36a58b294 100644 --- a/InitScript/scripts/3.0.9300.ts +++ b/InitScript/scripts/3.0.9300.ts @@ -9,7 +9,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < schedules.length; i++) { + for (let i: $TSFixMe = 0; i < schedules.length; i++) { const { name }: $TSFixMe = schedules[i]; schedules[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.9301.ts b/InitScript/scripts/3.0.9301.ts index 3ae7ffb465..2e0643ec91 100644 --- a/InitScript/scripts/3.0.9301.ts +++ b/InitScript/scripts/3.0.9301.ts @@ -10,7 +10,7 @@ async function run(): void { { slug: { $regex: /[&*+~.,\\/()|'"!:@]+/g } }, ], }); - for (let i = 0; i < items.length; i++) { + for (let i: $TSFixMe = 0; i < items.length; i++) { const { name }: $TSFixMe = items[i]; items[i].slug = getSlug(name); await update( diff --git a/InitScript/scripts/3.0.9305.ts b/InitScript/scripts/3.0.9305.ts index 500656aab9..64236714d5 100644 --- a/InitScript/scripts/3.0.9305.ts +++ b/InitScript/scripts/3.0.9305.ts @@ -5,7 +5,7 @@ async function run(): void { const items: $TSFixMe = await find(usersCollection, { email: { $regex: '[A-Z]' }, }); - for (let i = 0; i < items.length; i++) { + for (let i: $TSFixMe = 0; i < items.length; i++) { const { email }: $TSFixMe = items[i]; items[i].email = email.toLowerCase(); await update( diff --git a/InitScript/scripts/3.0.9309.ts b/InitScript/scripts/3.0.9309.ts index b586c856ed..4066d2bd97 100644 --- a/InitScript/scripts/3.0.9309.ts +++ b/InitScript/scripts/3.0.9309.ts @@ -25,7 +25,7 @@ async function run(): void { { startTime: 1 } ); - for (let i = 0; i < monitorStatuses.length; i++) { + for (let i: $TSFixMe = 0; i < monitorStatuses.length; i++) { if ( !monitorStatuses[i].endTime || monitorStatuses[i].endTime === null diff --git a/InitScript/scripts/3.0.9316.ts b/InitScript/scripts/3.0.9316.ts index c6ab5a86ff..db8c57a95f 100644 --- a/InitScript/scripts/3.0.9316.ts +++ b/InitScript/scripts/3.0.9316.ts @@ -7,7 +7,7 @@ async function run(): void { multipleNotificationTypes: { $exists: false }, }); - for (let i = 0; i < statusPages.length; i++) { + for (let i: $TSFixMe = 0; i < statusPages.length; i++) { const statusPage: $TSFixMe = statusPages[i]; await update( statusPageCollection, diff --git a/InitScript/scripts/3.0.9318.ts b/InitScript/scripts/3.0.9318.ts index 3a290e141e..2727b59d08 100644 --- a/InitScript/scripts/3.0.9318.ts +++ b/InitScript/scripts/3.0.9318.ts @@ -7,9 +7,9 @@ async function run(): void { notificationType: { $exists: false }, }); - for (let i = 0; i < subscribers.length; i++) { + for (let i: $TSFixMe = 0; i < subscribers.length; i++) { const subscriber: $TSFixMe = subscribers[i]; - let notificationType = null; + let notificationType: $TSFixMe = null; if (subscriber.statusPageId) { notificationType = { announcement: false, diff --git a/InitScript/scripts/3.0.9323.ts b/InitScript/scripts/3.0.9323.ts index 474186758b..6734450008 100644 --- a/InitScript/scripts/3.0.9323.ts +++ b/InitScript/scripts/3.0.9323.ts @@ -33,10 +33,10 @@ async function run(): void { } ); - let updatedMonitors = statusPage.monitors; + let updatedMonitors: $TSFixMe = statusPage.monitors; - const monitorIds = statusPage.monitors.map((monitorObj: $TSFixMe) => - ObjectId(monitorObj.monitor) + const monitorIds: $TSFixMe = statusPage.monitors.map( + (monitorObj: $TSFixMe) => ObjectId(monitorObj.monitor) ); for (const resourceCategory of resourceCategories) { // fetch monitors with this category @@ -65,8 +65,8 @@ async function run(): void { } ); - let monitorIds = monitors.map((monitor: $TSFixMe) => - ObjectId(monitor._id) + let monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => ObjectId(monitor._id) ); await updateMany( monitorCollection, @@ -109,10 +109,10 @@ async function run(): void { } ); - let updatedMonitors = statusPage.monitors; + let updatedMonitors: $TSFixMe = statusPage.monitors; - const monitorIds = statusPage.monitors.map((monitorObj: $TSFixMe) => - ObjectId(monitorObj.monitor) + const monitorIds: $TSFixMe = statusPage.monitors.map( + (monitorObj: $TSFixMe) => ObjectId(monitorObj.monitor) ); for (const resourceCategory of resourceCategories) { // fetch monitors with this category @@ -131,8 +131,8 @@ async function run(): void { } ); - let monitorIds = monitors.map((monitor: $TSFixMe) => - ObjectId(monitor._id) + let monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => ObjectId(monitor._id) ); await updateMany( monitorCollection, diff --git a/InitScript/scripts/3.0.9326.ts b/InitScript/scripts/3.0.9326.ts index 661aa8f42b..789b850ba7 100644 --- a/InitScript/scripts/3.0.9326.ts +++ b/InitScript/scripts/3.0.9326.ts @@ -17,8 +17,10 @@ async function run(): void { const adminUserId: $TSFixMe = adminUser[0]?._id; for (const project of projects) { - let projectUsers = project.users; - let mainUserIds = projectUsers.map((user: $TSFixMe) => user.userId); + let projectUsers: $TSFixMe = project.users; + let mainUserIds: $TSFixMe = projectUsers.map( + (user: $TSFixMe) => user.userId + ); if (adminUserId) { if (mainUserIds.includes(adminUserId.toString())) { projectUsers = project.users?.map((user: $TSFixMe) => { diff --git a/InitScript/scripts/3.0.9368.ts b/InitScript/scripts/3.0.9368.ts index c21747412f..1c9c56ae3b 100644 --- a/InitScript/scripts/3.0.9368.ts +++ b/InitScript/scripts/3.0.9368.ts @@ -7,7 +7,9 @@ async function run(): void { deleted: false, regions: { $exists: false }, }); - const monitorIds = monitors.map((monitor: $TSFixMe) => monitor._id); + const monitorIds: $TSFixMe = monitors.map( + (monitor: $TSFixMe) => monitor._id + ); // add regions field to monitors // regions = [] diff --git a/InitScript/util/encryptDecrypt.ts b/InitScript/util/encryptDecrypt.ts index f005703cbb..e48755c9ae 100755 --- a/InitScript/util/encryptDecrypt.ts +++ b/InitScript/util/encryptDecrypt.ts @@ -12,7 +12,7 @@ export default { key, iv ); - let encoded = cipher.update(plainText, 'utf8', 'hex'); + let encoded: $TSFixMe = cipher.update(plainText, 'utf8', 'hex'); encoded += cipher.final('hex'); resolve(encoded); } catch (error) { @@ -30,7 +30,7 @@ export default { key, iv ); - let decoded = decipher.update(encText, 'hex', 'utf8'); + let decoded: $TSFixMe = decipher.update(encText, 'hex', 'utf8'); decoded += decipher.final('utf8'); resolve(decoded); } catch (error) { diff --git a/InitScript/util/getSlug.ts b/InitScript/util/getSlug.ts index 5811b097f5..91a6dc1834 100644 --- a/InitScript/util/getSlug.ts +++ b/InitScript/util/getSlug.ts @@ -7,7 +7,7 @@ export default function getSlug(name: $TSFixMe): void { return; } - let slug = slugify(name, { remove: /[&*+~.,\\/()|'"!:@]+/g }); + let slug: $TSFixMe = slugify(name, { remove: /[&*+~.,\\/()|'"!:@]+/g }); slug = `${slug}-${generate('1234567890', 8)}`; slug = slug.toLowerCase(); diff --git a/InitScript/util/randomChar.ts b/InitScript/util/randomChar.ts index e1c8365fa7..78e07b1e42 100644 --- a/InitScript/util/randomChar.ts +++ b/InitScript/util/randomChar.ts @@ -7,8 +7,8 @@ export default (num = 15): void => { const input: $TSFixMe = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; - let output = ''; - for (let i = 0; i < num; i++) { + let output: $TSFixMe = ''; + for (let i: $TSFixMe = 0; i < num; i++) { output += input.charAt(Math.floor(Math.random() * input.length)); } return output; diff --git a/JavaScriptSDK/src/cli/server-monitor/bin/index.ts b/JavaScriptSDK/src/cli/server-monitor/bin/index.ts index c56a20db63..dfbd93034c 100644 --- a/JavaScriptSDK/src/cli/server-monitor/bin/index.ts +++ b/JavaScriptSDK/src/cli/server-monitor/bin/index.ts @@ -45,7 +45,7 @@ program .parse(process.argv); /** The questions to get project id, api url, api key and monitor id. */ -const questions = [ +const questions: $TSFixMe = [ { type: 'input', name: 'projectId', @@ -84,7 +84,7 @@ const questions = [ */ const checkParams: Function = (params): void => { - const values = []; + const values: $TSFixMe = []; return new Promise(resolve => { resolve( @@ -111,7 +111,7 @@ const checkParams: Function = (params): void => { */ const getParamValue: Function = (params, name): void => { - const options = program.opts(); + const options: $TSFixMe = program.opts(); return new Promise(resolve => { if (options[name] === true || options[name] === undefined) { if (name === 'monitorId') { @@ -160,7 +160,7 @@ checkParams(questions).then(values => { break; } - const svc = new Service({ + const svc: $TSFixMe = new Service({ name: 'OneUptime Server Monitor', description: 'OneUptime Monitoring Shell', script: require('path').join(__dirname, 'server-monitor.js'), @@ -260,7 +260,7 @@ checkParams(questions).then(values => { monitorId || (data => { return new Promise(resolve => { - const question = questions.filter( + const question: $TSFixMe = questions.filter( param => param.name === 'monitorId' ); diff --git a/JavaScriptSDK/src/cli/server-monitor/lib/api.ts b/JavaScriptSDK/src/cli/server-monitor/lib/api.ts index 98fba482bc..663c92c3f2 100644 --- a/JavaScriptSDK/src/cli/server-monitor/lib/api.ts +++ b/JavaScriptSDK/src/cli/server-monitor/lib/api.ts @@ -103,7 +103,7 @@ const ping: Function = ( si.cpu(), ]) .then(data => { - const storage = + const storage: $TSFixMe = data[2] && data[2].length > 0 ? data[2].filter( partition => @@ -214,7 +214,7 @@ export default function ( return get(apiUrl, url, apiKey, (response: $TSFixMe) => { return new Promise((resolve, reject) => { - const data = response.data; + const data: $TSFixMe = response.data; if (data && data !== null) { if (id && typeof id === 'string') { @@ -281,7 +281,8 @@ export default function ( logger.error(error); } - const errorCode = typeof error === 'number' ? error : 1; + const errorCode: $TSFixMe = + typeof error === 'number' ? error : 1; process.exitCode = errorCode; return error; diff --git a/JavaScriptSDK/src/cli/server-monitor/lib/logger.ts b/JavaScriptSDK/src/cli/server-monitor/lib/logger.ts index a821433c6c..456b8b4083 100644 --- a/JavaScriptSDK/src/cli/server-monitor/lib/logger.ts +++ b/JavaScriptSDK/src/cli/server-monitor/lib/logger.ts @@ -7,7 +7,7 @@ import pino from 'pino'; /** The logger service. */ -const logger = pino({ +const logger: $TSFixMe = pino({ level: process.env.LOG_LEVEL || 'info', prettyPrint: { colorize: true, translateTime: true }, }); diff --git a/JavaScriptSDK/src/cli/server-monitor/out/scripts/linenumber.ts b/JavaScriptSDK/src/cli/server-monitor/out/scripts/linenumber.ts index 65fbf1aed6..ea837d450f 100644 --- a/JavaScriptSDK/src/cli/server-monitor/out/scripts/linenumber.ts +++ b/JavaScriptSDK/src/cli/server-monitor/out/scripts/linenumber.ts @@ -1,9 +1,9 @@ (() => { - const source = document.getElementsByClassName( + const source: $TSFixMe = document.getElementsByClassName( 'prettyprint source linenums' ); - let i = 0; - let lineNumber = 0; + let i: $TSFixMe = 0; + let lineNumber: $TSFixMe = 0; let lineId; let lines; let totalLines; diff --git a/JavaScriptSDK/src/cli/server-monitor/out/scripts/prettify/prettify.ts b/JavaScriptSDK/src/cli/server-monitor/out/scripts/prettify/prettify.ts index d3f18dbd6f..3d84c8197e 100644 --- a/JavaScriptSDK/src/cli/server-monitor/out/scripts/prettify/prettify.ts +++ b/JavaScriptSDK/src/cli/server-monitor/out/scripts/prettify/prettify.ts @@ -1,12 +1,12 @@ -const q = null; +const q: $TSFixMe = null; window.PR_SHOULD_USE_CONTINUATION = !0; (function ():void { function L(a: $TSFixMe):void { function m(a: $TSFixMe):void { - let f = a.charCodeAt(0); + let f: $TSFixMe = a.charCodeAt(0); if (f !== 92) return f; - const b = a.charAt(1); + const b: $TSFixMe = a.charAt(1); return (f = r[b]) ? f : '0' <= b && b <= '7' @@ -247,7 +247,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; d += f.length; if (c) { c = o[1]; - let j = f.indexOf(c), + let j: $TSFixMe = f.indexOf(c), k = j + c.length; o[2] && ((k = f.length - o[2].length), (j = k - c.length)); b = b.substring(5); @@ -266,9 +266,9 @@ window.PR_SHOULD_USE_CONTINUATION = !0; d < g; ++d ) { - let r = e[d], + let r: $TSFixMe = e[d], n = r[3]; - if (n) for (let k = n.length; --k >= 0; ) h[n.charAt(k)] = r; + if (n) for (let k: $TSFixMe = n.length; --k >= 0; ) h[n.charAt(k)] = r; r = r[1]; n = '' + r; p.hasOwnProperty(n) || (l.push(r), (p[n] = q)); @@ -280,7 +280,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; return e; } function u(a: $TSFixMe):void { - const m = [], + const m: $TSFixMe = [], e = []; a.tripleQuotedStrings ? m.push([ @@ -303,7 +303,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; '"\'', ]); a.verbatimStrings && e.push(['str', /^@"(?:[^"]|"")*(?:"|$)/, q]); - let h = a.hashComments; + let h: $TSFixMe = a.hashComments; h && (a.cStyleComments ? (h > 1 @@ -369,10 +369,10 @@ window.PR_SHOULD_USE_CONTINUATION = !0; case 3: case 4: if (p) { - let b = a.nodeValue, + let b: $TSFixMe = a.nodeValue, d = b.match(t); if (d) { - const c = b.substring(0, d.index); + const c: $TSFixMe = b.substring(0, d.index); a.nodeValue = c; (b = b.substring(d.index + d[0].length)) && a.parentNode.insertBefore( @@ -393,7 +393,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; var f = b(f, 1), g = a.nextSibling; f.appendChild(e); - for (let h = g; h; h = g) + for (let h: $TSFixMe = g; h; h = g) (g = h.nextSibling), f.appendChild(h); } return e; @@ -428,7 +428,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; m ); - const r = s.createElement('OL'); + const r: $TSFixMe = s.createElement('OL'); r.className = 'linenums'; for ( var n = Math.max(0, (m - 1) | 0) || 0, g = 0, z = d.length; @@ -442,8 +442,8 @@ window.PR_SHOULD_USE_CONTINUATION = !0; a.appendChild(r); } function k(a: $TSFixMe, m: $TSFixMe):void { - for (let e = m.length; --e >= 0; ) { - const h = m[e]; + for (let e: $TSFixMe = m.length; --e >= 0; ) { + const h: $TSFixMe = m[e]; A.hasOwnProperty(h) ? window.console && console.warn('cannot override language handler %s', h) @@ -502,10 +502,10 @@ window.PR_SHOULD_USE_CONTINUATION = !0; if (i.nodeType !== 1 && (j = t.substring(e, b))) { k && (j = j.replace(m, '\r')); i.nodeValue = j; - const u = i.ownerDocument, + const u: $TSFixMe = i.ownerDocument, v = u.createElement('SPAN'); v.className = d[a + 1]; - const x = i.parentNode; + const x: $TSFixMe = i.parentNode; x.replaceChild(v, i); v.appendChild(i); e < o && @@ -682,7 +682,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; ); k(x([], [['str', /^[\S\s]+/]]), ['regex']); window.prettyPrintOne = function (a: $TSFixMe, m: $TSFixMe, e: $TSFixMe):void { - const h = document.createElement('PRE'); + const h: $TSFixMe = document.createElement('PRE'); h.innerHTML = a; e && D(h, e); E({ g: m, i: e, h: h }); @@ -691,7 +691,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; window.prettyPrint = function (a: $TSFixMe):void { function m():void { for ( - let e = window.PR_SHOULD_USE_CONTINUATION + let e: $TSFixMe = window.PR_SHOULD_USE_CONTINUATION ? l.now() + 250 : Infinity; p < h.length && l.now() < e; @@ -766,7 +766,7 @@ window.PR_SHOULD_USE_CONTINUATION = !0; k < e.length; ++k ) - for (let t = 0, s = e[k].length; t < s; ++t) h.push(e[k][t]); + for (let t: $TSFixMe = 0, s = e[k].length; t < s; ++t) h.push(e[k][t]); var e = q, l = Date; l.now || diff --git a/JavaScriptSDK/src/cli/server-monitor/test/server-monitor.test.ts b/JavaScriptSDK/src/cli/server-monitor/test/server-monitor.test.ts index 8524968c18..b6f4d5c37a 100644 --- a/JavaScriptSDK/src/cli/server-monitor/test/server-monitor.test.ts +++ b/JavaScriptSDK/src/cli/server-monitor/test/server-monitor.test.ts @@ -13,14 +13,14 @@ import utils from './test-utils'; import { expect } from 'chai'; import serverMonitor from '../lib/api'; -const user = require('./test-utils').user; +const user: $TSFixMe = require('./test-utils').user; user.email = utils.generateRandomBusinessEmail(); let token, projectId: ObjectID, apiKey: string, monitorId: $TSFixMe; const badProjectId: string = 'badProjectId', badApiKey = 'badApiKey'; const invalidProjectId: string = utils.generateRandomString(); -const timeout = 5000, +const timeout: $TSFixMe = 5000, monitor = { name: 'New Monitor', type: 'server-monitor', @@ -37,7 +37,7 @@ describe('Server Monitor', function (): void { .post('/user/signup') .send(user) .end((err: $TSFixMe, res: $TSFixMe): void => { - const project = res.body.project; + const project: $TSFixMe = res.body.project; projectId = project._id; apiKey = project.apiKey; @@ -66,14 +66,14 @@ describe('Server Monitor', function (): void { }); it('Should connect when project id, api key and monitor id are provided', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId, apiKey, monitorId, }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(stopJob).to.be.an('object'); @@ -83,7 +83,7 @@ describe('Server Monitor', function (): void { }); it('Should connect when project id, custom api url, api key and monitor id are provided', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId, apiUrl: 'http://localhost:3002', apiKey, @@ -91,7 +91,7 @@ describe('Server Monitor', function (): void { }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(stopJob).to.be.an('object'); @@ -101,11 +101,11 @@ describe('Server Monitor', function (): void { }); it('Should request for monitor id when only project id and api key are provided', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId, apiKey, monitorId: (data: $TSFixMe) => { - const filteredMonitor = data.filter( + const filteredMonitor: $TSFixMe = data.filter( (monitor: $TSFixMe) => monitor._id === monitorId ); @@ -116,7 +116,7 @@ describe('Server Monitor', function (): void { }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(stopJob).to.be.an('object'); @@ -126,13 +126,13 @@ describe('Server Monitor', function (): void { }); it('Should disconnect when project id is invalid', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId: invalidProjectId, apiKey: badApiKey, }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(job).to.haveOwnProperty('message'); @@ -144,13 +144,13 @@ describe('Server Monitor', function (): void { }); it('Should disconnect when project id or api key are incorrect', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId: badProjectId, apiKey: badApiKey, }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(job).to.haveOwnProperty('message'); @@ -164,13 +164,13 @@ describe('Server Monitor', function (): void { }); it('Should disconnect when project id is correct and api key is incorrect', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId, apiKey: badApiKey, }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(job).to.haveOwnProperty('message'); @@ -184,13 +184,13 @@ describe('Server Monitor', function (): void { }); it('Should disconnect when project id is incorrect and api key is correct', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId: badProjectId, apiKey, }); monitor.start().then((job: $TSFixMe) => { - const stopJob = monitor.stop(); + const stopJob: $TSFixMe = monitor.stop(); expect(job).to.be.an('object'); expect(job).to.haveOwnProperty('message'); @@ -204,7 +204,7 @@ describe('Server Monitor', function (): void { }); it('Should disconnect when timeout provided is exceeded', (done: $TSFixMe) => { - const monitor = serverMonitor({ + const monitor: $TSFixMe = serverMonitor({ projectId, apiKey, monitorId, diff --git a/JavaScriptSDK/src/listener.ts b/JavaScriptSDK/src/listener.ts index f04bd6ec25..604a4597ec 100644 --- a/JavaScriptSDK/src/listener.ts +++ b/JavaScriptSDK/src/listener.ts @@ -112,7 +112,7 @@ class OneUptimeListener { } // set up xhr listener _setUpXhrListener(): void { - const open = window.XMLHttpRequest.prototype.open; + const open: $TSFixMe = window.XMLHttpRequest.prototype.open; function openReplacement( this: $TSFixMe, @@ -148,7 +148,7 @@ class OneUptimeListener { } // set up fetch listener _setUpFetchListener(): void { - const currentFetch = global.fetch; + const currentFetch: $TSFixMe = global.fetch; global.fetch = function (url, options): void { const obj: $TSFixMe = { @@ -179,13 +179,13 @@ class OneUptimeListener { override(Https); function override(module: $TSFixMe): void { - const original = module.request; + const original: $TSFixMe = module.request; function wrapper(this: $TSFixMe, outgoing: $TSFixMe): void { // Store a call to the original in req - const req = original.apply(this, arguments); - const log = requestDetails(outgoing); - const emit = req.emit; + const req: $TSFixMe = original.apply(this, arguments); + const log: $TSFixMe = requestDetails(outgoing); + const emit: $TSFixMe = req.emit; req.emit = function ( eventName: $TSFixMe, response: $TSFixMe @@ -222,7 +222,7 @@ class OneUptimeListener { status: '', url: '', }; - const portDetails = log.port !== '' ? `:${log.port}` : ''; + const portDetails: $TSFixMe = log.port !== '' ? `:${log.port}` : ''; const absoluteUrl: string = `${log.protocol}//${log.host}${portDetails}${log.path}`; log.url = absoluteUrl; return log; @@ -296,7 +296,7 @@ class OneUptimeListener { } _logClickEvent(event: $TSFixMe, type: $TSFixMe): void { // preepare the event tree - const content = this._getEventTree(event); + const content: $TSFixMe = this._getEventTree(event); const timelineObj: $TSFixMe = { category: `ui.${event.type}`, data: { @@ -309,15 +309,15 @@ class OneUptimeListener { this.timelineObj.addToTimeline(timelineObj); } _getEventTree(event: $TSFixMe): void { - const tree = []; + const tree: $TSFixMe = []; const MAX_UP_TREE = 5; // we just want to go up the DOM for 5 times - let current = 0; - const fullPath = []; + let current: $TSFixMe = 0; + const fullPath: $TSFixMe = []; while (current < MAX_UP_TREE && event.path[current]) { // the current element has a path and we havent got up to 5 items, and its not an html tag - const currentElem = event.path[current]; + const currentElem: $TSFixMe = event.path[current]; if (currentElem.localName !== 'html') { - let elementPath = ''; + let elementPath: $TSFixMe = ''; elementPath += `${currentElem.localName}`; // attach ID if it has @@ -325,18 +325,19 @@ class OneUptimeListener { elementPath += `${currentElem.id}`; } // for classes - let classes = []; + let classes: $TSFixMe = []; classes = currentElem.classList; // get all classes - let classesForElement = ''; + let classesForElement: $TSFixMe = ''; classes.forEach((element: $TSFixMe) => { classesForElement += `.${element}`; }); elementPath += classesForElement; // get attributes - const attributes = this._getElementAttributes(currentElem); + const attributes: $TSFixMe = + this._getElementAttributes(currentElem); if (attributes.length > 0) { - let attributesForElement = ''; + let attributesForElement: $TSFixMe = ''; attributes.forEach(element => { if (element.key !== 'id') { attributesForElement += `${element.key}=${element.value},`; @@ -362,21 +363,21 @@ class OneUptimeListener { // increate the counter current = current + 1; } - let path = fullPath.reverse(); + let path: $TSFixMe = fullPath.reverse(); path = path.join(' > '); return { tree, path }; // return the final tree which contains a max of 5 elements } _getElementAttributes(elem: $TSFixMe): void { - const attributes = []; - const elementAtrributes = elem.attributes; // get all the attritubtes related to the element - const excludedAttributes = ['class', 'value']; // exclude items that are nnot needed + const attributes: $TSFixMe = []; + const elementAtrributes: $TSFixMe = elem.attributes; // get all the attritubtes related to the element + const excludedAttributes: $TSFixMe = ['class', 'value']; // exclude items that are nnot needed for (const [, value] of Object.entries(elementAtrributes)) { if (!excludedAttributes.includes(value.name)) { // if each attribute doesnt exist in the excluded one, we get the value and make an object - const attribute = elem[value.name]; + const attribute: $TSFixMe = elem[value.name]; attributes.push({ key: value.name, value: attribute, diff --git a/JavaScriptSDK/src/listeners/incomingListener.ts b/JavaScriptSDK/src/listeners/incomingListener.ts index 2529031e34..8f5f4957d2 100644 --- a/JavaScriptSDK/src/listeners/incomingListener.ts +++ b/JavaScriptSDK/src/listeners/incomingListener.ts @@ -23,21 +23,24 @@ class IncomingListener { override(Https); function override(module): void { - const emit = module.Server.prototype.emit; + const emit: $TSFixMe = module.Server.prototype.emit; module.Server.prototype.emit = function (type, req, res): void { if (type === 'request') { - const path = req.pathname || req.path || req.url || '/'; - const method = req.method; - let finalPattern = path; + const path: $TSFixMe = + req.pathname || req.path || req.url || '/'; + const method: $TSFixMe = req.method; + let finalPattern: $TSFixMe = path; // this will only work with express application if (this.app && this.app._router) { - const routes = getRoutes(this.app); + const routes: $TSFixMe = getRoutes(this.app); for (const [key, value] of Object.entries(routes)) { if (key === String(method).toLowerCase()) { for (const val of value) { - const pattern = new UrlPattern(val); + const pattern: $TSFixMe = new UrlPattern( + val + ); if (pattern.match(path)) { // path pattern found @@ -51,7 +54,7 @@ class IncomingListener { req.apm = {}; req.apm.uuid = uuidv4(); - const result = this.start(req.apm.uuid, { + const result: $TSFixMe = this.start(req.apm.uuid, { path: finalPattern, type: 'incoming', method, @@ -64,7 +67,7 @@ class IncomingListener { res.statusCode < 600 ) { // error must have occurred - const originalValue = this.store.getValue( + const originalValue: $TSFixMe = this.store.getValue( req.apm.uuid ); if (originalValue && originalValue !== undefined) { diff --git a/JavaScriptSDK/src/listeners/mongoose.ts b/JavaScriptSDK/src/listeners/mongoose.ts index 6b8a24ef4b..1abb5766b5 100644 --- a/JavaScriptSDK/src/listeners/mongoose.ts +++ b/JavaScriptSDK/src/listeners/mongoose.ts @@ -11,16 +11,16 @@ class MongooseListener { wrapAsync(orig, name) { return async function (): void { - const uuid = uuidv4(); + const uuid: $TSFixMe = uuidv4(); - const operation = this.op; + const operation: $TSFixMe = this.op; name = name || `mongoose.${operation}`; // mongose Query.exec specific - const result = this.start(uuid, { + const result: $TSFixMe = this.start(uuid, { path: operation, type: 'mongoose', }); try { - const res = await orig.apply(this, arguments); + const res: $TSFixMe = await orig.apply(this, arguments); this.end(uuid, result, name); return res; } catch (err) { @@ -31,17 +31,17 @@ class MongooseListener { } _setUpMongooseListener(mod): void { - const proto = Object.getPrototypeOf(mod); - const exec = proto.Query.prototype.exec; + const proto: $TSFixMe = Object.getPrototypeOf(mod); + const exec: $TSFixMe = proto.Query.prototype.exec; proto.Query.prototype.exec = this.wrapAsync(exec); - const Model = proto.Model; + const Model: $TSFixMe = proto.Model; - const remove = Model.prototype.remove; + const remove: $TSFixMe = Model.prototype.remove; Model.prototype.remove = this.wrapAsync(remove, 'mongoose.remove'); - const save = Model.prototype.save; + const save: $TSFixMe = Model.prototype.save; Model.prototype.save = this.wrapAsync(save, 'mongoose.save'); return mod; diff --git a/JavaScriptSDK/src/listeners/outgoingListener.ts b/JavaScriptSDK/src/listeners/outgoingListener.ts index 9dd0e9aea6..c6804dbf7e 100644 --- a/JavaScriptSDK/src/listeners/outgoingListener.ts +++ b/JavaScriptSDK/src/listeners/outgoingListener.ts @@ -19,23 +19,23 @@ class OutgoingListener { override(Https); function override(module): void { - const original = module.request; + const original: $TSFixMe = module.request; function wrapper(outgoing): void { // Store a call to the original in req - const req = original.apply(this, arguments); + const req: $TSFixMe = original.apply(this, arguments); - const host = outgoing.host || outgoing.hostname; - const protocol = outgoing.protocol; - const path = + const host: $TSFixMe = outgoing.host || outgoing.hostname; + const protocol: $TSFixMe = outgoing.protocol; + const path: $TSFixMe = outgoing.pathname || outgoing.path || outgoing.url || '/'; - const method = outgoing.method; + const method: $TSFixMe = outgoing.method; - const emit = req.emit; + const emit: $TSFixMe = req.emit; req.apm = {}; req.apm.uuid = uuidv4(); - const result = this.start(req.apm.uuid, { + const result: $TSFixMe = this.start(req.apm.uuid, { path: `${protocol}//${host}${path}`, // store full path for outgoing requests type: 'outgoing', method, @@ -50,7 +50,7 @@ class OutgoingListener { break; } case 'error': { - const originalValue = this.store.getValue( + const originalValue: $TSFixMe = this.store.getValue( req.apm.uuid ); if (originalValue && originalValue !== undefined) { diff --git a/JavaScriptSDK/src/logger.ts b/JavaScriptSDK/src/logger.ts index e760ff52ae..964a1eaf3c 100644 --- a/JavaScriptSDK/src/logger.ts +++ b/JavaScriptSDK/src/logger.ts @@ -23,7 +23,7 @@ class Logger { } async log(data: $TSFixMe, tags = null): void { - const type = typeof data; + const type: $TSFixMe = typeof data; if (!data || !(type === 'object' || type === 'string')) { return 'Invalid Content to be logged'; @@ -39,7 +39,7 @@ class Logger { return await this._makeApiRequest(data, logType, tags); } async warning(data: $TSFixMe, tags = null): void { - const type = typeof data; + const type: $TSFixMe = typeof data; if (!data || !(type === 'object' || type === 'string')) { return 'Invalid Content to be logged'; @@ -55,7 +55,7 @@ class Logger { return await this._makeApiRequest(data, logType, tags); } async error(data: $TSFixMe, tags = null): void { - const type = typeof data; + const type: $TSFixMe = typeof data; if (!data || !(type === 'object' || type === 'string')) { return 'Invalid Content to be logged'; diff --git a/JavaScriptSDK/src/performanceTracker.ts b/JavaScriptSDK/src/performanceTracker.ts index de92ecf735..f9b689f4b2 100644 --- a/JavaScriptSDK/src/performanceTracker.ts +++ b/JavaScriptSDK/src/performanceTracker.ts @@ -35,13 +35,21 @@ class PerformanceTracker { this.nodeUse = false; } if (this.nodeUse) { - const perf = new PerfTimer(this.apiUrl, this.appId, this.appKey); + const perf: $TSFixMe = new PerfTimer( + this.apiUrl, + this.appId, + this.appKey + ); const { start, end, store } = perf; this.start = start; this.end = end; this.store = store(); // returns the store instance } else { - const hrt = new HrTimer(this.apiUrl, this.appId, this.appKey); + const hrt: $TSFixMe = new HrTimer( + this.apiUrl, + this.appId, + this.appKey + ); const { start, end, store } = hrt; this.start = start; this.end = end; @@ -72,12 +80,15 @@ class PerformanceTracker { return new OutgoingListener(this.start, this.end, this.store); } setUpDataBaseListener(): void { - const load = Module._load; + const load: $TSFixMe = Module._load; Module._load = function (request: $TSFixMe): void { - const res = load.apply(this, arguments); + const res: $TSFixMe = load.apply(this, arguments); if (request === 'mongoose') { - const mongo = new MongooseListener(this.start, this.end); + const mongo: $TSFixMe = new MongooseListener( + this.start, + this.end + ); return mongo._setUpMongooseListener(res); } return res; diff --git a/JavaScriptSDK/src/tracker.ts b/JavaScriptSDK/src/tracker.ts index 633a4fe414..1b40ccbdfb 100644 --- a/JavaScriptSDK/src/tracker.ts +++ b/JavaScriptSDK/src/tracker.ts @@ -79,7 +79,7 @@ class ErrorTracker { ) { this.options[key] = this.MAX_ITEMS_ALLOWED_IN_STACK; } else if (key === 'captureCodeSnippet') { - const isBoolean = typeof value === 'boolean'; // check if the passed value is a boolean + const isBoolean: $TSFixMe = typeof value === 'boolean'; // check if the passed value is a boolean // set boolean value if boolean or set default `true` if annything other than boolean is passed this.options[key] = isBoolean ? value : true; } else { @@ -100,7 +100,9 @@ class ErrorTracker { return 'Invalid Tags type'; } // get the index if the key exist already - const index = this.tags.findIndex((tag: $TSFixMe) => tag.key === key); + const index: $TSFixMe = this.tags.findIndex( + (tag: $TSFixMe) => tag.key === key + ); if (index !== -1) { // replace value if it exist this.tags[index].value = value; @@ -159,7 +161,7 @@ class ErrorTracker { ): void { const errorEvent: $TSFixMe = { message, file, line, col, error }; - const string = errorEvent.message + const string: $TSFixMe = errorEvent.message ? errorEvent.message.toLowerCase() : errorEvent.toLowerCase(); const substring: string = 'script error'; @@ -167,9 +169,8 @@ class ErrorTracker { return; // third party error } else { // construct the error object - const errorObj = await this.utilObj._getErrorStackTrace( - errorEvent - ); + const errorObj: $TSFixMe = + await this.utilObj._getErrorStackTrace(errorEvent); // set the a handled tag this.setTag('handled', 'false'); @@ -200,7 +201,9 @@ class ErrorTracker { } async _manageErrorNode(error: $TSFixMe): void { // construct the error object - const errorObj = await this.utilObj._getErrorStackTrace(error); + const errorObj: $TSFixMe = await this.utilObj._getErrorStackTrace( + error + ); // set the a handled tag this.setTag('handled', 'false'); @@ -233,7 +236,9 @@ class ErrorTracker { } async captureException(error: $TSFixMe): void { // construct the error object - const errorObj = await this.utilObj._getErrorStackTrace(error); + const errorObj: $TSFixMe = await this.utilObj._getErrorStackTrace( + error + ); // set the a handled tag this.setTag('handled', 'true'); @@ -261,11 +266,13 @@ class ErrorTracker { // set the host as a tag to be used later this._setHost(); // get current timeline - const timeline = this.getTimeline(); + const timeline: $TSFixMe = this.getTimeline(); // get device location and details - const deviceDetails = this.utilObj._getUserDeviceDetails(); - const tags = this._getTags(); - const fingerprint = this._getFingerprint(errorStackTrace.message); // default fingerprint will be the message from the error stacktrace + const deviceDetails: $TSFixMe = this.utilObj._getUserDeviceDetails(); + const tags: $TSFixMe = this._getTags(); + const fingerprint: $TSFixMe = this._getFingerprint( + errorStackTrace.message + ); // default fingerprint will be the message from the error stacktrace // get event ID // Temporary display the state of the error stack, timeline and device details when an error occur // prepare the event so it can be sent to the server diff --git a/JavaScriptSDK/src/util.ts b/JavaScriptSDK/src/util.ts index 3120afefe7..7f3647ca51 100644 --- a/JavaScriptSDK/src/util.ts +++ b/JavaScriptSDK/src/util.ts @@ -15,17 +15,17 @@ class Util { }; } async _getErrorStackTrace(errorEvent: $TSFixMe): void { - const frames = []; + const frames: $TSFixMe = []; // get error stack trace - const stack = errorEvent.stack + const stack: $TSFixMe = errorEvent.stack ? errorEvent.stack : errorEvent.error.stack ? errorEvent.error.stack : errorEvent.error; - const stackTrace = stack.split('\n'); // it is all a string so split into array by the enter key + const stackTrace: $TSFixMe = stack.split('\n'); // it is all a string so split into array by the enter key // the first item is always the title. - const firstStack = stackTrace[0].split(':'); // browser add a : to seperate the title from the description - let obj = { + const firstStack: $TSFixMe = stackTrace[0].split(':'); // browser add a : to seperate the title from the description + let obj: $TSFixMe = { type: firstStack[0], message: errorEvent.message ? errorEvent.message : errorEvent.error, stacktrace: null, @@ -33,19 +33,21 @@ class Util { columnNumber: errorEvent.col, }; // loop through the remaining stack to construct the remaining frame - for (let index = 1; index < stackTrace.length; index++) { - const currentFrame = stackTrace[index]; + for (let index: $TSFixMe = 1; index < stackTrace.length; index++) { + const currentFrame: $TSFixMe = stackTrace[index]; // split the string into two - const firstHalf = currentFrame.substring( + const firstHalf: $TSFixMe = currentFrame.substring( 0, currentFrame.indexOf('(') - 1 ); // first half contains the method - const methodName = firstHalf + const methodName: $TSFixMe = firstHalf .substring(firstHalf.lastIndexOf(' ')) .replace(/\s+/g, ''); // second half contains file, line number and column number - let secondHalf = currentFrame.substring(currentFrame.indexOf('(')); + let secondHalf: $TSFixMe = currentFrame.substring( + currentFrame.indexOf('(') + ); // strip away the () the first and last character secondHalf = secondHalf.substring(1); secondHalf = secondHalf.substring(0, secondHalf.length - 1); @@ -53,11 +55,11 @@ class Util { // we split the second half by : since the format is filelocation:linenumber:columnnumber secondHalf = secondHalf.split(':'); // we pick the last two as the line number and column number - const lineNumber = secondHalf[secondHalf.length - 2]; - const columnNumber = secondHalf[secondHalf.length - 1]; + const lineNumber: $TSFixMe = secondHalf[secondHalf.length - 2]; + const columnNumber: $TSFixMe = secondHalf[secondHalf.length - 1]; // then we merge the rest by the : - let fileName = ''; - let position = 0; + let fileName: $TSFixMe = ''; + let position: $TSFixMe = 0; while (position < secondHalf.length - 2) { fileName += `${secondHalf[position]}`; if (position !== secondHalf.length - 3) { @@ -90,19 +92,19 @@ class Util { _getUserDeviceDetails(): void { const deviceDetails: $TSFixMe = { device: null, browser: null }; if (typeof window !== 'undefined') { - const details = window.navigator.appVersion; + const details: $TSFixMe = window.navigator.appVersion; // get string between first parenthesis - const deviceOS = details.substring( + const deviceOS: $TSFixMe = details.substring( details.indexOf('(') + 1, details.indexOf(')') ); - const device = deviceOS.split(';'); + const device: $TSFixMe = deviceOS.split(';'); // get string after last parenthesis - const deviceBrowser = details + const deviceBrowser: $TSFixMe = details .substring(details.lastIndexOf(')') + 1) .trim() .split(' '); - const browser = deviceBrowser[0]; + const browser: $TSFixMe = deviceBrowser[0]; const browserDetails: $TSFixMe = { name: browser.substring(0, browser.indexOf('/')), version: browser.substring(browser.indexOf('/') + 1), @@ -115,14 +117,16 @@ class Util { return deviceDetails; } async _getErrorCodeSnippet(errorObj: $TSFixMe): void { - const frames = errorObj.stacktrace ? errorObj.stacktrace.frames : []; - for (let i = 0; i < frames.length; i++) { - let fileName = frames[i].fileName; + const frames: $TSFixMe = errorObj.stacktrace + ? errorObj.stacktrace.frames + : []; + for (let i: $TSFixMe = 0; i < frames.length; i++) { + let fileName: $TSFixMe = frames[i].fileName; // check what it starts with fileName = this._formatFileName(fileName); // try to get the file from the cache - const cache = CONTENT_CACHE.get(fileName); + const cache: $TSFixMe = CONTENT_CACHE.get(fileName); // if we get a hit for the file if (cache !== undefined) { // and the content is not null @@ -131,15 +135,22 @@ class Util { } } else { // try to read the file content and save to cache - const currentContent = await this._readFileFromSource(fileName); + const currentContent: $TSFixMe = await this._readFileFromSource( + fileName + ); if (currentContent !== null) { frames[i].sourceFile = currentContent; } } } frames.map((frame: $TSFixMe): void => { - const lines = frame.sourceFile ? frame.sourceFile.split('\n') : []; - const localFrame = this._addCodeSnippetToFrame(lines, frame); + const lines: $TSFixMe = frame.sourceFile + ? frame.sourceFile.split('\n') + : []; + const localFrame: $TSFixMe = this._addCodeSnippetToFrame( + lines, + frame + ); frame = localFrame; return frame; }); @@ -149,7 +160,7 @@ class Util { _readFileFromSource(fileName: $TSFixMe): void { return new Promise(resolve => { readFile(fileName, (err, data) => { - const content = err ? null : data.toString(); + const content: $TSFixMe = err ? null : data.toString(); CONTENT_CACHE.set(fileName, content); resolve(content); @@ -158,7 +169,7 @@ class Util { } _formatFileName(fileName: $TSFixMe): void { const fileIndicator: string = 'file://'; - let localFileName = fileName; + let localFileName: $TSFixMe = fileName; if (fileName.indexOf(fileIndicator) > -1) { // check for index of file then trim the file part by skiping it and starting with the leading / localFileName = fileName.substring( @@ -175,9 +186,12 @@ class Util { if (lines.length < 1) { return; } - const lineNumber = frame.lineNumber || 0; - const maxLines = lines.length; - const sourceLine = Math.max(Math.min(maxLines, lineNumber - 1), 0); + const lineNumber: $TSFixMe = frame.lineNumber || 0; + const maxLines: $TSFixMe = lines.length; + const sourceLine: $TSFixMe = Math.max( + Math.min(maxLines, lineNumber - 1), + 0 + ); // attach the line before the error frame.linesBeforeError = lines.slice( Math.max(0, sourceLine - linesOfContext), diff --git a/JavaScriptSDK/src/utils/dataStore.ts b/JavaScriptSDK/src/utils/dataStore.ts index 2fbe2bedaf..c35b7f19cd 100644 --- a/JavaScriptSDK/src/utils/dataStore.ts +++ b/JavaScriptSDK/src/utils/dataStore.ts @@ -34,11 +34,11 @@ class DataStore { errorCount: $TSFixMe ): void { if (store.has(path)) { - const s = store.get(path); - const avg = s.avgTime, + const s: $TSFixMe = store.get(path); + const avg: $TSFixMe = s.avgTime, rq = s.requests, ct = time; - let avgTime = avg * rq + ct; + let avgTime: $TSFixMe = avg * rq + ct; avgTime = avgTime / (rq + 1); return { requests: s.requests + 1, @@ -84,12 +84,12 @@ class DataStore { return {}; } setData(value: $TSFixMe): void { - const type = value.type; - const path = value.path; - const time = value.duration; - const method = value.method; - const errorCount = value.errorCount || 0; - let val = {}; + const type: $TSFixMe = value.type; + const path: $TSFixMe = value.path; + const time: $TSFixMe = value.duration; + const method: $TSFixMe = value.method; + const errorCount: $TSFixMe = value.errorCount || 0; + let val: $TSFixMe = {}; if (type === 'incoming') { val = this.mapValue(path, this.incoming, time, method, errorCount); return this.incoming.set(path, val); diff --git a/JavaScriptSDK/src/utils/hrTimer.ts b/JavaScriptSDK/src/utils/hrTimer.ts index a59431a52f..dae8899666 100644 --- a/JavaScriptSDK/src/utils/hrTimer.ts +++ b/JavaScriptSDK/src/utils/hrTimer.ts @@ -17,10 +17,10 @@ class HrTimer { }; end = (id: $TSFixMe, startHrTime: $TSFixMe): void => { - let elapsedHrTime = process.hrtime(startHrTime); + let elapsedHrTime: $TSFixMe = process.hrtime(startHrTime); elapsedHrTime = elapsedHrTime[0] * 1000 + elapsedHrTime[1] / 1e6; - const originalValue = this.dataStore.getValue(id); + const originalValue: $TSFixMe = this.dataStore.getValue(id); if (originalValue && originalValue !== undefined) { originalValue.duration = elapsedHrTime; diff --git a/JavaScriptSDK/src/utils/perfTimer.ts b/JavaScriptSDK/src/utils/perfTimer.ts index 8ecf87ce09..7d059566e7 100644 --- a/JavaScriptSDK/src/utils/perfTimer.ts +++ b/JavaScriptSDK/src/utils/perfTimer.ts @@ -12,9 +12,9 @@ class PerfTimer { this.appKey = appKey; this.dataStore = new DataStore(this.apiUrl, this.appId, this.appKey); this.obs = new PerformanceObserver(list => { - const entry = list.getEntries()[0]; - const id = entry.name.slice(entry.name.indexOf('-') + 1); - const originalValue = this.dataStore.getValue(id); + const entry: $TSFixMe = list.getEntries()[0]; + const id: $TSFixMe = entry.name.slice(entry.name.indexOf('-') + 1); + const originalValue: $TSFixMe = this.dataStore.getValue(id); if (originalValue && originalValue !== undefined) { originalValue.duration = entry.duration; this.dataStore.setData(originalValue); diff --git a/JavaScriptSDK/test/logger.test.ts b/JavaScriptSDK/test/logger.test.ts index 90109e3d24..b85ef0a775 100644 --- a/JavaScriptSDK/test/logger.test.ts +++ b/JavaScriptSDK/test/logger.test.ts @@ -3,12 +3,12 @@ import ObjectID from 'Common/Types/ObjectID'; import chaihttp from 'chai-http'; chai.use(chaihttp); -const expect = chai.expect; +const expect: $TSFixMe = chai.expect; import { user, generateRandomBusinessEmail } from './util'; const API_URL: string = 'http://localhost:3002/api'; const request: $TSFixMe = chai.request.agent(API_URL); -const timeout = 5000; +const timeout: $TSFixMe = 5000; import OneUptimeLogger from '../src/logger'; @@ -32,7 +32,7 @@ describe('OneUptimeLogger', function (): void { .post('/user/signup') .send(user) .end((err: $TSFixMe, res: $TSFixMe): void => { - const project = res.body.project; + const project: $TSFixMe = res.body.project; projectId = project._id; token = res.body.tokens.jwtAccessToken; request @@ -60,7 +60,11 @@ describe('OneUptimeLogger', function (): void { }); it('should request for application log key', (): void => { - const firstLog = new OneUptimeLogger(API_URL, applicationLog._id, ''); + const firstLog: $TSFixMe = new OneUptimeLogger( + API_URL, + applicationLog._id, + '' + ); firstLog.log('here').catch(error => { expect(error.response.status).to.equal(400); expect(error.response.data.message).to.equal( @@ -70,7 +74,7 @@ describe('OneUptimeLogger', function (): void { }); it('should request for content', (): void => { - const firstLog = new OneUptimeLogger( + const firstLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -84,7 +88,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return invalid application log', (): void => { - const firstLog = new OneUptimeLogger( + const firstLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, 'key' @@ -98,7 +102,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item of type string', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -116,7 +120,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item of type object', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -147,7 +151,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item with log type of error', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -165,7 +169,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item with log type of warning', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -183,7 +187,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item with log type of info with one tag', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -209,7 +213,7 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item with log type of warning with no tag', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key @@ -227,13 +231,13 @@ describe('OneUptimeLogger', function (): void { }); it('should return a valid logged item with log type of error with 3 tags', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key ); const logMessage: string = 'This is a simple log'; - const tags = ['auction', 'trial', 'famous']; + const tags: $TSFixMe = ['auction', 'trial', 'famous']; validLog.error(logMessage, tags).then(response => { expect(response.status).to.equal(200); @@ -254,7 +258,7 @@ describe('OneUptimeLogger', function (): void { }); it('should reject a valid logged item with log type of error with invalid tags', (): void => { - const validLog = new OneUptimeLogger( + const validLog: $TSFixMe = new OneUptimeLogger( API_URL, applicationLog._id, applicationLog.key diff --git a/JavaScriptSDK/test/tracker.test.ts b/JavaScriptSDK/test/tracker.test.ts index 757268deef..93bafff152 100644 --- a/JavaScriptSDK/test/tracker.test.ts +++ b/JavaScriptSDK/test/tracker.test.ts @@ -1,7 +1,7 @@ import chai from 'chai'; import ObjectID from 'Common/Types/ObjectID'; -const expect = chai.expect; +const expect: $TSFixMe = chai.expect; import chaihttp from 'chai-http'; chai.use(chaihttp); @@ -9,7 +9,7 @@ import { user, generateSecondRandomBusinessEmail } from './util'; const API_URL: string = 'http://localhost:3002/api'; const request: $TSFixMe = chai.request.agent(API_URL); -const timeout = 5000; +const timeout: $TSFixMe = 5000; import OneUptimeTracker from '../src/tracker'; const customTimeline: $TSFixMe = { @@ -38,7 +38,7 @@ describe('Tracker Timeline', function (): void { .post('/user/signup') .send(user) .end((err: $TSFixMe, res: $TSFixMe): void => { - const project = res.body.project; + const project: $TSFixMe = res.body.project; projectId = project._id; token = res.body.tokens.jwtAccessToken; request @@ -66,7 +66,7 @@ describe('Tracker Timeline', function (): void { }); it('should take in custom timeline event', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -76,14 +76,14 @@ describe('Tracker Timeline', function (): void { customTimeline.content, customTimeline.type ); - const timeline = tracker.getTimeline(); + const timeline: $TSFixMe = tracker.getTimeline(); expect(timeline).to.be.an('array'); expect(timeline).to.have.lengthOf(1); expect(timeline[0].category).to.equal(customTimeline.category); }); it('should ensure timeline event contains eventId and timestamp', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -93,13 +93,13 @@ describe('Tracker Timeline', function (): void { customTimeline.content, customTimeline.type ); - const timeline = tracker.getTimeline(); + const timeline: $TSFixMe = tracker.getTimeline(); expect(timeline[0].eventId).to.be.a('string'); expect(timeline[0].timestamp).to.be.a('number'); }); it('should ensure different timeline event have the same eventId', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -114,14 +114,14 @@ describe('Tracker Timeline', function (): void { customTimeline.content, 'error' ); - const timeline = tracker.getTimeline(); + const timeline: $TSFixMe = tracker.getTimeline(); expect(timeline.length).to.equal(2); // two timeline events expect(timeline[0].eventId).to.equal(timeline[1].eventId); // their eveentId is the same till there is an error sent to the server }); it('should ensure max timline cant be set as a negative number', (): void => { const options: $TSFixMe = { maxTimeline: -5 }; - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, @@ -137,13 +137,13 @@ describe('Tracker Timeline', function (): void { customTimeline.content, 'error' ); - const timeline = tracker.getTimeline(); + const timeline: $TSFixMe = tracker.getTimeline(); expect(timeline.length).to.equal(2); // two timeline events }); it('should ensure new timeline event after max timeline are discarded', (): void => { const options: $TSFixMe = { maxTimeline: 2 }; - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, @@ -172,7 +172,7 @@ describe('Tracker Timeline', function (): void { customTimeline.content, 'debug' ); - const timeline = tracker.getTimeline(); + const timeline: $TSFixMe = tracker.getTimeline(); expect(timeline.length).to.equal(options.maxTimeline); expect(timeline[0].type).to.equal(customTimeline.type); expect(timeline[1].category).to.equal(customTimeline2.category); @@ -181,14 +181,14 @@ describe('Tracker Timeline', function (): void { describe('Tags', (): void => { it('should add tags ', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const tag: $TSFixMe = { key: 'location', value: 'Atlanta' }; tracker.setTag(tag.key, tag.value); - const availableTags = tracker._getTags(); + const availableTags: $TSFixMe = tracker._getTags(); expect(availableTags).to.be.an('array'); expect(availableTags.length).to.equal(1); expect(availableTags[0]).to.have.property('key'); @@ -196,29 +196,29 @@ describe('Tags', (): void => { }); it('should add multiple tags ', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); - const tags = [ + const tags: $TSFixMe = [ { key: 'location', value: 'Atlanta' }, { key: 'city', value: 'anywhere' }, { key: 'device', value: 'iOS' }, ]; tracker.setTags(tags); - const availableTags = tracker._getTags(); + const availableTags: $TSFixMe = tracker._getTags(); expect(availableTags).to.be.an('array'); expect(availableTags.length).to.equal(3); }); it('should overwrite existing keys to avoid duplicate tags ', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); - const tags = [ + const tags: $TSFixMe = [ { key: 'location', value: 'Atlanta' }, { key: 'city', value: 'anywhere' }, { key: 'location', value: 'Paris' }, @@ -226,7 +226,7 @@ describe('Tags', (): void => { { key: 'location', value: 'London' }, ]; tracker.setTags(tags); - const availableTags = tracker._getTags(); + const availableTags: $TSFixMe = tracker._getTags(); expect(availableTags).to.be.an('array'); expect(availableTags.length).to.equal(3); // since location repeated itself multiple times expect(availableTags[0].key).to.be.equal('location'); @@ -236,34 +236,34 @@ describe('Tags', (): void => { describe('Fingerpint', (): void => { it('should create fingerprint as message for error capture without any fingerprint', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'Uncaught Exception'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.fingerprint[0]).to.equal(errorMessage); }); it('should use defined fingerprint array for error capture with fingerprint', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); - const fingerprints = ['custom', 'errors']; + const fingerprints: $TSFixMe = ['custom', 'errors']; tracker.setFingerprint(fingerprints); const errorMessage: string = 'Uncaught Exception'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.fingerprint[0]).to.equal(fingerprints[0]); expect(event.fingerprint[1]).to.equal(fingerprints[1]); }); it('should use defined fingerprint string for error capture with fingerprint', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -272,27 +272,27 @@ describe('Fingerpint', (): void => { tracker.setFingerprint(fingerprint); const errorMessage: string = 'Uncaught Exception'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.fingerprint[0]).to.equal(fingerprint); }); }); describe('Capture Message', (): void => { it('should create an event ready for the server', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'This is a test'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.type).to.equal('message'); expect(event.exception.message).to.equal(errorMessage); }); it('should create an event ready for the server while having the timeline with same event id', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -304,7 +304,7 @@ describe('Capture Message', (): void => { ); const errorMessage: string = 'This is a test'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.timeline.length).to.equal(2); expect(event.eventId).to.equal(event.timeline[0].eventId); expect(event.exception.message).to.equal(errorMessage); @@ -313,27 +313,27 @@ describe('Capture Message', (): void => { describe('Capture Exception', (): void => { it('should create an event ready for the server', async (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'Error Found'; await tracker.captureException(new Error(errorMessage)); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.type).to.equal('exception'); expect(event.exception.message).to.equal(errorMessage); }); it('should create an event with a array of stacktrace ', async (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'Error Found'; await tracker.captureException(new Error(errorMessage)); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.type).to.equal('exception'); expect(event.exception.message).to.equal(errorMessage); expect(event.exception.stacktrace).to.be.an('object'); @@ -341,15 +341,15 @@ describe('Capture Exception', (): void => { }); it('should create an event with the object of the stacktrace in place', async (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'Error Found'; await tracker.captureException(new Error(errorMessage)); - const event = tracker.getCurrentEvent(); - const frame = event.exception.stacktrace.frames[0]; + const event: $TSFixMe = tracker.getCurrentEvent(); + const frame: $TSFixMe = event.exception.stacktrace.frames[0]; expect(frame).to.have.property('methodName'); expect(frame).to.have.property('lineNumber'); expect(frame).to.have.property('columnNumber'); @@ -357,7 +357,7 @@ describe('Capture Exception', (): void => { }); it('should create an event and new event should have different id ', async (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -391,7 +391,7 @@ describe('Capture Exception', (): void => { }); it('should create an event that has timeline and new event having tags', async (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key @@ -436,14 +436,14 @@ describe('Capture Exception', (): void => { describe('SDK Version', (): void => { it('should contain version number and sdk name in captured message', (): void => { - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key ); const errorMessage: string = 'Uncaught Exception'; tracker.captureMessage(errorMessage); - const event = tracker.getCurrentEvent(); + const event: $TSFixMe = tracker.getCurrentEvent(); expect(event.sdk.name).to.be.a('string'); expect(event.sdk.version).to.match(/(([0-9])+\.([0-9])+\.([0-9])+)/); // confirm that the versiion follows the patter XX.XX.XX where X is a non negative integer }); @@ -452,19 +452,19 @@ describe('SDK Version', (): void => { describe('Code Capture Snippet', (): void => { it('should add code capture to stack trace when flag is passed in options', async (): void => { const options: $TSFixMe = { captureCodeSnippet: true }; - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, options ); - let event = null; + let event: $TSFixMe = null; const errorMessageObj: string = 'Object Error Found'; await tracker.captureException(new Error(errorMessageObj)).then(evt => { event = evt.data; }); - const incidentFrame = event.content.stacktrace.frames[0]; + const incidentFrame: $TSFixMe = event.content.stacktrace.frames[0]; expect(incidentFrame).to.have.property('linesBeforeError'); expect(incidentFrame).to.have.property('linesAfterError'); expect(incidentFrame).to.have.property('errorLine'); @@ -472,19 +472,19 @@ describe('Code Capture Snippet', (): void => { it('should add code capture and confirm data type of fields added to frame', async (): void => { const options: $TSFixMe = { captureCodeSnippet: true }; - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, options ); - let event = null; + let event: $TSFixMe = null; const errorMessageObj: string = 'Object Error Found'; await tracker.captureException(new Error(errorMessageObj)).then(evt => { event = evt.data; }); - const incidentFrame = event.content.stacktrace.frames[0]; + const incidentFrame: $TSFixMe = event.content.stacktrace.frames[0]; expect(incidentFrame.errorLine).to.be.a('string'); expect(incidentFrame.linesBeforeError).to.be.an('array'); expect(incidentFrame.linesAfterError).to.be.an('array'); @@ -492,19 +492,19 @@ describe('Code Capture Snippet', (): void => { it('should not add code capture to stack trace when flag is passed in options', async (): void => { const options: $TSFixMe = { captureCodeSnippet: false }; - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, options ); - let event = null; + let event: $TSFixMe = null; const errorMessageObj: string = 'Object Error Found'; await tracker.captureException(new Error(errorMessageObj)).then(evt => { event = evt.data; }); - const incidentFrame = event.content.stacktrace.frames[0]; + const incidentFrame: $TSFixMe = event.content.stacktrace.frames[0]; expect(incidentFrame).to.not.have.property('linesBeforeError'); expect(incidentFrame).to.not.have.property('linesAfterError'); expect(incidentFrame).to.not.have.property('errorLine'); @@ -512,19 +512,19 @@ describe('Code Capture Snippet', (): void => { it('should add code capture to stack trace by default when unwanted flag is passed in options', async (): void => { const options: $TSFixMe = { captureCodeSnippet: 'heyy' }; // expects a true or false but it defaults to true - const tracker = new OneUptimeTracker( + const tracker: $TSFixMe = new OneUptimeTracker( API_URL, errorTracker._id, errorTracker.key, options ); - let event = null; + let event: $TSFixMe = null; const errorMessageObj: string = 'Object Error Found'; await tracker.captureException(new Error(errorMessageObj)).then(evt => { event = evt.data; }); - const incidentFrame = event.content.stacktrace.frames[0]; + const incidentFrame: $TSFixMe = event.content.stacktrace.frames[0]; expect(incidentFrame).to.have.property('linesBeforeError'); expect(incidentFrame).to.have.property('linesAfterError'); expect(incidentFrame).to.have.property('errorLine'); diff --git a/Licensing/src/Services/LicenseService.ts b/Licensing/src/Services/LicenseService.ts index b5cc556419..54666c4158 100644 --- a/Licensing/src/Services/LicenseService.ts +++ b/Licensing/src/Services/LicenseService.ts @@ -21,7 +21,7 @@ export default { expiryDate: new Date(), }; - let licenseFound = false; + let licenseFound: $TSFixMe = false; for (const record of records) { const fetchedLicense: $TSFixMe = record.get('License Key'); diff --git a/LighthouseRunner/utils/urlService.ts b/LighthouseRunner/utils/urlService.ts index cd9412b7a0..6e28f1d8ae 100755 --- a/LighthouseRunner/utils/urlService.ts +++ b/LighthouseRunner/utils/urlService.ts @@ -15,7 +15,7 @@ export default { }, body: async (val: $TSFixMe, type: $TSFixMe) => { - let bodyContent = {}; + let bodyContent: $TSFixMe = {}; if (type && type === 'formData' && val && val[0] && val[0].key) { val.forEach((bod: $TSFixMe) => { bodyContent[bod.key] = bod.value; diff --git a/LighthouseRunner/workers/urlMonitors.ts b/LighthouseRunner/workers/urlMonitors.ts index e1a16e1702..3639cf20df 100755 --- a/LighthouseRunner/workers/urlMonitors.ts +++ b/LighthouseRunner/workers/urlMonitors.ts @@ -49,7 +49,7 @@ export default { const lighthouseFetch: Function = (url: URL): void => { return new Promise((resolve, reject) => { const lighthouseWorker: $TSFixMe = fork('./utils/lighthouse'); - const timeoutHandler = setTimeout(async (): $TSFixMe => { + const timeoutHandler: $TSFixMe = setTimeout(async (): $TSFixMe => { await processLighthouseScan({ data: { url }, error: { message: 'TIMEOUT' }, diff --git a/Mail/API/Mail.ts b/Mail/API/Mail.ts index 2993288d00..37fad26aba 100644 --- a/Mail/API/Mail.ts +++ b/Mail/API/Mail.ts @@ -2,7 +2,7 @@ import express, { ExpressRequest, ExpressResponse, } from 'CommonServer/Utils/Express'; -const router = express.getRouter(); +const router: $TSFixMe = express.getRouter(); import { sendErrorResponse, sendEmptyResponse, @@ -18,7 +18,7 @@ router.post( ClusterKeyAuthorization.isAuthorizedService, async (req: ExpressRequest, res: ExpressResponse) => { try { - const body = req.body; + const body: $TSFixMe = req.body; const mail: Mail = { templateType: req.params['template-name'] as EmailTemplateType, diff --git a/Probe/utils/apiService.ts b/Probe/utils/apiService.ts index 87c7f88e05..5cc555e7da 100755 --- a/Probe/utils/apiService.ts +++ b/Probe/utils/apiService.ts @@ -15,7 +15,7 @@ export default { }, body: async (val: $TSFixMe, type: $TSFixMe) => { - let bodyContent = {}; + let bodyContent: $TSFixMe = {}; if (type && type === 'formData' && val && val[0] && val[0].key) { val.forEach((bod: $TSFixMe) => { bodyContent[bod.key] = bod.value; diff --git a/Probe/workers/apiMonitors.ts b/Probe/workers/apiMonitors.ts index 691602c70c..81688e7008 100755 --- a/Probe/workers/apiMonitors.ts +++ b/Probe/workers/apiMonitors.ts @@ -23,8 +23,8 @@ export default { : 'formData' ); - let retry = true; - let retryCount = 0; + let retry: $TSFixMe = true; + let retryCount: $TSFixMe = 0; while (retry || retryCount > 2) { const { res, resp, rawResp }: $TSFixMe = await pingfetch( monitor.data.url, diff --git a/Probe/workers/incomingHttpRequestMonitors.ts b/Probe/workers/incomingHttpRequestMonitors.ts index b9e519efa9..3dc1dfb75f 100644 --- a/Probe/workers/incomingHttpRequestMonitors.ts +++ b/Probe/workers/incomingHttpRequestMonitors.ts @@ -31,9 +31,9 @@ export default { }; const checkCondition: Function = async (condition: $TSFixMe): void => { - let response = false; + let response: $TSFixMe = false; if (condition && condition.and && condition.and.length) { - for (let i = 0; i < condition.and.length; i++) { + for (let i: $TSFixMe = 0; i < condition.and.length; i++) { if ( condition.and[i] && condition.and[i].responseType && @@ -55,7 +55,7 @@ const checkCondition: Function = async (condition: $TSFixMe): void => { } } } else if (condition && condition.or && condition.or.length) { - for (let i = 0; i < condition.or.length; i++) { + for (let i: $TSFixMe = 0; i < condition.or.length; i++) { if ( condition.or[i] && condition.or[i].responseType && diff --git a/Probe/workers/ipMonitors.ts b/Probe/workers/ipMonitors.ts index ff2a0c4b81..07f7f9175d 100644 --- a/Probe/workers/ipMonitors.ts +++ b/Probe/workers/ipMonitors.ts @@ -8,8 +8,8 @@ export default { ping: async ({ monitor }: $TSFixMe) => { if (monitor && monitor.type) { if (monitor.data.IPAddress) { - let retry = true; - let retryCount = 0; + let retry: $TSFixMe = true; + let retryCount: $TSFixMe = 0; while (retry || retryCount > 2) { const { res, resp, rawResp }: $TSFixMe = await pingfetch( monitor.data.IPAddress @@ -40,9 +40,9 @@ export default { const pingfetch: Function = async (IPAddress: $TSFixMe): void => { const now: $TSFixMe = new Date().getTime(); - let resp = null; - let rawResp = null; - let res = null; + let resp: $TSFixMe = null; + let rawResp: $TSFixMe = null; + let res: $TSFixMe = null; try { const response: $TSFixMe = await ping.promise.probe(IPAddress, { diff --git a/Probe/workers/kubernetesMonitors.ts b/Probe/workers/kubernetesMonitors.ts index 1dc1c19870..07d8cd73e9 100644 --- a/Probe/workers/kubernetesMonitors.ts +++ b/Probe/workers/kubernetesMonitors.ts @@ -62,7 +62,7 @@ export default { unhealthyPodData = [], allPods = [], allPodData = []; - let runningPods = 0, + let runningPods: $TSFixMe = 0, completedPods = 0, failedPods = 0; @@ -374,7 +374,7 @@ export default { }; // handle deployment output - let desiredDeployment = 0, + let desiredDeployment: $TSFixMe = 0, readyDeployment = 0; const unhealthyDeployments: $TSFixMe = [], @@ -501,7 +501,7 @@ export default { }; // handle statefulset output - let desiredStatefulsets = 0, + let desiredStatefulsets: $TSFixMe = 0, readyStatefulsets = 0; const healthyStatefulsets: $TSFixMe = [], @@ -659,7 +659,7 @@ export default { function loadPodOutput(configPath, namespace): void { return new Promise(resolve => { - let podOutput = ''; + let podOutput: $TSFixMe = ''; const podCommand: string = `kubectl get pods -o json --kubeconfig ${configPath} --namespace ${namespace}`; const podCommandOutput: $TSFixMe = spawn(podCommand, { @@ -682,7 +682,7 @@ function loadPodOutput(configPath, namespace): void { function loadJobOutput(configPath, namespace): void { return new Promise(resolve => { - let jobOutput = ''; + let jobOutput: $TSFixMe = ''; const jobCommand: string = `kubectl get jobs -o json --kubeconfig ${configPath} --namespace ${namespace}`; const jobCommandOutput: $TSFixMe = spawn(jobCommand, { @@ -705,7 +705,7 @@ function loadJobOutput(configPath, namespace): void { function loadServiceOutput(configPath, namespace): void { return new Promise(resolve => { - let serviceOutput = ''; + let serviceOutput: $TSFixMe = ''; const serviceCommand: string = `kubectl get services -o json --kubeconfig ${configPath} --namespace ${namespace}`; const serviceCommandOutput: $TSFixMe = spawn(serviceCommand, { @@ -728,7 +728,7 @@ function loadServiceOutput(configPath, namespace): void { function loadDeploymentOutput(configPath, namespace): void { return new Promise(resolve => { - let deploymentOutput = ''; + let deploymentOutput: $TSFixMe = ''; const deploymentCommand: string = `kubectl get deployments -o json --kubeconfig ${configPath} --namespace ${namespace}`; const deploymentCommandOutput: $TSFixMe = spawn(deploymentCommand, { @@ -751,7 +751,7 @@ function loadDeploymentOutput(configPath, namespace): void { function loadStatefulsetOutput(configPath, namespace): void { return new Promise(resolve => { - let statefulsetOutput = ''; + let statefulsetOutput: $TSFixMe = ''; const statefulsetCommand: string = `kubectl get statefulsets -o json --kubeconfig ${configPath} --namespace ${namespace}`; const statefulsetCommandOutput: $TSFixMe = spawn(statefulsetCommand, { diff --git a/Probe/workers/main.ts b/Probe/workers/main.ts index 6f0325c1bd..f83c95eed3 100755 --- a/Probe/workers/main.ts +++ b/Probe/workers/main.ts @@ -7,7 +7,7 @@ import ServerMonitors from './serverMonitors'; import IncomingHttpRequestMonitors from './incomingHttpRequestMonitors'; import KubernetesMonitors from './kubernetesMonitors'; -let limit = process.env['RESOURCES_LIMIT']; +let limit: $TSFixMe = process.env['RESOURCES_LIMIT']; if (limit && typeof limit === 'string') { limit = parseInt(limit); diff --git a/Probe/workers/urlMonitors.ts b/Probe/workers/urlMonitors.ts index 195adee346..7151ebf297 100755 --- a/Probe/workers/urlMonitors.ts +++ b/Probe/workers/urlMonitors.ts @@ -11,8 +11,8 @@ export default { ping: async ({ monitor }: $TSFixMe) => { if (monitor && monitor.type) { if (monitor.data.url) { - let retry = true; - let retryCount = 0; + let retry: $TSFixMe = true; + let retryCount: $TSFixMe = 0; while (retry || retryCount > 2) { const { res, resp, rawResp }: $TSFixMe = await pingfetch( monitor.data.url diff --git a/ScriptRunner/utils/scriptSandbox.ts b/ScriptRunner/utils/scriptSandbox.ts index d2d7ff8a27..6576156543 100644 --- a/ScriptRunner/utils/scriptSandbox.ts +++ b/ScriptRunner/utils/scriptSandbox.ts @@ -150,7 +150,7 @@ const run: $TSFixMe: Function = async ( worker.terminate(); }); - let totalRuntime = 0, + let totalRuntime: $TSFixMe = 0, statementTimeExceeded = false, scriptTimeExceeded = false; diff --git a/StatusPage/index.ts b/StatusPage/index.ts index 70fb8dd819..3e401fd538 100755 --- a/StatusPage/index.ts +++ b/StatusPage/index.ts @@ -54,7 +54,7 @@ if (!NODE_ENV || NODE_ENV === 'development') { app.use(cors()); -let apiHost = 'http://localhost:3002/api'; +let apiHost: $TSFixMe = 'http://localhost:3002/api'; if (process.env.BACKEND_URL) { apiHost = 'http://' + process.env.BACKEND_URL + '/api'; } @@ -93,7 +93,7 @@ app.get( /(http:\/\/|https:\/\/)/, '' ); // remove any protocol that might have been added - let protocol = 'http:'; + let protocol: $TSFixMe = 'http:'; if (process.env.BACKEND_PROTOCOL) { protocol = process.env.BACKEND_PROTOCOL + ':'; } else if (req.secure) { @@ -143,7 +143,7 @@ async function handleCustomDomain( deleted: false, }); - let domainObj = {}; + let domainObj: $TSFixMe = {}; statusPage && statusPage.domains && statusPage.domains.forEach((eachDomain: $TSFixMe) => { @@ -281,7 +281,7 @@ async function fetchCredential( function decodeAndSave(content: $TSFixMe, filePath: $TSFixMe): void { return new Promise(resolve => { const command: string = `echo ${content} | base64 -d`; - let output = ''; + let output: $TSFixMe = ''; const commandOutput: $TSFixMe = spawn(command, { cwd: process.cwd(), @@ -318,10 +318,10 @@ function createDir(dirPath: $TSFixMe): void { function countFreq(pat: $TSFixMe, txt: $TSFixMe): void { const M: $TSFixMe = pat.length; const N: $TSFixMe = txt.length; - let res = 0; + let res: $TSFixMe = 0; // A loop to slide pat[] one by one - for (let i = 0; i <= N - M; i++) { + for (let i: $TSFixMe = 0; i <= N - M; i++) { // For current index i, check for // pattern match let j; @@ -426,7 +426,7 @@ function countFreq(pat: $TSFixMe, txt: $TSFixMe): void { // check if the certificate is container chain // if not, add anc show update view for the frontend - let fullCert = certificate.cert; + let fullCert: $TSFixMe = certificate.cert; if ( countFreq( 'BEGIN CERTIFICATE', diff --git a/StatusPage/src/Actions/probe.ts b/StatusPage/src/Actions/probe.ts index ac3303b03b..c0c8bbbc88 100644 --- a/StatusPage/src/Actions/probe.ts +++ b/StatusPage/src/Actions/probe.ts @@ -14,7 +14,7 @@ export function getProbes( limit = parseInt(limit); return function (dispatch: Dispatch): void { - let promise = null; + let promise: $TSFixMe = null; if (skip >= 0 && limit >= 0) { promise = BackendAPI.get( `StatusPage/${projectId}/probes?skip=${skip}&limit=${limit}` diff --git a/StatusPage/src/Reducer/status.ts b/StatusPage/src/Reducer/status.ts index f9589eb631..81f858482b 100755 --- a/StatusPage/src/Reducer/status.ts +++ b/StatusPage/src/Reducer/status.ts @@ -520,8 +520,8 @@ export default (state = INITIAL_STATE, action: Action): void => { }); case 'ADD_INCIDENT_NOTE': { - let addToIncident = false; - let notes = [...state.incidentNotes.notes]; + let addToIncident: $TSFixMe = false; + let notes: $TSFixMe = [...state.incidentNotes.notes]; const noteData: $TSFixMe = state.notes.notes, result: $TSFixMe = []; const check: $TSFixMe = noteData.find( @@ -579,7 +579,7 @@ export default (state = INITIAL_STATE, action: Action): void => { } case 'UPDATE_INCIDENT_NOTE': { - let notes = [...state.incidentNotes.notes]; + let notes: $TSFixMe = [...state.incidentNotes.notes]; if ( String(state.incident.incident._id) === String(action.payload.incidentId._id) @@ -761,9 +761,9 @@ export default (state = INITIAL_STATE, action: Action): void => { }); case 'ADD_SCHEDULED_EVENT': { - let monitorInStatusPage = false; - let addEvent = false; - let addFutureEvent = false; + let monitorInStatusPage: $TSFixMe = false; + let addEvent: $TSFixMe = false; + let addFutureEvent: $TSFixMe = false; state.statusPage.monitors.map((monitorData: $TSFixMe) => { action.payload.monitors.map((monitor: $TSFixMe) => { @@ -818,8 +818,8 @@ export default (state = INITIAL_STATE, action: Action): void => { case 'DELETE_SCHEDULED_EVENT': { const currentDate: $TSFixMe = moment().format(); const startDate: $TSFixMe = moment(action.payload.startDate).format(); - let isFutureEvent = false; - let events = []; + let isFutureEvent: $TSFixMe = false; + let events: $TSFixMe = []; if (startDate > currentDate) { isFutureEvent = true; events = state.futureEvents.events.filter( @@ -852,11 +852,11 @@ export default (state = INITIAL_STATE, action: Action): void => { } case 'UPDATE_SCHEDULED_EVENT': { - let addEvent = false; - let addFutureEvent = false; - let futureEventExist = false; - let eventExist = false; - let monitorInStatusPage = false; + let addEvent: $TSFixMe = false; + let addFutureEvent: $TSFixMe = false; + let futureEventExist: $TSFixMe = false; + let eventExist: $TSFixMe = false; + let monitorInStatusPage: $TSFixMe = false; const currentDate: $TSFixMe = moment().format(); const startDate: $TSFixMe = moment(action.payload.startDate).format(); const endDate: $TSFixMe = moment(action.payload.endDate).format(); @@ -874,7 +874,7 @@ export default (state = INITIAL_STATE, action: Action): void => { return monitorData; }); - const updatedEvents = state.events.events.map(event: $TSFixMe => { + const updatedEvents: $TSFixMe = state.events.events.map(event: $TSFixMe => { if (String(event._id) === String(action.payload._id)) { eventExist = true; @@ -883,7 +883,7 @@ export default (state = INITIAL_STATE, action: Action): void => { return event; }); - const updatedFutureEvent = state.futureEvents.events.map(event: $TSFixMe => { + const updatedFutureEvent: $TSFixMe = state.futureEvents.events.map(event: $TSFixMe => { if (String(event._id) === String(action.payload._id)) { futureEventExist = true; @@ -1480,8 +1480,8 @@ export default (state = INITIAL_STATE, action: Action): void => { }; case 'ADD_EVENT_NOTE': { - let eventNotes = [...state.eventNoteList.eventNotes]; - let increaseCount = false; + let eventNotes: $TSFixMe = [...state.eventNoteList.eventNotes]; + let increaseCount: $TSFixMe = false; if ( String(state.scheduledEvent.event._id) === String(action.payload.scheduledEventId._id) @@ -1503,8 +1503,8 @@ export default (state = INITIAL_STATE, action: Action): void => { } case 'DELETE_EVENT_NOTE': { - let eventNotes = [...state.eventNoteList.eventNotes]; - let reduceCount = false; + let eventNotes: $TSFixMe = [...state.eventNoteList.eventNotes]; + let reduceCount: $TSFixMe = false; if ( String(state.scheduledEvent.event._id) === String(action.payload.scheduledEventId._id) @@ -1527,7 +1527,7 @@ export default (state = INITIAL_STATE, action: Action): void => { } case 'UPDATE_EVENT_NOTE': { - let eventNotes = [...state.eventNoteList.eventNotes]; + let eventNotes: $TSFixMe = [...state.eventNoteList.eventNotes]; if ( String(state.scheduledEvent.event._id) === String(action.payload.scheduledEventId._id) @@ -1685,12 +1685,12 @@ export default (state = INITIAL_STATE, action: Action): void => { }; case 'INCIDENT_CREATED': { - let incidentFound = false; + let incidentFound: $TSFixMe = false; const statusPageMonitorIds: $TSFixMe = state.statusPage.monitors.map( (monitorData: $TSFixMe) => String(monitorData.monitor._id) ); - let notes = state.notes.notes.map(note => { + let notes: $TSFixMe = state.notes.notes.map(note => { if (String(note._id) === String(action.payload._id)) { incidentFound = true; } @@ -1740,7 +1740,7 @@ export default (state = INITIAL_STATE, action: Action): void => { } case 'INCIDENT_UPDATED': { - const notes = state.notes.notes.map(note: $TSFixMe => { + const notes: $TSFixMe = state.notes.notes.map(note: $TSFixMe => { if (String(note._id) === String(action.payload._id)) { note = action.payload; return note; @@ -1903,8 +1903,8 @@ export default (state = INITIAL_STATE, action: Action): void => { case 'INCIDENT_TIMELINE_CREATED': { const timelineIds: $TSFixMe = []; - let singleTimeline = false; - let timelines = state.lastIncidentTimelines.timelines.map( + let singleTimeline: $TSFixMe = false; + let timelines: $TSFixMe = state.lastIncidentTimelines.timelines.map( timeline => { if ( String(timeline.incidentId) === diff --git a/StatusPage/src/config.ts b/StatusPage/src/config.ts index 92e81ddbef..3b1242f2aa 100755 --- a/StatusPage/src/config.ts +++ b/StatusPage/src/config.ts @@ -1,9 +1,9 @@ import isEmail from 'sane-email-validation'; import validUrl from 'valid-url'; -let apiUrl = window.location.origin + '/api'; -let dashboardUrl = window.location.origin + '/dashboard'; -let accountsUrl = window.location.origin + '/accounts'; -let realtimeUrl = window.location.origin + '/realtime'; +let apiUrl: $TSFixMe = window.location.origin + '/api'; +let dashboardUrl: $TSFixMe = window.location.origin + '/dashboard'; +let accountsUrl: $TSFixMe = window.location.origin + '/accounts'; +let realtimeUrl: $TSFixMe = window.location.origin + '/realtime'; export const env: Function = (value: $TSFixMe): void => { const { _env }: $TSFixMe = window; @@ -13,7 +13,7 @@ export const env: Function = (value: $TSFixMe): void => { ); }; -let protocol = window.location.protocol; +let protocol: $TSFixMe = window.location.protocol; if (env('BACKEND_PROTOCOL')) { protocol = env('BACKEND_PROTOCOL') + ':'; } @@ -195,8 +195,8 @@ export const getServiceStatus: Function = ( const probesLength: $TSFixMe = probes && probes.length; const totalServices: $TSFixMe = monitorsLength * probesLength; - let onlineServices = totalServices; - let degraded = 0; + let onlineServices: $TSFixMe = totalServices; + let degraded: $TSFixMe = 0; monitorsData.forEach((monitor: $TSFixMe) => { probes.forEach((probe: $TSFixMe) => { @@ -276,7 +276,7 @@ export const handleResources: Function = ( announcement: $TSFixMe ): void => { const affectedMonitors: $TSFixMe = []; - let monitorCount = 0; + let monitorCount: $TSFixMe = 0; if (announcement.monitors.length <= 0) { return 'No resource is affected'; diff --git a/Tests/enterprise-tests/accounts/accounts.test.ts b/Tests/enterprise-tests/accounts/accounts.test.ts index e18a19022e..9d91b50657 100644 --- a/Tests/enterprise-tests/accounts/accounts.test.ts +++ b/Tests/enterprise-tests/accounts/accounts.test.ts @@ -16,7 +16,7 @@ const user: $TSFixMe = { }; describe('Enterprise Accounts API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -40,10 +40,10 @@ describe('Enterprise Accounts API', () => { await init.logout(page); await init.loginUser(user, page); - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } diff --git a/Tests/enterprise-tests/accounts/login.test.ts b/Tests/enterprise-tests/accounts/login.test.ts index d35dbcd819..d79cf96a41 100644 --- a/Tests/enterprise-tests/accounts/login.test.ts +++ b/Tests/enterprise-tests/accounts/login.test.ts @@ -5,7 +5,7 @@ import utils from '../../test-utils'; import init from '../../test-init'; let browser: $TSFixMe, page: $TSFixMe; import 'should'; -const operationTimeOut = init.timeout; +const operationTimeOut: $TSFixMe = init.timeout; const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; @@ -133,7 +133,7 @@ describe('SSO login', () => { response.url().includes('/login') ), ]); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#main-body', (e: $TSFixMe) => e.innerHTML @@ -169,7 +169,7 @@ describe('SSO login', () => { response.url().includes('/login') ), ]); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#main-body', (e: $TSFixMe) => e.innerHTML @@ -204,7 +204,7 @@ describe('SSO login', () => { init.pageClick(page, 'button[type=submit]'), ]); - const chain = response.request().redirectChain(); + const chain: $TSFixMe = response.request().redirectChain(); expect(chain.length).not.toBe(0); await init.pageClick(page, '#username'); diff --git a/Tests/enterprise-tests/accounts/register.test.ts b/Tests/enterprise-tests/accounts/register.test.ts index bfdd554e29..d3eb9715fb 100644 --- a/Tests/enterprise-tests/accounts/register.test.ts +++ b/Tests/enterprise-tests/accounts/register.test.ts @@ -35,10 +35,10 @@ describe('Enterprise Registration API', () => { async () => { await init.registerEnterpriseUser(user, page); - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } @@ -67,7 +67,7 @@ describe('Enterprise Registration API', () => { .url() .should.containEql(utils.ACCOUNTS_URL + '/accounts/login'); - const signUp = await otherPage.$('#signUpLink'); + const signUp: $TSFixMe = await otherPage.$('#signUpLink'); should.not.exist(signUp); }, init.timeout @@ -78,10 +78,10 @@ describe('Enterprise Registration API', () => { async () => { await init.loginAdminUser(user, otherPage); - const localStorageData = await otherPage.evaluate(() => { + const localStorageData: $TSFixMe = await otherPage.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } diff --git a/Tests/enterprise-tests/admin-dashboard/About.test.ts b/Tests/enterprise-tests/admin-dashboard/About.test.ts index f5bac4525b..e90b313506 100644 --- a/Tests/enterprise-tests/admin-dashboard/About.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/About.test.ts @@ -10,7 +10,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('About Modal (IS_SAAS_SERVICE=false)', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -49,7 +49,7 @@ describe('About Modal (IS_SAAS_SERVICE=false)', () => { await init.page$Eval(page, '#profile-menu', (elem: $TSFixMe) => elem.click() ); - const about = await init.pageWaitForSelector( + const about: $TSFixMe = await init.pageWaitForSelector( page, '#about-button', { @@ -90,33 +90,33 @@ describe('About Modal (IS_SAAS_SERVICE=false)', () => { visible: true, timeout: init.timeout, }); - const serverVersion = await init.page$Eval( + const serverVersion: $TSFixMe = await init.page$Eval( page, '#server-version', (elem: $TSFixMe) => elem.textContent ); - const docsVersion = await init.page$Eval( + const docsVersion: $TSFixMe = await init.page$Eval( page, '#docs-version', (elem: $TSFixMe) => elem.textContent ); - const helmVersion = await init.page$Eval( + const helmVersion: $TSFixMe = await init.page$Eval( page, '#helm-version', (elem: $TSFixMe) => elem.textContent ); - const dashboardVersion = await init.page$Eval( + const dashboardVersion: $TSFixMe = await init.page$Eval( page, '#dashboard-version', (elem: $TSFixMe) => elem.textContent ); - const adminDashboardVersion = await init.page$Eval( + const adminDashboardVersion: $TSFixMe = await init.page$Eval( page, '#AdminDashboard-version', (elem: $TSFixMe) => elem.textContent ); - const probeVersion = await init.page$Eval( + const probeVersion: $TSFixMe = await init.page$Eval( page, '#probe-version', (elem: $TSFixMe) => elem.textContent diff --git a/Tests/enterprise-tests/admin-dashboard/AuditLog.test.ts b/Tests/enterprise-tests/admin-dashboard/AuditLog.test.ts index 72be50ffbe..a22a62df7c 100644 --- a/Tests/enterprise-tests/admin-dashboard/AuditLog.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/AuditLog.test.ts @@ -11,7 +11,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Audit Logs', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -59,7 +59,7 @@ describe('Audit Logs', () => { await init.pageWaitForSelector(page, '#confirmDelete', { hidden: true, }); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr', (row: $TSFixMe) => row.textContent @@ -95,7 +95,7 @@ describe('Audit Logs', () => { await init.pageClick(page, '#cancelAuditDelete'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -143,7 +143,7 @@ describe('Audit Logs', () => { await init.pageClick(page, '#auditLogs'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -177,7 +177,7 @@ describe('Audit Logs', () => { await init.pageType(page, '#searchAuditLog', 'probe'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -211,7 +211,7 @@ describe('Audit Logs', () => { await init.pageType(page, '#searchAuditLog', 'somerandom'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr', (row: $TSFixMe) => row.textContent @@ -326,7 +326,7 @@ describe('Audit Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#auditLogDisabled` ); @@ -350,7 +350,7 @@ describe('Audit Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#auditLogDisabled` ); @@ -422,7 +422,7 @@ describe('Audit Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#auditLogDisabled` ); diff --git a/Tests/enterprise-tests/admin-dashboard/CreateUser.test.ts b/Tests/enterprise-tests/admin-dashboard/CreateUser.test.ts index 4816f35ad3..6c34df38f3 100644 --- a/Tests/enterprise-tests/admin-dashboard/CreateUser.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/CreateUser.test.ts @@ -14,7 +14,7 @@ const masterAdmin: $TSFixMe = { }; describe('Enterprise User API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -92,8 +92,11 @@ describe('Enterprise User API', () => { await init.pageWaitForSelector(page, 'a.db-UserListRow'); - const userRows = await init.page$$(page, 'a.db-UserListRow'); - const countUsers = userRows.length; + const userRows: $TSFixMe = await init.page$$( + page, + 'a.db-UserListRow' + ); + const countUsers: $TSFixMe = userRows.length; expect(countUsers).toBeGreaterThanOrEqual(2); @@ -112,7 +115,7 @@ describe('Enterprise User API', () => { await init.loginAdminUser(masterAdmin, page); - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { // add new user await page.goto(utils.ADMIN_DASHBOARD_URL, { waitUntil: 'networkidle0', @@ -171,11 +174,11 @@ describe('Enterprise User API', () => { page, 'a.db-UserListRow' ); - let countUsers = userRows.length; + let countUsers: $TSFixMe = userRows.length; expect(countUsers).toEqual(10); - const nextSelector = await init.page$(page, '#btnNext'); + const nextSelector: $TSFixMe = await init.page$(page, '#btnNext'); await nextSelector.click(); @@ -183,7 +186,7 @@ describe('Enterprise User API', () => { countUsers = userRows.length; expect(countUsers).toBeGreaterThanOrEqual(2); - const prevSelector = await init.page$(page, '#btnPrev'); + const prevSelector: $TSFixMe = await init.page$(page, '#btnPrev'); await prevSelector.click(); @@ -252,7 +255,7 @@ describe('Enterprise User API', () => { await init.pageClick(page, 'button[type=submit]'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#frmUser', (e: $TSFixMe) => { diff --git a/Tests/enterprise-tests/admin-dashboard/EmailLog.test.ts b/Tests/enterprise-tests/admin-dashboard/EmailLog.test.ts index 09ebd657da..7ed54a6ff6 100644 --- a/Tests/enterprise-tests/admin-dashboard/EmailLog.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/EmailLog.test.ts @@ -11,7 +11,7 @@ const password: string = '1234567890'; let browser: $TSFixMe, page: $TSFixMe; describe('Email Logs', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -62,7 +62,7 @@ describe('Email Logs', () => { hidden: true, }); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr', (row: $TSFixMe) => row.textContent @@ -99,7 +99,7 @@ describe('Email Logs', () => { await init.pageClick(page, '#cancelEmailDelete'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -122,7 +122,7 @@ describe('Email Logs', () => { await init.pageWaitForSelector(page, '#emailLogs'); await init.pageClick(page, '#emailLogs'); - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#emailLogDisabled`, { hidden: true } @@ -183,7 +183,7 @@ describe('Email Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#emailLogDisabled` ); @@ -207,7 +207,7 @@ describe('Email Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#emailLogDisabled` ); @@ -277,7 +277,7 @@ describe('Email Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#emailLogDisabled` ); diff --git a/Tests/enterprise-tests/admin-dashboard/KeyboardShortcut.test.ts b/Tests/enterprise-tests/admin-dashboard/KeyboardShortcut.test.ts index 38daa2272e..7177294bc6 100644 --- a/Tests/enterprise-tests/admin-dashboard/KeyboardShortcut.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/KeyboardShortcut.test.ts @@ -11,7 +11,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Keyboard Shortcut: Admin Dashboard', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(360000); @@ -45,7 +45,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('p'); - const project = await init.pageWaitForSelector( + const project: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeProject', { @@ -70,7 +70,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('b'); - const probe = await init.pageWaitForSelector( + const probe: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeProbe', { @@ -99,7 +99,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('a'); - const auditLog = await init.pageWaitForSelector( + const auditLog: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeAuditLog', { @@ -124,7 +124,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('l'); - const license = await init.pageWaitForSelector( + const license: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeLicense', { @@ -149,7 +149,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('m'); - const smtp = await init.pageWaitForSelector( + const smtp: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeSmtp', { @@ -174,7 +174,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('t'); - const twilio = await init.pageWaitForSelector( + const twilio: $TSFixMe = await init.pageWaitForSelector( page, '#oneuptimeTwilio', { @@ -199,10 +199,14 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('o'); - const sso = await init.pageWaitForSelector(page, '#oneuptimeSso', { - visible: true, - timeout: init.timeout, - }); + const sso: $TSFixMe = await init.pageWaitForSelector( + page, + '#oneuptimeSso', + { + visible: true, + timeout: init.timeout, + } + ); expect(sso).toBeDefined(); done(); @@ -220,7 +224,7 @@ describe('Keyboard Shortcut: Admin Dashboard', () => { }); await page.keyboard.press('f'); await page.keyboard.press('d'); - const component = await init.pageWaitForSelector( + const component: $TSFixMe = await init.pageWaitForSelector( page, '#components', { diff --git a/Tests/enterprise-tests/admin-dashboard/License.test.ts b/Tests/enterprise-tests/admin-dashboard/License.test.ts index 7f57cb3e73..e58667c3bb 100644 --- a/Tests/enterprise-tests/admin-dashboard/License.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/License.test.ts @@ -11,7 +11,7 @@ const userEmail: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Enterprise License API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -61,7 +61,7 @@ describe('Enterprise License API', () => { await init.pageClick(page, 'button[type=submit]'); - const expiredError = await init.page$Eval( + const expiredError: $TSFixMe = await init.page$Eval( page, '#licenseError', (e: $TSFixMe) => { diff --git a/Tests/enterprise-tests/admin-dashboard/Project.test.ts b/Tests/enterprise-tests/admin-dashboard/Project.test.ts index 3978ac6a7c..360b49e134 100644 --- a/Tests/enterprise-tests/admin-dashboard/Project.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/Project.test.ts @@ -11,7 +11,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Project', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -49,11 +49,14 @@ describe('Project', () => { ); await page.reload({ waitUntil: 'networkidle0' }); - const elem = await init.page$$(page, 'table > tbody > tr'); + const elem: $TSFixMe = await init.page$$( + page, + 'table > tbody > tr' + ); elem[0].click(); await page.waitForNavigation({ waitUntil: 'networkidle0' }); - const planBox = await page.$('#planBox'); + const planBox: $TSFixMe = await page.$('#planBox'); expect(planBox).toBeNull(); }, operationTimeOut @@ -70,7 +73,7 @@ describe('Project', () => { await init.pageClick(page, '#projects'); - const firstProject = await init.pageWaitForSelector( + const firstProject: $TSFixMe = await init.pageWaitForSelector( page, '#project_0', { @@ -96,7 +99,7 @@ describe('Project', () => { hidden: true, }); - const restoreBtn = await init.pageWaitForSelector( + const restoreBtn: $TSFixMe = await init.pageWaitForSelector( page, '#restore', { @@ -122,7 +125,7 @@ describe('Project', () => { await init.pageClick(page, '#projects'); - const firstProject = await init.pageWaitForSelector( + const firstProject: $TSFixMe = await init.pageWaitForSelector( page, '#project_0', { @@ -138,10 +141,14 @@ describe('Project', () => { await init.pageClick(page, '#restore'); - const deleteBtn = await init.pageWaitForSelector(page, '#delete', { - visible: true, - timeout: init.timeout, - }); + const deleteBtn: $TSFixMe = await init.pageWaitForSelector( + page, + '#delete', + { + visible: true, + timeout: init.timeout, + } + ); expect(deleteBtn).toBeDefined(); done(); diff --git a/Tests/enterprise-tests/admin-dashboard/Settings.test.ts b/Tests/enterprise-tests/admin-dashboard/Settings.test.ts index 98ab450f31..7415bad5f4 100644 --- a/Tests/enterprise-tests/admin-dashboard/Settings.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/Settings.test.ts @@ -10,7 +10,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Settings Component (IS_SAAS_SERVICE=false)', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -42,10 +42,14 @@ describe('Settings Component (IS_SAAS_SERVICE=false)', () => { }); // if element does not exist it will timeout and throw - const elem = await init.pageWaitForSelector(page, '#settings', { - visible: true, - timeout: init.timeout, - }); + const elem: $TSFixMe = await init.pageWaitForSelector( + page, + '#settings', + { + visible: true, + timeout: init.timeout, + } + ); expect(elem).toBeDefined(); }, operationTimeOut @@ -67,7 +71,7 @@ describe('Settings Component (IS_SAAS_SERVICE=false)', () => { ); // if element does not exist it will timeout and throw - const licenseOption = await init.pageWaitForSelector( + const licenseOption: $TSFixMe = await init.pageWaitForSelector( page, '#license', { diff --git a/Tests/enterprise-tests/admin-dashboard/SmsLog.test.ts b/Tests/enterprise-tests/admin-dashboard/SmsLog.test.ts index c1c0ee8c1b..429a7f3b26 100644 --- a/Tests/enterprise-tests/admin-dashboard/SmsLog.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/SmsLog.test.ts @@ -11,7 +11,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('SMS Logs', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -78,7 +78,7 @@ describe('SMS Logs', () => { hidden: true, }); - const alertLogs = await init.page$Eval( + const alertLogs: $TSFixMe = await init.page$Eval( page, '#logsStatus', (element: $TSFixMe) => element.textContent @@ -122,7 +122,7 @@ describe('SMS Logs', () => { await init.pageClick(page, '#cancelSmsDelete'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -189,7 +189,7 @@ describe('SMS Logs', () => { await init.pageClick(page, '#smsLogs'); - const rowNum = await init.page$$Eval( + const rowNum: $TSFixMe = await init.page$$Eval( page, 'tbody tr.Table-row', (rows: $TSFixMe) => rows.length @@ -318,7 +318,7 @@ describe('SMS Logs', () => { // look for the alert panel - const alertPanelElement = await init.pageWaitForSelector( + const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( page, `#smsLogDisabled` ); @@ -335,7 +335,7 @@ describe('SMS Logs', () => { // await init.pageClick(page, '#smsLogs'); // // look for the alert panel - // const alertPanelElement = await init.pageWaitForSelector( + // const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( // page, // `#smsLogDisabled` // ); @@ -382,7 +382,7 @@ describe('SMS Logs', () => { // logCount = Number(logCount.split(' ')[0]); // // look for the alert panel - // const alertPanelElement = await init.pageWaitForSelector( + // const alertPanelElement: $TSFixMe = await init.pageWaitForSelector( // page, // `#smsLogDisabled` // ); diff --git a/Tests/enterprise-tests/admin-dashboard/TwilioSettings.test.ts b/Tests/enterprise-tests/admin-dashboard/TwilioSettings.test.ts index 2839d730db..812d053c0f 100644 --- a/Tests/enterprise-tests/admin-dashboard/TwilioSettings.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/TwilioSettings.test.ts @@ -11,7 +11,7 @@ const password: string = '1234567890'; const phoneNumber: string = '+19173976235'; describe('Twilio Settings API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -50,10 +50,14 @@ describe('Twilio Settings API', () => { await init.pageWaitForSelector(page, '#twilio-form'); await init.pageClick(page, 'button[type=submit]'); - const error = await init.pageWaitForSelector(page, '.field-error', { - visible: true, - timeout: init.timeout, - }); + const error: $TSFixMe = await init.pageWaitForSelector( + page, + '.field-error', + { + visible: true, + timeout: init.timeout, + } + ); expect(error).toBeDefined(); done(); @@ -109,7 +113,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const errorMessage = await init.page$Eval( + const errorMessage: $TSFixMe = await init.page$Eval( page, '#errors', (element: $TSFixMe) => element.textContent @@ -121,7 +125,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const value = await init.page$Eval( + const value: $TSFixMe = await init.page$Eval( page, 'input[name=account-sid]', (e: $TSFixMe) => e.value @@ -178,7 +182,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const errorMessage = await init.page$Eval( + const errorMessage: $TSFixMe = await init.page$Eval( page, '#errors', (element: $TSFixMe) => element.textContent @@ -192,7 +196,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const value = await init.page$Eval( + const value: $TSFixMe = await init.page$Eval( page, 'input[name=account-sid]', (e: $TSFixMe) => e.value @@ -265,7 +269,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const value = await init.page$Eval( + const value: $TSFixMe = await init.page$Eval( page, 'input[name=account-sid]', (e: $TSFixMe) => e.value @@ -310,7 +314,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '#smsVerificationErrors', (e: $TSFixMe) => e.textContent @@ -360,7 +364,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '#successMessage', (e: $TSFixMe) => e.textContent @@ -416,7 +420,7 @@ describe('Twilio Settings API', () => { visible: true, timeout: init.timeout, }); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '#successMessage', (e: $TSFixMe) => e.textContent diff --git a/Tests/enterprise-tests/admin-dashboard/Users.test.ts b/Tests/enterprise-tests/admin-dashboard/Users.test.ts index d24aecf30b..3eb30dc0ed 100644 --- a/Tests/enterprise-tests/admin-dashboard/Users.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/Users.test.ts @@ -10,7 +10,7 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; describe('Users Component (IS_SAAS_SERVICE=false)', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -44,10 +44,14 @@ describe('Users Component (IS_SAAS_SERVICE=false)', () => { }); // if element does not exist it will timeout and throw - const elem = await init.pageWaitForSelector(page, '#add_user', { - visible: true, - timeout: init.timeout, - }); + const elem: $TSFixMe = await init.pageWaitForSelector( + page, + '#add_user', + { + visible: true, + timeout: init.timeout, + } + ); expect(elem).toBeTruthy(); done(); diff --git a/Tests/enterprise-tests/admin-dashboard/admin-dashboard.test.ts b/Tests/enterprise-tests/admin-dashboard/admin-dashboard.test.ts index 8321cf17fa..287218444e 100644 --- a/Tests/enterprise-tests/admin-dashboard/admin-dashboard.test.ts +++ b/Tests/enterprise-tests/admin-dashboard/admin-dashboard.test.ts @@ -35,10 +35,10 @@ describe('Enterprise Admin Dashboard API', () => { async (done: $TSFixMe) => { await init.registerEnterpriseUser(user, page); - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } diff --git a/Tests/enterprise-tests/dashboard/Billing.test.ts b/Tests/enterprise-tests/dashboard/Billing.test.ts index 44de57cbc9..2ce1ab075b 100644 --- a/Tests/enterprise-tests/dashboard/Billing.test.ts +++ b/Tests/enterprise-tests/dashboard/Billing.test.ts @@ -15,7 +15,7 @@ const user: $TSFixMe = { }; describe('Enterprise Disabled Billing API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -45,7 +45,7 @@ describe('Enterprise Disabled Billing API', () => { await init.pageClick(page, '#projectSettings'); - const projectBilling = await page.$('#billingSetting'); + const projectBilling: $TSFixMe = await page.$('#billingSetting'); expect(projectBilling).toBeNull(); done(); }, @@ -65,7 +65,7 @@ describe('Enterprise Disabled Billing API', () => { await init.pageClick(page, '#profile-menu'); - const profileBilling = await page.$('#cbBilling'); + const profileBilling: $TSFixMe = await page.$('#cbBilling'); expect(profileBilling).toBeNull(); done(); }, diff --git a/Tests/enterprise-tests/dashboard/CreateProject.test.ts b/Tests/enterprise-tests/dashboard/CreateProject.test.ts index d08b98e3ee..134ebaddc9 100644 --- a/Tests/enterprise-tests/dashboard/CreateProject.test.ts +++ b/Tests/enterprise-tests/dashboard/CreateProject.test.ts @@ -61,15 +61,17 @@ describe('Enterprise Project API', () => { await init.pageClick(page, 'button[type=submit]'); - const localStorageData = await page.evaluate((): $TSFixMe => { - const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key: $TSFixMe = localStorage.key(i); + const localStorageData: $TSFixMe = await page.evaluate( + (): $TSFixMe => { + const json: $TSFixMe = {}; + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); - json[key] = localStorage.getItem(key); + json[key] = localStorage.getItem(key); + } + return json; } - return json; - }); + ); localStorageData.should.have.property('project'); done(); diff --git a/Tests/enterprise-tests/dashboard/Monitor.test.ts b/Tests/enterprise-tests/dashboard/Monitor.test.ts index 937b672400..15bd8cf8bf 100644 --- a/Tests/enterprise-tests/dashboard/Monitor.test.ts +++ b/Tests/enterprise-tests/dashboard/Monitor.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { }; describe('Enterprise Monitor API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/enterprise-tests/dashboard/MonitorSubProject.test.ts b/Tests/enterprise-tests/dashboard/MonitorSubProject.test.ts index dd22e44de0..e2887da43c 100644 --- a/Tests/enterprise-tests/dashboard/MonitorSubProject.test.ts +++ b/Tests/enterprise-tests/dashboard/MonitorSubProject.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { }; describe('Enterprise Monitor SubProject API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/enterprise-tests/dashboard/SubProject.test.ts b/Tests/enterprise-tests/dashboard/SubProject.test.ts index 85647d6417..b45a35625d 100644 --- a/Tests/enterprise-tests/dashboard/SubProject.test.ts +++ b/Tests/enterprise-tests/dashboard/SubProject.test.ts @@ -7,7 +7,7 @@ let browser: $TSFixMe, page: $TSFixMe; // user credentials const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; -let subProjectName = utils.generateRandomString(); +let subProjectName: $TSFixMe = utils.generateRandomString(); const newSubProjectName: string = utils.generateRandomString(); describe('Sub-Project API', () => { diff --git a/Tests/enterprise-tests/dashboard/TeamSubProject.test.ts b/Tests/enterprise-tests/dashboard/TeamSubProject.test.ts index 0d17770cbb..0e46ec45f9 100644 --- a/Tests/enterprise-tests/dashboard/TeamSubProject.test.ts +++ b/Tests/enterprise-tests/dashboard/TeamSubProject.test.ts @@ -15,7 +15,7 @@ const newUser: $TSFixMe = { }; describe('Enterprise Team SubProject API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); diff --git a/Tests/enterprise-tests/dashboard/User.test.ts b/Tests/enterprise-tests/dashboard/User.test.ts index c5e32fa690..816ddaeda8 100644 --- a/Tests/enterprise-tests/dashboard/User.test.ts +++ b/Tests/enterprise-tests/dashboard/User.test.ts @@ -18,7 +18,7 @@ const user: $TSFixMe = { }; describe('Users', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -103,10 +103,14 @@ describe('Users', () => { }); await init.pageClick(page, '#restore'); - const delBtn = await init.pageWaitForSelector(page, '#delete', { - visible: true, - timeout: init.timeout, - }); + const delBtn: $TSFixMe = await init.pageWaitForSelector( + page, + '#delete', + { + visible: true, + timeout: init.timeout, + } + ); expect(delBtn).toBeDefined(); done(); }, diff --git a/Tests/enterprise-tests/dashboard/UserLogout.test.ts b/Tests/enterprise-tests/dashboard/UserLogout.test.ts index bf10c0f913..4e169f420f 100755 --- a/Tests/enterprise-tests/dashboard/UserLogout.test.ts +++ b/Tests/enterprise-tests/dashboard/UserLogout.test.ts @@ -11,7 +11,7 @@ const user: $TSFixMe = { }; describe('User logout', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/enterprise-tests/http-test-server/homePage.test.ts b/Tests/enterprise-tests/http-test-server/homePage.test.ts index cf05bf2b94..e5fc9dc143 100644 --- a/Tests/enterprise-tests/http-test-server/homePage.test.ts +++ b/Tests/enterprise-tests/http-test-server/homePage.test.ts @@ -55,7 +55,7 @@ describe('HTTP Home page', () => { waitUntil: 'networkidle2', }); await page.waitForSelector('#html > span'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#html > span', (e: $TSFixMe) => { diff --git a/Tests/enterprise-tests/http-test-server/settings.test.ts b/Tests/enterprise-tests/http-test-server/settings.test.ts index e513b6aae2..d8e225f7b4 100644 --- a/Tests/enterprise-tests/http-test-server/settings.test.ts +++ b/Tests/enterprise-tests/http-test-server/settings.test.ts @@ -47,7 +47,7 @@ describe('HTTP Settings page', () => { await page.waitForSelector('#save-btn'); await page.waitForSelector('#errorMsg > label > span'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#errorMsg > label > span', (e: $TSFixMe) => { @@ -84,7 +84,7 @@ describe('HTTP Settings page', () => { await page.waitForSelector('#save-btn'); await page.waitForSelector('#errorMsg > label > span'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#errorMsg > label > span', (e: $TSFixMe) => { @@ -121,7 +121,7 @@ describe('HTTP Settings page', () => { await page.waitForSelector('#save-btn'); await page.waitForSelector('#errorMsg > label > span'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#errorMsg > label > span', (e: $TSFixMe) => { @@ -164,7 +164,7 @@ describe('HTTP Settings page', () => { waitUntil: 'networkidle2', }); await page.waitForSelector('#html > span'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#html > span', (e: $TSFixMe) => { diff --git a/Tests/enterprise-tests/http-test-server/test-utils.ts b/Tests/enterprise-tests/http-test-server/test-utils.ts index 3355384e07..c09a75aa84 100755 --- a/Tests/enterprise-tests/http-test-server/test-utils.ts +++ b/Tests/enterprise-tests/http-test-server/test-utils.ts @@ -18,7 +18,7 @@ const puppeteerLaunchConfig: $TSFixMe = { ], }; -const user = faker.helpers.createCard(); +const user: $TSFixMe = faker.helpers.createCard(); function generateRandomString(): void { return Math.random().toString(36).substring(10); diff --git a/Tests/enterprise-tests/licensing/license.test.ts b/Tests/enterprise-tests/licensing/license.test.ts index ed7094aef7..06fb58ca2a 100644 --- a/Tests/enterprise-tests/licensing/license.test.ts +++ b/Tests/enterprise-tests/licensing/license.test.ts @@ -17,7 +17,7 @@ describe('License API', function (): void { this.timeout(20000); before(async () => { - const licenses = await AirtableService.create({ + const licenses: $TSFixMe = await AirtableService.create({ tableName, fields: [{ fields: validLicense }, { fields: expiredLicense }], }); diff --git a/Tests/enterprise-tests/server/server.test.ts b/Tests/enterprise-tests/server/server.test.ts index e1301d70e6..c10df1e2da 100644 --- a/Tests/enterprise-tests/server/server.test.ts +++ b/Tests/enterprise-tests/server/server.test.ts @@ -21,7 +21,7 @@ describe('Check Enterprise Server', () => { await page.goto(`${utils.BACKEND_URL}/server/is-saas-service`, { waitUntil: 'networkidle2', }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, 'body > pre', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/accounts/accounts.test.ts b/Tests/saas-tests/accounts/accounts.test.ts index 9c8ef30891..ee80480725 100644 --- a/Tests/saas-tests/accounts/accounts.test.ts +++ b/Tests/saas-tests/accounts/accounts.test.ts @@ -37,10 +37,10 @@ describe('Login API', () => { await init.saasLogout(page); await init.loginUser(user, page); // Items required are only available when 'loginUser' is initiated. - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } diff --git a/Tests/saas-tests/accounts/changePassword.test.ts b/Tests/saas-tests/accounts/changePassword.test.ts index ce498d1b92..6161a37f63 100644 --- a/Tests/saas-tests/accounts/changePassword.test.ts +++ b/Tests/saas-tests/accounts/changePassword.test.ts @@ -57,7 +57,7 @@ describe('Change Password API', () => { page, '#confirmPasswordField > span > span:nth-child(2)' ); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#confirmPasswordField > span > span:nth-child(2)', (e: $TSFixMe) => { @@ -98,7 +98,7 @@ describe('Change Password API', () => { page, '#passwordField > span > span:nth-child(1)' ); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#passwordField > span > span:nth-child(2)', (e: $TSFixMe) => { @@ -139,7 +139,7 @@ describe('Change Password API', () => { page, '#passwordField > span > span:nth-child(1)' ); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#passwordField > span > span:nth-child(2)', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/accounts/login.test.ts b/Tests/saas-tests/accounts/login.test.ts index fba8763a5d..c0ceeff62b 100755 --- a/Tests/saas-tests/accounts/login.test.ts +++ b/Tests/saas-tests/accounts/login.test.ts @@ -53,13 +53,13 @@ describe('Login API', () => { visible: true, timeout: init.timeout, }); - const email = await init.page$Eval( + const email: $TSFixMe = await init.page$Eval( page, 'input[name=email]', (element: $TSFixMe) => element.value ); expect(email).toEqual(''); - const password = await init.page$Eval( + const password: $TSFixMe = await init.page$Eval( page, 'input[name=password]', (element: $TSFixMe) => element.value @@ -89,7 +89,7 @@ describe('Login API', () => { await init.pageClick(page, 'button[type=submit]'); await init.pageWaitForSelector(page, '#loginError'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#main-body', (e: $TSFixMe) => { @@ -114,10 +114,10 @@ describe('Login API', () => { timeout: init.timeout, }); - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } @@ -134,7 +134,8 @@ describe('Login API', () => { it( 'Should login valid User (even if the user uses 127.0.0.1 instead of localhost) ', async () => { - const context = await browser.createIncognitoBrowserContext(); + const context: $TSFixMe = + await browser.createIncognitoBrowserContext(); page = await context.newPage(); await init.loginUser( @@ -149,10 +150,10 @@ describe('Login API', () => { timeout: init.timeout, }); - const localStorageData = await page.evaluate(() => { + const localStorageData: $TSFixMe = await page.evaluate(() => { const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key = localStorage.key(i); + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); json[key] = localStorage.getItem(key); } diff --git a/Tests/saas-tests/accounts/register.test.ts b/Tests/saas-tests/accounts/register.test.ts index 0d8003d243..dbc5b13c29 100755 --- a/Tests/saas-tests/accounts/register.test.ts +++ b/Tests/saas-tests/accounts/register.test.ts @@ -76,7 +76,7 @@ describe('Registration API', () => { await init.pageClick(page, 'button[type=submit]'); await init.pageWaitForSelector(page, '#email_error'); - const errorMsg = await init.page$Eval( + const errorMsg: $TSFixMe = await init.page$Eval( page, '#email_error', (elem: $TSFixMe) => elem.textContent @@ -95,7 +95,7 @@ describe('Registration API', () => { password: '1234567890', }; await init.registerFailedUser(user, page); - const errorMsg = await init.page$Eval( + const errorMsg: $TSFixMe = await init.page$Eval( page, '#error', // The previous validation is no longer in use. (elem: $TSFixMe) => elem.textContent @@ -158,7 +158,7 @@ describe('Registration API', () => { await init.pageClick(page, '#signUpLink a'); await init.pageWaitForSelector(page, 'input[name=email]'); - const email = await init.page$Eval( + const email: $TSFixMe = await init.page$Eval( page, 'input[name=email]', (element: $TSFixMe) => element.value @@ -228,7 +228,7 @@ describe('Registration API', () => { await init.pageClick(page, '#signUpLink a'); await init.pageWaitForSelector(page, 'input[name=email]'); - const email = await init.page$Eval( + const email: $TSFixMe = await init.page$Eval( page, 'input[name=email]', (element: $TSFixMe) => element.value @@ -244,7 +244,7 @@ describe('Registration API', () => { await init.registerUser(user, page); await init.pageWaitForSelector(page, '#titleText'); - const innerText = await init.page$Eval( + const innerText: $TSFixMe = await init.page$Eval( page, '#cbHome', (elem: $TSFixMe) => elem.innerText diff --git a/Tests/saas-tests/accounts/resetPassword.test.ts b/Tests/saas-tests/accounts/resetPassword.test.ts index 3c62b64bcb..45db364d25 100755 --- a/Tests/saas-tests/accounts/resetPassword.test.ts +++ b/Tests/saas-tests/accounts/resetPassword.test.ts @@ -45,7 +45,7 @@ describe('Reset Password API', () => { await init.pageClick(page, 'button[type=submit]'); await init.pageWaitForSelector(page, '#reset-password-success'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#reset-password-success', (e: $TSFixMe) => { @@ -80,7 +80,7 @@ describe('Reset Password API', () => { await init.pageClick(page, 'button[type=submit]'); await init.pageWaitForSelector(page, '#error-msg'); - const html = await init.page$Eval( + const html: $TSFixMe = await init.page$Eval( page, '#error-msg', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/accounts/userRedirectRegister.test.ts b/Tests/saas-tests/accounts/userRedirectRegister.test.ts index 9c02231ae6..aa3cb2ca83 100644 --- a/Tests/saas-tests/accounts/userRedirectRegister.test.ts +++ b/Tests/saas-tests/accounts/userRedirectRegister.test.ts @@ -5,14 +5,14 @@ import init from '../../test-init'; import axios from 'axios'; -let page, browser: $TSFixMe; +let page: $TSFixMe, browser: $TSFixMe; // user credentials const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; const queryString: string = '?utm_source=runningtest&good=thankyou&kill=love&ion=pure'; -let queryObj = {}; +let queryObj: $TSFixMe = {}; describe('Home redirect', () => { beforeAll(async (done: $TSFixMe) => { diff --git a/Tests/saas-tests/admin-dashboard/Project.test.ts b/Tests/saas-tests/admin-dashboard/Project.test.ts index ba9a15d0f4..208ea7911e 100644 --- a/Tests/saas-tests/admin-dashboard/Project.test.ts +++ b/Tests/saas-tests/admin-dashboard/Project.test.ts @@ -17,7 +17,7 @@ const user: $TSFixMe = { let projectId: ObjectID = null; describe('Project', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -58,13 +58,17 @@ describe('Project', () => { await init.pageWaitForSelector(page, '.Table > tbody tr'); - const project = await init.pageWaitForSelector(page, '.projectId'); + const project: $TSFixMe = await init.pageWaitForSelector( + page, + '.projectId' + ); projectId = await ( await project.getProperty('innerText') ).jsonValue(); await page.evaluate(() => { - let elem = document.querySelectorAll('.Table > tbody tr'); + let elem: $TSFixMe = + document.querySelectorAll('.Table > tbody tr'); elem = Array.from(elem); @@ -89,7 +93,7 @@ describe('Project', () => { await page.reload({ waitUntil: 'networkidle0' }); - const checked = await init.page$Eval( + const checked: $TSFixMe = await init.page$Eval( page, '#Enterprise', (elem: $TSFixMe) => elem.checked @@ -127,13 +131,17 @@ describe('Project', () => { elem.click() ); - const loader = await init.pageWaitForSelector(page, '.ball-beat', { - hidden: true, - }); + const loader: $TSFixMe = await init.pageWaitForSelector( + page, + '.ball-beat', + { + hidden: true, + } + ); await page.reload({ waitUntil: 'networkidle0' }); - const checked = await init.page$Eval( + const checked: $TSFixMe = await init.page$Eval( page, '#Growth_annual', (elem: $TSFixMe) => elem.checked diff --git a/Tests/saas-tests/admin-dashboard/SMTPSettings.test.ts b/Tests/saas-tests/admin-dashboard/SMTPSettings.test.ts index 4115d6f1ef..802dbcef43 100644 --- a/Tests/saas-tests/admin-dashboard/SMTPSettings.test.ts +++ b/Tests/saas-tests/admin-dashboard/SMTPSettings.test.ts @@ -15,7 +15,7 @@ const smtpName: string = 'Hackerbay'; const wrongPassword: string = utils.generateRandomString(); describe('SMTP Settings API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -33,7 +33,7 @@ describe('SMTP Settings API', () => { await init.loginAdminUser(user, page); // delete existing smtp details, if there is any. - const data = JSON.stringify({ + const data: $TSFixMe = JSON.stringify({ collection: 'globalconfigs', query: {}, }); @@ -73,7 +73,7 @@ describe('SMTP Settings API', () => { await init.pageClick(page, '#customSmtp'); - const originalValues = await init.page$$Eval( + const originalValues: $TSFixMe = await init.page$$Eval( page, 'input', (e: $TSFixMe) => e.map((field: $TSFixMe) => field.value) @@ -196,7 +196,7 @@ describe('SMTP Settings API', () => { await page.reload(); - const value = await init.page$Eval( + const value: $TSFixMe = await init.page$Eval( page, 'input[name=email]', (e: $TSFixMe) => e.value diff --git a/Tests/saas-tests/admin-dashboard/Sso.test.ts b/Tests/saas-tests/admin-dashboard/Sso.test.ts index 52f5086ca6..659700a06a 100644 --- a/Tests/saas-tests/admin-dashboard/Sso.test.ts +++ b/Tests/saas-tests/admin-dashboard/Sso.test.ts @@ -56,7 +56,7 @@ const createSso: Function = async (page: $TSFixMe, data: $TSFixMe): void => { }; describe('SSO API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; afterAll(async (done: $TSFixMe) => { /**This takes care of the closing the browser when the test is complete */ @@ -116,7 +116,7 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#sso-domain'); - const ssoCountAfterCreation = await init.page$Eval( + const ssoCountAfterCreation: $TSFixMe = await init.page$Eval( page, '#sso-count', (e: $TSFixMe) => { @@ -126,9 +126,13 @@ describe('SSO API', () => { expect(ssoCountAfterCreation).toContain('1'); - const tbody = await init.page$Eval(page, 'tbody', (e: $TSFixMe) => { - return e.innerHTML; - }); + const tbody: $TSFixMe = await init.page$Eval( + page, + 'tbody', + (e: $TSFixMe) => { + return e.innerHTML; + } + ); expect(tbody).toContain('test.hackerbay.io'); @@ -148,7 +152,7 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#sso-count'); - const ssoCountAfterCreation = await init.page$Eval( + const ssoCountAfterCreation: $TSFixMe = await init.page$Eval( page, '#sso-count', (e: $TSFixMe) => { @@ -176,9 +180,13 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#sso-domain'); - const tbody = await init.page$Eval(page, 'tbody', (e: $TSFixMe) => { - return e.innerHTML; - }); + const tbody: $TSFixMe = await init.page$Eval( + page, + 'tbody', + (e: $TSFixMe) => { + return e.innerHTML; + } + ); expect(tbody).toContain('updated.test.hackerbay.io'); done(); @@ -194,7 +202,7 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#sso-count'); - const count = await init.page$Eval( + const count: $TSFixMe = await init.page$Eval( page, '#sso-count', (e: $TSFixMe) => { @@ -215,17 +223,16 @@ describe('SSO API', () => { await page.reload({ waitUntil: 'networkidle2' }); } - const ssoMessage = await init.pageWaitForSelector( + const ssoMessage: $TSFixMe = await init.pageWaitForSelector( page, '#no-sso-message' ); // 'No SSO created yet' is rendered when none is available expect(ssoMessage).toBeDefined(); - const ssoCountAfterDeletion = await init.pageWaitForSelector( - page, - '#sso-count', - { hidden: true } - ); + const ssoCountAfterDeletion: $TSFixMe = + await init.pageWaitForSelector(page, '#sso-count', { + hidden: true, + }); expect(ssoCountAfterDeletion).toBeNull(); done(); @@ -241,7 +248,7 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#no-sso-message'); - for (let i = 0; i <= 11; i++) { + for (let i: $TSFixMe = 0; i <= 11; i++) { await createSso(page, { domain: `subdomain.${i}.test.hackerbay.io`, entityId: 'hackerbay.io', //Updated UI @@ -254,7 +261,7 @@ describe('SSO API', () => { await init.pageWaitForSelector(page, '#sso-domain'); - const ssoCount = await init.page$Eval( + const ssoCount: $TSFixMe = await init.page$Eval( page, '#sso-count', (e: $TSFixMe) => { @@ -264,7 +271,7 @@ describe('SSO API', () => { expect(ssoCount).toContain('12'); - const firstPageTbody = await init.page$Eval( + const firstPageTbody: $TSFixMe = await init.page$Eval( page, 'tbody', (e: $TSFixMe) => { @@ -276,7 +283,7 @@ describe('SSO API', () => { await init.pageClick(page, '#next-button'); - const secondPageTbody = await init.page$Eval( + const secondPageTbody: $TSFixMe = await init.page$Eval( page, 'tbody', (e: $TSFixMe) => { @@ -288,7 +295,7 @@ describe('SSO API', () => { await init.pageClick(page, '#previous-button'); - const initalPageTbody = await init.page$Eval( + const initalPageTbody: $TSFixMe = await init.page$Eval( page, 'tbody', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/admin-dashboard/User.test.ts b/Tests/saas-tests/admin-dashboard/User.test.ts index 997416806f..77aa2e7d20 100644 --- a/Tests/saas-tests/admin-dashboard/User.test.ts +++ b/Tests/saas-tests/admin-dashboard/User.test.ts @@ -11,7 +11,7 @@ const password: string = '1234567890'; const createUserMail: Email = utils.generateRandomBusinessEmail(); describe('SMTP Settings API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -49,7 +49,10 @@ describe('SMTP Settings API', () => { await init.pageWaitForSelector(page, '.bs-ObjectList-rows > a'); - const users = await init.page$$(page, '.bs-ObjectList-rows > a'); + const users: $TSFixMe = await init.page$$( + page, + '.bs-ObjectList-rows > a' + ); await users[1].click(); await init.pageWaitForSelector(page, '#disableUser2fa'); @@ -78,10 +81,16 @@ describe('SMTP Settings API', () => { await init.pageWaitForSelector(page, '.bs-ObjectList-rows > a'); - const users = await init.page$$(page, '.bs-ObjectList-rows > a'); + const users: $TSFixMe = await init.page$$( + page, + '.bs-ObjectList-rows > a' + ); await users[0].click(); - const elem = await init.isElementOnPage(page, '#disableUser2fa'); + const elem: $TSFixMe = await init.isElementOnPage( + page, + '#disableUser2fa' + ); expect(elem).toEqual(false); done(); }, diff --git a/Tests/saas-tests/api-docs/api-docs.test.ts b/Tests/saas-tests/api-docs/api-docs.test.ts index bd6cf57599..2cb5a7b7e5 100644 --- a/Tests/saas-tests/api-docs/api-docs.test.ts +++ b/Tests/saas-tests/api-docs/api-docs.test.ts @@ -25,7 +25,7 @@ describe('Check ApiDocs up', () => { await page.goto(utils.APIDOCS_URL, { waitUntil: 'domcontentloaded', }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, 'head > title', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/backend/backend.test.ts b/Tests/saas-tests/backend/backend.test.ts index fadfe6e5c5..b80d118f44 100644 --- a/Tests/saas-tests/backend/backend.test.ts +++ b/Tests/saas-tests/backend/backend.test.ts @@ -22,7 +22,7 @@ describe('Check Backend', () => { await page.goto(utils.BACKEND_URL + '/api', { waitUntil: 'networkidle2', }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, 'body > pre', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/backend/env-var.test.ts b/Tests/saas-tests/backend/env-var.test.ts index 90dd57b93a..5f06df8e94 100644 --- a/Tests/saas-tests/backend/env-var.test.ts +++ b/Tests/saas-tests/backend/env-var.test.ts @@ -21,7 +21,7 @@ describe('Check Server', () => { await page.goto(`${utils.BACKEND_URL}/server/hosts`, { waitUntil: 'networkidle2', }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, 'body > pre', (e: $TSFixMe) => { @@ -55,7 +55,7 @@ describe('Check Server', () => { await page.goto(`${utils.BACKEND_URL}/server/is-saas-service`, { waitUntil: 'networkidle2', }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, 'body > pre', (e: $TSFixMe) => { diff --git a/Tests/saas-tests/dashboard/ApplicationLog2.test.ts b/Tests/saas-tests/dashboard/ApplicationLog2.test.ts index b177c1859a..3042b96b62 100644 --- a/Tests/saas-tests/dashboard/ApplicationLog2.test.ts +++ b/Tests/saas-tests/dashboard/ApplicationLog2.test.ts @@ -11,7 +11,7 @@ const user: $TSFixMe = { }; const componentName: string = utils.generateRandomString(); const applicationLogName: string = utils.generateRandomString(); -let applicationLogKey = ''; +let applicationLogKey: $TSFixMe = ''; describe('Log Containers', () => { const operationTimeOut: $TSFixMe = init.timeout; diff --git a/Tests/saas-tests/dashboard/ApplicationSecurity.test.ts b/Tests/saas-tests/dashboard/ApplicationSecurity.test.ts index 8e28d0dbaf..cb89a9e510 100644 --- a/Tests/saas-tests/dashboard/ApplicationSecurity.test.ts +++ b/Tests/saas-tests/dashboard/ApplicationSecurity.test.ts @@ -12,7 +12,7 @@ const component: string = 'TestComponent'; const applicationSecurityName: string = 'Test'; describe('Application Security Page', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(600000); @@ -38,9 +38,10 @@ describe('Application Security Page', () => { test( 'should create an application security with a resource category and ensure it redirects to the details page and has category attached', async (done: $TSFixMe) => { - const gitUsername = utils.gitCredential.gitUsername; - const gitPassword = utils.gitCredential.gitPassword; - const gitRepositoryUrl = utils.gitCredential.gitRepositoryUrl; + const gitUsername: $TSFixMe = utils.gitCredential.gitUsername; + const gitPassword: $TSFixMe = utils.gitCredential.gitPassword; + const gitRepositoryUrl: $TSFixMe = + utils.gitCredential.gitRepositoryUrl; await init.addComponent(component, page); @@ -110,19 +111,21 @@ describe('Application Security Page', () => { await init.pageWaitForSelector(page, '.ball-beat', { hidden: true, }); - const applicationSecurity = await init.pageWaitForSelector( - page, - `#applicationSecurityHeader_${applicationSecurityName}`, - { visible: true, timeout: init.timeout } - ); + const applicationSecurity: $TSFixMe = + await init.pageWaitForSelector( + page, + `#applicationSecurityHeader_${applicationSecurityName}`, + { visible: true, timeout: init.timeout } + ); expect(applicationSecurity).toBeDefined(); // find the edit button which appears only on the details page - const editApplicationElement = await init.pageWaitForSelector( - page, - `#edit_${applicationSecurityName}` - ); + const editApplicationElement: $TSFixMe = + await init.pageWaitForSelector( + page, + `#edit_${applicationSecurityName}` + ); expect(editApplicationElement).toBeDefined(); // confirm the category shows in the details page. @@ -183,10 +186,14 @@ describe('Application Security Page', () => { page, `#moreApplicationSecurity_${applicationSecurityName}` ); - const issueCount = await init.pageWaitForSelector(page, '#issueCount', { - visible: true, - timeout: init.timeout, - }); + const issueCount: $TSFixMe = await init.pageWaitForSelector( + page, + '#issueCount', + { + visible: true, + timeout: init.timeout, + } + ); expect(issueCount).toBeDefined(); done(); @@ -231,7 +238,7 @@ describe('Application Security Page', () => { page, `#moreApplicationSecurity_${applicationSecurityName}` ); - const securityLog = await init.pageWaitForSelector( + const securityLog: $TSFixMe = await init.pageWaitForSelector( page, '#securityLog', { @@ -283,7 +290,7 @@ describe('Application Security Page', () => { ); await init.pageClick(page, '#issueCount'); - const securityLog = await init.pageWaitForSelector( + const securityLog: $TSFixMe = await init.pageWaitForSelector( page, '#securityLog', { @@ -346,7 +353,10 @@ describe('Application Security Page', () => { // make sure the added application security // has atleast one security vulnerability - const logs = await init.page$$(page, '#securityLog tbody tr'); + const logs: $TSFixMe = await init.page$$( + page, + '#securityLog tbody tr' + ); expect(logs.length).toBeGreaterThanOrEqual(1); done(); @@ -427,7 +437,7 @@ describe('Application Security Page', () => { } ); - const textContent = await init.page$Eval( + const textContent: $TSFixMe = await init.page$Eval( page, `#applicationSecurityTitle_${newApplicationName}`, (elem: $TSFixMe) => elem.textContent @@ -503,11 +513,12 @@ describe('Application Security Page', () => { await init.pageClick(page, '#deleteApplicationSecurityModalBtn'); - const applicationSecurity = await init.pageWaitForSelector( - page, - `#applicationSecurityHeader_${newApplicationName}`, - { hidden: true } - ); + const applicationSecurity: $TSFixMe = + await init.pageWaitForSelector( + page, + `#applicationSecurityHeader_${newApplicationName}`, + { hidden: true } + ); expect(applicationSecurity).toBeNull(); done(); diff --git a/Tests/saas-tests/dashboard/ApplicationSecurityReload.test.ts b/Tests/saas-tests/dashboard/ApplicationSecurityReload.test.ts index 2e518b2508..f66cacd220 100644 --- a/Tests/saas-tests/dashboard/ApplicationSecurityReload.test.ts +++ b/Tests/saas-tests/dashboard/ApplicationSecurityReload.test.ts @@ -10,9 +10,9 @@ const user: $TSFixMe = { const componentName: string = utils.generateRandomString(); const applicationSecurityName: string = utils.generateRandomString(); -const gitUsername = utils.gitCredential.gitUsername; -const gitPassword = utils.gitCredential.gitPassword; -const gitRepositoryUrl = utils.gitCredential.gitRepositoryUrl; +const gitUsername: $TSFixMe = utils.gitCredential.gitUsername; +const gitPassword: $TSFixMe = utils.gitCredential.gitPassword; +const gitRepositoryUrl: $TSFixMe = utils.gitCredential.gitRepositoryUrl; /** This is a test to check: * No errors on page reload @@ -20,7 +20,7 @@ const gitRepositoryUrl = utils.gitCredential.gitRepositoryUrl; */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -108,11 +108,12 @@ describe('OneUptime Page Reload', () => { await init.pageWaitForSelector(page, '.ball-beat', { hidden: true, }); - const applicationSecurity = await init.pageWaitForSelector( - page, - `#applicationSecurityHeader_${applicationSecurityName}`, - { visible: true, timeout: init.timeout } - ); + const applicationSecurity: $TSFixMe = + await init.pageWaitForSelector( + page, + `#applicationSecurityHeader_${applicationSecurityName}`, + { visible: true, timeout: init.timeout } + ); expect(applicationSecurity).toBeDefined(); // To confirm no errors and stays on the same page on reload @@ -134,7 +135,7 @@ describe('OneUptime Page Reload', () => { } ); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, `#applicationSecurityTitle_${applicationSecurityName}` ); diff --git a/Tests/saas-tests/dashboard/Billing.test.ts b/Tests/saas-tests/dashboard/Billing.test.ts index 41a80e4fc2..3fad426370 100644 --- a/Tests/saas-tests/dashboard/Billing.test.ts +++ b/Tests/saas-tests/dashboard/Billing.test.ts @@ -15,7 +15,7 @@ const subProjectName: string = 'Trial'; let browser: $TSFixMe, page: $TSFixMe; describe('Project Setting: Change Plan', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(360000); @@ -46,7 +46,7 @@ describe('Project Setting: Change Plan', () => { await page.reload({ waitUntil: 'networkidle0' }); await init.pageWaitForSelector(page, 'input#Growth_month'); - const checked = await init.page$Eval( + const checked: $TSFixMe = await init.page$Eval( page, 'input#Growth_month', (input: $TSFixMe) => input.checked @@ -59,8 +59,8 @@ describe('Project Setting: Change Plan', () => { test( 'should not update project account when admin recharge account with negative number', async (done: $TSFixMe) => { - const balance = 0; - let creditedBalance = 0; + const balance: $TSFixMe = 0; + let creditedBalance: $TSFixMe = 0; await page.goto(utils.DASHBOARD_URL); await init.pageWaitForSelector(page, '#projectSettings', { visible: true, @@ -122,7 +122,7 @@ describe('Project Setting: Change Plan', () => { test( 'should update project account when admin recharge account', async (done: $TSFixMe) => { - let balance = 0, + let balance: $TSFixMe = 0, creditedBalance = 0; await page.goto(utils.DASHBOARD_URL); await init.pageWaitForSelector(page, '#projectSettings', { @@ -210,8 +210,8 @@ describe('Project Setting: Change Plan', () => { test( 'should not update project account when admin recharge account and clicks cancel', async (done: $TSFixMe) => { - const balance = 0; - let creditedBalance = 0; + const balance: $TSFixMe = 0; + let creditedBalance: $TSFixMe = 0; await page.goto(utils.DASHBOARD_URL); await init.pageWaitForSelector(page, '#projectSettings', { visible: true, @@ -277,7 +277,7 @@ describe('Project Setting: Change Plan', () => { }); describe('Member Restriction', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -350,7 +350,7 @@ describe('Member Restriction', () => { ); await init.pageClick(page, '#alertOptionSave'); - const unauthorisedModal = await init.pageWaitForSelector( + const unauthorisedModal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { visible: true, timeout: init.timeout } @@ -384,7 +384,7 @@ describe('Member Restriction', () => { await init.pageType(page, '#rechargeBalanceAmount', '20'); await init.pageClick(page, '#rechargeAccount'); - const unauthorisedModal = await init.pageWaitForSelector( + const unauthorisedModal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { visible: true, timeout: init.timeout } @@ -418,7 +418,7 @@ describe('Member Restriction', () => { await init.pageClick(page, 'input#Startup_month'); await init.pageClick(page, '#changePlanBtn'); - const unauthorisedModal = await init.pageWaitForSelector( + const unauthorisedModal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { visible: true, timeout: init.timeout } diff --git a/Tests/saas-tests/dashboard/BillingReload.test.ts b/Tests/saas-tests/dashboard/BillingReload.test.ts index 845e5cbbd4..b12c635c73 100644 --- a/Tests/saas-tests/dashboard/BillingReload.test.ts +++ b/Tests/saas-tests/dashboard/BillingReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -66,7 +66,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#Startup_month', { diff --git a/Tests/saas-tests/dashboard/CallRoutingReload.test.ts b/Tests/saas-tests/dashboard/CallRoutingReload.test.ts index 7ed977530d..19459be64c 100644 --- a/Tests/saas-tests/dashboard/CallRoutingReload.test.ts +++ b/Tests/saas-tests/dashboard/CallRoutingReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -55,7 +55,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#cbCallRouting', { diff --git a/Tests/saas-tests/dashboard/Component2.test.ts b/Tests/saas-tests/dashboard/Component2.test.ts index 2666438369..ba4e881736 100644 --- a/Tests/saas-tests/dashboard/Component2.test.ts +++ b/Tests/saas-tests/dashboard/Component2.test.ts @@ -14,7 +14,7 @@ const componentName: string = utils.generateRandomString(); let browser: $TSFixMe, page: $TSFixMe; describe('Components', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -42,10 +42,8 @@ describe('Components', () => { waitUntil: 'networkidle0', }); - const componentBoxElement = await init.pageWaitForSelector( - page, - '#info-teamMember' - ); + const componentBoxElement: $TSFixMe = + await init.pageWaitForSelector(page, '#info-teamMember'); expect(componentBoxElement).toBeDefined(); let spanElement; @@ -65,10 +63,8 @@ describe('Components', () => { e.click() ); - const componentFormElement = await init.pageWaitForSelector( - page, - `#teamMemberPage` - ); + const componentFormElement: $TSFixMe = + await init.pageWaitForSelector(page, `#teamMemberPage`); expect(componentFormElement).toBeDefined(); done(); }, @@ -83,10 +79,8 @@ describe('Components', () => { waitUntil: 'networkidle0', }); - const componentBoxElement = await init.pageWaitForSelector( - page, - '#info-component' - ); + const componentBoxElement: $TSFixMe = + await init.pageWaitForSelector(page, '#info-component'); expect(componentBoxElement).toBeDefined(); let spanElement; @@ -106,10 +100,8 @@ describe('Components', () => { e.click() ); - const componentFormElement = await init.pageWaitForSelector( - page, - '#form-new-component' - ); + const componentFormElement: $TSFixMe = + await init.pageWaitForSelector(page, '#form-new-component'); expect(componentFormElement).toBeDefined(); done(); }, @@ -167,7 +159,7 @@ describe('Components', () => { waitUntil: 'networkidle0', }); - const monitorBoxElement = await init.pageWaitForSelector( + const monitorBoxElement: $TSFixMe = await init.pageWaitForSelector( page, '#info-monitor' ); @@ -233,7 +225,7 @@ describe('Components', () => { visible: true, timeout: init.timeout, }); - const projectBreadcrumb = await page.evaluate( + const projectBreadcrumb: $TSFixMe = await page.evaluate( (projectSelector: $TSFixMe) => document.querySelector(projectSelector).textContent, projectSelector @@ -242,7 +234,7 @@ describe('Components', () => { visible: true, timeout: init.timeout, }); - const componentBreadcrumb = await page.evaluate( + const componentBreadcrumb: $TSFixMe = await page.evaluate( (componentSelector: $TSFixMe) => document.querySelector(componentSelector).textContent, componentSelector @@ -303,10 +295,11 @@ describe('Components', () => { const customTutorialType: string = 'monitor'; // confirm that monitor box exist on component details page - const componentBoxElement = await init.pageWaitForSelector( - page, - `#info-${customTutorialType}` - ); + const componentBoxElement: $TSFixMe = + await init.pageWaitForSelector( + page, + `#info-${customTutorialType}` + ); expect(componentBoxElement).toBeDefined(); done(); }, diff --git a/Tests/saas-tests/dashboard/Component3.test.ts b/Tests/saas-tests/dashboard/Component3.test.ts index 04283ee3c2..d9e307ca09 100644 --- a/Tests/saas-tests/dashboard/Component3.test.ts +++ b/Tests/saas-tests/dashboard/Component3.test.ts @@ -19,7 +19,7 @@ let browser: $TSFixMe, monitorPage: $TSFixMe; describe('Components', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -150,7 +150,9 @@ describe('Components', () => { ); await monitorPage.waitForSelector('#ResolveText_0'); // confirm it is resolved here - const resolveTextSelector = await monitorPage.$('#ResolveText_0'); + const resolveTextSelector: $TSFixMe = await monitorPage.$( + '#ResolveText_0' + ); expect(resolveTextSelector).not.toBeNull(); // goto component page @@ -263,7 +265,7 @@ describe('Components', () => { await init.pageClick(page, '#deleteComponent'); // after deleting the component - const componentClicked = await init.pageWaitForSelector( + const componentClicked: $TSFixMe = await init.pageWaitForSelector( page, '#components', { @@ -437,8 +439,10 @@ describe('Components', () => { page, `#resource_status_${newMonitorName}` ); - const element = await page.$(`#resource_status_${newMonitorName}`); - const value = await page.evaluate( + const element: $TSFixMe = await page.$( + `#resource_status_${newMonitorName}` + ); + const value: $TSFixMe = await page.evaluate( (el: $TSFixMe) => el.textContent, element ); diff --git a/Tests/saas-tests/dashboard/ComponentReload.test.ts b/Tests/saas-tests/dashboard/ComponentReload.test.ts index 7a214df522..1815d11e9a 100644 --- a/Tests/saas-tests/dashboard/ComponentReload.test.ts +++ b/Tests/saas-tests/dashboard/ComponentReload.test.ts @@ -15,7 +15,7 @@ const componentName: string = utils.generateRandomString(); */ describe('OneUptime Component Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/ContainerSecurity.test.ts b/Tests/saas-tests/dashboard/ContainerSecurity.test.ts index 77b247be22..9f4fe1c5c7 100644 --- a/Tests/saas-tests/dashboard/ContainerSecurity.test.ts +++ b/Tests/saas-tests/dashboard/ContainerSecurity.test.ts @@ -14,7 +14,7 @@ const newContainerSecurityName: string = 'Byter'; let browser: $TSFixMe, page: $TSFixMe; describe('Container Security Page', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(operationTimeOut); @@ -40,11 +40,14 @@ describe('Container Security Page', () => { test( 'should create an application security with a resource category and ensure it redirects to the details page and has category attached', async (done: $TSFixMe) => { - const dockerRegistryUrl = utils.dockerCredential.dockerRegistryUrl; - const dockerUsername = utils.dockerCredential.dockerUsername; - const dockerPassword = utils.dockerCredential.dockerPassword; - const imagePath = utils.dockerCredential.imagePath; - const imageTags = utils.dockerCredential.imageTags || ''; + const dockerRegistryUrl: $TSFixMe = + utils.dockerCredential.dockerRegistryUrl; + const dockerUsername: $TSFixMe = + utils.dockerCredential.dockerUsername; + const dockerPassword: $TSFixMe = + utils.dockerCredential.dockerPassword; + const imagePath: $TSFixMe = utils.dockerCredential.imagePath; + const imageTags: $TSFixMe = utils.dockerCredential.imageTags || ''; await init.addComponent(component, page); @@ -122,7 +125,7 @@ describe('Container Security Page', () => { await init.pageWaitForSelector(page, '.ball-beat', { hidden: true, }); - const containerSecurity = await init.pageWaitForSelector( + const containerSecurity: $TSFixMe = await init.pageWaitForSelector( page, `#containerSecurityHeader_${containerSecurityName}`, { visible: true, timeout: init.timeout } @@ -131,10 +134,11 @@ describe('Container Security Page', () => { // find the edit button which appears only on the details page - const editContainerElement = await init.pageWaitForSelector( - page, - `#edit_${containerSecurityName}` - ); + const editContainerElement: $TSFixMe = + await init.pageWaitForSelector( + page, + `#edit_${containerSecurityName}` + ); expect(editContainerElement).toBeDefined(); // confirm the category shows in the details page. @@ -191,7 +195,7 @@ describe('Container Security Page', () => { page, `#moreContainerSecurity_${containerSecurityName}` ); - const issueCount = await init.pageWaitForSelector( + const issueCount: $TSFixMe = await init.pageWaitForSelector( page, '#vulnerabilities', { @@ -241,7 +245,7 @@ describe('Container Security Page', () => { page, `#moreContainerSecurity_${containerSecurityName}` ); - const securityLog = await init.pageWaitForSelector( + const securityLog: $TSFixMe = await init.pageWaitForSelector( page, '#securityLog', { @@ -291,7 +295,7 @@ describe('Container Security Page', () => { }); await init.pageClick(page, '#issueCount'); - const securityLog = await init.pageWaitForSelector( + const securityLog: $TSFixMe = await init.pageWaitForSelector( page, '#securityLog', { @@ -352,7 +356,10 @@ describe('Container Security Page', () => { // make sure the added container security // have atlest one security vulnerability - const logs = await init.page$$(page, '#securityLog tbody tr'); + const logs: $TSFixMe = await init.page$$( + page, + '#securityLog tbody tr' + ); expect(logs.length).toBeGreaterThanOrEqual(1); done(); @@ -421,7 +428,7 @@ describe('Container Security Page', () => { hidden: true, }); - const textContent = await init.page$Eval( + const textContent: $TSFixMe = await init.page$Eval( page, `#containerSecurityTitle_${newContainerSecurityName}`, (elem: $TSFixMe) => elem.textContent @@ -493,7 +500,7 @@ describe('Container Security Page', () => { await init.pageClick(page, '#deleteContainerSecurityModalBtn'); - const containerSecurity = await init.pageWaitForSelector( + const containerSecurity: $TSFixMe = await init.pageWaitForSelector( page, `#containerSecurityHeader_${newContainerSecurityName}`, { hidden: true } diff --git a/Tests/saas-tests/dashboard/CreateProject.test.ts b/Tests/saas-tests/dashboard/CreateProject.test.ts index 48a207239c..a1580f57a7 100755 --- a/Tests/saas-tests/dashboard/CreateProject.test.ts +++ b/Tests/saas-tests/dashboard/CreateProject.test.ts @@ -67,15 +67,17 @@ describe('Project API', () => { timeout: init.timeout, }); - const localStorageData = await page.evaluate((): $TSFixMe => { - const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key: $TSFixMe = localStorage.key(i); + const localStorageData: $TSFixMe = await page.evaluate( + (): $TSFixMe => { + const json: $TSFixMe = {}; + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); - json[key] = localStorage.getItem(key); + json[key] = localStorage.getItem(key); + } + return json; } - return json; - }); + ); localStorageData.should.have.property('project'); diff --git a/Tests/saas-tests/dashboard/Credential.test.ts b/Tests/saas-tests/dashboard/Credential.test.ts index 5479092d5c..b9329c391f 100644 --- a/Tests/saas-tests/dashboard/Credential.test.ts +++ b/Tests/saas-tests/dashboard/Credential.test.ts @@ -11,9 +11,9 @@ const password: string = '1234567890'; let browser: $TSFixMe, page: $TSFixMe; describe('Credential Page', () => { - const operationTimeOut = init.timeout; - const gitUsername = utils.gitCredential.gitUsername; - const gitPassword = utils.gitCredential.gitPassword; + const operationTimeOut: $TSFixMe = init.timeout; + const gitUsername: $TSFixMe = utils.gitCredential.gitUsername; + const gitPassword: $TSFixMe = utils.gitCredential.gitPassword; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(operationTimeOut); @@ -151,7 +151,7 @@ describe('Credential Page', () => { await init.pageClick(page, '#addCredentialModalBtn'); - const credentialModal = await init.pageWaitForSelector( + const credentialModal: $TSFixMe = await init.pageWaitForSelector( page, '#gitCredentialForm', { hidden: true } @@ -201,7 +201,7 @@ describe('Credential Page', () => { await init.pageWaitForSelector(page, '#gitCredentialForm', { hidden: true, }); - const updatedCredential = await init.pageWaitForSelector( + const updatedCredential: $TSFixMe = await init.pageWaitForSelector( page, `#gitUsername_${gitUsername}`, { visible: true, timeout: init.timeout } @@ -239,7 +239,10 @@ describe('Credential Page', () => { hidden: true, }); - const initialTableRow = await init.page$$(page, 'tbody tr'); + const initialTableRow: $TSFixMe = await init.page$$( + page, + 'tbody tr' + ); await init.pageClick(page, '#deleteCredentialBtn_0'); @@ -253,7 +256,7 @@ describe('Credential Page', () => { hidden: true, }); - const finalTableRow = await init.page$$(page, 'tbody tr'); + const finalTableRow: $TSFixMe = await init.page$$(page, 'tbody tr'); expect(initialTableRow.length).toEqual(finalTableRow.length); diff --git a/Tests/saas-tests/dashboard/Credential2.test.ts b/Tests/saas-tests/dashboard/Credential2.test.ts index 42edb75238..7c2388b483 100644 --- a/Tests/saas-tests/dashboard/Credential2.test.ts +++ b/Tests/saas-tests/dashboard/Credential2.test.ts @@ -11,10 +11,11 @@ const password: string = '1234567890'; let browser: $TSFixMe, page: $TSFixMe; describe('Credential Page', () => { - const operationTimeOut = init.timeout; - const dockerRegistryUrl = utils.dockerCredential.dockerRegistryUrl; - const dockerUsername = utils.dockerCredential.dockerUsername; - const dockerPassword = utils.dockerCredential.dockerPassword; + const operationTimeOut: $TSFixMe = init.timeout; + const dockerRegistryUrl: $TSFixMe = + utils.dockerCredential.dockerRegistryUrl; + const dockerUsername: $TSFixMe = utils.dockerCredential.dockerUsername; + const dockerPassword: $TSFixMe = utils.dockerCredential.dockerPassword; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(operationTimeOut); @@ -150,11 +151,10 @@ describe('Credential Page', () => { await init.pageClick(page, '#addCredentialModalBtn'); - const credentialModalForm = await init.pageWaitForSelector( - page, - '#dockerCredentialForm', - { hidden: true } - ); + const credentialModalForm: $TSFixMe = + await init.pageWaitForSelector(page, '#dockerCredentialForm', { + hidden: true, + }); expect(credentialModalForm).toBeNull(); done(); @@ -202,7 +202,7 @@ describe('Credential Page', () => { hidden: true, }); - const updatedCredential = await init.pageWaitForSelector( + const updatedCredential: $TSFixMe = await init.pageWaitForSelector( page, `#dockerUsername_${dockerUsername}`, { visible: true, timeout: init.timeout } @@ -253,11 +253,11 @@ describe('Credential Page', () => { await init.pageClick(page, '#updateCredentialModalBtn'); - const updateCredentialError = await init.pageWaitForSelector( - page, - '#updateCredentialError', - { visible: true, timeout: operationTimeOut } - ); + const updateCredentialError: $TSFixMe = + await init.pageWaitForSelector(page, '#updateCredentialError', { + visible: true, + timeout: operationTimeOut, + }); expect(updateCredentialError).toBeDefined(); done(); @@ -312,7 +312,7 @@ describe('Credential Page', () => { await init.pageClick(page, '#addCredentialModalBtn'); - const addCredentialError = await init.pageWaitForSelector( + const addCredentialError: $TSFixMe = await init.pageWaitForSelector( page, '#addCredentialError', { visible: true, timeout: operationTimeOut } @@ -350,7 +350,10 @@ describe('Credential Page', () => { hidden: true, }); - const initialTableRow = await init.page$$(page, 'tbody tr'); + const initialTableRow: $TSFixMe = await init.page$$( + page, + 'tbody tr' + ); await init.pageClick(page, '#deleteCredentialBtn_0'); @@ -364,7 +367,7 @@ describe('Credential Page', () => { hidden: true, }); - const finalTableRow = await init.page$$(page, 'tbody tr'); + const finalTableRow: $TSFixMe = await init.page$$(page, 'tbody tr'); expect(initialTableRow.length).toEqual(finalTableRow.length); diff --git a/Tests/saas-tests/dashboard/DashboardReload.test.ts b/Tests/saas-tests/dashboard/DashboardReload.test.ts index aa103d7d4c..ad60197613 100644 --- a/Tests/saas-tests/dashboard/DashboardReload.test.ts +++ b/Tests/saas-tests/dashboard/DashboardReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/DeleteAccount.test.ts b/Tests/saas-tests/dashboard/DeleteAccount.test.ts index d605aa4000..c3b1676731 100644 --- a/Tests/saas-tests/dashboard/DeleteAccount.test.ts +++ b/Tests/saas-tests/dashboard/DeleteAccount.test.ts @@ -18,7 +18,7 @@ const projectName: string = utils.generateRandomString(); const projectName2: string = utils.generateRandomString(); describe('Profile -> Delete Account Component test', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -113,7 +113,7 @@ describe('Profile -> Delete Account Component test', () => { await init.pageClick(page, '#btn_confirm_delete'); - const projectDeletion = await init.pageWaitForSelector( + const projectDeletion: $TSFixMe = await init.pageWaitForSelector( page, '#projectOwnership' // Updated UI ); @@ -183,7 +183,7 @@ describe('Profile -> Delete Account Component test', () => { await init.pageClick(page, '#btn_confirm_delete'); - const projectDeletion = await init.pageWaitForSelector( + const projectDeletion: $TSFixMe = await init.pageWaitForSelector( page, '#projectOwnership' ); @@ -208,7 +208,7 @@ describe('Profile -> Delete Account Component test', () => { await init.pageWaitForSelector(page, '#teamMembers'); await init.pageClick(page, '#teamMembers'); - const emailSelector = user1.email.split('@')[0]; + const emailSelector: $TSFixMe = user1.email.split('@')[0]; await init.pageClick(page, `#changeRole_${emailSelector}`); @@ -262,7 +262,7 @@ describe('Profile -> Delete Account Component test', () => { await init.pageClick(page, '#btn_confirm_delete'); - const projectDeletion = await init.pageWaitForSelector( + const projectDeletion: $TSFixMe = await init.pageWaitForSelector( page, '#projectDeletion' ); @@ -311,7 +311,7 @@ describe('Profile -> Delete Account Component test', () => { await init.pageClick(page, '#close'); await page.waitForNavigation(); - const url = await page.url(); + const url: $TSFixMe = await page.url(); expect(url).toEqual(`${utils.ACCOUNTS_URL}/accounts/login`); done(); diff --git a/Tests/saas-tests/dashboard/DomainsReload.test.ts b/Tests/saas-tests/dashboard/DomainsReload.test.ts index 28fdd99f91..bd1f64043f 100644 --- a/Tests/saas-tests/dashboard/DomainsReload.test.ts +++ b/Tests/saas-tests/dashboard/DomainsReload.test.ts @@ -16,7 +16,7 @@ const customDomain: string = `${utils.generateRandomString()}.com`; */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -64,7 +64,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#projectdomain_0', { diff --git a/Tests/saas-tests/dashboard/EmailSettingsReload.test.ts b/Tests/saas-tests/dashboard/EmailSettingsReload.test.ts index 97cabea178..e345a7db6d 100644 --- a/Tests/saas-tests/dashboard/EmailSettingsReload.test.ts +++ b/Tests/saas-tests/dashboard/EmailSettingsReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -57,7 +57,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#showsmtpForm', { diff --git a/Tests/saas-tests/dashboard/ErrorTracker.test.ts b/Tests/saas-tests/dashboard/ErrorTracker.test.ts index 1bf446ceaf..5bdc1479ac 100644 --- a/Tests/saas-tests/dashboard/ErrorTracker.test.ts +++ b/Tests/saas-tests/dashboard/ErrorTracker.test.ts @@ -11,7 +11,7 @@ const user: $TSFixMe = { }; const componentName: string = utils.generateRandomString(); const errorTrackerName: string = utils.generateRandomString(); -let errorTrackerKey = ''; +let errorTrackerKey: $TSFixMe = ''; describe('Error Trackers', () => { const operationTimeOut: $TSFixMe = init.timeout; diff --git a/Tests/saas-tests/dashboard/GitCredentialsReload.test.ts b/Tests/saas-tests/dashboard/GitCredentialsReload.test.ts index a47c67e3c3..20aa37f4ce 100644 --- a/Tests/saas-tests/dashboard/GitCredentialsReload.test.ts +++ b/Tests/saas-tests/dashboard/GitCredentialsReload.test.ts @@ -7,8 +7,8 @@ const user: $TSFixMe = { email: utils.generateRandomBusinessEmail(), password: '1234567890', }; -const gitUsername = utils.gitCredential.gitUsername; -const gitPassword = utils.gitCredential.gitPassword; +const gitUsername: $TSFixMe = utils.gitCredential.gitUsername; +const gitPassword: $TSFixMe = utils.gitCredential.gitPassword; /** This is a test to check: * No errors on page reload @@ -16,7 +16,7 @@ const gitPassword = utils.gitCredential.gitPassword; */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -54,7 +54,7 @@ describe('OneUptime Page Reload', () => { await init.pageClick(page, '#addCredentialModalBtn'); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, `#gitUsername_${gitUsername}` ); diff --git a/Tests/saas-tests/dashboard/IncidentNotification.test.ts b/Tests/saas-tests/dashboard/IncidentNotification.test.ts index 1143132358..54c62d9930 100644 --- a/Tests/saas-tests/dashboard/IncidentNotification.test.ts +++ b/Tests/saas-tests/dashboard/IncidentNotification.test.ts @@ -17,7 +17,7 @@ const user1: $TSFixMe = { let browser: $TSFixMe, page: $TSFixMe; describe('Incident Created test', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; const monitorName: string = utils.generateRandomString(); const monitorName2: string = utils.generateRandomString(); @@ -95,7 +95,7 @@ describe('Incident Created test', () => { e.click() ); await page.goto(utils.DASHBOARD_URL, { timeout: init.timeout }); - const closeAllButton = await init.pageWaitForSelector( + const closeAllButton: $TSFixMe = await init.pageWaitForSelector( page, '#incidents-close-all-btn', { hidden: true } @@ -118,7 +118,7 @@ describe('Incident Created test', () => { visible: true, timeout: init.timeout, }); - const closeAllButton = await init.pageWaitForSelector( + const closeAllButton: $TSFixMe = await init.pageWaitForSelector( page, '#incidents-close-all-btn', { visible: true, timeout: init.timeout } @@ -139,7 +139,7 @@ describe('Incident Created test', () => { '#incidents-close-all-btn', (elem: $TSFixMe) => elem.click() ); - const closeButton = await init.pageWaitForSelector( + const closeButton: $TSFixMe = await init.pageWaitForSelector( page, '#closeIncidentButton_0', { @@ -157,7 +157,7 @@ describe('Incident Created test', () => { await page.goto(utils.DASHBOARD_URL, { timeout: init.timeout }); await init.addIncident(monitorName, 'Degraded', page, 'Low'); - const viewIncidentButton = await init.pageWaitForSelector( + const viewIncidentButton: $TSFixMe = await init.pageWaitForSelector( page, 'button[id=viewIncident-0]', { visible: true, timeout: init.timeout } @@ -224,7 +224,7 @@ describe('Incident Created test', () => { await init.loginUser(user1, page); // Switch projects await init.switchProject(projectName, page); - const viewIncidentButton = await init.page$( + const viewIncidentButton: $TSFixMe = await init.page$( page, 'button[id=viewIncident-0]', { hidden: true } @@ -276,7 +276,7 @@ describe('Incident Created test', () => { await init.loginUser(user1, page); // Switch projects await init.switchProject(projectName, page); - const viewIncidentButton = await init.page$( + const viewIncidentButton: $TSFixMe = await init.page$( page, 'button[id=viewIncident-0]', { hidden: true } @@ -300,7 +300,7 @@ describe('Incident Created test', () => { await init.loginUser(user1, page); // Switch projects await init.switchProject(projectName, page); - const viewIncidentButton = await init.pageWaitForSelector( + const viewIncidentButton: $TSFixMe = await init.pageWaitForSelector( page, 'button[id=viewIncident-0]', { visible: true, timeout: init.timeout } @@ -355,7 +355,7 @@ describe('Incident Created test', () => { await init.page$Eval(page, '#closeIncident_0', (elem: $TSFixMe) => elem.click() ); - const closeButton = await init.pageWaitForSelector( + const closeButton: $TSFixMe = await init.pageWaitForSelector( page, '#closeIncident_0', { @@ -377,7 +377,7 @@ describe('Incident Created test', () => { await page.goto(utils.DASHBOARD_URL, { timeout: init.timeout }); await init.switchProject(projectName, page); - const viewIncidentButton = await init.page$( + const viewIncidentButton: $TSFixMe = await init.page$( page, 'button[id=viewIncident-0]' ); @@ -400,7 +400,7 @@ describe('Incident Created test', () => { await init.pageClick(page, '#activeIncidents'); await init.pageWaitForSelector(page, '.activeIncidentList'); - const activeIncidents = await init.page$$Eval( + const activeIncidents: $TSFixMe = await init.page$$Eval( page, '.activeIncidentList', (rows: $TSFixMe) => rows.length @@ -480,11 +480,11 @@ describe('Incident Created test', () => { await init.pageWaitForSelector(page, 'tr.createdIncidentListItem'); - const filteredIncidents = await init.page$$( + const filteredIncidents: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const filteredIncidentsCount = filteredIncidents.length; + const filteredIncidentsCount: $TSFixMe = filteredIncidents.length; expect(filteredIncidentsCount).toEqual(2); }, @@ -591,11 +591,11 @@ describe('Incident Created test', () => { await init.pageWaitForSelector(page, 'tr.createdIncidentListItem'); - const filteredIncidents = await init.page$$( + const filteredIncidents: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const filteredIncidentsCount = filteredIncidents.length; + const filteredIncidentsCount: $TSFixMe = filteredIncidents.length; expect(filteredIncidentsCount).toEqual(3); }, @@ -632,11 +632,11 @@ describe('Incident Created test', () => { await init.pageWaitForSelector(page, 'tr.createdIncidentListItem'); - const filteredIncidents = await init.page$$( + const filteredIncidents: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const filteredIncidentsCount = filteredIncidents.length; + const filteredIncidentsCount: $TSFixMe = filteredIncidents.length; expect(filteredIncidentsCount).toEqual(5); }, @@ -667,11 +667,11 @@ describe('Incident Created test', () => { await init.pageWaitForSelector(page, 'tr.createdIncidentListItem'); - const filteredIncidents = await init.page$$( + const filteredIncidents: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const filteredIncidentsCount = filteredIncidents.length; + const filteredIncidentsCount: $TSFixMe = filteredIncidents.length; expect(filteredIncidentsCount).toEqual(7); }, operationTimeOut @@ -717,11 +717,11 @@ describe('Incident Created test', () => { await init.pageWaitForSelector(page, 'tr.createdIncidentListItem'); - const filteredIncidents = await init.page$$( + const filteredIncidents: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const filteredIncidentsCount = filteredIncidents.length; + const filteredIncidentsCount: $TSFixMe = filteredIncidents.length; expect(filteredIncidentsCount).toEqual(8); }, operationTimeOut @@ -738,7 +738,7 @@ describe('Incident Created test', () => { // await init.page$Eval(page, '#closeIncident_0', elem => elem.click()); // await init.pageWaitForSelector(page, '#closeIncidentButton_0'); // await init.page$Eval(page, '#closeIncidentButton_0',e=>e.click()); - // const elementHandle = await init.page$(page, '#modal-ok'); + // const elementHandle: $TSFixMe = await init.page$(page, '#modal-ok'); // expect(elementHandle).not.toBe(null); // }); // }, diff --git a/Tests/saas-tests/dashboard/IncidentSubProject.test.ts b/Tests/saas-tests/dashboard/IncidentSubProject.test.ts index 015ce06ec5..3291a61ab3 100755 --- a/Tests/saas-tests/dashboard/IncidentSubProject.test.ts +++ b/Tests/saas-tests/dashboard/IncidentSubProject.test.ts @@ -22,7 +22,7 @@ const newComponentName: string = utils.generateRandomString(); let browser: $TSFixMe, page: $TSFixMe; describe('Incident API With SubProjects', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -121,7 +121,7 @@ describe('Incident API With SubProjects', () => { } ); - const incidentTitleSelector = await init.page$( + const incidentTitleSelector: $TSFixMe = await init.page$( page, `#incident_${projectMonitorName}_title` ); @@ -148,14 +148,15 @@ describe('Incident API With SubProjects', () => { // Navigate to details page of monitor await init.navigateToComponentDetails(newComponentName, page); - const incidentTitleSelector = await init.pageWaitForSelector( - page, - `#incident_${projectMonitorName}_title`, - { - hidden: true, - timeout: init.timeout, - } - ); + const incidentTitleSelector: $TSFixMe = + await init.pageWaitForSelector( + page, + `#incident_${projectMonitorName}_title`, + { + hidden: true, + timeout: init.timeout, + } + ); expect(incidentTitleSelector).toBeNull(); await init.saasLogout(page); done(); @@ -168,7 +169,7 @@ describe('Incident API With SubProjects', () => { async (done: $TSFixMe) => { await init.registerAndLoggingTeamMember(newUser, page); // close incident modal - const closeModal = await init.pageWaitForSelector( + const closeModal: $TSFixMe = await init.pageWaitForSelector( page, '#closeIncident_0', { @@ -237,7 +238,7 @@ describe('Incident API With SubProjects', () => { { visible: true } ); - const incidentTitleSelector = await init.page$( + const incidentTitleSelector: $TSFixMe = await init.page$( page, `#incident_${projectMonitorName1}_title` ); @@ -276,7 +277,7 @@ describe('Incident API With SubProjects', () => { timeout: operationTimeOut, }); - const acknowledgeTextSelector = await init.page$( + const acknowledgeTextSelector: $TSFixMe = await init.page$( page, '#AcknowledgeText_0' ); @@ -308,7 +309,7 @@ describe('Incident API With SubProjects', () => { timeout: operationTimeOut, }); - const resolveTextSelector = await init.page$( + const resolveTextSelector: $TSFixMe = await init.page$( page, '#ResolveText_0' ); @@ -381,7 +382,7 @@ describe('Incident API With SubProjects', () => { } ); - const internalMessage = await init.page$( + const internalMessage: $TSFixMe = await init.page$( page, `#content_${type}_incident_message_0` ); @@ -431,7 +432,7 @@ describe('Incident API With SubProjects', () => { // // click on incident notes tab // await init.gotoTab(utils.incidentTabIndexes.BASIC, page); - // for (let i = 0; i < 10; i++) { + // for (let i: $TSFixMe = 0; i < 10; i++) { // await init.page$Eval(page, `#add-${type}-message`, e => // e.click() // ); @@ -475,7 +476,7 @@ describe('Incident API With SubProjects', () => { // page, // '#incidentTimeline tr.incidentListItem' // ); - // let countIncidentTimelines = incidentTimelineRows.length; + // let countIncidentTimelines: $TSFixMe = incidentTimelineRows.length; // expect(countIncidentTimelines).toEqual(10); @@ -550,11 +551,11 @@ describe('Incident API With SubProjects', () => { timeout: init.timeout, }); - const incidentRows = await init.page$$( + const incidentRows: $TSFixMe = await init.page$$( page, 'tr.createdIncidentListItem' ); - const countIncidents = incidentRows.length; + const countIncidents: $TSFixMe = incidentRows.length; expect(countIncidents).toBeGreaterThanOrEqual(1); done(); diff --git a/Tests/saas-tests/dashboard/IncidentTimeline.test.ts b/Tests/saas-tests/dashboard/IncidentTimeline.test.ts index f58cbdd451..95e2123751 100644 --- a/Tests/saas-tests/dashboard/IncidentTimeline.test.ts +++ b/Tests/saas-tests/dashboard/IncidentTimeline.test.ts @@ -14,7 +14,7 @@ const componentName: string = utils.generateRandomString(); const message: string = utils.generateRandomString(); describe('Incident Timeline API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(360000); @@ -156,7 +156,7 @@ describe('Incident Timeline API', () => { } ); - const investigationMessage = await init.page$( + const investigationMessage: $TSFixMe = await init.page$( page, `#content_${type}_incident_message_0` ); @@ -224,7 +224,7 @@ describe('Incident Timeline API', () => { } ); - const investigationMessage = await init.page$( + const investigationMessage: $TSFixMe = await init.page$( page, `#content_${type}_incident_message_0` ); @@ -300,7 +300,7 @@ describe('Incident Timeline API', () => { } ); - const incidentMessage = await init.page$( + const incidentMessage: $TSFixMe = await init.page$( page, `#content_${type}_incident_message_0` ); @@ -375,7 +375,7 @@ describe('Incident Timeline API', () => { } ); - const incidentMessage = await init.page$( + const incidentMessage: $TSFixMe = await init.page$( page, `#content_${type}_incident_message_0` ); @@ -427,7 +427,7 @@ describe('Incident Timeline API', () => { hidden: true, }); - const incidentMessage = await init.pageWaitForSelector( + const incidentMessage: $TSFixMe = await init.pageWaitForSelector( page, `#content_${type}_incident_message_0`, { hidden: true } @@ -461,7 +461,7 @@ describe('Incident Timeline API', () => { await init.page$Eval(page, `#incident_0`, (e: $TSFixMe) => e.click() ); - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { // add internal note await init.pageWaitForSelector(page, `#add-${type}-message`, { visible: true, @@ -498,11 +498,11 @@ describe('Incident Timeline API', () => { await init.pageWaitForSelector(page, '.internal-list'); - const incidentTimelineRow = await init.page$$( + const incidentTimelineRow: $TSFixMe = await init.page$$( page, '.internal-list' ); - const countIncidentTimelines = incidentTimelineRow.length; + const countIncidentTimelines: $TSFixMe = incidentTimelineRow.length; expect(countIncidentTimelines).toEqual(11); // An internal mesage has been exist in the previous test }, init.timeout @@ -541,11 +541,12 @@ describe('Incident Timeline API', () => { await init.pageWaitForSelector(page, '.internal-list'); - const incidentTimelineRows = await init.page$$( + const incidentTimelineRows: $TSFixMe = await init.page$$( page, '.internal-list' ); - const countIncidentTimelines = incidentTimelineRows.length; + const countIncidentTimelines: $TSFixMe = + incidentTimelineRows.length; expect(countIncidentTimelines).toEqual(11); }, @@ -581,11 +582,12 @@ describe('Incident Timeline API', () => { await init.pageWaitForSelector(page, '.internal-list'); - const incidentTimelineRows = await init.page$$( + const incidentTimelineRows: $TSFixMe = await init.page$$( page, '.internal-list' ); - const countIncidentTimelines = incidentTimelineRows.length; + const countIncidentTimelines: $TSFixMe = + incidentTimelineRows.length; expect(countIncidentTimelines).toEqual(11); }, diff --git a/Tests/saas-tests/dashboard/IncomingRequest.test.ts b/Tests/saas-tests/dashboard/IncomingRequest.test.ts index 3079c9c2e7..9719ab4b82 100644 --- a/Tests/saas-tests/dashboard/IncomingRequest.test.ts +++ b/Tests/saas-tests/dashboard/IncomingRequest.test.ts @@ -21,7 +21,7 @@ const incidentRequest: $TSFixMe = { }; describe('Incoming HTTP Request', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -122,11 +122,12 @@ describe('Incoming HTTP Request', () => { hidden: true, }); - const firstIncomingHttpRequest = await init.pageWaitForSelector( - page, - '#copyIncomingRequestBtn_0', - { visible: true, timeout: init.timeout } - ); + const firstIncomingHttpRequest: $TSFixMe = + await init.pageWaitForSelector( + page, + '#copyIncomingRequestBtn_0', + { visible: true, timeout: init.timeout } + ); expect(firstIncomingHttpRequest).toBeDefined(); done(); @@ -175,7 +176,7 @@ describe('Incoming HTTP Request', () => { hidden: true, }); - const updatedRequest = await init.pageWaitForSelector( + const updatedRequest: $TSFixMe = await init.pageWaitForSelector( page, '#incomingRequest_newName', { visible: true, timeout: init.timeout } @@ -227,7 +228,7 @@ describe('Incoming HTTP Request', () => { hidden: true, }); - const noIncomingRequest = await init.pageWaitForSelector( + const noIncomingRequest: $TSFixMe = await init.pageWaitForSelector( page, '#noIncomingRequest', { visible: true, timeout: init.timeout } diff --git a/Tests/saas-tests/dashboard/IntegrationsReload.test.ts b/Tests/saas-tests/dashboard/IntegrationsReload.test.ts index 1752a17d18..7ed4f006d3 100644 --- a/Tests/saas-tests/dashboard/IntegrationsReload.test.ts +++ b/Tests/saas-tests/dashboard/IntegrationsReload.test.ts @@ -10,7 +10,7 @@ const user: $TSFixMe = { const componentName: string = utils.generateRandomString(); const monitorName: string = utils.generateRandomString(); -const webHookEndpoint = utils.generateRandomWebsite(); +const webHookEndpoint: $TSFixMe = utils.generateRandomWebsite(); /** This is a test to check: * No errors on page reload @@ -18,7 +18,7 @@ const webHookEndpoint = utils.generateRandomWebsite(); */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -76,7 +76,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#addWebhookButton', { diff --git a/Tests/saas-tests/dashboard/Monitor.test.ts b/Tests/saas-tests/dashboard/Monitor.test.ts index 2c96493dab..e3d63ef453 100755 --- a/Tests/saas-tests/dashboard/Monitor.test.ts +++ b/Tests/saas-tests/dashboard/Monitor.test.ts @@ -13,7 +13,7 @@ const componentName: string = utils.generateRandomString(); const monitorName: string = utils.generateRandomString(); describe('Monitor API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -160,7 +160,7 @@ describe('Monitor API', () => { await criterionAdvancedOptions.click(); await init.pageWaitForSelector(page, 'input[id^=name_up]'); - const criterionName = await init.page$Eval( + const criterionName: $TSFixMe = await init.page$Eval( page, 'input[id^=name_up]', (el: $TSFixMe) => el.value diff --git a/Tests/saas-tests/dashboard/Monitor6.test.ts b/Tests/saas-tests/dashboard/Monitor6.test.ts index b5605c2140..e6f6e99d5e 100644 --- a/Tests/saas-tests/dashboard/Monitor6.test.ts +++ b/Tests/saas-tests/dashboard/Monitor6.test.ts @@ -13,7 +13,7 @@ const componentName: string = utils.generateRandomString(); const testServerMonitorName: string = utils.generateRandomString(); describe('Monitor API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/Monitor7.test.ts b/Tests/saas-tests/dashboard/Monitor7.test.ts index 668f102f39..7c28935399 100644 --- a/Tests/saas-tests/dashboard/Monitor7.test.ts +++ b/Tests/saas-tests/dashboard/Monitor7.test.ts @@ -13,7 +13,7 @@ const componentName: string = utils.generateRandomString(); const testServerMonitorName: string = utils.generateRandomString(); describe('Monitor API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(600000); diff --git a/Tests/saas-tests/dashboard/Monitor9.test.ts b/Tests/saas-tests/dashboard/Monitor9.test.ts index 93d2f431cc..6bcd730e7a 100644 --- a/Tests/saas-tests/dashboard/Monitor9.test.ts +++ b/Tests/saas-tests/dashboard/Monitor9.test.ts @@ -9,7 +9,7 @@ import 'should'; const password: string = '1234567890'; describe('API Monitor API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; const componentName: string = utils.generateRandomString(); const testMonitorName: string = utils.generateRandomString(); @@ -102,7 +102,10 @@ describe('API Monitor API', () => { spanElement = await spanElement.jsonValue(); spanElement.should.be.exactly(testMonitorName); - const probeTabs = await init.page$$(page, 'button[id^=probes-btn]'); + const probeTabs: $TSFixMe = await init.page$$( + page, + 'button[id^=probes-btn]' + ); for (const probeTab of probeTabs) { await probeTab.click(); @@ -151,12 +154,12 @@ describe('API Monitor API', () => { // for online criteria - const upFields = await init.page$$( + const upFields: $TSFixMe = await init.page$$( page, `input[name*="up_"][name*=".field1"]` ); - const lastUpField = upFields[upFields.length - 1]; - const upExpression = await ( + const lastUpField: $TSFixMe = upFields[upFields.length - 1]; + const upExpression: $TSFixMe = await ( await lastUpField.getProperty('value') ).jsonValue(); @@ -164,12 +167,13 @@ describe('API Monitor API', () => { // for degraded criteria - const degradedFields = await init.page$$( + const degradedFields: $TSFixMe = await init.page$$( page, `input[name*="degraded_"][name*=".field1"]` ); - const lastDegradedField = degradedFields[degradedFields.length - 1]; - const degradedExpression = await ( + const lastDegradedField: $TSFixMe = + degradedFields[degradedFields.length - 1]; + const degradedExpression: $TSFixMe = await ( await lastDegradedField.getProperty('value') ).jsonValue(); expect(degradedExpression).toEqual( @@ -233,7 +237,10 @@ describe('API Monitor API', () => { page ); - const probeTabs = await init.page$$(page, 'button[id^=probes-btn]'); + const probeTabs: $TSFixMe = await init.page$$( + page, + 'button[id^=probes-btn]' + ); for (const probeTab of probeTabs) { await probeTab.click(); @@ -311,7 +318,10 @@ describe('API Monitor API', () => { page ); - const probeTabs = await init.page$$(page, 'button[id^=probes-btn]'); + const probeTabs: $TSFixMe = await init.page$$( + page, + 'button[id^=probes-btn]' + ); for (const probeTab of probeTabs) { await probeTab.click(); @@ -383,7 +393,10 @@ describe('API Monitor API', () => { page ); - const probeTabs = await init.page$$(page, 'button[id^=probes-btn]'); + const probeTabs: $TSFixMe = await init.page$$( + page, + 'button[id^=probes-btn]' + ); for (const probeTab of probeTabs) { await probeTab.click(); @@ -485,7 +498,7 @@ describe('API Monitor API', () => { }); const selector: string = `span#monitor-title-${testMonitorName}`; - const spanElement = await init.page$(page, selector, { + const spanElement: $TSFixMe = await init.page$(page, selector, { hidden: true, }); expect(spanElement).toBeNull(); diff --git a/Tests/saas-tests/dashboard/MonitorDetail.test.ts b/Tests/saas-tests/dashboard/MonitorDetail.test.ts index c1af1a5ac7..388bb8ef73 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail.test.ts @@ -15,7 +15,7 @@ const incidentTitle: string = utils.generateRandomString(); const newIncidentTitle: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -108,7 +108,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, '#numberOfIncidents'); - const selector = await init.page$Eval( + const selector: $TSFixMe = await init.page$Eval( page, '#numberOfIncidents', (elem: $TSFixMe) => elem.textContent @@ -120,7 +120,7 @@ describe('Monitor Detail API', () => { timeout: init.timeout, }); const selector1: string = `#name_${priorityName}`; - const rowContent = await init.page$Eval( + const rowContent: $TSFixMe = await init.page$Eval( page, selector1, (e: $TSFixMe) => e.textContent @@ -223,13 +223,13 @@ describe('Monitor Detail API', () => { page ); - const nextSelector = await init.pageWaitForSelector( + const nextSelector: $TSFixMe = await init.pageWaitForSelector( page, '#btnNext' ); await nextSelector.click(); - let incidentRows = '#numberOfIncidents'; + let incidentRows: $TSFixMe = '#numberOfIncidents'; let countIncidents: $TSFixMe = await init.page$Eval( page, @@ -238,7 +238,7 @@ describe('Monitor Detail API', () => { ); expect(countIncidents).toEqual('1'); - const prevSelector = await init.pageWaitForSelector( + const prevSelector: $TSFixMe = await init.pageWaitForSelector( page, '#btnPrev' ); diff --git a/Tests/saas-tests/dashboard/MonitorDetail2.test.ts b/Tests/saas-tests/dashboard/MonitorDetail2.test.ts index 958692b32d..0569b92c0e 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail2.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail2.test.ts @@ -13,11 +13,11 @@ const componentName: string = utils.generateRandomString(); const subscriberEmail: Email = utils.generateRandomBusinessEmail(); const webHookName: string = utils.generateRandomString(); const newWebHookName: string = utils.generateRandomString(); -const webhookEndpoint = utils.generateRandomWebsite(); +const webhookEndpoint: $TSFixMe = utils.generateRandomWebsite(); const priorityName: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -81,7 +81,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, createdSubscriberSelector); - const createdSubscriberEmail = await init.page$Eval( + const createdSubscriberEmail: $TSFixMe = await init.page$Eval( page, createdSubscriberSelector, (el: $TSFixMe) => el.textContent @@ -110,7 +110,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, addButtonSelector); - for (let i = 0; i < 5; i++) { + for (let i: $TSFixMe = 0; i < 5; i++) { await init.page$Eval(page, addButtonSelector, (e: $TSFixMe) => e.click() ); @@ -140,11 +140,14 @@ describe('Monitor Detail API', () => { createdSubscriberSelector, (elem: $TSFixMe) => elem.textContent ); - let countSubscribers = subscriberRows; + let countSubscribers: $TSFixMe = subscriberRows; // Total number of subscribers is rendered and not first 5. expect(countSubscribers).toEqual('6'); - const nextSelector = await init.page$(page, '#btnNextSubscriber'); + const nextSelector: $TSFixMe = await init.page$( + page, + '#btnNextSubscriber' + ); await nextSelector.click(); await init.pageWaitForSelector(page, createdSubscriberSelector); @@ -159,7 +162,10 @@ describe('Monitor Detail API', () => { // Navigating to the next page did not affect the subscriber count. expect(countSubscribers).toEqual('6'); - const prevSelector = await init.page$(page, '#btnPrevSubscriber'); + const prevSelector: $TSFixMe = await init.page$( + page, + '#btnPrevSubscriber' + ); await prevSelector.click(); await init.pageWaitForSelector(page, createdSubscriberSelector); @@ -226,7 +232,7 @@ describe('Monitor Detail API', () => { }); // When an MSTeams is created, only 'Name' and 'Action' are rendered //MSTeams Endpoint is no longer rendered - const createdWebhookName = await init.page$Eval( + const createdWebhookName: $TSFixMe = await init.page$Eval( page, createdWebhookSelector, (el: $TSFixMe) => el.textContent @@ -254,7 +260,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, existingWebhookSelector); - const existingWebhookName = await init.page$Eval( + const existingWebhookName: $TSFixMe = await init.page$Eval( page, existingWebhookSelector, (el: $TSFixMe) => el.textContent @@ -269,7 +275,7 @@ describe('Monitor Detail API', () => { (e: $TSFixMe) => e.click() ); - const newWebhookEndpoint = utils.generateRandomWebsite(); + const newWebhookEndpoint: $TSFixMe = utils.generateRandomWebsite(); await init.pageClick(page, '#webHookName', { clickCount: 3 }); await init.pageType(page, '#webHookName', newWebHookName); @@ -284,7 +290,7 @@ describe('Monitor Detail API', () => { }); await init.pageWaitForSelector(page, `#msteam_${newWebHookName}`); - const updatedWebhookName = await init.page$Eval( + const updatedWebhookName: $TSFixMe = await init.page$Eval( page, `#msteam_${newWebHookName}`, (el: $TSFixMe) => el.textContent @@ -312,8 +318,11 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, createdWebhookSelector); - const webhookRows = await init.page$$(page, createdWebhookSelector); - const countWebhooks = webhookRows.length; + const webhookRows: $TSFixMe = await init.page$$( + page, + createdWebhookSelector + ); + const countWebhooks: $TSFixMe = webhookRows.length; expect(countWebhooks).toEqual(1); @@ -364,7 +373,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, addButtonSelector); - for (let i = 0; i < 11; i++) { + for (let i: $TSFixMe = 0; i < 11; i++) { await init.page$Eval(page, addButtonSelector, (e: $TSFixMe) => e.click() ); @@ -410,7 +419,7 @@ describe('Monitor Detail API', () => { page, createdWebhookSelector ); - let countWebhooks = webhookRows.length; + let countWebhooks: $TSFixMe = webhookRows.length; expect(countWebhooks).toEqual(10); diff --git a/Tests/saas-tests/dashboard/MonitorDetail3.test.ts b/Tests/saas-tests/dashboard/MonitorDetail3.test.ts index ef8fb60249..da75bc20ba 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail3.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail3.test.ts @@ -226,7 +226,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, addButtonSelector); - for (let i = 0; i < 11; i++) { + for (let i: $TSFixMe = 0; i < 11; i++) { await init.page$Eval(page, addButtonSelector, (e: $TSFixMe) => e.click() ); @@ -274,7 +274,7 @@ describe('Monitor Detail API', () => { page, createdWebhookSelector ); - let countWebhooks = webhookRows.length; + let countWebhooks: $TSFixMe = webhookRows.length; expect(countWebhooks).toEqual(10); diff --git a/Tests/saas-tests/dashboard/MonitorDetail4.test.ts b/Tests/saas-tests/dashboard/MonitorDetail4.test.ts index b2d659661d..1c5f12705b 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail4.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail4.test.ts @@ -10,11 +10,11 @@ const email: Email = utils.generateRandomBusinessEmail(); const password: string = '1234567890'; const monitorName: string = utils.generateRandomString(); const componentName: string = utils.generateRandomString(); -const webhookEndpoint = utils.generateRandomWebsite(); +const webhookEndpoint: $TSFixMe = utils.generateRandomWebsite(); const priorityName: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -80,7 +80,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, createdWebhookSelector); - const createdWebhookEndpoint = await init.page$Eval( + const createdWebhookEndpoint: $TSFixMe = await init.page$Eval( page, createdWebhookSelector, (el: $TSFixMe) => el.textContent @@ -109,7 +109,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, addButtonSelector); - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { await init.page$Eval(page, addButtonSelector, (e: $TSFixMe) => e.click() ); @@ -154,7 +154,7 @@ describe('Monitor Detail API', () => { page, createdWebhookSelector ); - let countWebhooks = webhookRows.length; + let countWebhooks: $TSFixMe = webhookRows.length; expect(countWebhooks).toEqual(10); diff --git a/Tests/saas-tests/dashboard/MonitorDetail5.test.ts b/Tests/saas-tests/dashboard/MonitorDetail5.test.ts index 8ecd0b165d..694e280a62 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail5.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail5.test.ts @@ -14,7 +14,7 @@ const urlMonitorName: string = utils.generateRandomString(); const componentName: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -86,11 +86,11 @@ describe('Monitor Detail API', () => { } ); - const lighthouseLogsRows = await init.page$$( + const lighthouseLogsRows: $TSFixMe = await init.page$$( page, createdLighthouseLogsSelector ); - const countLighthouseLogs = lighthouseLogsRows.length; + const countLighthouseLogs: $TSFixMe = lighthouseLogsRows.length; expect(countLighthouseLogs).toEqual(1); done(); @@ -138,11 +138,11 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, createdLighthouseLogsSelector); - const lighthouseLogsRows = await init.page$$( + const lighthouseLogsRows: $TSFixMe = await init.page$$( page, createdLighthouseLogsSelector ); - const countLighthouseLogs = lighthouseLogsRows.length; + const countLighthouseLogs: $TSFixMe = lighthouseLogsRows.length; expect(countLighthouseLogs).toEqual(2); done(); @@ -184,11 +184,11 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, createdLighthouseLogsSelector); - const lighthouseLogsRows = await init.page$$( + const lighthouseLogsRows: $TSFixMe = await init.page$$( page, createdLighthouseLogsSelector ); - const countLighthouseLogs = lighthouseLogsRows.length; + const countLighthouseLogs: $TSFixMe = lighthouseLogsRows.length; expect(countLighthouseLogs).toEqual(1); done(); @@ -273,7 +273,7 @@ describe('Monitor Detail API', () => { const selector: string = `span#monitor-title-${newMonitorName}`; - const spanElement = await init.page$(page, selector, { + const spanElement: $TSFixMe = await init.page$(page, selector, { hidden: true, }); expect(spanElement).toEqual(null); diff --git a/Tests/saas-tests/dashboard/MonitorDetail6.test.ts b/Tests/saas-tests/dashboard/MonitorDetail6.test.ts index a0607ab300..685c84fc95 100644 --- a/Tests/saas-tests/dashboard/MonitorDetail6.test.ts +++ b/Tests/saas-tests/dashboard/MonitorDetail6.test.ts @@ -12,7 +12,7 @@ const urlMonitorName: string = utils.generateRandomString(); const componentName: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(600000); @@ -105,12 +105,12 @@ describe('Monitor Detail API', () => { expect(probe0).toBeDefined(); expect(probe1).toBeDefined(); - const monitorStatus = await init.pageWaitForSelector( + const monitorStatus: $TSFixMe = await init.pageWaitForSelector( page, `#monitor-status-${urlMonitorName}`, { visible: true, timeout: operationTimeOut } ); - const sslStatus = await init.pageWaitForSelector( + const sslStatus: $TSFixMe = await init.pageWaitForSelector( page, `#ssl-status-${urlMonitorName}`, { visible: true, timeout: operationTimeOut } @@ -195,16 +195,16 @@ describe('Monitor Detail API', () => { await init.pageClick(page, `#lighthouseUrl_${urlMonitorName}_0`); - const websiteIssuesSelector = + const websiteIssuesSelector: $TSFixMe = '#performance #websiteIssuesList > tbody >tr.websiteIssuesListItem'; await init.pageWaitForSelector(page, websiteIssuesSelector); - const websiteIssuesRows = await init.page$$( + const websiteIssuesRows: $TSFixMe = await init.page$$( page, websiteIssuesSelector ); - const countWebsiteIssues = websiteIssuesRows.length; + const countWebsiteIssues: $TSFixMe = websiteIssuesRows.length; expect(countWebsiteIssues).toBeGreaterThanOrEqual(1); done(); diff --git a/Tests/saas-tests/dashboard/MonitorReload.test.ts b/Tests/saas-tests/dashboard/MonitorReload.test.ts index 608d37a706..344bf2101e 100644 --- a/Tests/saas-tests/dashboard/MonitorReload.test.ts +++ b/Tests/saas-tests/dashboard/MonitorReload.test.ts @@ -16,7 +16,7 @@ const monitorName: string = utils.generateRandomString(); */ describe('OneUptime Monitor Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/MonitorSubProject.test.ts b/Tests/saas-tests/dashboard/MonitorSubProject.test.ts index 7292b11e5a..b68a7adfe9 100755 --- a/Tests/saas-tests/dashboard/MonitorSubProject.test.ts +++ b/Tests/saas-tests/dashboard/MonitorSubProject.test.ts @@ -16,7 +16,7 @@ const newPassword: string = '1234567890'; const subProjectName: string = utils.generateRandomString(); describe('Monitor API With SubProjects', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -85,16 +85,20 @@ describe('Monitor API With SubProjects', () => { }); await init.pageClick(page, '#components'); - const newComponentForm = await init.page$( + const newComponentForm: $TSFixMe = await init.page$( page, '#form-new-component', { hidden: true } ); expect(newComponentForm).toEqual(null); - const newMonitorForm = await init.page$(page, '#form-new-monitor', { - hidden: true, - }); + const newMonitorForm: $TSFixMe = await init.page$( + page, + '#form-new-monitor', + { + hidden: true, + } + ); expect(newMonitorForm).toEqual(null); await init.saasLogout(page); diff --git a/Tests/saas-tests/dashboard/MonitorSubscribeBySms.test.ts b/Tests/saas-tests/dashboard/MonitorSubscribeBySms.test.ts index d79ba5e298..00c0d43ddc 100644 --- a/Tests/saas-tests/dashboard/MonitorSubscribeBySms.test.ts +++ b/Tests/saas-tests/dashboard/MonitorSubscribeBySms.test.ts @@ -12,7 +12,7 @@ const monitorName: string = utils.generateRandomString(); const componentName: string = utils.generateRandomString(); describe('Monitor Detail API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -89,7 +89,7 @@ describe('Monitor Detail API', () => { await init.pageClick(page, '.subscribers-tab'); - const textContent = await init.page$Eval( + const textContent: $TSFixMe = await init.page$Eval( page, '#subscriber_contact', (e: $TSFixMe) => e.textContent @@ -139,7 +139,7 @@ describe('Monitor Detail API', () => { await init.pageClick(page, '#createSubscriber'); - const textContent = await init.page$Eval( + const textContent: $TSFixMe = await init.page$Eval( page, '#field-error', (e: $TSFixMe) => e.textContent diff --git a/Tests/saas-tests/dashboard/MonitorSubscribers.test.ts b/Tests/saas-tests/dashboard/MonitorSubscribers.test.ts index 0179e34e9f..790f269aae 100644 --- a/Tests/saas-tests/dashboard/MonitorSubscribers.test.ts +++ b/Tests/saas-tests/dashboard/MonitorSubscribers.test.ts @@ -253,7 +253,7 @@ describe('Monitor Detail API', () => { await init.pageClick(page, '#react-tabs-2'); - let initialSubscribers = '.subscriber-list-item'; + let initialSubscribers: $TSFixMe = '.subscriber-list-item'; await init.pageWaitForSelector(page, initialSubscribers); @@ -276,7 +276,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, '#subscribersList'); - let finalSubscribers = '.subscriber-list-item'; + let finalSubscribers: $TSFixMe = '.subscriber-list-item'; await init.pageWaitForSelector(page, finalSubscribers); @@ -305,7 +305,7 @@ describe('Monitor Detail API', () => { await init.pageClick(page, '#react-tabs-2'); - let initialSubscribers = '.subscriber-list-item'; + let initialSubscribers: $TSFixMe = '.subscriber-list-item'; await init.pageWaitForSelector(page, initialSubscribers); @@ -325,7 +325,7 @@ describe('Monitor Detail API', () => { await init.pageWaitForSelector(page, '#subscribersList'); - let finalSubscribers = '.subscriber-list-item'; + let finalSubscribers: $TSFixMe = '.subscriber-list-item'; await init.pageWaitForSelector(page, finalSubscribers); diff --git a/Tests/saas-tests/dashboard/NewMonitor.test.ts b/Tests/saas-tests/dashboard/NewMonitor.test.ts index fd63094257..9e7f5bb2c2 100644 --- a/Tests/saas-tests/dashboard/NewMonitor.test.ts +++ b/Tests/saas-tests/dashboard/NewMonitor.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { }; describe('New Monitor API', () => { - const operationTimeOut = 1000000; // Custom Timeout is needed + const operationTimeOut: $TSFixMe = 1000000; // Custom Timeout is needed beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -47,7 +47,7 @@ describe('New Monitor API', () => { firstMonitorName ); - for (let i = 0; i < 4; i++) { + for (let i: $TSFixMe = 0; i < 4; i++) { // This adds 4 more monitors // The Interface for adding additional monitor has been updated const monitorName: string = utils.generateRandomString(); @@ -113,7 +113,7 @@ describe('New Monitor API', () => { await init.pageClick(page, 'button[type=submit]'); - const pricingPlanModal = await init.pageWaitForSelector( + const pricingPlanModal: $TSFixMe = await init.pageWaitForSelector( page, '#pricingPlanModal', { visible: true, timeout: init.timeout } diff --git a/Tests/saas-tests/dashboard/NewMonitor2.test.ts b/Tests/saas-tests/dashboard/NewMonitor2.test.ts index fac876cdd9..27c60f9a40 100644 --- a/Tests/saas-tests/dashboard/NewMonitor2.test.ts +++ b/Tests/saas-tests/dashboard/NewMonitor2.test.ts @@ -49,7 +49,7 @@ describe('New Monitor API', () => { firstMonitorName ); - for (let i = 0; i < 9; i++) { + for (let i: $TSFixMe = 0; i < 9; i++) { // This adds 9 more monitors // The Interface for adding additional monitor has been updated const monitorName: string = utils.generateRandomString(); diff --git a/Tests/saas-tests/dashboard/NewMonitor3.test.ts b/Tests/saas-tests/dashboard/NewMonitor3.test.ts index c593be5578..18608375af 100644 --- a/Tests/saas-tests/dashboard/NewMonitor3.test.ts +++ b/Tests/saas-tests/dashboard/NewMonitor3.test.ts @@ -49,7 +49,7 @@ describe('New Monitor API', () => { firstMonitorName ); - for (let i = 0; i < 14; i++) { + for (let i: $TSFixMe = 0; i < 14; i++) { // This adds 14 more monitors // The Interface for adding additional monitor has been updated const monitorName: string = utils.generateRandomString(); @@ -112,7 +112,7 @@ describe('New Monitor API', () => { await init.pageClick(page, 'button[type=submit]'); - const pricingPlanModal = await init.pageWaitForSelector( + const pricingPlanModal: $TSFixMe = await init.pageWaitForSelector( page, '#pricingPlanModal', { hidden: true } diff --git a/Tests/saas-tests/dashboard/OneUptimeApi.test.ts b/Tests/saas-tests/dashboard/OneUptimeApi.test.ts index 1ebb6a4596..802d0e78d4 100644 --- a/Tests/saas-tests/dashboard/OneUptimeApi.test.ts +++ b/Tests/saas-tests/dashboard/OneUptimeApi.test.ts @@ -15,7 +15,7 @@ const member: $TSFixMe = { }; describe('API test', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/Probe.test.ts b/Tests/saas-tests/dashboard/Probe.test.ts index f8abe73f7b..4ad157b8b8 100644 --- a/Tests/saas-tests/dashboard/Probe.test.ts +++ b/Tests/saas-tests/dashboard/Probe.test.ts @@ -11,7 +11,7 @@ const user: $TSFixMe = { }; describe('API test', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -51,7 +51,7 @@ describe('API test', () => { visible: true, timeout: init.timeout, }); - const elementHandle = await init.page$( + const elementHandle: $TSFixMe = await init.page$( page, '#offline_0 > span > span', { hidden: true } //Probe is expected to be online diff --git a/Tests/saas-tests/dashboard/ProbeReload.test.ts b/Tests/saas-tests/dashboard/ProbeReload.test.ts index e5044ae1bf..69b80b8254 100644 --- a/Tests/saas-tests/dashboard/ProbeReload.test.ts +++ b/Tests/saas-tests/dashboard/ProbeReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -61,7 +61,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#probe_0', { diff --git a/Tests/saas-tests/dashboard/Profile.test.ts b/Tests/saas-tests/dashboard/Profile.test.ts index ed22f87655..3fb56b3167 100644 --- a/Tests/saas-tests/dashboard/Profile.test.ts +++ b/Tests/saas-tests/dashboard/Profile.test.ts @@ -11,7 +11,7 @@ const user: $TSFixMe = { }; describe('Profile -> Delete Account Component test', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); diff --git a/Tests/saas-tests/dashboard/ResolvedIncident.test.ts b/Tests/saas-tests/dashboard/ResolvedIncident.test.ts index 91ddd29e3e..ddcce312bc 100644 --- a/Tests/saas-tests/dashboard/ResolvedIncident.test.ts +++ b/Tests/saas-tests/dashboard/ResolvedIncident.test.ts @@ -43,7 +43,7 @@ describe('Incident Reports API', () => { test( 'should create 5 incidents and resolved them', async (done: $TSFixMe) => { - for (let i = 0; i < 4; i++) { + for (let i: $TSFixMe = 0; i < 4; i++) { await init.navigateToMonitorDetails( componentName, monitorName, diff --git a/Tests/saas-tests/dashboard/ResourceCategory.test.ts b/Tests/saas-tests/dashboard/ResourceCategory.test.ts index 338e2d7e63..cf97c92eb8 100755 --- a/Tests/saas-tests/dashboard/ResourceCategory.test.ts +++ b/Tests/saas-tests/dashboard/ResourceCategory.test.ts @@ -18,7 +18,7 @@ const user: $TSFixMe = { }; describe('Resource Category', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -82,7 +82,7 @@ describe('Resource Category', () => { await init.pageClick(page, '#addResourceCategoryButton'); - const createdResourceCategorySelector = + const createdResourceCategorySelector: $TSFixMe = '#resourceCategoryList #resource-category-name:nth-child(2)'; await init.pageWaitForSelector( @@ -94,7 +94,7 @@ describe('Resource Category', () => { } ); - const createdResourceCategoryName = await init.page$Eval( + const createdResourceCategoryName: $TSFixMe = await init.page$Eval( page, createdResourceCategorySelector, (el: $TSFixMe) => el.textContent @@ -118,7 +118,7 @@ describe('Resource Category', () => { timeout: init.timeout, }); - let resourceCategoryCheck = false; + let resourceCategoryCheck: $TSFixMe = false; await init.selectDropdownValue( '#resourceCategory', @@ -126,9 +126,13 @@ describe('Resource Category', () => { page ); - const noOption = await init.page$(page, 'div.css-1gl4k7y', { - hidden: true, - }); + const noOption: $TSFixMe = await init.page$( + page, + 'div.css-1gl4k7y', + { + hidden: true, + } + ); if (!noOption) { resourceCategoryCheck = true; @@ -183,7 +187,7 @@ describe('Resource Category', () => { visible: true, timeout: operationTimeOut, }); - const createdMonitorName = await init.page$Eval( + const createdMonitorName: $TSFixMe = await init.page$Eval( page, createdMonitorSelector, (el: $TSFixMe) => el.textContent @@ -242,7 +246,7 @@ describe('Resource Category', () => { const resourceCategoryCounterSelector: string = '#resourceCategoryCount'; - const resourceCategoryCount = await init.page$Eval( + const resourceCategoryCount: $TSFixMe = await init.page$Eval( page, resourceCategoryCounterSelector, (el: $TSFixMe) => el.textContent @@ -256,7 +260,7 @@ describe('Resource Category', () => { }); describe('Member Restriction', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -328,7 +332,7 @@ describe('Member Restriction', () => { ); await init.pageClick(page, '#createResourceCategoryButton'); - const modal = await init.pageWaitForSelector( + const modal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { @@ -374,7 +378,7 @@ describe('Member Restriction', () => { }); await init.pageClick(page, editBtn); - const modal = await init.pageWaitForSelector( + const modal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { @@ -420,7 +424,7 @@ describe('Member Restriction', () => { }); await init.pageClick(page, deleteBtn); - const modal = await init.pageWaitForSelector( + const modal: $TSFixMe = await init.pageWaitForSelector( page, '#unauthorisedModal', { diff --git a/Tests/saas-tests/dashboard/ResourceCategoryReload.test.ts b/Tests/saas-tests/dashboard/ResourceCategoryReload.test.ts index e76ec1d325..7598f0f697 100644 --- a/Tests/saas-tests/dashboard/ResourceCategoryReload.test.ts +++ b/Tests/saas-tests/dashboard/ResourceCategoryReload.test.ts @@ -16,7 +16,7 @@ const resourceCategory: string = utils.generateRandomString(); */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -68,7 +68,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#resource-category-name', { visible: true, timeout: init.timeout } diff --git a/Tests/saas-tests/dashboard/Schedule.test.ts b/Tests/saas-tests/dashboard/Schedule.test.ts index 2e8b5316d7..d13402af70 100644 --- a/Tests/saas-tests/dashboard/Schedule.test.ts +++ b/Tests/saas-tests/dashboard/Schedule.test.ts @@ -18,7 +18,7 @@ const componentName: string = utils.generateRandomString(); const monitorName: string = utils.generateRandomString(); describe('Schedule', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -69,7 +69,8 @@ describe('Schedule', () => { await init.pageWaitForSelector(page, '#name', { hidden: true }); await page.evaluate(() => { - let elem = document.querySelectorAll('.Table > tbody tr'); + let elem: $TSFixMe = + document.querySelectorAll('.Table > tbody tr'); elem = Array.from(elem); @@ -80,7 +81,7 @@ describe('Schedule', () => { await init.pageClick(page, '#enableTeamRotation'); - const modal = await init.pageWaitForSelector( + const modal: $TSFixMe = await init.pageWaitForSelector( page, '#pricingPlanModal', { @@ -110,7 +111,8 @@ describe('Schedule', () => { await page.reload({ waitUntil: 'networkidle2' }); await page.evaluate(() => { - let elem = document.querySelectorAll('.Table > tbody tr'); + let elem: $TSFixMe = + document.querySelectorAll('.Table > tbody tr'); elem = Array.from(elem); @@ -121,7 +123,7 @@ describe('Schedule', () => { await init.pageClick(page, '#addOnCallDutyTimes'); - const modal = await init.pageWaitForSelector( + const modal: $TSFixMe = await init.pageWaitForSelector( page, '#pricingPlanModal', { @@ -160,7 +162,8 @@ describe('Schedule', () => { await page.reload({ waitUntil: 'networkidle2' }); await page.evaluate(() => { - let elem = document.querySelectorAll('.Table > tbody tr'); + let elem: $TSFixMe = + document.querySelectorAll('.Table > tbody tr'); elem = Array.from(elem); @@ -218,7 +221,7 @@ describe('Schedule', () => { visible: true, timeout: init.timeout, }); - const onCallScheduleName = await init.page$Eval( + const onCallScheduleName: $TSFixMe = await init.page$Eval( page, `#cb${newScheduleName}`, (el: $TSFixMe) => el.textContent diff --git a/Tests/saas-tests/dashboard/ScheduleSubProject.test.ts b/Tests/saas-tests/dashboard/ScheduleSubProject.test.ts index 89be7bea38..55da0c7931 100755 --- a/Tests/saas-tests/dashboard/ScheduleSubProject.test.ts +++ b/Tests/saas-tests/dashboard/ScheduleSubProject.test.ts @@ -21,7 +21,7 @@ const user: $TSFixMe = { }; describe('Schedule API With SubProjects', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -87,7 +87,7 @@ describe('Schedule API With SubProjects', () => { await init.pageClick(page, '#onCallDuty'); - const createButton = await init.page$( + const createButton: $TSFixMe = await init.page$( page, `#btnCreateSchedule_${subProjectName}`, { hidden: true } @@ -121,11 +121,12 @@ describe('Schedule API With SubProjects', () => { ); await page.reload({ waitUntil: 'networkidle2' }); - const scheduleCountSelector = await init.pageWaitForSelector( - page, - `#schedule_count_${subProjectName}`, - { visible: true, timeout: init.timeout } - ); + const scheduleCountSelector: $TSFixMe = + await init.pageWaitForSelector( + page, + `#schedule_count_${subProjectName}`, + { visible: true, timeout: init.timeout } + ); let textContent: $TSFixMe = await scheduleCountSelector.getProperty( 'innerText' ); @@ -148,7 +149,7 @@ describe('Schedule API With SubProjects', () => { await init.pageClick(page, `#project-${subProjectName}`); // add 10 more schedules to sub-project to test for pagination - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { const scheduleName: string = utils.generateRandomString(); await init.addScheduleToProject( scheduleName, @@ -167,11 +168,11 @@ describe('Schedule API With SubProjects', () => { page, 'tr.scheduleListItem' ); - let countSchedules = scheduleRows.length; + let countSchedules: $TSFixMe = scheduleRows.length; expect(countSchedules).toEqual(10); - //const nextSelector = + //const nextSelector: $TSFixMe = await init.pageWaitForSelector(page, `#btnNext-${subProjectName}`, { visible: true, timeout: init.timeout, @@ -185,7 +186,7 @@ describe('Schedule API With SubProjects', () => { countSchedules = scheduleRows.length; expect(countSchedules).toEqual(1); - // const prevSelector = + // const prevSelector: $TSFixMe = await init.pageWaitForSelector(page, `#btnPrev-${subProjectName}`, { visible: true, timeout: init.timeout, @@ -236,7 +237,7 @@ describe('Schedule API With SubProjects', () => { await init.pageClick(page, '#btnSaveMonitors'); - const monitorSelectValue = await init.page$Eval( + const monitorSelectValue: $TSFixMe = await init.page$Eval( page, 'input[type=checkbox]', (el: $TSFixMe) => el.value @@ -284,8 +285,11 @@ describe('Schedule API With SubProjects', () => { await init.pageWaitForSelector(page, 'tr.scheduleListItem'); - const scheduleRows = await init.page$$(page, 'tr.scheduleListItem'); - const countSchedules = scheduleRows.length; + const scheduleRows: $TSFixMe = await init.page$$( + page, + 'tr.scheduleListItem' + ); + const countSchedules: $TSFixMe = scheduleRows.length; expect(countSchedules).toEqual(10); diff --git a/Tests/saas-tests/dashboard/Scheduled-maintenance.test.ts b/Tests/saas-tests/dashboard/Scheduled-maintenance.test.ts index 12d9dd4818..044e6a0571 100644 --- a/Tests/saas-tests/dashboard/Scheduled-maintenance.test.ts +++ b/Tests/saas-tests/dashboard/Scheduled-maintenance.test.ts @@ -395,7 +395,7 @@ describe('Check scheduled maintenace', () => { page, `#event-name-${scheduledMaintenanceName}` ); - const eventName = await init.page$Eval( + const eventName: $TSFixMe = await init.page$Eval( page, `#event-name-${scheduledMaintenanceName}`, (elem: $TSFixMe) => elem.textContent @@ -408,7 +408,7 @@ describe('Check scheduled maintenace', () => { `#event-description-${scheduledMaintenanceDescription}`, { visible: true, timeout: init.timeout } ); - const eventDescription = await init.page$Eval( + const eventDescription: $TSFixMe = await init.page$Eval( page, `#event-description-${scheduledMaintenanceDescription}`, (elem: $TSFixMe) => elem.textContent @@ -420,7 +420,7 @@ describe('Check scheduled maintenace', () => { visible: true, timeout: init.timeout, }); - const eventDate = await init.page$Eval( + const eventDate: $TSFixMe = await init.page$Eval( page, '#event-date', (elem: $TSFixMe) => elem.textContent @@ -432,7 +432,7 @@ describe('Check scheduled maintenace', () => { visible: true, timeout: init.timeout, }); - const futureEvent = await init.page$Eval( + const futureEvent: $TSFixMe = await init.page$Eval( page, '#ongoing-event', (elem: $TSFixMe) => elem.textContent diff --git a/Tests/saas-tests/dashboard/ScheduledEventDetails.test.ts b/Tests/saas-tests/dashboard/ScheduledEventDetails.test.ts index 1ef6094994..7e6fc3e240 100644 --- a/Tests/saas-tests/dashboard/ScheduledEventDetails.test.ts +++ b/Tests/saas-tests/dashboard/ScheduledEventDetails.test.ts @@ -267,7 +267,7 @@ describe('Scheduled Maintenance Note ==> Pagination and Deletion', () => { page ); // create multiple notes - for (let i = 0; i < 15; i++) { + for (let i: $TSFixMe = 0; i < 15; i++) { const noteDescription: string = utils.generateRandomString(); await init.addScheduledMaintenanceNote( page, diff --git a/Tests/saas-tests/dashboard/SmsCallReload.test.ts b/Tests/saas-tests/dashboard/SmsCallReload.test.ts index bd355fc2dd..75a13f00ee 100644 --- a/Tests/saas-tests/dashboard/SmsCallReload.test.ts +++ b/Tests/saas-tests/dashboard/SmsCallReload.test.ts @@ -14,7 +14,7 @@ const user: $TSFixMe = { */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -53,7 +53,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, '#enableTwilio', { diff --git a/Tests/saas-tests/dashboard/SmtpSettings.test.ts b/Tests/saas-tests/dashboard/SmtpSettings.test.ts index 68e45ceb2f..67c0eaad9c 100644 --- a/Tests/saas-tests/dashboard/SmtpSettings.test.ts +++ b/Tests/saas-tests/dashboard/SmtpSettings.test.ts @@ -17,7 +17,7 @@ const user: $TSFixMe = { const smtpData: $TSFixMe = { ...utils.smtpCredential }; describe('Custom SMTP Settings', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -110,7 +110,7 @@ describe('Custom SMTP Settings', () => { visible: true, timeout: init.timeout, }); - const host = await init.page$Eval( + const host: $TSFixMe = await init.page$Eval( page, '#host', (elem: $TSFixMe) => elem.value @@ -167,7 +167,7 @@ describe('Custom SMTP Settings', () => { visible: true, timeout: init.timeout, }); - const fromVal = await init.page$Eval( + const fromVal: $TSFixMe = await init.page$Eval( page, '#from', (elem: $TSFixMe) => elem.value @@ -208,14 +208,14 @@ describe('Custom SMTP Settings', () => { timeout: init.timeout, }); - const port = await init.page$(page, '#port'); + const port: $TSFixMe = await init.page$(page, '#port'); await port.click({ clickCount: 3 }); await port.press('Backspace'); // clear out the input field await init.pageClick(page, '#saveSmtp'); await init.pageWaitForSelector(page, '#port'); - const emptyMessage = await init.page$Eval( + const emptyMessage: $TSFixMe = await init.page$Eval( page, '#port', (element: $TSFixMe) => element.textContent @@ -275,7 +275,9 @@ describe('Custom SMTP Settings', () => { await init.pageClick(page, '#saveSmtp'); await init.navigateToSmtp(page); - const username = await init.page$(page, '#user', { hidden: true }); + const username: $TSFixMe = await init.page$(page, '#user', { + hidden: true, + }); expect(username).toBe(null); done(); @@ -313,9 +315,13 @@ describe('Custom SMTP Settings', () => { }); await init.pageClick(page, '#saveSmtp'); - const error = await init.pageWaitForSelector(page, '#errorInfo', { - hidden: true, - }); + const error: $TSFixMe = await init.pageWaitForSelector( + page, + '#errorInfo', + { + hidden: true, + } + ); expect(error).toBeDefined(); done(); diff --git a/Tests/saas-tests/dashboard/StatusPage2.test.ts b/Tests/saas-tests/dashboard/StatusPage2.test.ts index f4600bc5fe..7a723fbb89 100644 --- a/Tests/saas-tests/dashboard/StatusPage2.test.ts +++ b/Tests/saas-tests/dashboard/StatusPage2.test.ts @@ -22,7 +22,7 @@ const gotoTheFirstStatusPage: Function = async (page: $TSFixMe): void => { await init.pageWaitForSelector(page, '#statusPages'); await init.page$Eval(page, '#statusPages', (e: $TSFixMe) => e.click()); - const rowItem = await init.pageWaitForSelector( + const rowItem: $TSFixMe = await init.pageWaitForSelector( page, '#statusPagesListContainer > tr', { visible: true, timeout: init.timeout } @@ -31,7 +31,7 @@ const gotoTheFirstStatusPage: Function = async (page: $TSFixMe): void => { }; describe('Status Page', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -98,21 +98,15 @@ describe('Status Page', () => { await init.pageClick(page, '#btnAddStatusPageMonitors'); await page.reload({ waitUntil: 'networkidle2' }); - const firstMonitorContainer = await init.pageWaitForSelector( - page, - '#monitor-0', - { + const firstMonitorContainer: $TSFixMe = + await init.pageWaitForSelector(page, '#monitor-0', { visible: true, - } - ); + }); expect(firstMonitorContainer).toBeDefined(); - const secondMonitorContainer = await init.pageWaitForSelector( - page, - '#monitor-1', - { + const secondMonitorContainer: $TSFixMe = + await init.pageWaitForSelector(page, '#monitor-1', { visible: true, - } - ); + }); expect(secondMonitorContainer).toBeDefined(); done(); }, @@ -131,7 +125,7 @@ describe('Status Page', () => { link = await link.jsonValue(); await page.goto(link); - const classicTheme = await init.pageWaitForSelector( + const classicTheme: $TSFixMe = await init.pageWaitForSelector( page, '.uptime-stat-name' ); @@ -156,12 +150,12 @@ describe('Status Page', () => { await page.goto(link); await init.pageWaitForSelector(page, '#monitor0'); - const firstMonitorBeforeSwap = await init.page$Eval( + const firstMonitorBeforeSwap: $TSFixMe = await init.page$Eval( page, '#monitor0 .uptime-stat-name', (e: $TSFixMe) => e.textContent ); - const secondMonitorBeforeSwap = await init.page$Eval( + const secondMonitorBeforeSwap: $TSFixMe = await init.page$Eval( page, '#monitor1 .uptime-stat-name', (e: $TSFixMe) => e.textContent @@ -189,32 +183,26 @@ describe('Status Page', () => { await page.reload({ waitUntil: 'networkidle2' }); // We check if the monitors are added - const firstMonitorContainer = await init.pageWaitForSelector( - page, - '#monitor-0', - { + const firstMonitorContainer: $TSFixMe = + await init.pageWaitForSelector(page, '#monitor-0', { visible: true, - } - ); + }); expect(firstMonitorContainer).toBeDefined(); - const secondMonitorContainer = await init.pageWaitForSelector( - page, - '#monitor-1', - { + const secondMonitorContainer: $TSFixMe = + await init.pageWaitForSelector(page, '#monitor-1', { visible: true, - } - ); + }); expect(secondMonitorContainer).toBeDefined(); await page.goto(link); await init.pageWaitForSelector(page, '#monitor0'); - const firstMonitorAfterSwap = await init.page$Eval( + const firstMonitorAfterSwap: $TSFixMe = await init.page$Eval( page, '#monitor0 .uptime-stat-name', (e: $TSFixMe) => e.textContent ); - const secondMonitorAfterSwap = await init.page$Eval( + const secondMonitorAfterSwap: $TSFixMe = await init.page$Eval( page, '#monitor1 .uptime-stat-name', (e: $TSFixMe) => e.textContent @@ -233,10 +221,14 @@ describe('Status Page', () => { await gotoTheFirstStatusPage(page); await init.pageClick(page, '.custom-domains-tab'); - const elem = await init.pageWaitForSelector(page, '#domainNotSet', { - visible: true, - timeout: init.timeout, - }); + const elem: $TSFixMe = await init.pageWaitForSelector( + page, + '#domainNotSet', + { + visible: true, + timeout: init.timeout, + } + ); expect(elem).toBeDefined(); done(); }, @@ -265,14 +257,18 @@ describe('Status Page', () => { await init.pageWaitForSelector(page, '#addMoreDomainModal', { hidden: true, }); - const elem = await init.pageWaitForSelector(page, '#domainNotSet', { - hidden: true, - }); + const elem: $TSFixMe = await init.pageWaitForSelector( + page, + '#domainNotSet', + { + hidden: true, + } + ); expect(elem).toBeNull(); // if domain was not added sucessfully, list will be undefined // it will timeout - const list = await init.pageWaitForSelector( + const list: $TSFixMe = await init.pageWaitForSelector( page, 'fieldset[name="added-domain"]', { visible: true, timeout: init.timeout } @@ -305,7 +301,7 @@ describe('Status Page', () => { await init.pageWaitForSelector(page, '#customDomain'); - const input = await init.page$(page, '#customDomain'); + const input: $TSFixMe = await init.page$(page, '#customDomain'); await input.click({ clickCount: 3 }); await input.type(finalValue); @@ -353,7 +349,7 @@ describe('Status Page', () => { await init.pageClick(page, '#confirmVerifyDomain'); // element will be visible once the domain was not verified - const elem = await init.pageWaitForSelector( + const elem: $TSFixMe = await init.pageWaitForSelector( page, '#verifyDomainError', { @@ -383,7 +379,7 @@ describe('Status Page', () => { ); //Get the initial length of domains - const initialLength = await init.page$$Eval( + const initialLength: $TSFixMe = await init.page$$Eval( page, 'fieldset[name="added-domain"]', (domains: $TSFixMe) => domains.length @@ -439,7 +435,7 @@ describe('Status Page', () => { page, 'fieldset[name="added-domain"]' ); - const finalLength = await init.page$$Eval( + const finalLength: $TSFixMe = await init.page$$Eval( page, 'fieldset[name="added-domain"]', (domains: $TSFixMe) => domains.length @@ -467,7 +463,7 @@ describe('Status Page', () => { } ); //Get the initial length of domains - const initialLength = await init.page$$Eval( + const initialLength: $TSFixMe = await init.page$$Eval( page, 'fieldset[name="added-domain"]', (domains: $TSFixMe) => domains.length @@ -516,7 +512,7 @@ describe('Status Page', () => { 'fieldset[name="added-domain"]' ); // get the final length of domains after cancelling - const finalLength = await init.page$$Eval( + const finalLength: $TSFixMe = await init.page$$Eval( page, 'fieldset[name="added-domain"]', (domains: $TSFixMe) => domains.length diff --git a/Tests/saas-tests/dashboard/StatusPage3.test.ts b/Tests/saas-tests/dashboard/StatusPage3.test.ts index b9468d6c77..9eaa60c0d2 100644 --- a/Tests/saas-tests/dashboard/StatusPage3.test.ts +++ b/Tests/saas-tests/dashboard/StatusPage3.test.ts @@ -21,7 +21,7 @@ const gotoTheFirstStatusPage: Function = async (page: $TSFixMe): void => { await init.pageWaitForSelector(page, '#statusPages'); await init.page$Eval(page, '#statusPages', (e: $TSFixMe) => e.click()); - const rowItem = await init.pageWaitForSelector( + const rowItem: $TSFixMe = await init.pageWaitForSelector( page, '#statusPagesListContainer > tr', { visible: true, timeout: init.timeout } @@ -30,7 +30,7 @@ const gotoTheFirstStatusPage: Function = async (page: $TSFixMe): void => { }; describe('Status Page', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -152,7 +152,7 @@ describe('Status Page', () => { await page.goto(link); await init.pageWaitForSelector(page, '#js', { hidden: true }); - const code = await init.page$Eval( + const code: $TSFixMe = await init.page$Eval( page, '#js', (script: $TSFixMe) => script.innerHTML, @@ -185,7 +185,7 @@ describe('Status Page', () => { visible: true, timeout: init.timeout, }); - const element = await init.page$Eval( + const element: $TSFixMe = await init.page$Eval( page, '#field-error', (e: $TSFixMe) => { @@ -224,7 +224,7 @@ describe('Status Page', () => { visible: true, timeout: init.timeout, }); - const element = await init.page$Eval( + const element: $TSFixMe = await init.page$Eval( page, '#field-error', (e: $TSFixMe) => { @@ -261,14 +261,18 @@ describe('Status Page', () => { await init.pageWaitForSelector(page, '#addMoreDomainModal', { hidden: true, }); - const elem = await init.pageWaitForSelector(page, '#domainNotSet', { - hidden: true, - }); + const elem: $TSFixMe = await init.pageWaitForSelector( + page, + '#domainNotSet', + { + hidden: true, + } + ); expect(elem).toBeNull(); // if domain was not added sucessfully, list will be undefined // it will timeout - const list = await init.pageWaitForSelector( + const list: $TSFixMe = await init.pageWaitForSelector( page, 'fieldset[name="added-domain"]', { visible: true, timeout: init.timeout } @@ -300,7 +304,7 @@ describe('Status Page', () => { await init.pageType(page, '#customDomain', customDomain); await init.pageClick(page, '#createCustomDomainBtn'); - const addDomainError = await init.pageWaitForSelector( + const addDomainError: $TSFixMe = await init.pageWaitForSelector( page, '#addDomainError', { diff --git a/Tests/saas-tests/dashboard/StatusPageSubProject.test.ts b/Tests/saas-tests/dashboard/StatusPageSubProject.test.ts index e42972a760..a1e4e64fd9 100755 --- a/Tests/saas-tests/dashboard/StatusPageSubProject.test.ts +++ b/Tests/saas-tests/dashboard/StatusPageSubProject.test.ts @@ -188,7 +188,7 @@ describe('StatusPage API With SubProjects', () => { await page.goto(utils.DASHBOARD_URL, { waitUntil: ['networkidle2'], }); - for (let i = 0; i < 10; i++) { + for (let i: $TSFixMe = 0; i < 10; i++) { const statuspageName: string = utils.generateRandomString(); await init.addStatusPageToProject( statuspageName, @@ -205,7 +205,7 @@ describe('StatusPage API With SubProjects', () => { page, 'tr.statusPageListItem' ); - let countStatusPages = statusPageRows.length; + let countStatusPages: $TSFixMe = statusPageRows.length; expect(countStatusPages).toEqual(10); diff --git a/Tests/saas-tests/dashboard/SwitchProject.test.ts b/Tests/saas-tests/dashboard/SwitchProject.test.ts index 517f93311f..0477e0101d 100755 --- a/Tests/saas-tests/dashboard/SwitchProject.test.ts +++ b/Tests/saas-tests/dashboard/SwitchProject.test.ts @@ -71,15 +71,17 @@ describe('Project API', () => { page.waitForNavigation(), ]); - const localStorageData = await page.evaluate((): $TSFixMe => { - const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key: $TSFixMe = localStorage.key(i); + const localStorageData: $TSFixMe = await page.evaluate( + (): $TSFixMe => { + const json: $TSFixMe = {}; + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); - json[key] = localStorage.getItem(key); + json[key] = localStorage.getItem(key); + } + return json; } - return json; - }); + ); localStorageData.should.have.property('project'); @@ -113,15 +115,17 @@ describe('Project API', () => { await element.click(); await page.waitForNavigation(); - const localStorageData = await page.evaluate((): $TSFixMe => { - const json: $TSFixMe = {}; - for (let i = 0; i < localStorage.length; i++) { - const key: $TSFixMe = localStorage.key(i); + const localStorageData: $TSFixMe = await page.evaluate( + (): $TSFixMe => { + const json: $TSFixMe = {}; + for (let i: $TSFixMe = 0; i < localStorage.length; i++) { + const key: $TSFixMe = localStorage.key(i); - json[key] = localStorage.getItem(key); + json[key] = localStorage.getItem(key); + } + return json; } - return json; - }); + ); localStorageData.should.have.property('project'); diff --git a/Tests/saas-tests/dashboard/TeamGroupsReload.test.ts b/Tests/saas-tests/dashboard/TeamGroupsReload.test.ts index f9cf8ae580..6e2e164629 100644 --- a/Tests/saas-tests/dashboard/TeamGroupsReload.test.ts +++ b/Tests/saas-tests/dashboard/TeamGroupsReload.test.ts @@ -14,7 +14,7 @@ const groupName: string = utils.generateRandomString(); */ describe('OneUptime Page Reload', () => { - const operationTimeOut = 100000; + const operationTimeOut: $TSFixMe = 100000; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(100000); @@ -50,7 +50,7 @@ describe('OneUptime Page Reload', () => { await init.selectDropdownValue('#componentList', 'Test Name', page); await init.pageClick(page, '#btnAddGroup'); - const spanElement = await page.waitForSelector( + const spanElement: $TSFixMe = await page.waitForSelector( `#sub_project_name_${groupName}` ); expect(spanElement).toBeDefined(); diff --git a/Tests/saas-tests/dashboard/TeamMemberReload.test.ts b/Tests/saas-tests/dashboard/TeamMemberReload.test.ts index ca0e11b342..2b5ae873b2 100644 --- a/Tests/saas-tests/dashboard/TeamMemberReload.test.ts +++ b/Tests/saas-tests/dashboard/TeamMemberReload.test.ts @@ -18,7 +18,7 @@ const teamMember: Email = utils.generateRandomBusinessEmail(); */ describe('OneUptime Page Reload', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -77,7 +77,7 @@ describe('OneUptime Page Reload', () => { visible: true, timeout: init.timeout, }); - const spanElement = await init.pageWaitForSelector( + const spanElement: $TSFixMe = await init.pageWaitForSelector( page, `#${teamMember.split('@')[0]}`, { visible: true, timeout: init.timeout } diff --git a/Tests/saas-tests/dashboard/TeamSubProject.test.ts b/Tests/saas-tests/dashboard/TeamSubProject.test.ts index 61a0fb5934..62181199e7 100755 --- a/Tests/saas-tests/dashboard/TeamSubProject.test.ts +++ b/Tests/saas-tests/dashboard/TeamSubProject.test.ts @@ -18,7 +18,7 @@ const anotherEmail: Email = utils.generateRandomBusinessEmail(); const subProjectName: string = utils.generateRandomString(); describe('Team API With SubProjects', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -89,7 +89,7 @@ describe('Team API With SubProjects', () => { }); await init.pageWaitForSelector(page, `#count_${projectName}`); - const memberCount = await init.page$Eval( + const memberCount: $TSFixMe = await init.page$Eval( page, `#count_${projectName}`, (elem: $TSFixMe) => elem.textContent @@ -118,7 +118,7 @@ describe('Team API With SubProjects', () => { await init.pageClick(page, `#btn_${projectName}`); await init.pageWaitForSelector(page, `#frm_${projectName}`); - const elementHandle = await init.page$( + const elementHandle: $TSFixMe = await init.page$( page, `#${role}_${projectName}`, { hidden: true } @@ -146,7 +146,7 @@ describe('Team API With SubProjects', () => { await init.pageClick(page, `#btn_${projectName}`); await init.pageWaitForSelector(page, `#frm_${projectName}`); - const elementHandle = await init.page$( + const elementHandle: $TSFixMe = await init.page$( page, `#${role}_${projectName}`, { hidden: true } @@ -204,7 +204,7 @@ describe('Team API With SubProjects', () => { ); await init.pageWaitForSelector(page, `#count_${subProjectName}`); - const memberCount = await init.page$Eval( + const memberCount: $TSFixMe = await init.page$Eval( page, `#count_${subProjectName}`, (elem: $TSFixMe) => elem.textContent @@ -220,7 +220,7 @@ describe('Team API With SubProjects', () => { 'should update existing user role in parent project and all sub-projects (old role -> administrator, new role -> member)', async (done: $TSFixMe) => { const newRole: string = 'Member'; - const emailSelector = anotherEmail.split('@')[0]; + const emailSelector: $TSFixMe = anotherEmail.split('@')[0]; await page.goto(utils.DASHBOARD_URL, { waitUntil: ['networkidle2'], }); @@ -244,7 +244,7 @@ describe('Team API With SubProjects', () => { await init.pageClick(page, `#${newRole}`); - const member = await init.pageWaitForSelector( + const member: $TSFixMe = await init.pageWaitForSelector( page, `#${newRole}_${emailSelector}`, { @@ -261,7 +261,7 @@ describe('Team API With SubProjects', () => { test( 'should remove user from project Team Members and all sub-projects.', async (done: $TSFixMe) => { - const emailSelector = anotherEmail.split('@')[0]; + const emailSelector: $TSFixMe = anotherEmail.split('@')[0]; await page.goto(utils.DASHBOARD_URL, { waitUntil: ['networkidle2'], }); @@ -288,7 +288,7 @@ describe('Team API With SubProjects', () => { }); await init.pageWaitForSelector(page, `#count_${projectName}`); - const memberCount = await init.page$Eval( + const memberCount: $TSFixMe = await init.page$Eval( page, `#count_${projectName}`, (elem: $TSFixMe) => elem.textContent @@ -304,7 +304,7 @@ describe('Team API With SubProjects', () => { 'should not add team members without business emails', async (done: $TSFixMe) => { const role: string = 'Member'; - const nonBusinessEmail = + const nonBusinessEmail: $TSFixMe = utils.generateRandomString() + '@gmail.com'; await page.goto(utils.DASHBOARD_URL, { waitUntil: ['networkidle2'], @@ -356,8 +356,8 @@ describe('Team API With SubProjects', () => { 'should assign a new owner of the project', async (done: $TSFixMe) => { const newRole: string = 'Owner'; - const memberEmailSelector = anotherEmail.split('@')[0]; - const ownerEmailSelector = email.split('@')[0]; + const memberEmailSelector: $TSFixMe = anotherEmail.split('@')[0]; + const ownerEmailSelector: $TSFixMe = email.split('@')[0]; await page.goto(utils.DASHBOARD_URL, { waitUntil: ['networkidle2'], @@ -398,13 +398,13 @@ describe('Team API With SubProjects', () => { page, `#changeRole_${memberEmailSelector}` ); - const oldMemberRole = await init.page$Eval( + const oldMemberRole: $TSFixMe = await init.page$Eval( page, `#Member_${memberEmailSelector}`, (elem: $TSFixMe) => elem.innerHTML ); expect(oldMemberRole).toEqual('Member'); - const oldOwnerRole = await init.page$Eval( + const oldOwnerRole: $TSFixMe = await init.page$Eval( page, `#Owner_${ownerEmailSelector}`, (elem: $TSFixMe) => elem.innerHTML @@ -421,13 +421,13 @@ describe('Team API With SubProjects', () => { await init.pageClick(page, '#confirmRoleChange'); - const newMemberRole = await init.page$Eval( + const newMemberRole: $TSFixMe = await init.page$Eval( page, `#Owner_${memberEmailSelector}`, (elem: $TSFixMe) => elem.innerHTML ); expect(newMemberRole).toEqual('Owner'); - const newOwnerRole = await init.page$Eval( + const newOwnerRole: $TSFixMe = await init.page$Eval( page, `#Administrator_${ownerEmailSelector}`, (elem: $TSFixMe) => elem.innerHTML diff --git a/Tests/saas-tests/dashboard/TwoFactorAuthentication.test.ts b/Tests/saas-tests/dashboard/TwoFactorAuthentication.test.ts index 458cb4b65a..0f6c7adbe5 100644 --- a/Tests/saas-tests/dashboard/TwoFactorAuthentication.test.ts +++ b/Tests/saas-tests/dashboard/TwoFactorAuthentication.test.ts @@ -16,7 +16,7 @@ const password: string = '1234567890'; let token: $TSFixMe; const generateOtp: Function = (): void => { - const otp = speakeasy.totp({ + const otp: $TSFixMe = speakeasy.totp({ secret: token.trim(), encoding: 'base32', }); @@ -24,7 +24,7 @@ const generateOtp: Function = (): void => { }; describe('TwoFactor Authentication API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(360000); @@ -84,7 +84,7 @@ describe('TwoFactor Authentication API', () => { await init.pageClick(page, '#enableTwoFactorAuthButton'); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '#modal-message', (element: $TSFixMe) => element.innerHTML @@ -125,7 +125,7 @@ describe('TwoFactor Authentication API', () => { (element: $TSFixMe) => element.innerHTML ); - const otp = await generateOtp(token); + const otp: $TSFixMe = await generateOtp(token); await init.pageWaitForSelector(page, '#nextFormButton'); @@ -138,7 +138,7 @@ describe('TwoFactor Authentication API', () => { await init.pageWaitForSelector(page, '#enableTwoFactorAuthButton'); await init.pageClick(page, '#enableTwoFactorAuthButton'); - const isVisible = await init.isElementOnPage( + const isVisible: $TSFixMe = await init.isElementOnPage( page, '#modal-message' ); @@ -172,7 +172,7 @@ describe('TwoFactor Authentication API', () => { timeout: init.timeout, }); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '.message', (element: $TSFixMe) => element.innerHTML @@ -210,7 +210,7 @@ describe('TwoFactor Authentication API', () => { await init.pageClick(page, 'button[type=submit]'); - const message = await init.page$Eval( + const message: $TSFixMe = await init.page$Eval( page, '.title span', (element: $TSFixMe) => element.innerHTML @@ -240,7 +240,7 @@ describe('TwoFactor Authentication API', () => { await init.pageClick(page, 'button[type=submit]'); - const otp = generateOtp(); + const otp: $TSFixMe = generateOtp(); await init.pageWaitForSelector(page, '#token'); diff --git a/Tests/saas-tests/dashboard/UserFeedback.test.ts b/Tests/saas-tests/dashboard/UserFeedback.test.ts index c94f9e3893..cbd97171fd 100755 --- a/Tests/saas-tests/dashboard/UserFeedback.test.ts +++ b/Tests/saas-tests/dashboard/UserFeedback.test.ts @@ -10,7 +10,7 @@ const password: string = '1234567890'; let browser: $TSFixMe, page: $TSFixMe; describe('User Feedback', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async (done: $TSFixMe) => { jest.setTimeout(init.timeout); @@ -51,7 +51,7 @@ describe('User Feedback', () => { await init.pageWaitForSelector(page, '#feedback-div'); - const feedbackMessage = await init.page$Eval( + const feedbackMessage: $TSFixMe = await init.page$Eval( page, '#feedback-div', (el: $TSFixMe) => el.textContent diff --git a/Tests/saas-tests/dashboard/incidentPriority.test.ts b/Tests/saas-tests/dashboard/incidentPriority.test.ts index 22c684ddb4..928fcadd4d 100644 --- a/Tests/saas-tests/dashboard/incidentPriority.test.ts +++ b/Tests/saas-tests/dashboard/incidentPriority.test.ts @@ -12,7 +12,7 @@ const newPriorityName: string = utils.generateRandomString(); const password: string = '1234567890'; describe('Incident Priority API', () => { - const operationTimeOut = init.timeout; + const operationTimeOut: $TSFixMe = init.timeout; beforeAll(async () => { jest.setTimeout(init.timeout); @@ -91,7 +91,7 @@ describe('Incident Priority API', () => { const lastRowFirstColumnIndentifier: string = `#priority_${priorityName}_2`; await init.pageWaitForSelector(page, lastRowFirstColumnIndentifier); - const content = await init.page$Eval( + const content: $TSFixMe = await init.page$Eval( page, lastRowFirstColumnIndentifier, (e: $TSFixMe) => e.textContent @@ -162,7 +162,7 @@ describe('Incident Priority API', () => { const lastRowIndentifier: string = `#priority_${newPriorityName}_2`; await init.pageWaitForSelector(page, lastRowIndentifier); - const content = await init.page$Eval( + const content: $TSFixMe = await init.page$Eval( page, lastRowIndentifier, (e: $TSFixMe) => e.textContent @@ -204,7 +204,7 @@ describe('Incident Priority API', () => { const incidentPrioritiesCount: string = '#incidentPrioritiesCount'; await init.pageWaitForSelector(page, incidentPrioritiesCount); - const incidentsCountBeforeDeletion = await init.page$Eval( + const incidentsCountBeforeDeletion: $TSFixMe = await init.page$Eval( page, incidentPrioritiesCount, (e: $TSFixMe) => e.textContent @@ -237,7 +237,7 @@ describe('Incident Priority API', () => { ); await init.pageWaitForSelector(page, incidentPrioritiesCount); - const incidentsCountAfterDeletion = await init.page$Eval( + const incidentsCountAfterDeletion: $TSFixMe = await init.page$Eval( page, incidentPrioritiesCount, (e: $TSFixMe) => e.textContent @@ -283,7 +283,7 @@ describe('Incident Priority API', () => { visible: true, timeout: init.timeout, }); - const incidentPrioritiesCountIdentifier = + const incidentPrioritiesCountIdentifier: $TSFixMe = '#incidentPrioritiesCount'; await init.pageWaitForSelector( @@ -299,7 +299,7 @@ describe('Incident Priority API', () => { 'Page 1 of 1 (2 Priorities)' ); - for (let i = 0; i < 11; i++) { + for (let i: $TSFixMe = 0; i < 11; i++) { await init.pageWaitForSelector(page, '#addNewPriority'); await init.pageClick(page, '#addNewPriority'); diff --git a/Tests/saas-tests/home/downloadWhitepaper.test.ts b/Tests/saas-tests/home/downloadWhitepaper.test.ts index cfbdde322e..74cda87b73 100644 --- a/Tests/saas-tests/home/downloadWhitepaper.test.ts +++ b/Tests/saas-tests/home/downloadWhitepaper.test.ts @@ -5,13 +5,13 @@ import init from '../../test-init'; import axios from 'axios'; -let page, browser: $TSFixMe; +let page: $TSFixMe, browser: $TSFixMe; // user credentials const email: Email = utils.generateRandomBusinessEmail(); const queryString: string = '?utm_source=runningtest&good=thankyou&kill=love&ion=pure'; -let queryObj = {}; +let queryObj: $TSFixMe = {}; describe('Download Whitepaper form', () => { beforeAll(async (done: $TSFixMe) => { @@ -67,7 +67,7 @@ describe('Download Whitepaper form', () => { await init.pageClick(page, '#request-resource-btn'); - const params = new URLSearchParams(queryString); + const params: $TSFixMe = new URLSearchParams(queryString); // formating query string to an object for (const param of params) { queryObj = { ...queryObj, [`${param[0]}`]: param[1] }; @@ -95,8 +95,8 @@ describe('Download Whitepaper form', () => { }, data: data, }; - const res = await axios(config); - const sourceObj = res.data[0].source; + const res: $TSFixMe = await axios(config); + const sourceObj: $TSFixMe = res.data[0].source; for (const key in sourceObj) { expect(sourceObj[key]).toEqual(queryObj[key]); } diff --git a/Tests/saas-tests/home/home.test.ts b/Tests/saas-tests/home/home.test.ts index 39396cfe9b..78d0db1277 100644 --- a/Tests/saas-tests/home/home.test.ts +++ b/Tests/saas-tests/home/home.test.ts @@ -52,7 +52,7 @@ describe('Request demo', () => { visible: true, timeout: init.timeout, }); - const emailSubmitted = await page.evaluate( + const emailSubmitted: $TSFixMe = await page.evaluate( () => document.querySelector('.submitted-email').innerText ); expect(emailSubmitted).toBe(utils.user.email); @@ -101,7 +101,7 @@ describe('Request demo', () => { visible: true, timeout: init.timeout, }); - const emailSubmitted = await page.evaluate( + const emailSubmitted: $TSFixMe = await page.evaluate( () => document.querySelector('.submitted-email').innerText ); expect(emailSubmitted).toBe(utils.user.email); @@ -150,7 +150,7 @@ describe('Request demo', () => { visible: true, timeout: init.timeout, }); - const emailSubmitted = await page.evaluate( + const emailSubmitted: $TSFixMe = await page.evaluate( () => document.querySelector('.submitted-email').innerText ); expect(emailSubmitted).toBe(utils.user.email); @@ -199,7 +199,7 @@ describe('Request demo', () => { visible: true, timeout: init.timeout, }); - const emailSubmitted = await page.evaluate( + const emailSubmitted: $TSFixMe = await page.evaluate( () => document.querySelector('.submitted-email').innerText ); expect(emailSubmitted).toBe(utils.user.email); @@ -248,7 +248,7 @@ describe('Request demo', () => { visible: true, timeout: init.timeout, }); - const emailSubmitted = await page.evaluate( + const emailSubmitted: $TSFixMe = await page.evaluate( () => document.querySelector('.submitted-email').innerText ); expect(emailSubmitted).toBe(utils.user.email); diff --git a/Tests/saas-tests/home/requestDemo.test.ts b/Tests/saas-tests/home/requestDemo.test.ts index 4c438e5db8..9ce728d6c8 100644 --- a/Tests/saas-tests/home/requestDemo.test.ts +++ b/Tests/saas-tests/home/requestDemo.test.ts @@ -5,13 +5,13 @@ import init from '../../test-init'; import axios from 'axios'; -let page, browser: $TSFixMe; +let page: $TSFixMe, browser: $TSFixMe; // user credentials const email: Email = utils.generateRandomBusinessEmail(); const queryString: string = '?utm_source=runningtest&good=thankyou&kill=love&ion=pure'; -let queryObj = {}; +let queryObj: $TSFixMe = {}; describe('Demo form', () => { beforeAll(async (done: $TSFixMe) => { @@ -58,7 +58,7 @@ describe('Demo form', () => { timeout: init.timeout, }); - const params = new URLSearchParams(queryString); + const params: $TSFixMe = new URLSearchParams(queryString); // formating query string to an object for (const param of params) { queryObj = { ...queryObj, [`${param[0]}`]: param[1] }; @@ -86,8 +86,8 @@ describe('Demo form', () => { }, data: data, }; - const res = await axios(config); - const sourceObj = res.data[0].source; + const res: $TSFixMe = await axios(config); + const sourceObj: $TSFixMe = res.data[0].source; for (const key in sourceObj) { expect(sourceObj[key]).toEqual(queryObj[key]); } diff --git a/Tests/saas-tests/status-page/status-page.test.ts b/Tests/saas-tests/status-page/status-page.test.ts index ab1b286845..142f708fb1 100644 --- a/Tests/saas-tests/status-page/status-page.test.ts +++ b/Tests/saas-tests/status-page/status-page.test.ts @@ -43,7 +43,7 @@ describe('Check StatusPage up', () => { visible: true, timeout: init.timeout, }); - const response = await init.page$Eval( + const response: $TSFixMe = await init.page$Eval( page, '#error', (e: $TSFixMe) => { @@ -284,8 +284,8 @@ describe('Check StatusPage up', () => { 'should add more monitors and see if they are present on the StatusPage', async (done: $TSFixMe) => { // This creates 2 additonal monitors - let additionalMonitor = 0; - for (let i = 0; i < 2; i++) { + let additionalMonitor: $TSFixMe = 0; + for (let i: $TSFixMe = 0; i < 2; i++) { await init.navigateToComponentDetails(componentName, page); const monitorName: string = utils.generateRandomString(); const description: string = utils.generateRandomString(); @@ -314,8 +314,8 @@ describe('Check StatusPage up', () => { timeout: init.timeout, }); - const monitor = await init.page$$(page, '.monitor-list'); - const monitorLength = monitor.length; + const monitor: $TSFixMe = await init.page$$(page, '.monitor-list'); + const monitorLength: $TSFixMe = monitor.length; expect(monitorLength).toEqual(3); done(); diff --git a/Tests/saas-tests/status-page/status-probeBar.test.ts b/Tests/saas-tests/status-page/status-probeBar.test.ts index 806ec0b292..7b3ce6f808 100644 --- a/Tests/saas-tests/status-page/status-probeBar.test.ts +++ b/Tests/saas-tests/status-page/status-probeBar.test.ts @@ -86,8 +86,8 @@ describe('Probe bar test', () => { await page.goto(link); // To confirm if the probe shows after creating a status. - const probeBar = await page.evaluate(() => { - const el = document.querySelector('.bs-probes'); + const probeBar: $TSFixMe = await page.evaluate(() => { + const el: $TSFixMe = document.querySelector('.bs-probes'); return el ? el.innerText : ''; }); diff --git a/Tests/test-init.ts b/Tests/test-init.ts index 74852ecdfb..18884a28af 100644 --- a/Tests/test-init.ts +++ b/Tests/test-init.ts @@ -77,7 +77,7 @@ const _this: $TSFixMe = { } ); - const stripeIframeElements = await this.page$$( + const stripeIframeElements: $TSFixMe = await this.page$$( page, '.__PrivateStripeElement > iframe' ); @@ -150,10 +150,13 @@ const _this: $TSFixMe = { await this.pageClick(page, 'button[type=submit]'); - const home = await this.pageWaitForSelector(page, '#profile-menu'); + const home: $TSFixMe = await this.pageWaitForSelector( + page, + '#profile-menu' + ); expect(home).toBeDefined(); // This ensures that we have been navigated to the dashboard page - const signupResponse = await page.waitForResponse( + const signupResponse: $TSFixMe = await page.waitForResponse( (response: $TSFixMe) => response.status() === 200 // The page navigates however '/user/signup' is not strictly included in the response. ); @@ -223,7 +226,7 @@ const _this: $TSFixMe = { } ); - const stripeIframeElements = await this.page$$( + const stripeIframeElements: $TSFixMe = await this.page$$( page, '.__PrivateStripeElement > iframe' ); @@ -511,7 +514,10 @@ const _this: $TSFixMe = { await page.goto(utils.ACCOUNTS_URL + '/login', { waitUntil: 'networkidle2', }); - const signUp = await this.isElementOnPage(page, '#signUpLink'); + const signUp: $TSFixMe = await this.isElementOnPage( + page, + '#signUpLink' + ); if (signUp) { await page.goto(utils.ACCOUNTS_URL + '/register', { @@ -597,14 +603,14 @@ const _this: $TSFixMe = { await this.pageClick(page, 'button[type=submit]'); try { - const signupResponse = await page.waitForResponse( + const signupResponse: $TSFixMe = await page.waitForResponse( (response: $TSFixMe) => response.url().includes('/user/signup') && response.status() === 200 ); if (signupResponse) { - const signupData = await signupResponse.text(); - const parsedSignupData = JSON.parse(signupData); + const signupData: $TSFixMe = await signupResponse.text(); + const parsedSignupData: $TSFixMe = JSON.parse(signupData); if (parsedSignupData.verificationToken) { await request .get( @@ -658,7 +664,7 @@ const _this: $TSFixMe = { await page.keyboard.press('Tab'); //String.fromCharCode(9) could not press tab }, clear: async function (selector: $TSFixMe, page: $TSFixMe): void { - const input = await this.page$(page, selector); + const input: $TSFixMe = await this.page$(page, selector); await input.click({ clickCount: 3 }); await input.type(''); }, @@ -1187,7 +1193,7 @@ const _this: $TSFixMe = { subProjectName: $TSFixMe, page: $TSFixMe ): void { - const subProjectNameSelector = await this.isElementOnPage( + const subProjectNameSelector: $TSFixMe = await this.isElementOnPage( page, '#btn_Add_SubProjects', @@ -1464,7 +1470,7 @@ const _this: $TSFixMe = { page, '[data-testId=add_criterion_up]', (addCriterionButtons: $TSFixMe) => { - const lastAddCriterionButton = + const lastAddCriterionButton: $TSFixMe = addCriterionButtons[addCriterionButtons.length - 1]; lastAddCriterionButton.click(); } @@ -1532,7 +1538,7 @@ const _this: $TSFixMe = { page, '[data-testId=add_criterion_degraded]', (addCriterionButtons: $TSFixMe) => { - const lastAddCriterionButton = + const lastAddCriterionButton: $TSFixMe = addCriterionButtons[addCriterionButtons.length - 1]; lastAddCriterionButton.click(); } @@ -1689,7 +1695,7 @@ const _this: $TSFixMe = { projectName: $TSFixMe, page: $TSFixMe ): void { - const createStatusPageSelector = await page.$( + const createStatusPageSelector: $TSFixMe = await page.$( `#btnCreateStatusPage_${projectName}` ); if (createStatusPageSelector) { @@ -1727,7 +1733,7 @@ const _this: $TSFixMe = { projectName: $TSFixMe, page: $TSFixMe ): void { - const createStatusPageSelector = await this.page$( + const createStatusPageSelector: $TSFixMe = await this.page$( page, `#btnCreateStatusPage_${projectName}`, { hidden: true } @@ -1880,7 +1886,7 @@ const _this: $TSFixMe = { await this.pageType(page, '#name', projectName ? projectName : 'test'); await this.pageClick(page, 'label[for=Startup_month]'); - const startupOption = await this.pageWaitForSelector( + const startupOption: $TSFixMe = await this.pageWaitForSelector( page, 'label[for=Startup_month]', { visible: true, timeout: this.timeout } @@ -1892,11 +1898,11 @@ const _this: $TSFixMe = { 'iframe[name=__privateStripeFrame5]' ); - const elementHandle = await this.page$( + const elementHandle: $TSFixMe = await this.page$( page, 'iframe[name=__privateStripeFrame5]' ); - const frame = await elementHandle.contentFrame(); + const frame: $TSFixMe = await elementHandle.contentFrame(); await frame.waitForSelector('input[name=cardnumber]'); await frame.type('input[name=cardnumber]', '42424242424242424242', { delay: 200, @@ -1959,7 +1965,7 @@ const _this: $TSFixMe = { hidden: true, }); - const createdResourceCategorySelector = + const createdResourceCategorySelector: $TSFixMe = '#resourceCategoryList #resource-category-name'; await this.pageWaitForSelector(page, createdResourceCategorySelector, { visible: true, @@ -1986,7 +1992,7 @@ const _this: $TSFixMe = { await this.pageType(page, '#name', projectName); await this.pageClick(page, 'label[for=Growth_month]'); - const growthOption = await this.pageWaitForSelector( + const growthOption: $TSFixMe = await this.pageWaitForSelector( page, 'label[for=Growth_month]', { visible: true, timeout: this.timeout } @@ -2018,7 +2024,7 @@ const _this: $TSFixMe = { await this.pageType(page, '#name', projectName); await this.pageClick(page, 'label[for=Scale_month]'); - const scaleOption = await this.pageWaitForSelector( + const scaleOption: $TSFixMe = await this.pageWaitForSelector( page, 'label[for=Scale_month]', { visible: true, timeout: this.timeout } diff --git a/Tests/test-utils.ts b/Tests/test-utils.ts index 91d95ec7c1..2751e520ee 100644 --- a/Tests/test-utils.ts +++ b/Tests/test-utils.ts @@ -11,7 +11,7 @@ user.message = 'Test message'; const agent: $TSFixMe = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36'; -let slomo = 20; +let slomo: $TSFixMe = 20; if ( process.env.SLOMO && @@ -81,7 +81,7 @@ function generateRandomString(): void { const result: $TSFixMe = []; const characters: string = 'abcdefghijklmnopqrstuvwxyz'; const charactersLength: $TSFixMe = characters.length; - for (let i = 0; i < 5; i++) { + for (let i: $TSFixMe = 0; i < 5; i++) { result.push( characters.charAt(Math.floor(Math.random() * charactersLength)) ); diff --git a/_test/error-tracker-js/index.ts b/_test/error-tracker-js/index.ts index b59d315fd8..936a874af6 100644 --- a/_test/error-tracker-js/index.ts +++ b/_test/error-tracker-js/index.ts @@ -9,7 +9,7 @@ const options: $TSFixMe = { }; // constructor -const tracker = new oneuptime.ErrorTracker( +const tracker: $TSFixMe = new oneuptime.ErrorTracker( 'https://staging.oneuptime.com/api', '605bad70ae110c0013e14005', 'cb4b107a-7f28-464d-9fda-32715fa4cd68', diff --git a/_test/logger-js/index.ts b/_test/logger-js/index.ts index a1fc78eb9f..3a53b76501 100644 --- a/_test/logger-js/index.ts +++ b/_test/logger-js/index.ts @@ -1,10 +1,10 @@ // In a FrontEnd Environment import oneuptime from 'oneuptime-staging'; -const Logger = oneuptime.Logger; +const Logger: $TSFixMe = oneuptime.Logger; // constructor -const logger = new Logger( +const logger: $TSFixMe = new Logger( 'https://staging.oneuptime.com/api', '6053aae39b79460013b35102', '4904db2d-968c-4656-b6c0-aac450c97ee2' diff --git a/_test/performance-tracker/app.ts b/_test/performance-tracker/app.ts index 8d1deda8ee..a47aea9c19 100644 --- a/_test/performance-tracker/app.ts +++ b/_test/performance-tracker/app.ts @@ -1,6 +1,6 @@ import express, { Request, Response } from 'CommonServer/utils/Express' import OneUptime from 'oneuptime-staging' -const app = express() +const app: $TSFixMe = express() import axios from 'axios' diff --git a/_test/script-monitor/scriptSandbox.test.ts b/_test/script-monitor/scriptSandbox.test.ts index 8ff52b7fe2..9f63f01eef 100644 --- a/_test/script-monitor/scriptSandbox.test.ts +++ b/_test/script-monitor/scriptSandbox.test.ts @@ -15,7 +15,7 @@ describe('ScriptMonitor V2', function ():void { before(function ():void { import express from "express" - const app = express.getExpressApp(); + const app: $TSFixMe = express.getExpressApp(); app.get("/test", (req: ExpressRequest, res: ExpressResponse) => res.send("yipee!")); server = app.listen(5050); }); @@ -32,12 +32,12 @@ describe('ScriptMonitor V2', function ():void { - const res = await axios.get("http://localhost:5050/test"); + const res: $TSFixMe = await axios.get("http://localhost:5050/test"); done(); } - const result = await runScript(someFunction.toString(), true); + const result: $TSFixMe = await runScript(someFunction.toString(), true); expect(result).to.not.be.undefined; expect(result.success).to.be.true; expect(result.status).eq("completed"); @@ -57,7 +57,7 @@ describe('ScriptMonitor V2', function ():void { logger.error('Bad Error'); throw new Error("Bad error"); } - const result = await runScript(someFunction.toString(), true); + const result: $TSFixMe = await runScript(someFunction.toString(), true); expect(result).to.not.be.undefined; expect(result.success).to.be.false; @@ -76,7 +76,7 @@ describe('ScriptMonitor V2', function ():void { const someFunction: Function = async (done: $TSFixMe): void => { done("Some Error"); } - const result = await runScript(someFunction.toString(), true); + const result: $TSFixMe = await runScript(someFunction.toString(), true); expect(result).to.be.ok; expect(result.success).to.be.false; @@ -94,7 +94,7 @@ describe('ScriptMonitor V2', function ():void { setTimeout(() => "All timed out", 7000); }) } - const result = await runScript(someFunction.toString(), true, { maxScriptRunTime: 1500 }); + const result: $TSFixMe = await runScript(someFunction.toString(), true, { maxScriptRunTime: 1500 }); expect(result).to.be.ok; expect(result.success).to.be.false; @@ -111,7 +111,7 @@ describe('ScriptMonitor V2', function ():void { // statement stuck in loop or too busy } } - const result = await runScript(someFunction.toString(), true, { maxSyncStatementDuration: 300 }); + const result: $TSFixMe = await runScript(someFunction.toString(), true, { maxSyncStatementDuration: 300 }); expect(result).to.be.ok; expect(result.success).to.be.false; diff --git a/_test/script-monitor/scriptSandbox.ts b/_test/script-monitor/scriptSandbox.ts index 9061400a75..740000cba2 100644 --- a/_test/script-monitor/scriptSandbox.ts +++ b/_test/script-monitor/scriptSandbox.ts @@ -43,9 +43,9 @@ const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, o // modifiable option in development mode only const { maxScriptRunTime, maxSyncStatementDuration } = options; if (!isCalled) return; - const start = performance.now(); + const start: $TSFixMe = performance.now(); return new Promise(resolve => { - const worker = new Worker(__filename, { + const worker: $TSFixMe = new Worker(__filename, { workerData: { functionCode }, execArgv: [ ...process.execArgv, @@ -97,7 +97,7 @@ const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, o }); break; case 1: { - const message = statementTimeExceeded + const message: $TSFixMe = statementTimeExceeded ? `Max. synchronous statement execution time exceeded (${maxSyncStatementDuration}ms)` : scriptTimeExceeded ? `Max. script execution time exceeded (${maxScriptRunTime}ms)` @@ -148,11 +148,11 @@ const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, o worker.terminate(); }); - let totalRuntime = 0, + let totalRuntime: $TSFixMe = 0, statementTimeExceeded = false, scriptTimeExceeded = false; - const checker = setInterval( + const checker: $TSFixMe = setInterval( () => { totalRuntime += 1000; if (totalRuntime > maxScriptRunTime) { @@ -178,7 +178,7 @@ const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, o // worker_threads code import { NodeVM } from 'vm2' - const vm = new NodeVM({ + const vm: $TSFixMe = new NodeVM({ eval: false, wasm: false, require: { @@ -207,9 +207,9 @@ const runScript: Function = async (functionCode: $TSFixMe, isCalled: $TSFixMe, o } }; - const code = workerData.functionCode; + const code: $TSFixMe = workerData.functionCode; setInterval(() => parentPort.postMessage({ type: 'ping' }), 500); - const sandboxFunction = await vm.run( + const sandboxFunction: $TSFixMe = await vm.run( `export default ${code}`, join(process.cwd(), 'node_modules') );