11/* eslint-disable max-lines */
2+ import type { AgnosticRouteObject } from '@remix-run/router' ;
3+ import { isDeferredData , isRouteErrorResponse } from '@remix-run/router' ;
4+ import type {
5+ ActionFunction ,
6+ ActionFunctionArgs ,
7+ AppLoadContext ,
8+ CreateRequestHandlerFunction ,
9+ EntryContext ,
10+ HandleDocumentRequestFunction ,
11+ LoaderFunction ,
12+ LoaderFunctionArgs ,
13+ RequestHandler ,
14+ ServerBuild ,
15+ } from '@remix-run/server-runtime' ;
216import type { RequestEventData , Span , TransactionSource , WrappedFunction } from '@sentry/core' ;
317import {
418 continueTrace ,
@@ -22,23 +36,15 @@ import {
2236} from '@sentry/core' ;
2337import { DEBUG_BUILD } from '../utils/debug-build' ;
2438import { createRoutes , getTransactionName } from '../utils/utils' ;
25- import { extractData , isDeferredData , isResponse , isRouteErrorResponse , json } from '../utils/vendor/response' ;
26- import type {
27- AppData ,
28- AppLoadContext ,
29- CreateRequestHandlerFunction ,
30- DataFunction ,
31- DataFunctionArgs ,
32- EntryContext ,
33- HandleDocumentRequestFunction ,
34- RemixRequest ,
35- RequestHandler ,
36- ServerBuild ,
37- ServerRoute ,
38- ServerRouteManifest ,
39- } from '../utils/vendor/types' ;
39+ import { extractData , isResponse , json } from '../utils/vendor/response' ;
4040import { captureRemixServerException , errorHandleDataFunction , errorHandleDocumentRequestFunction } from './errors' ;
4141
42+ type AppData = unknown ;
43+ type RemixRequest = Parameters < RequestHandler > [ 0 ] ;
44+ type ServerRouteManifest = ServerBuild [ 'routes' ] ;
45+ type DataFunction = LoaderFunction | ActionFunction ;
46+ type DataFunctionArgs = LoaderFunctionArgs | ActionFunctionArgs ;
47+
4248const redirectStatusCodes = new Set ( [ 301 , 302 , 303 , 307 , 308 ] ) ;
4349function isRedirectResponse ( response : Response ) : boolean {
4450 return redirectStatusCodes . has ( response . status ) ;
@@ -261,7 +267,7 @@ function wrapRequestHandler(
261267 return origRequestHandler . call ( this , request , loadContext ) ;
262268 }
263269
264- let resolvedRoutes : ServerRoute [ ] | undefined ;
270+ let resolvedRoutes : AgnosticRouteObject [ ] | undefined ;
265271
266272 if ( options ?. instrumentTracing ) {
267273 if ( typeof build === 'function' ) {
@@ -428,7 +434,7 @@ export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?:
428434 function ( origCreateRequestHandler : CreateRequestHandlerFunction ) : CreateRequestHandlerFunction {
429435 return function (
430436 this : unknown ,
431- build : ServerBuild | ( ( ) => Promise < ServerBuild > ) ,
437+ build : ServerBuild | ( ( ) => ServerBuild | Promise < ServerBuild > ) ,
432438 ...args : unknown [ ]
433439 ) : RequestHandler {
434440 const newBuild = instrumentBuild ( build , options ) ;
0 commit comments