@aws-amplify/datastore 3.12.5 → 3.12.6-clean-npm-artifacts.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/docs/conflict-resolution.md +8 -0
  3. package/docs/contributing.md +17 -0
  4. package/docs/datastore-lifecycle-events.md +88 -0
  5. package/docs/getting-started.md +26 -0
  6. package/docs/namespaces.md +52 -0
  7. package/docs/observables.md +11 -0
  8. package/docs/schema-changes.md +12 -0
  9. package/docs/storage.md +36 -0
  10. package/docs/sync-engine.md +64 -0
  11. package/docs/workarounds.md +1 -0
  12. package/lib/authModeStrategies/multiAuthStrategy.js +5 -63
  13. package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
  14. package/lib/datastore/datastore.d.ts +3 -3
  15. package/lib/datastore/datastore.js +56 -147
  16. package/lib/datastore/datastore.js.map +1 -1
  17. package/lib/index.js +2 -4
  18. package/lib/index.js.map +1 -1
  19. package/lib/storage/adapter/AsyncStorageAdapter.js +40 -96
  20. package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  21. package/lib/storage/adapter/AsyncStorageDatabase.js +32 -94
  22. package/lib/storage/adapter/AsyncStorageDatabase.js.map +1 -1
  23. package/lib/storage/adapter/InMemoryStore.js +16 -67
  24. package/lib/storage/adapter/InMemoryStore.js.map +1 -1
  25. package/lib/storage/adapter/InMemoryStore.native.js +2 -4
  26. package/lib/storage/adapter/InMemoryStore.native.js.map +1 -1
  27. package/lib/storage/adapter/IndexedDBAdapter.js +62 -141
  28. package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
  29. package/lib/storage/adapter/getDefaultAdapter/index.js +3 -5
  30. package/lib/storage/adapter/getDefaultAdapter/index.js.map +1 -1
  31. package/lib/storage/adapter/getDefaultAdapter/index.native.js +2 -4
  32. package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +1 -1
  33. package/lib/storage/storage.js +38 -125
  34. package/lib/storage/storage.js.map +1 -1
  35. package/lib/sync/datastoreConnectivity.js +4 -17
  36. package/lib/sync/datastoreConnectivity.js.map +1 -1
  37. package/lib/sync/datastoreReachability/index.native.js +2 -4
  38. package/lib/sync/datastoreReachability/index.native.js.map +1 -1
  39. package/lib/sync/index.js +36 -105
  40. package/lib/sync/index.js.map +1 -1
  41. package/lib/sync/merger.js +8 -74
  42. package/lib/sync/merger.js.map +1 -1
  43. package/lib/sync/outbox.js +24 -97
  44. package/lib/sync/outbox.js.map +1 -1
  45. package/lib/sync/processors/errorMaps.js +4 -34
  46. package/lib/sync/processors/errorMaps.js.map +1 -1
  47. package/lib/sync/processors/mutation.js +30 -117
  48. package/lib/sync/processors/mutation.js.map +1 -1
  49. package/lib/sync/processors/subscription.js +19 -95
  50. package/lib/sync/processors/subscription.js.map +1 -1
  51. package/lib/sync/processors/sync.js +23 -99
  52. package/lib/sync/processors/sync.js.map +1 -1
  53. package/lib/sync/utils.js +8 -54
  54. package/lib/sync/utils.js.map +1 -1
  55. package/lib/types.js +3 -38
  56. package/lib/types.js.map +1 -1
  57. package/lib/util.js +15 -81
  58. package/lib/util.js.map +1 -1
  59. package/lib-esm/authModeStrategies/multiAuthStrategy.js +1 -56
  60. package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
  61. package/lib-esm/datastore/datastore.d.ts +3 -3
  62. package/lib-esm/datastore/datastore.js +1 -89
  63. package/lib-esm/datastore/datastore.js.map +1 -1
  64. package/lib-esm/storage/adapter/AsyncStorageAdapter.js +1 -54
  65. package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
  66. package/lib-esm/storage/adapter/AsyncStorageDatabase.js +1 -63
  67. package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +1 -1
  68. package/lib-esm/storage/adapter/InMemoryStore.js +1 -52
  69. package/lib-esm/storage/adapter/InMemoryStore.js.map +1 -1
  70. package/lib-esm/storage/adapter/IndexedDBAdapter.js +7 -79
  71. package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
  72. package/lib-esm/storage/storage.js +1 -85
  73. package/lib-esm/storage/storage.js.map +1 -1
  74. package/lib-esm/sync/datastoreConnectivity.js +1 -11
  75. package/lib-esm/sync/datastoreConnectivity.js.map +1 -1
  76. package/lib-esm/sync/index.js +1 -67
  77. package/lib-esm/sync/index.js.map +1 -1
  78. package/lib-esm/sync/merger.js +1 -67
  79. package/lib-esm/sync/merger.js.map +1 -1
  80. package/lib-esm/sync/outbox.js +1 -74
  81. package/lib-esm/sync/outbox.js.map +1 -1
  82. package/lib-esm/sync/processors/errorMaps.js +1 -31
  83. package/lib-esm/sync/processors/errorMaps.js.map +1 -1
  84. package/lib-esm/sync/processors/mutation.js +1 -85
  85. package/lib-esm/sync/processors/mutation.js.map +1 -1
  86. package/lib-esm/sync/processors/subscription.js +1 -67
  87. package/lib-esm/sync/processors/subscription.js.map +1 -1
  88. package/lib-esm/sync/processors/sync.js +1 -74
  89. package/lib-esm/sync/processors/sync.js.map +1 -1
  90. package/lib-esm/sync/utils.js +1 -47
  91. package/lib-esm/sync/utils.js.map +1 -1
  92. package/lib-esm/types.js +1 -36
  93. package/lib-esm/types.js.map +1 -1
  94. package/lib-esm/util.js +1 -67
  95. package/lib-esm/util.js.map +1 -1
  96. package/package.json +15 -7
  97. package/src/datastore/datastore.ts +3 -3
  98. package/src/storage/adapter/IndexedDBAdapter.ts +1 -1
  99. package/build.js +0 -5
  100. package/dist/aws-amplify-datastore.js +0 -98009
  101. package/dist/aws-amplify-datastore.js.map +0 -1
  102. package/dist/aws-amplify-datastore.min.js +0 -66
  103. package/dist/aws-amplify-datastore.min.js.map +0 -1
  104. package/index.js +0 -7
  105. package/webpack.config.dev.js +0 -6
