diff --git a/services/API-service/src/api/admin-area-dynamic-data/admin-area-dynamic-data.service.ts b/services/API-service/src/api/admin-area-dynamic-data/admin-area-dynamic-data.service.ts index e917a073c..d424227b2 100644 --- a/services/API-service/src/api/admin-area-dynamic-data/admin-area-dynamic-data.service.ts +++ b/services/API-service/src/api/admin-area-dynamic-data/admin-area-dynamic-data.service.ts @@ -17,6 +17,11 @@ import { HelperService } from '../../shared/helper.service'; import { EventAreaService } from '../admin-area/services/event-area.service'; import { DisasterTypeGeoServerMapper } from '../../scripts/disaster-type-geoserver-file.mapper'; +interface RasterData { + originalname: string; + buffer: Buffer; +} + @Injectable() export class AdminAreaDynamicDataService { @InjectRepository(AdminAreaDynamicDataEntity) @@ -232,9 +237,9 @@ export class AdminAreaDynamicDataService { const result = await this.adminAreaDynamicDataRepo .createQueryBuilder('dynamic') .where({ - indicator: indicator, - placeCode: placeCode, - leadTime: leadTime, + indicator, + placeCode, + leadTime, eventName: eventName === 'no-name' || !eventName ? IsNull() : eventName, }) .select(['dynamic.value AS value']) @@ -244,7 +249,7 @@ export class AdminAreaDynamicDataService { } public async postRaster( - data: any, + data: RasterData, disasterType: DisasterType, ): Promise { const subfolder = diff --git a/services/API-service/src/api/admin-area/admin-area.controller.ts b/services/API-service/src/api/admin-area/admin-area.controller.ts index 8146c0893..bd03cb3e1 100644 --- a/services/API-service/src/api/admin-area/admin-area.controller.ts +++ b/services/API-service/src/api/admin-area/admin-area.controller.ts @@ -69,7 +69,7 @@ export class AdminAreaController { type: [AdminAreaEntity], }) @Get('raw/:countryCodeISO3') - public async getAdminAreasRaw(@Param() params): Promise { + public async getAdminAreasRaw(@Param() params) { return await this.adminAreaService.getAdminAreasRaw(params.countryCodeISO3); } diff --git a/services/API-service/src/api/admin-area/admin-area.service.ts b/services/API-service/src/api/admin-area/admin-area.service.ts index 959f18ce8..f11ca8d4a 100644 --- a/services/API-service/src/api/admin-area/admin-area.service.ts +++ b/services/API-service/src/api/admin-area/admin-area.service.ts @@ -292,7 +292,7 @@ export class AdminAreaService { }); } - public async getAdminAreasRaw(countryCodeISO3): Promise { + public async getAdminAreasRaw(countryCodeISO3) { return await this.adminAreaRepository.find({ select: [ 'countryCodeISO3', diff --git a/services/API-service/src/api/eap-actions/eap-actions.controller.ts b/services/API-service/src/api/eap-actions/eap-actions.controller.ts index d2bb7d277..ae535b920 100644 --- a/services/API-service/src/api/eap-actions/eap-actions.controller.ts +++ b/services/API-service/src/api/eap-actions/eap-actions.controller.ts @@ -1,5 +1,5 @@ import { Controller, Post, Body, Get, UseGuards, Param } from '@nestjs/common'; -import { EapActionsService } from './eap-actions.service'; +import { EapAction, EapActionsService } from './eap-actions.service'; import { UserDecorator } from '../user/user.decorator'; import { ApiBearerAuth, @@ -70,7 +70,7 @@ export class EapActionsController { @Post('check-external/:countryCodeISO3/:disasterType') public async checkActionExternally( @Param() params, - @Body() eapActions: any, + @Body() eapActions: EapAction[], ): Promise { return await this.eapActionsService.checkActionExternally( params.countryCodeISO3, diff --git a/services/API-service/src/api/eap-actions/eap-actions.service.ts b/services/API-service/src/api/eap-actions/eap-actions.service.ts index 3d44879fe..f3f43c1ee 100644 --- a/services/API-service/src/api/eap-actions/eap-actions.service.ts +++ b/services/API-service/src/api/eap-actions/eap-actions.service.ts @@ -11,6 +11,11 @@ import { AdminAreaEntity } from '../admin-area/admin-area.entity'; import { AddEapActionsDto } from './dto/eap-action.dto'; import { DisasterType } from '../disaster/disaster-type.enum'; +export interface EapAction { + Early_action: string; + placeCode: string; +} + @Injectable() export class EapActionsService { @InjectRepository(UserEntity) @@ -110,9 +115,8 @@ export class EapActionsService { public async checkActionExternally( countryCodeISO3: string, disasterType: DisasterType, - eapActions, + eapActions: EapAction[], ): Promise { - console.log('eapAction: ', eapActions); const eapActionIds = eapActions['Early_action'].split(' '); const actionIds = await this.eapActionRepository.find({ where: { @@ -129,7 +133,7 @@ export class EapActionsService { const placeCode = eapActions['placeCode']; const adminArea = await this.adminAreaRepository.findOne({ select: ['id'], - where: { placeCode: placeCode }, + where: { placeCode }, }); // note: the below will not be able to distinguish between different open events (= typhoon only) @@ -223,7 +227,7 @@ export class EapActionsService { '(' + eapActionsStates.getQuery() + ')', 'status', 'action.id = status."actionCheckedId" AND status."placeCode" = :placeCode', - { placeCode: placeCode }, + { placeCode }, ) .setParameters(eapActionsStates.getParameters()) .leftJoin('action.areaOfFocus', 'area') diff --git a/services/API-service/src/api/event/event.controller.ts b/services/API-service/src/api/event/event.controller.ts index 6dd6bb368..539107eeb 100644 --- a/services/API-service/src/api/event/event.controller.ts +++ b/services/API-service/src/api/event/event.controller.ts @@ -263,7 +263,8 @@ export class EventController { ); } const bufferStream = new stream.PassThrough(); - bufferStream.end(Buffer.from(blob, 'binary')); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + bufferStream.end(Buffer.from(blob as any, 'binary')); response.writeHead(HttpStatus.OK, { 'Content-Type': 'image/png', }); diff --git a/services/API-service/src/api/event/event.service.ts b/services/API-service/src/api/event/event.service.ts index 9b203b0e9..48393be00 100644 --- a/services/API-service/src/api/event/event.service.ts +++ b/services/API-service/src/api/event/event.service.ts @@ -130,6 +130,7 @@ export class EventService { } private async populateEventsDetails( + // eslint-disable-next-line @typescript-eslint/no-explicit-any rawEvents: any[], countryCodeISO3: string, disasterType: DisasterType, @@ -1025,7 +1026,7 @@ export class EventService { countryCodeISO3: string, disasterType: DisasterType, eventName: string, - ): Promise { + ): Promise { const eventMapImageEntity = await this.eventMapImageRepository.findOne({ where: { countryCodeISO3: countryCodeISO3, diff --git a/services/API-service/src/api/glofas-station/glofas-station.controller.ts b/services/API-service/src/api/glofas-station/glofas-station.controller.ts index e6baa24a3..50c2d3b13 100644 --- a/services/API-service/src/api/glofas-station/glofas-station.controller.ts +++ b/services/API-service/src/api/glofas-station/glofas-station.controller.ts @@ -34,7 +34,7 @@ export class GlofasStationController { description: 'Glofas station locations and attributes for given country.', }) @Get(':countryCodeISO3') - public async getStationsByCountry(@Param() params): Promise { + public async getStationsByCountry(@Param() params) { return await this.glofasStationService.getStationsByCountry( params.countryCodeISO3, ); diff --git a/services/API-service/src/api/glofas-station/glofas-station.service.ts b/services/API-service/src/api/glofas-station/glofas-station.service.ts index 5489cf7d3..dd7f407cf 100644 --- a/services/API-service/src/api/glofas-station/glofas-station.service.ts +++ b/services/API-service/src/api/glofas-station/glofas-station.service.ts @@ -15,7 +15,7 @@ export class GlofasStationService { public constructor(private readonly pointDataService: PointDataService) {} - public async getStationsByCountry(countryCodeISO3: string): Promise { + public async getStationsByCountry(countryCodeISO3: string) { const stations = await this.pointDataService.getPointDataByCountry( PointDataEnum.glofasStations, countryCodeISO3, diff --git a/services/API-service/src/api/lines-data/lines-data.service.ts b/services/API-service/src/api/lines-data/lines-data.service.ts index 864e46c1d..f52ee6375 100644 --- a/services/API-service/src/api/lines-data/lines-data.service.ts +++ b/services/API-service/src/api/lines-data/lines-data.service.ts @@ -17,7 +17,7 @@ export class LinesDataService { public constructor(private readonly helperService: HelperService) {} - private getDtoPerLinesDataCategory(linesDataCategory: LinesDataEnum): any { + private getDtoPerLinesDataCategory(linesDataCategory: LinesDataEnum) { switch (linesDataCategory) { case LinesDataEnum.roads: return new RoadDto(); @@ -34,6 +34,7 @@ export class LinesDataService { public async uploadJson( linesDataCategory: LinesDataEnum, countryCodeISO3: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any validatedObjArray: any, deleteExisting = true, ) { diff --git a/services/API-service/src/api/notification/dto/content-trigger-email.dto.ts b/services/API-service/src/api/notification/dto/content-trigger-email.dto.ts index 8d802b036..44bc7b412 100644 --- a/services/API-service/src/api/notification/dto/content-trigger-email.dto.ts +++ b/services/API-service/src/api/notification/dto/content-trigger-email.dto.ts @@ -10,7 +10,7 @@ export class ContentEventEmail { public indicatorMetadata: IndicatorMetadataEntity; public linkEapSop: string; public dataPerEvent: NotificationDataPerEventDto[]; - public mapImageData: any[]; + public mapImageData: unknown[]; public defaultAdminLevel: number; public defaultAdminAreaLabel: AdminAreaLabel; public country: CountryEntity; // Ensure that is has the following relations 'disasterTypes', 'notificationInfo','countryDisasterSettings','countryDisasterSettings.activeLeadTimes', diff --git a/services/API-service/src/api/notification/whatsapp/auth.middlewareTwilio.ts b/services/API-service/src/api/notification/whatsapp/auth.middlewareTwilio.ts index 7f6ea7ea5..fbd5bdf68 100644 --- a/services/API-service/src/api/notification/whatsapp/auth.middlewareTwilio.ts +++ b/services/API-service/src/api/notification/whatsapp/auth.middlewareTwilio.ts @@ -8,11 +8,7 @@ import { twilio } from './twilio.client'; export class AuthMiddlewareTwilio implements NestMiddleware { public constructor() {} - public async use( - req: Request, - res: Response, - next: NextFunction, - ): Promise { + public async use(req: Request, res: Response, next: NextFunction) { const twilioSignature = req.headers['x-twilio-signature']; if (DEBUG) { diff --git a/services/API-service/src/api/notification/whatsapp/whatsapp.service.ts b/services/API-service/src/api/notification/whatsapp/whatsapp.service.ts index b71ea3f2d..3359046c2 100644 --- a/services/API-service/src/api/notification/whatsapp/whatsapp.service.ts +++ b/services/API-service/src/api/notification/whatsapp/whatsapp.service.ts @@ -49,7 +49,7 @@ export class WhatsappService { message: string, recipientPhoneNr: string, mediaUrl?: string, - ): Promise { + ) { const payload = { body: message, messagingServiceSid: process.env.TWILIO_MESSAGING_SID, @@ -256,8 +256,7 @@ export class WhatsappService { events, disasterType.disasterType, ); - await this.sendWhatsapp(noTriggerMessage, fromNumber); - return; + return await this.sendWhatsapp(noTriggerMessage, fromNumber); } for (const event of sortedEvents) { diff --git a/services/API-service/src/api/point-data/point-data.controller.ts b/services/API-service/src/api/point-data/point-data.controller.ts index aa7e0b42b..aa51421b1 100644 --- a/services/API-service/src/api/point-data/point-data.controller.ts +++ b/services/API-service/src/api/point-data/point-data.controller.ts @@ -25,7 +25,7 @@ import { Roles } from '../../roles.decorator'; import { RolesGuard } from '../../roles.guard'; import { GeoJson } from '../../shared/geo.model'; import { UserRole } from '../user/user-role.enum'; -import { PointDataService } from './point-data.service'; +import { CommunityNotification, PointDataService } from './point-data.service'; import { UploadAssetExposureStatusDto, UploadDynamicPointDataDto, @@ -101,7 +101,7 @@ export class PointDataController { @Post('community-notification/:countryCodeISO3') public async uploadCommunityNotification( @Param() params, - @Body() communityNotification: any, + @Body() communityNotification: CommunityNotification, ): Promise { return await this.pointDataService.uploadCommunityNotification( params.countryCodeISO3, diff --git a/services/API-service/src/api/point-data/point-data.service.ts b/services/API-service/src/api/point-data/point-data.service.ts index ae14ec8a7..d08c16421 100644 --- a/services/API-service/src/api/point-data/point-data.service.ts +++ b/services/API-service/src/api/point-data/point-data.service.ts @@ -22,6 +22,16 @@ import { GaugeDto } from './dto/upload-gauge.dto'; import { DynamicPointDataEntity } from './dynamic-point-data.entity'; import { GlofasStationDto } from './dto/upload-glofas-station.dto'; +export interface CommunityNotification { + nameVolunteer: string; + nameVillage: string; + disasterType: string; + description: string; + end: Date; + _attachments: [{ download_url: string }]; + _geolocation: [number, number]; +} + @Injectable() export class PointDataService { @InjectRepository(PointDataEntity) @@ -89,7 +99,7 @@ export class PointDataService { return this.helperService.toGeojson(pointData); } - private getDtoPerPointDataCategory(pointDataCategory: PointDataEnum): any { + private getDtoPerPointDataCategory(pointDataCategory: PointDataEnum) { switch (pointDataCategory) { case PointDataEnum.dams: return new DamSiteDto(); @@ -120,6 +130,7 @@ export class PointDataService { public async uploadJson( pointDataCategory: PointDataEnum, countryCodeISO3: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any validatedObjArray: any, deleteExisting = true, ) { @@ -170,7 +181,7 @@ export class PointDataService { csvArray, ): Promise { const errors = []; - const validatatedArray = []; + const validatedArray = []; for (const [i, row] of csvArray.entries()) { const dto = this.getDtoPerPointDataCategory(pointDataCategory); for (const attribute in dto) { @@ -185,12 +196,12 @@ export class PointDataService { const errorObj = { lineNumber: i + 1, validationError: result }; errors.push(errorObj); } - validatatedArray.push(dto); + validatedArray.push(dto); } if (errors.length > 0) { throw new HttpException(errors, HttpStatus.BAD_REQUEST); } - return validatatedArray; + return validatedArray; } public async dismissCommunityNotification(pointDataId: string) { @@ -209,7 +220,7 @@ export class PointDataService { public async uploadCommunityNotification( countryCodeISO3: string, - communityNotification: any, + communityNotification: CommunityNotification, ): Promise { const notification = new CommunityNotificationDto(); notification.nameVolunteer = communityNotification['nameVolunteer']; diff --git a/services/API-service/src/api/user/user.controller.ts b/services/API-service/src/api/user/user.controller.ts index aced6e8b4..cb29a5bf6 100644 --- a/services/API-service/src/api/user/user.controller.ts +++ b/services/API-service/src/api/user/user.controller.ts @@ -86,7 +86,7 @@ export class UserController { public async update( @UserDecorator('userId') loggedInUserId: string, @Body() userData: UpdatePasswordDto, - ): Promise { + ) { return this.userService.update(loggedInUserId, userData); } } diff --git a/services/API-service/src/roles.decorator.ts b/services/API-service/src/roles.decorator.ts index a57ffef79..ea6255c28 100644 --- a/services/API-service/src/roles.decorator.ts +++ b/services/API-service/src/roles.decorator.ts @@ -1,4 +1,4 @@ import { SetMetadata } from '@nestjs/common'; import { UserRole } from './api/user/user-role.enum'; -export const Roles = (...roles: UserRole[]): any => SetMetadata('roles', roles); +export const Roles = (...roles: UserRole[]) => SetMetadata('roles', roles); diff --git a/services/API-service/src/scripts/geoserver-sync.service.ts b/services/API-service/src/scripts/geoserver-sync.service.ts index ae32d844e..e032d52f1 100644 --- a/services/API-service/src/scripts/geoserver-sync.service.ts +++ b/services/API-service/src/scripts/geoserver-sync.service.ts @@ -9,7 +9,7 @@ import fs from 'fs'; const workspaceName = 'ibf-system'; -class RecourceNameObject { +class ResourceNameObject { resourceName: string; disasterType: DisasterType; countryCodeISO3: string; @@ -24,7 +24,7 @@ export class GeoserverSyncService { disasterType?: DisasterType, ): Promise { const countriesCopy = JSON.parse(JSON.stringify(countries)); - const filteredCountries = countriesCopy.filter((country: any) => { + const filteredCountries = countriesCopy.filter((country) => { return countryCodeISO3 ? country.countryCodeISO3 === countryCodeISO3 : true; @@ -32,7 +32,7 @@ export class GeoserverSyncService { // also filter by disaster type for (const country of filteredCountries) { const disasterSettings = country.countryDisasterSettings.filter( - (disasterSetting: any) => { + (disasterSetting) => { return disasterType ? disasterSetting.disasterType === disasterType : true; @@ -47,7 +47,7 @@ export class GeoserverSyncService { await this.syncLayers(geoserverResourceNameObjects); } - private async syncStores(expectedStoreNameObjects: RecourceNameObject[]) { + private async syncStores(expectedStoreNameObjects: ResourceNameObject[]) { const foundStoreNames = await this.getStoreNamesFromGeoserver( workspaceName, ); @@ -58,8 +58,9 @@ export class GeoserverSyncService { } private generateGeoserverResourceNames( + // eslint-disable-next-line @typescript-eslint/no-explicit-any filteredCountries: any[], - ): RecourceNameObject[] { + ): ResourceNameObject[] { const resourceNameObjects = []; for (const country of filteredCountries) { resourceNameObjects.push(...this.generateStoreNameForCountry(country)); @@ -67,7 +68,7 @@ export class GeoserverSyncService { return resourceNameObjects; } - private generateStoreNameForCountry(country: any): RecourceNameObject[] { + private generateStoreNameForCountry(country): ResourceNameObject[] { const resourceNameObjects = []; const countryCode = country.countryCodeISO3; for (const disasterSetting of country.countryDisasterSettings) { @@ -92,13 +93,13 @@ export class GeoserverSyncService { private async getStoreNamesFromGeoserver(workspaceName: string) { const data = await this.get(`workspaces/${workspaceName}/coveragestores`); const storeNames = data.coverageStores.coverageStore.map( - (store: any) => store.name, + (store) => store.name, ); return storeNames; } private async postStoreNamesToGeoserver( - resourceNameObjects: RecourceNameObject[], + resourceNameObjects: ResourceNameObject[], ) { for (const resourceNameObject of resourceNameObjects) { const subfolder = DisasterTypeGeoServerMapper.getSubfolderForDisasterType( @@ -135,7 +136,7 @@ export class GeoserverSyncService { } } - public async syncLayers(expectedLayerNames: RecourceNameObject[]) { + public async syncLayers(expectedLayerNames: ResourceNameObject[]) { const foundLayerNames = await this.getLayerNamesFromGeoserver( workspaceName, ); @@ -147,12 +148,12 @@ export class GeoserverSyncService { private async getLayerNamesFromGeoserver(workspaceName: string) { const data = await this.get(`workspaces/${workspaceName}/layers`); - const layerNames = data.layers.layer.map((layer: any) => layer.name); + const layerNames = data.layers.layer.map((layer) => layer.name); return layerNames; } private async postLayerNamesToGeoserver( - resourceNameObjects: RecourceNameObject[], + resourceNameObjects: ResourceNameObject[], ) { for (const resourceNameObject of resourceNameObjects) { const publishLayerUrl = `workspaces/${workspaceName}/coveragestores/${resourceNameObject.resourceName}/coverages`; @@ -182,7 +183,7 @@ export class GeoserverSyncService { } } - private async post(path: string, body: any) { + private async post(path: string, body: unknown) { const url = `${INTERNAL_GEOSERVER_API_URL}/${path}`; const headers = this.getHeaders(); const result = await firstValueFrom( @@ -191,7 +192,7 @@ export class GeoserverSyncService { return result.data; } - private async put(path: string, body: any) { + private async put(path: string, body: unknown) { const url = `${INTERNAL_GEOSERVER_API_URL}/${path}`; const headers = this.getHeaders(); const result = await firstValueFrom( diff --git a/services/API-service/src/scripts/mock.service.ts b/services/API-service/src/scripts/mock.service.ts index 4626a6555..dd6795844 100644 --- a/services/API-service/src/scripts/mock.service.ts +++ b/services/API-service/src/scripts/mock.service.ts @@ -68,7 +68,7 @@ export class MockService { await this.removeEvents(mockBody.countryCodeISO3, disasterType); } - const selectedCountry = countries.find((country): any => { + const selectedCountry = countries.find((country) => { if (mockBody.countryCodeISO3 === country.countryCodeISO3) { return country; } @@ -244,6 +244,7 @@ export class MockService { private getLeadTimesForNoTrigger( disasterType: DisasterType, + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry: any, ): LeadTime[] { // NOTE: this reflects agreements with pipelines that are in place. This is ugly, and should be refactored better. diff --git a/services/API-service/src/scripts/scripts.service.ts b/services/API-service/src/scripts/scripts.service.ts index 38c6547d8..daee18356 100644 --- a/services/API-service/src/scripts/scripts.service.ts +++ b/services/API-service/src/scripts/scripts.service.ts @@ -155,7 +155,7 @@ export class ScriptsService { await this.eventPlaceCodeRepo.remove(allCountryEvents); } - const selectedCountry = countries.find((country): any => { + const selectedCountry = countries.find((country) => { if (mockInput.countryCodeISO3 === country.countryCodeISO3) { return country; } @@ -407,6 +407,7 @@ export class ScriptsService { } private getLeadTimes( + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry: any, disasterType: DisasterType, eventNr: number, @@ -456,6 +457,7 @@ export class ScriptsService { typhoonScenario?: TyphoonScenario, eventRegion?: string, leadTime?: LeadTime, + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry?: any, date?: Date, triggered?: boolean, @@ -494,6 +496,7 @@ export class ScriptsService { } private filterLeadTimesPerDisasterType( + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry: any, leadTime: string, disasterType: DisasterType, @@ -552,6 +555,7 @@ export class ScriptsService { } private getDroughtLeadTime( + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry: any, leadTime: string, disasterType: DisasterType, @@ -582,6 +586,7 @@ export class ScriptsService { forecastSeasons, leadTime: string, date: Date, + // eslint-disable-next-line @typescript-eslint/no-explicit-any selectedCountry: any, ) { const { currentYear, currentUTCMonth, leadTimeMonthFirstDay } = @@ -650,7 +655,8 @@ export class ScriptsService { } private async mockAmount( - exposurePlacecodes: any, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + exposurePlaceCodes: any, exposureUnit: DynamicIndicator, triggered: boolean, disasterType: DisasterType, @@ -658,8 +664,8 @@ export class ScriptsService { activeLeadTime: LeadTime, date: Date, eventRegion?: string, - ): Promise { - let copyOfExposureUnit = JSON.parse(JSON.stringify(exposurePlacecodes)); + ) { + let copyOfExposureUnit = JSON.parse(JSON.stringify(exposurePlaceCodes)); if ( disasterType === DisasterType.Drought && selectedCountry.countryCodeISO3 !== 'ZWE' && // exclude ZWE drought from this rule @@ -718,9 +724,7 @@ export class ScriptsService { const month = leadTimeMonthFirstDay.getMonth() + 1; const triggeredAreas = droughtRegionAreas[droughtRegion].map( - (placeCode) => { - return { placeCode: placeCode, triggered: false }; - }, + (placeCode) => ({ placeCode, triggered: false }), ); for (const season of Object.values(forecastSeasonAreas[droughtRegion])) { const filteredSeason = season[this.rainMonthsKey].filter(