@aws-amplify/datastore 3.12.6-next.20 → 3.12.6-next.36
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 +58 -0
- package/lib/authModeStrategies/multiAuthStrategy.d.ts +11 -0
- package/lib/authModeStrategies/multiAuthStrategy.js +13 -2
- package/lib/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib/datastore/datastore.d.ts +107 -17
- package/lib/datastore/datastore.js +648 -344
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/index.d.ts +3 -19
- package/lib/predicates/index.d.ts +3 -2
- package/lib/predicates/index.js +12 -2
- package/lib/predicates/index.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.d.ts +4 -3
- package/lib/storage/adapter/AsyncStorageAdapter.js +354 -203
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageDatabase.d.ts +14 -4
- package/lib/storage/adapter/AsyncStorageDatabase.js +65 -28
- package/lib/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +26 -4
- package/lib/storage/adapter/IndexedDBAdapter.js +444 -271
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/storage/adapter/index.d.ts +1 -1
- package/lib/storage/storage.d.ts +1 -1
- package/lib/storage/storage.js +93 -28
- package/lib/storage/storage.js.map +1 -1
- package/lib/sync/datastoreConnectivity.d.ts +1 -0
- package/lib/sync/datastoreConnectivity.js +9 -0
- package/lib/sync/datastoreConnectivity.js.map +1 -1
- package/lib/sync/index.d.ts +31 -5
- package/lib/sync/index.js +522 -397
- package/lib/sync/index.js.map +1 -1
- package/lib/sync/merger.d.ts +9 -3
- package/lib/sync/merger.js +13 -6
- package/lib/sync/merger.js.map +1 -1
- package/lib/sync/outbox.d.ts +2 -2
- package/lib/sync/outbox.js +77 -71
- package/lib/sync/outbox.js.map +1 -1
- package/lib/sync/processors/mutation.d.ts +2 -0
- package/lib/sync/processors/mutation.js +269 -209
- package/lib/sync/processors/mutation.js.map +1 -1
- package/lib/sync/processors/subscription.d.ts +2 -0
- package/lib/sync/processors/subscription.js +213 -178
- package/lib/sync/processors/subscription.js.map +1 -1
- package/lib/sync/processors/sync.d.ts +2 -1
- package/lib/sync/processors/sync.js +126 -121
- package/lib/sync/processors/sync.js.map +1 -1
- package/lib/sync/utils.d.ts +3 -2
- package/lib/sync/utils.js +43 -8
- package/lib/sync/utils.js.map +1 -1
- package/lib/types.d.ts +65 -26
- package/lib/types.js +10 -1
- package/lib/types.js.map +1 -1
- package/lib/util.d.ts +67 -24
- package/lib/util.js +419 -166
- package/lib/util.js.map +1 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.d.ts +11 -0
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +12 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +1 -1
- package/lib-esm/datastore/datastore.d.ts +107 -17
- package/lib-esm/datastore/datastore.js +648 -344
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/index.d.ts +3 -19
- package/lib-esm/predicates/index.d.ts +3 -2
- package/lib-esm/predicates/index.js +13 -3
- package/lib-esm/predicates/index.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.d.ts +4 -3
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +355 -204
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageDatabase.d.ts +14 -4
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +66 -29
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +26 -4
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +445 -272
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/index.d.ts +1 -1
- package/lib-esm/storage/storage.d.ts +1 -1
- package/lib-esm/storage/storage.js +93 -28
- package/lib-esm/storage/storage.js.map +1 -1
- package/lib-esm/sync/datastoreConnectivity.d.ts +1 -0
- package/lib-esm/sync/datastoreConnectivity.js +10 -1
- package/lib-esm/sync/datastoreConnectivity.js.map +1 -1
- package/lib-esm/sync/index.d.ts +31 -5
- package/lib-esm/sync/index.js +524 -399
- package/lib-esm/sync/index.js.map +1 -1
- package/lib-esm/sync/merger.d.ts +9 -3
- package/lib-esm/sync/merger.js +13 -6
- package/lib-esm/sync/merger.js.map +1 -1
- package/lib-esm/sync/outbox.d.ts +2 -2
- package/lib-esm/sync/outbox.js +78 -72
- 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 +270 -210
- 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 +213 -178
- package/lib-esm/sync/processors/subscription.js.map +1 -1
- package/lib-esm/sync/processors/sync.d.ts +2 -1
- package/lib-esm/sync/processors/sync.js +126 -121
- package/lib-esm/sync/processors/sync.js.map +1 -1
- package/lib-esm/sync/utils.d.ts +3 -2
- package/lib-esm/sync/utils.js +45 -11
- package/lib-esm/sync/utils.js.map +1 -1
- package/lib-esm/types.d.ts +65 -26
- package/lib-esm/types.js +9 -2
- package/lib-esm/types.js.map +1 -1
- package/lib-esm/util.d.ts +67 -24
- package/lib-esm/util.js +419 -166
- package/lib-esm/util.js.map +1 -1
- package/package.json +16 -9
- package/src/authModeStrategies/multiAuthStrategy.ts +12 -1
- package/src/datastore/datastore.ts +798 -397
- package/src/predicates/index.ts +32 -10
- package/src/storage/adapter/AsyncStorageAdapter.ts +309 -93
- package/src/storage/adapter/AsyncStorageDatabase.ts +74 -26
- package/src/storage/adapter/IndexedDBAdapter.ts +358 -134
- package/src/storage/adapter/index.ts +1 -1
- package/src/storage/storage.ts +69 -22
- package/src/sync/datastoreConnectivity.ts +6 -0
- package/src/sync/index.ts +521 -412
- package/src/sync/merger.ts +20 -4
- package/src/sync/outbox.ts +22 -9
- package/src/sync/processors/mutation.ts +188 -150
- package/src/sync/processors/subscription.ts +289 -253
- package/src/sync/processors/sync.ts +151 -138
- package/src/sync/utils.ts +67 -12
- package/src/types.ts +182 -30
- package/src/util.ts +505 -176
- package/build.js +0 -5
- package/dist/aws-amplify-datastore.js +0 -83311
- package/dist/aws-amplify-datastore.js.map +0 -1
- package/dist/aws-amplify-datastore.min.js +0 -168
- package/dist/aws-amplify-datastore.min.js.map +0 -1
- package/index.js +0 -7
- package/webpack.config.dev.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,64 @@
|
|
|
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.14.2](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.14.1...@aws-amplify/datastore@3.14.2) (2022-10-26)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @aws-amplify/datastore
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [3.14.1](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.14.0...@aws-amplify/datastore@3.14.1) (2022-10-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **@aws-amplify/datastore:** introduce "settlement" guarantees to stop() and clear() ([#10450](https://github.com/aws-amplify/amplify-js/issues/10450)) ([16c535b](https://github.com/aws-amplify/amplify-js/commit/16c535beda9386a027c2805f29a359fbeb8bac15)), closes [#10449](https://github.com/aws-amplify/amplify-js/issues/10449)
|
|
20
|
+
* **datastore:** CPK on Safari ([#10527](https://github.com/aws-amplify/amplify-js/issues/10527)) ([7a2f3ec](https://github.com/aws-amplify/amplify-js/commit/7a2f3ecf0fda83f087b1c2ce650f4b5f00214dbe))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# [3.14.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.13.0...@aws-amplify/datastore@3.14.0) (2022-10-14)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **datastore:** unblock vite build after CPK changes ([#10478](https://github.com/aws-amplify/amplify-js/issues/10478)) ([42ae8de](https://github.com/aws-amplify/amplify-js/commit/42ae8de62f53e7d81363c0dd676967454271259a))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
* **datastore:** allow sync query to complete when non-applicable data present ([#10471](https://github.com/aws-amplify/amplify-js/issues/10471)) ([f8e8ff4](https://github.com/aws-amplify/amplify-js/commit/f8e8ff4c1a59d600b96944e5963dfa56a44af035))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
# [3.13.0](https://github.com/aws-amplify/amplify-js/compare/@aws-amplify/datastore@3.12.12...@aws-amplify/datastore@3.13.0) (2022-10-14)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
|
|
47
|
+
* validate non models when using object literal ([#10417](https://github.com/aws-amplify/amplify-js/issues/10417)) ([b6f6c81](https://github.com/aws-amplify/amplify-js/commit/b6f6c813f80f951f21f986411928c0ddbd1c6b6c))
|
|
48
|
+
* **@aws-amplify/datastore:** introduce "settlement" guarantees to stop() and clear() ([#10055](https://github.com/aws-amplify/amplify-js/issues/10055)) ([c64d7d6](https://github.com/aws-amplify/amplify-js/commit/c64d7d6284bc7b41a5a65b4b47d35ea274aed6b3))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Features
|
|
52
|
+
|
|
53
|
+
* **datastore:** custom pk support ([66bfe31](https://github.com/aws-amplify/amplify-js/commit/66bfe312f300fd6ca1bc756ab01690d36f337af9))
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
### Reverts
|
|
57
|
+
|
|
58
|
+
* "fix(@aws-amplify/datastore): introduce "settlement" guarantees to stop() and clear()" ([#10449](https://github.com/aws-amplify/amplify-js/issues/10449)) ([d726bcc](https://github.com/aws-amplify/amplify-js/commit/d726bccca9712b8f43bc273052f970f8f931dd8c)), closes [aws-amplify/amplify-js#10055](https://github.com/aws-amplify/amplify-js/issues/10055)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
6
64
|
## [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
65
|
|
|
8
66
|
**Note:** Version bump only for package @aws-amplify/datastore
|
|
@@ -1,2 +1,13 @@
|
|
|
1
1
|
import { AuthModeStrategy, AmplifyContext } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an array of auth modes to try based on the schema, model, and
|
|
4
|
+
* authenticated user (or lack thereof). Rules are sourced from `getAuthRules`
|
|
5
|
+
* and returned in the order they ought to be attempted.
|
|
6
|
+
*
|
|
7
|
+
* @see sortAuthRulesWithPriority
|
|
8
|
+
* @see getAuthRules
|
|
9
|
+
*
|
|
10
|
+
* @param param0 The `{schema, modelName}` to inspect.
|
|
11
|
+
* @returns A sorted array of auth modes to attempt.
|
|
12
|
+
*/
|
|
2
13
|
export declare const multiAuthStrategy: (amplifyContext: AmplifyContext) => AuthModeStrategy;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var tslib_1 = require("tslib");
|
|
4
|
-
var auth_1 =
|
|
4
|
+
var auth_1 = require("@aws-amplify/auth");
|
|
5
5
|
var api_graphql_1 = require("@aws-amplify/api-graphql");
|
|
6
6
|
var types_1 = require("../types");
|
|
7
7
|
function getProviderFromRule(rule) {
|
|
@@ -95,6 +95,17 @@ function getAuthRules(_a) {
|
|
|
95
95
|
});
|
|
96
96
|
return Array.from(authModes);
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Returns an array of auth modes to try based on the schema, model, and
|
|
100
|
+
* authenticated user (or lack thereof). Rules are sourced from `getAuthRules`
|
|
101
|
+
* and returned in the order they ought to be attempted.
|
|
102
|
+
*
|
|
103
|
+
* @see sortAuthRulesWithPriority
|
|
104
|
+
* @see getAuthRules
|
|
105
|
+
*
|
|
106
|
+
* @param param0 The `{schema, modelName}` to inspect.
|
|
107
|
+
* @returns A sorted array of auth modes to attempt.
|
|
108
|
+
*/
|
|
98
109
|
exports.multiAuthStrategy = function (amplifyContext) {
|
|
99
110
|
return function (_a) {
|
|
100
111
|
var schema = _a.schema, modelName = _a.modelName;
|
|
@@ -104,7 +115,7 @@ exports.multiAuthStrategy = function (amplifyContext) {
|
|
|
104
115
|
return tslib_1.__generator(this, function (_c) {
|
|
105
116
|
switch (_c.label) {
|
|
106
117
|
case 0:
|
|
107
|
-
amplifyContext.Auth = amplifyContext.Auth || auth_1.
|
|
118
|
+
amplifyContext.Auth = amplifyContext.Auth || auth_1.Auth;
|
|
108
119
|
_c.label = 1;
|
|
109
120
|
case 1:
|
|
110
121
|
_c.trys.push([1, 3, , 4]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiAuthStrategy.js","sourceRoot":"","sources":["../../src/authModeStrategies/multiAuthStrategy.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"multiAuthStrategy.js","sourceRoot":"","sources":["../../src/authModeStrategies/multiAuthStrategy.ts"],"names":[],"mappings":";;;AAAA,0CAAyC;AACzC,wDAA6D;AAC7D,kCAMkB;AAElB,SAAS,mBAAmB,CAC3B,IAAgC;IAEhC,2CAA2C;IAC3C,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,CAAC,IAAI,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BD,CAuBC,CAAC"}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import Observable from 'zen-observable-ts';
|
|
2
2
|
import { PredicateAll } from '../predicates';
|
|
3
|
-
import { ConflictHandler, DataStoreConfig,
|
|
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
|
-
declare const initSchema: (userSchema: Schema) => Record<string,
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
*/
|
|
8
15
|
export declare type ModelInstanceCreator = typeof modelInstanceCreator;
|
|
9
|
-
declare function modelInstanceCreator<T extends PersistentModel
|
|
16
|
+
declare function modelInstanceCreator<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, init: Partial<T>): T;
|
|
10
17
|
declare class DataStore {
|
|
11
18
|
private Auth;
|
|
12
19
|
private API;
|
|
@@ -16,50 +23,133 @@ declare class DataStore {
|
|
|
16
23
|
private conflictHandler;
|
|
17
24
|
private errorHandler;
|
|
18
25
|
private fullSyncInterval;
|
|
19
|
-
private initialized
|
|
26
|
+
private initialized?;
|
|
20
27
|
private initReject;
|
|
21
28
|
private initResolve;
|
|
22
29
|
private maxRecordsToSync;
|
|
23
|
-
private storage
|
|
24
|
-
private sync
|
|
30
|
+
private storage?;
|
|
31
|
+
private sync?;
|
|
25
32
|
private syncPageSize;
|
|
26
33
|
private syncExpressions;
|
|
27
34
|
private syncPredicates;
|
|
28
35
|
private sessionId;
|
|
29
36
|
private storageAdapter;
|
|
30
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;
|
|
31
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
|
+
*/
|
|
32
94
|
start: () => Promise<void>;
|
|
33
95
|
query: {
|
|
34
|
-
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>,
|
|
96
|
+
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, identifier: IdentifierFieldOrIdentifierObject<T, PersistentModelMetaData<T>>): Promise<T | undefined>;
|
|
35
97
|
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, criteria?: ProducerModelPredicate<T> | typeof PredicateAll, paginationProducer?: ProducerPaginationInput<T>): Promise<T[]>;
|
|
36
98
|
};
|
|
37
|
-
save: <T extends Readonly<
|
|
38
|
-
id: string;
|
|
39
|
-
} & Record<string, any>>>(model: T, condition?: ProducerModelPredicate<T>) => Promise<T>;
|
|
99
|
+
save: <T extends Readonly<Record<string, any>>>(model: T, condition?: ProducerModelPredicate<T>) => Promise<T>;
|
|
40
100
|
setConflictHandler: (config: DataStoreConfig) => ConflictHandler;
|
|
41
101
|
setErrorHandler: (config: DataStoreConfig) => ErrorHandler;
|
|
42
102
|
delete: {
|
|
43
|
-
<T extends PersistentModel>(
|
|
44
|
-
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, id: string): Promise<T[]>;
|
|
103
|
+
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, identifier: IdentifierFieldOrIdentifierObject<T, PersistentModelMetaData<T>>): Promise<T[]>;
|
|
45
104
|
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, condition: ProducerModelPredicate<T> | typeof PredicateAll): Promise<T[]>;
|
|
105
|
+
<T extends PersistentModel>(model: T, condition?: ProducerModelPredicate<T>): Promise<T>;
|
|
46
106
|
};
|
|
47
107
|
observe: {
|
|
48
108
|
(): Observable<SubscriptionMessage<PersistentModel>>;
|
|
109
|
+
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, identifier: string): Observable<SubscriptionMessage<T>>;
|
|
110
|
+
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, criteria?: ProducerModelPredicate<T> | typeof PredicateAll): Observable<SubscriptionMessage<T>>;
|
|
49
111
|
<T extends PersistentModel>(model: T): Observable<SubscriptionMessage<T>>;
|
|
50
|
-
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, criteria?: string | ProducerModelPredicate<T>): Observable<SubscriptionMessage<T>>;
|
|
51
112
|
};
|
|
52
113
|
observeQuery: {
|
|
53
114
|
<T extends PersistentModel>(modelConstructor: PersistentModelConstructor<T>, criteria?: ProducerModelPredicate<T> | typeof PredicateAll, paginationProducer?: ObserveQueryOptions<T>): Observable<DataStoreSnapshot<T>>;
|
|
54
115
|
};
|
|
55
116
|
configure: (config?: DataStoreConfig) => void;
|
|
56
|
-
|
|
57
|
-
|
|
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
|
+
*/
|
|
58
140
|
private processPagination;
|
|
141
|
+
/**
|
|
142
|
+
* Examines the configured `syncExpressions` and produces a WeakMap of
|
|
143
|
+
* SchemaModel -> predicate to use during sync.
|
|
144
|
+
*/
|
|
59
145
|
private processSyncExpressions;
|
|
60
146
|
private createFromCondition;
|
|
61
147
|
private unwrapPromise;
|
|
62
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
|
+
*/
|
|
63
153
|
private retrieveSessionId;
|
|
64
154
|
}
|
|
65
155
|
declare const instance: DataStore;
|