@@ -294,6 +294,45 @@ async function retrieveResult(request: HttpRequest): Promise<HttpResponse> {
294294}
295295}
296296
297+ async function retrieveSample ( request :HttpRequest ) :Promise < HttpResponse > {
298+ try {
299+ const id = request . queryStringParameters . id ;
300+ const object = await s3 . getObject ( {
301+ Bucket :'phpstan-playground' ,
302+ Key :'api/results/' + id + '.json' ,
303+ } ) . promise ( ) ;
304+ const json = JSON . parse ( object . Body as string ) ;
305+ const strictRules = typeof json . config . strictRules !== 'undefined' ?json . config . strictRules :false ;
306+ const bleedingEdge = typeof json . config . bleedingEdge !== 'undefined' ?json . config . bleedingEdge :false ;
307+ const treatPhpDocTypesAsCertain = typeof json . config . treatPhpDocTypesAsCertain !== 'undefined' ?json . config . treatPhpDocTypesAsCertain :true ;
308+
309+ const bodyJson :any = {
310+ code :json . code ,
311+ errors :json . errors ,
312+ version :json . version ,
313+ level :json . level ,
314+ config :{
315+ strictRules,
316+ bleedingEdge,
317+ treatPhpDocTypesAsCertain,
318+ } ,
319+ } ;
320+ if ( typeof json . versionedErrors !== 'undefined' ) {
321+ bodyJson . versionedErrors = json . versionedErrors ;
322+ } else {
323+ bodyJson . versionedErrors = [ { errors :json . errors , title :'PHP 7.4' } ] ;
324+ }
325+ return Promise . resolve ( {
326+ statusCode :200 ,
327+ body :JSON . stringify ( bodyJson ) ,
328+ } ) ;
329+ } catch ( e ) {
330+ console . error ( e ) ;
331+ captureException ( e ) ;
332+ return Promise . resolve ( { statusCode :500 } ) ;
333+ }
334+ }
335+
297336async function retrieveLegacyResult ( request :HttpRequest ) :Promise < HttpResponse > {
298337try {
299338const id = request . queryStringParameters . id ;
@@ -343,5 +382,6 @@ const corsMiddleware = cors();
343382module . exports = {
344383analyseResult :middy ( analyseResult ) . use ( corsMiddleware ) ,
345384retrieveResult :middy ( retrieveResult ) . use ( corsMiddleware ) ,
385+ retrieveSample :middy ( retrieveSample ) . use ( corsMiddleware ) ,
346386retrieveLegacyResult :middy ( retrieveLegacyResult ) . use ( corsMiddleware ) ,
347387} ;