@aws-amplify/datastore 3.9.1-unstable.3 → 3.10.0
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.
- package/CHANGELOG.md +11 -0
- package/README.md +154 -0
- package/dist/aws-amplify-datastore.js +2 -1
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/sync/merger.js +1 -0
- package/lib/sync/merger.js.map +1 -1
- package/lib/sync/outbox.js +1 -0
- package/lib/sync/outbox.js.map +1 -1
- package/lib-esm/sync/merger.js +1 -0
- package/lib-esm/sync/merger.js.map +1 -1
- package/lib-esm/sync/outbox.js +1 -0
- package/lib-esm/sync/outbox.js.map +1 -1
- package/package.json +7 -7
- package/src/sync/merger.ts +2 -0
- package/src/sync/outbox.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.10.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.9.0...@aws-amplify/datastore@3.10.0) (2022-04-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **data:** Datastore Docs ([#9753](https://github.com/aws-amplify/amplify-js/issues/9753)) ([4eb824f](https://github.com/aws-amplify/amplify-js/commit/4eb824f168df408469557e6ccc60edfee99953c2))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [3.9.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.8.0...@aws-amplify/datastore@3.9.0) (2022-04-04)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# AWS Amplify DataStore Docs
|
|
2
|
+
|
|
3
|
+
[Amplify DataStore](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/) provides a programming model for leveraging shared and distributed data without writing additional code for offline and online scenarios, which makes working with distributed, cross-user data just as simple as working with local-only data.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
| package | version | open issues | closed issues |
|
|
8
|
+
| ---------------------- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
9
|
+
| @aws-amplify/datastore |  | [](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+label%3ADataStore+is%3Aopen) | [](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+label%3ADataStore+is%3Aclosed) |
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## **👋 Note For Contributers: 👋**
|
|
14
|
+
|
|
15
|
+
_**Please update these docs any time you find something that is incorrect or lacking. In particular, if a line in the docs prompts a question, take a moment to figure out the answer, then update the docs with the necessary detail.**_
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
Before you start reading through these docs, take a moment to understand [how DataStore works at a high level](https://docs.amplify.aws/lib/datastore/how-it-works/q/platform/js/). Additionally, we recommend first reading through [docs.amplify.aws](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/). The purpose of these docs is to dive deep into the codebase itself and understand the inner workings of DataStore for the purpose of contributing. Understanding these docs is **not** necessary for using DataStore. Lastly, before reading, take a look at [the diagrams below](#diagrams).
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Docs
|
|
26
|
+
|
|
27
|
+
- [Conflict Resolution](docs/conflict-resolution.md)
|
|
28
|
+
- [Contributing](docs/contributing.md)
|
|
29
|
+
- [DataStore Lifecycle Events ("Start", "Stop", "Clear")](docs/datastore-lifecycle-events.md)
|
|
30
|
+
- This explains how DataStore fundementally works, and is a great place to start.
|
|
31
|
+
- [Getting Started](docs/getting-started.md) (Running against a sample app, etc.)
|
|
32
|
+
- [Namespaces](docs/namespaces.md)
|
|
33
|
+
- [How DataStore uses Observables](docs/observables.md)
|
|
34
|
+
- [Schema Changes](docs/schema-changes.md)
|
|
35
|
+
- [Storage](docs/storage.md)
|
|
36
|
+
- [Sync Engine](docs/sync-engine.md)
|
|
37
|
+
- ["Unsupported hacks" / workarounds](docs/workarounds.md)
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# Diagrams
|
|
42
|
+
|
|
43
|
+
_Note: relationships with dotted lines are explained more in a separate diagram._
|
|
44
|
+
|
|
45
|
+
## How the DataStore API and Storage Engine Interact
|
|
46
|
+
|
|
47
|
+
```mermaid
|
|
48
|
+
flowchart TD
|
|
49
|
+
%% API and Storage
|
|
50
|
+
api[[DS API]]-- observe -->storage{Storage Engine}
|
|
51
|
+
storage-- next -->adapter[[Adapter]]
|
|
52
|
+
adapter-->db[[Local DB]]
|
|
53
|
+
db-->api
|
|
54
|
+
sync[[Sync Engine*]]-.-storage
|
|
55
|
+
sync-.-appSync[(AppSync)]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
# How the Sync Engine Observes Changes in Storage and AppSync
|
|
59
|
+
|
|
60
|
+
_Note: All green nodes belong to the Sync Engine._
|
|
61
|
+
|
|
62
|
+
\* Merger first checks outbox
|
|
63
|
+
|
|
64
|
+
\*\* Outbox sends outgoing messages to AppSync
|
|
65
|
+
|
|
66
|
+
```mermaid
|
|
67
|
+
flowchart TD
|
|
68
|
+
|
|
69
|
+
subgraph SyncEngine
|
|
70
|
+
index{index.ts}-- observe -->reach[Core reachability]
|
|
71
|
+
|
|
72
|
+
subgraph processors
|
|
73
|
+
mp[Mutation Processor]
|
|
74
|
+
sp[Subscription Processor]
|
|
75
|
+
syp[Sync Processor]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
reach--next-->mp[Mutation Processor]
|
|
79
|
+
reach--next-->sp[Subscription Processor]
|
|
80
|
+
reach--next-->syp[Sync Processor]
|
|
81
|
+
|
|
82
|
+
subgraph outbox / merger
|
|
83
|
+
outbox[Outbox]
|
|
84
|
+
merger[Merger]
|
|
85
|
+
outbox---merger
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
api[DS API]-.->storage
|
|
91
|
+
mp-- 1. observe -->storage{Storage Engine}
|
|
92
|
+
storage-- 2. next -->merger[merger*]-- next -->storage
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
sp-- observe -->appsync[(AppSync)]
|
|
96
|
+
appsync-- next -->sp
|
|
97
|
+
|
|
98
|
+
syp---appsync
|
|
99
|
+
|
|
100
|
+
mp-->outbox[outbox**]
|
|
101
|
+
|
|
102
|
+
appsync<--->outbox
|
|
103
|
+
%% styling
|
|
104
|
+
classDef syncEngineClass fill:#8FB,stroke:#333,stroke-width:4px,color:#333;
|
|
105
|
+
class index,mp,sp,syp,merger,outbox syncEngineClass;
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
# Project Structure
|
|
111
|
+
|
|
112
|
+
<pre>
|
|
113
|
+
amplify-js/packages/datastore/src
|
|
114
|
+
├── authModeStrategies
|
|
115
|
+
│ └── defaultAuthStraegy.ts
|
|
116
|
+
│ └── index.ts
|
|
117
|
+
│ └── multiAuthStrategy.ts
|
|
118
|
+
├── datastore
|
|
119
|
+
│ └── datastore.ts # Entry point for DataStore
|
|
120
|
+
├── predicates
|
|
121
|
+
│ └── index.ts
|
|
122
|
+
│ └── sort.ts
|
|
123
|
+
├── ssr
|
|
124
|
+
├── storage # Storage Engine
|
|
125
|
+
│ └── adapter # Platform-specific Storage Adapters
|
|
126
|
+
│ └── getDefaultAdapter
|
|
127
|
+
│ └── AsyncStorageAdapter.ts
|
|
128
|
+
│ └── AsyncStorageDatabase.ts
|
|
129
|
+
│ └── index.ts
|
|
130
|
+
│ └── IndexedDBAdapter.ts
|
|
131
|
+
│ └── InMemoryStore.native.ts
|
|
132
|
+
│ └── InMemoryStore.ts
|
|
133
|
+
│ └── storage.ts # Entry point for Storage
|
|
134
|
+
├── sync # Sync Engine
|
|
135
|
+
│ └── dataStoreReachability
|
|
136
|
+
│ └── index.native.ts
|
|
137
|
+
│ └── index.ts
|
|
138
|
+
│ └── processors # Sync Engine Processors
|
|
139
|
+
│ └── mutation.ts
|
|
140
|
+
│ └── subscription.ts
|
|
141
|
+
│ └── sync.ts
|
|
142
|
+
│ └── datastoreConnectivity.ts # Subscribe to reachability monitor
|
|
143
|
+
│ └── index.ts # Entry point for Sync Engine
|
|
144
|
+
│ └── merger.ts # <a href="https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#merger" title="merger doc">doc</a>
|
|
145
|
+
│ └── outbox.ts # <a href="https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#outbox" title="outbox doc">doc</a>
|
|
146
|
+
</pre>
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Other Resources:
|
|
151
|
+
|
|
152
|
+
- [High-level overview of how DataStore works](https://docs.amplify.aws/lib/datastore/how-it-works/q/platform/js/)
|
|
153
|
+
- [DataStore Docs](https://docs.amplify.aws/lib/datastore/getting-started/q/platform/js/)
|
|
154
|
+
- [re:Invent talk](https://www.youtube.com/watch?v=KcYl6_We0EU)
|
|
@@ -91422,7 +91422,7 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
91422
91422
|
return ar;
|
|
91423
91423
|
};
|
|
91424
91424
|
|
|
91425
|
-
|
|
91425
|
+
// https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#merger
|
|
91426
91426
|
|
|
91427
91427
|
var ModelMerger =
|
|
91428
91428
|
/** @class */
|
|
@@ -91751,6 +91751,7 @@ var __read = undefined && undefined.__read || function (o, n) {
|
|
|
91751
91751
|
|
|
91752
91752
|
|
|
91753
91753
|
// TODO: Persist deleted ids
|
|
91754
|
+
// https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#outbox
|
|
91754
91755
|
|
|
91755
91756
|
var MutationEventOutbox =
|
|
91756
91757
|
/** @class */
|