Skip to content

Commit 79db2aa

Browse files
authoredOct 8, 2024
Ensure Events still compiles (#67)
* Ensure Events still compiles * Fix unacceptable language * Fix more * swift-format * Fix docs? * Fix license check
1 parent a61f77e commit 79db2aa

33 files changed

+1656
-1389
lines changed
 

‎.github/workflows/pull_request.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
name: Soundness
1010
uses: apple/swift-nio/.github/workflows/soundness.yml@main
1111
with:
12-
license_header_check_project_name: "SwiftAWSLambdaEvents"
12+
license_header_check_project_name: "SwiftAWSLambdaRuntime"
1313
shell_check_enabled: false
14-
api_breakage_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
15-
docs_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
14+
api_breakage_check_container_image: "swift:6.0-noble"
15+
docs_check_container_image: "swift:6.0-noble"
1616

1717
unit-tests:
1818
name: Unit tests

‎.licenseignore

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.gitignore
2+
.licenseignore
3+
.swiftformatignore
4+
.spi.yml
5+
.swift-format
6+
.github/*
7+
*.md
8+
**/*.md
9+
CONTRIBUTORS.txt
10+
LICENSE.txt
11+
NOTICE.txt
12+
Package.swift
13+
Package@swift-*.swift
14+
Package.resolved
15+
**/*.docc/*
16+
**/.gitignore
17+
**/Package.swift
18+
**/Package.resolved
19+
**/docker-compose*.yaml
20+
**/docker/*
21+
**/.dockerignore
22+
**/Dockerfile
23+
**/Makefile
24+
**/*.html
25+
**/*-template.yml
26+
**/*.xcworkspace/*
27+
**/*.xcodeproj/*
28+
**/*.xcassets/*
29+
**/*.appiconset/*
30+
**/ResourcePackaging/hello.txt
31+
.mailmap
32+
.swiftformat

‎Examples/Simple/Package.swift

+9-6
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import PackageDescription
55
let package = Package(
66
name: "swift-aws-lambda-events-samples",
77
platforms: [
8-
.macOS(.v12),
8+
.macOS(.v12)
99
],
1010
products: [
1111
// demonstrate how to integrate with AWS API Gateway
12-
.executable(name: "APIGateway", targets: ["APIGateway"]),
12+
.executable(name: "APIGateway", targets: ["APIGateway"])
1313
],
1414
dependencies: [
1515
// this is the dependency on the swift-aws-lambda-runtime library
@@ -21,9 +21,12 @@ let package = Package(
2121
.package(name: "swift-aws-lambda-events", path: "../.."),
2222
],
2323
targets: [
24-
.executableTarget(name: "APIGateway", dependencies: [
25-
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
26-
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
27-
]),
24+
.executableTarget(
25+
name: "APIGateway",
26+
dependencies: [
27+
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
28+
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
29+
]
30+
)
2831
]
2932
)

‎Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let swiftSettings: [SwiftSetting] = [.enableExperimentalFeature("StrictConcurren
77
let package = Package(
88
name: "swift-aws-lambda-events",
99
products: [
10-
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"]),
10+
.library(name: "AWSLambdaEvents", targets: ["AWSLambdaEvents"])
1111
],
1212
dependencies: [
1313
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
@@ -17,14 +17,14 @@ let package = Package(
1717
.target(
1818
name: "AWSLambdaEvents",
1919
dependencies: [
20-
.product(name: "HTTPTypes", package: "swift-http-types"),
20+
.product(name: "HTTPTypes", package: "swift-http-types")
2121
],
2222
swiftSettings: swiftSettings
2323
),
2424
.testTarget(
2525
name: "AWSLambdaEventsTests",
2626
dependencies: [
27-
"AWSLambdaEvents",
27+
"AWSLambdaEvents"
2828
],
2929
swiftSettings: swiftSettings
3030
),

‎Sources/AWSLambdaEvents/ALB.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import FoundationEssentials
2020
import Foundation
2121
#endif
2222

23-
// https://github.com/aws/aws-lambda-go/blob/master/events/alb.go
23+
// https://github.com/aws/aws-lambda-go/blob/main/events/alb.go
2424
/// `ALBTargetGroupRequest` contains data originating from the ALB Lambda target group integration.
2525
public struct ALBTargetGroupRequest: Codable, Sendable {
2626
/// `Context` contains information to identify the load balancer invoking the lambda.

‎Sources/AWSLambdaEvents/APIGatewayLambdaAuthorizers.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public struct APIGatewayLambdaAuthorizerSimpleResponse: Codable, Sendable {
6060
public let isAuthorized: Bool
6161
public let context: LambdaAuthorizerContext?
6262

63-
public init(isAuthorized: Bool,
64-
context: LambdaAuthorizerContext?) {
63+
public init(
64+
isAuthorized: Bool,
65+
context: LambdaAuthorizerContext?
66+
) {
6567
self.isAuthorized = isAuthorized
6668
self.context = context
6769
}

‎Sources/AWSLambdaEvents/AppSync.swift

+14-8
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ public struct AppSyncEvent: Decodable, Sendable {
2929
} else if let dictionaryValue = try? container.decode([String: String].self) {
3030
self = .dictionary(dictionaryValue)
3131
} else {
32-
throw DecodingError.dataCorruptedError(in: container, debugDescription: """
33-
Unexpected AppSync argument.
34-
Expected a String or a Dictionary.
35-
""")
32+
throw DecodingError.dataCorruptedError(
33+
in: container,
34+
debugDescription: """
35+
Unexpected AppSync argument.
36+
Expected a String or a Dictionary.
37+
"""
38+
)
3639
}
3740
}
3841

@@ -127,10 +130,13 @@ public struct AppSyncEvent: Decodable, Sendable {
127130
} else if let cognitoIdentity = try? container.decode(CognitoUserPoolIdentity.self) {
128131
self = .cognitoUserPools(cognitoIdentity)
129132
} else {
130-
throw DecodingError.dataCorruptedError(in: container, debugDescription: """
131-
Unexpected Identity argument.
132-
Expected a IAM Identity or a Cognito User Pool Identity.
133-
""")
133+
throw DecodingError.dataCorruptedError(
134+
in: container,
135+
debugDescription: """
136+
Unexpected Identity argument.
137+
Expected a IAM Identity or a Cognito User Pool Identity.
138+
"""
139+
)
134140
}
135141
}
136142

‎Sources/AWSLambdaEvents/Cognito.swift

+22-4
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ extension CognitoEvent: Codable {
189189
let userName = try container.decode(String.self, forKey: .userName)
190190
let callerContext = try container.decode(CallerContext.self, forKey: .callerContext)
191191

192-
let params = CognitoEvent.Parameters(version: version, triggerSource: triggerSource, region: region, userPoolId: userPoolId, userName: userName, callerContext: callerContext)
192+
let params = CognitoEvent.Parameters(
193+
version: version,
194+
triggerSource: triggerSource,
195+
region: region,
196+
userPoolId: userPoolId,
197+
userName: userName,
198+
callerContext: callerContext
199+
)
193200

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

207-
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode, .customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute, .customMessage_Authentication:
214+
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode,
215+
.customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute,
216+
.customMessage_Authentication:
208217
let value = try container.decode(CognitoEvent.CustomMessage.self, forKey: .request)
209218
self = .customMessage(params, value)
210219

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

320-
let params = CognitoEvent.Parameters(version: version, triggerSource: triggerSource, region: region, userPoolId: userPoolId, userName: userName, callerContext: callerContext)
329+
let params = CognitoEvent.Parameters(
330+
version: version,
331+
triggerSource: triggerSource,
332+
region: region,
333+
userPoolId: userPoolId,
334+
userName: userName,
335+
callerContext: callerContext
336+
)
321337

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

339355
self = .postAuthentication(params, request, response)
340356

341-
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode, .customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute, .customMessage_Authentication:
357+
case .customMessage_SignUp, .customMessage_AdminCreateUser, .customMessage_ResendCode,
358+
.customMessage_ForgotPassword, .customMessage_UpdateUserAttribute, .customMessage_VerifyUserAttribute,
359+
.customMessage_Authentication:
342360
let request = try container.decode(CognitoEvent.CustomMessage.self, forKey: .request)
343361
let response = try container.decode(CognitoEventResponse.CustomMessage.self, forKey: .response)
344362

0 commit comments

Comments
 (0)
Please sign in to comment.