Skip to content

Commit 7307819

Browse files
authored
chore: kickoff release
2 parents 50fbbc7 + a400a16 commit 7307819

File tree

10 files changed

+75
-13
lines changed

10 files changed

+75
-13
lines changed

.github/workflows/integ_test_api.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@ jobs:
3535
secrets: inherit
3636

3737
graphql-user-pool-test:
38+
if: ${{ false }}
3839
needs: prepare-for-test
3940
uses: ./.github/workflows/integ_test_api_graphql_user_pool.yml
4041
secrets: inherit
4142

4243
graphql-auth-directive-test:
44+
if: ${{ false }}
4345
needs: prepare-for-test
4446
uses: ./.github/workflows/integ_test_api_graphql_auth_directive.yml
4547
secrets: inherit
4648

4749
graphql-iam-test:
50+
if: ${{ false }}
4851
needs: prepare-for-test
4952
uses: ./.github/workflows/integ_test_api_graphql_iam.yml
5053
secrets: inherit
@@ -55,11 +58,13 @@ jobs:
5558
secrets: inherit
5659

5760
graphql-lazy-load-test:
61+
if: ${{ false }}
5862
needs: prepare-for-test
5963
uses: ./.github/workflows/integ_test_api_graphql_lazy_load.yml
6064
secrets: inherit
6165

6266
rest-user-pool-test:
67+
if: ${{ false }}
6368
needs: prepare-for-test
6469
uses: ./.github/workflows/integ_test_api_rest_user_pool.yml
6570
secrets: inherit

.github/workflows/integ_test_api_graphql_auth_directive.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ permissions:
99

1010
jobs:
1111
api-graphql-auth-directive-test:
12-
if: ${{ false }}
1312
runs-on: macos-12
1413
environment: IntegrationTest
1514
steps:

.github/workflows/integ_test_api_graphql_iam.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ permissions:
99

1010
jobs:
1111
api-graphql-iam-test:
12-
if: ${{ false }}
1312
runs-on: macos-12
1413
environment: IntegrationTest
1514
steps:

.github/workflows/integ_test_api_graphql_user_pool.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ permissions:
99

1010
jobs:
1111
api-graphql-user-pool-test:
12-
if: ${{ false }}
1312
runs-on: macos-12
1413
environment: IntegrationTest
1514
steps:

.github/workflows/integ_test_api_rest_user_pool.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ permissions:
99

1010
jobs:
1111
api-rest-user-pool-test:
12-
if: ${{ false }}
1312
runs-on: macos-12
1413
environment: IntegrationTest
1514
steps:

.github/workflows/integ_test_datastore.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,13 @@ jobs:
5151
secrets: inherit
5252

5353
datastore-multi-auth-test:
54+
if: ${{ false }}
5455
needs: prepare-for-test
5556
uses: ./.github/workflows/integ_test_datastore_multi_auth.yml
5657
secrets: inherit
5758

5859
datastore-transformer-v2-test:
60+
if: ${{ false }}
5961
needs: prepare-for-test
6062
uses: ./.github/workflows/integ_test_datastore_v2.yml
6163
secrets: inherit

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Subscribe/DataStoreObserveQueryOperation.swift

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class ObserveQueryTaskRunner<M: Model>: InternalTaskRunner, InternalTaskAsyncThr
226226
.filter { _ in !self.dispatchedModelSyncedEvent.get() }
227227
.filter(self.filterByModelName(mutationEvent:))
228228
.filter(self.filterByPredicateMatch(mutationEvent:))
229+
.handleEvents(receiveOutput: self.onItemChangeDuringSync(mutationEvent:) )
229230
.collect(.byTimeOrCount(self.serialQueue, self.itemsChangedPeriodicPublishTimeInSeconds, self.itemsChangedMaxSize))
230231
.sink(receiveCompletion: self.onReceiveCompletion(completed:),
231232
receiveValue: self.onItemsChangeDuringSync(mutationEvents:))
@@ -238,7 +239,7 @@ class ObserveQueryTaskRunner<M: Model>: InternalTaskRunner, InternalTaskAsyncThr
238239
receiveValue: self.onItemChangeAfterSync(mutationEvent:))
239240
}
240241
}
241-
242+
242243
func subscribeToModelSyncedEvent() {
243244
modelSyncedEventSink = Amplify.Hub.publisher(for: .dataStore).sink { event in
244245
if event.eventName == HubPayload.EventName.DataStore.modelSynced,
@@ -271,14 +272,25 @@ class ObserveQueryTaskRunner<M: Model>: InternalTaskRunner, InternalTaskAsyncThr
271272
}
272273
}
273274

