@aws-amplify/datastore 5.0.1-api-v6-models.c1977f8.0 → 5.0.1-api-v6-models.891fe0d.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/lib/authModeStrategies/defaultAuthStrategy.js +1 -1
- package/lib/authModeStrategies/multiAuthStrategy.js +29 -105
- package/lib/datastore/datastore.js +887 -1370
- package/lib/index.js +1 -1
- package/lib/predicates/index.js +53 -102
- package/lib/predicates/next.js +310 -557
- package/lib/predicates/sort.js +24 -27
- package/lib/ssr/index.js +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js +115 -449
- package/lib/storage/adapter/AsyncStorageDatabase.js +215 -480
- package/lib/storage/adapter/InMemoryStore.js +27 -101
- package/lib/storage/adapter/InMemoryStore.native.js +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.js +441 -1002
- package/lib/storage/adapter/StorageAdapterBase.js +177 -396
- package/lib/storage/adapter/getDefaultAdapter/index.js +5 -6
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +2 -2
- package/lib/storage/relationship.js +174 -260
- package/lib/storage/storage.js +244 -507
- package/lib/sync/datastoreConnectivity.js +29 -84
- package/lib/sync/datastoreReachability/index.js +1 -1
- package/lib/sync/datastoreReachability/index.native.js +2 -2
- package/lib/sync/index.js +512 -885
- package/lib/sync/merger.js +30 -133
- package/lib/sync/outbox.js +147 -302
- package/lib/sync/processors/errorMaps.js +30 -80
- package/lib/sync/processors/mutation.js +331 -579
- package/lib/sync/processors/subscription.js +268 -428
- package/lib/sync/processors/sync.js +276 -464
- package/lib/sync/utils.js +248 -393
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.js +16 -58
- package/lib/util.js +335 -575
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js +1 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +27 -103
- package/lib-esm/datastore/datastore.js +874 -1359
- package/lib-esm/index.js +6 -6
- package/lib-esm/predicates/index.js +54 -104
- package/lib-esm/predicates/next.js +306 -555
- package/lib-esm/predicates/sort.js +24 -27
- package/lib-esm/ssr/index.js +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +111 -446
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +212 -477
- package/lib-esm/storage/adapter/InMemoryStore.js +27 -102
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +436 -997
- package/lib-esm/storage/adapter/StorageAdapterBase.js +172 -392
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -3
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +1 -1
- package/lib-esm/storage/relationship.js +173 -260
- package/lib-esm/storage/storage.js +236 -499
- package/lib-esm/sync/datastoreConnectivity.js +26 -82
- package/lib-esm/sync/datastoreReachability/index.js +1 -1
- package/lib-esm/sync/datastoreReachability/index.native.js +1 -1
- package/lib-esm/sync/index.js +498 -872
- package/lib-esm/sync/merger.js +28 -131
- package/lib-esm/sync/outbox.js +143 -298
- package/lib-esm/sync/processors/errorMaps.js +32 -82
- package/lib-esm/sync/processors/mutation.js +324 -572
- package/lib-esm/sync/processors/subscription.js +258 -418
- package/lib-esm/sync/processors/sync.js +269 -457
- package/lib-esm/sync/utils.js +245 -390
- package/lib-esm/tsconfig.tsbuildinfo +1 -1
- package/lib-esm/types.js +16 -59
- package/lib-esm/util.js +335 -577
- package/package.json +12 -12
- package/src/datastore/datastore.ts +4 -3
- package/src/storage/adapter/getDefaultAdapter/index.ts +1 -3
- package/src/sync/processors/mutation.ts +1 -1
- package/src/sync/processors/sync.ts +1 -1
- package/src/sync/utils.ts +1 -1
- package/src/util.ts +44 -6
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
get: function (_target, propertyKey, receiver) {
|
|
10
|
-
var field = propertyKey;
|
|
1
|
+
class ModelSortPredicateCreator {
|
|
2
|
+
static createPredicateBuilder(modelDefinition) {
|
|
3
|
+
const { name: modelName } = modelDefinition;
|
|
4
|
+
const fieldNames = new Set(Object.keys(modelDefinition.fields));
|
|
5
|
+
let handler;
|
|
6
|
+
const predicate = new Proxy({}, (handler = {
|
|
7
|
+
get(_target, propertyKey, receiver) {
|
|
8
|
+
const field = propertyKey;
|
|
11
9
|
if (!fieldNames.has(field)) {
|
|
12
|
-
throw new Error(
|
|
10
|
+
throw new Error(`Invalid field for model. field: ${String(field)}, model: ${modelName}`);
|
|
13
11
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const result = (sortDirection) => {
|
|
13
|
+
ModelSortPredicateCreator.sortPredicateGroupsMap
|
|
14
|
+
.get(receiver)
|
|
15
|
+
?.push({ field, sortDirection });
|
|
18
16
|
return receiver;
|
|
19
17
|
};
|
|
20
18
|
return result;
|
|
@@ -22,31 +20,30 @@ export var ModelSortPredicateCreator = /** @class */ (function () {
|
|
|
22
20
|
}));
|
|
23
21
|
ModelSortPredicateCreator.sortPredicateGroupsMap.set(predicate, []);
|
|
24
22
|
return predicate;
|
|
25
|
-
}
|
|
26
|
-
|
|
23
|
+
}
|
|
24
|
+
static isValidPredicate(predicate) {
|
|
27
25
|
return ModelSortPredicateCreator.sortPredicateGroupsMap.has(predicate);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
if (throwOnInvalid === void 0) { throwOnInvalid = true; }
|
|
26
|
+
}
|
|
27
|
+
static getPredicates(predicate, throwOnInvalid = true) {
|
|
31
28
|
if (throwOnInvalid &&
|
|
32
29
|
!ModelSortPredicateCreator.isValidPredicate(predicate)) {
|
|
33
30
|
throw new Error('The predicate is not valid');
|
|
34
31
|
}
|
|
35
|
-
|
|
32
|
+
const predicateGroup = ModelSortPredicateCreator.sortPredicateGroupsMap.get(predicate);
|
|
36
33
|
if (predicateGroup) {
|
|
37
34
|
return predicateGroup;
|
|
38
35
|
}
|
|
39
36
|
else {
|
|
40
37
|
throw new Error('Predicate group not found');
|
|
41
38
|
}
|
|
42
|
-
}
|
|
39
|
+
}
|
|
43
40
|
// transforms cb-style predicate into Proxy
|
|
44
|
-
|
|
41
|
+
static createFromExisting(modelDefinition, existing) {
|
|
45
42
|
if (!existing || !modelDefinition) {
|
|
46
43
|
return undefined;
|
|
47
44
|
}
|
|
48
45
|
return existing(ModelSortPredicateCreator.createPredicateBuilder(modelDefinition));
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
ModelSortPredicateCreator.sortPredicateGroupsMap = new WeakMap();
|
|
49
|
+
export { ModelSortPredicateCreator };
|
package/lib-esm/ssr/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Helper for converting JSON back into DataStore models (while respecting IDs)
|
|
2
2
|
export function deserializeModel(Model, init) {
|
|
3
3
|
if (Array.isArray(init)) {
|
|
4
|
-
return init.map(
|
|
4
|
+
return init.map(init => deserializeModel(Model, init));
|
|
5
5
|
}
|
|
6
6
|
// `fromJSON` is intentionally hidden from types as a "private" method (though it exists on the instance)
|
|
7
7
|
// @ts-ignore Property 'fromJSON' does not exist on type 'PersistentModelConstructor<T>'.ts(2339)
|