@aws-amplify/datastore 3.9.0 → 3.9.1-unstable.5

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/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 | ![npm](https://img.shields.io/npm/v/@aws-amplify/datastore.svg) | [![Open Issues](https://img.shields.io/github/issues/aws-amplify/amplify-js/DataStore?color=red)](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+label%3ADataStore+is%3Aopen) | [![Closed Issues](https://img.shields.io/github/issues-closed/aws-amplify/amplify-js/DataStore)](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)
@@ -71106,7 +71106,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
71106
71106
  __webpack_require__.r(__webpack_exports__);
71107
71107
  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
71108
71108
  // generated by genversion
71109
- var version = '4.5.0';
71109
+ var version = '4.5.1';
71110
71110
 
71111
71111
  /***/ }),
71112
71112
 
@@ -73953,6 +73953,10 @@ __webpack_require__.r(__webpack_exports__);
73953
73953
  * is used for AppSync/GraphQL subscriptions in the API category.
73954
73954
  */
73955
73955
  var hasSymbol = typeof Symbol !== 'undefined' && typeof Symbol["for"] === 'function';
73956
+ /**
73957
+ * @deprecated Unused, all usecases have migrated to INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER
73958
+ */
73959
+
73956
73960
  var INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER = hasSymbol ? Symbol["for"]('INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER') : '@@INTERNAL_AWS_APPSYNC_PUBSUB_PROVIDER';
73957
73961
  var INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER = hasSymbol ? Symbol["for"]('INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER') : '@@INTERNAL_AWS_APPSYNC_REALTIME_PUBSUB_PROVIDER';
73958
73962
  var USER_AGENT_HEADER = 'x-amz-user-agent';
@@ -91418,7 +91422,7 @@ var __spread = undefined && undefined.__spread || function () {
91418
91422
  return ar;
91419
91423
  };
91420
91424
 
91421
-
91425
+ // https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#merger
91422
91426
 
91423
91427
  var ModelMerger =
91424
91428
  /** @class */
@@ -91747,6 +91751,7 @@ var __read = undefined && undefined.__read || function (o, n) {
91747
91751
 
91748
91752
 
91749
91753
  // TODO: Persist deleted ids
91754
+ // https://github.com/aws-amplify/amplify-js/blob/datastore-docs/packages/datastore/docs/sync-engine.md#outbox
91750
91755
 
91751
91756
  var MutationEventOutbox =
91752
91757
  /** @class */