-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(@aws-amplify/datastore): nested predicates on observe, observeQuery, TS fixes #9195
feat(@aws-amplify/datastore): nested predicates on observe, observeQuery, TS fixes #9195
Conversation
…cements (aws-amplify#9141) * feat(@aws-amplify/datastore): constrain ObserveQuery options with explicit Type, add time interval/limit Promise race * feat(@aws-amplify/datastore): address PR callouts * feat(@aws-amplify/datastore): abstract SubscriptionBuffer to util class (TODO: add unit test) * feat(@aws-amplify/datastore): add unit test for util class * remove .only from test * feat(@aws-amplify/datastore): address PR callouts * remove .only from describe block * feat(@aws-amplify/datastore): PR-callouts, adjust naming conventions Co-authored-by: Sam Martinez <samlmar@amazon.com>
… when it is a killed state (aws-amplify#9055) * feat: new script to improve local dev experience for RN * feat: rn local dev script * docs: adds the needed documentation for running the local rn dev script * fix: pr review changes, formatting and code clean up * fix: refactored the open tab function and minor code cleanup * refactor: utility functions for lerna and wml cmd formation and added comments * fix: attempt to fix the lgtm bot issue to sanitized the path input * fix: attempt 2 to build cmds after sanitizing the path * fix: attempt three at solving the bot warning, sanatizes alias,npm bin and cd commands * refactor * fix: attempt four at fixing the lgtm warning * fix: clearer documentation on the usage of the script * refactor: change get delay and open new tab names * refactor: changed all caps wording to camel case for gotopackageroot element * feat: all flag to indicate script should use all supported packages * fix: adds a new UI packages list that is used to change their package name to directory name used in wml * refactor: adds a clear note to indicate script is different from the linking method of development * fix:handle reactContext is null by listening to changes * refactor: rephrase comment Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> * refactor: emitNotificationOpened has been refactored to a new function and other nits * fix: adds an intent parameter to emitNotificationOpenedEvent * refactor: makes variables final Co-authored-by: Manoj NB <manojnb@amazon.com> Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> Co-authored-by: Sam Martinez <samlmar@amazon.com> Co-authored-by: Ashish Nanda <ashish.nanda.5591@gmail.com>
This reverts commit 13e776e.
- @aws-amplify/ui-angular@1.0.33 - @aws-amplify/ui-components@1.9.4 - @aws-amplify/ui-react@1.2.24 - @aws-amplify/ui-storybook@2.0.24 - @aws-amplify/ui-vue@1.1.18 - @aws-amplify/analytics@5.1.4 - @aws-amplify/api-graphql@2.2.13 - @aws-amplify/api-rest@2.0.24 - @aws-amplify/api@4.0.24 - @aws-amplify/auth@4.3.14 - aws-amplify-angular@6.0.24 - aws-amplify-react-native@6.0.1 - aws-amplify-react@5.1.7 - aws-amplify@4.3.6 - @aws-amplify/cache@4.0.26 - @aws-amplify/core@4.3.6 - @aws-amplify/datastore-storage-adapter@1.1.12 - @aws-amplify/datastore@3.6.0 - @aws-amplify/geo@1.1.6 - @aws-amplify/interactions@4.0.24 - @aws-amplify/predictions@4.0.24 - @aws-amplify/pubsub@4.2.0 - @aws-amplify/pushnotification@4.3.3 - @aws-amplify/storage@4.4.7 - @aws-amplify/xr@3.0.24
Codecov Report
@@ Coverage Diff @@
## datastore-laziness #9195 +/- ##
======================================================
+ Coverage 78.91% 79.10% +0.19%
======================================================
Files 251 251
Lines 18555 18619 +64
Branches 3985 4046 +61
======================================================
+ Hits 14642 14729 +87
+ Misses 3784 3761 -23
Partials 129 129
Continue to review full report at Codecov.
|
…ws-amplify#9191) * feat: new script to improve local dev experience for RN * feat: rn local dev script * docs: adds the needed documentation for running the local rn dev script * fix: pr review changes, formatting and code clean up * fix: refactored the open tab function and minor code cleanup * refactor: utility functions for lerna and wml cmd formation and added comments * fix: attempt to fix the lgtm bot issue to sanitized the path input * fix: attempt 2 to build cmds after sanitizing the path * fix: attempt three at solving the bot warning, sanatizes alias,npm bin and cd commands * refactor * fix: attempt four at fixing the lgtm warning * fix: clearer documentation on the usage of the script * refactor: change get delay and open new tab names * refactor: changed all caps wording to camel case for gotopackageroot element * feat: all flag to indicate script should use all supported packages * fix: adds a new UI packages list that is used to change their package name to directory name used in wml * refactor: adds a clear note to indicate script is different from the linking method of development * chore: upgrade firebase package and made required changes to getToken and onNewToken * refactor: review comments, added exception handling to get token * Apply suggestions from code review Co-authored-by: Sam Martinez <sammartinez19@gmail.com> Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> * refactor: formatting updates * refactor: formatting updates * remove react event listener so no multiples are registered and adds an error callback to get token Co-authored-by: Manoj NB <manojnb@amazon.com> Co-authored-by: Ashish Nanda <ashish.nanda.5591@gmail.com> Co-authored-by: Caleb Pollman <cpollman1@gmail.com> Co-authored-by: Sam Martinez <sammartinez19@gmail.com> Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
8835c30
to
77ac3c4
Compare
This pull request introduces 1 alert when merging 77ac3c4 into 743bf8f - view on LGTM.com new alerts:
|
This pull request introduces 1 alert when merging c2c2909 into 743bf8f - view on LGTM.com new alerts:
|
fadc51d
to
fd8e051
Compare
This pull request introduces 1 alert when merging 866acc9 into 23ed2f3 - view on LGTM.com new alerts:
|
- @aws-amplify/ui-angular@1.0.34 - @aws-amplify/ui-components@1.9.5 - @aws-amplify/ui-react@1.2.25 - @aws-amplify/ui-storybook@2.0.25 - @aws-amplify/ui-vue@1.1.19 - @aws-amplify/analytics@5.1.5 - @aws-amplify/api-graphql@2.2.14 - @aws-amplify/api-rest@2.0.25 - @aws-amplify/api@4.0.25 - @aws-amplify/auth@4.3.15 - aws-amplify-angular@6.0.25 - aws-amplify-react@5.1.8 - aws-amplify@4.3.7 - @aws-amplify/cache@4.0.27 - @aws-amplify/core@4.3.7 - @aws-amplify/datastore-storage-adapter@1.1.13 - @aws-amplify/datastore@3.6.1 - @aws-amplify/geo@1.1.7 - @aws-amplify/interactions@4.0.25 - @aws-amplify/predictions@4.0.25 - @aws-amplify/pubsub@4.2.1 - @aws-amplify/pushnotification@4.3.4 - @aws-amplify/storage@4.4.8 - @aws-amplify/xr@3.0.25
This pull request introduces 1 alert when merging cecf0ae into 23ed2f3 - view on LGTM.com new alerts:
|
- @aws-amplify/ui-angular@1.0.35 - @aws-amplify/ui-components@1.9.6 - @aws-amplify/ui-react@1.2.26 - @aws-amplify/ui-storybook@2.0.26 - @aws-amplify/ui-vue@1.1.20 - @aws-amplify/analytics@5.1.6 - @aws-amplify/api-graphql@2.2.15 - @aws-amplify/api-rest@2.0.26 - @aws-amplify/api@4.0.26 - @aws-amplify/auth@4.3.16 - aws-amplify-angular@6.0.26 - aws-amplify-react@5.1.9 - aws-amplify@4.3.8 - @aws-amplify/cache@4.0.28 - @aws-amplify/core@4.3.8 - @aws-amplify/datastore-storage-adapter@1.2.0 - @aws-amplify/datastore@3.7.0 - @aws-amplify/geo@1.1.8 - @aws-amplify/interactions@4.0.26 - @aws-amplify/predictions@4.0.26 - @aws-amplify/pubsub@4.2.2 - @aws-amplify/pushnotification@4.3.5 - @aws-amplify/storage@4.4.9 - @aws-amplify/xr@3.0.26
Co-authored-by: Nick Arocho <16296496+nickarocho@users.noreply.github.com>
3f40c34
to
fbd4274
Compare
This pull request introduces 1 alert when merging fbd4274 into b2eaa3e - view on LGTM.com new alerts:
|
@@ -13,7 +13,8 @@ import { | |||
PersistentModel, | |||
PersistentModelConstructor, | |||
} from '../src/types'; | |||
import { Model, Post, Metadata, testSchema } from './helpers'; | |||
import { Comment, Model, Post, Metadata, testSchema } from './helpers'; | |||
import { UpdatingHookContext } from 'dexie'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing it due to the many diffs in this file, but where is UpdatingHookContext
being used? And what does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a really good question ... I didn't actually add this. I thought it showed up during the merge/rebase. But, it's not used. I'll remove it!
expectType<PersistentModelConstructor<PersistentModel>>(model); | ||
expectType<PersistentModel>(element); | ||
expect(opType).toEqual('INSERT'); | ||
expect(element.field1).toEqual('Smurfs'); | ||
sub.unsubscribe(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is unsubscribe
called here for cleanup purposes? Or is it affecting the intended behavior of the model in the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't remember, honestly.
I have a vague memory that I added these partly to ensure that calling unsubscribe()
didn't blow anything up — it would be called in the normal course of things. I wanted to ensure I mirrored correct/normal usage.
@@ -1,5 +1,5 @@ | |||
import { ModelMerger } from '../src/sync/merger'; | |||
import { PersistentModelConstructor } from '../src/'; | |||
import { PersistentModelConstructor, ModelInstanceMetadata } from '../src/'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another large diff question: I don't seeModelInstanceMetadata
being used in this test file. Why import it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really not sure why this was added. Artifact of the merge. Removing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little surprised our TS Config doesn't catch unused imports 🤔
@@ -1164,14 +1203,14 @@ class DataStore { | |||
throw new Error(msg); | |||
} | |||
|
|||
if (typeof idOrCriteria === 'string') { | |||
if (typeof idOrCriteria === 'string' && modelConstructor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably just my lack of understanding of this specific method, but why check for modelConstructor
if it isn't being passed anymore? (via old diff getModelDefinition(modelConstructor)
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. Seems to be cruft. Removing.
// TODO: abstract this function into a util file to be able to write better unit tests | ||
const generateSnapshot = (): DataStoreSnapshot<T> => { | ||
const isSynced = this.sync?.getModelSyncedStatus(model) ?? false; | ||
const isSynced = this.sync?.getModelSyncedStatus(model) ?? true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want isSynced
to default to true here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appeared to be a non-impactful change outside of a little debugging session. But, I didn't intend to leave it swapped. Fixing.
// case 'MANY_TO_MANY': | ||
// // TODO: implement | ||
// throw new Error('WRITE THIS CODE'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumping to remove.
// case 'MANY_TO_MANY': | ||
// // TODO: implement | ||
// throw new Error('WRITE THIS CODE'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same bump to remove.
@@ -390,7 +387,7 @@ export const traverseModel = <T extends PersistentModel>( | |||
// // Intentionally blank | |||
// break; | |||
// default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any clarification on this?
This pull request introduces 1 alert when merging da57c65 into b2eaa3e - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 Thanks for fixing the nit comments and removing the lingering cruft. This was a beast of a PR, thanks for the great improvements, Jon! 🚢🍾
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Description of changes
This PR was initially about getting nested predicates to work for
observe
andobserveQuery
.This effort snowballed into a few other areas as it brought my attention to a small mismatch with the design, which snowballed into other areas.
Here's what this includes:
observe
andobserveQuery
.observe
andobserveQuery
to work with new lazy loading behavior.AsyncCollection
to not be a promise.Promise
/AsyncCollection
and corrects associated tests.ModelInit
to extract inner "settable" types and derive required-ness.DeepWritable
. Updates are intended to force assignment to all top-level props instead of nested property updates.I had not planned on addressing TS gaps in this PR. That work was originally intended to be done with cascading saves. But, it seemed the path of least resistance to ensure we didn't leave any test models behind.
Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.