Skip to content

Ensure Events still compiles #67

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
name: Soundness
uses: apple/swift-nio/.github/workflows/soundness.yml@main
with:
license_header_check_project_name: "SwiftAWSLambdaEvents"
license_header_check_project_name: "SwiftAWSLambdaRuntime"
shell_check_enabled: false
api_breakage_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
docs_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
api_breakage_check_container_image: "swift:6.0-noble"
docs_check_container_image: "swift:6.0-noble"

unit-tests:
name: Unit tests
Expand Down
32 changes: 32 additions & 0 deletions .licenseignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.gitignore
.licenseignore
.swiftformatignore
.spi.yml
.swift-format
.github/*
*.md
**/*.md
CONTRIBUTORS.txt
LICENSE.txt
NOTICE.txt
Package.swift
Package@swift-*.swift
Package.resolved
**/*.docc/*
**/.gitignore
**/Package.swift
**/Package.resolved
**/docker-compose*.yaml
**/docker/*
**/.dockerignore
**/Dockerfile
**/Makefile
**/*.html
**/*-template.yml
**/*.xcworkspace/*
**/*.xcodeproj/*
**/*.xcassets/*
**/*.appiconset/*
**/ResourcePackaging/hello.txt
.mailmap
.swiftformat
15 changes: 9 additions & 6 deletions Examples/Simple/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import PackageDescription
let package = Package(
name: "swift-aws-lambda-events-samples",
platforms: [
.macOS(.v12),
.macOS(.v12)
],
products: [
// demonstrate how to integrate with AWS API Gateway
.executable(name: "APIGateway", targets: ["APIGateway"]),
.executable(name: "APIGateway", targets: ["APIGateway"])
],
dependencies: [
// this is the dependency on the swift-aws-lambda-runtime library
Expand All @@ -21,9 +21,12 @@ let package = Package(
.package(name: "swift-aws-lambda-events", path: "../.."),
],
targets: [
.executableTarget(name: "APIGateway", dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
]),
.executableTarget(
name: "APIGateway",
dependencies: [
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
]
)
]
)
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let swiftSettings: [SwiftSetting] = [.enableExperimentalFeature("StrictConcurren
let package = Package(
name: "swift-aws-lambda-events",
products: [
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]),
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
Expand All @@ -17,14 +17,14 @@ let package = Package(
.target(
name: "AWSLambdaEvents",
dependencies: [
.product(name: "HTTPTypes", package: "swift-http-types"),
.product(name: "HTTPTypes", package: "swift-http-types")
],
swiftSettings: swiftSettings
),
.testTarget(
name: "AWSLambdaEventsTests",
dependencies: [
"AWSLambdaEvents",
"AWSLambdaEvents"
],
swiftSettings: swiftSettings
),
Expand Down
2 changes: 1 addition & 1 deletion Sources/AWSLambdaEvents/ALB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import FoundationEssentials
import Foundation
#endif

// https://github.com/aws/aws-lambda-go/blob/master/events/alb.go
// https://github.com/aws/aws-lambda-go/blob/main/events/alb.go
/// `ALBTargetGroupRequest` contains data originating from the ALB Lambda target group integration.
public struct ALBTargetGroupRequest: Codable, Sendable {
/// `Context` contains information to identify the load balancer invoking the lambda.
Expand Down
6 changes: 4 additions & 2 deletions Sources/AWSLambdaEvents/APIGatewayLambdaAuthorizers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ public struct APIGatewayLambdaAuthorizerSimpleResponse: Codable, Sendable {
public let isAuthorized: Bool
public let context: LambdaAuthorizerContext?

public init(isAuthorized: Bool,
context: LambdaAuthorizerContext?) {
public init(
isAuthorized: Bool,
context: LambdaAuthorizerContext?
) {
self.isAuthorized = isAuthorized
self.context = context
}
Expand Down
22 changes: 14 additions & 8 deletions Sources/AWSLambdaEvents/AppSync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ public struct AppSyncEvent: Decodable, Sendable {
} else if let dictionaryValue = try? container.decode([String: String].self) {
self = .dictionary(dictionaryValue)
} else {
throw DecodingError.dataCorruptedError(in: container, debugDescription: """
Unexpected AppSync argument.
Expected a String or a Dictionary.
""")
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: """
Unexpected AppSync argument.
Expected a String or a Dictionary.
"""
)
}
}

Expand Down Expand Up @@ -127,10 +130,13 @@ public struct AppSyncEvent: Decodable, Sendable {
} else if let cognitoIdentity = try? container.decode(CognitoUserPoolIdentity.self) {
self = .cognitoUserPools(cognitoIdentity)
} else {
throw DecodingError.dataCorruptedError(in: container, debugDescription: """
Unexpected Identity argument.
Expected a IAM Identity or a Cognito User Pool Identity.
""")
throw DecodingError.dataCorruptedError(
in: container,
debugDescription: """
Unexpected Identity argument.
Expected a IAM Identity or a Cognito User Pool Identity.
"""
)
}
}

Expand Down
26 changes: 22 additions & 4 deletions Sources/AWSLambdaEvents/Cognito.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,14 @@ extension CognitoEvent: Codable {
let userName = try container.decode(String.self, forKey: .userName)
let callerContext = try container.decode(CallerContext.self, forKey: .callerContext)

let params = CognitoEvent.Parameters(version: version, triggerSource: triggerSource, region: region, userPoolId: userPoolId, userName: userName, callerContext: callerContext)
let params = CognitoEvent.Parameters(
version: version,
triggerSource: triggerSource,
region: region,
userPoolId: userPoolId,
userName: userName,
callerContext: callerContext
)

switch triggerSource {
case .preSignUp_SignUp, .preSignUp_ExternalProvider, .preSignUp_AdminCreateUser:
Expand All @@ -204,7 +211,9 @@ extension CognitoEvent: Codable {
let value = try container.decode(CognitoEvent.PostAuthentication.self, forKey: .request)
self = .postAuthentication(params, value)

case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode, .customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute, .customMessage_Authentication:
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode,
.customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute,
.customMessage_Authentication:
let value = try container.decode(CognitoEvent.CustomMessage.self, forKey: .request)
self = .customMessage(params, value)

Expand Down Expand Up @@ -317,7 +326,14 @@ extension CognitoEventResponse: Codable {
let userName = try container.decode(String.self, forKey: .userName)
let callerContext = try container.decode(CognitoEvent.CallerContext.self, forKey: .callerContext)

let params = CognitoEvent.Parameters(version: version, triggerSource: triggerSource, region: region, userPoolId: userPoolId, userName: userName, callerContext: callerContext)
let params = CognitoEvent.Parameters(
version: version,
triggerSource: triggerSource,
region: region,
userPoolId: userPoolId,
userName: userName,
callerContext: callerContext
)

switch triggerSource {
case .preSignUp_SignUp, .preSignUp_AdminCreateUser, .preSignUp_ExternalProvider:
Expand All @@ -338,7 +354,9 @@ extension CognitoEventResponse: Codable {

self = .postAuthentication(params, request, response)

case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode, .customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute, .customMessage_Authentication:
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode,
.customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute,
.customMessage_Authentication:
let request = try container.decode(CognitoEvent.CustomMessage.self, forKey: .request)
let response = try container.decode(CognitoEventResponse.CustomMessage.self, forKey: .response)

Expand Down
Loading
Loading