From 6f0e519c12fccdb5e49509c72a103152cfdb6cec Mon Sep 17 00:00:00 2001 From: Adam Chelminski Date: Thu, 2 Aug 2018 15:15:18 -0400 Subject: [PATCH] STITCH-1818 Expose StitchServiceClient and add AWSServiceClient (#89) --- .gitignore | 6 + .../AWSS3PutObjectResult.swift | 3 +- .../AWSS3SignPolicyResult.swift | 3 +- .../Internal/CoreAWSS3ServiceClient.swift | 6 +- .../CoreAWSS3ServiceClientUnitTests.swift | 24 +- .../AWSSESSendResult.swift | 3 +- .../Internal/CoreAWSSESServiceClient.swift | 3 +- .../CoreAWSSESServiceClientUnitTests.swift | 6 +- Core/Services/StitchCoreAWSService/.gitignore | 6 + Core/Services/StitchCoreAWSService/Makefile | 21 + .../StitchCoreAWSService/Package.swift | 22 + Core/Services/StitchCoreAWSService/README.md | 3 + .../StitchCoreAWSService/AWSRequest.swift | 106 ++++ .../Internal/CoreAWSServiceClient.swift | 52 ++ .../StitchCoreAWSService.podspec | 32 + .../AWSRequestUnitTests.swift | 50 ++ .../CoreAWSServiceClientUnitTests.swift | 89 +++ .../Internal/CoreFCMServiceClient.swift | 2 +- .../CoreFCMServiceClientUnitTests.swift | 14 +- .../Internal/CoreHTTPServiceClient.swift | 2 +- .../CoreHTTPServiceClientUnitTests.swift | 6 +- .../StitchCoreLocalMongoDBService.podspec | 2 +- .../Internal/CoreRemoteMongoCollection.swift | 10 +- .../CoreRemoteMongoReadOperation.swift | 2 +- .../CoreRemoteMongoCollectionUnitTests.swift | 78 +-- .../CoreTwilioServiceClient.swift | 2 +- .../CoreTwilioServiceClientUnitTests.swift | 8 +- .../Services/Rules/RulesResources.swift | 17 +- .../Services/ServiceConfigs.swift | 37 +- .../Internal/CoreStitchAppClient.swift | 8 +- .../Internal/CoreStitchServiceClient.swift | 4 +- .../CoreStitchServiceClientImpl.swift | 12 +- .../MockCoreStitchServiceClient.swift | 20 +- .../Services/SpyCoreStitchServiceClient.swift | 28 +- .../FoundationHTTPTransportUnitTests.swift | 4 +- .../CoreStitchServiceClientUnitTests.swift | 4 +- .../project.pbxproj | 8 +- .../AWSS3ServiceClient.swift | 5 +- .../Internal/AWSS3ServiceClientImpl.swift | 1 + ...ontants.h => AWSS3ServiceTestsConstants.h} | 0 .../AWSSESServiceClient.swift | 5 +- .../Internal/AWSSESServiceClientImpl.swift | 1 + .../StitchAWSService/StitchAWSService.podspec | 33 ++ .../project.pbxproj | 548 ++++++++++++++++++ .../StitchAWSService/AWSServiceClient.swift | 81 +++ .../StitchAWSService/Info.plist | 24 + .../Internal/AWSServiceClientImpl.swift | 39 ++ .../StitchAWSServiceExports.swift | 3 + .../AWSServiceClientIntTests.swift | 202 +++++++ .../AWSServiceTestsConstants.h | 15 + .../StitchAWSServiceTests/Info.plist | 22 + .../StitchFCMService/FCMServiceClient.swift | 2 +- .../StitchHTTPService/HTTPServiceClient.swift | 2 +- .../LocalMongoClient.swift | 2 +- .../RemoteMongoClient.swift | 2 +- .../TwilioServiceClient.swift | 2 +- .../StitchCore.xcodeproj/project.pbxproj | 2 +- .../Core/Internal/StitchAppClientImpl.swift | 124 +--- .../StitchCore/Core/StitchAppClient.swift | 10 + .../Internal/NamedServiceClientFactory.swift | 9 +- .../Internal/ServiceClientFactory.swift | 9 +- .../Internal/StitchServiceClientImpl.swift | 56 +- .../ThrowingServiceClientFactory.swift | 9 +- .../{Internal => }/StitchServiceClient.swift | 36 +- ...hrowingServiceClientFactoryUnitTests.swift | 2 +- Makefile | 7 + README.md | 6 +- Stitch.xcworkspace/contents.xcworkspacedata | 9 +- StitchSDK.podspec | 10 + contrib/generate_docs.sh | 2 + jazzy.json | 16 +- scripts/add_copy_phase.py | 2 + scripts/generate_xcconfigs.py | 1 + scripts/run_xctests.py | 5 + 74 files changed, 1710 insertions(+), 297 deletions(-) create mode 100644 Core/Services/StitchCoreAWSService/.gitignore create mode 100644 Core/Services/StitchCoreAWSService/Makefile create mode 100644 Core/Services/StitchCoreAWSService/Package.swift create mode 100644 Core/Services/StitchCoreAWSService/README.md create mode 100644 Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/AWSRequest.swift create mode 100644 Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/Internal/CoreAWSServiceClient.swift create mode 100644 Core/Services/StitchCoreAWSService/StitchCoreAWSService.podspec create mode 100644 Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/AWSRequestUnitTests.swift create mode 100644 Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/CoreAWSServiceClientUnitTests.swift rename Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests/{AWSS3ServiceTestsContants.h => AWSS3ServiceTestsConstants.h} (100%) create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService.podspec create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService.xcodeproj/project.pbxproj create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService/AWSServiceClient.swift create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService/Info.plist create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService/Internal/AWSServiceClientImpl.swift create mode 100644 Darwin/Services/StitchAWSService/StitchAWSService/StitchAWSServiceExports.swift create mode 100644 Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceClientIntTests.swift create mode 100644 Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceTestsConstants.h create mode 100644 Darwin/Services/StitchAWSService/StitchAWSServiceTests/Info.plist rename Darwin/StitchCore/StitchCore/Services/{Internal => }/StitchServiceClient.swift (53%) diff --git a/.gitignore b/.gitignore index faf0d185..fc946075 100755 --- a/.gitignore +++ b/.gitignore @@ -68,6 +68,12 @@ Core/StitchCoreTestUtils/Package.resolved Core/StitchCoreTestUtils/.build/ Core/StitchCoreTestUtils/*.xcodeproj/ +Core/Services/StitchCoreAWSService/Packages/ +Core/Services/StitchCoreAWSService/Package.pins +Core/Services/StitchCoreAWSService/Package.resolved +Core/Services/StitchCoreAWSService/.build/ +Core/Services/StitchCoreAWSService/StitchCoreAWSService.xcodeproj/ + Core/Services/StitchCoreAWSS3Service/Packages/ Core/Services/StitchCoreAWSS3Service/Package.pins Core/Services/StitchCoreAWSS3Service/Package.resolved diff --git a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3PutObjectResult.swift b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3PutObjectResult.swift index ef2c5601..a3ebab41 100644 --- a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3PutObjectResult.swift +++ b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3PutObjectResult.swift @@ -1,8 +1,9 @@ import Foundation /** - * The result of an AWS S3 put object request. + * The result of an AWS S3 put object request. (Deprecated) */ +@available(*, deprecated, message: "Use the generic AWS service instead") public struct AWSS3PutObjectResult: Decodable { /** * The location of the object. diff --git a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3SignPolicyResult.swift b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3SignPolicyResult.swift index ae651fb4..8542e397 100644 --- a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3SignPolicyResult.swift +++ b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/AWSS3SignPolicyResult.swift @@ -1,8 +1,9 @@ import Foundation /** - * The result of an AWS S3 sign policy request. + * The result of an AWS S3 sign policy request. (Deprecated) */ +@available(*, deprecated, message: "Use the generic AWS service instead") public struct AWSS3SignPolicyResult: Decodable { /** * The description of the policy that has been signed. diff --git a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/Internal/CoreAWSS3ServiceClient.swift b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/Internal/CoreAWSS3ServiceClient.swift index ac7d98d6..724f8ec7 100644 --- a/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/Internal/CoreAWSS3ServiceClient.swift +++ b/Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service/Internal/CoreAWSS3ServiceClient.swift @@ -2,7 +2,7 @@ import Foundation import MongoSwift import StitchCoreSDK - +@available(*, deprecated, message: "Use AWSServiceClient instead") public final class CoreAWSS3ServiceClient { private let service: CoreStitchServiceClient @@ -41,7 +41,7 @@ public final class CoreAWSS3ServiceClient { args[bodyKey] = Binary.init(data: dataVal, subtype: .binary) } - return try self.service.callFunctionInternal( + return try self.service.callFunction( withName: "put", withArgs: [args], withRequestTimeout: timeout @@ -107,7 +107,7 @@ public final class CoreAWSS3ServiceClient { "contentType": contentType ] - return try service.callFunctionInternal( + return try service.callFunction( withName: "signPolicy", withArgs: [args], withRequestTimeout: nil) } } diff --git a/Core/Services/StitchCoreAWSS3Service/Tests/StitchCoreAWSS3ServiceTests/CoreAWSS3ServiceClientUnitTests.swift b/Core/Services/StitchCoreAWSS3Service/Tests/StitchCoreAWSS3ServiceTests/CoreAWSS3ServiceClientUnitTests.swift index 0696a8ca..7faaa97f 100644 --- a/Core/Services/StitchCoreAWSS3Service/Tests/StitchCoreAWSS3ServiceTests/CoreAWSS3ServiceClientUnitTests.swift +++ b/Core/Services/StitchCoreAWSS3Service/Tests/StitchCoreAWSS3ServiceTests/CoreAWSS3ServiceClientUnitTests.swift @@ -18,7 +18,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { let expectedLocation = "awsLocation" - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: AWSS3PutObjectResult.init(location: expectedLocation), forArg1: .any, forArg2: .any, @@ -35,7 +35,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedLocation, result.location) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("put", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -51,7 +51,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -84,7 +84,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { let expectedLocation = "awsLocation" - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: AWSS3PutObjectResult.init(location: expectedLocation), forArg1: .any, forArg2: .any, @@ -101,7 +101,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedLocation, result.location) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("put", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -117,7 +117,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -150,7 +150,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { let expectedLocation = "awsLocation" - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: AWSS3PutObjectResult.init(location: expectedLocation), forArg1: .any, forArg2: .any, @@ -167,7 +167,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedLocation, result.location) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("put", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -183,7 +183,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -219,7 +219,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { let expectedDate = "01-101-2012" let expectedCredential = "someCredential" - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: AWSS3SignPolicyResult.init(policy: expectedPolicy, signature: expectedSignature, algorithm: expectedAlgorithm, @@ -236,7 +236,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedDate, result.date) XCTAssertEqual(expectedCredential, result.credential) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("signPolicy", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -251,7 +251,7 @@ final class CoreAWSS3ServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, diff --git a/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/AWSSESSendResult.swift b/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/AWSSESSendResult.swift index 3bb5c3e4..1ae395f9 100644 --- a/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/AWSSESSendResult.swift +++ b/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/AWSSESSendResult.swift @@ -1,8 +1,9 @@ import Foundation /** - * The result of an AWS SES send request. + * The result of an AWS SES send request. (Deprecated) */ +@available(*, deprecated, message: "Use the generic AWS service instead") public struct AWSSESSendResult: Decodable { /** * The id of the sent message. diff --git a/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/Internal/CoreAWSSESServiceClient.swift b/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/Internal/CoreAWSSESServiceClient.swift index cae250a9..cf967338 100644 --- a/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/Internal/CoreAWSSESServiceClient.swift +++ b/Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService/Internal/CoreAWSSESServiceClient.swift @@ -2,6 +2,7 @@ import Foundation import MongoSwift import StitchCoreSDK +@available(*, deprecated, message: "Use AWSServiceClient instead") public final class CoreAWSSESServiceClient { private let service: CoreStitchServiceClient @@ -20,6 +21,6 @@ public final class CoreAWSSESServiceClient { "body": body ] - return try self.service.callFunctionInternal(withName: "send", withArgs: [args], withRequestTimeout: nil) + return try self.service.callFunction(withName: "send", withArgs: [args], withRequestTimeout: nil) } } diff --git a/Core/Services/StitchCoreAWSSESService/Tests/StitchCoreAWSSESServiceTests/CoreAWSSESServiceClientUnitTests.swift b/Core/Services/StitchCoreAWSSESService/Tests/StitchCoreAWSSESServiceTests/CoreAWSSESServiceClientUnitTests.swift index 6d655306..b5e62842 100644 --- a/Core/Services/StitchCoreAWSSESService/Tests/StitchCoreAWSSESServiceTests/CoreAWSSESServiceClientUnitTests.swift +++ b/Core/Services/StitchCoreAWSSESService/Tests/StitchCoreAWSSESServiceTests/CoreAWSSESServiceClientUnitTests.swift @@ -16,7 +16,7 @@ final class CoreAWSSESServiceClientUnitTests: XCTestCase { let expectedMessageID = "yourMessageID" - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: AWSSESSendResult.init(messageID: expectedMessageID), forArg1: .any, forArg2: .any, @@ -27,7 +27,7 @@ final class CoreAWSSESServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedMessageID, result.messageID) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -42,7 +42,7 @@ final class CoreAWSSESServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, diff --git a/Core/Services/StitchCoreAWSService/.gitignore b/Core/Services/StitchCoreAWSService/.gitignore new file mode 100644 index 00000000..9c0dd9b7 --- /dev/null +++ b/Core/Services/StitchCoreAWSService/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +/.build +/Packages +/*.xcodeproj +vendor +dist diff --git a/Core/Services/StitchCoreAWSService/Makefile b/Core/Services/StitchCoreAWSService/Makefile new file mode 100644 index 00000000..1382a42b --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Makefile @@ -0,0 +1,21 @@ +all: prepare build +git: + git init + git add . + git commit --allow-empty -m "init" +lint: + swiftlint +clean: + swift package --build-path ../../../.build clean +build: + swift build --build-path ../../../.build -Xcc -I../../../vendor/MobileSDKs/include/libbson-1.0/ -Xcc -I../../../vendor/MobileSDKs/include/libmongoc-1.0 +resolve: + swift package --build-path ../../../.build resolve +update: + swift package --build-path ../../../.build update +test: + # temporary until a fix is in for .brew dependency for libmongoc + xcodebuild test -workspace ../../../Stitch.xcworkspace/ -scheme StitchCoreAWSService-Package -configuration Debug -destination "platform=iOS Simulator,name=iPhone 7,OS=11.2" +project: + swift package generate-xcodeproj --xcconfig-overrides StitchCoreAWSService.xcconfig +prepare: git resolve project diff --git a/Core/Services/StitchCoreAWSService/Package.swift b/Core/Services/StitchCoreAWSService/Package.swift new file mode 100644 index 00000000..0060d879 --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Package.swift @@ -0,0 +1,22 @@ +// swift-tools-version:4.0 +import PackageDescription + +let package = Package( + name: "StitchCoreAWSService", + products: [ + .library( + name: "StitchCoreAWSService", + targets: ["StitchCoreAWSService"]), + ], + dependencies: [ + .package(url: "../../StitchCoreSDK", .branch("master")) + ], + targets: [ + .target( + name: "StitchCoreAWSService", + dependencies: ["StitchCoreSDK"]), + .testTarget( + name: "StitchCoreAWSServiceTests", + dependencies: ["StitchCoreAWSService", "StitchCoreSDKMocks"]), + ] +) diff --git a/Core/Services/StitchCoreAWSService/README.md b/Core/Services/StitchCoreAWSService/README.md new file mode 100644 index 00000000..70a4cbc3 --- /dev/null +++ b/Core/Services/StitchCoreAWSService/README.md @@ -0,0 +1,3 @@ +# StitchCoreAWSService + +A description of this package. diff --git a/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/AWSRequest.swift b/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/AWSRequest.swift new file mode 100644 index 00000000..c8b70fb9 --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/AWSRequest.swift @@ -0,0 +1,106 @@ +import Foundation +import MongoSwift + +/** + * An error that the `AWSRequestBuilder` can throw if it is missing certain configuration properties. + */ +public enum AWSRequestBuilderError: Error { + case missingService + case missingAction +} + +/** + * An AWSRequest encapsulates the details of an AWS request over the AWS service. + */ +public struct AWSRequest { + /** + * The service that the action in the request will be performed against. + */ + public let service: String + + /** + * The action within the AWS service to perform. + */ + public let action: String + + /** + * The region that service in this request should be scoped to. + */ + public let region: String? + + /** + * The arguments that will be used in the action. + */ + public let arguments: Document +} + +/** + * A builder that can build an `AWSRequest` + */ +public class AWSRequestBuilder { + internal var service: String? + internal var action: String? + internal var region: String? + internal var arguments: Document? + + /** + * Initializes a new builder for an AWS request. + */ + public init() { } + + /** + * Sets the service that the action in the request will be performed against. + */ + @discardableResult + public func with(service: String) -> Self { + self.service = service + return self + } + + /** + * Sets the action within the AWS service to perform. + */ + @discardableResult + public func with(action: String) -> Self { + self.action = action + return self + } + + /** + * Sets the region that service in this request should be scoped to. + */ + @discardableResult + public func with(region: String) -> Self { + self.region = region + return self + } + + /** + * Sets the arguments that will be used in the action. + */ + @discardableResult + public func with(arguments: Document) -> Self { + self.arguments = arguments + return self + } + + /** + * Builds, validates, and returns the `AWSRequest`. + */ + public func build() throws -> AWSRequest { + guard let service = service, service != "" else { + throw AWSRequestBuilderError.missingService + } + + guard let action = action, action != "" else { + throw AWSRequestBuilderError.missingAction + } + + return AWSRequest.init( + service: service, + action: action, + region: region, + arguments: arguments ?? Document.init() + ) + } +} diff --git a/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/Internal/CoreAWSServiceClient.swift b/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/Internal/CoreAWSServiceClient.swift new file mode 100644 index 00000000..a997fbbd --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService/Internal/CoreAWSServiceClient.swift @@ -0,0 +1,52 @@ +import Foundation +import MongoSwift +import StitchCoreSDK + +public final class CoreAWSServiceClient { + private let service: CoreStitchServiceClient + + public init(withService service: CoreStitchServiceClient) { + self.service = service + } + + public func execute(request: AWSRequest, withRequestTimeout requestTimeout: TimeInterval? = nil) throws { + try service.callFunction( + withName: Field.executeAction.rawValue, + withArgs: [getRequestArgs(fromRequest: request)], + withRequestTimeout: requestTimeout + ) + } + + public func execute( + request: AWSRequest, + withRequestTimeout requestTimeout: TimeInterval? = nil + ) throws -> T { + return try service.callFunction( + withName: Field.executeAction.rawValue, + withArgs: [getRequestArgs(fromRequest: request)], + withRequestTimeout: requestTimeout + ) + } + + private func getRequestArgs(fromRequest request: AWSRequest) -> Document { + var args: Document = [ + Field.serviceParam.rawValue: request.service, + Field.actionParam.rawValue: request.action, + Field.argumentsParam.rawValue: request.arguments + ] + + if let region = request.region { + args[Field.regionParam.rawValue] = region + } + + return args + } + + private enum Field: String { + case executeAction = "execute" + case serviceParam = "aws_service" + case actionParam = "aws_action" + case regionParam = "aws_region" + case argumentsParam = "aws_arguments" + } +} diff --git a/Core/Services/StitchCoreAWSService/StitchCoreAWSService.podspec b/Core/Services/StitchCoreAWSService/StitchCoreAWSService.podspec new file mode 100644 index 00000000..73b57d05 --- /dev/null +++ b/Core/Services/StitchCoreAWSService/StitchCoreAWSService.podspec @@ -0,0 +1,32 @@ +Pod::Spec.new do |spec| + spec.name = File.basename(__FILE__, '.podspec') + spec.version = "4.0.3" + spec.summary = "#{__FILE__} Module" + spec.homepage = "https://github.com/mongodb/stitch-ios-sdk" + spec.license = "Apache2" + spec.authors = { + "Jason Flax" => "jason.flax@mongodb.com", + "Adam Chelminski" => "adam.chelminski@mongodb.com", + "Eric Daniels" => "eric.daniels@mongodb.com", + } + spec.source = { + :git => "https://github.com/mongodb/stitch-ios-sdk.git", + :branch => "master", + :tag => '4.0.3' + } + + spec.platform = :ios, "11.0" + spec.platform = :tvos, "10.2" + spec.platform = :watchos, "4.3" + spec.platform = :macos, "10.10" + + + spec.ios.deployment_target = "11.0" + spec.tvos.deployment_target = "10.2" + spec.watchos.deployment_target = "4.3" + spec.macos.deployment_target = "10.10" + + spec.source_files = "Core/Services/#{spec.name}/Sources/#{spec.name}/**/*.swift" + + spec.dependency 'StitchCoreSDK', '~> 4.0.3' +end diff --git a/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/AWSRequestUnitTests.swift b/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/AWSRequestUnitTests.swift new file mode 100644 index 00000000..2221e07f --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/AWSRequestUnitTests.swift @@ -0,0 +1,50 @@ +import XCTest +import MongoSwift +@testable import StitchCoreAWSService + +final class AWSRequestUnitTests: XCTestCase { + func testBuilder() throws { + // Require at a minimum service and action + XCTAssertThrowsError(try AWSRequestBuilder().build()) { error in + XCTAssertTrue(error is AWSRequestBuilderError) + } + + XCTAssertThrowsError(try AWSRequestBuilder().with(service: "ses").build()) { error in + XCTAssertTrue(error is AWSRequestBuilderError) + } + + XCTAssertThrowsError(try AWSRequestBuilder().with(action: "send").build()) { error in + XCTAssertTrue(error is AWSRequestBuilderError) + } + + // Minimum satisifed + let expectedService = "ses" + let expectedAction = "send" + + let request = try AWSRequestBuilder() + .with(service: expectedService) + .with(action: expectedAction) + .build() + + XCTAssertEqual(expectedService, request.service) + XCTAssertEqual(expectedAction, request.action) + XCTAssertNil(request.region) + XCTAssertEqual(0, request.arguments.count) + + // Full request + let expectedRegion = "us-east-1" + let expectedArgs: Document = ["hi": "hello"] + + let fullRequest = try AWSRequestBuilder() + .with(service: expectedService) + .with(action: expectedAction) + .with(region: expectedRegion) + .with(arguments: expectedArgs) + .build() + + XCTAssertEqual(expectedService, fullRequest.service) + XCTAssertEqual(expectedAction, fullRequest.action) + XCTAssertEqual(expectedRegion, fullRequest.region) + XCTAssertEqual(expectedArgs, fullRequest.arguments) + } +} diff --git a/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/CoreAWSServiceClientUnitTests.swift b/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/CoreAWSServiceClientUnitTests.swift new file mode 100644 index 00000000..d248f50e --- /dev/null +++ b/Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests/CoreAWSServiceClientUnitTests.swift @@ -0,0 +1,89 @@ +import XCTest +import MockUtils +import MongoSwift +import StitchCoreSDK +import StitchCoreSDKMocks +@testable import StitchCoreAWSService + +final class CoreAWSServiceClientUnitTests: XCTestCase { + func testExecute() throws { + let service = MockCoreStitchServiceClient() + let client = CoreAWSServiceClient(withService: service) + + let expectedService = "ses" + let expectedAction = "send" + let expectedRegion = "us-east-1" + let expectedArguments: Document = ["hi": "hello"] + + let request = try AWSRequestBuilder() + .with(service: expectedService) + .with(action: expectedAction) + .with(region: expectedRegion) + .with(arguments: expectedArguments) + .build() + + let response: Document = ["email": "sent"] + + service.callFunctionWithDecodingMock.doReturn( + result: response, + forArg1: .any, forArg2: .any, forArg3: .any + ) + + let result: Document = try client.execute(request: request) + + XCTAssertEqual(response, result) + + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! + + XCTAssertEqual("execute", funcNameArg) + XCTAssertEqual(1, funcArgsArg.count) + + let expectedArgs: Document = [ + "aws_service": expectedService, + "aws_action": expectedAction, + "aws_arguments": expectedArguments, + "aws_region": expectedRegion + ] + + XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) + + // second request + + let request2 = try AWSRequestBuilder() + .with(service: expectedService) + .with(action: expectedAction) + .build() + + let result2: Document = try client.execute(request: request2) + XCTAssertEqual(response, result2) + + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! + + XCTAssertEqual("execute", funcNameArg) + XCTAssertEqual(1, funcArgsArg.count) + + let expectedArgs2: Document = [ + "aws_service": expectedService, + "aws_action": expectedAction, + "aws_arguments": Document.init() + ] + + XCTAssertEqual(expectedArgs2, funcArgsArg[0] as? Document) + + // should pass along errors + service.callFunctionMock.doThrow( + error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), + forArg1: .any, + forArg2: .any, + forArg3: .any + ) + + do { + _ = try client.execute(request: request) + XCTFail("function did not fail where expected") + } catch { + // do nothing + } + + } +} diff --git a/Core/Services/StitchCoreFCMService/Sources/StitchCoreFCMService/Internal/CoreFCMServiceClient.swift b/Core/Services/StitchCoreFCMService/Sources/StitchCoreFCMService/Internal/CoreFCMServiceClient.swift index f7c664d1..c6f99a2f 100644 --- a/Core/Services/StitchCoreFCMService/Sources/StitchCoreFCMService/Internal/CoreFCMServiceClient.swift +++ b/Core/Services/StitchCoreFCMService/Sources/StitchCoreFCMService/Internal/CoreFCMServiceClient.swift @@ -41,7 +41,7 @@ public class CoreFCMServiceClient { targetTypeValue: T) throws -> FCMSendMessageResult { var args = try BsonEncoder().encode(request) args[targetTypeKey.rawValue] = targetTypeValue - return try self.service.callFunctionInternal( + return try self.service.callFunction( withName: CoreFCMServiceClient.sendAction, withArgs: [args], withRequestTimeout: nil diff --git a/Core/Services/StitchCoreFCMService/Tests/StitchCoreFCMServiceTests/Internal/CoreFCMServiceClientUnitTests.swift b/Core/Services/StitchCoreFCMService/Tests/StitchCoreFCMServiceTests/Internal/CoreFCMServiceClientUnitTests.swift index c7cf8411..8c4e9b42 100644 --- a/Core/Services/StitchCoreFCMService/Tests/StitchCoreFCMServiceTests/Internal/CoreFCMServiceClientUnitTests.swift +++ b/Core/Services/StitchCoreFCMService/Tests/StitchCoreFCMServiceTests/Internal/CoreFCMServiceClientUnitTests.swift @@ -90,7 +90,7 @@ final class CoreFCMServiceClientUnitTests: XCTestCase { let result = FCMSendMessageResult.init(successes: 4, failures: 2, failureDetails: failureDetails) - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: result, forArg1: .any, forArg2: .any, forArg3: .any ) @@ -100,7 +100,7 @@ final class CoreFCMServiceClientUnitTests: XCTestCase { let to = "who" XCTAssertEqual(result, try client.sendMessage(to: to, withRequest: fullRequest)) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -141,8 +141,8 @@ final class CoreFCMServiceClientUnitTests: XCTestCase { try client.sendMessage(toRegistrationTokens: registrationTokens, withRequest: fullRequest) ) - XCTAssertEqual(2, service.callFunctionInternalWithDecodingMock.capturedInvocations.count) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + XCTAssertEqual(2, service.callFunctionWithDecodingMock.capturedInvocations.count) + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -155,8 +155,8 @@ final class CoreFCMServiceClientUnitTests: XCTestCase { let userIDs = ["two", "three"] XCTAssertEqual(result, try client.sendMessage(toUserIDs: userIDs, withRequest: fullRequest)) - XCTAssertEqual(3, service.callFunctionInternalWithDecodingMock.capturedInvocations.count) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + XCTAssertEqual(3, service.callFunctionWithDecodingMock.capturedInvocations.count) + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -166,7 +166,7 @@ final class CoreFCMServiceClientUnitTests: XCTestCase { XCTAssertEqual(userIDsExpectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, forArg3: .any ) diff --git a/Core/Services/StitchCoreHTTPService/Sources/StitchCoreHTTPService/Internal/CoreHTTPServiceClient.swift b/Core/Services/StitchCoreHTTPService/Sources/StitchCoreHTTPService/Internal/CoreHTTPServiceClient.swift index d84cae67..ce41cf7a 100644 --- a/Core/Services/StitchCoreHTTPService/Sources/StitchCoreHTTPService/Internal/CoreHTTPServiceClient.swift +++ b/Core/Services/StitchCoreHTTPService/Sources/StitchCoreHTTPService/Internal/CoreHTTPServiceClient.swift @@ -49,7 +49,7 @@ public final class CoreHTTPServiceClient { throw StitchError.requestError(withError: error, withRequestErrorCode: .encodingError) } - return try service.callFunctionInternal( + return try service.callFunction( withName: request.method.rawValue, withArgs: [args], withRequestTimeout: timeout diff --git a/Core/Services/StitchCoreHTTPService/Tests/StitchCoreHTTPServiceTests/Internal/CoreHTTPServiceClientUnitTests.swift b/Core/Services/StitchCoreHTTPService/Tests/StitchCoreHTTPServiceTests/Internal/CoreHTTPServiceClientUnitTests.swift index a77b16e7..e4651cab 100644 --- a/Core/Services/StitchCoreHTTPService/Tests/StitchCoreHTTPServiceTests/Internal/CoreHTTPServiceClientUnitTests.swift +++ b/Core/Services/StitchCoreHTTPService/Tests/StitchCoreHTTPServiceTests/Internal/CoreHTTPServiceClientUnitTests.swift @@ -38,13 +38,13 @@ final class CoreHTTPServiceClientUnitTests: XCTestCase { body: "response body".data(using: .utf8) ) - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: response, forArg1: .any, forArg2: .any, forArg3: .any ) _ = try client.execute(request: request) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("delete", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -63,7 +63,7 @@ final class CoreHTTPServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, diff --git a/Core/Services/StitchCoreLocalMongoDBService/StitchCoreLocalMongoDBService.podspec b/Core/Services/StitchCoreLocalMongoDBService/StitchCoreLocalMongoDBService.podspec index bee538a1..02bcbdc3 100644 --- a/Core/Services/StitchCoreLocalMongoDBService/StitchCoreLocalMongoDBService.podspec +++ b/Core/Services/StitchCoreLocalMongoDBService/StitchCoreLocalMongoDBService.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = File.basename(__FILE__, '.podspec') - spec.version = "4.0.3" + spec.version = "4.0.0" spec.summary = "#{__FILE__} Module" spec.homepage = "https://github.com/mongodb/stitch-ios-sdk" spec.license = "Apache2" diff --git a/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoCollection.swift b/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoCollection.swift index 79ebde4e..54202972 100644 --- a/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoCollection.swift +++ b/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoCollection.swift @@ -132,7 +132,7 @@ public class CoreRemoteMongoCollection { args[RemoteCountOptionsKeys.limit.rawValue] = limit } - return try service.callFunctionInternal( + return try service.callFunction( withName: "count", withArgs: [args], withRequestTimeout: nil @@ -163,7 +163,7 @@ public class CoreRemoteMongoCollection { args["document"] = generateObjectIdIfMissing(try BsonEncoder().encode(value)) - return try service.callFunctionInternal( + return try service.callFunction( withName: "insertOne", withArgs: [args], withRequestTimeout: nil @@ -185,7 +185,7 @@ public class CoreRemoteMongoCollection { let encoder = BsonEncoder() args["documents"] = try documents.map { generateObjectIdIfMissing(try encoder.encode($0)) } - return try service.callFunctionInternal( + return try service.callFunction( withName: "insertMany", withArgs: [args], withRequestTimeout: nil @@ -222,7 +222,7 @@ public class CoreRemoteMongoCollection { var args = baseOperationArgs args["query"] = filter - return try service.callFunctionInternal( + return try service.callFunction( withName: multi ? "deleteMany" : "deleteOne", withArgs: [args], withRequestTimeout: nil @@ -284,7 +284,7 @@ public class CoreRemoteMongoCollection { args[RemoteUpdateOptionsKeys.upsert.rawValue] = upsert } - return try service.callFunctionInternal( + return try service.callFunction( withName: multi ? "updateMany" : "updateOne", withArgs: [args], withRequestTimeout: nil diff --git a/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoReadOperation.swift b/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoReadOperation.swift index d9528720..c0287796 100644 --- a/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoReadOperation.swift +++ b/Core/Services/StitchCoreRemoteMongoDBService/Sources/StitchCoreRemoteMongoDBService/Internal/CoreRemoteMongoReadOperation.swift @@ -40,7 +40,7 @@ public class CoreRemoteMongoReadOperation { } private func executeRead() throws -> [T] { - return try service.callFunctionInternal( + return try service.callFunction( withName: self.command, withArgs: [self.args], withRequestTimeout: nil diff --git a/Core/Services/StitchCoreRemoteMongoDBService/Tests/StitchCoreRemoteMongoDBServiceTests/CoreRemoteMongoCollectionUnitTests.swift b/Core/Services/StitchCoreRemoteMongoDBService/Tests/StitchCoreRemoteMongoDBServiceTests/CoreRemoteMongoCollectionUnitTests.swift index f6877cc3..eb82fba3 100644 --- a/Core/Services/StitchCoreRemoteMongoDBService/Tests/StitchCoreRemoteMongoDBServiceTests/CoreRemoteMongoCollectionUnitTests.swift +++ b/Core/Services/StitchCoreRemoteMongoDBService/Tests/StitchCoreRemoteMongoDBServiceTests/CoreRemoteMongoCollectionUnitTests.swift @@ -35,14 +35,14 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let client = CoreRemoteMongoClient.init(withService: service) let coll = TestUtils.getCollection(withClient: client) - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: 42, forArg1: .any, forArg2: .any, forArg3: .any ) // without filter or options XCTAssertEqual(42, try coll.count()) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("count", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -59,11 +59,11 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let expectedFilter: Document = ["one": Int32(23)] XCTAssertEqual(42, try coll.count(expectedFilter, options: RemoteCountOptions.init(limit: 5))) - XCTAssertTrue(service.callFunctionInternalWithDecodingMock + XCTAssertTrue(service.callFunctionWithDecodingMock .verify(numberOfInvocations: 2, forArg1: .any, forArg2: .any, forArg3: .any) ) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("count", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -78,7 +78,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -103,7 +103,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let docs = [doc1, doc2] - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: docs, forArg1: .any, forArg2: .any, forArg3: .any ) @@ -112,7 +112,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(docs, resultDocs) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("find", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -137,11 +137,11 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(docs, resultDocs) - XCTAssertTrue(service.callFunctionInternalWithDecodingMock + XCTAssertTrue(service.callFunctionWithDecodingMock .verify(numberOfInvocations: 2, forArg1: .any, forArg2: .any, forArg3: .any) ) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("find", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -157,7 +157,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -182,7 +182,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let docs = [doc1, doc2] - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: docs, forArg1: .any, forArg2: .any, forArg3: .any ) @@ -191,7 +191,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(docs, resultDocs) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("aggregate", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -214,11 +214,11 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(docs, resultDocs) - XCTAssertTrue(service.callFunctionInternalWithDecodingMock + XCTAssertTrue(service.callFunctionWithDecodingMock .verify(numberOfInvocations: 2, forArg1: .any, forArg2: .any, forArg3: .any) ) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("aggregate", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -232,7 +232,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -255,7 +255,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let id = ObjectId() let doc1: Document = ["_id": id, "one": 2] - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteInsertOneResult.init(insertedId: id), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -265,7 +265,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(id, result.insertedId as? ObjectId) XCTAssertEqual(id, doc1["_id"] as? ObjectId) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("insertOne", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -280,12 +280,12 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { // object id should be generated if no _id was provided _ = try coll.insertOne(["hello": "world"]) - (_, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (_, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertNotNil(((funcArgsArg[0] as? Document)!["document"] as? Document)!["_id"] as? ObjectId) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -313,7 +313,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let ids: [Int64: BsonValue] = [Int64(0): id1, Int64(1): id2] - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteInsertManyResult.init(fromArray: [id1, id2]), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -326,7 +326,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(result.insertedIds[Int64(0)] as? ObjectId, doc1["_id"] as? ObjectId) XCTAssertEqual(result.insertedIds[Int64(1)] as? ObjectId, doc2["_id"] as? ObjectId) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("insertMany", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -341,12 +341,12 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { // object ids should be generated if no _id was provided _ = try coll.insertMany([["hello": "world"], ["goodbye": "world"]]) - (_, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (_, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertNotNil(((funcArgsArg[0] as? Document)!["documents"] as? [Document])![0]["_id"] as? ObjectId) XCTAssertNotNil(((funcArgsArg[0] as? Document)!["documents"] as? [Document])![1]["_id"] as? ObjectId) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -366,7 +366,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let client = CoreRemoteMongoClient.init(withService: service) let coll = TestUtils.getCollection(withClient: client) - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteDeleteResult.init(deletedCount: 1), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -376,7 +376,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let result = try coll.deleteOne(expectedFilter) XCTAssertEqual(1, result.deletedCount) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("deleteOne", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -390,7 +390,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -410,7 +410,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let client = CoreRemoteMongoClient.init(withService: service) let coll = TestUtils.getCollection(withClient: client) - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteDeleteResult.init(deletedCount: 1), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -420,7 +420,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let result = try coll.deleteMany(expectedFilter) XCTAssertEqual(1, result.deletedCount) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + let (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("deleteMany", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -434,7 +434,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -456,7 +456,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let id = ObjectId() - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteUpdateResult.init(matchedCount: 1, modifiedCount: 1, upsertedId: id), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -471,7 +471,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(1, result.modifiedCount) XCTAssertEqual(id, result.upsertedId as? ObjectId) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("updateOne", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -496,11 +496,11 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(1, result.modifiedCount) XCTAssertEqual(id, result.upsertedId as? ObjectId) - XCTAssertTrue(service.callFunctionInternalWithDecodingMock + XCTAssertTrue(service.callFunctionWithDecodingMock .verify(numberOfInvocations: 2, forArg1: .any, forArg2: .any, forArg3: .any) ) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("updateOne", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -516,7 +516,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -538,7 +538,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { let id = ObjectId() - service.callFunctionInternalWithDecodingMock.doReturn( + service.callFunctionWithDecodingMock.doReturn( result: RemoteUpdateResult.init(matchedCount: 1, modifiedCount: 1, upsertedId: id), forArg1: .any, forArg2: .any, forArg3: .any ) @@ -553,7 +553,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(1, result.modifiedCount) XCTAssertEqual(id, result.upsertedId as? ObjectId) - var (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + var (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("updateMany", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -578,11 +578,11 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(1, result.modifiedCount) XCTAssertEqual(id, result.upsertedId as? ObjectId) - XCTAssertTrue(service.callFunctionInternalWithDecodingMock + XCTAssertTrue(service.callFunctionWithDecodingMock .verify(numberOfInvocations: 2, forArg1: .any, forArg2: .any, forArg3: .any) ) - (funcNameArg, funcArgsArg, _) = service.callFunctionInternalWithDecodingMock.capturedInvocations.last! + (funcNameArg, funcArgsArg, _) = service.callFunctionWithDecodingMock.capturedInvocations.last! XCTAssertEqual("updateMany", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -598,7 +598,7 @@ final class CoreRemoteMongoCollectionUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalWithDecodingMock.doThrow( + service.callFunctionWithDecodingMock.doThrow( error: StitchError.serviceError(withMessage: "whoops", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, diff --git a/Core/Services/StitchCoreTwilioService/Sources/StitchCoreTwilioService/CoreTwilioServiceClient.swift b/Core/Services/StitchCoreTwilioService/Sources/StitchCoreTwilioService/CoreTwilioServiceClient.swift index 8732f0ec..c386e6b5 100644 --- a/Core/Services/StitchCoreTwilioService/Sources/StitchCoreTwilioService/CoreTwilioServiceClient.swift +++ b/Core/Services/StitchCoreTwilioService/Sources/StitchCoreTwilioService/CoreTwilioServiceClient.swift @@ -25,6 +25,6 @@ public final class CoreTwilioServiceClient { args["mediaUrl"] = mediaURL } - try self.service.callFunctionInternal(withName: "send", withArgs: [args], withRequestTimeout: nil) + try self.service.callFunction(withName: "send", withArgs: [args], withRequestTimeout: nil) } } diff --git a/Core/Services/StitchCoreTwilioService/Tests/StitchCoreTwilioServiceTests/CoreTwilioServiceClientUnitTests.swift b/Core/Services/StitchCoreTwilioService/Tests/StitchCoreTwilioServiceTests/CoreTwilioServiceClientUnitTests.swift index 63e63f34..43a4f985 100644 --- a/Core/Services/StitchCoreTwilioService/Tests/StitchCoreTwilioServiceTests/CoreTwilioServiceClientUnitTests.swift +++ b/Core/Services/StitchCoreTwilioService/Tests/StitchCoreTwilioServiceTests/CoreTwilioServiceClientUnitTests.swift @@ -15,7 +15,7 @@ class CoreTwilioServiceClientUnitTests: XCTestCase { try client.sendMessage(to: to, from: from, body: body) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalMock.capturedInvocations.first! + let (funcNameArg, funcArgsArg, _) = service.callFunctionMock.capturedInvocations.first! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -25,7 +25,7 @@ class CoreTwilioServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalMock.doThrow( + service.callFunctionMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, @@ -51,7 +51,7 @@ class CoreTwilioServiceClientUnitTests: XCTestCase { try client.sendMessage(to: to, from: from, body: body, mediaURL: mediaURL) - let (funcNameArg, funcArgsArg, _) = service.callFunctionInternalMock.capturedInvocations.first! + let (funcNameArg, funcArgsArg, _) = service.callFunctionMock.capturedInvocations.first! XCTAssertEqual("send", funcNameArg) XCTAssertEqual(1, funcArgsArg.count) @@ -61,7 +61,7 @@ class CoreTwilioServiceClientUnitTests: XCTestCase { XCTAssertEqual(expectedArgs, funcArgsArg[0] as? Document) // should pass along errors - service.callFunctionInternalMock.doThrow( + service.callFunctionMock.doThrow( error: StitchError.serviceError(withMessage: "", withServiceErrorCode: .unknown), forArg1: .any, forArg2: .any, diff --git a/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/Rules/RulesResources.swift b/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/Rules/RulesResources.swift index 0bf9c03d..3a710511 100644 --- a/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/Rules/RulesResources.swift +++ b/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/Rules/RulesResources.swift @@ -64,6 +64,17 @@ public class RuleCreatorMongoDb: Encodable { } } +// Allowed actions for an AWS service rule +private struct AWSRuleActions: Encodable { + let actions: [String] + + func encode(to encoder: Encoder) throws { + var container = encoder.unkeyedContainer() + for action in actions { + try container.encode(action) + } + } +} /// Allowed actions for an AWS S3 service rule private struct AWSS3RuleActions: RuleActions { @@ -100,6 +111,8 @@ public enum RuleActionsCreator: Encodable { case http(get: Bool, post: Bool, put: Bool, delete: Bool, patch: Bool, head: Bool) /// - parameter send: allow message sending case twilio(send: Bool) + /// - parameter actions: specify allowed AWS actions + case aws(actions: [String]) /// - parameter putObject: allow object putting, signPolicy: allow policy signing case awsS3(put: Bool, signPolicy: Bool) /// - parameter send: allow message sending @@ -119,6 +132,8 @@ public enum RuleActionsCreator: Encodable { head: head).encode(to: encoder) case .twilio(let send): try TwilioRuleActions.init(send: send).encode(to: encoder) + case .aws(let actions): + try AWSRuleActions.init(actions: actions).encode(to: encoder) case .awsS3(let put, let signPolicy): try AWSS3RuleActions.init(put: put, signPolicy: signPolicy).encode(to: encoder) case .awsSes(let send): @@ -129,8 +144,6 @@ public enum RuleActionsCreator: Encodable { } } - - public struct RuleResponse: Codable { init() { fatalError("RuleView not implemented") diff --git a/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/ServiceConfigs.swift b/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/ServiceConfigs.swift index cea3abc3..203e497b 100644 --- a/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/ServiceConfigs.swift +++ b/Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient/Services/ServiceConfigs.swift @@ -27,6 +27,24 @@ private struct ServiceConfigWrapper: Encodable { private struct HTTPServiceConfig: ServiceConfig { } +/// Configuration for an AWS service +private struct AWSServiceConfig: ServiceConfig { + /// your access key identifier + private let accessKeyID: String + /// your secret access key + private let secretAccessKey: String + + fileprivate init(accessKeyID: String, + secretAccessKey: String) { + self.accessKeyID = accessKeyID + self.secretAccessKey = secretAccessKey + } + + internal enum CodingKeys: String, CodingKey { + case accessKeyID = "accessKeyId", secretAccessKey + } +} + /// Configuration for an AWS S3 service private struct AWSS3ServiceConfig: ServiceConfig { /// aws region @@ -128,6 +146,12 @@ public enum ServiceConfigs: Encodable { /// - parameter name: name of this service case http(name: String) + /// configure an AWS service + /// - parameter name: name of this service + /// - parameter accessKeyID: your access key identifier + /// - parameter secretAccessKey: your secret access key + case aws(name: String, accessKeyID: String, secretAccessKey: String) + /// configure an AWS S3 service /// - parameter name: name of this service /// - parameter region: aws region @@ -168,13 +192,20 @@ public enum ServiceConfigs: Encodable { type: "http", config: HTTPServiceConfig.init() ).encode(to: encoder) + case .aws(let name, let accessKeyID, let secretAccessKey): + try ServiceConfigWrapper.init( + name: name, + type: "aws", + config: AWSServiceConfig.init(accessKeyID: accessKeyID, + secretAccessKey: secretAccessKey) + ).encode(to: encoder) case .awsS3(let name, let region, let accessKeyID, let secretAccessKey): try ServiceConfigWrapper.init( name: name, type: "aws-s3", - config: AWSSESServiceConfig.init(region: region, - accessKeyID: accessKeyID, - secretAccessKey: secretAccessKey) + config: AWSS3ServiceConfig.init(region: region, + accessKeyID: accessKeyID, + secretAccessKey: secretAccessKey) ).encode(to: encoder) case .awsSes(let name, let region, let accessKeyID, let secretAccessKey): try ServiceConfigWrapper.init( diff --git a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Internal/CoreStitchAppClient.swift b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Internal/CoreStitchAppClient.swift index 48876919..8e43da5d 100644 --- a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Internal/CoreStitchAppClient.swift +++ b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Internal/CoreStitchAppClient.swift @@ -30,10 +30,10 @@ public final class CoreStitchAppClient { * Performs a request against the Stitch server to call a function in the Stitch application. Takes the function * name and arguments as parameters. */ - public func callFunctionInternal(withName name: String, + public func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval? = nil) throws { - try self.functionService.callFunctionInternal(withName: name, + try self.functionService.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) } @@ -44,10 +44,10 @@ public final class CoreStitchAppClient { * * - returns: A `T` representing the decoded JSON of the result of the function call. */ - public func callFunctionInternal(withName name: String, + public func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval? = nil) throws -> T { - return try self.functionService.callFunctionInternal(withName: name, + return try self.functionService.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) } diff --git a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClient.swift b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClient.swift index 94f607c0..80006096 100644 --- a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClient.swift +++ b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClient.swift @@ -6,7 +6,7 @@ import Foundation * Stitch service. */ public protocol CoreStitchServiceClient { - func callFunctionInternal(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval?) throws + func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval?) throws - func callFunctionInternal(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval?) throws -> T + func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval?) throws -> T } diff --git a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClientImpl.swift b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClientImpl.swift index c166e784..806bebe9 100644 --- a/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClientImpl.swift +++ b/Core/StitchCoreSDK/Sources/StitchCoreSDK/Services/Internal/CoreStitchServiceClientImpl.swift @@ -39,9 +39,9 @@ open class CoreStitchServiceClientImpl: CoreStitchServiceClient { return try reqBuilder.build() } - public func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout timeout: TimeInterval? = nil) throws { + public func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout timeout: TimeInterval? = nil) throws { // Coerce the `Response` return type so response decoding is not attempted. let _: Response = try requestClient.doAuthenticatedRequest( getCallServiceFunctionRequest(withName: name, @@ -49,9 +49,9 @@ open class CoreStitchServiceClientImpl: CoreStitchServiceClient { withTimeout: timeout)) } - public func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout timeout: TimeInterval? = nil) throws -> T { + public func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout timeout: TimeInterval? = nil) throws -> T { return try requestClient.doAuthenticatedRequest( getCallServiceFunctionRequest(withName: name, withArgs: args, diff --git a/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/MockCoreStitchServiceClient.swift b/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/MockCoreStitchServiceClient.swift index f1814417..15828d5e 100644 --- a/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/MockCoreStitchServiceClient.swift +++ b/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/MockCoreStitchServiceClient.swift @@ -5,19 +5,19 @@ import MockUtils public final class MockCoreStitchServiceClient: CoreStitchServiceClient { public init() { } - public var callFunctionInternalMock = FunctionMockUnitThreeArgs() - public func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout requestTimeout: TimeInterval?) throws { - return try callFunctionInternalMock.throwingRun(arg1: name, arg2: args, arg3: requestTimeout) + public var callFunctionMock = FunctionMockUnitThreeArgs() + public func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout requestTimeout: TimeInterval?) throws { + return try callFunctionMock.throwingRun(arg1: name, arg2: args, arg3: requestTimeout) } - public var callFunctionInternalWithDecodingMock = + public var callFunctionWithDecodingMock = FunctionMockUnitThreeArgs() - public func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout requestTimeout: TimeInterval?) throws -> T where T : Decodable { - if let result = try callFunctionInternalWithDecodingMock.throwingRun(arg1: name, arg2: args, arg3: requestTimeout) as? T { + public func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout requestTimeout: TimeInterval?) throws -> T where T : Decodable { + if let result = try callFunctionWithDecodingMock.throwingRun(arg1: name, arg2: args, arg3: requestTimeout) as? T { return result } else { fatalError("Returning incorrect type from mocked result") diff --git a/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/SpyCoreStitchServiceClient.swift b/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/SpyCoreStitchServiceClient.swift index c0a3e914..e5b259dd 100644 --- a/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/SpyCoreStitchServiceClient.swift +++ b/Core/StitchCoreSDK/Sources/StitchCoreSDKMocks/Services/SpyCoreStitchServiceClient.swift @@ -5,25 +5,25 @@ import MockUtils public final class SpyCoreStitchServiceClient: CoreStitchServiceClientImpl { public override init(requestClient: StitchAuthRequestClient, - routes: StitchServiceRoutes, - serviceName: String?) { + routes: StitchServiceRoutes, + serviceName: String?) { super.init(requestClient: requestClient, routes: routes, serviceName: serviceName) } - public var callFunctionInternalSpy = FunctionSpyUnitThreeArgs() - public override func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout requestTimeout: TimeInterval?) throws { - callFunctionInternalSpy.run(arg1: name, arg2: args, arg3: requestTimeout) - return try super.callFunctionInternal(withName: name, withArgs: args, withRequestTimeout: requestTimeout) + public var callFunctionSpy = FunctionSpyUnitThreeArgs() + public override func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout requestTimeout: TimeInterval?) throws { + callFunctionSpy.run(arg1: name, arg2: args, arg3: requestTimeout) + return try super.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) } - public var callFunctionInternalWithDecodingSpy = + public var callFunctionWithDecodingSpy = FunctionSpyUnitThreeArgs() - public override func callFunctionInternal(withName name: String, - withArgs args: [BsonValue], - withRequestTimeout requestTimeout: TimeInterval?) + public override func callFunction(withName name: String, + withArgs args: [BsonValue], + withRequestTimeout requestTimeout: TimeInterval?) throws -> T where T : Decodable { - callFunctionInternalWithDecodingSpy.run(arg1: name, arg2: args, arg3: requestTimeout) - return try super.callFunctionInternal(withName: name, withArgs: args, withRequestTimeout: requestTimeout) + callFunctionWithDecodingSpy.run(arg1: name, arg2: args, arg3: requestTimeout) + return try super.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) } } diff --git a/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Internal/Net/FoundationHTTPTransportUnitTests.swift b/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Internal/Net/FoundationHTTPTransportUnitTests.swift index 3be49ce3..9678b721 100644 --- a/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Internal/Net/FoundationHTTPTransportUnitTests.swift +++ b/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Internal/Net/FoundationHTTPTransportUnitTests.swift @@ -47,7 +47,7 @@ class FoundationHTTPTransportUnitTests: StitchXCTestCase { ) { error in XCTAssertEqual(error.localizedDescription, "unsupported URL") } - + builder.with(url: "\(self.baseURL)\(self.getEndpoint)") var response = try transport.roundTrip(request: builder.build()) @@ -70,7 +70,7 @@ class FoundationHTTPTransportUnitTests: StitchXCTestCase { XCTAssertEqual(response.statusCode, 400) builder.with(url: "http://localhost:9000/notreal") - + XCTAssertThrowsError( try transport.roundTrip(request: builder.build()) ) { error in diff --git a/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Services/Internal/CoreStitchServiceClientUnitTests.swift b/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Services/Internal/CoreStitchServiceClientUnitTests.swift index d15d3745..ef7b5193 100644 --- a/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Services/Internal/CoreStitchServiceClientUnitTests.swift +++ b/Core/StitchCoreSDK/Tests/StitchCoreSDKTests/Services/Internal/CoreStitchServiceClientUnitTests.swift @@ -15,7 +15,7 @@ private let expectedDoc: Document = [ class CoreStitchServiceClientUnitTests: XCTestCase { - func testCallFunctionInternal() throws { + func testCallFunction() throws { let serviceName = "svc1" let routes = StitchAppRoutes.init(clientAppID: "foo").serviceRoutes let requestClient = MockStitchAuthRequestClient() @@ -32,7 +32,7 @@ class CoreStitchServiceClientUnitTests: XCTestCase { let args = [1, 2, 3] let expectedRequestDoc: Document = ["name": funcName, "arguments": args, "service": serviceName] - XCTAssertEqual(42, try coreStitchService.callFunctionInternal(withName: funcName, withArgs: args)) + XCTAssertEqual(42, try coreStitchService.callFunction(withName: funcName, withArgs: args)) let functionCallRequest = requestClient.doAuthenticatedRequestWithDecodingMock.capturedInvocations[0] as? StitchAuthDocRequest diff --git a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service.xcodeproj/project.pbxproj b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service.xcodeproj/project.pbxproj index 0824c218..557a7031 100644 --- a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service.xcodeproj/project.pbxproj +++ b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service.xcodeproj/project.pbxproj @@ -74,7 +74,7 @@ 494C21D220ED7B3D00A26734 /* libmongoc.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = libmongoc.framework; path = ../../../Frameworks/macos/libmongoc.framework; sourceTree = ""; }; 494C21D420ED7B4200A26734 /* MongoSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MongoSwift.framework; path = ../../../Frameworks/macos/MongoSwift.framework; sourceTree = ""; }; 494C21D820ED825400A26734 /* StitchDarwinCoreTestUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StitchDarwinCoreTestUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - F4E33AED20DECDD8003DE41C /* AWSS3ServiceTestsContants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWSS3ServiceTestsContants.h; sourceTree = ""; }; + F4E33AED20DECDD8003DE41C /* AWSS3ServiceTestsConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWSS3ServiceTestsConstants.h; sourceTree = ""; }; F587472A83DBC77E5D5D487C /* MongoSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MongoSwift.framework; path = "/Users/jasonflax/Development/stitch-ios-sdk/Frameworks/ios/MongoSwift.framework"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -136,7 +136,7 @@ isa = PBXGroup; children = ( 11405A8220C5A01E0041105B /* AWSS3ServiceClientIntTests.swift */, - F4E33AED20DECDD8003DE41C /* AWSS3ServiceTestsContants.h */, + F4E33AED20DECDD8003DE41C /* AWSS3ServiceTestsConstants.h */, 11405A8420C5A01E0041105B /* Info.plist */, ); path = StitchAWSS3ServiceTests; @@ -537,7 +537,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSS3ServiceTests; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; - SWIFT_OBJC_BRIDGING_HEADER = StitchAWSS3ServiceTests/AWSS3ServiceTestsContants.h; + SWIFT_OBJC_BRIDGING_HEADER = StitchAWSS3ServiceTests/AWSS3ServiceTestsConstants.h; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -565,7 +565,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSS3ServiceTests; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; - SWIFT_OBJC_BRIDGING_HEADER = StitchAWSS3ServiceTests/AWSS3ServiceTestsContants.h; + SWIFT_OBJC_BRIDGING_HEADER = StitchAWSS3ServiceTests/AWSS3ServiceTestsConstants.h; SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; diff --git a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/AWSS3ServiceClient.swift b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/AWSS3ServiceClient.swift index 5823c7b7..fc6415c9 100644 --- a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/AWSS3ServiceClient.swift +++ b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/AWSS3ServiceClient.swift @@ -7,7 +7,7 @@ import StitchCoreAWSS3Service private final class AWSS3NamedServiceClientFactory: NamedServiceClientFactory { typealias ClientType = AWSS3ServiceClient - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> AWSS3ServiceClient { return AWSS3ServiceClientImpl( withClient: CoreAWSS3ServiceClient.init(withService: serviceClient), @@ -20,12 +20,15 @@ private final class AWSS3NamedServiceClientFactory: NamedServiceClientFactory { * Global factory const which can be used to create an `AWSS3ServiceClient` with a `StitchAppClient`. Pass into * `StitchAppClient.serviceClient(fromFactory:withName)` to get an `AWSS3ServiceClient. */ +@available(*, deprecated, message: "Use awsServiceClientFactory instead") public let awsS3ServiceClientFactory = AnyNamedServiceClientFactory(factory: AWSS3NamedServiceClientFactory()) /** * The AWS S3 service client, which can be used to interact with AWS Simple Storage Service (S3) via MongoDB Stitch. + * This client is deprecated. Use the AWSServiceClient in StitchAWSService. */ +@available(*, deprecated, message: "Use AWSServiceClient instead") public protocol AWSS3ServiceClient { /** * Puts an object into an AWS S3 bucket as a string. diff --git a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/Internal/AWSS3ServiceClientImpl.swift b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/Internal/AWSS3ServiceClientImpl.swift index f317b52f..06da7586 100644 --- a/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/Internal/AWSS3ServiceClientImpl.swift +++ b/Darwin/Services/StitchAWSS3Service/StitchAWSS3Service/Internal/AWSS3ServiceClientImpl.swift @@ -4,6 +4,7 @@ import StitchCore import StitchCoreSDK import StitchCoreAWSS3Service +@available(*, deprecated, message: "Use AWSServiceClient instead") public final class AWSS3ServiceClientImpl: AWSS3ServiceClient { private let proxy: CoreAWSS3ServiceClient private let dispatcher: OperationDispatcher diff --git a/Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests/AWSS3ServiceTestsContants.h b/Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests/AWSS3ServiceTestsConstants.h similarity index 100% rename from Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests/AWSS3ServiceTestsContants.h rename to Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests/AWSS3ServiceTestsConstants.h diff --git a/Darwin/Services/StitchAWSSESService/StitchAWSSESService/AWSSESServiceClient.swift b/Darwin/Services/StitchAWSSESService/StitchAWSSESService/AWSSESServiceClient.swift index 9a78ec32..1b3cee3c 100644 --- a/Darwin/Services/StitchAWSSESService/StitchAWSSESService/AWSSESServiceClient.swift +++ b/Darwin/Services/StitchAWSSESService/StitchAWSSESService/AWSSESServiceClient.swift @@ -6,7 +6,7 @@ import StitchCoreSDK private final class AWSSESNamedServiceClientFactory: NamedServiceClientFactory { typealias ClientType = AWSSESServiceClient - func client(withServiceClient service: StitchServiceClient, + func client(withServiceClient service: CoreStitchServiceClient, withClientInfo client: StitchAppClientInfo) -> AWSSESServiceClient { return AWSSESServiceClientImpl( withClient: CoreAWSSESServiceClient.init(withService: service), @@ -19,12 +19,15 @@ private final class AWSSESNamedServiceClientFactory: NamedServiceClientFactory { * Global factory const which can be used to create an `AWSSESServiceClient` with a `StitchAppClient`. Pass into * `StitchAppClient.serviceClient(fromFactory:withName)` to get an `AWSSESServiceClient. */ +@available(*, deprecated, message: "Use awsServiceClientFactory instead") public let awsSESServiceClientFactory = AnyNamedServiceClientFactory(factory: AWSSESNamedServiceClientFactory()) /** * The AWS SES service client, which can be used to interact with AWS Simple Email Service (SES) via MongoDB Stitch. + * This client is deprecated. Use the AWSServiceClient in StitchAWSService. */ +@available(*, deprecated, message: "Use AWSServiceClient instead") public protocol AWSSESServiceClient { /** * Sends an email. diff --git a/Darwin/Services/StitchAWSSESService/StitchAWSSESService/Internal/AWSSESServiceClientImpl.swift b/Darwin/Services/StitchAWSSESService/StitchAWSSESService/Internal/AWSSESServiceClientImpl.swift index 16af1d5e..64ef9d45 100644 --- a/Darwin/Services/StitchAWSSESService/StitchAWSSESService/Internal/AWSSESServiceClientImpl.swift +++ b/Darwin/Services/StitchAWSSESService/StitchAWSSESService/Internal/AWSSESServiceClientImpl.swift @@ -3,6 +3,7 @@ import StitchCore import StitchCoreSDK import StitchCoreAWSSESService +@available(*, deprecated, message: "Use AWSServiceClient instead") public final class AWSSESServiceClientImpl: AWSSESServiceClient { private let proxy: CoreAWSSESServiceClient private let dispatcher: OperationDispatcher diff --git a/Darwin/Services/StitchAWSService/StitchAWSService.podspec b/Darwin/Services/StitchAWSService/StitchAWSService.podspec new file mode 100644 index 00000000..c70f9e4f --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService.podspec @@ -0,0 +1,33 @@ +Pod::Spec.new do |spec| + spec.name = File.basename(__FILE__, '.podspec') + spec.version = "4.0.3" + spec.summary = "#{__FILE__} Module" + spec.homepage = "https://github.com/mongodb/stitch-ios-sdk" + spec.license = "Apache2" + spec.authors = { + "Jason Flax" => "jason.flax@mongodb.com", + "Adam Chelminski" => "adam.chelminski@mongodb.com", + "Eric Daniels" => "eric.daniels@mongodb.com", + } + spec.source = { + :git => "https://github.com/mongodb/stitch-ios-sdk.git", + :branch => "master", + :tag => '4.0.3' + } + + spec.platform = :ios, "11.0" + spec.platform = :tvos, "10.2" + spec.platform = :watchos, "4.3" + spec.platform = :macos, "10.10" + + + spec.ios.deployment_target = "11.0" + spec.tvos.deployment_target = "10.2" + spec.watchos.deployment_target = "4.3" + spec.macos.deployment_target = "10.10" + + spec.source_files = "Darwin/Services/#{spec.name}/#{spec.name}/**/*.swift" + + spec.dependency 'StitchCore', '~> 4.0.3' + spec.dependency 'StitchCoreAWSService', '~> 4.0.3' +end diff --git a/Darwin/Services/StitchAWSService/StitchAWSService.xcodeproj/project.pbxproj b/Darwin/Services/StitchAWSService/StitchAWSService.xcodeproj/project.pbxproj new file mode 100644 index 00000000..137d3317 --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService.xcodeproj/project.pbxproj @@ -0,0 +1,548 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + 11B54E1A211248D80009E0F0 /* StitchAWSService.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11B54E10211248D80009E0F0 /* StitchAWSService.framework */; }; + 11B54E1F211248D80009E0F0 /* AWSServiceClientIntTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11B54E1E211248D80009E0F0 /* AWSServiceClientIntTests.swift */; }; + 11FCDBD82112566100894377 /* StitchCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11FCDBD72112566100894377 /* StitchCore.framework */; }; + 11FCDBDA2112566600894377 /* StitchCoreAWSService.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11FCDBD92112566600894377 /* StitchCoreAWSService.framework */; }; + 11FCDBDD2112584000894377 /* StitchDarwinCoreTestUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11FCDBDC2112584000894377 /* StitchDarwinCoreTestUtils.framework */; }; + 11FCDBDF2112584900894377 /* StitchCoreTestUtils.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 11FCDBDE2112584900894377 /* StitchCoreTestUtils.framework */; }; + 11FCDC33211263E200894377 /* AWSServiceClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11FCDC32211263E200894377 /* AWSServiceClient.swift */; }; + 11FCDC352112640400894377 /* AWSServiceClientImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11FCDC342112640400894377 /* AWSServiceClientImpl.swift */; }; + 11FCDC372112643600894377 /* StitchAWSServiceExports.swift in Sources */ = {isa = PBXBuildFile; fileRef = 11FCDC362112643600894377 /* StitchAWSServiceExports.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 11B54E1B211248D80009E0F0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 11B54E07211248D80009E0F0 /* Project object */; + proxyType = 1; + remoteGlobalIDString = 11B54E0F211248D80009E0F0; + remoteInfo = StitchAWSService; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 11B54E10211248D80009E0F0 /* StitchAWSService.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StitchAWSService.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 11B54E14211248D80009E0F0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 11B54E19211248D80009E0F0 /* StitchAWSServiceTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = StitchAWSServiceTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; + 11B54E1E211248D80009E0F0 /* AWSServiceClientIntTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSServiceClientIntTests.swift; sourceTree = ""; }; + 11B54E20211248D80009E0F0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 11FCDBD72112566100894377 /* StitchCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StitchCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 11FCDBD92112566600894377 /* StitchCoreAWSService.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StitchCoreAWSService.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 11FCDBDB2112581400894377 /* AWSServiceTestsConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWSServiceTestsConstants.h; sourceTree = ""; }; + 11FCDBDC2112584000894377 /* StitchDarwinCoreTestUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StitchDarwinCoreTestUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 11FCDBDE2112584900894377 /* StitchCoreTestUtils.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = StitchCoreTestUtils.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 11FCDC32211263E200894377 /* AWSServiceClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSServiceClient.swift; sourceTree = ""; }; + 11FCDC342112640400894377 /* AWSServiceClientImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSServiceClientImpl.swift; sourceTree = ""; }; + 11FCDC362112643600894377 /* StitchAWSServiceExports.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StitchAWSServiceExports.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 11B54E0C211248D80009E0F0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 11FCDBD82112566100894377 /* StitchCore.framework in Frameworks */, + 11FCDBDA2112566600894377 /* StitchCoreAWSService.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 11B54E16211248D80009E0F0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 11FCDBDD2112584000894377 /* StitchDarwinCoreTestUtils.framework in Frameworks */, + 11FCDBDF2112584900894377 /* StitchCoreTestUtils.framework in Frameworks */, + 11B54E1A211248D80009E0F0 /* StitchAWSService.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 11B54E06211248D80009E0F0 = { + isa = PBXGroup; + children = ( + 11B54E12211248D80009E0F0 /* StitchAWSService */, + 11B54E1D211248D80009E0F0 /* StitchAWSServiceTests */, + 11B54E11211248D80009E0F0 /* Products */, + 11FCDBD62112566100894377 /* Frameworks */, + ); + sourceTree = ""; + }; + 11B54E11211248D80009E0F0 /* Products */ = { + isa = PBXGroup; + children = ( + 11B54E10211248D80009E0F0 /* StitchAWSService.framework */, + 11B54E19211248D80009E0F0 /* StitchAWSServiceTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; + 11B54E12211248D80009E0F0 /* StitchAWSService */ = { + isa = PBXGroup; + children = ( + 11FCDC31211263CA00894377 /* Internal */, + 11FCDC32211263E200894377 /* AWSServiceClient.swift */, + 11FCDC362112643600894377 /* StitchAWSServiceExports.swift */, + 11B54E14211248D80009E0F0 /* Info.plist */, + ); + path = StitchAWSService; + sourceTree = ""; + }; + 11B54E1D211248D80009E0F0 /* StitchAWSServiceTests */ = { + isa = PBXGroup; + children = ( + 11B54E1E211248D80009E0F0 /* AWSServiceClientIntTests.swift */, + 11B54E20211248D80009E0F0 /* Info.plist */, + 11FCDBDB2112581400894377 /* AWSServiceTestsConstants.h */, + ); + path = StitchAWSServiceTests; + sourceTree = ""; + }; + 11FCDBD62112566100894377 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 11FCDBDE2112584900894377 /* StitchCoreTestUtils.framework */, + 11FCDBDC2112584000894377 /* StitchDarwinCoreTestUtils.framework */, + 11FCDBD92112566600894377 /* StitchCoreAWSService.framework */, + 11FCDBD72112566100894377 /* StitchCore.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 11FCDC31211263CA00894377 /* Internal */ = { + isa = PBXGroup; + children = ( + 11FCDC342112640400894377 /* AWSServiceClientImpl.swift */, + ); + path = Internal; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 11B54E0D211248D80009E0F0 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 11B54E0F211248D80009E0F0 /* StitchAWSService */ = { + isa = PBXNativeTarget; + buildConfigurationList = 11B54E24211248D80009E0F0 /* Build configuration list for PBXNativeTarget "StitchAWSService" */; + buildPhases = ( + 11B54E0B211248D80009E0F0 /* Sources */, + 11B54E0C211248D80009E0F0 /* Frameworks */, + 11B54E0D211248D80009E0F0 /* Headers */, + 11B54E0E211248D80009E0F0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = StitchAWSService; + productName = StitchAWSService; + productReference = 11B54E10211248D80009E0F0 /* StitchAWSService.framework */; + productType = "com.apple.product-type.framework"; + }; + 11B54E18211248D80009E0F0 /* StitchAWSServiceTests */ = { + isa = PBXNativeTarget; + buildConfigurationList = 11B54E27211248D80009E0F0 /* Build configuration list for PBXNativeTarget "StitchAWSServiceTests" */; + buildPhases = ( + 11B54E15211248D80009E0F0 /* Sources */, + 11B54E16211248D80009E0F0 /* Frameworks */, + 11B54E17211248D80009E0F0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 11B54E1C211248D80009E0F0 /* PBXTargetDependency */, + ); + name = StitchAWSServiceTests; + productName = StitchAWSServiceTests; + productReference = 11B54E19211248D80009E0F0 /* StitchAWSServiceTests.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 11B54E07211248D80009E0F0 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0940; + LastUpgradeCheck = 0940; + ORGANIZATIONNAME = MongoDB; + TargetAttributes = { + 11B54E0F211248D80009E0F0 = { + CreatedOnToolsVersion = 9.4; + LastSwiftMigration = 0940; + }; + 11B54E18211248D80009E0F0 = { + CreatedOnToolsVersion = 9.4; + }; + }; + }; + buildConfigurationList = 11B54E0A211248D80009E0F0 /* Build configuration list for PBXProject "StitchAWSService" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 11B54E06211248D80009E0F0; + productRefGroup = 11B54E11211248D80009E0F0 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 11B54E0F211248D80009E0F0 /* StitchAWSService */, + 11B54E18211248D80009E0F0 /* StitchAWSServiceTests */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 11B54E0E211248D80009E0F0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 11B54E17211248D80009E0F0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 11B54E0B211248D80009E0F0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 11FCDC352112640400894377 /* AWSServiceClientImpl.swift in Sources */, + 11FCDC372112643600894377 /* StitchAWSServiceExports.swift in Sources */, + 11FCDC33211263E200894377 /* AWSServiceClient.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 11B54E15211248D80009E0F0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 11B54E1F211248D80009E0F0 /* AWSServiceClientIntTests.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 11B54E1C211248D80009E0F0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + target = 11B54E0F211248D80009E0F0 /* StitchAWSService */; + targetProxy = 11B54E1B211248D80009E0F0 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 11B54E22211248D80009E0F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Debug; + }; + 11B54E23211248D80009E0F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + CURRENT_PROJECT_VERSION = 1; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + VERSIONING_SYSTEM = "apple-generic"; + VERSION_INFO_PREFIX = ""; + }; + name = Release; + }; + 11B54E25211248D80009E0F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + "FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = ( + "$(inherited)", + "\"$(SRCROOT)/../../../Frameworks/macos\"", + ); + INFOPLIST_FILE = StitchAWSService/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSService; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 11B54E26211248D80009E0F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_IDENTITY = ""; + CODE_SIGN_STYLE = Automatic; + DEFINES_MODULE = YES; + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + DYLIB_INSTALL_NAME_BASE = "@rpath"; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + INFOPLIST_FILE = StitchAWSService/Info.plist; + INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSService; + PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; + SKIP_INSTALL = YES; + SUPPORTED_PLATFORMS = "macosx iphonesimulator iphoneos"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 11B54E28211248D80009E0F0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphonesimulator*]" = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=macosx*]" = ""; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + "FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = ( + "$(SRCROOT)/../../../Frameworks/ios", + "$(inherited)", + ); + "FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = ( + "$(SRCROOT)/../../../Frameworks/macos", + "$(inherited)", + ); + INFOPLIST_FILE = StitchAWSServiceTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(inherited)", + "@executable_path/Frameworks", + ); + "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = ( + "\"$(SRCROOT)/../../../Frameworks/macos\"", + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSServiceTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; + SWIFT_OBJC_BRIDGING_HEADER = StitchAWSServiceTests/AWSServiceTestsConstants.h; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 11B54E29211248D80009E0F0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + CODE_SIGN_STYLE = Automatic; + FRAMEWORK_SEARCH_PATHS = ( + "$(SRCROOT)/../../../Frameworks/ios", + "$(inherited)", + ); + INFOPLIST_FILE = StitchAWSServiceTests/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 10.2; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.mongodb.StitchAWSServiceTests; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx"; + SWIFT_OBJC_BRIDGING_HEADER = StitchAWSServiceTests/AWSServiceTestsConstants.h; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 11B54E0A211248D80009E0F0 /* Build configuration list for PBXProject "StitchAWSService" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 11B54E22211248D80009E0F0 /* Debug */, + 11B54E23211248D80009E0F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 11B54E24211248D80009E0F0 /* Build configuration list for PBXNativeTarget "StitchAWSService" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 11B54E25211248D80009E0F0 /* Debug */, + 11B54E26211248D80009E0F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 11B54E27211248D80009E0F0 /* Build configuration list for PBXNativeTarget "StitchAWSServiceTests" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 11B54E28211248D80009E0F0 /* Debug */, + 11B54E29211248D80009E0F0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 11B54E07211248D80009E0F0 /* Project object */; +} diff --git a/Darwin/Services/StitchAWSService/StitchAWSService/AWSServiceClient.swift b/Darwin/Services/StitchAWSService/StitchAWSService/AWSServiceClient.swift new file mode 100644 index 00000000..274c44f2 --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService/AWSServiceClient.swift @@ -0,0 +1,81 @@ +import Foundation +import StitchCore +import StitchCoreSDK +import StitchCoreAWSService + +private final class AWSNamedServiceClientFactory: NamedServiceClientFactory { + typealias ClientType = AWSServiceClient + + func client(withServiceClient serviceClient: CoreStitchServiceClient, + withClientInfo clientInfo: StitchAppClientInfo) -> AWSServiceClient { + return AWSServiceClientImpl( + withClient: CoreAWSServiceClient.init(withService: serviceClient), + withDispatcher: OperationDispatcher(withDispatchQueue: DispatchQueue.global()) + ) + } +} + +/** + * Global factory const which can be used to create an `AWSServiceClient` with a `StitchAppClient`. Pass into + * `StitchAppClient.serviceClient(fromFactory:withName)` to get an `AWSServiceClient. + */ +public let awsServiceClientFactory = + AnyNamedServiceClientFactory(factory: AWSNamedServiceClientFactory()) + +/** + * The AWS service client, which can be used to interact with AWS via MongoDB Stitch. + */ +public protocol AWSServiceClient { + + /** + * Executes the AWS request. + * + * - parameters: + * - request the AWS request to execute. + * - completionHandler: The completion handler to call when the request is complete or the operation fails. + * This handler is executed on a non-main global `DispatchQueue`. If the operation is + * successful, the result will be ignored. + */ + func execute(request: AWSRequest, _ completionHandler: @escaping (StitchResult) -> Void) + + /** + * Executes the AWS request. Also accepts a timeout. Use this for functions that may run longer than the + * client-wide default timeout (15 seconds by default). + * + * - parameters: + * - request the AWS request to execute. + * - withRequestTimeout: The number of seconds the client should wait for a response from the server before + * failing with an error. + * - completionHandler: The completion handler to call when the request is complete or the operation fails. + * This handler is executed on a non-main global `DispatchQueue`. If the operation is + * successful, the result will be ignored. + */ + func execute(request: AWSRequest, withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) + + /** + * Executes the AWS request, and decodes the result into an instance of the type parameter T. + * + * - parameters: + * - request the AWS request to execute. + * - completionHandler: The completion handler to call when the request is complete or the operation fails. + * This handler is executed on a non-main global `DispatchQueue`. If the operation is + * successful, the result will decoded into the type T and will be included in the result. + */ + func execute(request: AWSRequest, _ completionHandler: @escaping (StitchResult) -> Void) + + /** + * Executes the AWS request, and decodes the result into an instance of the type parameter T. Also accepts a + * timeout. Use this for functions that may run longer than the client-wide default timeout (15 seconds by + * default). + * + * - parameters: + * - request the AWS request to execute. + * - withRequestTimeout: The number of seconds the client should wait for a response from the server before + * failing with an error. + * - completionHandler: The completion handler to call when the request is complete or the operation fails. + * This handler is executed on a non-main global `DispatchQueue`. If the operation is + * successful, the result will decoded into the type T and will be included in the result. + */ + func execute(request: AWSRequest, withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) + +} diff --git a/Darwin/Services/StitchAWSService/StitchAWSService/Info.plist b/Darwin/Services/StitchAWSService/StitchAWSService/Info.plist new file mode 100644 index 00000000..1007fd9d --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Darwin/Services/StitchAWSService/StitchAWSService/Internal/AWSServiceClientImpl.swift b/Darwin/Services/StitchAWSService/StitchAWSService/Internal/AWSServiceClientImpl.swift new file mode 100644 index 00000000..7657b63e --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService/Internal/AWSServiceClientImpl.swift @@ -0,0 +1,39 @@ +import Foundation +import StitchCore +import StitchCoreSDK +import StitchCoreAWSService + +public final class AWSServiceClientImpl: AWSServiceClient { + private let proxy: CoreAWSServiceClient + private let dispatcher: OperationDispatcher + + internal init(withClient client: CoreAWSServiceClient, + withDispatcher dispatcher: OperationDispatcher) { + self.proxy = client + self.dispatcher = dispatcher + } + + public func execute(request: AWSRequest, _ completionHandler: @escaping (StitchResult) -> Void) { + self.dispatcher.run(withCompletionHandler: completionHandler) { + try self.proxy.execute(request: request) + } + } + + public func execute(request: AWSRequest, withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) { + self.dispatcher.run(withCompletionHandler: completionHandler) { + try self.proxy.execute(request: request, withRequestTimeout: requestTimeout) + } + } + + public func execute(request: AWSRequest, _ completionHandler: @escaping (StitchResult) -> Void) where T : Decodable { + self.dispatcher.run(withCompletionHandler: completionHandler) { + return try self.proxy.execute(request: request) + } + } + + public func execute(request: AWSRequest, withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) where T : Decodable { + self.dispatcher.run(withCompletionHandler: completionHandler) { + return try self.proxy.execute(request: request, withRequestTimeout: requestTimeout) + } + } +} diff --git a/Darwin/Services/StitchAWSService/StitchAWSService/StitchAWSServiceExports.swift b/Darwin/Services/StitchAWSService/StitchAWSService/StitchAWSServiceExports.swift new file mode 100644 index 00000000..12fae7ba --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSService/StitchAWSServiceExports.swift @@ -0,0 +1,3 @@ +// Re-exported classes, structs, protocols, and enums from StitchCoreAWSService + +@_exported import struct StitchCoreAWSService.AWSRequest diff --git a/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceClientIntTests.swift b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceClientIntTests.swift new file mode 100644 index 00000000..c140f53d --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceClientIntTests.swift @@ -0,0 +1,202 @@ +import XCTest +import MongoSwift +import StitchCore +import StitchCoreSDK +import StitchCoreAdminClient +import StitchDarwinCoreTestUtils +import StitchCoreAWSService +@testable import StitchAWSService + +let testAWSAccessKeyID = TEST_AWS_ACCESS_KEY_ID.isEmpty ? + ProcessInfo.processInfo.environment["AWS_ACCESS_KEY_ID"] : TEST_AWS_ACCESS_KEY_ID +let testAWSSecretAccessKey = TEST_AWS_SECRET_ACCESS_KEY.isEmpty ? + ProcessInfo.processInfo.environment["AWS_SECRET_ACCESS_KEY"] : TEST_AWS_SECRET_ACCESS_KEY + +class AWSServiceClientIntTests: BaseStitchIntTestCocoaTouch { + + override func setUp() { + super.setUp() + + guard !(testAWSAccessKeyID?.isEmpty ?? true), + !(testAWSSecretAccessKey?.isEmpty ?? true) else { + XCTFail("No AWS_ACCESS_KEY_ID or AWS_SECRET_ACCESS_KEY in preprocessor macros; failing test. See README for more details.") + return + } + } + + func testPutObject() throws { + let app = try self.createApp() + let _ = try self.addProvider(toApp: app.1, withConfig: ProviderConfigs.anon()) + let svc = try self.addService( + toApp: app.1, + withType: "aws", + withName: "aws1", + withConfig: ServiceConfigs.aws( + name: "aws1", + accessKeyID: testAWSAccessKeyID!, + secretAccessKey: testAWSSecretAccessKey! + ) + ) + _ = try self.addRule(toService: svc.1, + withConfig: RuleCreator.actions( + name: "default", + actions: RuleActionsCreator.aws(actions: ["s3:PutObject"]) + )) + + let client = try self.appClient(forApp: app.0) + + let exp0 = expectation(description: "should login") + client.auth.login(withCredential: AnonymousCredential()) { _ in + exp0.fulfill() + } + wait(for: [exp0], timeout: 5.0) + + let awsS3 = client.serviceClient(fromFactory: awsServiceClientFactory, withName: "aws1") + + // Putting to a bad bucket should fail + let bucket = "notmystuff" + let key = ObjectId.init().description + let acl = "public-read" + let contentType = "plain/text" + let body = "hello again friend; did you miss me" + + let args1: Document = [ + "Bucket": bucket, + "Key": key, + "ACL": acl, + "ContentType": contentType, + "Body": body + ] + + let exp1 = expectation(description: "should not put object") + awsS3.execute(request: try AWSRequestBuilder() + .with(service: "s3") + .with(action: "PutObject") + .with(arguments: args1) + .build()) { result in + switch result { + case .success: + XCTFail("expected a failure") + case .failure(let error): + switch error { + case .serviceError(_, let withServiceErrorCode): + XCTAssertEqual(StitchServiceErrorCode.awsError, withServiceErrorCode) + default: + XCTFail("unexpected error") + } + } + + exp1.fulfill() + } + wait(for: [exp1], timeout: 5.0) + + // Putting with all good params for S3 should work + let bucketGood = "stitch-test-sdkfiles" + let expectedLocation = "https://stitch-test-sdkfiles.s3.amazonaws.com/\(key)" + let transport = FoundationHTTPTransport() + + let args2: Document = [ + "Bucket": bucketGood, + "Key": key, + "ACL": acl, + "ContentType": contentType, + "Body": body + ] + + let exp2 = expectation(description: "should put string") + awsS3.execute(request: try AWSRequestBuilder() + .with(service: "s3") + .with(action: "PutObject") + .with(arguments: args2) + .build()) { (result: StitchResult) in + switch result { + case .success(let awsS3Result): + XCTAssertNotNil(awsS3Result["ETag"]) + case .failure: + XCTFail("unexpected error") + } + + exp2.fulfill() + } + wait(for: [exp2], timeout: 5.0) + + var httpResult = try transport.roundTrip(request: RequestBuilder() + .with(method: .get) + .with(url: expectedLocation) + .with(timeout: 1.5) + .build() + ) + + XCTAssertEqual(body, String.init(data: httpResult.body!, encoding: .utf8)) + + // ...with BSON binary parameter + let bodyBin = Binary(data: body.data(using: .utf8)!, subtype: .binary) + + let args3: Document = [ + "Bucket": bucketGood, + "Key": key, + "ACL": acl, + "ContentType": contentType, + "Body": bodyBin + ] + + let exp3 = expectation(description: "should put BSON binary") + awsS3.execute(request: try AWSRequestBuilder() + .with(service: "s3") + .with(action: "PutObject") + .with(arguments: args3) + .build()) { (result: StitchResult) in + switch result { + case .success(let awsS3Result): + XCTAssertNotNil(awsS3Result["ETag"]) + case .failure: + XCTFail("unexpected error") + } + + exp3.fulfill() + } + wait(for: [exp3], timeout: 5.0) + + httpResult = try transport.roundTrip(request: RequestBuilder() + .with(method: .get) + .with(url: expectedLocation) + .with(timeout: 1.5) + .build() + ) + + XCTAssertEqual(bodyBin.data, httpResult.body!) + + // Excluding any required parameters should fail + let exp4 = expectation(description: "should not put object") + + let args4: Document = [ + "Bucket": "", + "Key": key, + "ACL": acl, + "ContentType": contentType, + "Body": bodyBin + ] + + awsS3.execute(request: try AWSRequestBuilder() + .with(service: "s3") + .with(action: "PutObject") + .with(arguments: args4) + .build()) { result in + switch result { + case .success: + XCTFail("expected a failure") + case .failure(let error): + switch error { + case .serviceError(_, let withServiceErrorCode): + XCTAssertEqual(StitchServiceErrorCode.awsError, withServiceErrorCode) + default: + XCTFail("unexpected error") + } + } + + exp4.fulfill() + } + wait(for: [exp4], timeout: 5.0) + } + +} diff --git a/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceTestsConstants.h b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceTestsConstants.h new file mode 100644 index 00000000..f1722d4f --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/AWSServiceTestsConstants.h @@ -0,0 +1,15 @@ +#define STRINGIZE(x) #x +#define STRINGIZE2(x) STRINGIZE(x) + +#if defined(AWS_ACCESS_KEY_ID) && defined(AWS_SECRET_ACCESS_KEY) +#define __AWS_ACCESS_KEY_ID @ STRINGIZE2(AWS_ACCESS_KEY_ID) +#define __AWS_SECRET_ACCESS_KEY @ STRINGIZE2(AWS_SECRET_ACCESS_KEY) +#else +#define __AWS_ACCESS_KEY_ID NULL +#define __AWS_SECRET_ACCESS_KEY NULL +#endif + +#import + +static NSString* __nullable const TEST_AWS_ACCESS_KEY_ID = __AWS_ACCESS_KEY_ID; +static NSString* __nullable const TEST_AWS_SECRET_ACCESS_KEY = __AWS_SECRET_ACCESS_KEY; diff --git a/Darwin/Services/StitchAWSService/StitchAWSServiceTests/Info.plist b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/Info.plist new file mode 100644 index 00000000..6c40a6cd --- /dev/null +++ b/Darwin/Services/StitchAWSService/StitchAWSServiceTests/Info.plist @@ -0,0 +1,22 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + + diff --git a/Darwin/Services/StitchFCMService/StitchFCMService/FCMServiceClient.swift b/Darwin/Services/StitchFCMService/StitchFCMService/FCMServiceClient.swift index 7ea60f47..75862e4e 100644 --- a/Darwin/Services/StitchFCMService/StitchFCMService/FCMServiceClient.swift +++ b/Darwin/Services/StitchFCMService/StitchFCMService/FCMServiceClient.swift @@ -6,7 +6,7 @@ import StitchCoreFCMService private final class FCMNamedServiceClientFactory: NamedServiceClientFactory { typealias ClientType = FCMServiceClient - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> FCMServiceClient { return FCMServiceClientImpl.init( withClient: CoreFCMServiceClient(withServiceClient: serviceClient), diff --git a/Darwin/Services/StitchHTTPService/StitchHTTPService/HTTPServiceClient.swift b/Darwin/Services/StitchHTTPService/StitchHTTPService/HTTPServiceClient.swift index be8f5a78..049adfc4 100644 --- a/Darwin/Services/StitchHTTPService/StitchHTTPService/HTTPServiceClient.swift +++ b/Darwin/Services/StitchHTTPService/StitchHTTPService/HTTPServiceClient.swift @@ -6,7 +6,7 @@ import StitchCoreSDK private final class HTTPNamedServiceClientFactory: NamedServiceClientFactory { typealias ClientType = HTTPServiceClient - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> HTTPServiceClient { return HTTPServiceClientImpl( withClient: CoreHTTPServiceClient.init(withService: serviceClient), diff --git a/Darwin/Services/StitchLocalMongoDBService/StitchLocalMongoDBService/LocalMongoClient.swift b/Darwin/Services/StitchLocalMongoDBService/StitchLocalMongoDBService/LocalMongoClient.swift index 6c11da93..9942d7be 100644 --- a/Darwin/Services/StitchLocalMongoDBService/StitchLocalMongoDBService/LocalMongoClient.swift +++ b/Darwin/Services/StitchLocalMongoDBService/StitchLocalMongoDBService/LocalMongoClient.swift @@ -81,7 +81,7 @@ private final class MobileMongoDBClientFactory: CoreLocalMongoDBService, Throwin #endif } - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) throws -> MongoClient { return try CoreLocalMongoDBService.client(withAppInfo: clientInfo) } diff --git a/Darwin/Services/StitchRemoteMongoDBService/StitchRemoteMongoDBService/RemoteMongoClient.swift b/Darwin/Services/StitchRemoteMongoDBService/StitchRemoteMongoDBService/RemoteMongoClient.swift index 2234df3f..75bdde0a 100644 --- a/Darwin/Services/StitchRemoteMongoDBService/StitchRemoteMongoDBService/RemoteMongoClient.swift +++ b/Darwin/Services/StitchRemoteMongoDBService/StitchRemoteMongoDBService/RemoteMongoClient.swift @@ -6,7 +6,7 @@ import StitchCoreRemoteMongoDBService private final class RemoteMongoClientFactory: NamedServiceClientFactory { typealias ClientType = RemoteMongoClient - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> RemoteMongoClient { return RemoteMongoClient.init( withClient: CoreRemoteMongoClient.init(withService: serviceClient), diff --git a/Darwin/Services/StitchTwilioService/StitchTwilioService/TwilioServiceClient.swift b/Darwin/Services/StitchTwilioService/StitchTwilioService/TwilioServiceClient.swift index 70a358e4..32a06570 100644 --- a/Darwin/Services/StitchTwilioService/StitchTwilioService/TwilioServiceClient.swift +++ b/Darwin/Services/StitchTwilioService/StitchTwilioService/TwilioServiceClient.swift @@ -6,7 +6,7 @@ import StitchCoreSDK private final class TwilioNamedServiceClientFactory: NamedServiceClientFactory { typealias ClientType = TwilioServiceClient - func client(withServiceClient service: StitchServiceClient, + func client(withServiceClient service: CoreStitchServiceClient, withClientInfo client: StitchAppClientInfo) -> TwilioServiceClient { return TwilioServiceClientImpl( withClient: CoreTwilioServiceClient.init(withService: service), diff --git a/Darwin/StitchCore/StitchCore.xcodeproj/project.pbxproj b/Darwin/StitchCore/StitchCore.xcodeproj/project.pbxproj index 646c3a5b..fd9f4fe9 100644 --- a/Darwin/StitchCore/StitchCore.xcodeproj/project.pbxproj +++ b/Darwin/StitchCore/StitchCore.xcodeproj/project.pbxproj @@ -427,6 +427,7 @@ isa = PBXGroup; children = ( 4902C6BB2050112C00E53674 /* Internal */, + 4902C6AE20500FAD00E53674 /* StitchServiceClient.swift */, ); path = Services; sourceTree = ""; @@ -434,7 +435,6 @@ 4902C6BB2050112C00E53674 /* Internal */ = { isa = PBXGroup; children = ( - 4902C6AE20500FAD00E53674 /* StitchServiceClient.swift */, 4902C6B92050112300E53674 /* StitchServiceClientImpl.swift */, 4902C6C8205174A100E53674 /* NamedServiceClientFactory.swift */, 496CAA8820A5E3A6001F0D3C /* ThrowingServiceClientFactory.swift */, diff --git a/Darwin/StitchCore/StitchCore/Core/Internal/StitchAppClientImpl.swift b/Darwin/StitchCore/StitchCore/Core/Internal/StitchAppClientImpl.swift index c502ae4c..058519c7 100644 --- a/Darwin/StitchCore/StitchCore/Core/Internal/StitchAppClientImpl.swift +++ b/Darwin/StitchCore/StitchCore/Core/Internal/StitchAppClientImpl.swift @@ -84,151 +84,85 @@ internal final class StitchAppClientImpl: StitchAppClient { } // MARK: Services + + public func serviceClient(withServiceName serviceName: String) -> StitchServiceClient { + return StitchServiceClientImpl.init( + proxy: CoreStitchServiceClientImpl.init( + requestClient: self._auth, + routes: self.routes.serviceRoutes, + serviceName: serviceName + ), + dispatcher: self.dispatcher + ) + } - /** - * Retrieves the service client associated with the Stitch service with the specified name and type. - * - * - parameters: - * - fromFactory: An `AnyNamedServiceClientFactory` object which contains a `NamedServiceClientFactory` - * class which will provide the client for this service. - * - withName: The name of the service as defined in the MongoDB Stitch application. - * - returns: a service client whose type is determined by the `T` type parameter of the - * `AnyNamedServiceClientFactory` passed in the `fromFactory` parameter. - */ public func serviceClient(fromFactory factory: AnyNamedServiceClientFactory, withName serviceName: String) -> T { return factory.client( - forService: StitchServiceClientImpl.init(requestClient: self._auth, - routes: self.routes.serviceRoutes, - name: serviceName, dispatcher: self.dispatcher), + forService: CoreStitchServiceClientImpl.init(requestClient: self._auth, + routes: self.routes.serviceRoutes, + serviceName: serviceName), withClientInfo: self.info ) } - /** - * Retrieves the service client associated with the service type specified in the argument. - * - * - parameters: - * - fromFactory: An `AnyServiceClientProvider` object which contains a `ServiceClientFactory` - * class which will provide the client for this service. - * - returns: a service client whose type is determined by the `T` type parameter of the - * `AnyNamedServiceClientFactory` passed in the `fromFactory` parameter. - */ public func serviceClient(fromFactory factory: AnyNamedServiceClientFactory) -> T { return factory.client( - forService: StitchServiceClientImpl.init(requestClient: self._auth, + forService: CoreStitchServiceClientImpl.init(requestClient: self._auth, routes: self.routes.serviceRoutes, - name: "", dispatcher: self.dispatcher), + serviceName: nil), withClientInfo: self.info ) } - /** - * Retrieves the service client associated with the service type specified in the argument. - * - * - parameters: - * - fromFactory: An `AnyThrowingServiceClientFactory` object which contains a `ThrowingServiceClientFactory` - * class which will provide the client for this service. - * - returns: a service client whose type is determined by the `T` type parameter of the - * `AnyThrowingServiceClientFactory` passed in the `fromFactory` parameter. - */ public func serviceClient(fromFactory factory: AnyThrowingServiceClientFactory) throws -> T { return try factory.client( - forService: StitchServiceClientImpl.init(requestClient: self._auth, - routes: self.routes.serviceRoutes, - name: "", dispatcher: self.dispatcher), + forService: CoreStitchServiceClientImpl.init(requestClient: self._auth, + routes: self.routes.serviceRoutes, + serviceName: nil), withClientInfo: self.info ) } // MARK: Functions - /** - * Calls the MongoDB Stitch function with the provided name and arguments. - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. - */ + public func callFunction(withName name: String, withArgs args: [BsonValue], _ completionHandler: @escaping (StitchResult) -> Void) { self.dispatcher.run(withCompletionHandler: completionHandler) { - return try self.coreClient.callFunctionInternal(withName: name, withArgs: args) + return try self.coreClient.callFunction(withName: name, withArgs: args) } } - /** - * Calls the MongoDB Stitch function with the provided name and arguments, and decodes the result of the function - * into a `Decodable` type as specified by the `T` type parameter. - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. If the operation is - * successful, the result will contain a `T` representing the decoded result of the - * function call. - * - */ public func callFunction(withName name: String, withArgs args: [BsonValue], _ completionHandler: @escaping (StitchResult) -> Void) { dispatcher.run(withCompletionHandler: completionHandler) { - return try self.coreClient.callFunctionInternal(withName: name, - withArgs: args) + return try self.coreClient.callFunction(withName: name, + withArgs: args) } } - /** - * Calls the MongoDB Stitch function with the provided name and arguments. Also accepts a timeout. Use this for - * function that may run longer than the client-wide default timeout (15 seconds by default). - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - withRequestTimeout: The number of seconds the client should wait for a response from the server before - * failing with an error. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. - * - */ public func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) { self.dispatcher.run(withCompletionHandler: completionHandler) { - return try self.coreClient.callFunctionInternal(withName: name, - withArgs: args, - withRequestTimeout: requestTimeout + return try self.coreClient.callFunction(withName: name, + withArgs: args, + withRequestTimeout: requestTimeout ) } } - /** - * Calls the MongoDB Stitch function with the provided name and arguments, and decodes the result of the function - * into a `Decodable` type as specified by the `T` type parameter. Also accepts a timeout. Use this for functions - * that may run longer than the client-wide default timeout (15 seconds by default). - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - withRequestTimeout: The number of seconds the client should wait for a response from the server before - * failing with an error. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. If the operation is - * successful, the result will contain a `T` representing the decoded result of the - * function call. - */ public func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) { dispatcher.run(withCompletionHandler: completionHandler) { - return try self.coreClient.callFunctionInternal(withName: name, - withArgs: args, - withRequestTimeout: requestTimeout) + return try self.coreClient.callFunction(withName: name, + withArgs: args, + withRequestTimeout: requestTimeout) } } } diff --git a/Darwin/StitchCore/StitchCore/Core/StitchAppClient.swift b/Darwin/StitchCore/StitchCore/Core/StitchAppClient.swift index 746ab934..7e1bafbc 100644 --- a/Darwin/StitchCore/StitchCore/Core/StitchAppClient.swift +++ b/Darwin/StitchCore/StitchCore/Core/StitchAppClient.swift @@ -33,6 +33,16 @@ public protocol StitchAppClient { // MARK: Services + /** + * Retrieves a general-purpose service client for the Stitch service + * associated with the specified name. Use this for services which do not + * have a well-defined interface in the SDK. + * + * - parameters: + * - withServiceName: The name of the desired service in MongoDB Stitch. + */ + func serviceClient(withServiceName serviceName: String) -> StitchServiceClient + /** * Retrieves the service client for the Stitch service associated with the specified name and factory. * diff --git a/Darwin/StitchCore/StitchCore/Services/Internal/NamedServiceClientFactory.swift b/Darwin/StitchCore/StitchCore/Services/Internal/NamedServiceClientFactory.swift index e6a337fe..548184c0 100644 --- a/Darwin/StitchCore/StitchCore/Services/Internal/NamedServiceClientFactory.swift +++ b/Darwin/StitchCore/StitchCore/Services/Internal/NamedServiceClientFactory.swift @@ -10,9 +10,10 @@ public protocol NamedServiceClientFactory { associatedtype ClientType /** - * Returns a client of type `ClientType`, with the provided `StitchServiceClient` and `StitchAppClientInfo` objects. + * Returns a client of type `ClientType`, with the provided `CoreStitchServiceClient` and `StitchAppClientInfo` + * objects. */ - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> ClientType } @@ -23,7 +24,7 @@ public struct AnyNamedServiceClientFactory { /** * A property containing the function that produces the service client object. */ - private let clientBlock: (StitchServiceClient, StitchAppClientInfo) -> T + private let clientBlock: (CoreStitchServiceClient, StitchAppClientInfo) -> T /** * Initializes this `AnyNamedServiceClientFactory` with an arbitrary `NamedServiceClientFactory`. @@ -35,7 +36,7 @@ public struct AnyNamedServiceClientFactory { /** * Produces a service client with the stored `clientBlock`. */ - func client(forService service: StitchServiceClient, + func client(forService service: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> T { return self.clientBlock(service, clientInfo) } diff --git a/Darwin/StitchCore/StitchCore/Services/Internal/ServiceClientFactory.swift b/Darwin/StitchCore/StitchCore/Services/Internal/ServiceClientFactory.swift index d89e1353..49b1a106 100644 --- a/Darwin/StitchCore/StitchCore/Services/Internal/ServiceClientFactory.swift +++ b/Darwin/StitchCore/StitchCore/Services/Internal/ServiceClientFactory.swift @@ -10,9 +10,10 @@ public protocol ServiceClientFactory { associatedtype ClientType /** - * Returns a client of type `ClientType`, with the provided `StitchServiceClient` and `StitchAppClientInfo` objects. + * Returns a client of type `ClientType`, with the provided `CoreStitchServiceClient` and `StitchAppClientInfo` + * objects. */ - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> ClientType } @@ -23,7 +24,7 @@ public struct AnyServiceClientFactory { /** * A property containing the function that provides the service client object. */ - private let clientBlock: (StitchServiceClient, StitchAppClientInfo) -> T + private let clientBlock: (CoreStitchServiceClient, StitchAppClientInfo) -> T /** * Initializes this `AnyServiceClientFactory` with an arbitrary `ServiceClientFactory`. @@ -35,7 +36,7 @@ public struct AnyServiceClientFactory { /** * Produces a service client with the stored `clientBlock`. */ - func client(forService service: StitchServiceClient, + func client(forService service: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) -> T { return self.clientBlock(service, clientInfo) } diff --git a/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClientImpl.swift b/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClientImpl.swift index 2a554db0..a4b015a7 100644 --- a/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClientImpl.swift +++ b/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClientImpl.swift @@ -6,65 +6,55 @@ import MongoSwift * The implementation of `StitchServiceClient`, which is capable of making requests to execute functions for a * particular service. */ -internal final class StitchServiceClientImpl: CoreStitchServiceClientImpl, StitchServiceClient { +internal final class StitchServiceClientImpl: StitchServiceClient { /** * The operation dispatcher used to dispatch asynchronous operations made by this service. */ private let dispatcher: OperationDispatcher + + private let proxy: CoreStitchServiceClient /** * Initializes the service with the provided request client, service API routes, service name, and operation * dispatcher. */ - public init(requestClient: StitchAuthRequestClient, - routes: StitchServiceRoutes, - name: String, + public init(proxy: CoreStitchServiceClient, dispatcher: OperationDispatcher) { + self.proxy = proxy self.dispatcher = dispatcher - super.init(requestClient: requestClient, routes: routes, serviceName: name) + } + + func callFunction(withName name: String, + withArgs args: [BsonValue], + _ completionHandler: @escaping (StitchResult) -> Void) { + dispatcher.run(withCompletionHandler: completionHandler) { + try self.proxy.callFunction(withName: name, withArgs: args, withRequestTimeout: nil) + } } - /** - * Calls the MongoDB Stitch function with the provided name and arguments. Also accepts a timeout. Use this for - * function that may run longer than the client-wide default timeout (15 seconds by default). - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. - * - */ func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) { dispatcher.run(withCompletionHandler: completionHandler) { - try self.callFunctionInternal(withName: name, withArgs: args, withRequestTimeout: requestTimeout) + try self.proxy.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) + } + } + + public func callFunction(withName name: String, + withArgs args: [BsonValue], + _ completionHandler: @escaping (StitchResult) -> Void) { + dispatcher.run(withCompletionHandler: completionHandler) { + return try self.proxy.callFunction(withName: name, withArgs: args, withRequestTimeout: nil) } } - /** - * Calls the MongoDB Stitch function with the provided name and arguments, and decodes the result of the function - * into a `Decodable` type as specified by the `T` type parameter. Also accepts a timeout. Use this for functions - * that may run longer than the client-wide default timeout (15 seconds by default). - * - * - parameters: - * - withName: The name of the Stitch function to be called. - * - withArgs: The `BSONArray` of arguments to be provided to the function. - * - withRequestTimeout: The number of seconds the client should wait for a response from the server before - * failing with an error. - * - completionHandler: The completion handler to call when the function call is complete. - * This handler is executed on a non-main global `DispatchQueue`. If the operation is - * successful, the result will contain a `T` representing the decoded result of the - * function call. - */ public func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) { dispatcher.run(withCompletionHandler: completionHandler) { - return try self.callFunctionInternal(withName: name, withArgs: args, withRequestTimeout: requestTimeout) + return try self.proxy.callFunction(withName: name, withArgs: args, withRequestTimeout: requestTimeout) } } } diff --git a/Darwin/StitchCore/StitchCore/Services/Internal/ThrowingServiceClientFactory.swift b/Darwin/StitchCore/StitchCore/Services/Internal/ThrowingServiceClientFactory.swift index 414dffb3..6cf58a3a 100644 --- a/Darwin/StitchCore/StitchCore/Services/Internal/ThrowingServiceClientFactory.swift +++ b/Darwin/StitchCore/StitchCore/Services/Internal/ThrowingServiceClientFactory.swift @@ -10,9 +10,10 @@ public protocol ThrowingServiceClientFactory { associatedtype ClientType /** - * Returns a client of type `ClientType`, with the provided `StitchServiceClient` and `StitchAppClientInfo` objects. + * Returns a client of type `ClientType`, with the provided `CoreStitchServiceClient` and `StitchAppClientInfo` + * objects. */ - func client(withServiceClient serviceClient: StitchServiceClient, + func client(withServiceClient serviceClient: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) throws -> ClientType } @@ -23,7 +24,7 @@ public struct AnyThrowingServiceClientFactory { /** * A property containing the function that provides the service client object. */ - private let clientBlock: (StitchServiceClient, StitchAppClientInfo) throws -> T + private let clientBlock: (CoreStitchServiceClient, StitchAppClientInfo) throws -> T /** * Initializes this `AnyThrowingServiceClientFactory` with an arbitrary `ThrowingServiceClientFactory`. @@ -35,7 +36,7 @@ public struct AnyThrowingServiceClientFactory { /** * Produces a service client with the stored `clientBlock`. */ - func client(forService service: StitchServiceClient, + func client(forService service: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) throws -> T { return try self.clientBlock(service, clientInfo) } diff --git a/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClient.swift b/Darwin/StitchCore/StitchCore/Services/StitchServiceClient.swift similarity index 53% rename from Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClient.swift rename to Darwin/StitchCore/StitchCore/Services/StitchServiceClient.swift index e4c58214..19f8da4a 100644 --- a/Darwin/StitchCore/StitchCore/Services/Internal/StitchServiceClient.swift +++ b/Darwin/StitchCore/StitchCore/Services/StitchServiceClient.swift @@ -3,13 +3,24 @@ import StitchCoreSDK import Foundation /** - * A protocol representing a MongoDB Stitch service, with methods for executing functions on that service. - * A class implementing this protocol for a service with known functions and return values may implement - * concrete methods that use these methods internally. + * StitchServiceClient acts as a general purpose client for working with services that are not defined or well defined + * by this SDK. It has methods similar to the `callFunction` method on `StitchAppClient`. */ -public protocol StitchServiceClient: CoreStitchServiceClient { +public protocol StitchServiceClient { // swiftlint:disable line_length + + /** + * Calls the MongoDB Stitch function with the provided name and arguments. + * + * - parameters: + * - withName: The name of the Stitch function to be called. + * - withArgs: The `BSONArray` of arguments to be provided to the function. + * - completionHandler: The completion handler to call when the function call is complete. + * This handler is executed on a non-main global `DispatchQueue`. + * + */ + func callFunction(withName name: String, withArgs args: [BsonValue], _ completionHandler: @escaping (StitchResult) -> Void) /** * Calls the MongoDB Stitch function with the provided name and arguments. Also accepts a timeout. Use this for @@ -18,11 +29,28 @@ public protocol StitchServiceClient: CoreStitchServiceClient { * - parameters: * - withName: The name of the Stitch function to be called. * - withArgs: The `BSONArray` of arguments to be provided to the function. + * - withRequestTimeout: The number of seconds the client should wait for a response from the server before + * failing with an error. * - completionHandler: The completion handler to call when the function call is complete. * This handler is executed on a non-main global `DispatchQueue`. * */ func callFunction(withName name: String, withArgs args: [BsonValue], withRequestTimeout requestTimeout: TimeInterval, _ completionHandler: @escaping (StitchResult) -> Void) + + /** + * Calls the function for this service with the provided name and arguments. + * + * - parameters: + * - withName: The name of the function to be called. + * - withArgs: The `BSONArray` of arguments to be provided to the function. + * - completionHandler: The completion handler to call when the function call is complete. + * This handler is executed on a non-main global `DispatchQueue`. + * - result: The result of the function call as `T`, or `nil` if the function call failed. + * - error: An error object that indicates why the function call failed, or `nil` if the function call was + * successful. + * + */ + func callFunction(withName name: String, withArgs args: [BsonValue], _ completionHandler: @escaping (StitchResult) -> Void) /** * Calls the function for this service with the provided name and arguments, as well as with a specified timeout. diff --git a/Darwin/StitchCore/StitchCoreTests/Services/ThrowingServiceClientFactoryUnitTests.swift b/Darwin/StitchCore/StitchCoreTests/Services/ThrowingServiceClientFactoryUnitTests.swift index a00a77e2..4353f93f 100644 --- a/Darwin/StitchCore/StitchCoreTests/Services/ThrowingServiceClientFactoryUnitTests.swift +++ b/Darwin/StitchCore/StitchCoreTests/Services/ThrowingServiceClientFactoryUnitTests.swift @@ -6,7 +6,7 @@ import StitchDarwinCoreTestUtils private final class TestThrowingServiceClientFactory: ThrowingServiceClientFactory { typealias ClientType = String - func client(withServiceClient service: StitchServiceClient, + func client(withServiceClient service: CoreStitchServiceClient, withClientInfo clientInfo: StitchAppClientInfo) throws -> TestThrowingServiceClientFactory.ClientType { throw StitchError.serviceError( withMessage: "test-message", diff --git a/Makefile b/Makefile index 8c71002f..76fc0c13 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ all: $(MAKE) -C Core/StitchCoreSDK prepare $(MAKE) -C Core/StitchCoreAdminClient prepare $(MAKE) -C Core/StitchCoreTestUtils prepare + $(MAKE) -C Core/Services/StitchCoreAWSService prepare $(MAKE) -C Core/Services/StitchCoreAWSS3Service prepare $(MAKE) -C Core/Services/StitchCoreAWSSESService prepare $(MAKE) -C Core/Services/StitchCoreFCMService prepare @@ -22,6 +23,7 @@ clean: $(MAKE) -C Core/StitchCoreSDK clean $(MAKE) -C Core/StitchCoreAdminClient clean $(MAKE) -C Core/StitchCoreTestUtils clean + $(MAKE) -C Core/Services/StitchCoreAWSService clean $(MAKE) -C Core/Services/StitchCoreAWSS3Service clean $(MAKE) -C Core/Services/StitchCoreAWSSESService clean $(MAKE) -C Core/Services/StitchCoreFCMService clean @@ -34,6 +36,7 @@ lint: $(MAKE) -C Core/StitchCoreSDK lint $(MAKE) -C Core/StitchCoreAdminClient lint $(MAKE) -C Core/StitchCoreTestUtils lint + $(MAKE) -C Core/Services/StitchCoreAWSService lint $(MAKE) -C Core/Services/StitchCoreAWSS3Service lint $(MAKE) -C Core/Services/StitchCoreAWSSESService lint $(MAKE) -C Core/Services/StitchCoreFCMService lint @@ -46,6 +49,7 @@ git: $(MAKE) -C Core/StitchCoreSDK git $(MAKE) -C Core/StitchCoreAdminClient git $(MAKE) -C Core/StitchCoreTestUtils git + $(MAKE) -C Core/Services/StitchCoreAWSService git $(MAKE) -C Core/Services/StitchCoreAWSS3Service git $(MAKE) -C Core/Services/StitchCoreAWSSESService git $(MAKE) -C Core/Services/StitchCoreFCMService git @@ -58,6 +62,7 @@ update: $(MAKE) -C Core/StitchCoreSDK update $(MAKE) -C Core/StitchCoreAdminClient update $(MAKE) -C Core/StitchCoreTestUtils update + $(MAKE) -C Core/Services/StitchCoreAWSService update $(MAKE) -C Core/Services/StitchCoreAWSS3Service update $(MAKE) -C Core/Services/StitchCoreAWSSESService update $(MAKE) -C Core/Services/StitchCoreFCMService update @@ -70,6 +75,7 @@ test: $(MAKE) -C Core/StitchCoreSDK test $(MAKE) -C Core/StitchCoreAdminClient test $(MAKE) -C Core/StitchCoreTestUtils test + $(MAKE) -C Core/Services/StitchCoreAWSService test $(MAKE) -C Core/Services/StitchCoreAWSS3Service test $(MAKE) -C Core/Services/StitchCoreAWSSESService test $(MAKE) -C Core/Services/StitchCoreFCMService test @@ -82,6 +88,7 @@ project: $(MAKE) -C Core/StitchCoreSDK project $(MAKE) -C Core/StitchCoreAdminClient project $(MAKE) -C Core/StitchCoreTestUtils project + $(MAKE) -C Core/Services/StitchCoreAWSService project $(MAKE) -C Core/Services/StitchCoreAWSS3Service project $(MAKE) -C Core/Services/StitchCoreAWSSESService project $(MAKE) -C Core/Services/StitchCoreFCMService project diff --git a/README.md b/README.md index 490673e2..c00110e5 100644 --- a/README.md +++ b/README.md @@ -43,10 +43,8 @@ target '' do # For core functionality and the Remote MongoDB Service pod 'StitchSDK', '~> 4.0.3' - # optional: for using the AWS S3 service - pod 'StitchSDK/StitchAWSS3Service', '~> 4.0.3' - # optional: for using the AWS SES service - pod 'StitchSDK/StitchAWSSESService', '~> 4.0.3' + # optional: for using the AWS service + pod 'StitchSDK/StitchAWSService', '~> 4.0.3' # optional: for using the Firebase Cloud Messaging service pod 'StitchSDK/StitchFCMService', '~> 4.0.3' # optional: for using the HTTP service diff --git a/Stitch.xcworkspace/contents.xcworkspacedata b/Stitch.xcworkspace/contents.xcworkspacedata index ab257246..680e86e4 100644 --- a/Stitch.xcworkspace/contents.xcworkspacedata +++ b/Stitch.xcworkspace/contents.xcworkspacedata @@ -34,10 +34,10 @@ + + - - @@ -97,6 +97,9 @@ + + diff --git a/StitchSDK.podspec b/StitchSDK.podspec index 8eb1621f..df12810e 100644 --- a/StitchSDK.podspec +++ b/StitchSDK.podspec @@ -33,6 +33,11 @@ Pod::Spec.new do |spec| core.dependency "StitchCoreSDK", "~> 4.0.3" end + # pod "StitchSDK/StitchCoreAWSService", "~> 4.0" + spec.subspec "StitchCoreAWSService" do |core_aws_service| + core_aws_service.dependency 'StitchCoreAWSService', '~> 4.0.3' + end + # pod "StitchSDK/StitchCoreAWSS3Service", "~> 4.0" spec.subspec "StitchCoreAWSS3Service" do |core_aws_s3_service| core_aws_s3_service.dependency 'StitchCoreAWSS3Service', '~> 4.0.3' @@ -63,6 +68,11 @@ Pod::Spec.new do |spec| ios_core.dependency 'StitchCoreSDK', '~> 4.0.3' end + # pod "StitchSDK/StitchAWSService", "~> 4.0" + spec.subspec "StitchAWSService" do |aws_service| + aws_service.dependency 'StitchAWSService', '~> 4.0.3' + end + # pod "StitchSDK/StitchAWSS3Service", "~> 4.0" spec.subspec "StitchAWSS3Service" do |aws_s3_service| aws_s3_service.dependency 'StitchAWSS3Service', '~> 4.0.3' diff --git a/contrib/generate_docs.sh b/contrib/generate_docs.sh index 69308149..0998f80d 100755 --- a/contrib/generate_docs.sh +++ b/contrib/generate_docs.sh @@ -6,6 +6,7 @@ python scripts/run_xctests.py --test=False sourcekitten doc --module-name StitchCoreSDK -- -workspace ./Stitch.xcworkspace -scheme StitchCoreSDK-Package -xcconfig DocGen/Configs/kitten.xcconfig > .raw_docs.json +sourcekitten doc --module-name StitchCoreAWSService -- -workspace ./Stitch.xcworkspace -scheme StitchCoreAWSService-Package -xcconfig DocGen/Configs/kitten.coreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchCoreAWSS3Service -- -workspace ./Stitch.xcworkspace -scheme StitchCoreAWSS3Service-Package -xcconfig DocGen/Configs/kitten.coreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchCoreAWSSESService -- -workspace ./Stitch.xcworkspace -scheme StitchCoreAWSSESService-Package -xcconfig DocGen/Configs/kitten.coreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchCoreFCMService -- -workspace ./Stitch.xcworkspace -scheme StitchCoreFCMService-Package -xcconfig DocGen/Configs/kitten.coreservice.xcconfig >> .raw_docs.json @@ -15,6 +16,7 @@ sourcekitten doc --module-name StitchCoreTwilioService -- -workspace ./Stitch.xc sourcekitten doc --module-name StitchCore -- -workspace ./Stitch.xcworkspace -scheme StitchCore -sdk macosx -xcconfig DocGen/Configs/kitten.ioscore.xcconfig >> .raw_docs.json +sourcekitten doc --module-name StitchAWSService -- -workspace ./Stitch.xcworkspace -scheme StitchAWSService -sdk macosx -xcconfig DocGen/Configs/kitten.ioscoreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchAWSS3Service -- -workspace ./Stitch.xcworkspace -scheme StitchAWSS3Service -sdk macosx -xcconfig DocGen/Configs/kitten.ioscoreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchAWSSESService -- -workspace ./Stitch.xcworkspace -scheme StitchAWSSESService -sdk macosx -xcconfig DocGen/Configs/kitten.ioscoreservice.xcconfig >> .raw_docs.json sourcekitten doc --module-name StitchFCMService -- -workspace ./Stitch.xcworkspace -scheme StitchFCMService -sdk macosx -xcconfig DocGen/Configs/kitten.ioscoreservice.xcconfig >> .raw_docs.json diff --git a/jazzy.json b/jazzy.json index 00532558..a93b8a93 100644 --- a/jazzy.json +++ b/jazzy.json @@ -23,6 +23,7 @@ "StitchAuth", "StitchAuthDelegate", "StitchPush", + "StitchServiceClient", "StitchUser", "StitchUserProfile", "StitchUserIdentity", @@ -76,8 +77,17 @@ "RemoteUpdateOptions", "RemoteUpdateResult" ] - }, { - "name": "AWS S3 Service", + }, + { + "name": "AWS Service", + "children": [ + "awsServiceClientFactory", + "AWSServiceClient", + "AWSRequest" + ] + }, + { + "name": "AWS S3 Service (deprecated)", "children": [ "awsS3ServiceClientFactory", "AWSS3ServiceClient", @@ -85,7 +95,7 @@ "AWSS3SignPolicyResult" ] }, { - "name": "AWS SES Service", + "name": "AWS SES Service (deprecated)", "children": [ "awsSESServiceClientFactory", "AWSSESServiceClient", diff --git a/scripts/add_copy_phase.py b/scripts/add_copy_phase.py index 7cfe6187..4f28417f 100644 --- a/scripts/add_copy_phase.py +++ b/scripts/add_copy_phase.py @@ -8,6 +8,7 @@ 'Core/StitchCoreSDK', 'Core/StitchCoreAdminClient', 'Core/StitchCoreTestUtils', + 'Core/Services/StitchCoreAWSService', 'Core/Services/StitchCoreAWSS3Service', 'Core/Services/StitchCoreAWSSESService', 'Core/Services/StitchCoreFCMService', @@ -16,6 +17,7 @@ 'Core/Services/StitchCoreRemoteMongoDBService', 'Core/Services/StitchCoreTwilioService', 'Darwin/StitchCore', + 'Darwin/Services/StitchAWSService', 'Darwin/Services/StitchAWSS3Service', 'Darwin/Services/StitchAWSSESService', 'Darwin/Services/StitchFCMService', diff --git a/scripts/generate_xcconfigs.py b/scripts/generate_xcconfigs.py index e6d6a38d..152b1102 100644 --- a/scripts/generate_xcconfigs.py +++ b/scripts/generate_xcconfigs.py @@ -8,6 +8,7 @@ 'Core/StitchCoreSDK', 'Core/StitchCoreAdminClient', 'Core/StitchCoreTestUtils', + 'Core/Services/StitchCoreAWSService', 'Core/Services/StitchCoreAWSS3Service', 'Core/Services/StitchCoreAWSSESService', 'Core/Services/StitchCoreFCMService', diff --git a/scripts/run_xctests.py b/scripts/run_xctests.py index 51d7cfee..781f4e88 100644 --- a/scripts/run_xctests.py +++ b/scripts/run_xctests.py @@ -43,6 +43,7 @@ def run_xctest(fmk_name): ('StitchCoreSDK', mini_module('Core/StitchCoreSDK/Sources/StitchCoreSDK')), ('StitchCoreAdminClient', mini_module('Core/StitchCoreAdminClient/Sources/StitchCoreAdminClient')), ('StitchCoreSDKMocks', mini_module('Core/StitchCoreSDK/Sources/StitchCoreSDKMocks', imports='JSONWebToken/CommonCrypto')), + ('StitchCoreAWSService', mini_module('Core/Services/StitchCoreAWSService/Sources/StitchCoreAWSService')), ('StitchCoreAWSS3Service', mini_module('Core/Services/StitchCoreAWSS3Service/Sources/StitchCoreAWSS3Service')), ('StitchCoreAWSSESService', mini_module('Core/Services/StitchCoreAWSSESService/Sources/StitchCoreAWSSESService')), ('StitchCoreFCMService', mini_module('Core/Services/StitchCoreFCMService/Sources/StitchCoreFCMService')), @@ -55,6 +56,7 @@ def run_xctest(fmk_name): mini_module('Core/Services/StitchCoreTwilioService/Sources/StitchCoreTwilioService')), # Darwin ('StitchCore', mini_module('Darwin/StitchCore/StitchCore')), + ('StitchAWSService', mini_module('Darwin/Services/StitchAWSService/StitchAWSService')), ('StitchAWSS3Service', mini_module('Darwin/Services/StitchAWSS3Service/StitchAWSS3Service')), ('StitchAWSSESService', mini_module('Darwin/Services/StitchAWSSESService/StitchAWSSESService')), ('StitchFCMService', mini_module('Darwin/Services/StitchFCMService/StitchFCMService')), @@ -68,6 +70,7 @@ def run_xctest(fmk_name): core_tests = OrderedDict([ # Core ('StitchCoreSDKTests', mini_module('Core/StitchCoreSDK/Tests/StitchCoreSDKTests', imports='JSONWebToken/CommonCrypto')), + ('StitchCoreAWSServiceTests', mini_module('Core/Services/StitchCoreAWSService/Tests/StitchCoreAWSServiceTests')), ('StitchCoreAWSS3ServiceTests', mini_module('Core/Services/StitchCoreAWSS3Service/Tests/StitchCoreAWSS3ServiceTests')), ('StitchCoreAWSSESServiceTests', mini_module('Core/Services/StitchCoreAWSSESService/Tests/StitchCoreAWSSESServiceTests')), ('StitchCoreFCMServiceTests', mini_module('Core/Services/StitchCoreFCMService/Tests/StitchCoreFCMServiceTests')), @@ -81,6 +84,8 @@ def run_xctest(fmk_name): darwin_tests = OrderedDict([ # Darwin ('StitchCoreTests', mini_module('Darwin/StitchCore/StitchCoreTests', imports='JSONWebToken/CommonCrypto')), + ('StitchAWSServiceTests', \ + mini_module('Darwin/Services/StitchAWSService/StitchAWSServiceTests', imports='JSONWebToken/CommonCrypto')), ('StitchAWSS3ServiceTests', mini_module('Darwin/Services/StitchAWSS3Service/StitchAWSS3ServiceTests')), ('StitchAWSSESServiceTests', \ mini_module('Darwin/Services/StitchAWSSESService/StitchAWSSESServiceTests', imports='JSONWebToken/CommonCrypto')),