mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
fix
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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/'),
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 };
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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('+');
|
||||
|
||||
@@ -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'],
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 = [
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 = {};
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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 });
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'] ||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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: [
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -114,7 +114,7 @@ describe('Scheduled event API', function (): void {
|
||||
[];
|
||||
|
||||
for (
|
||||
let i = 0;
|
||||
let i: $TSFixMe = 0;
|
||||
i < 12;
|
||||
i++
|
||||
) {
|
||||
|
||||
@@ -154,7 +154,7 @@ describe('Scheduled Event Note', function (): void {
|
||||
[];
|
||||
|
||||
for (
|
||||
let i = 0;
|
||||
let i: $TSFixMe = 0;
|
||||
i <
|
||||
12;
|
||||
i++
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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]] : [];
|
||||
|
||||
@@ -10,7 +10,7 @@ export default {
|
||||
code: $TSFixMe,
|
||||
invoiceUrl: URL
|
||||
) => {
|
||||
let data = {
|
||||
let data: $TSFixMe = {
|
||||
blocks: [
|
||||
{
|
||||
type: 'header',
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import logger from '../Utils/Logger';
|
||||
|
||||
import { DatabaseUrl, IsMongoReplicaSet } from '../Config';
|
||||
|
||||
let options = {};
|
||||
let options: $TSFixMe = {};
|
||||
|
||||
if (IsMongoReplicaSet) {
|
||||
options = {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class Service extends DatabaseService<typeof Model> {
|
||||
}
|
||||
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
);
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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 },
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -262,7 +262,7 @@ class DatabaseService<ModelType> {
|
||||
data: createBy.data,
|
||||
});
|
||||
|
||||
let data = _createdBy.data;
|
||||
let data: $TSFixMe = _createdBy.data;
|
||||
|
||||
this.checkRequiredFields(data);
|
||||
|
||||
@@ -323,7 +323,7 @@ class DatabaseService<ModelType> {
|
||||
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<ModelType> {
|
||||
|
||||
query['deleted'] = false;
|
||||
|
||||
let dbQuery = null;
|
||||
let dbQuery: $TSFixMe = null;
|
||||
|
||||
if (!multiple) {
|
||||
dbQuery = this.model.findOne(onBeforeFind.query);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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,
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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]);
|
||||
});
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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 &&
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
@@ -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 } },
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export default class Service {
|
||||
escalations,
|
||||
incidentAcknowledged,
|
||||
}: $TSFixMe): void {
|
||||
let item = new OnCallScheduleStatusModel();
|
||||
let item: $TSFixMe = new OnCallScheduleStatusModel();
|
||||
|
||||
item.project = project;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -205,7 +205,7 @@ class Service extends DatabaseService<typeof Model> {
|
||||
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<typeof Model> {
|
||||
}),
|
||||
]);
|
||||
const { matchedCriterion }: $TSFixMe = data;
|
||||
let incidentIds = [];
|
||||
let scripts = [];
|
||||
let incidentIds: $TSFixMe = [];
|
||||
let scripts: $TSFixMe = [];
|
||||
|
||||
if (
|
||||
matchedCriterion &&
|
||||
@@ -310,7 +310,7 @@ class Service extends DatabaseService<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
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<typeof Model> {
|
||||
|
||||
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<typeof Model> {
|
||||
|
||||
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<typeof Model> {
|
||||
}
|
||||
|
||||
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<typeof Model> {
|
||||
),
|
||||
])
|
||||
: 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') {
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user