Skip to content

Commit

Permalink
feat(@aws-amplify/datastore): nested predicates on observe, observeQu…
Browse files Browse the repository at this point in the history
…ery, TS fixes (#9195)

* feat(@aws-amplify/datastore): ObserveQuery performance and type enhancements (#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>

* fix(@aws-amplify/pushnotification): tap on notification opens the app when it is a killed state (#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>

* feat(amplify-js): add CD support (#9171)

* fix: AWSAppSyncRealTimeProvider websocket init fix

* Revert "fix: AWSAppSyncRealTimeProvider websocket init fix"

This reverts commit 13e776e.

* fix: AWSAppSyncRealTimeProvider websocket init fix (#9200)

* chore: preparing release

* chore(release): Publish [ci skip]

 - @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

* chore(release): update version.ts [ci skip]

* fix(@aws-amplify/pushnotification): Upgrade Firebase Android package (#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>

* chore: preparing release

* chore(release): Publish [ci skip]

 - @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

* chore(release): update version.ts [ci skip]

* feat(@aws-amplify/datastore): hasOne CRUD improvements (#9239)

* fix(geo): update client-location to fix tslib issue (#9247)

#8967

* chore: preparing release

* chore(release): Publish [ci skip]

 - @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

* chore(release): update version.ts [ci skip]

* chore(@aws-amplify/datastore): bump dexie packages (#9262)

* chore: mark ui packages as private (#9251)

* fix(@aws-amplify/datastore): belongsTo bug (#9268)

* fix(@aws-amplify/core): Use undefined for default sequence token with CloudWatch logging (#9181)

Co-authored-by: Aaron Michael Lamb <aarolamb@amazon.com>
Co-authored-by: Ashika <35131273+ashika01@users.noreply.github.com>

* chore(@aws-amplify/analytics): Changed a couple file in dos format to unix (#9199)

* dos->unix

Co-authored-by: Sam Martinez  <sammartinez19@gmail.com>
Co-authored-by: Ashika <35131273+ashika01@users.noreply.github.com>

* fix(@aws-amplify/datastore): consecutive saves with timestamps (#9298)

* chore: preparing release

* chore(release): Publish [ci skip]

 - @aws-amplify/ui-angular@1.0.36
 - @aws-amplify/ui-components@1.9.7
 - @aws-amplify/ui-react@1.2.27
 - @aws-amplify/ui-storybook@2.0.27
 - @aws-amplify/ui-vue@1.1.21
 - @aws-amplify/ui@2.0.4
 - @aws-amplify/analytics@5.1.7
 - @aws-amplify/api-graphql@2.2.16
 - @aws-amplify/api-rest@2.0.27
 - @aws-amplify/api@4.0.27
 - @aws-amplify/auth@4.3.17
 - aws-amplify-angular@6.0.27
 - aws-amplify-react@5.1.10
 - aws-amplify-vue@2.1.6
 - aws-amplify@4.3.9
 - @aws-amplify/cache@4.0.29
 - @aws-amplify/core@4.3.9
 - @aws-amplify/datastore-storage-adapter@1.2.1
 - @aws-amplify/datastore@3.7.1
 - @aws-amplify/geo@1.1.9
 - @aws-amplify/interactions@4.0.27
 - @aws-amplify/predictions@4.0.27
 - @aws-amplify/pubsub@4.2.3
 - @aws-amplify/pushnotification@4.3.6
 - @aws-amplify/storage@4.4.10
 - @aws-amplify/xr@3.0.27

* chore(release): update version.ts [ci skip]

* fix(@aws-amplify/amplify-ui): change private property to false in package.json (#9303)

Resolving an issue with installing the library

* chore: preparing release

* fix(@aws-amplify/amplify-ui): remove private prop from package.json (#9304)

* fix(@aws-amplify/amplify-ui): change private property to false in package.json

* fix(@aws-amplify/amplify-ui): remove private property from package.json

Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

* fix(@aws-amplify/amplify-ui): remove private prop from package.json (#9304)

* fix(@aws-amplify/amplify-ui): change private property to false in package.json

* fix(@aws-amplify/amplify-ui): remove private property from package.json

Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

* chore(release): Publish [ci skip]

 - @aws-amplify/ui-angular@1.0.37
 - @aws-amplify/ui-components@1.9.8
 - @aws-amplify/ui-react@1.2.28
 - @aws-amplify/ui-storybook@2.0.28
 - @aws-amplify/ui-vue@1.1.22
 - @aws-amplify/ui@2.0.5
 - @aws-amplify/analytics@5.1.8
 - @aws-amplify/api-graphql@2.2.17
 - @aws-amplify/api-rest@2.0.28
 - @aws-amplify/api@4.0.28
 - @aws-amplify/auth@4.3.18
 - aws-amplify-angular@6.0.28
 - aws-amplify-react@5.1.11
 - aws-amplify@4.3.10
 - @aws-amplify/cache@4.0.30
 - @aws-amplify/core@4.3.10
 - @aws-amplify/datastore-storage-adapter@1.2.2
 - @aws-amplify/datastore@3.7.2
 - @aws-amplify/geo@1.1.10
 - @aws-amplify/interactions@4.0.28
 - @aws-amplify/predictions@4.0.28
 - @aws-amplify/pubsub@4.2.4
 - @aws-amplify/pushnotification@4.3.7
 - @aws-amplify/storage@4.4.11
 - @aws-amplify/xr@3.0.28

* chore(release): update version.ts [ci skip]

* fix(@aws-amplify/datastore): fixes observeQuery in local-only mode (#9300)

* fix(@aws-amplify/pushnotification): make eligible variables final (#9301)

Co-authored-by: Manoj NB <manojnb@amazon.com>
Co-authored-by: Caleb Pollman <cpollman1@gmail.com>

* fix(@aws-amplify/aws-amplify-react-native): fix dev build for Windows (#9341)

* fix(@aws-amplify/api-graphql): Fix webpack build (#9358)

* chore: preparing release

* chore(release): Publish [ci skip]

 - @aws-amplify/ui-angular@1.0.38
 - @aws-amplify/ui-components@1.9.9
 - @aws-amplify/ui-react@1.2.29
 - @aws-amplify/ui-storybook@2.0.29
 - @aws-amplify/ui-vue@1.1.23
 - @aws-amplify/analytics@5.1.9
 - @aws-amplify/api-graphql@2.2.18
 - @aws-amplify/api-rest@2.0.29
 - @aws-amplify/api@4.0.29
 - @aws-amplify/auth@4.3.19
 - aws-amplify-angular@6.0.29
 - aws-amplify-react-native@6.0.2
 - aws-amplify-react@5.1.12
 - aws-amplify@4.3.11
 - @aws-amplify/cache@4.0.31
 - @aws-amplify/core@4.3.11
 - @aws-amplify/datastore-storage-adapter@1.2.3
 - @aws-amplify/datastore@3.7.3
 - @aws-amplify/geo@1.1.11
 - @aws-amplify/interactions@4.0.29
 - @aws-amplify/predictions@4.0.29
 - @aws-amplify/pubsub@4.2.5
 - @aws-amplify/pushnotification@4.3.8
 - @aws-amplify/storage@4.4.12
 - @aws-amplify/xr@3.0.29

* chore(release): update version.ts [ci skip]

* Fix typo in comment (psuedo) (#9389)

* fix(amazon-cognito-identity-js): added missing method param (#9276)

added missing method param for updateAttributes(...) method

fixes: #9275

* chore: add transformer v2 DataStore integ tests to CCI pipeline (#9354)

* modify config.yml to add v2 tests to pipeline

* comment out all non-v2 jobs for quick iteration

* needs integ_setup job

* modify v2 sample app path names for CCI

* re-enable auth v1 owner-and-group-same-model-default integ test for regression validation

* re-enable auth v1 owner-and-group-same-model-default integ test for regression validation

* re-enable auth tests

* enable v1 datastore integ tests

* fix(@aws-amplify/datastore): consecutive saves with timestamps (#9298)

* chore: preparing release

* chore(release): Publish [ci skip]

 - @aws-amplify/ui-angular@1.0.36
 - @aws-amplify/ui-components@1.9.7
 - @aws-amplify/ui-react@1.2.27
 - @aws-amplify/ui-storybook@2.0.27
 - @aws-amplify/ui-vue@1.1.21
 - @aws-amplify/ui@2.0.4
 - @aws-amplify/analytics@5.1.7
 - @aws-amplify/api-graphql@2.2.16
 - @aws-amplify/api-rest@2.0.27
 - @aws-amplify/api@4.0.27
 - @aws-amplify/auth@4.3.17
 - aws-amplify-angular@6.0.27
 - aws-amplify-react@5.1.10
 - aws-amplify-vue@2.1.6
 - aws-amplify@4.3.9
 - @aws-amplify/cache@4.0.29
 - @aws-amplify/core@4.3.9
 - @aws-amplify/datastore-storage-adapter@1.2.1
 - @aws-amplify/datastore@3.7.1
 - @aws-amplify/geo@1.1.9
 - @aws-amplify/interactions@4.0.27
 - @aws-amplify/predictions@4.0.27
 - @aws-amplify/pubsub@4.2.3
 - @aws-amplify/pushnotification@4.3.6
 - @aws-amplify/storage@4.4.10
 - @aws-amplify/xr@3.0.27

* chore(release): update version.ts [ci skip]

* fix(@aws-amplify/amplify-ui): change private property to false in package.json (#9303)

Resolving an issue with installing the library

* chore: preparing release

* fix(@aws-amplify/amplify-ui): remove private prop from package.json (#9304)

* fix(@aws-amplify/amplify-ui): change private property to false in package.json

* fix(@aws-amplify/amplify-ui): remove private property from package.json

Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

* chore(release): Publish [ci skip]

 - @aws-amplify/ui-angular@1.0.37
 - @aws-amplify/ui-components@1.9.8
 - @aws-amplify/ui-react@1.2.28
 - @aws-amplify/ui-storybook@2.0.28
 - @aws-amplify/ui-vue@1.1.22
 - @aws-amplify/ui@2.0.5
 - @aws-amplify/analytics@5.1.8
 - @aws-amplify/api-graphql@2.2.17
 - @aws-amplify/api-rest@2.0.28
 - @aws-amplify/api@4.0.28
 - @aws-amplify/auth@4.3.18
 - aws-amplify-angular@6.0.28
 - aws-amplify-react@5.1.11
 - aws-amplify@4.3.10
 - @aws-amplify/cache@4.0.30
 - @aws-amplify/core@4.3.10
 - @aws-amplify/datastore-storage-adapter@1.2.2
 - @aws-amplify/datastore@3.7.2
 - @aws-amplify/geo@1.1.10
 - @aws-amplify/interactions@4.0.28
 - @aws-amplify/predictions@4.0.28
 - @aws-amplify/pubsub@4.2.4
 - @aws-amplify/pushnotification@4.3.7
 - @aws-amplify/storage@4.4.11
 - @aws-amplify/xr@3.0.28

* chore(release): update version.ts [ci skip]

* fix(@aws-amplify/datastore): fixes observeQuery in local-only mode (#9300)

* uncomment tests, prepare for main pipeline addition

* add v2 tests to deploy job

* add observe query integ tests to the pipeline

* add SQLite adapter e2e test to pipeline

Co-authored-by: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com>
Co-authored-by: aws-amplify-bot <aws@amazon.com>
Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>

* ci: upgrade macOS executors (#9431)

* fix(@aws-amplify/core): use empty string as translation (#9403)

* fix for using empty string as translation

* Update I18n.ts

strict inequality with undefined for the dictionary values

Co-authored-by: Eddy Varela <eddvar@amazon.com>
Co-authored-by: Nick Arocho <16296496+nickarocho@users.noreply.github.com>

* Revert "fix(@aws-amplify/core): use empty string as translation (#9403)" (#9436)

This reverts commit 512fd99.

* chore: preparing release

* fix(aws-amplify-angular): removed old zone package (#9437)

* chore: preparing release (#9441)

Co-authored-by: James Au <40404256+jamesaucode@users.noreply.github.com>

* chore(release): Publish [ci skip]

 - amazon-cognito-identity-js@5.2.4
 - @aws-amplify/ui-angular@1.0.39
 - @aws-amplify/ui-components@1.9.10
 - @aws-amplify/ui-react@1.2.30
 - @aws-amplify/ui-storybook@2.0.30
 - @aws-amplify/ui-vue@1.1.24
 - @aws-amplify/analytics@5.1.10
 - @aws-amplify/api-graphql@2.2.19
 - @aws-amplify/api-rest@2.0.30
 - @aws-amplify/api@4.0.30
 - @aws-amplify/auth@4.3.20
 - aws-amplify-angular@6.0.30
 - aws-amplify-react@5.1.13
 - aws-amplify@4.3.12
 - @aws-amplify/cache@4.0.32
 - @aws-amplify/core@4.3.12
 - @aws-amplify/datastore-storage-adapter@1.2.4
 - @aws-amplify/datastore@3.7.4
 - @aws-amplify/geo@1.1.12
 - @aws-amplify/interactions@4.0.30
 - @aws-amplify/predictions@4.0.30
 - @aws-amplify/pubsub@4.2.6
 - @aws-amplify/pushnotification@4.3.9
 - @aws-amplify/storage@4.4.13
 - @aws-amplify/xr@3.0.30

* chore(release): update version.ts [ci skip]

* chore(amplify-js): consolidate react-native dependencies (#9451)

* Revert "chore(amplify-js): consolidate react-native dependencies (#9451)" (#9473)

This reverts commit d304f94.

* fix: Fix CircleCI integration tests (#9500)

* fix: pin jsdoc version (#9510)

The latest jsdoc requires node >= 14. Pinning it to an older version to avoid upgrading our docker images' node version.

* fix(geo): remove 'ensure to' from error message

* chore(geo): remove file that's no longer used

* chore(geo): fix type comment

* fix(geo): error if mutually exclusive options are given

* test(@aws-amplify/geo): fix failing tests

* chore(amplify-js): consolidate react-native dependencies (#9521)

* feat(@aws-amplify/auth): Delete user API exposed (#9428)

* fix for using empty string as translation

* feat(@aws-amplify/auth): delete user poc

* reverting internationalization commit

* adding hub event

* addressing feedback and beginning unit tests

* added unit tests within suite for deleteUser API call

* removing zone dependency to fix failing builds

* integ test commit

* fix e2e for delete user

* adding branch for deleteUser in sample staging repo

* pinning jsdoc dependency

* one more time

* adding fixes for hosted ui

* preventing signout race condition

* fixing circle ci

* hot fix

* circle ci configured for deleteUser

* fixing pr comments

* changing tests and updating circle ci

* reverting circle ci config

* adding integ tests

* staging url

* removing comments

* empty commit

* rerun integ test

* remove deploy and post release step

* run only delete user test

* correct config

* rerun integ test

* uncomment test

* fix unit test

* final auth

* revert i18N change

* addressing pr comments

* resolving promise

* remove missed signout

* ts nit

Co-authored-by: yanakatty <yu@yanakatty.com>
Co-authored-by: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>

* chore: preparing release

* chore(release): Publish [ci skip]

 - amazon-cognito-identity-js@5.2.5
 - @aws-amplify/ui-angular@1.0.40
 - @aws-amplify/ui-components@1.9.11
 - @aws-amplify/ui-react@1.2.31
 - @aws-amplify/ui-storybook@2.0.31
 - @aws-amplify/ui-vue@1.1.25
 - @aws-amplify/analytics@5.1.11
 - @aws-amplify/api-graphql@2.2.20
 - @aws-amplify/api-rest@2.0.31
 - @aws-amplify/api@4.0.31
 - @aws-amplify/auth@4.4.0
 - aws-amplify-angular@6.0.31
 - aws-amplify-react@5.1.14
 - aws-amplify@4.3.13
 - @aws-amplify/cache@4.0.33
 - @aws-amplify/core@4.3.13
 - @aws-amplify/datastore-storage-adapter@1.2.5
 - @aws-amplify/datastore@3.7.5
 - @aws-amplify/geo@1.1.13
 - @aws-amplify/interactions@4.0.31
 - @aws-amplify/predictions@4.0.31
 - @aws-amplify/pubsub@4.2.7
 - @aws-amplify/pushnotification@4.3.10
 - @aws-amplify/storage@4.4.14
 - @aws-amplify/xr@3.0.31

* chore(release): update version.ts [ci skip]

* chore(react-native): upgrade React Native devDependency version to ^0.64.1 (#9525)

* upgrade next version to ^11.1.3 for security patch (#9533)

* import React Native headers from <React/*.h> (#9387)

This ensures compatibility with Expo SDK 44.

see expo/expo#15622 (comment)

Co-authored-by: Caleb Pollman <cpollman1@gmail.com>
Co-authored-by: KJ(Kaijie) Huang <kaijih@amazon.com>

* fix(datastore): correctly apply config values (#9542)

* feat(@aws-amplify/geo): searchForSuggestions API (#9516)

* feat(geo): searchForSuggestions initial implementation

* chore(@aws-amplify/geo): update dependencies

* chore(@aws-amplify/geo): update test strings

* test(@aws-amplify/geo): update searchForSuggestion tests

* added missing import

* added baseline observeQuery tests; prep for nested predicate observeQuery testing

* adjust test titles

* observeQuery test for isSync status

* test: observeQuery behavior after isSynced; also simple predicate case

* rebased

* observeQuery hasMany test; test cleanup and completness

* cleanup; harden has many predicate selection

* copy instead of mutate observe messages

* fixed rebase mistake

* fixed types

* fixed modelinit and copyof typing

* renames; cruft cleanup

* fixed LGTM, removed unused import

* yet another attempt to fix TS errors ...

* set alwaysStrict to find TS errors locally, fixed TS errors

* fix: TS casting errors in sync engine

* upgrade dexie

* stash TS strictness fixes

* fixed all TS erros?git add .??

* fixed TS for ds sqlite adapter

* removed accidentally added tsconfig

* fixed LGTM unused variable inits

* comment cleanup

* Update packages/datastore/__tests__/DataStore.ts

Co-authored-by: Nick Arocho <16296496+nickarocho@users.noreply.github.com>

* removed some cruft

* revert superfluous null check; more error message details

* fixed tests after rebase

* cruft cleanup

Co-authored-by: Nick Arocho <16296496+nickarocho@users.noreply.github.com>
Co-authored-by: Sam Martinez <samlmar@amazon.com>
Co-authored-by: ManojNB <manojnb95@gmail.com>
Co-authored-by: Manoj NB <manojnb@amazon.com>
Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Ashish Nanda <ashish.nanda.5591@gmail.com>
Co-authored-by: David McAfee <mcafd@amazon.com>
Co-authored-by: aws-amplify-bot <aws@amazon.com>
Co-authored-by: Caleb Pollman <cpollman1@gmail.com>
Co-authored-by: Sam Martinez  <sammartinez19@gmail.com>
Co-authored-by: Ashika Kasiviswanathan Arumugakarthik <akasivis@amazon.com>
Co-authored-by: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com>
Co-authored-by: Tré Ammatuna <16496746+TreTuna@users.noreply.github.com>
Co-authored-by: William Lee <43682783+wlee221@users.noreply.github.com>
Co-authored-by: Aaron Lamb <aaronlamb93@gmail.com>
Co-authored-by: Aaron Michael Lamb <aarolamb@amazon.com>
Co-authored-by: Ashika <35131273+ashika01@users.noreply.github.com>
Co-authored-by: James Au <40404256+jamesaucode@users.noreply.github.com>
Co-authored-by: Nick Arocho <nicaroch@amazon.com>
Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com>
Co-authored-by: Katie Goines <katiegoi@amazon.com>
Co-authored-by: Bruno P. Kinoshita <kinow@users.noreply.github.com>
Co-authored-by: Arthur Brandstetter <31988348+brandart@users.noreply.github.com>
Co-authored-by: Yusuke Yanaka <yu@yanakatty.com>
Co-authored-by: Eddy Varela <eddvar@amazon.com>
Co-authored-by: Tré Ammatuna <tretuna@amazon.com>
Co-authored-by: hkjpotato <hkjpotato@gmail.com>
Co-authored-by: KJ(Kaijie) Huang <kaijih@amazon.com>
Co-authored-by: Manuel Schiller <meisterpink@gmail.com>
  • Loading branch information
1 parent b2eaa3e commit c50e13f
Show file tree
Hide file tree
Showing 39 changed files with 1,545 additions and 824 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
ModelInstanceMetadata,
ModelPredicate,
NamespaceResolver,
NAMESPACES,
OpType,
PaginationInput,
PersistentModel,
Expand All @@ -40,7 +41,7 @@ export class SQLiteAdapter implements StorageAdapter {
private namespaceResolver: NamespaceResolver;
private modelInstanceCreator: ModelInstanceCreator;
private getModelConstructorByModelName: (
namsespaceName: string,
namsespaceName: NAMESPACES,
modelName: string
) => PersistentModelConstructor<any>;
private db: SQLiteDatabase;
Expand All @@ -53,7 +54,7 @@ export class SQLiteAdapter implements StorageAdapter {
namespaceResolver: NamespaceResolver,
modelInstanceCreator: ModelInstanceCreator,
getModelConstructorByModelName: (
namsespaceName: string,
namsespaceName: NAMESPACES,
modelName: string
) => PersistentModelConstructor<any>
) {
Expand Down Expand Up @@ -105,7 +106,7 @@ export class SQLiteAdapter implements StorageAdapter {
this.schema.namespaces[this.namespaceResolver(modelConstructor)]
);
const connectionStoreNames = Object.values(connectedModels).map(
({ modelName, item, instance }) => {
({ modelName, item, instance }: any) => {
return { modelName, item, instance };
}
);
Expand Down Expand Up @@ -156,7 +157,7 @@ export class SQLiteAdapter implements StorageAdapter {
}

private async load<T>(
namespaceName: string,
namespaceName: NAMESPACES,
srcModelName: string,
records: T[]
): Promise<T[]> {
Expand Down Expand Up @@ -232,9 +233,7 @@ export class SQLiteAdapter implements StorageAdapter {
// TODO: Lazy loading
break;
default:
const _: never = relationType as never;
throw new Error(`invalid relation type ${relationType}`);
break;
}
}

Expand All @@ -249,7 +248,9 @@ export class SQLiteAdapter implements StorageAdapter {
pagination?: PaginationInput<T>
): Promise<T[]> {
const { name: tableName } = modelConstructor;
const namespaceName = this.namespaceResolver(modelConstructor);
const namespaceName = this.namespaceResolver(
modelConstructor
) as NAMESPACES;

const predicates =
predicate && ModelPredicateCreator.getPredicates(predicate);
Expand Down Expand Up @@ -328,7 +329,9 @@ export class SQLiteAdapter implements StorageAdapter {
): Promise<[T[], T[]]> {
if (isModelConstructor(modelOrModelConstructor)) {
const modelConstructor = modelOrModelConstructor;
const namespaceName = this.namespaceResolver(modelConstructor);
const namespaceName = this.namespaceResolver(
modelConstructor
) as NAMESPACES;
const { name: tableName } = modelConstructor;

const predicates =
Expand Down
1 change: 1 addition & 0 deletions packages/datastore/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tsconfig.json
51 changes: 26 additions & 25 deletions packages/datastore/__tests__/AsyncStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ let Comment: PersistentModelConstructor<InstanceType<typeof CommentType>>;
let Nested: NonModelTypeConstructor<InstanceType<typeof NestedType>>;
let Post: PersistentModelConstructor<InstanceType<typeof PostType>>;
let Person: PersistentModelConstructor<InstanceType<typeof PersonType>>;
let PostAuthorJoin: PersistentModelConstructor<InstanceType<
typeof PostAuthorJoinType
>>;
let PostMetadata: NonModelTypeConstructor<InstanceType<
typeof PostMetadataType
>>;
let PostAuthorJoin: PersistentModelConstructor<
InstanceType<typeof PostAuthorJoinType>
>;
let PostMetadata: NonModelTypeConstructor<
InstanceType<typeof PostMetadataType>
>;

const inmemoryMap = new Map<string, string>();

Expand All @@ -49,12 +49,12 @@ jest.mock('../src/storage/adapter/InMemoryStore', () => {
};
multiGet = async (keys: string[]) => {
return keys.reduce(
(res, k) => (res.push([k, inmemoryMap.get(k)]), res),
[]
(res, k) => (res.push([k, inmemoryMap.get(k)!]), res),
[] as [string, string][]
);
};
multiRemove = async (keys: string[]) => {
return keys.forEach(k => inmemoryMap.delete(k));
return keys.forEach((k) => inmemoryMap.delete(k));
};
setItem = async (key: string, value: string) => {
return inmemoryMap.set(key, value);
Expand All @@ -75,8 +75,9 @@ jest.mock('../src/storage/adapter/InMemoryStore', () => {
};
});

jest.mock('../src/storage/adapter/getDefaultAdapter/index', () => () =>
AsyncStorageAdapter
jest.mock(
'../src/storage/adapter/getDefaultAdapter/index',
() => () => AsyncStorageAdapter
);

/**
Expand Down Expand Up @@ -249,7 +250,7 @@ describe('AsyncStorage tests', () => {
);

expect(get1['blogOwnerId']).toBe(owner.id);
const updated = Blog.copyOf(blog, draft => {
const updated = Blog.copyOf(blog, (draft) => {
draft.name = 'Avatar: The Last Airbender';
});

Expand All @@ -272,7 +273,7 @@ describe('AsyncStorage tests', () => {

await DataStore.save(blog3);
const query1 = await DataStore.query(Blog);
query1.forEach(async item => {
query1.forEach(async (item) => {
if (item.owner) {
const resolvedOwner = await item.owner;
expect(resolvedOwner).toHaveProperty('name');
Expand All @@ -299,9 +300,9 @@ describe('AsyncStorage tests', () => {
await DataStore.save(c2);

const q1 = await DataStore.query(Comment, c1.id);
const resolvedPost = await q1.post;
const resolvedPost = await q1!.post;

expect(resolvedPost.id).toEqual(p.id);
expect(resolvedPost!.id).toEqual(p.id);
});

test('query with sort on a single field', async () => {
Expand Down Expand Up @@ -333,7 +334,7 @@ describe('AsyncStorage tests', () => {
const sortedPersons = await DataStore.query(Person, null, {
page: 0,
limit: 20,
sort: s => s.firstName(SortDirection.DESCENDING),
sort: (s) => s.firstName(SortDirection.DESCENDING),
});

expect(sortedPersons[0].firstName).toEqual('Meow Meow');
Expand Down Expand Up @@ -366,11 +367,11 @@ describe('AsyncStorage tests', () => {

const sortedPersons = await DataStore.query(
Person,
c => c.username.ne(undefined),
(c) => c.username.ne(undefined),
{
page: 0,
limit: 20,
sort: s =>
sort: (s) =>
s
.firstName(SortDirection.ASCENDING)
.lastName(SortDirection.ASCENDING)
Expand All @@ -397,14 +398,14 @@ describe('AsyncStorage tests', () => {
await DataStore.save(owner2);

await DataStore.save(
Blog.copyOf(blog, draft => {
Blog.copyOf(blog, (draft) => {
draft;
})
);
await DataStore.save(blog2);
await DataStore.save(blog3);

await DataStore.delete(Blog, c => c.name('beginsWith', 'Avatar'));
await DataStore.delete(Blog, (c) => c.name('beginsWith', 'Avatar'));

expect(await DataStore.query(Blog, blog.id)).toBeUndefined();
expect(await DataStore.query(Blog, blog2.id)).toBeDefined();
Expand Down Expand Up @@ -433,7 +434,7 @@ describe('AsyncStorage tests', () => {
await DataStore.delete(Comment, c1.id);

expect(await DataStore.query(Comment, c1.id)).toBeUndefined;
expect((await DataStore.query(Comment, c2.id)).id).toEqual(c2.id);
expect((await DataStore.query(Comment, c2.id))!.id).toEqual(c2.id);
});

test('delete 1:M function', async () => {
Expand Down Expand Up @@ -469,7 +470,7 @@ describe('AsyncStorage tests', () => {
await DataStore.delete(Post, post.id);
expect(await DataStore.query(Comment, c1.id)).toBeUndefined();
expect(await DataStore.query(Comment, c2.id)).toBeUndefined();
expect((await DataStore.query(Comment, c3.id)).id).toEqual(c3.id);
expect((await DataStore.query(Comment, c3.id))!.id).toEqual(c3.id);
expect(await DataStore.query(Post, post.id)).toBeUndefined();
});

Expand Down Expand Up @@ -507,8 +508,8 @@ describe('AsyncStorage tests', () => {

expect(postAuthorJoins).toHaveLength(0);

await DataStore.delete(Post, c => c);
await DataStore.delete(Author, c => c);
await DataStore.delete(Post, (c) => c);
await DataStore.delete(Author, (c) => c);
});

// skipping in this PR. will re-enable as part of cascading deletes work
Expand Down Expand Up @@ -621,7 +622,7 @@ function getKeyForAsyncStorage(
AsyncStorageAdapter
)).db._collectionInMemoryIndex;
const storeName = `${namespaceName}_${modelName}`;
const ulid = collectionInMemoryIndex.get(storeName).get(id);
const ulid = collectionInMemoryIndex.get(storeName)!.get(id);

return `@AmplifyDatastore::${storeName}::Data::${ulid}::${id}`;
}
14 changes: 7 additions & 7 deletions packages/datastore/__tests__/AsyncStorageAdapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('AsyncStorageAdapter tests', () => {
it('Should call getById for query by id', async () => {
const result = await DataStore.query(Model, model1Id);

expect(result.field1).toEqual('Some value');
expect(result!.field1).toEqual('Some value');
expect(spyOnGetOne).toHaveBeenCalled();
expect(spyOnGetAll).not.toHaveBeenCalled();
expect(spyOnMemory).not.toHaveBeenCalled();
Expand Down Expand Up @@ -163,8 +163,8 @@ describe('AsyncStorageAdapter tests', () => {
let profile = await DataStore.query(Profile, profile1Id);

// double-checking that both of the records exist at first
expect(user.id).toEqual(user1Id);
expect(profile.id).toEqual(profile1Id);
expect(user!.id).toEqual(user1Id);
expect(profile!.id).toEqual(profile1Id);

await DataStore.delete(User, user1Id);

Expand Down Expand Up @@ -207,8 +207,8 @@ describe('AsyncStorageAdapter tests', () => {
const user1Id = savedUser.id;

const user = await DataStore.query(User, user1Id);
expect(user.profileID).toEqual(profile.id);
expect(await user.profile).toEqual(profile);
expect(user!.profileID).toEqual(profile.id);
expect(await user!.profile).toEqual(profile);
});

it('should allow linking model via FK', async () => {
Expand All @@ -218,8 +218,8 @@ describe('AsyncStorageAdapter tests', () => {
const user1Id = savedUser.id;

const user = await DataStore.query(User, user1Id);
expect(user.profileID).toEqual(profile.id);
expect(await user.profile).toEqual(profile);
expect(user!.profileID).toEqual(profile.id);
expect(await user!.profile).toEqual(profile);
});
});
});
Loading

0 comments on commit c50e13f

Please sign in to comment.