package/CHANGELOG.md CHANGED
@@ -3,6 +3,68 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.12.12](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.10...@aws-amplify/datastore@3.12.12) (2022-09-30)
7
+
8
+ **Note:** Version bump only for package @aws-amplify/datastore
9
+
10
+
11
+
12
+
13
+
14
+ ## [3.12.11](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.10...@aws-amplify/datastore@3.12.11) (2022-09-20)
15
+
16
+ **Note:** Version bump only for package @aws-amplify/datastore
17
+
18
+
19
+
20
+
21
+
22
+ ## [3.12.10](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.9...@aws-amplify/datastore@3.12.10) (2022-09-08)
23
+
24
+ **Note:** Version bump only for package @aws-amplify/datastore
25
+
26
+
27
+
28
+
29
+
30
+ ## [3.12.9](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.8...@aws-amplify/datastore@3.12.9) (2022-09-01)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **datastore:** clear before start with nextjs ([#10234](https://github.com/aws-amplify/amplify-js/issues/10234)) ([98dd9f2](https://github.com/aws-amplify/amplify-js/commit/98dd9f27fe798d4337201d082e9f65d785366f8b))
36
+
37
+
38
+
39
+
40
+
41
+ ## [3.12.8](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.7...@aws-amplify/datastore@3.12.8) (2022-08-23)
42
+
43
+ **Note:** Version bump only for package @aws-amplify/datastore
44
+
45
+
46
+
47
+
48
+
49
+ ## [3.12.7](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.6...@aws-amplify/datastore@3.12.7) (2022-08-18)
50
+
51
+ **Note:** Version bump only for package @aws-amplify/datastore
52
+
53
+
54
+
55
+
56
+
57
+ ## [3.12.6](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.5...@aws-amplify/datastore@3.12.6) (2022-08-16)
58
+
59
+
60
+ ### Bug Fixes
61
+
62
+ * **datastore:** make di context fields private ([#10162](https://github.com/aws-amplify/amplify-js/issues/10162)) ([88a9ec9](https://github.com/aws-amplify/amplify-js/commit/88a9ec97fca2eb19c9cc9496b8b7d25b75f02073))
63
+
64
+
65
+
66
+
67
+
6
68
  ## [3.12.5](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.4...@aws-amplify/datastore@3.12.5) (2022-08-01)
7
69
 
8
70
  **Note:** Version bump only for package @aws-amplify/datastore
@@ -0,0 +1,8 @@
1
+ # Conflict Resolution
2
+ - **AppSync is the source of truth for conflict resolution**
3
+ 1. In the event AppSync fails to resolve a conflict, the network response will contain an error message (`conflict unhandled`). This is how we give customers the chance to make an update, or try again.
4
+ 2. We use jittered retry (10x).
5
+ - TODO: add more detail / links to how this retry logic occurs.
6
+ - We err on the side of not deleting customer data when performing conflict resolution.
7
+ - Auto-merge is the default resolution strategy. This relies on the version, and will attempt to merge fields that changed when possible.
8
+ - For more, see [the AppSync docs](https://docs.aws.amazon.com/appsync/latest/devguide/conflict-detection-and-sync.html)
@@ -0,0 +1,17 @@
1
+ # Contributing
2
+
3
+ ## Formatting
4
+ - We use Prettier to format our code. We recommend installing it within your IDE to prevent formatting code within other Amplify packages (as opposed to formatting from the Prettier CLI directly). Example [VS Code Extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)).
5
+
6
+ ## Testing DataStore changes locally
7
+ - On first build:
8
+ - Within **amplify-js**: `yarn && yarn build && yarn link-all && yarn build:esm:watch`
9
+ - Within sample app: `yarn && yarn link aws-amplify && yarn link @aws-amplify/datastore && yarn start`
10
+ - On subsequent builds (useful if something isn't working):
11
+ - Within **amplify-js**: `yarn clean && yarn build && yarn link-all && yarn build:esm:watch`
12
+ - Within sample app: `rm -rf node_modules && yarn && yarn link aws-amplify && yarn link @aws-amplify/datastore && yarn start`
13
+
14
+ ## Contributing to these docs
15
+ - Do not link to specific lines of code, as these frequently change. Instead, do the opposite: link to the documentation within the code itself, as the docs are less likely to change.
16
+ - Prefer small, self-contained sections over large, monolothic documents.
17
+ - Do not use permalinks - instead, link to the most current files.
@@ -0,0 +1,88 @@
1
+ # DataStore Lifecycle Events ("Start", "Stop", "Clear")
2
+
3
+ # DataStore Initialization ("Start")
4
+
5
+ **Understanding how DataStore starts is critical to understanding how DataStore fundamentally works.** At a high level, starting DataStore does the following things in order for each model:
6
+
7
+ > 1. Init Schema
8
+ > 2. Init the Storage Engine
9
+ > 3. Migrate schema changes
10
+ > 4. Sync Engine Operations
11
+ > 5. Empty the Outbox / processes the mutation queue
12
+ > 6. Begin processing the subscription buffer
13
+ > 7. DataStore is now in "ready" state
14
+
15
+ - _We can eagerly start DataStore by calling `DataStore.start`. Otherwise, invoking a method (query, save, delete, observe) will start it up_
16
+ - _When importing a model, DS consumes `schema.js`, and creates the IndexedDB store._
17
+
18
+ ## **How it works:**
19
+
20
+ 1. ### **Init schema**
21
+ - **1.1** First we call `initSchema` [here](packages/datastore/src/datastore/datastore.ts)
22
+ - **1.2** Codegen then generates `schema.js` from the schema
23
+ - **1.3** DataStore consumes `schema.js`
24
+
25
+ 2. ### **Init the storage engine**
26
+ - **2.1** The adapter is initialized
27
+ - **2.2** The local database gets created if it doesn’t exist already
28
+ - **2.3** The adapter [has a `setUp`](packages/datastore/src/storage/adapter/IndexedDBAdapter.ts#L82) method that then calls the database's `init` method
29
+ - **2.4** Relations are established
30
+ - _Nothing happens until the first interaction with DataStore_
31
+
32
+ 3. ### **Migrate schema changes (if needed)**
33
+ - See [schema-changes.md](./schema-changes.md)
34
+ - If the user has updated the schema, we perform the migration here
35
+
36
+ 4. ### **Sync Engine Operations**
37
+ - #### 4.1 Instantiate Sync Engine (`this.sync = new SyncEngine(`)
38
+ - The Sync Engine is only instantiated if there is a graphql endpoint (meaning we’ve already provisioned the backend). Otherwise, DataStore is in local-only mode. See [datastore.ts](packages/datastore/src/datastore/datastore.ts#L735)
39
+ - **Note: at this step, we do not yet process the buffer**
40
+ - There are three subscriptions per model: `create`, `update`, and `delete`
41
+
42
+ - #### 4.2 Sync Engine is started (`syncSubscription = this.sync.start(`)
43
+ - **4.2.1 Subscribe to the Sync Engine**
44
+ - Messages from this subscription are emmited as Hub events for DataStore
45
+ - When ready, we call `initResolve`
46
+ - If unauthorized, DS keeps working, as we may have publicly readable models
47
+ - If a validation error occurs, DataStore Sync breaks entirely
48
+ - Without subscriptions, DataStore doesn’t work (when there is an endpoint present)
49
+ - Subscriptions are the only component that update the local store from remote
50
+ - If updates come in, they’re buffered to be processed after sync is complete
51
+ - Prepares the sync predicates (similar to adapter setup)
52
+
53
+ - **4.2.2 Subscribe to DataStore connectivity observable (notifications about network status)**
54
+ - `this.datastoreConnectivity.status().subscribe`
55
+ - Subscribe Amplify Core component that monitors network reachability
56
+ - We do this here because we need the ability to stop or start the sync process. When offline, we disconnect the websocket and stop syncing. Once online, we reconnect the websocket and start base / delta syncing
57
+ - Sync engine subscribes to the Storage Engine
58
+ - Every write may need to get translated to a mutation in the outbox
59
+ - Storage engine is local source of truth for DataStore, all other pieces are observing
60
+
61
+ - **4.2.3 Run the Sync Queries (when online)**
62
+ - _Note: We perform a topological sort of the data - we sync the children first, so when we query the parent, the children are already present We also use an optimisation to parallelize this process if possible (i.e. non-dependent models)_
63
+ - Sync queries are Graphql queries that are necessary to hydrate the local store initially
64
+ - The first time we run the app, we will perform a query to perform a scan or query of DynamoDB with up to 10k records per table. This populates the local store. With selective sync, we perform a query instead of a scan against DynamoDB.
65
+ - Subsequent changes after the initial sync query come in through subscriptions
66
+ - There are two mechanisms:
67
+ - Base sync - retrieve all records up to total sync value
68
+ - Delta sync - one table per model, one delta sync table per DS store
69
+ - AppSync makse the final decision regarding which sync (base vs delta) to perform
70
+ - The client sends the last sync param with the sync query, service then compares the diff
71
+ - There is a TTL on all delta sync table records
72
+ - To find the TTL within the AppSync Console, see "Update Data Source"
73
+
74
+ 5. ### **Empty the Outbox / processes the mutation queue**
75
+ - Example: when performing mutations offline, records are added to the queue. Once there is connectivity, we start sending these **ONE BY ONE**.
76
+ - **Note: No batch API is exposed to consumers**
77
+ - Mutation events have ids
78
+ - Syncs get applied before mutations are sent
79
+ 6. ### **Begin processing the subscription buffer**
80
+ - If we receive subscription messages any time in the process of initializing subscriptions, performing sync queries, or processing the mutation queue, we buffer the subscription messages until everything else is completed. Once we have completed processing the mutation queue, we then process the subscription buffer
81
+ 7. ### **DataStore is now in "ready" state**
82
+ - For additional reference, and how the above are published as Hub events, see [the docs](https://docs.amplify.aws/lib/datastore/datastore-events/q/platform/js/)
83
+
84
+ ## Stop
85
+ - Stops the DataStore sync process. This will close the real-time subscription connection when your app is no longer interested in updates. You will typically call DataStore.stop() just before your application is closed. You can also force your DataStore sync expressions to be re-evaluated at runtime by calling stop(), followed by start()
86
+
87
+ ## Clear
88
+ - Clears local data from DataStore. DataStore will now require a full sync (not a delta sync) to populate the local store with data
@@ -0,0 +1,26 @@
1
+ # Onboarding with DataStore
2
+
3
+ ## Understand the primary DataStore events
4
+ - Read the [DataStore lifecycle events doc](docs/datastore-lifecycle-events.md)
5
+
6
+ ## Building a sample app with DataStore to understand how it works
7
+ 1. Build a basic DataStore sample app (no @auth, just 1-2 models).
8
+ 2. Build a similar sample app with the API category.
9
+ 3. Add @auth rules to the DataStore app:
10
+ 1. `amplify update api`
11
+ 2. Modify schema according to auth rules docs (https://docs.amplify.aws/lib/datastore/setup-auth-rules/q/platform/js).
12
+ 3. `amplify push`
13
+ 4. `amplify codegen models`
14
+ 4. Add [selective sync](https://docs.amplify.aws/lib/datastore/sync/q/platform/js#selectively-syncing-a-subset-of-your-data).
15
+ 5. Enable [real-time changes](https://docs.amplify.aws/lib/datastore/real-time/q/platform/js).
16
+ 6. While interacting with your app, examine the IndexedDB tables (Application > IndexedDB within Chrome dev tools):
17
+ 1. Check out the different stores in IDB that get created for your schema. Note the internal stores prefixed with sync_, and the stores corresponding to your models prefixed with user_.
18
+ 2. Familiarize yourself with how actions taken in the UI affect the data stored in IDB. This may be easier to do while throttling the network connection. You'll be able to see how outgoing mutations first get persisted into the corresponding store, then added to the mutation queue / outbox (sync_MutationEvent), and then updated in the store with data from AppSync.
19
+ 7. Turn on DEBUG logging (`Amplify.Logger.LOG_LEVEL = "DEBUG";`) at the root of your project, and inspect the logs in the console while using your app. Additionally, [enable hub events](https://docs.amplify.aws/lib/datastore/datastore-events/q/platform/js#usage) for DataStore.
20
+ 8. The best way to understand DataStore events is to place several debuggers or breakpoints throughout DataStore.
21
+ - With logging / Hub events enabled, you can see what operations DataStore is performing (i.e. start, sync, etc.) as you step through with the debugger.
22
+ 9. Testing offline scenerios / concurrent user sessions is a useful way to test the full functionality of DataStore, and to fully understand how the sync process actually works.
23
+ 10. Next steps:
24
+ - Create a React Native example (uses a different storage type)
25
+ - Try more complex schema types
26
+ - Observe changes in records within DynamoDB (for instance, soft deletion).
@@ -0,0 +1,52 @@
1
+ # Namespaces
2
+ - `datastore`
3
+ - Settings
4
+ - `user`
5
+ - Models that came from user schema
6
+ - `sync`
7
+ - Metadata (last time ran query, etc.)
8
+ - `storage`
9
+ - Deprecated
10
+ # Local database examples:
11
+
12
+ - *Note: Anything prepended with `sync_` is an internal table.*
13
+
14
+ - ## datastore_Setting
15
+ - Used for schema versioning
16
+ - See the [schema changes doc](docs/schema-changes.md)
17
+ ```
18
+ {
19
+ id: "01FYABF3DMBZZJ46W1CC214NH2"
20
+ key: "schemaVersion"
21
+ value: "\"4401034582a70c60713e1f7f9da3b752\""
22
+ }
23
+ ```
24
+ - ## sync_ModelMetadata
25
+ - Sync Engine metadata
26
+ - Includes information about the last time we synced a model
27
+ ```
28
+ {
29
+ fullSyncInterval: 86400000
30
+ id: "01FYABF3DMBZZJ46W1CC214NH3"
31
+ lastFullSync: 1647467532307
32
+ lastSync: 1647467532307
33
+ lastSyncPredicate: null
34
+ model: "Todo"
35
+ namespace: "user"
36
+ }
37
+ ```
38
+ - ## sync_MutationEvent
39
+ - ## user_[Model Name]
40
+ - The actual records themselves.
41
+ ```
42
+ {
43
+ createdAt: "2022-03-16T21:52:07.718Z"
44
+ description: null
45
+ id: "6f69055b-b081-4225-8fc4-1d6d52732660"
46
+ name: "name 1647467527489"
47
+ updatedAt: "2022-03-16T21:52:07.718Z"
48
+ _deleted: null
49
+ _lastChangedAt: 1647467527754
50
+ _version: 1
51
+ }
52
+ ```
@@ -0,0 +1,11 @@
1
+ # How DataStore uses Observables
2
+ - All of DataStore internally uses event driven methods (observables) to handle everything from the sync process, to observing online connectivity. **This makes the Storage Engine the single source of truth for DataStore.**
3
+ - Examples:
4
+ - The Sync Engine observes DataStore Connectivity
5
+ - The Sync Engine observes the Storage Engine
6
+ - The client observes DataStore with `observe` and `observeQuery`:
7
+ - https://docs.amplify.aws/lib/datastore/real-time/q/platform/js/
8
+
9
+ ## Understanding Observables
10
+ - DataStore uses [`zen-observable`](https://github.com/zenparsing/zen-observable)
11
+ - [The RXJS docs](https://rxjs.dev/guide/observable) do a good job of describing observables in more detail.
@@ -0,0 +1,12 @@
1
+ # What happens when a user changes their schema?
2
+ - The `schema.js` file that exists within an Amplify project (located at `src/models/schema.js`) contains a version hash.
3
+ - This hash is compared against the hash stored in the `Settings` table of the local database. Example:
4
+ ```
5
+ {
6
+ id: "01FYABF3DMBZZJ46W1CC214NH2"
7
+ key: "schemaVersion"
8
+ value: "\"4401034582a70c60713e1f7f9da3b752\""
9
+ }
10
+ ```
11
+ - The process of checking the schema version (`checkSchemaVersion`) occurs when DataStore starts, after the Storage Engine has been initialized, and before the Sync Engine is initialized.
12
+ - If the schema version has changed, we clear local storage, and perform a full sync
@@ -0,0 +1,36 @@
1
+ # Storage
2
+ ## Adapters:
3
+ - Web
4
+ - [IndexedDB](../src/storage/adapter/IndexedDBAdapter.ts)
5
+ - Mobile
6
+ - React Native
7
+ - [Async Storage](../src/storage/adapter/AsyncStorageAdapter.ts) (can opt in to use SQLite)
8
+ - SSR
9
+ - [InMemoryStore](../src/storage/adapter/InMemoryStore.ts)
10
+
11
+ ## How we determine which adapter to use
12
+
13
+ We determine the storage adapter [here](../src/storage/adapter/getDefaultAdapter/index.ts).
14
+
15
+
16
+ ## [The Storage class](../src/storage/storage.ts)
17
+ - The Storage class is what interacts with the adapters.
18
+
19
+ ## [Storage Adapters](../src/storage/adapter)
20
+ 1. There is one adapter per database type we support (i.e. three adapters).
21
+ 2. Each adapter provides a unified API for the storage engine to interact with.
22
+ 3. The SQLite adapter lives [in it’s own package](https://github.com/aws-amplify/amplify-js/tree/main/packages/datastore-storage-adapter).
23
+ 4. **ExclusiveStorage wraps public storage methods (e.g. `Storage.runExclusive`)**
24
+ 1. Guarantees consistency
25
+ 2. Makes the storage class transactional
26
+ 3. **Provides concurrency control**
27
+
28
+ ## How DataStore finds records locally:
29
+ - Varies by storage adapter
30
+ - [SQLiteAdapter](https://github.com/aws-amplify/amplify-js/tree/main/packages/datastore-storage-adapter): DataStore constructs a query.
31
+ - [Async Storage](../src/storage/adapter/AsyncStorageAdapter.ts): DataStore scans and filters.
32
+ - [IndexedDB](../src/storage/adapter/IndexedDBAdapter.ts): if the query is by primary key, DataStore queries against the index, otherwise it scans and filters.
33
+ - *Note: The lazy loading branch includes an improvement to the IndexedDB adapter that will check if any search criteria can leverage an index (there is no preference for low cardinality; the first identified index is used.) If so, the base result is sourced from the index and the remaining criteria will be applied as a filter.*
34
+
35
+ ## Understanding the difference between Save and Batch Save
36
+ - As the names imply, `save` accepts a single record and persists it, while `batchSave` accepts a page of records and persists them all. `batchSave`, however, is *only used within the sync processor*, and will filter out deleted records from the sync page results, and then delete them from the local db.
@@ -0,0 +1,64 @@
1
+ # Sync Engine
2
+
3
+ See [the sync class](packages/datastore/src/sync/index.ts)
4
+
5
+ ## High-level overview:
6
+ - The first time DataStore is started on a new client, a full sync is performed. Subsequent reloads of the app (including browser refresh, or a new browser session) are delta syncs.
7
+ - If it has been greater than the `fullSyncInterval` (configurable) since the client has performed a full sync, this operation occurs as a full sync.
8
+ - The Sync Engine is well documented in the [DataStore Lifecycle Events doc](./datastore-lifecycle-events.md). The purpose of this doc is to explain anything about the sync process that is not already documented there.
9
+
10
+
11
+ ## Types of Syncs
12
+ ### Full Sync
13
+ - All records are fetched from AppSync.
14
+
15
+ ### Delta Sync
16
+ - All the records that changed after a given time stamp are fetched.
17
+
18
+ ## How it works
19
+
20
+ ### [Merger](../src/sync/merger.ts)
21
+ - A helper class for merging subscription records with the outbox (checks IDs).
22
+ - The Sync Engine uses merge in two places:
23
+ - 1. https://github.com/aws-amplify/amplify-js/blob/main/packages/datastore/src/sync/index.ts#L289
24
+ - Triggered by the mutation response. It gets called after the client that authored the change receives the network response of the mutation request they generated.
25
+ - 2. https://github.com/aws-amplify/amplify-js/blob/main/packages/datastore/src/sync/index.ts#L326
26
+ - Triggered by an AppSync real-time subscription event, which is how all clients get notified of the change. In the case of the mutation author, this notification is redundant, but it’s necessary for all other active users of the application. This is why there will always be multiple snapshot returned by `observe` and `observeQuery` in the case of the mutation author.
27
+
28
+ - The function of [the Merger class](../src/sync/merger.ts) is to filter out any incoming records that have corresponding pending changes in that client’s mutation queue / outbox, and is done to maintain data consistency. We wouldn’t want to write over data that the client has deliberately changed, and essentially undo whatever changes were performed on that client - even temporarily. Thus, each time a change comes in via a mutation response, AppSync subscription, or sync query, **Merger will only persist that change to the local database when there is not a pending mutation for that same record**.
29
+ - If there is a pending change in the outbox - we discard the incoming model we were working with inside the merge call (by not saving it). Later, when the record from the Outbox gets processed by AppSync (and conflict resolution rules are applied as appropriate), we will persist the response of the mutation (assuming we don’t change the record again in the interim)
30
+ - If there is not a pending change in the outbox - we persist the model to the local store via `Storage.save` within `merge`.
31
+ - _Note: We maintain a single instance of a mutation when we are offline (i.e. if we perform multiple updates on the same record, we merge them into a single event). Once we are online, but other mutations are processing, we'll still attempt to merge outgoing events into an existing one if they are not already in flight_
32
+ - Merger Example:
33
+ - User A updates record 1
34
+ - The update to record 1 is persisted locally, and enters the mutation queue for persistence to Appsync
35
+ - User B has not yet received the update to record 1, and updates record 1
36
+ - User A receives User B's update to record 1, but has not yet sent the mutation to AppSync
37
+ - If Merger did not first check the mutation queue prior to applying the change from User B, User A would see their update, then user B's update, then, depending on how the conflict is handled by AppSync, could then see their update again. Instead, User A sees their update, and rejects User B's update. Once the conflict is handled by AppSync, any changes that are received are then applied.
38
+ - *How to locally test / step through Merger:*
39
+ - Create a few records and make sure the records go out successfully and are persisted. Then, delete local data in IndexedDB (either by clicking the `clear` button in a sample, or through dev tools), then reload the page, or perform a query.
40
+ - **Note: AppSync expects us to send only updated fields in order for merge to work correctly.**
41
+
42
+ ### [Outbox]((../src/sync/outbox.ts))
43
+ - A mutation event outbox
44
+ - Holds all local changes (even if you close the app).
45
+ - Peek returns the next mutation event to be sent to AppSync, but does not remove it from the outbox.
46
+
47
+ ## [Processors](../src/sync/processors)
48
+ - Sync Engine uses processors depending on the type of operation
49
+ - All processors utilize observables
50
+ - Where retry happens
51
+
52
+ ### Mutation Processor (Local changes)
53
+ - Online or offline changes that were optimistically made to the Storage Engine (processed in mutation queue **one by one**).
54
+ - Observes Storage Engine for new changes.
55
+
56
+ ### Subscription Processor (Remote changes)
57
+ - Real-time subscription messages (such as another client performing a change).
58
+ - Uses the Amplify API Graphql package (which then uses PubSub).
59
+ ### Sync Processor
60
+ - When the client goes online, fetch all changes that were performed in AppSync (could be full or delta sync).
61
+
62
+ ## Misc:
63
+ - AppSync records are soft-deleted and have a TTL.
64
+ - TODO: special configurations around sync intervals
@@ -0,0 +1 @@
1
+ # TODO: "Unsupported hacks" / Workarounds
@@ -1,65 +1,7 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- var __spread = (this && this.__spread) || function () {
55
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
56
- return ar;
57
- };
58
- var __importDefault = (this && this.__importDefault) || function (mod) {
59
- return (mod && mod.__esModule) ? mod : { "default": mod };
60
- };
61
2
  Object.defineProperty(exports, "__esModule", { value: true });
62
- var auth_1 = __importDefault(require("@aws-amplify/auth"));
3
+ var tslib_1 = require("tslib");
4
+ var auth_1 = tslib_1.__importDefault(require("@aws-amplify/auth"));
63
5
  var api_graphql_1 = require("@aws-amplify/api-graphql");
64
6
  var types_1 = require("../types");
65
7
  function getProviderFromRule(rule) {
@@ -88,7 +30,7 @@ function sortAuthRulesWithPriority(rules) {
88
30
  types_1.ModelAttributeAuthProvider.IAM,
89
31
  types_1.ModelAttributeAuthProvider.API_KEY,
90
32
  ];
91
- return __spread(rules).sort(function (a, b) {
33
+ return tslib_1.__spread(rules).sort(function (a, b) {
92
34
  if (a.allow === b.allow) {
93
35
  return (providerSortPriority.indexOf(getProviderFromRule(a)) -
94
36
  providerSortPriority.indexOf(getProviderFromRule(b)));
@@ -156,10 +98,10 @@ function getAuthRules(_a) {
156
98
  exports.multiAuthStrategy = function (amplifyContext) {
157
99
  return function (_a) {
158
100
  var schema = _a.schema, modelName = _a.modelName;
159
- return __awaiter(void 0, void 0, void 0, function () {
101
+ return tslib_1.__awaiter(void 0, void 0, void 0, function () {
160
102
  var currentUser, e_1, attributes, authAttribute, sortedRules;
161
103
  var _b;
162
- return __generator(this, function (_c) {
104
+ return tslib_1.__generator(this, function (_c) {
163
105
  switch (_c.label) {
164
106
  case 0:
165
107
  amplifyContext.Auth = amplifyContext.Auth || auth_1.default;
@@ -1 +1 @@
1
- {"version":3,"file":"multiAuthStrategy.js","sourceRoot":"","sources":["../../src/authModeStrategies/multiAuthStrategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAG,UAAU,CAAC,IAAI,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,IAAI,KAAK,MAAM,EAApB,CAAoB,CAAC,CAAC;4BAEpE,UAAI,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,UAAU,0CAAE,KAAK,EAAE;gCAC/B,WAAW,GAAG,yBAAyB,CAC5C,aAAa,CAAC,UAAU,CAAC,KAAK,CAC9B,CAAC;gCAEF,sBAAO,YAAY,CAAC,EAAE,WAAW,aAAA,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAC;6BACzD;yBACD;wBACD,sBAAO,EAAE,EAAC;;;;KACV;AAvBD,CAuBC,CAAC"}
@@ -8,9 +8,9 @@ declare const initSchema: (userSchema: Schema) => Record<string, NonModelTypeCon
8
8
  export declare type ModelInstanceCreator = typeof modelInstanceCreator;
9
9
  declare function modelInstanceCreator<T extends PersistentModel = PersistentModel>(modelConstructor: PersistentModelConstructor<T>, init: ModelInit<T> & Partial<ModelInstanceMetadata>): T;
10
10
  declare class DataStore {
11
- Auth: import("@aws-amplify/auth/lib-esm/Auth").AuthClass;
12
- API: import("@aws-amplify/api").APIClass;
13
- Cache: import("@aws-amplify/cache/lib-esm/types").ICache;
11
+ private Auth;
12
+ private API;
13
+ private Cache;
14
14
  private amplifyConfig;
15
15
  private authModeStrategy;
16
16
  private conflictHandler;