Skip to content

Commit d4163e6

Browse files
authored
chore: kickoff release
2 parents ee5cdde + 457d53e commit d4163e6

File tree

27 files changed

+682
-188
lines changed

27 files changed

+682
-188
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,13 @@
1313
- [ ] PR title conforms to conventional commit style
1414
- [ ] If breaking change, documentation/changelog update with migration instructions
1515

16+
*DataStore checkpoints (check when completed)*
17+
18+
- [ ] Ran AWSDataStorePluginIntegrationTests
19+
- [ ] Ran AWSDataStorePluginV2Tests
20+
- [ ] Ran AWSDataStorePluginMultiAuthTests
21+
- [ ] Ran AWSDataStorePluginCPKTests
22+
- [ ] Ran AWSDataStorePluginAuthCognitoTests
23+
- [ ] Ran AWSDataStorePluginAuthIAMTests
24+
1625
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

.github/workflows/integ_test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Integration Tests
22
on:
3+
workflow_dispatch:
34
push:
45
branches: [main]
56

.github/workflows/integ_test_api.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: API Integration Tests
22
on:
3+
workflow_dispatch:
34
push:
45
branches: [main]
56

.github/workflows/integ_test_datastore.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: DataStore Integration Tests
22
on:
3+
workflow_dispatch:
34
push:
45
branches: [main]
56

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: DataStore TransformerV2 Tests
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
id-token: write
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.head_ref || github.run_id }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
prepare-for-test:
17+
runs-on: macos-12
18+
environment: IntegrationTest
19+
steps:
20+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
21+
with:
22+
persist-credentials: false
23+
24+
- name: Verify copy resources
25+
uses: ./.github/composite_actions/download_test_configuration
26+
with:
27+
resource_subfolder: NA
28+
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
29+
aws_region: ${{ secrets.AWS_REGION }}
30+
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG }}
31+
32+
datastore-integration-v2-test:
33+
continue-on-error: true
34+
timeout-minutes: 30
35+
needs: prepare-for-test
36+
runs-on: macos-12
37+
environment: IntegrationTest
38+
steps:
39+
- uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
40+
with:
41+
persist-credentials: false
42+
43+
- name: Make directory
44+
run: mkdir -p ~/.aws-amplify/amplify-ios/testconfiguration/
45+
46+
- name: Copy integration test resouces
47+
uses: ./.github/composite_actions/download_test_configuration
48+
with:
49+
resource_subfolder: datastore
50+
aws_role_to_assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
51+
aws_region: ${{ secrets.AWS_REGION }}
52+
aws_s3_bucket: ${{ secrets.AWS_S3_BUCKET_INTEG }}
53+
54+
- name: Run Integration test
55+
uses: ./.github/composite_actions/run_xcodebuild_test
56+
with:
57+
project_path: ./AmplifyPlugins/DataStore/Tests/DataStoreHostApp
58+
scheme: AWSDataStorePluginV2Tests
59+
60+

