Skip to content

Commit

Permalink
fix: API GatewayV2 routes take Input<T> as handler (#1171)
Browse files Browse the repository at this point in the history
* Routes takes Input type as handler

* Fix mismatching types for the route handlers

* sync

---------

Co-authored-by: Frank <[email protected]>
  • Loading branch information
alexanderbh and fwang authored Oct 1, 2024
1 parent 055af43 commit 7c4b74d
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 37 deletions.
3 changes: 1 addition & 2 deletions platform/src/components/aws/apigateway-websocket-route.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import {
ComponentResourceOptions,
Input,
Output,
all,
interpolate,
output,
} from "@pulumi/pulumi";
import { Component, Transform, transform } from "../component";
import { Function, FunctionArgs } from "./function";
import { FunctionArgs } from "./function";
import { ApiGatewayWebSocketRouteArgs } from "./apigateway-websocket";
import { apigatewayv2, lambda } from "@pulumi/aws";
import { FunctionBuilder, functionBuilder } from "./helpers/function-builder";
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/apigateway-websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ export class ApiGatewayWebSocket extends Component implements Link.Linkable {
*/
public route(
route: string,
handler: string | FunctionArgs | Input<FunctionArn>,
handler: Input<string | FunctionArgs | FunctionArn>,
args: ApiGatewayWebSocketRouteArgs = {},
) {
const prefix = this.constructorName;
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/apigatewayv1-lambda-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
output,
} from "@pulumi/pulumi";
import { Component, Transform, transform } from "../component";
import { Function, FunctionArgs } from "./function";
import { FunctionArgs } from "./function";
import { apigateway, lambda } from "@pulumi/aws";
import {
ApiGatewayV1BaseRouteArgs,
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/apigatewayv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ export class ApiGatewayV1 extends Component implements Link.Linkable {
*/
public route(
route: string,
handler: string | FunctionArgs | Input<FunctionArn>,
handler: Input<string | FunctionArgs | FunctionArn>,
args: ApiGatewayV1RouteArgs = {},
) {
const { method, path } = this.parseRoute(route);
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/apigatewayv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ export class ApiGatewayV2 extends Component implements Link.Linkable {
*/
public route(
rawRoute: string,
handler: string | FunctionArgs | Input<FunctionArn>,
handler: Input<string | FunctionArgs | FunctionArn>,
args: ApiGatewayV2RouteArgs = {},
) {
const route = this.parseRoute(rawRoute);
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/bucket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ export class Bucket extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: BucketSubscriberArgs,
) {
this.ensureNotSubscribed();
Expand Down Expand Up @@ -707,7 +707,7 @@ export class Bucket extends Component implements Link.Linkable {
*/
public static subscribe(
bucketArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: BucketSubscriberArgs,
) {
return output(bucketArn).apply((bucketArn) => {
Expand All @@ -726,7 +726,7 @@ export class Bucket extends Component implements Link.Linkable {
name: string,
bucketName: Input<string>,
bucketArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: BucketSubscriberArgs = {},
opts: ComponentResourceOptions = {},
) {
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export class Bus extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: BusSubscriberArgs = {},
) {
return Bus._subscribeFunction(
Expand Down Expand Up @@ -309,7 +309,7 @@ export class Bus extends Component implements Link.Linkable {
*/
public static subscribe(
busArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: BusSubscriberArgs,
) {
return output(busArn).apply((busArn) => {
Expand All @@ -328,7 +328,7 @@ export class Bus extends Component implements Link.Linkable {
name: string,
busName: Input<string>,
busArn: string | Output<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: BusSubscriberArgs = {},
opts: ComponentResourceOptions = {},
) {
Expand Down
24 changes: 12 additions & 12 deletions platform/src/components/aws/cognito-user-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,75 +24,75 @@ interface Triggers {
*
* Takes the handler path, the function args, or a function ARN.
*/
createAuthChallenge?: string | FunctionArgs | Input<FunctionArn>;
createAuthChallenge?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered during events like user sign-up, password recovery, email/phone number
* verification, and when an admin creates a user. Use this trigger to customize the
* email provider.
*
* Takes the handler path, the function args, or a function ARN.
*/
customEmailSender?: string | FunctionArgs | Input<FunctionArn>;
customEmailSender?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered during events like user sign-up, password recovery, email/phone number
* verification, and when an admin creates a user. Use this trigger to customize the
* message that is sent to your users.
*
* Takes the handler path, the function args, or a function ARN.
*/
customMessage?: string | FunctionArgs | Input<FunctionArn>;
customMessage?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered when an SMS message needs to be sent, such as for MFA or verification codes.
* Use this trigger to customize the SMS provider.
*
* Takes the handler path, the function args, or a function ARN.
*/
customSmsSender?: string | FunctionArgs | Input<FunctionArn>;
customSmsSender?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered after each challenge response to determine the next action. Evaluates whether the
* user has completed the authentication process or if additional challenges are needed.
* ARN of the lambda function to name a custom challenge.
*
* Takes the handler path, the function args, or a function ARN.
*/
defineAuthChallenge?: string | FunctionArgs | Input<FunctionArn>;
defineAuthChallenge?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered after a successful authentication event. Use this to perform custom actions,
* such as logging or modifying user attributes, after the user is authenticated.
*
* Takes the handler path, the function args, or a function ARN.
*/
postAuthentication?: string | FunctionArgs | Input<FunctionArn>;
postAuthentication?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered after a user is successfully confirmed; sign-up or email/phone number
* verification. Use this to perform additional actions, like sending a welcome email or
* initializing user data, after user confirmation.
*
* Takes the handler path, the function args, or a function ARN.
*/
postConfirmation?: string | FunctionArgs | Input<FunctionArn>;
postConfirmation?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered before the authentication process begins. Use this to implement custom
* validation or checks (like checking if the user is banned) before continuing
* authentication.
*
* Takes the handler path, the function args, or a function ARN.
*/
preAuthentication?: string | FunctionArgs | Input<FunctionArn>;
preAuthentication?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered before the user sign-up process completes. Use this to perform custom
* validation, auto-confirm users, or auto-verify attributes based on custom logic.
*
* Takes the handler path, the function args, or a function ARN.
*/
preSignUp?: string | FunctionArgs | Input<FunctionArn>;
preSignUp?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered before tokens are generated in the authentication process. Use this to
* customize or add claims to the tokens that will be generated and returned to the user.
*
* Takes the handler path, the function args, or a function ARN.
*/
preTokenGeneration?: string | FunctionArgs | Input<FunctionArn>;
preTokenGeneration?: Input<string | FunctionArgs | FunctionArn>;
/**
* The version of the preTokenGeneration trigger to use. Higher versions have access to
* more information that support new features.
Expand All @@ -106,15 +106,15 @@ interface Triggers {
*
* Takes the handler path, the function args, or a function ARN.
*/
userMigration?: string | FunctionArgs | Input<FunctionArn>;
userMigration?: Input<string | FunctionArgs | FunctionArn>;
/**
* Triggered after the user responds to a custom authentication challenge. Use this to
* verify the user's response to the challenge and determine whether to continue
* authenticating the user.
*
* Takes the handler path, the function args, or a function ARN.
*/
verifyAuthChallengeResponse?: string | FunctionArgs | Input<FunctionArn>;
verifyAuthChallengeResponse?: Input<string | FunctionArgs | FunctionArn>;
}

export interface CognitoUserPoolArgs {
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/dynamo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ export class Dynamo extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: DynamoSubscriberArgs,
) {
const sourceName = this.constructorName;
Expand Down Expand Up @@ -632,7 +632,7 @@ export class Dynamo extends Component implements Link.Linkable {
*/
public static subscribe(
streamArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: DynamoSubscriberArgs,
) {
return output(streamArn).apply((streamArn) =>
Expand All @@ -648,7 +648,7 @@ export class Dynamo extends Component implements Link.Linkable {
private static _subscribe(
name: string,
streamArn: string | Output<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: DynamoSubscriberArgs = {},
opts: ComponentResourceOptions = {},
) {
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/kinesis-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class KinesisStream extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: KinesisStreamLambdaSubscriberArgs,
) {
return KinesisStream._subscribe(
Expand Down Expand Up @@ -255,7 +255,7 @@ export class KinesisStream extends Component implements Link.Linkable {
*/
public static subscribe(
streamArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: KinesisStreamLambdaSubscriberArgs,
) {
return output(streamArn).apply((streamArn) =>
Expand All @@ -271,7 +271,7 @@ export class KinesisStream extends Component implements Link.Linkable {
private static _subscribe(
name: string,
streamArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: KinesisStreamLambdaSubscriberArgs = {},
opts: ComponentResourceOptions = {},
) {
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ export class Queue extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: QueueSubscriberArgs,
opts?: ComponentResourceOptions,
) {
Expand Down Expand Up @@ -537,7 +537,7 @@ export class Queue extends Component implements Link.Linkable {
*/
public static subscribe(
queueArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: QueueSubscriberArgs,
opts?: ComponentResourceOptions,
) {
Expand All @@ -555,7 +555,7 @@ export class Queue extends Component implements Link.Linkable {
private static _subscribeFunction(
name: string,
queueArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: QueueSubscriberArgs = {},
opts?: ComponentResourceOptions,
) {
Expand Down
2 changes: 1 addition & 1 deletion platform/src/components/aws/realtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export class Realtime extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: RealtimeSubscriberArgs,
) {
return all([subscriber, args.filter]).apply(([subscriber, filter]) => {
Expand Down
6 changes: 3 additions & 3 deletions platform/src/components/aws/sns-topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class SnsTopic extends Component implements Link.Linkable {
* ```
*/
public subscribe(
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: SnsTopicSubscriberArgs = {},
) {
return SnsTopic._subscribeFunction(
Expand Down Expand Up @@ -307,7 +307,7 @@ export class SnsTopic extends Component implements Link.Linkable {
*/
public static subscribe(
topicArn: Input<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args?: SnsTopicSubscriberArgs,
) {
return output(topicArn).apply((topicArn) =>
Expand All @@ -323,7 +323,7 @@ export class SnsTopic extends Component implements Link.Linkable {
private static _subscribeFunction(
name: string,
topicArn: string | Output<string>,
subscriber: string | FunctionArgs | Input<FunctionArn>,
subscriber: Input<string | FunctionArgs | FunctionArn>,
args: SnsTopicSubscriberArgs = {},
opts: $util.ComponentResourceOptions = {},
) {
Expand Down

0 comments on commit 7c4b74d

Please sign in to comment.