@@ -29,7 +29,7 @@ const CoercedDate = z.preprocess((arg) => {
2929  return  arg ; 
3030} ,  z . date ( ) . optional ( ) ) ; 
3131
32- const  SearchParamsSchema  =  z . object ( { 
32+ export   const  ApiRunListSearchParams  =  z . object ( { 
3333  "page[size]" : z . coerce . number ( ) . int ( ) . positive ( ) . min ( 1 ) . max ( 100 ) . optional ( ) , 
3434  "page[after]" : z . string ( ) . optional ( ) , 
3535  "page[before]" : z . string ( ) . optional ( ) , 
@@ -121,58 +121,44 @@ const SearchParamsSchema = z.object({
121121  "filter[createdAt][period]" : z . string ( ) . optional ( ) , 
122122} ) ; 
123123
124- type  SearchParamsSchema  =  z . infer < typeof  SearchParamsSchema > ; 
124+ type  ApiRunListSearchParams  =  z . infer < typeof  ApiRunListSearchParams > ; 
125125
126126export  class  ApiRunListPresenter  extends  BasePresenter  { 
127127  public  async  call ( 
128128    project : Project , 
129-     searchParams : URLSearchParams , 
129+     searchParams : ApiRunListSearchParams , 
130130    environment ?: RuntimeEnvironment 
131131  ) : Promise < ListRunResponse >  { 
132132    return  this . trace ( "call" ,  async  ( span )  =>  { 
133-       const  rawSearchParams  =  Object . fromEntries ( searchParams . entries ( ) ) ; 
134-       const  $searchParams  =  SearchParamsSchema . safeParse ( rawSearchParams ) ; 
135- 
136-       if  ( ! $searchParams . success )  { 
137-         logger . error ( "Invalid search params" ,  { 
138-           searchParams : rawSearchParams , 
139-           errors : $searchParams . error . errors , 
140-         } ) ; 
141- 
142-         throw  fromZodError ( $searchParams . error ) ; 
143-       } 
144- 
145-       logger . debug ( "Valid search params" ,  {  searchParams : $searchParams . data  } ) ; 
146- 
147133      const  options : RunListOptions  =  { 
148134        projectId : project . id , 
149135      } ; 
150136
151137      // pagination 
152-       if  ( $ searchParams. data [ "page[size]" ] )  { 
153-         options . pageSize  =  $ searchParams. data [ "page[size]" ] ; 
138+       if  ( searchParams [ "page[size]" ] )  { 
139+         options . pageSize  =  searchParams [ "page[size]" ] ; 
154140      } 
155141
156-       if  ( $ searchParams. data [ "page[after]" ] )  { 
157-         options . cursor  =  $ searchParams. data [ "page[after]" ] ; 
142+       if  ( searchParams [ "page[after]" ] )  { 
143+         options . cursor  =  searchParams [ "page[after]" ] ; 
158144        options . direction  =  "forward" ; 
159145      } 
160146
161-       if  ( $ searchParams. data [ "page[before]" ] )  { 
162-         options . cursor  =  $ searchParams. data [ "page[before]" ] ; 
147+       if  ( searchParams [ "page[before]" ] )  { 
148+         options . cursor  =  searchParams [ "page[before]" ] ; 
163149        options . direction  =  "backward" ; 
164150      } 
165151
166152      // filters 
167153      if  ( environment )  { 
168154        options . environments  =  [ environment . id ] ; 
169155      }  else  { 
170-         if  ( $ searchParams. data [ "filter[env]" ] )  { 
156+         if  ( searchParams [ "filter[env]" ] )  { 
171157          const  environments  =  await  this . _prisma . runtimeEnvironment . findMany ( { 
172158            where : { 
173159              projectId : project . id , 
174160              slug : { 
175-                 in : $ searchParams. data [ "filter[env]" ] , 
161+                 in : searchParams [ "filter[env]" ] , 
176162              } , 
177163            } , 
178164          } ) ; 
@@ -181,46 +167,46 @@ export class ApiRunListPresenter extends BasePresenter {
181167        } 
182168      } 
183169
184-       if  ( $ searchParams. data [ "filter[status]" ] )  { 
185-         options . statuses  =  $ searchParams. data [ "filter[status]" ] . flatMap ( ( status )  => 
170+       if  ( searchParams [ "filter[status]" ] )  { 
171+         options . statuses  =  searchParams [ "filter[status]" ] . flatMap ( ( status )  => 
186172          ApiRunListPresenter . apiStatusToRunStatuses ( status ) 
187173        ) ; 
188174      } 
189175
190-       if  ( $ searchParams. data [ "filter[taskIdentifier]" ] )  { 
191-         options . tasks  =  $ searchParams. data [ "filter[taskIdentifier]" ] ; 
176+       if  ( searchParams [ "filter[taskIdentifier]" ] )  { 
177+         options . tasks  =  searchParams [ "filter[taskIdentifier]" ] ; 
192178      } 
193179
194-       if  ( $ searchParams. data [ "filter[version]" ] )  { 
195-         options . versions  =  $ searchParams. data [ "filter[version]" ] ; 
180+       if  ( searchParams [ "filter[version]" ] )  { 
181+         options . versions  =  searchParams [ "filter[version]" ] ; 
196182      } 
197183
198-       if  ( $ searchParams. data [ "filter[tag]" ] )  { 
199-         options . tags  =  $ searchParams. data [ "filter[tag]" ] ; 
184+       if  ( searchParams [ "filter[tag]" ] )  { 
185+         options . tags  =  searchParams [ "filter[tag]" ] ; 
200186      } 
201187
202-       if  ( $ searchParams. data [ "filter[bulkAction]" ] )  { 
203-         options . bulkId  =  $ searchParams. data [ "filter[bulkAction]" ] ; 
188+       if  ( searchParams [ "filter[bulkAction]" ] )  { 
189+         options . bulkId  =  searchParams [ "filter[bulkAction]" ] ; 
204190      } 
205191
206-       if  ( $ searchParams. data [ "filter[schedule]" ] )  { 
207-         options . scheduleId  =  $ searchParams. data [ "filter[schedule]" ] ; 
192+       if  ( searchParams [ "filter[schedule]" ] )  { 
193+         options . scheduleId  =  searchParams [ "filter[schedule]" ] ; 
208194      } 
209195
210-       if  ( $ searchParams. data [ "filter[createdAt][from]" ] )  { 
211-         options . from  =  $ searchParams. data [ "filter[createdAt][from]" ] . getTime ( ) ; 
196+       if  ( searchParams [ "filter[createdAt][from]" ] )  { 
197+         options . from  =  searchParams [ "filter[createdAt][from]" ] . getTime ( ) ; 
212198      } 
213199
214-       if  ( $ searchParams. data [ "filter[createdAt][to]" ] )  { 
215-         options . to  =  $ searchParams. data [ "filter[createdAt][to]" ] . getTime ( ) ; 
200+       if  ( searchParams [ "filter[createdAt][to]" ] )  { 
201+         options . to  =  searchParams [ "filter[createdAt][to]" ] . getTime ( ) ; 
216202      } 
217203
218-       if  ( $ searchParams. data [ "filter[createdAt][period]" ] )  { 
219-         options . period  =  $ searchParams. data [ "filter[createdAt][period]" ] ; 
204+       if  ( searchParams [ "filter[createdAt][period]" ] )  { 
205+         options . period  =  searchParams [ "filter[createdAt][period]" ] ; 
220206      } 
221207
222-       if  ( typeof  $ searchParams. data [ "filter[isTest]" ]  ===  "boolean" )  { 
223-         options . isTest  =  $ searchParams. data [ "filter[isTest]" ] ; 
208+       if  ( typeof  searchParams [ "filter[isTest]" ]  ===  "boolean" )  { 
209+         options . isTest  =  searchParams [ "filter[isTest]" ] ; 
224210      } 
225211
226212      const  presenter  =  new  RunListPresenter ( ) ; 
0 commit comments