@aws-amplify/datastore 3.14.1-unstable.3 → 3.14.1
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 +12 -0
- package/dist/aws-amplify-datastore.js +2798 -1458
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +10 -10
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/authModeStrategies/multiAuthStrategy.js +11 -0
- package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib/datastore/datastore.js +524 -323
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.js +76 -25
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/storage/storage.js +2 -2
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/datastoreConnectivity.js +45 -0
- package/lib/sync/datastoreConnectivity.js.map +1 -1
- package/lib/sync/index.js +518 -395
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/merger.js +6 -0
- package/lib/sync/merger.js.map +1 -1
- package/lib/sync/outbox.js +66 -62
- package/lib/sync/outbox.js.map +1 -1
- package/lib/sync/processors/mutation.js +207 -165
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/sync/processors/subscription.js +210 -175
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.js +95 -72
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.js +1 -3
- package/lib/sync/utils.js.map +1 -1
- package/lib/util.js +89 -0
- package/lib/util.js.map +1 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.d.ts +11 -0
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +11 -0
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib-esm/datastore/datastore.d.ts +95 -2
- package/lib-esm/datastore/datastore.js +524 -323
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +21 -0
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +77 -26
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/storage.js +2 -2
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/datastoreConnectivity.d.ts +1 -0
- package/lib-esm/sync/datastoreConnectivity.js +45 -0
- package/lib-esm/sync/datastoreConnectivity.js.map +1 -1
- package/lib-esm/sync/index.d.ts +9 -1
- package/lib-esm/sync/index.js +519 -396
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/merger.d.ts +6 -0
- package/lib-esm/sync/merger.js +6 -0
- package/lib-esm/sync/merger.js.map +1 -1
- package/lib-esm/sync/outbox.js +66 -62
- package/lib-esm/sync/outbox.js.map +1 -1
- package/lib-esm/sync/processors/mutation.d.ts +2 -0
- package/lib-esm/sync/processors/mutation.js +208 -166
- package/lib-esm/sync/processors/mutation.js.map +1 -1
- package/lib-esm/sync/processors/subscription.d.ts +2 -0
- package/lib-esm/sync/processors/subscription.js +211 -176
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.d.ts +2 -0
- package/lib-esm/sync/processors/sync.js +96 -73
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.js +1 -3
- package/lib-esm/sync/utils.js.map +1 -1
- package/lib-esm/util.d.ts +11 -0
- package/lib-esm/util.js +89 -0
- package/lib-esm/util.js.map +1 -1
- package/package.json +7 -7
- package/src/authModeStrategies/multiAuthStrategy.ts +11 -0
- package/src/datastore/datastore.ts +572 -366
- package/src/storage/adapter/IndexedDBAdapter.ts +50 -9
- package/src/storage/storage.ts +2 -2
- package/src/sync/datastoreConnectivity.ts +6 -0
- package/src/sync/index.ts +492 -400
- package/src/sync/merger.ts +6 -0
- package/src/sync/outbox.ts +1 -1
- package/src/sync/processors/mutation.ts +139 -104
- package/src/sync/processors/subscription.ts +287 -250
- package/src/sync/processors/sync.ts +88 -60
- package/src/sync/utils.ts +1 -3
- package/src/util.ts +92 -2
- package/lib/authModeStrategies/defaultAuthStrategy.d.ts +0 -2
- package/lib/authModeStrategies/index.d.ts +0 -2
- package/lib/authModeStrategies/multiAuthStrategy.d.ts +0 -2
- package/lib/datastore/datastore.d.ts +0 -63
- package/lib/index.d.ts +0 -15
- package/lib/predicates/index.d.ts +0 -16
- package/lib/predicates/sort.d.ts +0 -8
- package/lib/ssr/index.d.ts +0 -3
- package/lib/storage/adapter/AsyncStorageAdapter.d.ts +0 -41
- package/lib/storage/adapter/AsyncStorageDatabase.d.ts +0 -39
- package/lib/storage/adapter/InMemoryStore.d.ts +0 -11
- package/lib/storage/adapter/InMemoryStore.native.d.ts +0 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +0 -38
- package/lib/storage/adapter/getDefaultAdapter/index.d.ts +0 -3
- package/lib/storage/adapter/getDefaultAdapter/index.native.d.ts +0 -3
- package/lib/storage/adapter/index.d.ts +0 -9
- package/lib/storage/storage.d.ts +0 -49
- package/lib/sync/datastoreConnectivity.d.ts +0 -15
- package/lib/sync/datastoreReachability/index.d.ts +0 -3
- package/lib/sync/datastoreReachability/index.native.d.ts +0 -3
- package/lib/sync/index.d.ts +0 -81
- package/lib/sync/merger.d.ts +0 -11
- package/lib/sync/outbox.d.ts +0 -27
- package/lib/sync/processors/errorMaps.d.ts +0 -17
- package/lib/sync/processors/mutation.d.ts +0 -56
- package/lib/sync/processors/subscription.d.ts +0 -31
- package/lib/sync/processors/sync.d.ts +0 -26
- package/lib/sync/utils.d.ts +0 -42
- package/lib/types.d.ts +0 -501
- package/lib/util.d.ts +0 -145
|
@@ -3,6 +3,15 @@ import { PredicateAll } from '../predicates';
|
|
|
3
3
|
import { ConflictHandler, DataStoreConfig, NonModelTypeConstructor, ProducerPaginationInput, PersistentModel, PersistentModelConstructor, ProducerModelPredicate, Schema, SubscriptionMessage, DataStoreSnapshot, TypeConstructorMap, ErrorHandler, ObserveQueryOptions, PersistentModelMetaData, IdentifierFieldOrIdentifierObject } from '../types';
|
|
4
4
|
export declare let syncClasses: TypeConstructorMap;
|
|
5
5
|
declare const initSchema: (userSchema: Schema) => Record<string, PersistentModelConstructor<any> | NonModelTypeConstructor<unknown>>;
|
|
6
|
+
/**
|
|
7
|
+
* Constructs a model and records it with its metadata in a weakset. Allows for
|
|
8
|
+
* the separate storage of core model fields and Amplify/DataStore metadata
|
|
9
|
+
* fields that the customer app does not want exposed.
|
|
10
|
+
*
|
|
11
|
+
* @param modelConstructor The model constructor.
|
|
12
|
+
* @param init Init data that would normally be passed to the constructor.
|
|
13
|
+
* @returns The initialized model.
|
|
14
|
+
*/
|
|
6
15
|
export declare type ModelInstanceCreator = typeof modelInstanceCreator;
|
|
7
16
|
declare function modelInstanceCreator<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, init: Partial<T>): T;
|
|
8
17
|
declare class DataStore {
|
|
@@ -26,7 +35,62 @@ declare class DataStore {
|
|
|
26
35
|
private sessionId;
|
|
27
36
|
private storageAdapter;
|
|
28
37
|
private amplifyContext;
|
|
38
|
+
private connectivityMonitor?;
|
|
39
|
+
/**
|
|
40
|
+
* **IMPORTANT!**
|
|
41
|
+
*
|
|
42
|
+
* Accumulator for background things that can **and MUST** be called when
|
|
43
|
+
* DataStore stops.
|
|
44
|
+
*
|
|
45
|
+
* These jobs **MUST** be *idempotent promises* that resolve ONLY
|
|
46
|
+
* once the intended jobs are completely finished and/or otherwise destroyed
|
|
47
|
+
* and cleaned up with ZERO outstanding:
|
|
48
|
+
*
|
|
49
|
+
* 1. side effects (e.g., state changes)
|
|
50
|
+
* 1. callbacks
|
|
51
|
+
* 1. subscriptions
|
|
52
|
+
* 1. calls to storage
|
|
53
|
+
* 1. *etc.*
|
|
54
|
+
*
|
|
55
|
+
* Methods that create pending promises, subscriptions, callbacks, or any
|
|
56
|
+
* type of side effect **MUST** be registered with the manager. And, a new
|
|
57
|
+
* manager must be created after each `exit()`.
|
|
58
|
+
*
|
|
59
|
+
* Failure to comply will put DataStore into a highly unpredictable state
|
|
60
|
+
* when it needs to stop or clear -- which occurs when restarting with new
|
|
61
|
+
* sync expressions, during testing, and potentially during app code
|
|
62
|
+
* recovery handling, etc..
|
|
63
|
+
*
|
|
64
|
+
* It is up to the discretion of each disposer whether to wait for job
|
|
65
|
+
* completion or to cancel operations and issue failures *as long as the
|
|
66
|
+
* disposer returns in a reasonable amount of time.*
|
|
67
|
+
*
|
|
68
|
+
* (Reasonable = *seconds*, not minutes.)
|
|
69
|
+
*/
|
|
70
|
+
private runningProcesses;
|
|
71
|
+
/**
|
|
72
|
+
* Indicates what state DataStore is in.
|
|
73
|
+
*
|
|
74
|
+
* Not [yet?] used for actual state management; but for messaging
|
|
75
|
+
* when errors occur, to help troubleshoot.
|
|
76
|
+
*/
|
|
77
|
+
private state;
|
|
29
78
|
getModuleName(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Builds a function to capture `BackgroundManagerNotOpenError`'s to produce friendlier,
|
|
81
|
+
* more instructive errors for customers.
|
|
82
|
+
*
|
|
83
|
+
* @param operation The name of the operation (usually a Datastore method) the customer
|
|
84
|
+
* tried to call.
|
|
85
|
+
*/
|
|
86
|
+
handleAddProcError(operation: string): (err: Error) => never;
|
|
87
|
+
/**
|
|
88
|
+
* If not already done:
|
|
89
|
+
* 1. Attaches and initializes storage.
|
|
90
|
+
* 1. Loads the schema and records metadata.
|
|
91
|
+
* 1. If `this.amplifyConfig.aws_appsync_graphqlEndpoint` contains a URL,
|
|
92
|
+
* attaches a sync engine, starts it, and subscribes.
|
|
93
|
+
*/
|
|
30
94
|
start: () => Promise<void>;
|
|
31
95
|
query: {
|
|
32
96
|
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, identifier: IdentifierFieldOrIdentifierObject<T, PersistentModelMetaData<T>>): Promise<T | undefined>;
|
|
@@ -50,13 +114,42 @@ declare class DataStore {
|
|
|
50
114
|
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, criteria?: ProducerModelPredicate<T> | typeof PredicateAll, paginationProducer?: ObserveQueryOptions<T>): Observable<DataStoreSnapshot<T>>;
|
|
51
115
|
};
|
|
52
116
|
configure: (config?: DataStoreConfig) => void;
|
|
53
|
-
|
|
54
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Clears all data from storage and removes all data, schema info, other
|
|
119
|
+
* initialization details, and then stops DataStore.
|
|
120
|
+
*
|
|
121
|
+
* That said, reinitialization is required after clearing. This can be done
|
|
122
|
+
* by explicitiliy calling `start()` or any method that implicitly starts
|
|
123
|
+
* DataStore, such as `query()`, `save()`, or `delete()`.
|
|
124
|
+
*/
|
|
125
|
+
clear(): Promise<void>;
|
|
126
|
+
/**
|
|
127
|
+
* Stops all DataStore sync activities.
|
|
128
|
+
*
|
|
129
|
+
* TODO: "Waits for graceful termination of
|
|
130
|
+
* running queries and terminates subscriptions."
|
|
131
|
+
*/
|
|
132
|
+
stop(this: InstanceType<typeof DataStore>): Promise<void>;
|
|
133
|
+
/**
|
|
134
|
+
* Validates given pagination input from a query and creates a pagination
|
|
135
|
+
* argument for use against the storage layer.
|
|
136
|
+
*
|
|
137
|
+
* @param modelDefinition
|
|
138
|
+
* @param paginationProducer
|
|
139
|
+
*/
|
|
55
140
|
private processPagination;
|
|
141
|
+
/**
|
|
142
|
+
* Examines the configured `syncExpressions` and produces a WeakMap of
|
|
143
|
+
* SchemaModel -> predicate to use during sync.
|
|
144
|
+
*/
|
|
56
145
|
private processSyncExpressions;
|
|
57
146
|
private createFromCondition;
|
|
58
147
|
private unwrapPromise;
|
|
59
148
|
private weakMapFromEntries;
|
|
149
|
+
/**
|
|
150
|
+
* A session ID to allow CMS to open databases against multiple apps.
|
|
151
|
+
* This session ID is only expected be set by AWS Amplify Studio.
|
|
152
|
+
*/
|
|
60
153
|
private retrieveSessionId;
|
|
61
154
|
}
|
|
62
155
|
declare const instance: DataStore;
|