diff --git a/database/getWorkOrderMilestones.js b/database/getWorkOrderMilestones.js index c668e5eb..7b2f9a03 100644 --- a/database/getWorkOrderMilestones.js +++ b/database/getWorkOrderMilestones.js @@ -49,14 +49,12 @@ function buildWhereClause(filters) { if ((filters.workOrderTypeIds ?? '') !== '' && commaSeparatedNumbersRegex.test(filters.workOrderTypeIds)) { sqlWhereClause += - ' and w.workOrderTypeId in (' + filters.workOrderTypeIds + ')'; + ` and w.workOrderTypeId in (${filters.workOrderTypeIds})`; } - if ((filters.workOrderMilestoneTypeIds ?? '') !== '' && + if (filters.workOrderMilestoneTypeIds !== undefined && + filters.workOrderMilestoneTypeIds !== '' && commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds)) { - sqlWhereClause += - ' and m.workOrderMilestoneTypeId in (' + - filters.workOrderMilestoneTypeIds + - ')'; + sqlWhereClause += ` and m.workOrderMilestoneTypeId in (${filters.workOrderMilestoneTypeIds})`; } return { sqlWhereClause, diff --git a/database/getWorkOrderMilestones.ts b/database/getWorkOrderMilestones.ts index 4113633b..80657fe0 100644 --- a/database/getWorkOrderMilestones.ts +++ b/database/getWorkOrderMilestones.ts @@ -1,4 +1,5 @@ import { + type DateString, dateIntegerToString, dateStringToInteger, dateToInteger, @@ -100,7 +101,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): { if ((filters.workOrderMilestoneDateString ?? '') !== '') { sqlWhereClause += ' and m.workOrderMilestoneDate = ?' sqlParameters.push( - dateStringToInteger(filters.workOrderMilestoneDateString!) + dateStringToInteger(filters.workOrderMilestoneDateString as DateString) ) } @@ -109,17 +110,15 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): { commaSeparatedNumbersRegex.test(filters.workOrderTypeIds!) ) { sqlWhereClause += - ' and w.workOrderTypeId in (' + filters.workOrderTypeIds! + ')' + ` and w.workOrderTypeId in (${filters.workOrderTypeIds})` } if ( - (filters.workOrderMilestoneTypeIds ?? '') !== '' && + filters.workOrderMilestoneTypeIds !== undefined && + filters.workOrderMilestoneTypeIds !== '' && commaSeparatedNumbersRegex.test(filters.workOrderMilestoneTypeIds!) ) { - sqlWhereClause += - ' and m.workOrderMilestoneTypeId in (' + - filters.workOrderMilestoneTypeIds! + - ')' + sqlWhereClause += ` and m.workOrderMilestoneTypeId in (${filters.workOrderMilestoneTypeIds})` } return { diff --git a/helpers/functions.api.ts b/helpers/functions.api.ts index 5f5a4e37..db9ce960 100644 --- a/helpers/functions.api.ts +++ b/helpers/functions.api.ts @@ -11,7 +11,7 @@ let apiKeys: Record async function loadApiKeys(): Promise { try { const fileData = await fs.readFile(apiKeyPath, 'utf8') - apiKeys = JSON.parse(fileData) + apiKeys = JSON.parse(fileData) as Record } catch (error) { debug(error) apiKeys = {} diff --git a/helpers/functions.authentication.js b/helpers/functions.authentication.js index bb6851a4..3a04f484 100644 --- a/helpers/functions.authentication.js +++ b/helpers/functions.authentication.js @@ -6,7 +6,7 @@ async function authenticateViaActiveDirectory(userName, password) { return await new Promise((resolve) => { try { const ad = new ActiveDirectory(activeDirectoryConfig); - ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => { + ad.authenticate(`${userDomain}\\${userName}`, password, (error, auth) => { let authenticated = false; if ((error ?? '') === '') { authenticated = auth; diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index c7fa8a9b..26d729a0 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -4,7 +4,8 @@ import * as configFunctions from './functions.config.js' const userDomain = configFunctions.getConfigProperty('application.userDomain') -const activeDirectoryConfig = configFunctions.getConfigProperty('activeDirectory') +const activeDirectoryConfig = + configFunctions.getConfigProperty('activeDirectory') async function authenticateViaActiveDirectory( userName: string, @@ -14,7 +15,7 @@ async function authenticateViaActiveDirectory( try { const ad = new ActiveDirectory(activeDirectoryConfig) - ad.authenticate(userDomain + '\\' + userName, password, (error, auth) => { + ad.authenticate(`${userDomain}\\${userName}`, password, (error, auth) => { let authenticated = false if ((error ?? '') === '') { diff --git a/test/functions.ts b/test/functions.ts index f47493e1..ed9574ac 100644 --- a/test/functions.ts +++ b/test/functions.ts @@ -19,6 +19,7 @@ describe('config.cemetery.ssm', () => { describe('functions.cache', () => { const badId = -3 + // eslint-disable-next-line no-secrets/no-secrets const badName = 'qwertyuiopasdfghjklzxcvbnm' before(() => { @@ -477,7 +478,7 @@ describe('functions.user', () => { it('authenticates with a valid API key', async () => { const apiKeysJSON: Record = JSON.parse( fs.readFileSync('data/apiKeys.json', 'utf8') - ) + ) as Record const apiKey = Object.values(apiKeysJSON)[0]