From 1a28c3806604eadcdfdeb53d0f37e278b1f7bc56 Mon Sep 17 00:00:00 2001 From: Dan Gowans Date: Mon, 24 Jun 2024 09:05:17 -0400 Subject: [PATCH] rename `getProperty` to `getConfigProperty` --- app.js | 16 ++--- app.ts | 16 ++--- bin/www.js | 10 +-- bin/www.ts | 10 +-- bin/wwwProcess.js | 4 +- bin/wwwProcess.ts | 4 +- cypress/e2e/01-admin/feeManagement.cy.js | 2 +- cypress/e2e/01-admin/feeManagement.cy.ts | 2 +- cypress/e2e/02-update/maps.cy.js | 8 +-- cypress/e2e/02-update/maps.cy.ts | 8 +-- data/databasePaths.js | 2 +- data/databasePaths.ts | 2 +- database/cleanupDatabase.js | 2 +- database/cleanupDatabase.ts | 2 +- database/getLotOccupancies.js | 2 +- database/getLotOccupancies.ts | 2 +- database/getLotOccupancy.js | 2 +- database/getLotOccupancy.ts | 2 +- database/getLotOccupancyTransactions.js | 2 +- database/getLotOccupancyTransactions.ts | 2 +- database/getLots.js | 2 +- database/getLots.ts | 2 +- database/getNextLotId.js | 2 +- database/getNextLotId.ts | 2 +- database/getNextWorkOrderNumber.js | 2 +- database/getNextWorkOrderNumber.ts | 2 +- database/getOccupancyTypePrints.js | 2 +- database/getOccupancyTypePrints.ts | 2 +- database/getPreviousLotId.js | 2 +- database/getPreviousLotId.ts | 2 +- database/getReportData.js | 8 +-- database/getReportData.ts | 8 +-- database/getWorkOrderMilestones.js | 6 +- database/getWorkOrderMilestones.ts | 6 +- database/moveFee.ts | 3 +- database/updateLotComment.d.ts | 5 +- database/updateLotComment.ts | 6 +- database/updateLotOccupancy.d.ts | 5 +- database/updateLotOccupancy.ts | 6 +- handlers/admin-get/lotTypes.js | 2 +- handlers/admin-get/lotTypes.ts | 2 +- handlers/admin-get/ntfyStartup.js | 4 +- handlers/admin-get/ntfyStartup.ts | 4 +- handlers/admin-get/occupancyTypes.js | 4 +- handlers/admin-get/occupancyTypes.ts | 4 +- handlers/api-get/milestoneICS.js | 32 ++++----- handlers/api-get/milestoneICS.ts | 32 ++++----- handlers/lotOccupancies-get/edit.js | 4 +- handlers/lotOccupancies-get/edit.ts | 4 +- handlers/lotOccupancies-get/new.js | 2 +- handlers/lotOccupancies-get/new.ts | 2 +- handlers/lotOccupancies-get/search.js | 2 +- handlers/lotOccupancies-get/search.ts | 2 +- handlers/lotOccupancies-get/view.js | 4 +- handlers/lotOccupancies-get/view.ts | 4 +- handlers/lots-get/edit.js | 2 +- handlers/lots-get/edit.ts | 2 +- handlers/lots-get/new.js | 2 +- handlers/lots-get/new.ts | 2 +- handlers/lots-get/next.js | 4 +- handlers/lots-get/next.ts | 4 +- handlers/lots-get/previous.js | 4 +- handlers/lots-get/previous.ts | 4 +- handlers/lots-get/search.js | 2 +- handlers/lots-get/search.ts | 2 +- handlers/lots-get/view.js | 2 +- handlers/lots-get/view.ts | 2 +- handlers/maps-get/edit.js | 2 +- handlers/maps-get/edit.ts | 2 +- handlers/maps-get/new.js | 6 +- handlers/maps-get/new.ts | 6 +- handlers/maps-get/next.js | 4 +- handlers/maps-get/next.ts | 4 +- handlers/maps-get/previous.js | 4 +- handlers/maps-get/previous.ts | 4 +- handlers/maps-get/search.js | 2 +- handlers/maps-get/search.ts | 2 +- handlers/maps-get/view.js | 2 +- handlers/maps-get/view.ts | 2 +- handlers/permissions.js | 2 +- handlers/permissions.ts | 2 +- handlers/print-get/pdf.js | 10 +-- handlers/print-get/pdf.ts | 10 +-- handlers/print-get/screen.js | 8 +-- handlers/print-get/screen.ts | 8 +-- handlers/workOrders-get/edit.js | 4 +- handlers/workOrders-get/edit.ts | 4 +- handlers/workOrders-get/view.js | 2 +- handlers/workOrders-get/view.ts | 2 +- helpers/functions.authentication.js | 6 +- helpers/functions.authentication.ts | 6 +- helpers/functions.cache.js | 2 +- helpers/functions.cache.ts | 2 +- helpers/functions.config.d.ts | 22 +++---- helpers/functions.config.js | 6 +- helpers/functions.config.ts | 30 ++++----- helpers/functions.dynamicsGP.js | 14 ++-- helpers/functions.dynamicsGP.ts | 14 ++-- helpers/functions.print.js | 2 +- helpers/functions.print.ts | 4 +- helpers/functions.user.js | 2 +- helpers/functions.user.ts | 2 +- package-lock.json | 16 ++--- package.json | 4 +- routes/login.js | 10 +-- routes/login.ts | 10 +-- routes/lotOccupancies.js | 2 +- routes/lotOccupancies.ts | 2 +- views/_footerA.ejs | 28 ++++---- views/_header.ejs | 14 ++-- views/_menu-admin.ejs | 14 ++-- views/admin-database.ejs | 2 +- views/admin-fees.ejs | 2 +- views/admin-lotTypes.ejs | 6 +- views/admin-ntfyStartup.ejs | 4 +- views/admin-occupancyTypes.ejs | 6 +- views/admin-tables.ejs | 16 ++--- views/dashboard.ejs | 48 +++++++------- views/login.ejs | 12 ++-- views/lot-edit.ejs | 56 ++++++++-------- views/lot-search.ejs | 18 ++--- views/lot-view.ejs | 28 ++++---- views/lotOccupancy-edit.ejs | 80 +++++++++++------------ views/lotOccupancy-search.ejs | 26 ++++---- views/lotOccupancy-view.ejs | 42 ++++++------ views/map-edit.ejs | 28 ++++---- views/map-search.ejs | 10 +-- views/map-view.ejs | 22 +++---- views/print/pdf/_workOrder-header.ejs | 4 +- views/print/pdf/ssm.cemetery.contract.ejs | 8 +-- views/print/pdf/workOrder.ejs | 18 ++--- views/print/screen/_header-print.ejs | 2 +- views/print/screen/lotOccupancy.ejs | 30 ++++----- views/report-search.ejs | 46 ++++++------- views/workOrder-edit.ejs | 22 +++---- views/workOrder-search.ejs | 8 +-- views/workOrder-view.ejs | 48 +++++++------- 137 files changed, 607 insertions(+), 602 deletions(-) diff --git a/app.js b/app.js index 836d61f0..0d4c7c2e 100644 --- a/app.js +++ b/app.js @@ -33,12 +33,12 @@ databaseInitializer.initializeDatabase(); const _dirname = '.'; export const app = express(); app.disable('X-Powered-By'); -if (!configFunctions.getProperty('reverseProxy.disableEtag')) { +if (!configFunctions.getConfigProperty('reverseProxy.disableEtag')) { app.set('etag', false); } app.set('views', path.join(_dirname, 'views')); app.set('view engine', 'ejs'); -if (!configFunctions.getProperty('reverseProxy.disableCompression')) { +if (!configFunctions.getConfigProperty('reverseProxy.disableCompression')) { app.use(compression()); } app.use((request, _response, next) => { @@ -57,7 +57,7 @@ app.use(rateLimit({ windowMs: 10_000, max: useTestDatabases ? 1_000_000 : 200 })); -const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix'); +const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix'); if (urlPrefix !== '') { debug(`urlPrefix = ${urlPrefix}`); } @@ -68,7 +68,7 @@ app.use(`${urlPrefix}/lib/cityssm-bulma-webapp-js`, express.static(path.join('no app.use(`${urlPrefix}/lib/fa`, express.static(path.join('node_modules', '@fortawesome', 'fontawesome-free'))); app.use(`${urlPrefix}/lib/leaflet`, express.static(path.join('node_modules', 'leaflet', 'dist'))); app.use(`${urlPrefix}/lib/randomcolor/randomColor.js`, express.static(path.join('node_modules', 'randomcolor', 'randomColor.js'))); -const sessionCookieName = configFunctions.getProperty('session.cookieName'); +const sessionCookieName = configFunctions.getConfigProperty('session.cookieName'); const FileStoreSession = FileStore(session); app.use(session({ store: new FileStoreSession({ @@ -77,12 +77,12 @@ app.use(session({ retries: 20 }), name: sessionCookieName, - secret: configFunctions.getProperty('session.secret'), + secret: configFunctions.getConfigProperty('session.secret'), resave: true, saveUninitialized: false, rolling: true, cookie: { - maxAge: configFunctions.getProperty('session.maxAgeMillis'), + maxAge: configFunctions.getConfigProperty('session.maxAgeMillis'), sameSite: 'strict' } })); @@ -111,7 +111,7 @@ app.use((request, response, next) => { response.locals.dateTimeFunctions = dateTimeFns; response.locals.stringFunctions = stringFns; response.locals.htmlFunctions = htmlFns; - response.locals.urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix'); + response.locals.urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix'); next(); }); app.get(`${urlPrefix}/`, sessionChecker, (_request, response) => { @@ -126,7 +126,7 @@ app.use(`${urlPrefix}/lotOccupancies`, sessionChecker, routerLotOccupancies); app.use(`${urlPrefix}/workOrders`, sessionChecker, routerWorkOrders); app.use(`${urlPrefix}/reports`, sessionChecker, routerReports); app.use(`${urlPrefix}/admin`, sessionChecker, permissionHandlers.adminGetHandler, routerAdmin); -if (configFunctions.getProperty('session.doKeepAlive')) { +if (configFunctions.getConfigProperty('session.doKeepAlive')) { app.all(`${urlPrefix}/keepAlive`, (_request, response) => { response.json(true); }); diff --git a/app.ts b/app.ts index 5ecfc818..98c4b907 100644 --- a/app.ts +++ b/app.ts @@ -49,7 +49,7 @@ export const app = express() app.disable('X-Powered-By') -if (!configFunctions.getProperty('reverseProxy.disableEtag')) { +if (!configFunctions.getConfigProperty('reverseProxy.disableEtag')) { app.set('etag', false) } @@ -57,7 +57,7 @@ if (!configFunctions.getProperty('reverseProxy.disableEtag')) { app.set('views', path.join(_dirname, 'views')) app.set('view engine', 'ejs') -if (!configFunctions.getProperty('reverseProxy.disableCompression')) { +if (!configFunctions.getConfigProperty('reverseProxy.disableCompression')) { app.use(compression()) } @@ -96,7 +96,7 @@ app.use( * STATIC ROUTES */ -const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix') +const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix') if (urlPrefix !== '') { debug(`urlPrefix = ${urlPrefix}`) @@ -143,7 +143,7 @@ app.use( */ const sessionCookieName: string = - configFunctions.getProperty('session.cookieName') + configFunctions.getConfigProperty('session.cookieName') const FileStoreSession = FileStore(session) @@ -156,12 +156,12 @@ app.use( retries: 20 }), name: sessionCookieName, - secret: configFunctions.getProperty('session.secret'), + secret: configFunctions.getConfigProperty('session.secret'), resave: true, saveUninitialized: false, rolling: true, cookie: { - maxAge: configFunctions.getProperty('session.maxAgeMillis'), + maxAge: configFunctions.getConfigProperty('session.maxAgeMillis'), sameSite: 'strict' } }) @@ -218,7 +218,7 @@ app.use((request, response, next) => { response.locals.stringFunctions = stringFns response.locals.htmlFunctions = htmlFns - response.locals.urlPrefix = configFunctions.getProperty( + response.locals.urlPrefix = configFunctions.getConfigProperty( 'reverseProxy.urlPrefix' ) @@ -251,7 +251,7 @@ app.use( routerAdmin ) -if (configFunctions.getProperty('session.doKeepAlive')) { +if (configFunctions.getConfigProperty('session.doKeepAlive')) { app.all(`${urlPrefix}/keepAlive`, (_request, response) => { response.json(true) }) diff --git a/bin/www.js b/bin/www.js index 8abffd46..01cbb8dc 100644 --- a/bin/www.js +++ b/bin/www.js @@ -8,8 +8,8 @@ import exitHook from 'exit-hook'; import * as configFunctions from '../helpers/functions.config.js'; const debug = Debug(`lot-occupancy-system:www:${process.pid}`); const directoryName = dirname(fileURLToPath(import.meta.url)); -const processCount = Math.min(configFunctions.getProperty('application.maximumProcesses'), os.cpus().length); -process.title = `${configFunctions.getProperty('application.applicationName')} (Primary)`; +const processCount = Math.min(configFunctions.getConfigProperty('application.maximumProcesses'), os.cpus().length); +process.title = `${configFunctions.getConfigProperty('application.applicationName')} (Primary)`; debug(`Primary pid: ${process.pid}`); debug(`Primary title: ${process.title}`); debug(`Launching ${processCount} processes`); @@ -37,19 +37,19 @@ cluster.on('exit', (worker) => { debug('Starting another worker'); cluster.fork(); }); -const ntfyStartupConfig = configFunctions.getProperty('application.ntfyStartup'); +const ntfyStartupConfig = configFunctions.getConfigProperty('application.ntfyStartup'); if (ntfyStartupConfig !== undefined) { const topic = ntfyStartupConfig.topic; const server = ntfyStartupConfig.server; const ntfyStartupMessage = { topic, - title: configFunctions.getProperty('application.applicationName'), + title: configFunctions.getConfigProperty('application.applicationName'), message: 'Application Started', tags: ['arrow_up'] }; const ntfyShutdownMessage = { topic, - title: configFunctions.getProperty('application.applicationName'), + title: configFunctions.getConfigProperty('application.applicationName'), message: 'Application Shut Down', tags: ['arrow_down'] }; diff --git a/bin/www.ts b/bin/www.ts index d79c91a1..516edcdd 100644 --- a/bin/www.ts +++ b/bin/www.ts @@ -15,11 +15,11 @@ const debug = Debug(`lot-occupancy-system:www:${process.pid}`) const directoryName = dirname(fileURLToPath(import.meta.url)) const processCount = Math.min( - configFunctions.getProperty('application.maximumProcesses'), + configFunctions.getConfigProperty('application.maximumProcesses'), os.cpus().length ) -process.title = `${configFunctions.getProperty( +process.title = `${configFunctions.getConfigProperty( 'application.applicationName' )} (Primary)` @@ -59,7 +59,7 @@ cluster.on('exit', (worker) => { cluster.fork() }) -const ntfyStartupConfig = configFunctions.getProperty('application.ntfyStartup') +const ntfyStartupConfig = configFunctions.getConfigProperty('application.ntfyStartup') if (ntfyStartupConfig !== undefined) { const topic = ntfyStartupConfig.topic @@ -67,14 +67,14 @@ if (ntfyStartupConfig !== undefined) { const ntfyStartupMessage: NtfyMessageOptions = { topic, - title: configFunctions.getProperty('application.applicationName'), + title: configFunctions.getConfigProperty('application.applicationName'), message: 'Application Started', tags: ['arrow_up'] } const ntfyShutdownMessage: NtfyMessageOptions = { topic, - title: configFunctions.getProperty('application.applicationName'), + title: configFunctions.getConfigProperty('application.applicationName'), message: 'Application Shut Down', tags: ['arrow_down'] } diff --git a/bin/wwwProcess.js b/bin/wwwProcess.js index 9c5a34df..0a81b204 100644 --- a/bin/wwwProcess.js +++ b/bin/wwwProcess.js @@ -29,8 +29,8 @@ function onListening(server) { debug(`HTTP Listening on ${bind}`); } } -process.title = `${configFunctions.getProperty('application.applicationName')} (Worker)`; -const httpPort = configFunctions.getProperty('application.httpPort'); +process.title = `${configFunctions.getConfigProperty('application.applicationName')} (Worker)`; +const httpPort = configFunctions.getConfigProperty('application.httpPort'); const httpServer = http.createServer(app); httpServer.listen(httpPort); httpServer.on('error', onError); diff --git a/bin/wwwProcess.ts b/bin/wwwProcess.ts index dd088b12..d60d5255 100644 --- a/bin/wwwProcess.ts +++ b/bin/wwwProcess.ts @@ -58,11 +58,11 @@ function onListening(server: http.Server): void { * Initialize HTTP */ -process.title = `${configFunctions.getProperty( +process.title = `${configFunctions.getConfigProperty( 'application.applicationName' )} (Worker)` -const httpPort = configFunctions.getProperty('application.httpPort') +const httpPort = configFunctions.getConfigProperty('application.httpPort') const httpServer = http.createServer(app) diff --git a/cypress/e2e/01-admin/feeManagement.cy.js b/cypress/e2e/01-admin/feeManagement.cy.js index 99fa8432..ef76813a 100644 --- a/cypress/e2e/01-admin/feeManagement.cy.js +++ b/cypress/e2e/01-admin/feeManagement.cy.js @@ -40,7 +40,7 @@ describe('Admin - Fee Management', () => { cy.get(".modal input[name='taxPercentage']") .invoke('val') .should('equal', configFunctions - .getProperty('settings.fees.taxPercentageDefault') + .getConfigProperty('settings.fees.taxPercentageDefault') .toString()); cy.get(".modal input[name='quantityUnit']").should('be.disabled'); cy.get(".modal select[name='includeQuantity']").select('1'); diff --git a/cypress/e2e/01-admin/feeManagement.cy.ts b/cypress/e2e/01-admin/feeManagement.cy.ts index 6e9d3741..3eb9d12c 100644 --- a/cypress/e2e/01-admin/feeManagement.cy.ts +++ b/cypress/e2e/01-admin/feeManagement.cy.ts @@ -67,7 +67,7 @@ describe('Admin - Fee Management', () => { .should( 'equal', configFunctions - .getProperty('settings.fees.taxPercentageDefault') + .getConfigProperty('settings.fees.taxPercentageDefault') .toString() ) diff --git a/cypress/e2e/02-update/maps.cy.js b/cypress/e2e/02-update/maps.cy.js index 23ee6876..04833df9 100644 --- a/cypress/e2e/02-update/maps.cy.js +++ b/cypress/e2e/02-update/maps.cy.js @@ -37,8 +37,8 @@ describe('Update - Maps', () => { .type(mapJSON.mapLongitude.toString()); }); cy.log('Ensure the default city and province are used'); - cy.get("input[name='mapCity']").should('have.value', configFunctions.getProperty('settings.map.mapCityDefault')); - cy.get("input[name='mapProvince']").should('have.value', configFunctions.getProperty('settings.map.mapProvinceDefault')); + cy.get("input[name='mapCity']").should('have.value', configFunctions.getConfigProperty('settings.map.mapCityDefault')); + cy.get("input[name='mapProvince']").should('have.value', configFunctions.getConfigProperty('settings.map.mapProvinceDefault')); cy.log('Submit the form'); cy.get('#form--map').submit(); cy.wait(1000); @@ -50,8 +50,8 @@ describe('Update - Maps', () => { cy.get("textarea[name='mapDescription']").should('have.value', mapJSON.mapDescription); cy.get("input[name='mapAddress1']").should('have.value', mapJSON.mapAddress1); cy.get("input[name='mapAddress2']").should('have.value', mapJSON.mapAddress2); - cy.get("input[name='mapCity']").should('have.value', configFunctions.getProperty('settings.map.mapCityDefault')); - cy.get("input[name='mapProvince']").should('have.value', configFunctions.getProperty('settings.map.mapProvinceDefault')); + cy.get("input[name='mapCity']").should('have.value', configFunctions.getConfigProperty('settings.map.mapCityDefault')); + cy.get("input[name='mapProvince']").should('have.value', configFunctions.getConfigProperty('settings.map.mapProvinceDefault')); cy.get("input[name='mapPostalCode']").should('have.value', mapJSON.mapPostalCode); cy.get("input[name='mapPhoneNumber']").should('have.value', mapJSON.mapPhoneNumber); cy.get("input[name='mapLatitude']").should('have.value', mapJSON.mapLatitude.toString()); diff --git a/cypress/e2e/02-update/maps.cy.ts b/cypress/e2e/02-update/maps.cy.ts index c13cc807..64bb8ee8 100644 --- a/cypress/e2e/02-update/maps.cy.ts +++ b/cypress/e2e/02-update/maps.cy.ts @@ -56,12 +56,12 @@ describe('Update - Maps', () => { cy.get("input[name='mapCity']").should( 'have.value', - configFunctions.getProperty('settings.map.mapCityDefault') + configFunctions.getConfigProperty('settings.map.mapCityDefault') ) cy.get("input[name='mapProvince']").should( 'have.value', - configFunctions.getProperty('settings.map.mapProvinceDefault') + configFunctions.getConfigProperty('settings.map.mapProvinceDefault') ) cy.log('Submit the form') @@ -93,11 +93,11 @@ describe('Update - Maps', () => { cy.get("input[name='mapCity']").should( 'have.value', - configFunctions.getProperty('settings.map.mapCityDefault') + configFunctions.getConfigProperty('settings.map.mapCityDefault') ) cy.get("input[name='mapProvince']").should( 'have.value', - configFunctions.getProperty('settings.map.mapProvinceDefault') + configFunctions.getConfigProperty('settings.map.mapProvinceDefault') ) cy.get("input[name='mapPostalCode']").should( diff --git a/data/databasePaths.js b/data/databasePaths.js index bd81c818..16868e19 100644 --- a/data/databasePaths.js +++ b/data/databasePaths.js @@ -1,7 +1,7 @@ import * as configFunctions from '../helpers/functions.config.js'; import Debug from 'debug'; const debug = Debug('lot-occupancy-system:databasePaths'); -export const useTestDatabases = configFunctions.getProperty('application.useTestDatabases') || +export const useTestDatabases = configFunctions.getConfigProperty('application.useTestDatabases') || process.env.TEST_DATABASES === 'true'; if (useTestDatabases) { debug('Using "-testing" databases.'); diff --git a/data/databasePaths.ts b/data/databasePaths.ts index 865b946f..367ef156 100644 --- a/data/databasePaths.ts +++ b/data/databasePaths.ts @@ -6,7 +6,7 @@ const debug = Debug('lot-occupancy-system:databasePaths') // Determine if test databases should be used export const useTestDatabases = - configFunctions.getProperty('application.useTestDatabases') || + configFunctions.getConfigProperty('application.useTestDatabases') || process.env.TEST_DATABASES === 'true' if (useTestDatabases) { diff --git a/database/cleanupDatabase.js b/database/cleanupDatabase.js index dfe837c3..28e9f606 100644 --- a/database/cleanupDatabase.js +++ b/database/cleanupDatabase.js @@ -4,7 +4,7 @@ export default async function cleanupDatabase(user) { const database = await acquireConnection(); const rightNowMillis = Date.now(); const recordDeleteTimeMillisMin = rightNowMillis - - configFunctions.getProperty('settings.adminCleanup.recordDeleteAgeDays') * + configFunctions.getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') * 86_400 * 1000; let inactivatedRecordCount = 0; diff --git a/database/cleanupDatabase.ts b/database/cleanupDatabase.ts index c47acf5d..e24dcaa2 100644 --- a/database/cleanupDatabase.ts +++ b/database/cleanupDatabase.ts @@ -10,7 +10,7 @@ export default async function cleanupDatabase( const rightNowMillis = Date.now() const recordDeleteTimeMillisMin = rightNowMillis - - configFunctions.getProperty('settings.adminCleanup.recordDeleteAgeDays') * + configFunctions.getConfigProperty('settings.adminCleanup.recordDeleteAgeDays') * 86_400 * 1000 diff --git a/database/getLotOccupancies.js b/database/getLotOccupancies.js index 93ee6b71..2ccc0629 100644 --- a/database/getLotOccupancies.js +++ b/database/getLotOccupancies.js @@ -116,7 +116,7 @@ export async function getLotOccupancies(filters, options, connectedDatabase) { const occupancyType = await getOccupancyTypeById(lotOccupancy.occupancyTypeId); if (occupancyType !== undefined) { lotOccupancy.printEJS = (occupancyType.occupancyTypePrints ?? []).includes('*') - ? configFunctions.getProperty('settings.lotOccupancy.prints')[0] + ? configFunctions.getConfigProperty('settings.lotOccupancy.prints')[0] : occupancyType.occupancyTypePrints[0]; } await addInclusions(lotOccupancy, options, database); diff --git a/database/getLotOccupancies.ts b/database/getLotOccupancies.ts index 2f75902a..316ccc0b 100644 --- a/database/getLotOccupancies.ts +++ b/database/getLotOccupancies.ts @@ -222,7 +222,7 @@ export async function getLotOccupancies( lotOccupancy.printEJS = ( occupancyType.occupancyTypePrints ?? [] ).includes('*') - ? configFunctions.getProperty('settings.lotOccupancy.prints')[0] + ? configFunctions.getConfigProperty('settings.lotOccupancy.prints')[0] : occupancyType.occupancyTypePrints![0] } diff --git a/database/getLotOccupancy.js b/database/getLotOccupancy.js index e903ac37..bc8d0807 100644 --- a/database/getLotOccupancy.js +++ b/database/getLotOccupancy.js @@ -15,7 +15,7 @@ export async function getLotOccupancy(lotOccupancyId, connectedDatabase) { o.lotId, l.lotName, l.lotTypeId, l.mapId, m.mapName, o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, - o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString, + o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString, o.recordUpdate_timeMillis from LotOccupancies o left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId diff --git a/database/getLotOccupancy.ts b/database/getLotOccupancy.ts index 2de530ac..bd75a1f4 100644 --- a/database/getLotOccupancy.ts +++ b/database/getLotOccupancy.ts @@ -26,7 +26,7 @@ export async function getLotOccupancy( o.lotId, l.lotName, l.lotTypeId, l.mapId, m.mapName, o.occupancyStartDate, userFn_dateIntegerToString(o.occupancyStartDate) as occupancyStartDateString, - o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString, + o.occupancyEndDate, userFn_dateIntegerToString(o.occupancyEndDate) as occupancyEndDateString, o.recordUpdate_timeMillis from LotOccupancies o left join OccupancyTypes t on o.occupancyTypeId = t.occupancyTypeId diff --git a/database/getLotOccupancyTransactions.js b/database/getLotOccupancyTransactions.js index 9a850ac4..f77145ec 100644 --- a/database/getLotOccupancyTransactions.js +++ b/database/getLotOccupancyTransactions.js @@ -20,7 +20,7 @@ export async function getLotOccupancyTransactions(lotOccupancyId, options, conne database.release(); } if ((options?.includeIntegrations ?? false) && - configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { + configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { for (const transaction of lotOccupancyTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { const gpDocument = await gpFunctions.getDynamicsGPDocument(transaction.externalReceiptNumber ?? ''); diff --git a/database/getLotOccupancyTransactions.ts b/database/getLotOccupancyTransactions.ts index 6ba6c76f..82f7cded 100644 --- a/database/getLotOccupancyTransactions.ts +++ b/database/getLotOccupancyTransactions.ts @@ -41,7 +41,7 @@ export async function getLotOccupancyTransactions( if ( (options?.includeIntegrations ?? false) && - configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled') + configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled') ) { for (const transaction of lotOccupancyTransactions) { if ((transaction.externalReceiptNumber ?? '') !== '') { diff --git a/database/getLots.js b/database/getLots.js index f417bd36..2e113392 100644 --- a/database/getLots.js +++ b/database/getLots.js @@ -61,7 +61,7 @@ export async function getLots(filters, options, connectedDatabase) { let lots = []; if (options.limit === -1 || count > 0) { const includeLotOccupancyCount = options.includeLotOccupancyCount ?? true; - database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction')); + database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')); if (includeLotOccupancyCount) { sqlParameters.unshift(currentDate, currentDate); } diff --git a/database/getLots.ts b/database/getLots.ts index eb93cb81..7a018298 100644 --- a/database/getLots.ts +++ b/database/getLots.ts @@ -113,7 +113,7 @@ export async function getLots( database.function( 'userFn_lotNameSortName', - configFunctions.getProperty('settings.lot.lotNameSortNameFunction') + configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction') ) if (includeLotOccupancyCount) { diff --git a/database/getNextLotId.js b/database/getNextLotId.js index 4066c4ea..311549c5 100644 --- a/database/getNextLotId.js +++ b/database/getNextLotId.js @@ -2,7 +2,7 @@ import * as configFunctions from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; export async function getNextLotId(lotId) { const database = await acquireConnection(); - database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction')); + database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')); const result = database .prepare(`select lotId from Lots diff --git a/database/getNextLotId.ts b/database/getNextLotId.ts index 05b08910..c6266b46 100644 --- a/database/getNextLotId.ts +++ b/database/getNextLotId.ts @@ -9,7 +9,7 @@ export async function getNextLotId( database.function( 'userFn_lotNameSortName', - configFunctions.getProperty('settings.lot.lotNameSortNameFunction') + configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction') ) const result = database diff --git a/database/getNextWorkOrderNumber.js b/database/getNextWorkOrderNumber.js index 3a75f033..ec9f9980 100644 --- a/database/getNextWorkOrderNumber.js +++ b/database/getNextWorkOrderNumber.js @@ -2,7 +2,7 @@ import * as configFunctions from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; export async function getNextWorkOrderNumber(connectedDatabase) { const database = connectedDatabase ?? (await acquireConnection()); - const paddingLength = configFunctions.getProperty('settings.workOrders.workOrderNumberLength'); + const paddingLength = configFunctions.getConfigProperty('settings.workOrders.workOrderNumberLength'); const currentYearString = new Date().getFullYear().toString(); const regex = new RegExp('^' + currentYearString + '-\\d+$'); database.function('userFn_matchesWorkOrderNumberSyntax', (workOrderNumber) => { diff --git a/database/getNextWorkOrderNumber.ts b/database/getNextWorkOrderNumber.ts index 4f5f2e16..ee9889a9 100644 --- a/database/getNextWorkOrderNumber.ts +++ b/database/getNextWorkOrderNumber.ts @@ -9,7 +9,7 @@ export async function getNextWorkOrderNumber( ): Promise { const database = connectedDatabase ?? (await acquireConnection()) - const paddingLength = configFunctions.getProperty( + const paddingLength = configFunctions.getConfigProperty( 'settings.workOrders.workOrderNumberLength' ) const currentYearString = new Date().getFullYear().toString() diff --git a/database/getOccupancyTypePrints.js b/database/getOccupancyTypePrints.js index 1467332e..a309a189 100644 --- a/database/getOccupancyTypePrints.js +++ b/database/getOccupancyTypePrints.js @@ -1,6 +1,6 @@ import * as configFunctions from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; -const availablePrints = configFunctions.getProperty('settings.lotOccupancy.prints'); +const availablePrints = configFunctions.getConfigProperty('settings.lotOccupancy.prints'); const userFunction_configContainsPrintEJS = (printEJS) => { if (printEJS === '*' || availablePrints.includes(printEJS)) { return 1; diff --git a/database/getOccupancyTypePrints.ts b/database/getOccupancyTypePrints.ts index 76ccd582..4cd81a9f 100644 --- a/database/getOccupancyTypePrints.ts +++ b/database/getOccupancyTypePrints.ts @@ -4,7 +4,7 @@ import * as configFunctions from '../helpers/functions.config.js' import { acquireConnection } from './pool.js' -const availablePrints = configFunctions.getProperty( +const availablePrints = configFunctions.getConfigProperty( 'settings.lotOccupancy.prints' ) diff --git a/database/getPreviousLotId.js b/database/getPreviousLotId.js index 10712f2e..2676d04d 100644 --- a/database/getPreviousLotId.js +++ b/database/getPreviousLotId.js @@ -2,7 +2,7 @@ import * as configFunctions from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; export async function getPreviousLotId(lotId) { const database = await acquireConnection(); - database.function('userFn_lotNameSortName', configFunctions.getProperty('settings.lot.lotNameSortNameFunction')); + database.function('userFn_lotNameSortName', configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction')); const result = database .prepare(`select lotId from Lots where recordDelete_timeMillis is null diff --git a/database/getPreviousLotId.ts b/database/getPreviousLotId.ts index 488b8de7..58b49877 100644 --- a/database/getPreviousLotId.ts +++ b/database/getPreviousLotId.ts @@ -9,7 +9,7 @@ export async function getPreviousLotId( database.function( 'userFn_lotNameSortName', - configFunctions.getProperty('settings.lot.lotNameSortNameFunction') + configFunctions.getConfigProperty('settings.lot.lotNameSortNameFunction') ) const result = database diff --git a/database/getReportData.js b/database/getReportData.js index 93e6dc01..314ee019 100644 --- a/database/getReportData.js +++ b/database/getReportData.js @@ -2,7 +2,7 @@ import * as dateTimeFunctions from '@cityssm/utils-datetime'; import camelCase from 'camelcase'; import * as configFunctions from '../helpers/functions.config.js'; import { acquireConnection } from './pool.js'; -const mapCamelCase = camelCase(configFunctions.getProperty('aliases.map')); +const mapCamelCase = camelCase(configFunctions.getConfigProperty('aliases.map')); const mapNameAlias = `${mapCamelCase}Name`; const mapDescriptionAlias = `${mapCamelCase}Description`; const mapAddress1Alias = `${mapCamelCase}Address1`; @@ -11,17 +11,17 @@ const mapCityAlias = `${mapCamelCase}City`; const mapProvinceAlias = `${mapCamelCase}Province`; const mapPostalCodeAlias = `${mapCamelCase}PostalCode`; const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber`; -const lotCamelCase = camelCase(configFunctions.getProperty('aliases.lot')); +const lotCamelCase = camelCase(configFunctions.getConfigProperty('aliases.lot')); const lotIdAlias = `${lotCamelCase}Id`; const lotNameAlias = `${lotCamelCase}Name`; const lotTypeAlias = `${lotCamelCase}Type`; const lotStatusAlias = `${lotCamelCase}Status`; -const occupancyCamelCase = camelCase(configFunctions.getProperty('aliases.occupancy')); +const occupancyCamelCase = camelCase(configFunctions.getConfigProperty('aliases.occupancy')); const lotOccupancyIdAlias = `${occupancyCamelCase}Id`; const occupancyTypeAlias = `${occupancyCamelCase}Type`; const occupancyStartDateAlias = `${occupancyCamelCase}StartDate`; const occupancyEndDateAlias = `${occupancyCamelCase}EndDate`; -const occupantCamelCase = camelCase(configFunctions.getProperty('aliases.occupant')); +const occupantCamelCase = camelCase(configFunctions.getConfigProperty('aliases.occupant')); const lotOccupantIndexAlias = `${occupantCamelCase}Index`; const lotOccupantTypeAlias = `${occupantCamelCase}Type`; const occupantNameAlias = `${occupantCamelCase}Name`; diff --git a/database/getReportData.ts b/database/getReportData.ts index d1a37a3e..8b3cb47e 100644 --- a/database/getReportData.ts +++ b/database/getReportData.ts @@ -10,7 +10,7 @@ import { acquireConnection } from './pool.js' export type ReportParameters = Record -const mapCamelCase = camelCase(configFunctions.getProperty('aliases.map')) +const mapCamelCase = camelCase(configFunctions.getConfigProperty('aliases.map')) const mapNameAlias = `${mapCamelCase}Name` const mapDescriptionAlias = `${mapCamelCase}Description` const mapAddress1Alias = `${mapCamelCase}Address1` @@ -20,14 +20,14 @@ const mapProvinceAlias = `${mapCamelCase}Province` const mapPostalCodeAlias = `${mapCamelCase}PostalCode` const mapPhoneNumberAlias = `${mapCamelCase}PhoneNumber` -const lotCamelCase = camelCase(configFunctions.getProperty('aliases.lot')) +const lotCamelCase = camelCase(configFunctions.getConfigProperty('aliases.lot')) const lotIdAlias = `${lotCamelCase}Id` const lotNameAlias = `${lotCamelCase}Name` const lotTypeAlias = `${lotCamelCase}Type` const lotStatusAlias = `${lotCamelCase}Status` const occupancyCamelCase = camelCase( - configFunctions.getProperty('aliases.occupancy') + configFunctions.getConfigProperty('aliases.occupancy') ) const lotOccupancyIdAlias = `${occupancyCamelCase}Id` const occupancyTypeAlias = `${occupancyCamelCase}Type` @@ -35,7 +35,7 @@ const occupancyStartDateAlias = `${occupancyCamelCase}StartDate` const occupancyEndDateAlias = `${occupancyCamelCase}EndDate` const occupantCamelCase = camelCase( - configFunctions.getProperty('aliases.occupant') + configFunctions.getConfigProperty('aliases.occupant') ) const lotOccupantIndexAlias = `${occupantCamelCase}Index` const lotOccupantTypeAlias = `${occupantCamelCase}Type` diff --git a/database/getWorkOrderMilestones.js b/database/getWorkOrderMilestones.js index c7d55850..c668e5eb 100644 --- a/database/getWorkOrderMilestones.js +++ b/database/getWorkOrderMilestones.js @@ -14,11 +14,11 @@ function buildWhereClause(filters) { const date = new Date(); const currentDateNumber = dateToInteger(date); date.setDate(date.getDate() - - configFunctions.getProperty('settings.workOrders.workOrderMilestoneDateRecentBeforeDays')); + configFunctions.getConfigProperty('settings.workOrders.workOrderMilestoneDateRecentBeforeDays')); const recentBeforeDateNumber = dateToInteger(date); date.setDate(date.getDate() + - configFunctions.getProperty('settings.workOrders.workOrderMilestoneDateRecentBeforeDays') + - configFunctions.getProperty('settings.workOrders.workOrderMilestoneDateRecentAfterDays')); + configFunctions.getConfigProperty('settings.workOrders.workOrderMilestoneDateRecentBeforeDays') + + configFunctions.getConfigProperty('settings.workOrders.workOrderMilestoneDateRecentAfterDays')); const recentAfterDateNumber = dateToInteger(date); switch (filters.workOrderMilestoneDateFilter) { case 'upcomingMissed': { diff --git a/database/getWorkOrderMilestones.ts b/database/getWorkOrderMilestones.ts index 5aed8612..4113633b 100644 --- a/database/getWorkOrderMilestones.ts +++ b/database/getWorkOrderMilestones.ts @@ -52,7 +52,7 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): { date.setDate( date.getDate() - - configFunctions.getProperty( + configFunctions.getConfigProperty( 'settings.workOrders.workOrderMilestoneDateRecentBeforeDays' ) ) @@ -61,10 +61,10 @@ function buildWhereClause(filters: WorkOrderMilestoneFilters): { date.setDate( date.getDate() + - configFunctions.getProperty( + configFunctions.getConfigProperty( 'settings.workOrders.workOrderMilestoneDateRecentBeforeDays' ) + - configFunctions.getProperty( + configFunctions.getConfigProperty( 'settings.workOrders.workOrderMilestoneDateRecentAfterDays' ) ) diff --git a/database/moveFee.ts b/database/moveFee.ts index d034ea92..6deef10d 100644 --- a/database/moveFee.ts +++ b/database/moveFee.ts @@ -1,4 +1,5 @@ -import { Fee } from '../types/recordTypes.js' +import type { Fee } from '../types/recordTypes.js' + import { getFee } from './getFee.js' import { acquireConnection } from './pool.js' import { updateRecordOrderNumber } from './updateRecordOrderNumber.js' diff --git a/database/updateLotComment.d.ts b/database/updateLotComment.d.ts index 6dc0643b..83deb8c7 100644 --- a/database/updateLotComment.d.ts +++ b/database/updateLotComment.d.ts @@ -1,7 +1,8 @@ +import { type DateString, type TimeString } from '@cityssm/utils-datetime'; interface UpdateLotCommentForm { lotCommentId: string | number; - lotCommentDateString: string; - lotCommentTimeString: string; + lotCommentDateString: DateString; + lotCommentTimeString: TimeString; lotComment: string; } export declare function updateLotComment(commentForm: UpdateLotCommentForm, user: User): Promise; diff --git a/database/updateLotComment.ts b/database/updateLotComment.ts index 19936f82..b4edccf9 100644 --- a/database/updateLotComment.ts +++ b/database/updateLotComment.ts @@ -1,4 +1,6 @@ import { + type DateString, + type TimeString, dateStringToInteger, timeStringToInteger } from '@cityssm/utils-datetime' @@ -7,8 +9,8 @@ import { acquireConnection } from './pool.js' interface UpdateLotCommentForm { lotCommentId: string | number - lotCommentDateString: string - lotCommentTimeString: string + lotCommentDateString: DateString + lotCommentTimeString: TimeString lotComment: string } diff --git a/database/updateLotOccupancy.d.ts b/database/updateLotOccupancy.d.ts index 3098953c..78128f5a 100644 --- a/database/updateLotOccupancy.d.ts +++ b/database/updateLotOccupancy.d.ts @@ -1,9 +1,10 @@ +import { type DateString } from '@cityssm/utils-datetime'; interface UpdateLotOccupancyForm { lotOccupancyId: string | number; occupancyTypeId: string | number; lotId: string | number; - occupancyStartDateString: string; - occupancyEndDateString: string; + occupancyStartDateString: DateString; + occupancyEndDateString: DateString | ''; occupancyTypeFieldIds?: string; [lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown; } diff --git a/database/updateLotOccupancy.ts b/database/updateLotOccupancy.ts index 68b14b6f..a507df3f 100644 --- a/database/updateLotOccupancy.ts +++ b/database/updateLotOccupancy.ts @@ -1,4 +1,4 @@ -import { dateStringToInteger } from '@cityssm/utils-datetime' +import { type DateString, dateStringToInteger } from '@cityssm/utils-datetime' import addOrUpdateLotOccupancyField from './addOrUpdateLotOccupancyField.js' import deleteLotOccupancyField from './deleteLotOccupancyField.js' @@ -9,8 +9,8 @@ interface UpdateLotOccupancyForm { occupancyTypeId: string | number lotId: string | number - occupancyStartDateString: string - occupancyEndDateString: string + occupancyStartDateString: DateString + occupancyEndDateString: DateString | '' occupancyTypeFieldIds?: string [lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown diff --git a/handlers/admin-get/lotTypes.js b/handlers/admin-get/lotTypes.js index dc606cf6..45c04ef5 100644 --- a/handlers/admin-get/lotTypes.js +++ b/handlers/admin-get/lotTypes.js @@ -3,7 +3,7 @@ import * as configFunctions from '../../helpers/functions.config.js'; export async function handler(_request, response) { const lotTypes = await getLotTypes(); response.render('admin-lotTypes', { - headTitle: `${configFunctions.getProperty('aliases.lot')} Type Management`, + headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Type Management`, lotTypes }); } diff --git a/handlers/admin-get/lotTypes.ts b/handlers/admin-get/lotTypes.ts index 9fd7fd98..ebdbf664 100644 --- a/handlers/admin-get/lotTypes.ts +++ b/handlers/admin-get/lotTypes.ts @@ -10,7 +10,7 @@ export async function handler( const lotTypes = await getLotTypes() response.render('admin-lotTypes', { - headTitle: `${configFunctions.getProperty('aliases.lot')} Type Management`, + headTitle: `${configFunctions.getConfigProperty('aliases.lot')} Type Management`, lotTypes }) } diff --git a/handlers/admin-get/ntfyStartup.js b/handlers/admin-get/ntfyStartup.js index d5082c0f..bd6d8b15 100644 --- a/handlers/admin-get/ntfyStartup.js +++ b/handlers/admin-get/ntfyStartup.js @@ -1,7 +1,7 @@ import * as configFunctions from '../../helpers/functions.config.js'; export function handler(_request, response) { - if (configFunctions.getProperty('application.ntfyStartup') === undefined) { - response.redirect(configFunctions.getProperty('reverseProxy.urlPrefix') + + if (configFunctions.getConfigProperty('application.ntfyStartup') === undefined) { + response.redirect(configFunctions.getConfigProperty('reverseProxy.urlPrefix') + '/dashboard/?error=ntfyNotConfigured'); return; } diff --git a/handlers/admin-get/ntfyStartup.ts b/handlers/admin-get/ntfyStartup.ts index 3146bf24..775fa6fd 100644 --- a/handlers/admin-get/ntfyStartup.ts +++ b/handlers/admin-get/ntfyStartup.ts @@ -3,9 +3,9 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' export function handler(_request: Request, response: Response): void { - if (configFunctions.getProperty('application.ntfyStartup') === undefined) { + if (configFunctions.getConfigProperty('application.ntfyStartup') === undefined) { response.redirect( - configFunctions.getProperty('reverseProxy.urlPrefix') + + configFunctions.getConfigProperty('reverseProxy.urlPrefix') + '/dashboard/?error=ntfyNotConfigured' ) return diff --git a/handlers/admin-get/occupancyTypes.js b/handlers/admin-get/occupancyTypes.js index b534c672..1364c37a 100644 --- a/handlers/admin-get/occupancyTypes.js +++ b/handlers/admin-get/occupancyTypes.js @@ -4,7 +4,7 @@ import * as printFunctions from '../../helpers/functions.print.js'; export async function handler(_request, response) { const occupancyTypes = await getOccupancyTypes(); const allOccupancyTypeFields = await getAllOccupancyTypeFields(); - const occupancyTypePrints = configFunctions.getProperty('settings.lotOccupancy.prints'); + const occupancyTypePrints = configFunctions.getConfigProperty('settings.lotOccupancy.prints'); const occupancyTypePrintTitles = {}; for (const printEJS of occupancyTypePrints) { const printConfig = printFunctions.getPrintConfig(printEJS); @@ -13,7 +13,7 @@ export async function handler(_request, response) { } } response.render('admin-occupancyTypes', { - headTitle: `${configFunctions.getProperty('aliases.occupancy')} Type Management`, + headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Type Management`, occupancyTypes, allOccupancyTypeFields, occupancyTypePrintTitles diff --git a/handlers/admin-get/occupancyTypes.ts b/handlers/admin-get/occupancyTypes.ts index 9667b6e4..3d368465 100644 --- a/handlers/admin-get/occupancyTypes.ts +++ b/handlers/admin-get/occupancyTypes.ts @@ -14,7 +14,7 @@ export async function handler( const occupancyTypes = await getOccupancyTypes() const allOccupancyTypeFields = await getAllOccupancyTypeFields() - const occupancyTypePrints = configFunctions.getProperty( + const occupancyTypePrints = configFunctions.getConfigProperty( 'settings.lotOccupancy.prints' ) @@ -30,7 +30,7 @@ export async function handler( response.render('admin-occupancyTypes', { headTitle: - `${configFunctions.getProperty('aliases.occupancy')} Type Management`, + `${configFunctions.getConfigProperty('aliases.occupancy')} Type Management`, occupancyTypes, allOccupancyTypeFields, occupancyTypePrintTitles diff --git a/handlers/api-get/milestoneICS.js b/handlers/api-get/milestoneICS.js index c6e5ac47..5c9932cd 100644 --- a/handlers/api-get/milestoneICS.js +++ b/handlers/api-get/milestoneICS.js @@ -3,7 +3,7 @@ import { getWorkOrderMilestones } from '../../database/getWorkOrderMilestones.js import * as configFunctions from '../../helpers/functions.config.js'; import { getPrintConfig } from '../../helpers/functions.print.js'; const calendarCompany = 'cityssm.github.io'; -const calendarProduct = configFunctions.getProperty('application.applicationName'); +const calendarProduct = configFunctions.getConfigProperty('application.applicationName'); const timeStringSplitRegex = /[ :-]/; function escapeHTML(stringToEscape) { return stringToEscape.replaceAll(/[^\d a-z]/gi, (c) => `&#${c.codePointAt(0)};`); @@ -11,10 +11,10 @@ function escapeHTML(stringToEscape) { function getUrlRoot(request) { return ('http://' + request.hostname + - (configFunctions.getProperty('application.httpPort') === 80 + (configFunctions.getConfigProperty('application.httpPort') === 80 ? '' - : `:${configFunctions.getProperty('application.httpPort')}`) + - configFunctions.getProperty('reverseProxy.urlPrefix')); + : `:${configFunctions.getConfigProperty('application.httpPort')}`) + + configFunctions.getConfigProperty('reverseProxy.urlPrefix')); } function getWorkOrderUrl(request, milestone) { return `${getUrlRoot(request)}/workOrders/${milestone.workOrderId}`; @@ -49,15 +49,15 @@ function buildEventDescriptionHTML_occupancies(request, milestone) { if (milestone.workOrderLotOccupancies.length > 0) { const urlRoot = getUrlRoot(request); descriptionHTML = `

- Related ${escapeHTML(configFunctions.getProperty('aliases.occupancies'))} + Related ${escapeHTML(configFunctions.getConfigProperty('aliases.occupancies'))}

- - + + - + `; for (const occupancy of milestone.workOrderLotOccupancies) { @@ -93,17 +93,17 @@ function buildEventDescriptionHTML_lots(request, milestone) { if (milestone.workOrderLots.length > 0) { const urlRoot = getUrlRoot(request); descriptionHTML += `

- Related ${escapeHTML(configFunctions.getProperty('aliases.lots'))} + Related ${escapeHTML(configFunctions.getConfigProperty('aliases.lots'))}

${escapeHTML(configFunctions.getProperty('aliases.occupancy'))} Type${escapeHTML(configFunctions.getProperty('aliases.lot'))}${escapeHTML(configFunctions.getConfigProperty('aliases.occupancy'))} Type${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Start Date End Date${escapeHTML(configFunctions.getProperty('aliases.occupants'))}${escapeHTML(configFunctions.getConfigProperty('aliases.occupants'))}
@@ -126,7 +126,7 @@ function buildEventDescriptionHTML_lots(request, milestone) { } function buildEventDescriptionHTML_prints(request, milestone) { let descriptionHTML = ''; - const prints = configFunctions.getProperty('settings.workOrders.prints'); + const prints = configFunctions.getConfigProperty('settings.workOrders.prints'); if (prints.length > 0) { const urlRoot = getUrlRoot(request); descriptionHTML += '

Prints

'; @@ -245,13 +245,13 @@ export async function handler(request, response) { if (organizerSet) { calendarEvent.createAttendee({ name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`, - email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress') + email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress') }); } else { calendarEvent.organizer({ name: `${occupant.occupantName ?? ''} ${occupant.occupantFamilyName ?? ''}`, - email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress') + email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress') }); organizerSet = true; } @@ -261,7 +261,7 @@ export async function handler(request, response) { else { calendarEvent.organizer({ name: milestone.recordCreate_userName, - email: configFunctions.getProperty('settings.workOrders.calendarEmailAddress') + email: configFunctions.getConfigProperty('settings.workOrders.calendarEmailAddress') }); } } diff --git a/handlers/api-get/milestoneICS.ts b/handlers/api-get/milestoneICS.ts index 0bee5207..0e95f5b3 100644 --- a/handlers/api-get/milestoneICS.ts +++ b/handlers/api-get/milestoneICS.ts @@ -12,7 +12,7 @@ import { getPrintConfig } from '../../helpers/functions.print.js' import type { WorkOrderMilestone } from '../../types/recordTypes.js' const calendarCompany = 'cityssm.github.io' -const calendarProduct = configFunctions.getProperty( +const calendarProduct = configFunctions.getConfigProperty( 'application.applicationName' ) @@ -29,10 +29,10 @@ function getUrlRoot(request: Request): string { return ( 'http://' + request.hostname + - (configFunctions.getProperty('application.httpPort') === 80 + (configFunctions.getConfigProperty('application.httpPort') === 80 ? '' - : `:${configFunctions.getProperty('application.httpPort')}`) + - configFunctions.getProperty('reverseProxy.urlPrefix') + : `:${configFunctions.getConfigProperty('application.httpPort')}`) + + configFunctions.getConfigProperty('reverseProxy.urlPrefix') ) } @@ -88,17 +88,17 @@ function buildEventDescriptionHTML_occupancies( const urlRoot = getUrlRoot(request) descriptionHTML = `

- Related ${escapeHTML(configFunctions.getProperty('aliases.occupancies'))} + Related ${escapeHTML(configFunctions.getConfigProperty('aliases.occupancies'))}

- ${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type + ${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type - ${escapeHTML(configFunctions.getProperty('aliases.map'))} + ${escapeHTML(configFunctions.getConfigProperty('aliases.map'))} - ${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type + ${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type Status
- + - + ` @@ -152,17 +152,17 @@ function buildEventDescriptionHTML_lots( const urlRoot = getUrlRoot(request) descriptionHTML += `

- Related ${escapeHTML(configFunctions.getProperty('aliases.lots'))} + Related ${escapeHTML(configFunctions.getConfigProperty('aliases.lots'))}

${escapeHTML( - configFunctions.getProperty('aliases.occupancy') + configFunctions.getConfigProperty('aliases.occupancy') )} Type${escapeHTML(configFunctions.getProperty('aliases.lot'))}${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Start Date End Date${escapeHTML(configFunctions.getProperty('aliases.occupants'))}${escapeHTML(configFunctions.getConfigProperty('aliases.occupants'))}
@@ -194,7 +194,7 @@ function buildEventDescriptionHTML_prints( ): string { let descriptionHTML = '' - const prints = configFunctions.getProperty('settings.workOrders.prints') + const prints = configFunctions.getConfigProperty('settings.workOrders.prints') if (prints.length > 0) { const urlRoot = getUrlRoot(request) @@ -395,7 +395,7 @@ export async function handler( name: `${occupant.occupantName ?? ''} ${ occupant.occupantFamilyName ?? '' }`, - email: configFunctions.getProperty( + email: configFunctions.getConfigProperty( 'settings.workOrders.calendarEmailAddress' ) }) @@ -404,7 +404,7 @@ export async function handler( name: `${occupant.occupantName ?? ''} ${ occupant.occupantFamilyName ?? '' }`, - email: configFunctions.getProperty( + email: configFunctions.getConfigProperty( 'settings.workOrders.calendarEmailAddress' ) }) @@ -415,7 +415,7 @@ export async function handler( } else { calendarEvent.organizer({ name: milestone.recordCreate_userName!, - email: configFunctions.getProperty( + email: configFunctions.getConfigProperty( 'settings.workOrders.calendarEmailAddress' ) }) diff --git a/handlers/lotOccupancies-get/edit.js b/handlers/lotOccupancies-get/edit.js index 04441bbc..a7964224 100644 --- a/handlers/lotOccupancies-get/edit.js +++ b/handlers/lotOccupancies-get/edit.js @@ -5,7 +5,7 @@ import * as configFunctions from '../../helpers/functions.config.js'; export async function handler(request, response) { const lotOccupancy = await getLotOccupancy(request.params.lotOccupancyId); if (lotOccupancy === undefined) { - response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`); + response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/lotOccupancies/?error=lotOccupancyIdNotFound`); return; } const occupancyTypePrints = await getOccupancyTypePrintsById(lotOccupancy.occupancyTypeId); @@ -16,7 +16,7 @@ export async function handler(request, response) { const maps = await getMaps(); const workOrderTypes = await getWorkOrderTypes(); response.render('lotOccupancy-edit', { - headTitle: `${configFunctions.getProperty('aliases.occupancy')} Update`, + headTitle: `${configFunctions.getConfigProperty('aliases.occupancy')} Update`, lotOccupancy, occupancyTypePrints, occupancyTypes, diff --git a/handlers/lotOccupancies-get/edit.ts b/handlers/lotOccupancies-get/edit.ts index 7f562843..284af342 100644 --- a/handlers/lotOccupancies-get/edit.ts +++ b/handlers/lotOccupancies-get/edit.ts @@ -17,7 +17,7 @@ export async function handler(request: Request, response: Response): Promise { const map: MapRecord = { - mapCity: configFunctions.getProperty('settings.map.mapCityDefault'), - mapProvince: configFunctions.getProperty('settings.map.mapProvinceDefault') + mapCity: configFunctions.getConfigProperty('settings.map.mapCityDefault'), + mapProvince: configFunctions.getConfigProperty('settings.map.mapProvinceDefault') } const mapSVGs = await getMapSVGs() response.render('map-edit', { - headTitle: `${configFunctions.getProperty('aliases.map')} Create`, + headTitle: `${configFunctions.getConfigProperty('aliases.map')} Create`, isCreate: true, map, mapSVGs diff --git a/handlers/maps-get/next.js b/handlers/maps-get/next.js index dc871d13..353744bf 100644 --- a/handlers/maps-get/next.js +++ b/handlers/maps-get/next.js @@ -4,9 +4,9 @@ export async function handler(request, response) { const mapId = Number.parseInt(request.params.mapId, 10); const nextMapId = await getNextMapId(mapId); if (nextMapId === undefined) { - response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/maps/?error=noNextMapIdFound`); + response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noNextMapIdFound`); return; } - response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/maps/${nextMapId.toString()}`); + response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/${nextMapId.toString()}`); } export default handler; diff --git a/handlers/maps-get/next.ts b/handlers/maps-get/next.ts index 4cef210a..3e993db1 100644 --- a/handlers/maps-get/next.ts +++ b/handlers/maps-get/next.ts @@ -13,7 +13,7 @@ export async function handler( if (nextMapId === undefined) { response.redirect( - `${configFunctions.getProperty( + `${configFunctions.getConfigProperty( 'reverseProxy.urlPrefix' )}/maps/?error=noNextMapIdFound` ) @@ -21,7 +21,7 @@ export async function handler( } response.redirect( - `${configFunctions.getProperty( + `${configFunctions.getConfigProperty( 'reverseProxy.urlPrefix' )}/maps/${nextMapId.toString()}` ) diff --git a/handlers/maps-get/previous.js b/handlers/maps-get/previous.js index 80154cc9..62bc34e2 100644 --- a/handlers/maps-get/previous.js +++ b/handlers/maps-get/previous.js @@ -4,9 +4,9 @@ export async function handler(request, response) { const mapId = Number.parseInt(request.params.mapId, 10); const previousMapId = await getPreviousMapId(mapId); if (previousMapId === undefined) { - response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/maps/?error=noPreviousMapIdFound`); + response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/?error=noPreviousMapIdFound`); return; } - response.redirect(`${configFunctions.getProperty('reverseProxy.urlPrefix')}/maps/${previousMapId.toString()}`); + response.redirect(`${configFunctions.getConfigProperty('reverseProxy.urlPrefix')}/maps/${previousMapId.toString()}`); } export default handler; diff --git a/handlers/maps-get/previous.ts b/handlers/maps-get/previous.ts index de8f73b5..2c1b4d17 100644 --- a/handlers/maps-get/previous.ts +++ b/handlers/maps-get/previous.ts @@ -13,7 +13,7 @@ export async function handler( if (previousMapId === undefined) { response.redirect( - `${configFunctions.getProperty( + `${configFunctions.getConfigProperty( 'reverseProxy.urlPrefix' )}/maps/?error=noPreviousMapIdFound` ) @@ -21,7 +21,7 @@ export async function handler( } response.redirect( - `${configFunctions.getProperty( + `${configFunctions.getConfigProperty( 'reverseProxy.urlPrefix' )}/maps/${previousMapId.toString()}` ) diff --git a/handlers/maps-get/search.js b/handlers/maps-get/search.js index 029705d7..2d0e202b 100644 --- a/handlers/maps-get/search.js +++ b/handlers/maps-get/search.js @@ -3,7 +3,7 @@ import * as configFunctions from '../../helpers/functions.config.js'; export async function handler(_request, response) { const maps = await getMaps(); response.render('map-search', { - headTitle: `${configFunctions.getProperty('aliases.map')} Search`, + headTitle: `${configFunctions.getConfigProperty('aliases.map')} Search`, maps }); } diff --git a/handlers/maps-get/search.ts b/handlers/maps-get/search.ts index 3b9dfb0b..2f58a7b8 100644 --- a/handlers/maps-get/search.ts +++ b/handlers/maps-get/search.ts @@ -7,7 +7,7 @@ export async function handler(_request: Request, response: Response): Promise { try { @@ -46,7 +46,7 @@ const safeRedirects = new Set([ const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/; const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/; export function getSafeRedirectURL(possibleRedirectURL = '') { - const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix'); + const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix'); if (typeof possibleRedirectURL === 'string') { const urlToCheck = possibleRedirectURL.startsWith(urlPrefix) ? possibleRedirectURL.slice(urlPrefix.length) diff --git a/helpers/functions.authentication.ts b/helpers/functions.authentication.ts index 1bf1da11..c7fa8a9b 100644 --- a/helpers/functions.authentication.ts +++ b/helpers/functions.authentication.ts @@ -2,9 +2,9 @@ import ActiveDirectory from 'activedirectory2' import * as configFunctions from './functions.config.js' -const userDomain = configFunctions.getProperty('application.userDomain') +const userDomain = configFunctions.getConfigProperty('application.userDomain') -const activeDirectoryConfig = configFunctions.getProperty('activeDirectory') +const activeDirectoryConfig = configFunctions.getConfigProperty('activeDirectory') async function authenticateViaActiveDirectory( userName: string, @@ -64,7 +64,7 @@ const recordUrl = /^\/(?:maps|lots|lotoccupancies|workorders)\/\d+(?:\/edit)?$/ const printUrl = /^\/print\/(?:pdf|screen)\/[\d/=?A-Za-z-]+$/ export function getSafeRedirectURL(possibleRedirectURL = ''): string { - const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix') + const urlPrefix = configFunctions.getConfigProperty('reverseProxy.urlPrefix') if (typeof possibleRedirectURL === 'string') { const urlToCheck = possibleRedirectURL.startsWith(urlPrefix) diff --git a/helpers/functions.cache.js b/helpers/functions.cache.js index aea14e28..8c0172df 100644 --- a/helpers/functions.cache.js +++ b/helpers/functions.cache.js @@ -114,7 +114,7 @@ export async function getOccupancyTypePrintsById(occupancyTypeId) { return []; } if (occupancyType.occupancyTypePrints.includes('*')) { - return configFunctions.getProperty('settings.lotOccupancy.prints'); + return configFunctions.getConfigProperty('settings.lotOccupancy.prints'); } return occupancyType.occupancyTypePrints ?? []; } diff --git a/helpers/functions.cache.ts b/helpers/functions.cache.ts index ae18941c..47b9d16b 100644 --- a/helpers/functions.cache.ts +++ b/helpers/functions.cache.ts @@ -205,7 +205,7 @@ export async function getOccupancyTypePrintsById( } if (occupancyType.occupancyTypePrints.includes('*')) { - return configFunctions.getProperty('settings.lotOccupancy.prints') + return configFunctions.getConfigProperty('settings.lotOccupancy.prints') } return occupancyType.occupancyTypePrints ?? [] diff --git a/helpers/functions.config.d.ts b/helpers/functions.config.d.ts index 7b18260e..9be646d8 100644 --- a/helpers/functions.config.d.ts +++ b/helpers/functions.config.d.ts @@ -1,14 +1,14 @@ import type { config as MSSQLConfig } from 'mssql'; import type { ConfigActiveDirectory, ConfigNtfyStartup, DynamicsGPLookup } from '../types/configTypes.js'; -export declare function getProperty(propertyName: 'application.applicationName' | 'application.logoURL' | 'application.userDomain' | 'reverseProxy.urlPrefix' | 'session.cookieName' | 'session.secret' | 'aliases.lot' | 'aliases.lots' | 'aliases.map' | 'aliases.maps' | 'aliases.occupancy' | 'aliases.occupancies' | 'aliases.occupancyStartDate' | 'aliases.occupant' | 'aliases.occupants' | 'aliases.workOrderOpenDate' | 'aliases.workOrderCloseDate' | 'aliases.externalReceiptNumber' | 'settings.map.mapCityDefault' | 'settings.map.mapProvinceDefault' | 'settings.lot.lotNameHelpText' | 'settings.lotOccupancy.occupantCityDefault' | 'settings.lotOccupancy.occupantProvinceDefault' | 'settings.workOrders.calendarEmailAddress'): string; -export declare function getProperty(propertyName: 'application.httpPort' | 'application.maximumProcesses' | 'session.maxAgeMillis' | 'settings.fees.taxPercentageDefault' | 'settings.workOrders.workOrderNumberLength' | 'settings.workOrders.workOrderMilestoneDateRecentBeforeDays' | 'settings.workOrders.workOrderMilestoneDateRecentAfterDays' | 'settings.adminCleanup.recordDeleteAgeDays'): number; -export declare function getProperty(propertyName: 'application.useTestDatabases' | 'reverseProxy.disableCompression' | 'reverseProxy.disableEtag' | 'session.doKeepAlive' | 'settings.lotOccupancy.occupancyEndDateIsRequired' | 'settings.dynamicsGP.integrationIsEnabled'): boolean; -export declare function getProperty(propertyName: 'users.testing' | 'users.canLogin' | 'users.canUpdate' | 'users.isAdmin' | 'settings.dynamicsGP.accountCodes' | 'settings.dynamicsGP.itemNumbers' | 'settings.dynamicsGP.trialBalanceCodes' | 'settings.lotOccupancy.prints' | 'settings.workOrders.prints'): string[]; -export declare function getProperty(propertyName: 'application.ntfyStartup'): ConfigNtfyStartup | undefined; -export declare function getProperty(propertyName: 'activeDirectory'): ConfigActiveDirectory; -export declare function getProperty(propertyName: 'settings.lot.lotNamePattern'): RegExp; -export declare function getProperty(propertyName: 'settings.lot.lotNameSortNameFunction'): (lotName: string) => string; -export declare function getProperty(propertyName: 'settings.printPdf.contentDisposition'): 'attachment' | 'inline'; -export declare function getProperty(propertyName: 'settings.dynamicsGP.mssqlConfig'): MSSQLConfig; -export declare function getProperty(propertyName: 'settings.dynamicsGP.lookupOrder'): DynamicsGPLookup[]; +export declare function getConfigProperty(propertyName: 'application.applicationName' | 'application.logoURL' | 'application.userDomain' | 'reverseProxy.urlPrefix' | 'session.cookieName' | 'session.secret' | 'aliases.lot' | 'aliases.lots' | 'aliases.map' | 'aliases.maps' | 'aliases.occupancy' | 'aliases.occupancies' | 'aliases.occupancyStartDate' | 'aliases.occupant' | 'aliases.occupants' | 'aliases.workOrderOpenDate' | 'aliases.workOrderCloseDate' | 'aliases.externalReceiptNumber' | 'settings.map.mapCityDefault' | 'settings.map.mapProvinceDefault' | 'settings.lot.lotNameHelpText' | 'settings.lotOccupancy.occupantCityDefault' | 'settings.lotOccupancy.occupantProvinceDefault' | 'settings.workOrders.calendarEmailAddress'): string; +export declare function getConfigProperty(propertyName: 'application.httpPort' | 'application.maximumProcesses' | 'session.maxAgeMillis' | 'settings.fees.taxPercentageDefault' | 'settings.workOrders.workOrderNumberLength' | 'settings.workOrders.workOrderMilestoneDateRecentBeforeDays' | 'settings.workOrders.workOrderMilestoneDateRecentAfterDays' | 'settings.adminCleanup.recordDeleteAgeDays'): number; +export declare function getConfigProperty(propertyName: 'application.useTestDatabases' | 'reverseProxy.disableCompression' | 'reverseProxy.disableEtag' | 'session.doKeepAlive' | 'settings.lotOccupancy.occupancyEndDateIsRequired' | 'settings.dynamicsGP.integrationIsEnabled'): boolean; +export declare function getConfigProperty(propertyName: 'users.testing' | 'users.canLogin' | 'users.canUpdate' | 'users.isAdmin' | 'settings.dynamicsGP.accountCodes' | 'settings.dynamicsGP.itemNumbers' | 'settings.dynamicsGP.trialBalanceCodes' | 'settings.lotOccupancy.prints' | 'settings.workOrders.prints'): string[]; +export declare function getConfigProperty(propertyName: 'application.ntfyStartup'): ConfigNtfyStartup | undefined; +export declare function getConfigProperty(propertyName: 'activeDirectory'): ConfigActiveDirectory; +export declare function getConfigProperty(propertyName: 'settings.lot.lotNamePattern'): RegExp; +export declare function getConfigProperty(propertyName: 'settings.lot.lotNameSortNameFunction'): (lotName: string) => string; +export declare function getConfigProperty(propertyName: 'settings.printPdf.contentDisposition'): 'attachment' | 'inline'; +export declare function getConfigProperty(propertyName: 'settings.dynamicsGP.mssqlConfig'): MSSQLConfig; +export declare function getConfigProperty(propertyName: 'settings.dynamicsGP.lookupOrder'): DynamicsGPLookup[]; export declare const keepAliveMillis: number; diff --git a/helpers/functions.config.js b/helpers/functions.config.js index 2cf9e8fe..d37ed608 100644 --- a/helpers/functions.config.js +++ b/helpers/functions.config.js @@ -54,7 +54,7 @@ configFallbackValues.set('settings.dynamicsGP.lookupOrder', ['invoice']); configFallbackValues.set('settings.dynamicsGP.accountCodes', []); configFallbackValues.set('settings.dynamicsGP.itemNumbers', []); configFallbackValues.set('settings.dynamicsGP.trialBalanceCodes', []); -export function getProperty(propertyName) { +export function getConfigProperty(propertyName) { const propertyNameSplit = propertyName.split('.'); let currentObject = config; for (const propertyNamePiece of propertyNameSplit) { @@ -66,6 +66,6 @@ export function getProperty(propertyName) { } return currentObject; } -export const keepAliveMillis = getProperty('session.doKeepAlive') - ? Math.max(getProperty('session.maxAgeMillis') / 2, getProperty('session.maxAgeMillis') - 10 * 60 * 1000) +export const keepAliveMillis = getConfigProperty('session.doKeepAlive') + ? Math.max(getConfigProperty('session.maxAgeMillis') / 2, getConfigProperty('session.maxAgeMillis') - 10 * 60 * 1000) : 0; diff --git a/helpers/functions.config.ts b/helpers/functions.config.ts index 2370df9b..9a087a30 100644 --- a/helpers/functions.config.ts +++ b/helpers/functions.config.ts @@ -106,7 +106,7 @@ configFallbackValues.set('settings.dynamicsGP.trialBalanceCodes', []) * Set up function overloads */ -export function getProperty( +export function getConfigProperty( propertyName: | 'application.applicationName' | 'application.logoURL' @@ -134,7 +134,7 @@ export function getProperty( | 'settings.workOrders.calendarEmailAddress' ): string -export function getProperty( +export function getConfigProperty( propertyName: | 'application.httpPort' | 'application.maximumProcesses' @@ -146,7 +146,7 @@ export function getProperty( | 'settings.adminCleanup.recordDeleteAgeDays' ): number -export function getProperty( +export function getConfigProperty( propertyName: | 'application.useTestDatabases' | 'reverseProxy.disableCompression' @@ -156,7 +156,7 @@ export function getProperty( | 'settings.dynamicsGP.integrationIsEnabled' ): boolean -export function getProperty( +export function getConfigProperty( propertyName: | 'users.testing' | 'users.canLogin' @@ -169,33 +169,33 @@ export function getProperty( | 'settings.workOrders.prints' ): string[] -export function getProperty( +export function getConfigProperty( propertyName: 'application.ntfyStartup' ): ConfigNtfyStartup | undefined -export function getProperty( +export function getConfigProperty( propertyName: 'activeDirectory' ): ConfigActiveDirectory -export function getProperty(propertyName: 'settings.lot.lotNamePattern'): RegExp +export function getConfigProperty(propertyName: 'settings.lot.lotNamePattern'): RegExp -export function getProperty( +export function getConfigProperty( propertyName: 'settings.lot.lotNameSortNameFunction' ): (lotName: string) => string -export function getProperty( +export function getConfigProperty( propertyName: 'settings.printPdf.contentDisposition' ): 'attachment' | 'inline' -export function getProperty( +export function getConfigProperty( propertyName: 'settings.dynamicsGP.mssqlConfig' ): MSSQLConfig -export function getProperty( +export function getConfigProperty( propertyName: 'settings.dynamicsGP.lookupOrder' ): DynamicsGPLookup[] -export function getProperty(propertyName: string): unknown { +export function getConfigProperty(propertyName: string): unknown { const propertyNameSplit = propertyName.split('.') let currentObject = config @@ -212,9 +212,9 @@ export function getProperty(propertyName: string): unknown { return currentObject } -export const keepAliveMillis = getProperty('session.doKeepAlive') +export const keepAliveMillis = getConfigProperty('session.doKeepAlive') ? Math.max( - getProperty('session.maxAgeMillis') / 2, - getProperty('session.maxAgeMillis') - 10 * 60 * 1000 + getConfigProperty('session.maxAgeMillis') / 2, + getConfigProperty('session.maxAgeMillis') - 10 * 60 * 1000 ) : 0 diff --git a/helpers/functions.dynamicsGP.js b/helpers/functions.dynamicsGP.js index b8d5dbfb..5d7c7384 100644 --- a/helpers/functions.dynamicsGP.js +++ b/helpers/functions.dynamicsGP.js @@ -1,11 +1,11 @@ import { DynamicsGP } from '@cityssm/dynamics-gp'; import * as configFunctions from './functions.config.js'; let gp; -if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { - gp = new DynamicsGP(configFunctions.getProperty('settings.dynamicsGP.mssqlConfig')); +if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { + gp = new DynamicsGP(configFunctions.getConfigProperty('settings.dynamicsGP.mssqlConfig')); } function filterCashReceipt(cashReceipt) { - const accountCodes = configFunctions.getProperty('settings.dynamicsGP.accountCodes'); + const accountCodes = configFunctions.getConfigProperty('settings.dynamicsGP.accountCodes'); if (accountCodes.length > 0) { for (const detail of cashReceipt.details) { if (accountCodes.includes(detail.accountCode)) { @@ -22,7 +22,7 @@ function filterCashReceipt(cashReceipt) { return cashReceipt; } function filterInvoice(invoice) { - const itemNumbers = configFunctions.getProperty('settings.dynamicsGP.itemNumbers'); + const itemNumbers = configFunctions.getConfigProperty('settings.dynamicsGP.itemNumbers'); for (const itemNumber of itemNumbers) { const found = invoice.lineItems.some((itemRecord) => { return itemRecord.itemNumber === itemNumber; @@ -37,7 +37,7 @@ function filterExtendedInvoice(invoice) { if (filterInvoice(invoice) === undefined) { return undefined; } - const trialBalanceCodes = configFunctions.getProperty('settings.dynamicsGP.trialBalanceCodes'); + const trialBalanceCodes = configFunctions.getConfigProperty('settings.dynamicsGP.trialBalanceCodes'); if (trialBalanceCodes.length > 0 && trialBalanceCodes.includes(invoice.trialBalanceCode ?? '')) { return invoice; @@ -115,11 +115,11 @@ async function _getDynamicsGPDocument(documentNumber, lookupType) { return document; } export async function getDynamicsGPDocument(documentNumber) { - if (!configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { + if (!configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { return undefined; } let document; - for (const lookupType of configFunctions.getProperty('settings.dynamicsGP.lookupOrder')) { + for (const lookupType of configFunctions.getConfigProperty('settings.dynamicsGP.lookupOrder')) { document = await _getDynamicsGPDocument(documentNumber, lookupType); if (document !== undefined) { break; diff --git a/helpers/functions.dynamicsGP.ts b/helpers/functions.dynamicsGP.ts index fc39dd5d..d652da2e 100644 --- a/helpers/functions.dynamicsGP.ts +++ b/helpers/functions.dynamicsGP.ts @@ -14,16 +14,16 @@ import * as configFunctions from './functions.config.js' let gp: DynamicsGP -if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { +if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { gp = new DynamicsGP( - configFunctions.getProperty('settings.dynamicsGP.mssqlConfig') + configFunctions.getConfigProperty('settings.dynamicsGP.mssqlConfig') ) } function filterCashReceipt( cashReceipt: DiamondCashReceipt ): DiamondCashReceipt | undefined { - const accountCodes = configFunctions.getProperty( + const accountCodes = configFunctions.getConfigProperty( 'settings.dynamicsGP.accountCodes' ) @@ -47,7 +47,7 @@ function filterCashReceipt( } function filterInvoice(invoice: GPInvoice): GPInvoice | undefined { - const itemNumbers = configFunctions.getProperty( + const itemNumbers = configFunctions.getConfigProperty( 'settings.dynamicsGP.itemNumbers' ) @@ -71,7 +71,7 @@ function filterExtendedInvoice( return undefined } - const trialBalanceCodes = configFunctions.getProperty( + const trialBalanceCodes = configFunctions.getConfigProperty( 'settings.dynamicsGP.trialBalanceCodes' ) @@ -177,14 +177,14 @@ export async function getDynamicsGPDocument( documentNumber: string ): Promise { if ( - !configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled') + !configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled') ) { return undefined } let document: DynamicsGPDocument | undefined - for (const lookupType of configFunctions.getProperty( + for (const lookupType of configFunctions.getConfigProperty( 'settings.dynamicsGP.lookupOrder' )) { document = await _getDynamicsGPDocument(documentNumber, lookupType) diff --git a/helpers/functions.print.js b/helpers/functions.print.js index bbf0660c..d43c6d55 100644 --- a/helpers/functions.print.js +++ b/helpers/functions.print.js @@ -4,7 +4,7 @@ import { getWorkOrder } from '../database/getWorkOrder.js'; import * as configFunctions from './functions.config.js'; const screenPrintConfigs = { lotOccupancy: { - title: `${configFunctions.getProperty('aliases.lot')} ${configFunctions.getProperty('aliases.occupancy')} Print`, + title: `${configFunctions.getConfigProperty('aliases.lot')} ${configFunctions.getConfigProperty('aliases.occupancy')} Print`, params: ['lotOccupancyId'] } }; diff --git a/helpers/functions.print.ts b/helpers/functions.print.ts index c53366b5..8ec3fc10 100644 --- a/helpers/functions.print.ts +++ b/helpers/functions.print.ts @@ -11,9 +11,9 @@ interface PrintConfig { const screenPrintConfigs: Record = { lotOccupancy: { - title: `${configFunctions.getProperty( + title: `${configFunctions.getConfigProperty( 'aliases.lot' - )} ${configFunctions.getProperty('aliases.occupancy')} Print`, + )} ${configFunctions.getConfigProperty('aliases.occupancy')} Print`, params: ['lotOccupancyId'] } } diff --git a/helpers/functions.user.js b/helpers/functions.user.js index f3ed8c51..5059dfa0 100644 --- a/helpers/functions.user.js +++ b/helpers/functions.user.js @@ -16,7 +16,7 @@ export async function apiKeyIsValid(request) { return false; } return configFunctions - .getProperty('users.canLogin') + .getConfigProperty('users.canLogin') .some((currentUserName) => { return userName === currentUserName.toLowerCase(); }); diff --git a/helpers/functions.user.ts b/helpers/functions.user.ts index 78b35b98..4ff56907 100644 --- a/helpers/functions.user.ts +++ b/helpers/functions.user.ts @@ -35,7 +35,7 @@ export async function apiKeyIsValid(request: APIRequest): Promise { } return configFunctions - .getProperty('users.canLogin') + .getConfigProperty('users.canLogin') .some((currentUserName) => { return userName === currentUserName.toLowerCase() }) diff --git a/package-lock.json b/package-lock.json index 9b2255bc..6de16350 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@cityssm/font-awesome-v5-iconclasses": "^0.1.0", "@cityssm/ntfy-publish": "^1.0.1", "@cityssm/pdf-puppeteer": "^4.2.0", - "@cityssm/utils-datetime": "^1.2.0", + "@cityssm/utils-datetime": "^1.3.0", "@fortawesome/fontawesome-free": "^5.15.4", "activedirectory2": "^2.2.0", "better-sqlite-pool": "^0.3.2", @@ -88,7 +88,7 @@ "gulp-include": "^2.4.1", "gulp-minify": "^3.1.0", "gulp-sass": "^5.1.0", - "nodemon": "^3.1.3", + "nodemon": "^3.1.4", "prettier-config-cityssm": "^1.0.0", "sass": "^1.77.6" }, @@ -617,9 +617,9 @@ } }, "node_modules/@cityssm/utils-datetime": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@cityssm/utils-datetime/-/utils-datetime-1.2.0.tgz", - "integrity": "sha512-GNp7nUhUA2iwwxkPUk7swiMcyhb7/0rzjzvuojGZcgL4D6hBq0umcH+gDsvQ3+dn8Xvv5MHkFu/1067Y1RE2pg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@cityssm/utils-datetime/-/utils-datetime-1.3.0.tgz", + "integrity": "sha512-CPfRawEFshGUKoOkfNrVCX7FnWrHbZQBFQfRW3Y4iZJ3xZ9mp+euKVPvW6d1wTp8Nz1hIsD/ArpL1ImJYfhPnA==", "engines": { "node": ">=18.0.0" } @@ -7970,9 +7970,9 @@ "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==" }, "node_modules/nodemon": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.3.tgz", - "integrity": "sha512-m4Vqs+APdKzDFpuaL9F9EVOF85+h070FnkHVEoU4+rmT6Vw0bmNl7s61VEkY/cJkL7RCv1p4urnUDUMrS5rk2w==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.1.4.tgz", + "integrity": "sha512-wjPBbFhtpJwmIeY2yP7QF+UKzPfltVGtfce1g/bB15/8vCGZj8uxD62b/b9M9/WVgme0NZudpownKN+c0plXlQ==", "dev": true, "dependencies": { "chokidar": "^3.5.2", diff --git a/package.json b/package.json index 46a94f85..70dfa5e4 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@cityssm/font-awesome-v5-iconclasses": "^0.1.0", "@cityssm/ntfy-publish": "^1.0.1", "@cityssm/pdf-puppeteer": "^4.2.0", - "@cityssm/utils-datetime": "^1.2.0", + "@cityssm/utils-datetime": "^1.3.0", "@fortawesome/fontawesome-free": "^5.15.4", "activedirectory2": "^2.2.0", "better-sqlite-pool": "^0.3.2", @@ -112,7 +112,7 @@ "gulp-include": "^2.4.1", "gulp-minify": "^3.1.0", "gulp-sass": "^5.1.0", - "nodemon": "^3.1.3", + "nodemon": "^3.1.4", "prettier-config-cityssm": "^1.0.0", "sass": "^1.77.6" } diff --git a/routes/login.js b/routes/login.js index 60b8b922..29512464 100644 --- a/routes/login.js +++ b/routes/login.js @@ -7,7 +7,7 @@ import * as configFunctions from '../helpers/functions.config.js'; const debug = Debug('lot-occupancy-system:login'); export const router = Router(); function getHandler(request, response) { - const sessionCookieName = configFunctions.getProperty('session.cookieName'); + const sessionCookieName = configFunctions.getConfigProperty('session.cookieName'); if (request.session.user !== undefined && request.cookies[sessionCookieName] !== undefined) { const redirectURL = authenticationFunctions.getSafeRedirectURL((request.query.redirect ?? '')); @@ -31,7 +31,7 @@ async function postHandler(request, response) { if (userName.startsWith('*')) { if (useTestDatabases && userName === passwordPlain) { isAuthenticated = configFunctions - .getProperty('users.testing') + .getConfigProperty('users.testing') .includes(userName); if (isAuthenticated) { debug('Authenticated testing user: ' + userName); @@ -45,18 +45,18 @@ async function postHandler(request, response) { if (isAuthenticated) { const userNameLowerCase = userName.toLowerCase(); const canLogin = configFunctions - .getProperty('users.canLogin') + .getConfigProperty('users.canLogin') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase(); }); if (canLogin) { const canUpdate = configFunctions - .getProperty('users.canUpdate') + .getConfigProperty('users.canUpdate') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase(); }); const isAdmin = configFunctions - .getProperty('users.isAdmin') + .getConfigProperty('users.isAdmin') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase(); }); diff --git a/routes/login.ts b/routes/login.ts index b8e5c13c..12dcf8b5 100644 --- a/routes/login.ts +++ b/routes/login.ts @@ -16,7 +16,7 @@ const debug = Debug('lot-occupancy-system:login') export const router = Router() function getHandler(request: Request, response: Response): void { - const sessionCookieName = configFunctions.getProperty('session.cookieName') + const sessionCookieName = configFunctions.getConfigProperty('session.cookieName') if ( request.session.user !== undefined && @@ -60,7 +60,7 @@ async function postHandler( if (userName.startsWith('*')) { if (useTestDatabases && userName === passwordPlain) { isAuthenticated = configFunctions - .getProperty('users.testing') + .getConfigProperty('users.testing') .includes(userName) if (isAuthenticated) { @@ -80,20 +80,20 @@ async function postHandler( const userNameLowerCase = userName.toLowerCase() const canLogin = configFunctions - .getProperty('users.canLogin') + .getConfigProperty('users.canLogin') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase() }) if (canLogin) { const canUpdate = configFunctions - .getProperty('users.canUpdate') + .getConfigProperty('users.canUpdate') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase() }) const isAdmin = configFunctions - .getProperty('users.isAdmin') + .getConfigProperty('users.isAdmin') .some((currentUserName) => { return userNameLowerCase === currentUserName.toLowerCase() }) diff --git a/routes/lotOccupancies.js b/routes/lotOccupancies.js index f1222deb..822cb1f3 100644 --- a/routes/lotOccupancies.js +++ b/routes/lotOccupancies.js @@ -48,7 +48,7 @@ router.post('/doGetFees', permissionHandlers.updatePostHandler, handler_doGetFee router.post('/doAddLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyFee); router.post('/doUpdateLotOccupancyFeeQuantity', permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancyFeeQuantity); router.post('/doDeleteLotOccupancyFee', permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancyFee); -if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { +if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { router.post('/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, handler_doGetDynamicsGPDocument); } router.post('/doAddLotOccupancyTransaction', permissionHandlers.updatePostHandler, handler_doAddLotOccupancyTransaction); diff --git a/routes/lotOccupancies.ts b/routes/lotOccupancies.ts index 63fb00e6..3220e99b 100644 --- a/routes/lotOccupancies.ts +++ b/routes/lotOccupancies.ts @@ -163,7 +163,7 @@ router.post( // Transactions -if (configFunctions.getProperty('settings.dynamicsGP.integrationIsEnabled')) { +if (configFunctions.getConfigProperty('settings.dynamicsGP.integrationIsEnabled')) { router.post( '/doGetDynamicsGPDocument', permissionHandlers.updatePostHandler, diff --git a/views/_footerA.ejs b/views/_footerA.ejs index 030380ed..297ca7a2 100644 --- a/views/_footerA.ejs +++ b/views/_footerA.ejs @@ -4,7 +4,7 @@

- <%= configFunctions.getProperty("application.applicationName") %> + <%= configFunctions.getConfigProperty("application.applicationName") %>
Build <%= buildNumber %>

@@ -14,20 +14,20 @@ diff --git a/views/_header.ejs b/views/_header.ejs index 167c6a69..d0cc28bd 100644 --- a/views/_header.ejs +++ b/views/_header.ejs @@ -8,10 +8,10 @@ <%= headTitle %>: - <%= configFunctions.getProperty("application.applicationName") %> + <%= configFunctions.getConfigProperty("application.applicationName") %> - " /> + " /> @@ -24,10 +24,10 @@ diff --git a/views/admin-occupancyTypes.ejs b/views/admin-occupancyTypes.ejs index 152cc918..cb7e2a7e 100644 --- a/views/admin-occupancyTypes.ejs +++ b/views/admin-occupancyTypes.ejs @@ -16,7 +16,7 @@
  • - <%= configFunctions.getProperty("aliases.occupancy") %> Type Management + <%= configFunctions.getConfigProperty("aliases.occupancy") %> Type Management
  • @@ -25,13 +25,13 @@

    - <%= configFunctions.getProperty("aliases.occupancy") %> Type Management + <%= configFunctions.getConfigProperty("aliases.occupancy") %> Type Management

    diff --git a/views/admin-tables.ejs b/views/admin-tables.ejs index 85a1d6c4..441218e0 100644 --- a/views/admin-tables.ejs +++ b/views/admin-tables.ejs @@ -44,13 +44,13 @@
  • - <%= configFunctions.getProperty("aliases.lot") %> Statuses + <%= configFunctions.getConfigProperty("aliases.lot") %> Statuses
  • - <%= configFunctions.getProperty("aliases.lot") %> <%= configFunctions.getProperty("aliases.occupant") %> Types + <%= configFunctions.getConfigProperty("aliases.lot") %> <%= configFunctions.getConfigProperty("aliases.occupant") %> Types
  • @@ -117,11 +117,11 @@
    - ${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type + ${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type - ${escapeHTML(configFunctions.getProperty('aliases.map'))} + ${escapeHTML(configFunctions.getConfigProperty('aliases.map'))} - ${escapeHTML(configFunctions.getProperty('aliases.lot'))} Type + ${escapeHTML(configFunctions.getConfigProperty('aliases.lot'))} Type Status