diff --git a/cypress/e2e/01-admin/configTables.cy.ts b/cypress/e2e/01-admin/configTables.cy.ts index f626963e..6ea0ce4b 100644 --- a/cypress/e2e/01-admin/configTables.cy.ts +++ b/cypress/e2e/01-admin/configTables.cy.ts @@ -1,7 +1,4 @@ -/* eslint-disable unicorn/filename-case, promise/catch-or-return, promise/always-return */ - import { testAdmin } from '../../../test/_globals.js' - import { logout, login } from '../../support/index.js' describe('Admin - Config Table Management', () => { diff --git a/cypress/e2e/02-update/maps.cy.js b/cypress/e2e/02-update/maps.cy.js index ac9773f2..23ee6876 100644 --- a/cypress/e2e/02-update/maps.cy.js +++ b/cypress/e2e/02-update/maps.cy.js @@ -1,6 +1,6 @@ +import * as configFunctions from '../../../helpers/functions.config.js'; import { testUpdate } from '../../../test/_globals.js'; import { logout, login } from '../../support/index.js'; -import * as configFunctions from '../../../helpers/functions.config.js'; describe('Update - Maps', () => { beforeEach('Loads page', () => { logout(); diff --git a/cypress/e2e/02-update/maps.cy.ts b/cypress/e2e/02-update/maps.cy.ts index 202e4bbc..a4cf0fb1 100644 --- a/cypress/e2e/02-update/maps.cy.ts +++ b/cypress/e2e/02-update/maps.cy.ts @@ -1,12 +1,10 @@ +// eslint-disable-next-line eslint-comments/disable-enable-pair /* eslint-disable @typescript-eslint/no-non-null-assertion */ -import { testUpdate } from '../../../test/_globals.js' - -import { logout, login } from '../../support/index.js' - import * as configFunctions from '../../../helpers/functions.config.js' - -import type * as recordTypes from '../../../types/recordTypes' +import { testUpdate } from '../../../test/_globals.js' +import type { MapRecord } from '../../../types/recordTypes.js' +import { logout, login } from '../../support/index.js' describe('Update - Maps', () => { beforeEach('Loads page', () => { @@ -33,7 +31,7 @@ describe('Update - Maps', () => { cy.log('Populate the fields') // eslint-disable-next-line promise/catch-or-return, promise/always-return - cy.fixture('map.json').then((mapJSON: recordTypes.Map) => { + cy.fixture('map.json').then((mapJSON: MapRecord) => { cy.get("input[name='mapName']").clear().type(mapJSON.mapName!) cy.get("textarea[name='mapDescription']") .clear() @@ -77,7 +75,7 @@ describe('Update - Maps', () => { .should('contain', '/edit') // eslint-disable-next-line promise/catch-or-return, promise/always-return - cy.fixture('map.json').then((mapJSON: recordTypes.Map) => { + cy.fixture('map.json').then((mapJSON: MapRecord) => { cy.get("input[name='mapName']").should('have.value', mapJSON.mapName) cy.get("textarea[name='mapDescription']").should( 'have.value', diff --git a/handlers/lots-get/edit.js b/handlers/lots-get/edit.js index b63baf3c..d58aeb88 100644 --- a/handlers/lots-get/edit.js +++ b/handlers/lots-get/edit.js @@ -1,7 +1,7 @@ +import * as cacheFunctions from '../../helpers/functions.cache.js'; import * as configFunctions from '../../helpers/functions.config.js'; import { getLot } from '../../helpers/lotOccupancyDB/getLot.js'; import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'; -import * as cacheFunctions from '../../helpers/functions.cache.js'; export async function handler(request, response) { const lot = await getLot(request.params.lotId); if (lot === undefined) { diff --git a/handlers/lots-get/edit.ts b/handlers/lots-get/edit.ts index d5ee2c91..343a346d 100644 --- a/handlers/lots-get/edit.ts +++ b/handlers/lots-get/edit.ts @@ -1,10 +1,9 @@ import type { Request, Response } from 'express' +import * as cacheFunctions from '../../helpers/functions.cache.js' import * as configFunctions from '../../helpers/functions.config.js' - import { getLot } from '../../helpers/lotOccupancyDB/getLot.js' import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' -import * as cacheFunctions from '../../helpers/functions.cache.js' export async function handler( request: Request, diff --git a/handlers/lots-get/new.js b/handlers/lots-get/new.js index c1de9a88..11397b92 100644 --- a/handlers/lots-get/new.js +++ b/handlers/lots-get/new.js @@ -1,6 +1,6 @@ +import * as cacheFunctions from '../../helpers/functions.cache.js'; import * as configFunctions from '../../helpers/functions.config.js'; import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'; -import * as cacheFunctions from '../../helpers/functions.cache.js'; export async function handler(request, response) { const lot = { lotId: -1, diff --git a/handlers/lots-get/new.ts b/handlers/lots-get/new.ts index fdf11d49..5b820cb2 100644 --- a/handlers/lots-get/new.ts +++ b/handlers/lots-get/new.ts @@ -1,17 +1,15 @@ import type { Request, Response } from 'express' -import * as configFunctions from '../../helpers/functions.config.js' - -import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' import * as cacheFunctions from '../../helpers/functions.cache.js' - -import type * as recordTypes from '../../types/recordTypes' +import * as configFunctions from '../../helpers/functions.config.js' +import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' +import type { Lot } from '../../types/recordTypes.js' export async function handler( request: Request, response: Response ): Promise { - const lot: recordTypes.Lot = { + const lot: Lot = { lotId: -1, lotOccupancies: [] } diff --git a/handlers/lots-get/next.ts b/handlers/lots-get/next.ts index 97b871b7..0ff067a3 100644 --- a/handlers/lots-get/next.ts +++ b/handlers/lots-get/next.ts @@ -1,7 +1,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getNextLotId } from '../../helpers/functions.lots.js' export async function handler( diff --git a/handlers/lots-get/previous.ts b/handlers/lots-get/previous.ts index 6c16b65e..45ffb669 100644 --- a/handlers/lots-get/previous.ts +++ b/handlers/lots-get/previous.ts @@ -1,7 +1,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getPreviousLotId } from '../../helpers/functions.lots.js' export async function handler( diff --git a/handlers/lots-get/search.js b/handlers/lots-get/search.js index 27a1def4..61b61188 100644 --- a/handlers/lots-get/search.js +++ b/handlers/lots-get/search.js @@ -1,6 +1,6 @@ +import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js'; import * as configFunctions from '../../helpers/functions.config.js'; import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js'; -import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js'; export async function handler(request, response) { const maps = await getMaps(); const lotTypes = await getLotTypes(); diff --git a/handlers/lots-get/search.ts b/handlers/lots-get/search.ts index 44747af0..bcc63ff3 100644 --- a/handlers/lots-get/search.ts +++ b/handlers/lots-get/search.ts @@ -1,10 +1,8 @@ import type { Request, Response } from 'express' -import * as configFunctions from '../../helpers/functions.config.js' - -import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' - import { getLotTypes, getLotStatuses } from '../../helpers/functions.cache.js' +import * as configFunctions from '../../helpers/functions.config.js' +import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' export async function handler( request: Request, diff --git a/handlers/lots-get/view.ts b/handlers/lots-get/view.ts index 3bfa9859..2fb20bb9 100644 --- a/handlers/lots-get/view.ts +++ b/handlers/lots-get/view.ts @@ -2,7 +2,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' import { getNextLotId, getPreviousLotId } from '../../helpers/functions.lots.js' - import { getLot } from '../../helpers/lotOccupancyDB/getLot.js' export async function handler( diff --git a/handlers/maps-get/edit.js b/handlers/maps-get/edit.js index 17b8346d..be5e1f38 100644 --- a/handlers/maps-get/edit.js +++ b/handlers/maps-get/edit.js @@ -1,8 +1,8 @@ import * as configFunctions from '../../helpers/functions.config.js'; -import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'; import { getMapSVGs } from '../../helpers/functions.map.js'; -import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'; import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js'; +import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'; +import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'; export async function handler(request, response) { const map = await getMap(request.params.mapId); if (map === undefined) { diff --git a/handlers/maps-get/edit.ts b/handlers/maps-get/edit.ts index c67adb96..ea7f6055 100644 --- a/handlers/maps-get/edit.ts +++ b/handlers/maps-get/edit.ts @@ -1,12 +1,10 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - -import { getMap } from '../../helpers/lotOccupancyDB/getMap.js' - import { getMapSVGs } from '../../helpers/functions.map.js' -import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js' import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js' +import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js' +import { getMap } from '../../helpers/lotOccupancyDB/getMap.js' export async function handler( request: Request, diff --git a/handlers/maps-get/new.ts b/handlers/maps-get/new.ts index 64c84ea7..237b26c2 100644 --- a/handlers/maps-get/new.ts +++ b/handlers/maps-get/new.ts @@ -1,16 +1,14 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getMapSVGs } from '../../helpers/functions.map.js' - -import * as recordTypes from '../../types/recordTypes' +import type { MapRecord } from '../../types/recordTypes.js' export async function handler( _request: Request, response: Response ): Promise { - const map: recordTypes.Map = { + const map: MapRecord = { mapCity: configFunctions.getProperty('settings.map.mapCityDefault'), mapProvince: configFunctions.getProperty('settings.map.mapProvinceDefault') } diff --git a/handlers/maps-get/next.ts b/handlers/maps-get/next.ts index 45f83ab2..7b03d2a1 100644 --- a/handlers/maps-get/next.ts +++ b/handlers/maps-get/next.ts @@ -1,7 +1,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getNextMapId } from '../../helpers/lotOccupancyDB/getNextMapId.js' export async function handler( diff --git a/handlers/maps-get/previous.ts b/handlers/maps-get/previous.ts index a8414c08..b179deff 100644 --- a/handlers/maps-get/previous.ts +++ b/handlers/maps-get/previous.ts @@ -1,7 +1,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getPreviousMapId } from '../../helpers/lotOccupancyDB/getPreviousMapId.js' export async function handler( diff --git a/handlers/maps-get/search.ts b/handlers/maps-get/search.ts index d1cb044e..8faee41f 100644 --- a/handlers/maps-get/search.ts +++ b/handlers/maps-get/search.ts @@ -1,7 +1,6 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - import { getMaps } from '../../helpers/lotOccupancyDB/getMaps.js' export async function handler(_request: Request, response: Response): Promise { diff --git a/handlers/maps-get/view.js b/handlers/maps-get/view.js index cf82491e..e9ceea93 100644 --- a/handlers/maps-get/view.js +++ b/handlers/maps-get/view.js @@ -1,7 +1,7 @@ import * as configFunctions from '../../helpers/functions.config.js'; -import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'; import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js'; import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js'; +import { getMap } from '../../helpers/lotOccupancyDB/getMap.js'; export async function handler(request, response) { const map = await getMap(request.params.mapId); if (map === undefined) { diff --git a/handlers/maps-get/view.ts b/handlers/maps-get/view.ts index 50c5c40c..f7032608 100644 --- a/handlers/maps-get/view.ts +++ b/handlers/maps-get/view.ts @@ -1,18 +1,20 @@ import type { Request, Response } from 'express' import * as configFunctions from '../../helpers/functions.config.js' - -import { getMap } from '../../helpers/lotOccupancyDB/getMap.js' import { getLotStatusSummary } from '../../helpers/lotOccupancyDB/getLotStatusSummary.js' import { getLotTypeSummary } from '../../helpers/lotOccupancyDB/getLotTypeSummary.js' +import { getMap } from '../../helpers/lotOccupancyDB/getMap.js' -export async function handler(request: Request, response: Response): Promise { +export async function handler( + request: Request, + response: Response +): Promise { const map = await getMap(request.params.mapId) if (map === undefined) { response.redirect( configFunctions.getProperty('reverseProxy.urlPrefix') + - '/maps/?error=mapIdNotFound' + '/maps/?error=mapIdNotFound' ) return } diff --git a/handlers/workOrders-get/edit.ts b/handlers/workOrders-get/edit.ts index 5f4711a6..a5c8f8c8 100644 --- a/handlers/workOrders-get/edit.ts +++ b/handlers/workOrders-get/edit.ts @@ -5,9 +5,7 @@ import { getWorkOrderMilestoneTypes, getWorkOrderTypes } from '../../helpers/functions.cache.js' - import * as configFunctions from '../../helpers/functions.config.js' - import { getWorkOrder } from '../../helpers/lotOccupancyDB/getWorkOrder.js' export async function handler( diff --git a/handlers/workOrders-get/new.ts b/handlers/workOrders-get/new.ts index 0c56f2ed..c137acc6 100644 --- a/handlers/workOrders-get/new.ts +++ b/handlers/workOrders-get/new.ts @@ -1,12 +1,8 @@ -import { - dateToInteger, - dateToString -} from '@cityssm/utils-datetime' +import { dateToInteger, dateToString } from '@cityssm/utils-datetime' import type { Request, Response } from 'express' import { getWorkOrderTypes } from '../../helpers/functions.cache.js' - -import type * as recordTypes from '../../types/recordTypes' +import type { WorkOrder } from '../../types/recordTypes.js' export async function handler( request: Request, @@ -14,7 +10,7 @@ export async function handler( ): Promise { const currentDate = new Date() - const workOrder: recordTypes.WorkOrder = { + const workOrder: WorkOrder = { workOrderOpenDate: dateToInteger(currentDate), workOrderOpenDateString: dateToString(currentDate) } diff --git a/helpers/lotOccupancyDB/getMap.d.ts b/helpers/lotOccupancyDB/getMap.d.ts index ddfd203a..6d1c3db1 100644 --- a/helpers/lotOccupancyDB/getMap.d.ts +++ b/helpers/lotOccupancyDB/getMap.d.ts @@ -1,3 +1,3 @@ -import type * as recordTypes from '../../types/recordTypes'; -export declare function getMap(mapId: number | string): Promise; +import type { MapRecord } from '../../types/recordTypes.js'; +export declare function getMap(mapId: number | string): Promise; export default getMap; diff --git a/helpers/lotOccupancyDB/getMap.ts b/helpers/lotOccupancyDB/getMap.ts index 77ca8732..5374e524 100644 --- a/helpers/lotOccupancyDB/getMap.ts +++ b/helpers/lotOccupancyDB/getMap.ts @@ -1,10 +1,10 @@ -import { acquireConnection } from './pool.js' +import type { MapRecord } from '../../types/recordTypes.js' -import type * as recordTypes from '../../types/recordTypes' +import { acquireConnection } from './pool.js' export async function getMap( mapId: number | string -): Promise { +): Promise { const database = await acquireConnection() const map = database @@ -29,7 +29,7 @@ export async function getMap( m.recordUpdate_userName, m.recordUpdate_timeMillis, m.recordDelete_userName, m.recordDelete_timeMillis` ) - .get(mapId) as recordTypes.Map | undefined + .get(mapId) as MapRecord | undefined database.release() diff --git a/helpers/lotOccupancyDB/getMaps.d.ts b/helpers/lotOccupancyDB/getMaps.d.ts index 7d20d624..285099a3 100644 --- a/helpers/lotOccupancyDB/getMaps.d.ts +++ b/helpers/lotOccupancyDB/getMaps.d.ts @@ -1,3 +1,3 @@ -import type * as recordTypes from '../../types/recordTypes'; -export declare function getMaps(): Promise; +import type { MapRecord } from '../../types/recordTypes.js'; +export declare function getMaps(): Promise; export default getMaps; diff --git a/helpers/lotOccupancyDB/getMaps.ts b/helpers/lotOccupancyDB/getMaps.ts index c73ac75c..27d6a4d2 100644 --- a/helpers/lotOccupancyDB/getMaps.ts +++ b/helpers/lotOccupancyDB/getMaps.ts @@ -1,8 +1,8 @@ +import type { MapRecord } from '../../types/recordTypes.js' + import { acquireConnection } from './pool.js' -import type * as recordTypes from '../../types/recordTypes' - -export async function getMaps(): Promise { +export async function getMaps(): Promise { const database = await acquireConnection() const maps = database @@ -20,7 +20,7 @@ export async function getMaps(): Promise { ) l on m.mapId = l.mapId where m.recordDelete_timeMillis is null order by m.mapName, m.mapId` ) - .all() as recordTypes.Map[] + .all() as MapRecord[] database.release() diff --git a/public-typescript/lotOccupancyEdit/lotOccupancyEdit.ts b/public-typescript/lotOccupancyEdit/lotOccupancyEdit.ts index 9b1891c4..0a920ace 100644 --- a/public-typescript/lotOccupancyEdit/lotOccupancyEdit.ts +++ b/public-typescript/lotOccupancyEdit/lotOccupancyEdit.ts @@ -661,7 +661,7 @@ declare const bulmaJS: BulmaJS '#lotCreate--mapId' ) as HTMLSelectElement - for (const map of exports.maps as recordTypes.Map[]) { + for (const map of exports.maps as recordTypes.MapRecord[]) { const optionElement = document.createElement('option') optionElement.value = map.mapId!.toString() optionElement.textContent = diff --git a/public-typescript/mapSearch.ts b/public-typescript/mapSearch.ts index 6673fe2c..973d4a43 100644 --- a/public-typescript/mapSearch.ts +++ b/public-typescript/mapSearch.ts @@ -9,7 +9,7 @@ declare const cityssm: cityssmGlobal ;(() => { const los = exports.los as globalTypes.LOS - const maps: recordTypes.Map[] = exports.maps + const maps: recordTypes.MapRecord[] = exports.maps const searchFilterElement = document.querySelector( '#searchFilter--map' diff --git a/temp/legacy.importFromCSV.ts b/temp/legacy.importFromCSV.ts index 5c797c39..b1e69a03 100644 --- a/temp/legacy.importFromCSV.ts +++ b/temp/legacy.importFromCSV.ts @@ -232,14 +232,14 @@ function purgeConfigTables(): void { console.timeEnd('purgeConfigTables') } -function getMapByMapDescription(mapDescription: string): recordTypes.Map { +function getMapByMapDescription(mapDescription: string): recordTypes.MapRecord { const database = sqlite(databasePath, { readonly: true }) - const map: recordTypes.Map = database + const map = database .prepare('select * from Maps where mapDescription = ?') - .get(mapDescription) + .get(mapDescription) as recordTypes.MapRecord database.close() @@ -274,9 +274,9 @@ const cemeteryToMapName = { WK: 'West Korah' } -const mapCache = new Map() +const mapCache = new Map() -async function getMap(dataRow: { cemetery: string }): Promise { +async function getMap(dataRow: { cemetery: string }): Promise { const mapCacheKey = dataRow.cemetery /* @@ -312,7 +312,7 @@ async function getMap(dataRow: { cemetery: string }): Promise { user ) - map = (await getMapFromDatabase(mapId)) as recordTypes.Map + map = (await getMapFromDatabase(mapId)) as recordTypes.MapRecord } mapCache.set(mapCacheKey, map) diff --git a/types/recordTypes.d.ts b/types/recordTypes.d.ts index 030115e4..d664d5ec 100644 --- a/types/recordTypes.d.ts +++ b/types/recordTypes.d.ts @@ -10,7 +10,7 @@ export interface Record { recordDelete_timeMillis?: number; recordDelete_dateString?: string; } -export interface Map extends Record { +export interface MapRecord extends Record { mapId?: number; mapName?: string; mapDescription?: string; @@ -55,7 +55,7 @@ export interface Lot extends Record { lotType?: string; mapId?: number; mapName?: string; - map?: Map; + map?: MapRecord; mapSVG?: string; mapKey?: string; lotLatitude?: number; diff --git a/types/recordTypes.ts b/types/recordTypes.ts index dba270fa..fe75aa4f 100644 --- a/types/recordTypes.ts +++ b/types/recordTypes.ts @@ -17,7 +17,7 @@ export interface Record { * LOT OCCUPANCY DB TYPES */ -export interface Map extends Record { +export interface MapRecord extends Record { mapId?: number mapName?: string mapDescription?: string @@ -74,7 +74,7 @@ export interface Lot extends Record { mapId?: number mapName?: string - map?: Map + map?: MapRecord mapSVG?: string mapKey?: string