@@ -55,7 +55,7 @@ const WORKERS_ANALYTICS_SEARCH_TOOL: Tool = {
5555 status : {
5656 type : 'string' ,
5757 description : 'Filter by status (e.g., "success", "error")' ,
58- }
58+ } ,
5959 } ,
6060 required : [ 'accountId' ] ,
6161 } ,
@@ -64,16 +64,16 @@ const WORKERS_ANALYTICS_SEARCH_TOOL: Tool = {
6464export const ANALYTICS_TOOLS = [ ANALYTICS_GET_TOOL , WORKERS_ANALYTICS_SEARCH_TOOL ]
6565
6666interface GraphQLResponse {
67- data ?: any ;
67+ data ?: any
6868 errors ?: Array < {
69- message : string ;
69+ message : string
7070 locations ?: Array < {
71- line : number ;
72- column : number ;
73- } > ;
74- path ?: string [ ] ;
75- extensions ?: Record < string , any > ;
76- } > ;
71+ line : number
72+ column : number
73+ } >
74+ path ?: string [ ]
75+ extensions ?: Record < string , any >
76+ } >
7777}
7878
7979export const ANALYTICS_HANDLERS : ToolHandlers = {
@@ -125,24 +125,24 @@ export const ANALYTICS_HANDLERS: ToolHandlers = {
125125 throw new Error ( `Analytics API error: ${ await analyticsResponse . text ( ) } ` )
126126 }
127127
128- const analyticsData = await analyticsResponse . json ( ) as GraphQLResponse
129-
128+ const analyticsData = ( await analyticsResponse . json ( ) ) as GraphQLResponse
129+
130130 // Check for GraphQL errors
131131 if ( analyticsData . errors ) {
132132 throw new Error ( `GraphQL error: ${ JSON . stringify ( analyticsData . errors ) } ` )
133133 }
134-
134+
135135 return {
136136 content : [
137137 {
138138 type : 'text' ,
139139 text : JSON . stringify ( analyticsData , null , 2 ) ,
140140 } ,
141141 ] ,
142- metadata : { }
142+ metadata : { } ,
143143 }
144144 } ,
145-
145+
146146 workers_analytics_search : async ( request ) => {
147147 const { accountId, scriptName, startTime, endTime, limit, status } = request . params . arguments as {
148148 accountId : string
@@ -152,31 +152,31 @@ export const ANALYTICS_HANDLERS: ToolHandlers = {
152152 limit ?: number
153153 status ?: string
154154 }
155-
155+
156156 // Set default time range if not provided (last 24 hours)
157157 const now = new Date ( )
158158 const defaultEndTime = now . toISOString ( )
159159 const defaultStartTime = new Date ( now . getTime ( ) - 24 * 60 * 60 * 1000 ) . toISOString ( )
160-
160+
161161 const datetimeStart = startTime || defaultStartTime
162162 const datetimeEnd = endTime || defaultEndTime
163163 const resultLimit = limit || 100
164-
164+
165165 // Build filter object for the GraphQL query
166166 const filter : Record < string , any > = {
167167 datetime_geq : datetimeStart ,
168- datetime_leq : datetimeEnd
168+ datetime_leq : datetimeEnd ,
169169 }
170-
170+
171171 // Add optional filters if provided
172172 if ( scriptName ) {
173173 filter . scriptName = scriptName
174174 }
175-
175+
176176 if ( status ) {
177177 filter . status = status
178178 }
179-
179+
180180 // Construct the GraphQL query
181181 const graphqlQuery = {
182182 query : `
@@ -206,8 +206,8 @@ export const ANALYTICS_HANDLERS: ToolHandlers = {
206206 variables : {
207207 accountTag : accountId ,
208208 limit : resultLimit ,
209- filter : filter
210- }
209+ filter : filter ,
210+ } ,
211211 }
212212
213213 try {
@@ -224,13 +224,13 @@ export const ANALYTICS_HANDLERS: ToolHandlers = {
224224 throw new Error ( `Workers Analytics API error: ${ await analyticsResponse . text ( ) } ` )
225225 }
226226
227- const analyticsData = await analyticsResponse . json ( ) as GraphQLResponse
228-
227+ const analyticsData = ( await analyticsResponse . json ( ) ) as GraphQLResponse
228+
229229 // Check for GraphQL errors
230230 if ( analyticsData . errors ) {
231231 throw new Error ( `GraphQL error: ${ JSON . stringify ( analyticsData . errors ) } ` )
232232 }
233-
233+
234234 return {
235235 toolResult : {
236236 content : [
0 commit comments