Skip to content
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
2 changes: 2 additions & 0 deletions Examples/RoutingDemo/Sources/Middleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
// bearer-token auth middleware that resolves to a `HikerID`.
//

import AWSLambdaEvents
import Foundation
import struct HTTPTypes.HTTPResponse
import Logging
import Routing

Expand Down
1 change: 1 addition & 0 deletions Examples/RoutingDemo/Sources/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import AWSLambdaEvents
import AWSLambdaRuntime
import Foundation
import struct HTTPTypes.HTTPResponse
import Logging
import Routing

Expand Down
10 changes: 6 additions & 4 deletions Examples/TrailLog/Sources/Middleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
// and short-circuit with `401` on failure.
//

import AWSLambdaEvents
import Foundation
import HTTPTypes
import Logging
import Routing

Expand All @@ -16,8 +18,8 @@ import Routing
/// through unchanged.
struct LoggingMiddleware: MiddlewareProtocol {
func handle(
_ input: HTTPRequest,
next: @Sendable (HTTPRequest, Logger) async throws -> RouteResponse,
_ input: Routing.HTTPRequest,
next: @Sendable (Routing.HTTPRequest, Logger) async throws -> RouteResponse,
logger: Logger
) async throws -> RouteResponse {
let method = input.event.context.http.method.rawValue
Expand All @@ -33,15 +35,15 @@ struct LoggingMiddleware: MiddlewareProtocol {
/// `HikerID`. A production middleware would verify a JWT against an
/// identity provider and short-circuit with `401` on failure.
struct AuthMiddleware: Middleware {
typealias Input = HTTPRequest
typealias Input = Routing.HTTPRequest
typealias Value = HikerID

struct HikerID: Sendable, Codable {
let value: String
}

func process(
_ input: HTTPRequest,
_ input: Routing.HTTPRequest,
logger _: Logger
) async throws -> MiddlewareAction<HikerID> {
.next(HikerID(value: "demo-hiker"))
Expand Down
40 changes: 26 additions & 14 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let package = Package(
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(
url: "https://github.com/awslabs/swift-aws-lambda-runtime",
from: "2.6.2"
from: "3.0.1"
),
.package(url: "https://github.com/apple/swift-log.git", from: "1.6.0"),
.package(url: "https://github.com/hummingbird-project/hummingbird.git", from: "2.0.0"),
Expand All @@ -53,25 +53,25 @@ let package = Package(
.product(name: "RoutingKit", package: "routing-kit"),
.product(name: "HTTPTypes", package: "swift-http-types"),
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
]
],
),
.target(
name: "DynamoQueries",
dependencies: [
"DynamoQueriesMacros",
.product(name: "Logging", package: "swift-log"),
]
],
),
.target(
name: "DynamoQueriesSoto",
dependencies: [
"DynamoQueries",
.product(name: "SotoDynamoDB", package: "soto"),
]
],
),
.target(
name: "DynamoQueriesTestSupport",
dependencies: ["DynamoQueries"]
dependencies: ["DynamoQueries"],
),
.target(
name: "DynamoQueriesSnapshotTesting",
Expand All @@ -80,7 +80,7 @@ let package = Package(
"DynamoQueriesTestSupport",
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
]
],
),
.macro(
name: "DynamoQueriesMacros",
Expand All @@ -89,21 +89,21 @@ let package = Package(
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
.product(name: "SwiftParser", package: "swift-syntax"),
]
],
),
.testTarget(
name: "RoutingTests",
dependencies: [
"Routing",
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
]
],
),
.testTarget(
name: "DynamoQueriesMacrosTests",
dependencies: [
"DynamoQueriesMacros",
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
]
],
),
.testTarget(
name: "DynamoQueriesTests",
Expand All @@ -114,7 +114,7 @@ let package = Package(
"DynamoQueriesSnapshotTesting",
.product(name: "SotoDynamoDB", package: "soto"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
]
],
),
.executableTarget(
name: "RoutingDemo",
Expand All @@ -123,12 +123,12 @@ let package = Package(
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
],
path: "Examples/RoutingDemo/Sources"
path: "Examples/RoutingDemo/Sources",
),
.executableTarget(
name: "DynamoQueriesDemo",
dependencies: ["DynamoQueries", "DynamoQueriesTestSupport"],
path: "Examples/DynamoQueriesDemo/Sources"
path: "Examples/DynamoQueriesDemo/Sources",
),
.executableTarget(
name: "TrailLogDemo",
Expand All @@ -138,7 +138,7 @@ let package = Package(
.product(name: "AWSLambdaEvents", package: "swift-aws-lambda-events"),
.product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"),
],
path: "Examples/TrailLog/Sources"
path: "Examples/TrailLog/Sources",
),
.target(
name: "APIGatewayV2Server",
Expand All @@ -150,7 +150,19 @@ let package = Package(
.product(name: "HummingbirdTLS", package: "hummingbird"),
.product(name: "Logging", package: "swift-log"),
.product(name: "AsyncHTTPClient", package: "async-http-client"),
]
],
),
]
)

for target in package.targets {
target.swiftSettings = target.swiftSettings ?? []
target.swiftSettings?.append(contentsOf: [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ImmutableWeakCaptures"),
.enableUpcomingFeature("InferIsolatedConformances"),
.enableUpcomingFeature("InternalImportsByDefault"),
.enableUpcomingFeature("MemberImportVisibility"),
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
])
}
3 changes: 2 additions & 1 deletion Sources/APIGatewayV2Server/APIGatewayV2Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ import HTTPTypes
import Hummingbird
import HummingbirdCore
import HummingbirdTLS
import Logging
public import Logging
import NIOFoundationCompat
import NIOHTTP1
import NIOSSL

