@@ -16,6 +16,70 @@ import Dispatch
16
16
import Logging
17
17
import NIOCore
18
18
19
+ // MARK: - Client Context
20
+
21
+ /// AWS Mobile SDK client fields.
22
+ public struct ClientApplication : Codable , Sendable {
23
+ /// The mobile app installation id
24
+ public let installationID : String ?
25
+ /// The app title for the mobile app as registered with AWS' mobile services.
26
+ public let appTitle : String ?
27
+ /// The version name of the application as registered with AWS' mobile services.
28
+ public let appVersionName : String ?
29
+ /// The app version code.
30
+ public let appVersionCode : String ?
31
+ /// The package name for the mobile application invoking the function
32
+ public let appPackageName : String ?
33
+
34
+ private enum CodingKeys : String , CodingKey {
35
+ case installationID = " installation_id "
36
+ case appTitle = " app_title "
37
+ case appVersionName = " app_version_name "
38
+ case appVersionCode = " app_version_code "
39
+ case appPackageName = " app_package_name "
40
+ }
41
+
42
+ public init (
43
+ installationID: String ? = nil ,
44
+ appTitle: String ? = nil ,
45
+ appVersionName: String ? = nil ,
46
+ appVersionCode: String ? = nil ,
47
+ appPackageName: String ? = nil
48
+ ) {
49
+ self . installationID = installationID
50
+ self . appTitle = appTitle
51
+ self . appVersionName = appVersionName
52
+ self . appVersionCode = appVersionCode
53
+ self . appPackageName = appPackageName
54
+ }
55
+ }
56
+
57
+ /// For invocations from the AWS Mobile SDK, data about the client application and device.
58
+ public struct ClientContext : Codable , Sendable {
59
+ /// Information about the mobile application invoking the function.
60
+ public let client : ClientApplication ?
61
+ /// Custom properties attached to the mobile event context.
62
+ public let custom : [ String : String ] ?
63
+ /// Environment settings from the mobile client.
64
+ public let environment : [ String : String ] ?
65
+
66
+ private enum CodingKeys : String , CodingKey {
67
+ case client
68
+ case custom
69
+ case environment = " env "
70
+ }
71
+
72
+ public init (
73
+ client: ClientApplication ? = nil ,
74
+ custom: [ String : String ] ? = nil ,
75
+ environment: [ String : String ] ? = nil
76
+ ) {
77
+ self . client = client
78
+ self . custom = custom
79
+ self . environment = environment
80
+ }
81
+ }
82
+
19
83
// MARK: - Context
20
84
21
85
/// Lambda runtime context.
@@ -27,7 +91,7 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
27
91
let invokedFunctionARN : String
28
92
let deadline : DispatchWallTime
29
93
let cognitoIdentity : String ?
30
- let clientContext : String ?
94
+ let clientContext : ClientContext ?
31
95
let logger : Logger
32
96
33
97
init (
@@ -36,7 +100,7 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
36
100
invokedFunctionARN: String ,
37
101
deadline: DispatchWallTime ,
38
102
cognitoIdentity: String ? ,
39
- clientContext: String ? ,
103
+ clientContext: ClientContext ? ,
40
104
logger: Logger
41
105
) {
42
106
self . requestID = requestID
@@ -77,7 +141,7 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
77
141
}
78
142
79
143
/// For invocations from the AWS Mobile SDK, data about the client application and device.
80
- public var clientContext : String ? {
144
+ public var clientContext : ClientContext ? {
81
145
self . storage. clientContext
82
146
}
83
147
@@ -94,7 +158,7 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
94
158
invokedFunctionARN: String ,
95
159
deadline: DispatchWallTime ,
96
160
cognitoIdentity: String ? = nil ,
97
- clientContext: String ? = nil ,
161
+ clientContext: ClientContext ? = nil ,
98
162
logger: Logger
99
163
) {
100
164
self . storage = _Storage (
@@ -117,7 +181,7 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
117
181
}
118
182
119
183
public var debugDescription : String {
120
- " \( Self . self) (requestID: \( self . requestID) , traceID: \( self . traceID) , invokedFunctionARN: \( self . invokedFunctionARN) , cognitoIdentity: \( self . cognitoIdentity ?? " nil " ) , clientContext: \( self . clientContext ?? " nil " ) , deadline: \( self . deadline) ) "
184
+ " \( Self . self) (requestID: \( self . requestID) , traceID: \( self . traceID) , invokedFunctionARN: \( self . invokedFunctionARN) , cognitoIdentity: \( self . cognitoIdentity ?? " nil " ) , clientContext: \( String ( describing : self . clientContext) ) , deadline: \( self . deadline) ) "
121
185
}
122
186
123
187
/// This interface is not part of the public API and must not be used by adopters. This API is not part of semver versioning.
0 commit comments