Amplify/Categories/Storage/StorageCategory+ClientBehavior.swift

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,60 @@ import Foundation
1010
extension StorageCategory: StorageCategoryBehavior {
1111

1212
@discardableResult
13-
public func getURL(key: String,
14-
options: StorageGetURLOperation.Request.Options? = nil) async throws -> URL {
13+
public func getURL(
14+
key: String,
15+
options: StorageGetURLOperation.Request.Options? = nil
16+
) async throws -> URL {
1517
try await plugin.getURL(key: key, options: options)
1618
}
1719

1820
@discardableResult
19-
public func downloadData(key: String,
20-
options: StorageDownloadDataOperation.Request.Options? = nil) async throws -> StorageDownloadDataTask {
21-
try await plugin.downloadData(key: key, options: options)
21+
public func downloadData(
22+
key: String,
23+
options: StorageDownloadDataOperation.Request.Options? = nil
24+
) -> StorageDownloadDataTask {
25+
plugin.downloadData(key: key, options: options)
2226
}
2327

2428
@discardableResult
25-
public func downloadFile(key: String,
26-
local: URL,
27-
options: StorageDownloadFileOperation.Request.Options?) async throws -> StorageDownloadFileTask {
28-
try await plugin.downloadFile(key: key, local: local, options: options)
29+
public func downloadFile(
30+
key: String,
31+
local: URL,
32+
options: StorageDownloadFileOperation.Request.Options? = nil
33+
) -> StorageDownloadFileTask {
34+
plugin.downloadFile(key: key, local: local, options: options)
2935
}
3036

3137
@discardableResult
32-
public func uploadData(key: String,
33-
data: Data,
34-
options: StorageUploadDataOperation.Request.Options? = nil) async throws -> StorageUploadDataTask {
35-
try await plugin.uploadData(key: key, data: data, options: options)
38+
public func uploadData(
39+
key: String,
40+
data: Data,
41+
options: StorageUploadDataOperation.Request.Options? = nil
42+
) -> StorageUploadDataTask {
43+
plugin.uploadData(key: key, data: data, options: options)
3644
}
3745

3846
@discardableResult
39-
public func uploadFile(key: String,
40-
local: URL,
41-
options: StorageUploadFileOperation.Request.Options? = nil) async throws -> StorageUploadFileTask {
42-
try await plugin.uploadFile(key: key, local: local, options: options)
47+
public func uploadFile(
48+
key: String,
49+
local: URL,
50+
options: StorageUploadFileOperation.Request.Options? = nil
51+
) -> StorageUploadFileTask {
52+
plugin.uploadFile(key: key, local: local, options: options)
4353
}
4454

4555
@discardableResult
46-
public func remove(key: String,
47-
options: StorageRemoveRequest.Options? = nil) async throws -> String {
56+
public func remove(
57+
key: String,
58+
options: StorageRemoveRequest.Options? = nil
59+
) async throws -> String {
4860
try await plugin.remove(key: key, options: options)
4961
}
5062

5163
@discardableResult
52-
public func list(options: StorageListOperation.Request.Options? = nil) async throws -> StorageListResult {
64+
public func list(
65+
options: StorageListOperation.Request.Options? = nil
66+
) async throws -> StorageListResult {
5367
try await plugin.list(options: options)
5468
}
5569

Amplify/Categories/Storage/StorageCategoryBehavior.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public protocol StorageCategoryBehavior {
2828
/// - Returns: A task that provides progress updates and the key which was used to download
2929
@discardableResult
3030
func downloadData(key: String,
31-
options: StorageDownloadDataOperation.Request.Options?) async throws -> StorageDownloadDataTask
31+
options: StorageDownloadDataOperation.Request.Options?) -> StorageDownloadDataTask
3232

3333
/// Download to file the object from storage.
3434
///
@@ -40,7 +40,7 @@ public protocol StorageCategoryBehavior {
4040
@discardableResult
4141
func downloadFile(key: String,
4242
local: URL,
43-
options: StorageDownloadFileOperation.Request.Options?) async throws -> StorageDownloadFileTask
43+
options: StorageDownloadFileOperation.Request.Options?) -> StorageDownloadFileTask
4444

4545
/// Upload data to storage
4646
///
@@ -52,7 +52,7 @@ public protocol StorageCategoryBehavior {
5252
@discardableResult
5353
func uploadData(key: String,
5454
data: Data,
55-
options: StorageUploadDataOperation.Request.Options?) async throws -> StorageUploadDataTask
55+
options: StorageUploadDataOperation.Request.Options?) -> StorageUploadDataTask
5656

5757
/// Upload local file to storage
5858
///
@@ -64,7 +64,7 @@ public protocol StorageCategoryBehavior {
6464
@discardableResult
6565
func uploadFile(key: String,
6666
local: URL,
67-
options: StorageUploadFileOperation.Request.Options?) async throws -> StorageUploadFileTask
67+
options: StorageUploadFileOperation.Request.Options?) -> StorageUploadFileTask
6868

6969
/// Delete object from storage
7070
///

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin+DataStoreBaseBehavior.swift

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,17 @@ extension AWSDataStorePlugin: DataStoreBaseBehavior {
419419
dispatchedModelSynced.set(false)
420420
}
421421
if storageEngine == nil {
422-
423-
completion(.successfulVoid)
422+
queue.async {
423+
completion(.successfulVoid)
424+
}
424425
return
425426
}
426427

427428
storageEngine.stopSync { result in
428429
self.storageEngine = nil
429-
completion(result)
430+
self.queue.async {
431+
completion(result)
432+
}
430433
}
431434
}
432435
}
@@ -451,12 +454,16 @@ extension AWSDataStorePlugin: DataStoreBaseBehavior {
451454
dispatchedModelSynced.set(false)
452455
}
453456
if storageEngine == nil {
454-
completion(.successfulVoid)
457+
queue.async {
458+
completion(.successfulVoid)
459+
}
455460
return
456461
}
457462
storageEngine.clear { result in
458463
self.storageEngine = nil
459-
completion(result)
464+
self.queue.async {
465+
completion(result)
466+
}
460467
}
461468
}
462469
}

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/AWSDataStorePlugin.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ final public class AWSDataStorePlugin: DataStoreCategoryPlugin {
5454

5555
var storageEngine: StorageEngineBehavior!
5656
var storageEngineInitQueue = DispatchQueue(label: "AWSDataStorePlugin.storageEngineInitQueue")
57+
var queue = DispatchQueue(label: "AWSDataStorePlugin.queue", target: DispatchQueue.global())
5758
var storageEngineBehaviorFactory: StorageEngineBehaviorFactory
5859

5960
var iStorageEngineSink: Any?

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/MutationSync/OutgoingMutationQueue/ProcessMutationErrorFromCloudOperation.swift

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,42 @@ class ProcessMutationErrorFromCloudOperation: AsynchronousOperation {
5454
return
5555
}
5656

57-
if let apiError = apiError, isAuthSignedOutError(apiError: apiError) {
57+
if let apiError = apiError {
58+
if isAuthSignedOutError(apiError: apiError) {
59+
log.verbose("User is signed out, passing error back to the error handler, and removing mutation event.")
60+
} else if let underlyingError = apiError.underlyingError {
61+
log.debug("Received APIError: \(apiError.localizedDescription) with underlying error: \(underlyingError.localizedDescription)")
62+
} else {
63+
log.debug("Received APIError: \(apiError.localizedDescription)")
64+
}
5865
dataStoreConfiguration.errorHandler(DataStoreError.api(apiError, mutationEvent))
5966
finish(result: .success(nil))
6067
return
6168
}
6269

63-
guard let graphQLResponseError = graphQLResponseError,
64-
case let .error(graphQLErrors) = graphQLResponseError else {
65-
finish(result: .success(nil))
66-
return
70+
guard let graphQLResponseError = graphQLResponseError else {
71+
dataStoreConfiguration.errorHandler(
72+
DataStoreError.api(APIError.unknown("This is unexpected. Missing APIError and GraphQLError.", ""),
73+
mutationEvent))
74+
finish(result: .success(nil))
75+
return
76+
}
77+
78+
guard case let .error(graphQLErrors) = graphQLResponseError else {
79+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
80+
finish(result: .success(nil))
81+
return
6782
}
6883

6984
guard graphQLErrors.count == 1 else {
7085
log.error("Received more than one error response: \(String(describing: graphQLResponseError))")
86+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
7187
finish(result: .success(nil))
7288
return
7389
}
7490

7591
guard let graphQLError = graphQLErrors.first else {
92+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
7693
finish(result: .success(nil))
7794
return
7895
}
@@ -84,22 +101,26 @@ class ProcessMutationErrorFromCloudOperation: AsynchronousOperation {
84101
let payload = HubPayload(eventName: HubPayload.EventName.DataStore.conditionalSaveFailed,
85102
data: mutationEvent)
86103
Amplify.Hub.dispatch(to: .dataStore, payload: payload)
104+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
87105
finish(result: .success(nil))
88106
case .conflictUnhandled:
89107
processConflictUnhandled(extensions)
90108
case .unauthorized:
91-
// TODO: dispatch Hub event
92109
log.debug("Unauthorized mutation \(errorType)")
110+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
93111
finish(result: .success(nil))
94112
case .operationDisabled:
95113
log.debug("Operation disabled \(errorType)")
114+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
96115
finish(result: .success(nil))
97116
case .unknown(let errorType):
98117
log.debug("Unhandled error with errorType \(errorType)")
118+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
99119
finish(result: .success(nil))
100120
}
101121
} else {
102122
log.debug("GraphQLError missing extensions and errorType \(graphQLError)")
123+
dataStoreConfiguration.errorHandler(DataStoreError.api(graphQLResponseError, mutationEvent))
103124
finish(result: .success(nil))
104125
}
105126
}

0 commit comments

Comments
 (0)