@@ -10,6 +10,11 @@ import axios from 'axios';
1010import { wrapper } from 'axios-cookiejar-support' ;
1111import * as cheerio from 'cheerio' ;
1212
13+ // Type for raw portal JSON data - using `any` is acceptable here since we're dealing with
14+ // dynamic external API responses that we don't control
15+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16+ type PortalApiResponse = any ;
17+
1318// Process the case search queue - responsible for finding caseId (status: 'found')
1419const processCaseSearch : SQSHandler = async ( event : SQSEvent ) => {
1520 console . log ( `Received ${ event . Records . length } case search messages` ) ;
@@ -570,7 +575,7 @@ async function fetchCaseSummary(caseId: string): Promise<CaseSummary | null> {
570575 } ) ;
571576
572577 // First, collect all raw data from endpoints
573- const rawData : Record < string , any > = { } ;
578+ const rawData : Record < string , PortalApiResponse > = { } ;
574579
575580 // Create an array of promises for all endpoint requests
576581 const endpointPromises = Object . entries ( caseEndpoints ) . map ( async ( [ key , endpoint ] ) => {
@@ -655,7 +660,7 @@ async function fetchCaseSummary(caseId: string): Promise<CaseSummary | null> {
655660 }
656661}
657662
658- function buildCaseSummary ( rawData : Record < string , any > ) : CaseSummary | null {
663+ function buildCaseSummary ( rawData : Record < string , PortalApiResponse > ) : CaseSummary | null {
659664 try {
660665 if ( ! rawData [ 'summary' ] || ! rawData [ 'charges' ] || ! rawData [ 'dispositionEvents' ] ) {
661666 console . error ( 'Missing required raw data for building case summary' ) ;
@@ -672,6 +677,7 @@ function buildCaseSummary(rawData: Record<string, any>): CaseSummary | null {
672677
673678 // Process charges
674679 const charges = rawData [ 'charges' ] [ 'Charges' ] || [ ] ;
680+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
675681 charges . forEach ( ( chargeData : any ) => {
676682 if ( ! chargeData ) return ;
677683
@@ -702,7 +708,12 @@ function buildCaseSummary(rawData: Record<string, any>): CaseSummary | null {
702708
703709 // Process dispositions and link them to charges
704710 const events = rawData [ 'dispositionEvents' ] [ 'Events' ] || [ ] ;
705- events . filter ( ( eventData : any ) => eventData && eventData [ 'Type' ] === 'CriminalDispositionEvent' )
711+ events
712+ . filter (
713+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
714+ ( eventData : any ) => eventData && eventData [ 'Type' ] === 'CriminalDispositionEvent'
715+ )
716+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
706717 . forEach ( ( eventData : any ) => {
707718 if ( ! eventData || ! eventData [ 'Event' ] ) return ;
708719
@@ -723,6 +734,7 @@ function buildCaseSummary(rawData: Record<string, any>): CaseSummary | null {
723734 ) . catch ( err => console . error ( 'Failed to log alert:' , err ) ) ;
724735 }
725736
737+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
726738 dispositions . forEach ( ( disp : any ) => {
727739 if ( ! disp ) return ;
728740
@@ -743,14 +755,14 @@ function buildCaseSummary(rawData: Record<string, any>): CaseSummary | null {
743755 const chargeId = disp [ 'ChargeID' ] ;
744756
745757 // Find the matching charge and add the disposition
746- if ( chargeId ) {
758+ if ( chargeId && typeof chargeId === 'string' ) {
747759 const charge = chargeMap . get ( chargeId ) ;
748760 if ( charge ) {
749761 charge . dispositions . push ( disposition ) ;
750762 }
751763 }
752764 } ) ;
753- } ) ;
765+ } ) ;
754766
755767 return caseSummary ;
756768 } catch ( error ) {
@@ -761,7 +773,7 @@ function buildCaseSummary(rawData: Record<string, any>): CaseSummary | null {
761773 'Error building case summary from raw data' ,
762774 error as Error ,
763775 {
764- caseId : rawData . summary ?. CaseSummaryHeader ?. CaseId || 'unknown'
776+ caseId : rawData [ ' summary' ] [ ' CaseSummaryHeader' ] [ ' CaseId' ] || 'unknown' ,
765777 }
766778 ) . catch ( err => console . error ( 'Failed to log alert:' , err ) ) ;
767779 return null ;
0 commit comments