274-
func onItemsChangeDuringSync(mutationEvents: [MutationEvent]) {
275-
serialQueue.async {
276-
guard self.observeQueryStarted, !mutationEvents.isEmpty else {
275+
func onItemChangeDuringSync(mutationEvent: MutationEvent) {
276+
serialQueue.async { [weak self] in
277+
guard let self = self, self.observeQueryStarted else {
277278
return
278279
}
279280

281+
self.apply(itemsChanged: [mutationEvent])
282+
}
283+
}
284+
285+
func onItemsChangeDuringSync(mutationEvents: [MutationEvent]) {
286+
serialQueue.async { [weak self] in
287+
guard let self = self,
288+
self.observeQueryStarted,
289+
!mutationEvents.isEmpty,
290+
!self.dispatchedModelSyncedEvent.get()
291+
else { return }
292+
280293
self.startSnapshotStopWatch()
281-
self.apply(itemsChanged: mutationEvents)
282294
self.sendSnapshot()
283295
}
284296
}

AmplifyPlugins/DataStore/Sources/AWSDataStorePlugin/Sync/InitialSync/ModelSyncedEventEmitter.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ final class ModelSyncedEventEmitter {
150150
}
151151

152152
modelSyncedEventTopic.send(.mutationEventApplied(event))
153-
154153
if shouldSendModelSyncedEvent {
155154
sendModelSyncedEvent()
156155
}

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/AWSDataStorePluginIntegrationTests/DataStoreObserveQueryTests.swift

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,54 @@ class DataStoreObserveQueryTests: SyncEngineIntegrationTestBase {
301301
XCTAssertTrue(snapshots.last!.items.count > numberOfPosts)
302302
}
303303

304+
305+
/// ObserveQuery with DataStore sync. Ensure datastore is cleared.
306+
/// When ObserveQuery is called, it will start DataStore and perform a full sync on max records.
307+
///
308+
/// - Given: DataStore is cleared.
309+
/// - When:
310+
/// - ObserveQuery is called to do perform full sync
311+
/// - Then:
312+
/// - The first snapshot should have the old data and `isSynced` false
313+
/// - The final snapshot should have all the latest models with `isSynced` true
314+
///
315+
func testObserveQuery_withClearedDataStore_fullySyncedWithMaxRecords() async throws {
316+
await setUp(withModels: TestModelRegistration())
317+
try await startAmplifyAndWaitForReady()
318+
try await clearDataStore()
319+
320+
let snapshotWithIsSynced = asyncExpectation(description: "query snapshot with isSynced true")
321+
var snapshots = [DataStoreQuerySnapshot<Post>]()
322+
323+
Amplify.Publisher.create(Amplify.DataStore.observeQuery(for: Post.self)).sink { completed in
324+
switch completed {
325+
case .finished:
326+
break
327+
case .failure(let error):
328+
XCTFail("\(error)")
329+
}
330+
} receiveValue: { querySnapshot in
331+
snapshots.append(querySnapshot)
332+
if querySnapshot.isSynced {
333+
Task { await snapshotWithIsSynced.fulfill() }
334+
}
335+
}.store(in: &cancellables)
336+
337+
let newPost = Post(title: "title", content: "content", createdAt: .now())
338+
let receivedPost = asyncExpectation(description: "received Post")
339+
try await savePostAndWaitForSync(newPost,
340+
postSyncedExpctation: receivedPost)
341+
342+
await waitForExpectations([snapshotWithIsSynced, receivedPost], timeout: 30)
343+
XCTAssertTrue(snapshots.count >= 2)
344+
XCTAssertFalse(snapshots[0].isSynced)
345+
XCTAssertEqual(1, snapshots.filter({ $0.isSynced }).count)
346+
347+
let theSyncedSnapshot = snapshots.first(where: { $0.isSynced })
348+
XCTAssertNotNil(theSyncedSnapshot)
349+
XCTAssertTrue(theSyncedSnapshot!.items.contains(newPost))
350+
}
351+
304352
/// ObserveQuery is set up with a query predicate.
305353
/// Sync is completed and actions are applied after sync to observe expected snapshots.
306354
///

AmplifyPlugins/DataStore/Tests/DataStoreHostApp/DataStoreHostApp.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
21182143289BFBC4001B5945 /* AWSAPIPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 21182142289BFBC4001B5945 /* AWSAPIPlugin */; };
2929
21182145289BFBC4001B5945 /* AWSCognitoAuthPlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 21182144289BFBC4001B5945 /* AWSCognitoAuthPlugin */; };
3030
21182147289BFBC4001B5945 /* AWSDataStorePlugin in Frameworks */ = {isa = PBXBuildFile; productRef = 21182146289BFBC4001B5945 /* AWSDataStorePlugin */; };
31+
211F5094296DD4C30040EB62 /* AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211F5093296DD4C30040EB62 /* AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift */; };
3132
2138482A2947ACCF00BBA647 /* AWSDataStoreLazyLoadBlogPostComment8V2Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213848292947ACCF00BBA647 /* AWSDataStoreLazyLoadBlogPostComment8V2Tests.swift */; };
3233
2138482C2947F89C00BBA647 /* AWSDataStoreLazyLoadingBlogPostCmment8V2SnapshotTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2138482B2947F89C00BBA647 /* AWSDataStoreLazyLoadingBlogPostCmment8V2SnapshotTests.swift */; };
33-
211F5094296DD4C30040EB62 /* AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 211F5093296DD4C30040EB62 /* AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift */; };
3434
213DBB9C28A5743600B30280 /* ModelImplicitDefaultPk+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213DBB6228A5743200B30280 /* ModelImplicitDefaultPk+Schema.swift */; };
3535
213DBB9D28A5743600B30280 /* ModelImplicitDefaultPk.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213DBB6328A5743200B30280 /* ModelImplicitDefaultPk.swift */; };
3636
213DBB9E28A5743600B30280 /* ModelExplicitDefaultPk+Schema.swift in Sources */ = {isa = PBXBuildFile; fileRef = 213DBB6428A5743200B30280 /* ModelExplicitDefaultPk+Schema.swift */; };
@@ -759,7 +759,6 @@
759759
21182131289BFB4B001B5945 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
760760
21182133289BFB4F001B5945 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
761761
21182136289BFB4F001B5945 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
762-
2118213E289BFB63001B5945 /* amplify-ios-staging */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "amplify-ios-staging"; path = ../../../..; sourceTree = "<group>"; };
763762
211F5093296DD4C30040EB62 /* AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSDataStorePrimaryKeyPostCommentCompositeKeyTest.swift; sourceTree = "<group>"; };
764763
213848292947ACCF00BBA647 /* AWSDataStoreLazyLoadBlogPostComment8V2Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSDataStoreLazyLoadBlogPostComment8V2Tests.swift; sourceTree = "<group>"; };
765764
2138482B2947F89C00BBA647 /* AWSDataStoreLazyLoadingBlogPostCmment8V2SnapshotTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSDataStoreLazyLoadingBlogPostCmment8V2SnapshotTests.swift; sourceTree = "<group>"; };
@@ -1317,6 +1316,7 @@
13171316
21DFAE9D295F4E8600B4A883 /* PhoneCall.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PhoneCall.swift; sourceTree = "<group>"; };
13181317
21DFAE9E295F4E8600B4A883 /* Transcript.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Transcript.swift; sourceTree = "<group>"; };
13191318
21DFAEA5295F4E9E00B4A883 /* AWSDataStoreLazyLoadPhoneCallTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AWSDataStoreLazyLoadPhoneCallTests.swift; sourceTree = "<group>"; };
1319+
60CB6B3E2A1454F90051BAD2 /* amplify-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "amplify-swift"; path = ../../../..; sourceTree = "<group>"; };
13201320
681DFE8028E746C10000C36A /* AsyncTesting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncTesting.swift; sourceTree = "<group>"; };
13211321
681DFE8128E746C10000C36A /* AsyncExpectation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AsyncExpectation.swift; sourceTree = "<group>"; };
13221322
681DFE8228E746C10000C36A /* XCTestCase+AsyncTesting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "XCTestCase+AsyncTesting.swift"; sourceTree = "<group>"; };
@@ -1554,7 +1554,7 @@
15541554
2118213D289BFB63001B5945 /* Packages */ = {
15551555
isa = PBXGroup;
15561556
children = (
1557-
2118213E289BFB63001B5945 /* amplify-ios-staging */,
1557+
60CB6B3E2A1454F90051BAD2 /* amplify-swift */,
15581558
);
15591559
name = Packages;
15601560
sourceTree = "<group>";

0 commit comments

Comments
 (0)