@@ -26,6 +26,7 @@ import {
26
26
} from "./types" ;
27
27
import enhancedErrors from "./utils/guards-reasons" ;
28
28
29
+ // @internal
29
30
const createBox : CreateBox = ( event , context , callback ) =>
30
31
Object . seal ( {
31
32
state : { } ,
@@ -41,6 +42,7 @@ const createBox: CreateBox = (event, context, callback) =>
41
42
multiValueHeaders : undefined ,
42
43
} ) ;
43
44
45
+ // @internal
44
46
const errorResponse = flow (
45
47
R . over (
46
48
toBodyErrorResponseLens ,
@@ -61,6 +63,7 @@ const errorResponse = flow(
61
63
)
62
64
) ;
63
65
66
+ // @internal
64
67
const successResponse = flow (
65
68
R . over ( toIsEncodedResponseLens , R . identity ) ,
66
69
R . over ( toStatusResponseLens , R . unless ( R . is ( Number ) , R . always ( 200 ) ) ) ,
@@ -70,6 +73,7 @@ const successResponse = flow(
70
73
)
71
74
) ;
72
75
76
+ // @internal
73
77
const returnResponse : ResponseMiddleware = async ( box ) =>
74
78
flow (
75
79
R . set ( responseLens , { } ) ,
@@ -84,6 +88,7 @@ const returnResponse: ResponseMiddleware = async (box) =>
84
88
R . prop ( "response" )
85
89
) ( await box ) as Promise < APIGatewayProxyStructuredResultV2 > ;
86
90
91
+ // @internal
87
92
const validateBoxState = ( middleware : FlowMiddleware ) =>
88
93
R . unless (
89
94
R . is ( Object ) ,
@@ -97,6 +102,7 @@ const validateBoxState = (middleware: FlowMiddleware) =>
97
102
)
98
103
) ;
99
104
105
+ // @internal
100
106
const notCatchedErrors = ( middleware : FlowMiddleware ) => (
101
107
error : Error ,
102
108
errorBox : FlowBoxWithError
@@ -107,30 +113,30 @@ const notCatchedErrors = (middleware: FlowMiddleware) => (
107
113
R . tap ( logError )
108
114
) ;
109
115
116
+ // @internal
110
117
const errorOut : ErrorOut = ( middleware ) => async ( box ) =>
111
- // @ts -ignore
118
+ // @ts -expect-error
112
119
flow (
113
- // @ts -ignore
114
120
R . unless (
115
121
flow ( R . prop ( "error" ) , R . is ( Object ) ) ,
116
- // @ts -ignore
117
122
// TODO have a look at ramda otherwise
118
123
tryCatchAsync (
119
- // @ts -ignore
124
+ // @ts -expect-error
120
125
flow ( middleware , validateBoxState ( middleware ) ) ,
121
126
notCatchedErrors ( middleware )
122
127
)
123
128
)
124
- // @ts -ignore
129
+ // @ts -expect-error
125
130
) ( await box ) ;
126
131
132
+ // @internal
127
133
const errorCallbackHandler : ErrorCallbackHandler = ( errorCallback ) => async (
128
134
box
129
135
) =>
130
- // @ts -ignore
136
+ // @ts -expect-error
131
137
R . when (
132
138
flow ( R . prop ( "error" ) , R . is ( Object ) ) ,
133
- // @ts -ignore
139
+ // @ts -expect-error
134
140
flow ( R . clone , errorCallback , R . always ( await box ) )
135
141
) ( await box ) ;
136
142
@@ -142,10 +148,10 @@ const errorCallbackHandler: ErrorCallbackHandler = (errorCallback) => async (
142
148
const lambdaFlow : LambdaFlow = ( ...middlewares ) => (
143
149
errorCallback = R . identity
144
150
) =>
145
- // @ts -ignore
151
+ // @ts -expect-error
146
152
flow (
147
153
createBox ,
148
- // @ts -ignore
154
+ // @ts -expect-error
149
155
...R . map ( errorOut ) ( middlewares ) ,
150
156
errorCallbackHandler ( errorCallback ) ,
151
157
returnResponse
0 commit comments