@@ -74,15 +74,24 @@ type IntegrationTarget<IntegrationRequest, IntegrationResponse> =
74
74
| Function < IntegrationRequest , IntegrationResponse >
75
75
| ExpressStepFunction < IntegrationRequest , IntegrationResponse > ;
76
76
77
- interface BaseApiIntegration {
77
+ export abstract class BaseApiIntegration {
78
+ /**
79
+ * Identify subclasses as API integrations to the Functionless plugin
80
+ */
81
+ public static readonly FunctionlessType = "ApiIntegration" ;
82
+ protected readonly functionlessKind = BaseApiIntegration . FunctionlessType ;
83
+
78
84
/**
79
85
* Add this integration as a Method to an API Gateway resource.
80
86
*
81
87
* TODO: this mirrors the AppsyncResolver.addResolver method, but it
82
88
* is on the chopping block: https://github.com/functionless/functionless/issues/137
83
89
* The 2 classes are conceptually similar so we should keep the DX in sync.
84
90
*/
85
- addMethod ( httpMethod : HttpMethod , resource : aws_apigateway . Resource ) : void ;
91
+ public abstract addMethod (
92
+ httpMethod : HttpMethod ,
93
+ resource : aws_apigateway . Resource
94
+ ) : void ;
86
95
}
87
96
88
97
/**
@@ -158,17 +167,12 @@ export interface MockApiIntegrationProps<
158
167
*/
159
168
export class MockApiIntegration <
160
169
Props extends MockApiIntegrationProps < any , any , any >
161
- > implements BaseApiIntegration
162
- {
163
- /**
164
- * This static property identifies this class as a MockApiIntegration to the Functionless plugin.
165
- */
166
- public static readonly FunctionlessType = "MockApiIntegration" ;
167
-
170
+ > extends BaseApiIntegration {
168
171
private readonly request : FunctionDecl ;
169
172
private readonly responses : { [ K in keyof Props [ "responses" ] ] : FunctionDecl } ;
170
173
171
174
public constructor ( props : Props ) {
175
+ super ( ) ;
172
176
this . request = validateFunctionDecl ( props . request ) ;
173
177
this . responses = Object . fromEntries (
174
178
Object . entries ( props . responses ) . map ( ( [ k , v ] ) => [
@@ -251,18 +255,13 @@ export interface AwsApiIntegrationProps<
251
255
*/
252
256
export class AwsApiIntegration <
253
257
Props extends AwsApiIntegrationProps < any , any , any , any >
254
- > implements BaseApiIntegration
255
- {
256
- /**
257
- * This static property identifies this class as an AwsApiIntegration to the Functionless plugin.
258
- */
259
- public static readonly FunctionlessType = "AwsApiIntegration" ;
260
-
258
+ > extends BaseApiIntegration {
261
259
private readonly request : FunctionDecl ;
262
260
private readonly response : FunctionDecl ;
263
261
private readonly integration : Props [ "integration" ] ;
264
262
265
263
constructor ( props : Props ) {
264
+ super ( ) ;
266
265
this . request = validateFunctionDecl ( props . request ) ;
267
266
this . response = validateFunctionDecl ( props . response ) ;
268
267
this . integration = props . integration ;
0 commit comments