/// Local development HTTP server that proxies requests to a Lambda local server.
Expand Down
4 changes: 2 additions & 2 deletions Sources/APIGatewayV2Server/LambdaRuntime+APIGateway.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// LambdaKit
//

import AWSLambdaRuntime
public import AWSLambdaRuntime
import Foundation
import Logging
public import Logging

/// Configuration for one local HTTP gateway server: the port to listen on, and
/// an optional transformer to fill in what the real gateway would have put on
Expand Down
6 changes: 3 additions & 3 deletions Sources/APIGatewayV2Server/MutableAPIGatewayV2Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// LambdaKit
//

import AWSLambdaEvents
public import AWSLambdaEvents
import Foundation
import HTTPTypes
import Hummingbird
import NIOCore
public import Hummingbird
public import NIOCore
import NIOFoundationCompat

public struct MutableAPIGatewayV2Request: Encodable, Sendable {
Expand Down
6 changes: 3 additions & 3 deletions Sources/DynamoQueries/Core/DynamoValue.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Foundation
public import Foundation

/// A value matching one of DynamoDB's attribute-value variants.
///
Expand Down Expand Up @@ -42,7 +42,7 @@ extension DynamoValue: Codable {
case binarySet = "BS"
}

public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if let value = try container.decodeIfPresent(String.self, forKey: .string) {
self = .string(value)
Expand Down Expand Up @@ -89,7 +89,7 @@ extension DynamoValue: Codable {
}
}

public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .string(let value): try container.encode(value, forKey: .string)
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Client/DynamoClient.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// The transport-level interface a `DynamoClient` adapter implements. Each
/// method is non-chainable on purpose. Chaining lives on the `*Input` types
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

public extension Logger {
/// The logger DynamoQueries `execute` calls use when the caller doesn't
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Reads/BatchGet.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A multi-key read against a single table. Up to 100 keys per DynamoDB
/// request, 16MB total per response. Adapters auto-retry the
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Reads/GetItem.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A single-item lookup keyed by primary key, parameterized by the model it
/// returns.
Expand Down
10 changes: 7 additions & 3 deletions Sources/DynamoQueries/Query/Reads/MappedReads.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// Mapped read inputs: the result of calling `.map` on a *collection / paged*
/// read (`QueryInput`, `ScanInput`, `BatchGetInput`) or on `UpdateReturning`.
Expand Down Expand Up @@ -42,8 +42,12 @@ public struct MappedPageSequence<
var base: Base.AsyncIterator
let transform: @Sendable (Model) throws -> Output

public mutating func next() async throws -> QueryPage<Output>? {
guard let page = try await base.next() else { return nil }
public mutating func next(
isolation actor: isolated (any Actor)?
) async throws -> QueryPage<Output>? {
guard let page = try await base.next(isolation: actor) else {
return nil
}
return try page.map(transform)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/DynamoQueries/Query/Reads/Pagination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public struct PaginationToken: Sendable, Equatable {
}

extension PaginationToken: Codable {
public init(from decoder: Decoder) throws {
public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()
let string = try container.decode(String.self)
guard let token = PaginationToken(string: string) else {
Expand All @@ -49,7 +49,7 @@ extension PaginationToken: Codable {
self = token
}

public func encode(to encoder: Encoder) throws {
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(self.stringValue)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Reads/QueryInput.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A compiled DynamoDB Query request, parameterized by the model it returns.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Reads/ReadProtocols.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// Read abstractions that let a call site name *what a read delivers* without
/// naming *how it's stored*. Each has a primary associated type `Output`, so a
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Reads/ScanInput.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A compiled DynamoDB Scan request, parameterized by the model it returns.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Schema/KeyAttribute.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Foundation
public import Foundation

/// The DynamoDB scalar type of a key attribute.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Transactions/TransactGet.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A primary-key read leg that can be composed into a `TransactGet { ... }`
/// block *or* executed on its own. Both a plain `GetItemInput` and a mapped
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// Thrown by `TransactWriteInput.execute(using:)` when DynamoDB cancels the
/// whole transaction. Reports the per-leg cancellation reasons in the same
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Writes/BatchWrite.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A multi-item write against a single table: up to 25 items (puts +
/// deletes combined) per DynamoDB request, 16MB total. Adapters retry the
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Writes/DeleteItem.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A delete request for a single item, addressed by primary key. Optionally
/// guarded by a condition expression. The delete only fires if the
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Writes/PutItem.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// An insert-or-replace request for a single item.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueries/Query/Writes/UpdateItem.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Logging
public import Logging

/// A targeted update against an existing item, identified by its primary
/// key. Unlike `PutItem`, `UpdateItem` modifies only the attributes named in
Expand Down
4 changes: 2 additions & 2 deletions Sources/DynamoQueriesMacros/MarkerMacros.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftSyntax
import SwiftSyntaxMacros
public import SwiftSyntax
public import SwiftSyntaxMacros

/// Marks a property as the partition key. Generates no code. Read by @Table.
public struct PartitionKeyMacro: PeerMacro {
Expand Down
2 changes: 1 addition & 1 deletion Sources/DynamoQueriesMacros/Plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftSyntaxMacros

@main
struct DynamoKitMacrosPlugin: CompilerPlugin {
let providingMacros: [Macro.Type] = [
let providingMacros: [any Macro.Type] = [
TableMacro.self,
PartitionKeyMacro.self,
SortKeyMacro.self,
Expand Down
4 changes: 2 additions & 2 deletions Sources/DynamoQueriesMacros/TableMacro.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SwiftSyntax
import SwiftSyntaxMacros
public import SwiftSyntax
public import SwiftSyntaxMacros
import SwiftParser

public struct TableMacro: ExtensionMacro {
Expand Down
Loading
Loading