@aws-amplify/datastore 4.7.6-api-v6-models.b3abc9b.0 → 5.0.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/README.md +4 -0
- package/lib/authModeStrategies/defaultAuthStrategy.js +3 -2
- package/lib/authModeStrategies/index.js +3 -3
- package/lib/authModeStrategies/multiAuthStrategy.js +38 -53
- package/lib/datastore/datastore.d.ts +4 -5
- package/lib/datastore/datastore.js +929 -1284
- package/lib/index.d.ts +1 -1
- package/lib/index.js +26 -13
- package/lib/predicates/index.js +54 -69
- package/lib/predicates/next.d.ts +2 -2
- package/lib/predicates/next.js +313 -462
- package/lib/predicates/sort.js +24 -28
- package/lib/ssr/index.js +2 -2
- package/lib/storage/adapter/AsyncStorageAdapter.js +120 -342
- package/lib/storage/adapter/AsyncStorageDatabase.js +217 -421
- package/lib/storage/adapter/InMemoryStore.js +28 -51
- package/lib/storage/adapter/InMemoryStore.native.js +5 -3
- package/lib/storage/adapter/IndexedDBAdapter.js +466 -871
- package/lib/storage/adapter/StorageAdapterBase.js +180 -330
- package/lib/storage/adapter/getDefaultAdapter/index.js +8 -10
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +5 -4
- package/lib/storage/adapter/index.js +0 -1
- package/lib/storage/relationship.js +177 -253
- package/lib/storage/storage.d.ts +4 -4
- package/lib/storage/storage.js +255 -433
- package/lib/sync/datastoreConnectivity.d.ts +2 -2
- package/lib/sync/datastoreConnectivity.js +29 -39
- package/lib/sync/datastoreReachability/index.d.ts +1 -3
- package/lib/sync/datastoreReachability/index.js +3 -3
- package/lib/sync/datastoreReachability/index.native.d.ts +1 -3
- package/lib/sync/datastoreReachability/index.native.js +4 -5
- package/lib/sync/index.d.ts +2 -2
- package/lib/sync/index.js +522 -827
- package/lib/sync/merger.js +31 -63
- package/lib/sync/outbox.js +148 -232
- package/lib/sync/processors/errorMaps.d.ts +1 -1
- package/lib/sync/processors/errorMaps.js +30 -47
- package/lib/sync/processors/mutation.d.ts +2 -2
- package/lib/sync/processors/mutation.js +343 -502
- package/lib/sync/processors/subscription.d.ts +5 -2
- package/lib/sync/processors/subscription.js +283 -437
- package/lib/sync/processors/sync.d.ts +2 -2
- package/lib/sync/processors/sync.js +279 -404
- package/lib/sync/utils.d.ts +5 -4
- package/lib/sync/utils.js +267 -320
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +138 -140
- package/lib/types.js +17 -24
- package/lib/util.d.ts +9 -17
- package/lib/util.js +387 -511
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js +1 -2
- package/lib-esm/authModeStrategies/index.js +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +35 -52
- package/lib-esm/datastore/datastore.d.ts +4 -5
- package/lib-esm/datastore/datastore.js +888 -1247
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +6 -7
- package/lib-esm/predicates/index.js +53 -70
- package/lib-esm/predicates/next.d.ts +2 -2
- package/lib-esm/predicates/next.js +306 -459
- package/lib-esm/predicates/sort.js +23 -28
- package/lib-esm/ssr/index.js +1 -2
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +111 -338
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +212 -416
- package/lib-esm/storage/adapter/InMemoryStore.js +27 -52
- package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +438 -866
- package/lib-esm/storage/adapter/StorageAdapterBase.js +173 -325
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -6
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +1 -2
- package/lib-esm/storage/adapter/index.js +1 -1
- package/lib-esm/storage/relationship.js +173 -251
- package/lib-esm/storage/storage.d.ts +4 -4
- package/lib-esm/storage/storage.js +242 -424
- package/lib-esm/sync/datastoreConnectivity.d.ts +2 -2
- package/lib-esm/sync/datastoreConnectivity.js +28 -39
- package/lib-esm/sync/datastoreReachability/index.d.ts +1 -3
- package/lib-esm/sync/datastoreReachability/index.js +2 -3
- package/lib-esm/sync/datastoreReachability/index.native.d.ts +1 -3
- package/lib-esm/sync/datastoreReachability/index.native.js +3 -4
- package/lib-esm/sync/index.d.ts +2 -2
- package/lib-esm/sync/index.js +502 -812
- package/lib-esm/sync/merger.js +28 -61
- package/lib-esm/sync/outbox.js +143 -228
- package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
- package/lib-esm/sync/processors/errorMaps.js +32 -50
- package/lib-esm/sync/processors/mutation.d.ts +2 -2
- package/lib-esm/sync/processors/mutation.js +329 -490
- package/lib-esm/sync/processors/subscription.d.ts +5 -2
- package/lib-esm/sync/processors/subscription.js +266 -421
- package/lib-esm/sync/processors/sync.d.ts +2 -2
- package/lib-esm/sync/processors/sync.js +271 -397
- package/lib-esm/sync/utils.d.ts +5 -4
- package/lib-esm/sync/utils.js +252 -307
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types.d.ts +138 -140
- package/lib-esm/types.js +16 -25
- package/lib-esm/util.d.ts +9 -17
- package/lib-esm/util.js +335 -497
- package/package.json +31 -26
- package/src/authModeStrategies/multiAuthStrategy.ts +15 -12
- package/src/datastore/datastore.ts +36 -35
- package/src/predicates/sort.ts +3 -1
- package/src/storage/adapter/InMemoryStore.ts +1 -1
- package/src/storage/adapter/IndexedDBAdapter.ts +2 -2
- package/src/storage/adapter/StorageAdapterBase.ts +2 -2
- package/src/storage/adapter/getDefaultAdapter/index.ts +1 -4
- package/src/storage/storage.ts +29 -24
- package/src/sync/datastoreConnectivity.ts +6 -6
- package/src/sync/datastoreReachability/index.native.ts +5 -3
- package/src/sync/datastoreReachability/index.ts +1 -1
- package/src/sync/index.ts +79 -89
- package/src/sync/processors/errorMaps.ts +7 -7
- package/src/sync/processors/mutation.ts +19 -13
- package/src/sync/processors/subscription.ts +221 -295
- package/src/sync/processors/sync.ts +11 -8
- package/src/sync/utils.ts +30 -15
- package/src/types.ts +4 -8
- package/src/util.ts +46 -9
- package/lib/.tsbuildinfo +0 -3
- package/lib/authModeStrategies/defaultAuthStrategy.js.map +0 -1
- package/lib/authModeStrategies/index.js.map +0 -1
- package/lib/authModeStrategies/multiAuthStrategy.js.map +0 -1
- package/lib/datastore/datastore.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/predicates/index.js.map +0 -1
- package/lib/predicates/next.js.map +0 -1
- package/lib/predicates/sort.js.map +0 -1
- package/lib/ssr/index.js.map +0 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +0 -1
- package/lib/storage/adapter/AsyncStorageDatabase.js.map +0 -1
- package/lib/storage/adapter/InMemoryStore.js.map +0 -1
- package/lib/storage/adapter/InMemoryStore.native.js.map +0 -1
- package/lib/storage/adapter/IndexedDBAdapter.js.map +0 -1
- package/lib/storage/adapter/StorageAdapterBase.js.map +0 -1
- package/lib/storage/adapter/getDefaultAdapter/index.js.map +0 -1
- package/lib/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
- package/lib/storage/adapter/index.js.map +0 -1
- package/lib/storage/relationship.js.map +0 -1
- package/lib/storage/storage.js.map +0 -1
- package/lib/sync/datastoreConnectivity.js.map +0 -1
- package/lib/sync/datastoreReachability/index.js.map +0 -1
- package/lib/sync/datastoreReachability/index.native.js.map +0 -1
- package/lib/sync/index.js.map +0 -1
- package/lib/sync/merger.js.map +0 -1
- package/lib/sync/outbox.js.map +0 -1
- package/lib/sync/processors/errorMaps.js.map +0 -1
- package/lib/sync/processors/mutation.js.map +0 -1
- package/lib/sync/processors/subscription.js.map +0 -1
- package/lib/sync/processors/sync.js.map +0 -1
- package/lib/sync/utils.js.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/util.js.map +0 -1
- package/lib-esm/.tsbuildinfo +0 -3
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js.map +0 -1
- package/lib-esm/authModeStrategies/index.js.map +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js.map +0 -1
- package/lib-esm/datastore/datastore.js.map +0 -1
- package/lib-esm/index.js.map +0 -1
- package/lib-esm/predicates/index.js.map +0 -1
- package/lib-esm/predicates/next.js.map +0 -1
- package/lib-esm/predicates/sort.js.map +0 -1
- package/lib-esm/ssr/index.js.map +0 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +0 -1
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +0 -1
- package/lib-esm/storage/adapter/InMemoryStore.js.map +0 -1
- package/lib-esm/storage/adapter/InMemoryStore.native.js.map +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +0 -1
- package/lib-esm/storage/adapter/StorageAdapterBase.js.map +0 -1
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js.map +0 -1
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js.map +0 -1
- package/lib-esm/storage/adapter/index.js.map +0 -1
- package/lib-esm/storage/relationship.js.map +0 -1
- package/lib-esm/storage/storage.js.map +0 -1
- package/lib-esm/sync/datastoreConnectivity.js.map +0 -1
- package/lib-esm/sync/datastoreReachability/index.js.map +0 -1
- package/lib-esm/sync/datastoreReachability/index.native.js.map +0 -1
- package/lib-esm/sync/index.js.map +0 -1
- package/lib-esm/sync/merger.js.map +0 -1
- package/lib-esm/sync/outbox.js.map +0 -1
- package/lib-esm/sync/processors/errorMaps.js.map +0 -1
- package/lib-esm/sync/processors/mutation.js.map +0 -1
- package/lib-esm/sync/processors/subscription.js.map +0 -1
- package/lib-esm/sync/processors/sync.js.map +0 -1
- package/lib-esm/sync/utils.js.map +0 -1
- package/lib-esm/types.js.map +0 -1
- package/lib-esm/util.js.map +0 -1
package/lib/storage/storage.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
6
|
+
exports.ExclusiveStorage = void 0;
|
|
4
7
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
5
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
const rxjs_1 = require("rxjs");
|
|
10
|
+
const predicates_1 = require("../predicates");
|
|
11
|
+
const types_1 = require("../types");
|
|
12
|
+
const util_1 = require("../util");
|
|
13
|
+
const utils_1 = require("../sync/utils");
|
|
14
|
+
const getDefaultAdapter_1 = __importDefault(require("./adapter/getDefaultAdapter"));
|
|
15
|
+
const utils_2 = require("@aws-amplify/core/internals/utils");
|
|
16
|
+
const core_1 = require("@aws-amplify/core");
|
|
17
|
+
const logger = new core_1.ConsoleLogger('DataStore');
|
|
18
|
+
class StorageClass {
|
|
19
|
+
constructor(schema, namespaceResolver, getModelConstructorByModelName, modelInstanceCreator, adapter, sessionId) {
|
|
16
20
|
this.schema = schema;
|
|
17
21
|
this.namespaceResolver = namespaceResolver;
|
|
18
22
|
this.getModelConstructorByModelName = getModelConstructorByModelName;
|
|
19
23
|
this.modelInstanceCreator = modelInstanceCreator;
|
|
20
24
|
this.adapter = adapter;
|
|
21
25
|
this.sessionId = sessionId;
|
|
22
|
-
this.adapter = this.adapter || getDefaultAdapter_1.default();
|
|
23
|
-
this.pushStream = new
|
|
26
|
+
this.adapter = this.adapter || (0, getDefaultAdapter_1.default)();
|
|
27
|
+
this.pushStream = new rxjs_1.Subject();
|
|
24
28
|
}
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
static getNamespace() {
|
|
30
|
+
const namespace = {
|
|
27
31
|
name: util_1.STORAGE,
|
|
28
32
|
relationships: {},
|
|
29
33
|
enums: {},
|
|
@@ -31,371 +35,235 @@ var StorageClass = /** @class */ (function () {
|
|
|
31
35
|
nonModels: {},
|
|
32
36
|
};
|
|
33
37
|
return namespace;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
case 2:
|
|
47
|
-
logger.debug('Starting Storage');
|
|
48
|
-
this.initialized = new Promise(function (res, rej) {
|
|
49
|
-
resolve = res;
|
|
50
|
-
reject = rej;
|
|
51
|
-
});
|
|
52
|
-
this.adapter.setUp(this.schema, this.namespaceResolver, this.modelInstanceCreator, this.getModelConstructorByModelName, this.sessionId).then(resolve, reject);
|
|
53
|
-
return [4 /*yield*/, this.initialized];
|
|
54
|
-
case 3:
|
|
55
|
-
_a.sent();
|
|
56
|
-
return [2 /*return*/];
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
StorageClass.prototype.save = function (model, condition, mutator, patchesTuple) {
|
|
62
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
63
|
-
var result;
|
|
64
|
-
var _this = this;
|
|
65
|
-
return tslib_1.__generator(this, function (_a) {
|
|
66
|
-
switch (_a.label) {
|
|
67
|
-
case 0: return [4 /*yield*/, this.init()];
|
|
68
|
-
case 1:
|
|
69
|
-
_a.sent();
|
|
70
|
-
if (!this.adapter) {
|
|
71
|
-
throw new Error('Storage adapter is missing');
|
|
72
|
-
}
|
|
73
|
-
return [4 /*yield*/, this.adapter.save(model, condition)];
|
|
74
|
-
case 2:
|
|
75
|
-
result = _a.sent();
|
|
76
|
-
result.forEach(function (r) {
|
|
77
|
-
var _a = tslib_1.__read(r, 2), savedElement = _a[0], opType = _a[1];
|
|
78
|
-
// truthy when save is called by the Merger
|
|
79
|
-
var syncResponse = !!mutator;
|
|
80
|
-
var updateMutationInput;
|
|
81
|
-
// don't attempt to calc mutation input when storage.save
|
|
82
|
-
// is called by Merger, i.e., when processing an AppSync response
|
|
83
|
-
if ((opType === types_1.OpType.UPDATE || opType === types_1.OpType.INSERT) &&
|
|
84
|
-
!syncResponse) {
|
|
85
|
-
//
|
|
86
|
-
// TODO: LOOK!!!
|
|
87
|
-
// the `model` used here is in effect regardless of what model
|
|
88
|
-
// comes back from adapter.save().
|
|
89
|
-
// Prior to fix, SQLite adapter had been returning two models
|
|
90
|
-
// of different types, resulting in invalid outbox entries.
|
|
91
|
-
//
|
|
92
|
-
// the bug is essentially fixed in SQLite adapter.
|
|
93
|
-
// leaving as-is, because it's currently unclear whether anything
|
|
94
|
-
// depends on this remaining as-is.
|
|
95
|
-
//
|
|
96
|
-
updateMutationInput = _this.getChangedFieldsInput(model, savedElement, patchesTuple);
|
|
97
|
-
// // an update without changed user fields
|
|
98
|
-
// => don't create mutationEvent
|
|
99
|
-
if (updateMutationInput === null) {
|
|
100
|
-
return result;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
var element = updateMutationInput || savedElement;
|
|
104
|
-
var modelConstructor = Object.getPrototypeOf(savedElement)
|
|
105
|
-
.constructor;
|
|
106
|
-
_this.pushStream.next({
|
|
107
|
-
model: modelConstructor,
|
|
108
|
-
opType: opType,
|
|
109
|
-
element: element,
|
|
110
|
-
mutator: mutator,
|
|
111
|
-
condition: (condition &&
|
|
112
|
-
predicates_1.ModelPredicateCreator.getPredicates(condition, false)) ||
|
|
113
|
-
null,
|
|
114
|
-
savedElement: savedElement,
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
return [2 /*return*/, result];
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
StorageClass.prototype.delete = function (modelOrModelConstructor, condition, mutator) {
|
|
123
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
124
|
-
var models, deleted, modelConstructor, namespaceName, modelDefinition, modelIds;
|
|
125
|
-
var _a;
|
|
126
|
-
var _this = this;
|
|
127
|
-
return tslib_1.__generator(this, function (_b) {
|
|
128
|
-
switch (_b.label) {
|
|
129
|
-
case 0: return [4 /*yield*/, this.init()];
|
|
130
|
-
case 1:
|
|
131
|
-
_b.sent();
|
|
132
|
-
if (!this.adapter) {
|
|
133
|
-
throw new Error('Storage adapter is missing');
|
|
134
|
-
}
|
|
135
|
-
return [4 /*yield*/, this.adapter.delete(modelOrModelConstructor, condition)];
|
|
136
|
-
case 2:
|
|
137
|
-
_a = tslib_1.__read.apply(void 0, [_b.sent(), 2]), models = _a[0], deleted = _a[1];
|
|
138
|
-
modelConstructor = util_1.isModelConstructor(modelOrModelConstructor)
|
|
139
|
-
? modelOrModelConstructor
|
|
140
|
-
: Object.getPrototypeOf(modelOrModelConstructor || {})
|
|
141
|
-
.constructor;
|
|
142
|
-
namespaceName = this.namespaceResolver(modelConstructor);
|
|
143
|
-
modelDefinition = this.schema.namespaces[namespaceName].models[modelConstructor.name];
|
|
144
|
-
modelIds = new Set(models.map(function (model) {
|
|
145
|
-
var modelId = utils_1.getIdentifierValue(modelDefinition, model);
|
|
146
|
-
return modelId;
|
|
147
|
-
}));
|
|
148
|
-
if (!util_1.isModelConstructor(modelOrModelConstructor) &&
|
|
149
|
-
!Array.isArray(deleted)) {
|
|
150
|
-
deleted = [deleted];
|
|
151
|
-
}
|
|
152
|
-
deleted.forEach(function (model) {
|
|
153
|
-
var modelConstructor = Object.getPrototypeOf(model)
|
|
154
|
-
.constructor;
|
|
155
|
-
var theCondition;
|
|
156
|
-
if (!util_1.isModelConstructor(modelOrModelConstructor)) {
|
|
157
|
-
var modelId = utils_1.getIdentifierValue(modelDefinition, model);
|
|
158
|
-
theCondition = modelIds.has(modelId)
|
|
159
|
-
? predicates_1.ModelPredicateCreator.getPredicates(condition, false)
|
|
160
|
-
: undefined;
|
|
161
|
-
}
|
|
162
|
-
_this.pushStream.next({
|
|
163
|
-
model: modelConstructor,
|
|
164
|
-
opType: types_1.OpType.DELETE,
|
|
165
|
-
element: model,
|
|
166
|
-
mutator: mutator,
|
|
167
|
-
condition: theCondition || null,
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
return [2 /*return*/, [models, deleted]];
|
|
171
|
-
}
|
|
172
|
-
});
|
|
38
|
+
}
|
|
39
|
+
async init() {
|
|
40
|
+
if (this.initialized !== undefined) {
|
|
41
|
+
await this.initialized;
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
logger.debug('Starting Storage');
|
|
45
|
+
let resolve;
|
|
46
|
+
let reject;
|
|
47
|
+
this.initialized = new Promise((res, rej) => {
|
|
48
|
+
resolve = res;
|
|
49
|
+
reject = rej;
|
|
173
50
|
});
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
51
|
+
this.adapter.setUp(this.schema, this.namespaceResolver, this.modelInstanceCreator, this.getModelConstructorByModelName, this.sessionId).then(resolve, reject);
|
|
52
|
+
await this.initialized;
|
|
53
|
+
}
|
|
54
|
+
async save(model, condition, mutator, patchesTuple) {
|
|
55
|
+
await this.init();
|
|
56
|
+
if (!this.adapter) {
|
|
57
|
+
throw new Error('Storage adapter is missing');
|
|
58
|
+
}
|
|
59
|
+
const result = await this.adapter.save(model, condition);
|
|
60
|
+
result.forEach(r => {
|
|
61
|
+
const [savedElement, opType] = r;
|
|
62
|
+
// truthy when save is called by the Merger
|
|
63
|
+
const syncResponse = !!mutator;
|
|
64
|
+
let updateMutationInput;
|
|
65
|
+
// don't attempt to calc mutation input when storage.save
|
|
66
|
+
// is called by Merger, i.e., when processing an AppSync response
|
|
67
|
+
if ((opType === types_1.OpType.UPDATE || opType === types_1.OpType.INSERT) &&
|
|
68
|
+
!syncResponse) {
|
|
69
|
+
//
|
|
70
|
+
// TODO: LOOK!!!
|
|
71
|
+
// the `model` used here is in effect regardless of what model
|
|
72
|
+
// comes back from adapter.save().
|
|
73
|
+
// Prior to fix, SQLite adapter had been returning two models
|
|
74
|
+
// of different types, resulting in invalid outbox entries.
|
|
75
|
+
//
|
|
76
|
+
// the bug is essentially fixed in SQLite adapter.
|
|
77
|
+
// leaving as-is, because it's currently unclear whether anything
|
|
78
|
+
// depends on this remaining as-is.
|
|
79
|
+
//
|
|
80
|
+
updateMutationInput = this.getChangedFieldsInput(model, savedElement, patchesTuple);
|
|
81
|
+
// // an update without changed user fields
|
|
82
|
+
// => don't create mutationEvent
|
|
83
|
+
if (updateMutationInput === null) {
|
|
84
|
+
return result;
|
|
187
85
|
}
|
|
86
|
+
}
|
|
87
|
+
const element = updateMutationInput || savedElement;
|
|
88
|
+
const modelConstructor = Object.getPrototypeOf(savedElement)
|
|
89
|
+
.constructor;
|
|
90
|
+
this.pushStream.next({
|
|
91
|
+
model: modelConstructor,
|
|
92
|
+
opType,
|
|
93
|
+
element,
|
|
94
|
+
mutator,
|
|
95
|
+
condition: (condition &&
|
|
96
|
+
predicates_1.ModelPredicateCreator.getPredicates(condition, false)) ||
|
|
97
|
+
null,
|
|
98
|
+
savedElement,
|
|
188
99
|
});
|
|
189
100
|
});
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
async delete(modelOrModelConstructor, condition, mutator) {
|
|
104
|
+
await this.init();
|
|
105
|
+
if (!this.adapter) {
|
|
106
|
+
throw new Error('Storage adapter is missing');
|
|
107
|
+
}
|
|
108
|
+
let models;
|
|
109
|
+
let deleted;
|
|
110
|
+
[models, deleted] = await this.adapter.delete(modelOrModelConstructor, condition);
|
|
111
|
+
const modelConstructor = (0, util_1.isModelConstructor)(modelOrModelConstructor)
|
|
112
|
+
? modelOrModelConstructor
|
|
113
|
+
: Object.getPrototypeOf(modelOrModelConstructor || {})
|
|
114
|
+
.constructor;
|
|
115
|
+
const namespaceName = this.namespaceResolver(modelConstructor);
|
|
116
|
+
const modelDefinition = this.schema.namespaces[namespaceName].models[modelConstructor.name];
|
|
117
|
+
const modelIds = new Set(models.map(model => {
|
|
118
|
+
const modelId = (0, utils_1.getIdentifierValue)(modelDefinition, model);
|
|
119
|
+
return modelId;
|
|
120
|
+
}));
|
|
121
|
+
if (!(0, util_1.isModelConstructor)(modelOrModelConstructor) &&
|
|
122
|
+
!Array.isArray(deleted)) {
|
|
123
|
+
deleted = [deleted];
|
|
124
|
+
}
|
|
125
|
+
deleted.forEach(model => {
|
|
126
|
+
const modelConstructor = Object.getPrototypeOf(model)
|
|
127
|
+
.constructor;
|
|
128
|
+
let theCondition;
|
|
129
|
+
if (!(0, util_1.isModelConstructor)(modelOrModelConstructor)) {
|
|
130
|
+
const modelId = (0, utils_1.getIdentifierValue)(modelDefinition, model);
|
|
131
|
+
theCondition = modelIds.has(modelId)
|
|
132
|
+
? predicates_1.ModelPredicateCreator.getPredicates(condition, false)
|
|
133
|
+
: undefined;
|
|
134
|
+
}
|
|
135
|
+
this.pushStream.next({
|
|
136
|
+
model: modelConstructor,
|
|
137
|
+
opType: types_1.OpType.DELETE,
|
|
138
|
+
element: model,
|
|
139
|
+
mutator,
|
|
140
|
+
condition: theCondition || null,
|
|
205
141
|
});
|
|
206
142
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
143
|
+
return [models, deleted];
|
|
144
|
+
}
|
|
145
|
+
async query(modelConstructor, predicate, pagination) {
|
|
146
|
+
await this.init();
|
|
147
|
+
if (!this.adapter) {
|
|
148
|
+
throw new Error('Storage adapter is missing');
|
|
149
|
+
}
|
|
150
|
+
return await this.adapter.query(modelConstructor, predicate, pagination);
|
|
151
|
+
}
|
|
152
|
+
async queryOne(modelConstructor, firstOrLast = types_1.QueryOne.FIRST) {
|
|
153
|
+
await this.init();
|
|
154
|
+
if (!this.adapter) {
|
|
155
|
+
throw new Error('Storage adapter is missing');
|
|
156
|
+
}
|
|
157
|
+
return await this.adapter.queryOne(modelConstructor, firstOrLast);
|
|
158
|
+
}
|
|
159
|
+
observe(modelConstructor, predicate, skipOwn) {
|
|
160
|
+
const listenToAll = !modelConstructor;
|
|
161
|
+
const { predicates, type } = (predicate && predicates_1.ModelPredicateCreator.getPredicates(predicate, false)) ||
|
|
162
|
+
{};
|
|
163
|
+
let result = this.pushStream
|
|
164
|
+
.pipe((0, rxjs_1.filter)(({ mutator }) => {
|
|
215
165
|
return !skipOwn || mutator !== skipOwn;
|
|
216
|
-
})
|
|
217
|
-
.map(
|
|
218
|
-
var _mutator = _a.mutator, message = tslib_1.__rest(_a, ["mutator"]);
|
|
219
|
-
return message;
|
|
220
|
-
});
|
|
166
|
+
}))
|
|
167
|
+
.pipe((0, rxjs_1.map)(({ mutator: _mutator, ...message }) => message));
|
|
221
168
|
if (!listenToAll) {
|
|
222
|
-
result = result.filter(
|
|
223
|
-
var model = _a.model, element = _a.element;
|
|
169
|
+
result = result.pipe((0, rxjs_1.filter)(({ model, element }) => {
|
|
224
170
|
if (modelConstructor !== model) {
|
|
225
171
|
return false;
|
|
226
172
|
}
|
|
227
173
|
if (!!predicates && !!type) {
|
|
228
|
-
return util_1.validatePredicate(element, type, predicates);
|
|
174
|
+
return (0, util_1.validatePredicate)(element, type, predicates);
|
|
229
175
|
}
|
|
230
176
|
return true;
|
|
231
|
-
});
|
|
177
|
+
}));
|
|
232
178
|
}
|
|
233
179
|
return result;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
var result;
|
|
259
|
-
var _this = this;
|
|
260
|
-
return tslib_1.__generator(this, function (_a) {
|
|
261
|
-
switch (_a.label) {
|
|
262
|
-
case 0: return [4 /*yield*/, this.init()];
|
|
263
|
-
case 1:
|
|
264
|
-
_a.sent();
|
|
265
|
-
if (!this.adapter) {
|
|
266
|
-
throw new Error('Storage adapter is missing');
|
|
267
|
-
}
|
|
268
|
-
return [4 /*yield*/, this.adapter.batchSave(modelConstructor, items)];
|
|
269
|
-
case 2:
|
|
270
|
-
result = _a.sent();
|
|
271
|
-
result.forEach(function (_a) {
|
|
272
|
-
var _b = tslib_1.__read(_a, 2), element = _b[0], opType = _b[1];
|
|
273
|
-
_this.pushStream.next({
|
|
274
|
-
model: modelConstructor,
|
|
275
|
-
opType: opType,
|
|
276
|
-
element: element,
|
|
277
|
-
mutator: mutator,
|
|
278
|
-
condition: null,
|
|
279
|
-
});
|
|
280
|
-
});
|
|
281
|
-
return [2 /*return*/, result];
|
|
282
|
-
}
|
|
180
|
+
}
|
|
181
|
+
async clear(completeObservable = true) {
|
|
182
|
+
this.initialized = undefined;
|
|
183
|
+
if (!this.adapter) {
|
|
184
|
+
throw new Error('Storage adapter is missing');
|
|
185
|
+
}
|
|
186
|
+
await this.adapter.clear();
|
|
187
|
+
if (completeObservable) {
|
|
188
|
+
this.pushStream.complete();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async batchSave(modelConstructor, items, mutator) {
|
|
192
|
+
await this.init();
|
|
193
|
+
if (!this.adapter) {
|
|
194
|
+
throw new Error('Storage adapter is missing');
|
|
195
|
+
}
|
|
196
|
+
const result = await this.adapter.batchSave(modelConstructor, items);
|
|
197
|
+
result.forEach(([element, opType]) => {
|
|
198
|
+
this.pushStream.next({
|
|
199
|
+
model: modelConstructor,
|
|
200
|
+
opType,
|
|
201
|
+
element,
|
|
202
|
+
mutator,
|
|
203
|
+
condition: null,
|
|
283
204
|
});
|
|
284
205
|
});
|
|
285
|
-
|
|
206
|
+
return result;
|
|
207
|
+
}
|
|
286
208
|
// returns null if no user fields were changed (determined by value comparison)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
var _b;
|
|
290
|
-
var containsPatches = patchesTuple && patchesTuple.length;
|
|
209
|
+
getChangedFieldsInput(model, originalElement, patchesTuple) {
|
|
210
|
+
const containsPatches = patchesTuple && patchesTuple.length;
|
|
291
211
|
if (!containsPatches) {
|
|
292
212
|
return null;
|
|
293
213
|
}
|
|
294
|
-
|
|
295
|
-
|
|
214
|
+
const [patches, source] = patchesTuple;
|
|
215
|
+
const updatedElement = {};
|
|
296
216
|
// extract array of updated fields from patches
|
|
297
|
-
|
|
217
|
+
const updatedFields = (patches.map(patch => patch.path && patch.path[0]));
|
|
298
218
|
// check model def for association and replace with targetName if exists
|
|
299
|
-
|
|
219
|
+
const modelConstructor = Object.getPrototypeOf(model)
|
|
300
220
|
.constructor;
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
221
|
+
const namespace = this.namespaceResolver(modelConstructor);
|
|
222
|
+
const { fields } = this.schema.namespaces[namespace].models[modelConstructor.name];
|
|
223
|
+
const { primaryKey, compositeKeys = [] } = this.schema.namespaces[namespace].keys?.[modelConstructor.name] || {};
|
|
304
224
|
// set original values for these fields
|
|
305
|
-
updatedFields.forEach(
|
|
306
|
-
|
|
307
|
-
var _f;
|
|
308
|
-
var targetNames = types_1.isTargetNameAssociation((_f = fields[field]) === null || _f === void 0 ? void 0 : _f.association);
|
|
225
|
+
updatedFields.forEach((field) => {
|
|
226
|
+
const targetNames = (0, types_1.isTargetNameAssociation)(fields[field]?.association);
|
|
309
227
|
if (Array.isArray(targetNames)) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
//
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
originalElement[targetName]
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
for (
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (fieldSet.has(targetName)) {
|
|
326
|
-
try {
|
|
327
|
-
for (var fieldSet_1 = (e_4 = void 0, tslib_1.__values(fieldSet)), fieldSet_1_1 = fieldSet_1.next(); !fieldSet_1_1.done; fieldSet_1_1 = fieldSet_1.next()) {
|
|
328
|
-
var compositeField = fieldSet_1_1.value;
|
|
329
|
-
updatedElement[compositeField] =
|
|
330
|
-
originalElement[compositeField];
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
334
|
-
finally {
|
|
335
|
-
try {
|
|
336
|
-
if (fieldSet_1_1 && !fieldSet_1_1.done && (_c = fieldSet_1.return)) _c.call(fieldSet_1);
|
|
337
|
-
}
|
|
338
|
-
finally { if (e_4) throw e_4.error; }
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
344
|
-
finally {
|
|
345
|
-
try {
|
|
346
|
-
if (compositeKeys_1_1 && !compositeKeys_1_1.done && (_b = compositeKeys_1.return)) _b.call(compositeKeys_1);
|
|
228
|
+
// if field refers to a belongsTo relation, use the target field instead
|
|
229
|
+
for (const targetName of targetNames) {
|
|
230
|
+
// check field values by value. Ignore unchanged fields
|
|
231
|
+
if (!(0, util_1.valuesEqual)(source[targetName], originalElement[targetName])) {
|
|
232
|
+
// if the field was updated to 'undefined', replace with 'null' for compatibility with JSON and GraphQL
|
|
233
|
+
updatedElement[targetName] =
|
|
234
|
+
originalElement[targetName] === undefined
|
|
235
|
+
? null
|
|
236
|
+
: originalElement[targetName];
|
|
237
|
+
for (const fieldSet of compositeKeys) {
|
|
238
|
+
// include all of the fields that comprise the composite key
|
|
239
|
+
if (fieldSet.has(targetName)) {
|
|
240
|
+
for (const compositeField of fieldSet) {
|
|
241
|
+
updatedElement[compositeField] =
|
|
242
|
+
originalElement[compositeField];
|
|
347
243
|
}
|
|
348
|
-
finally { if (e_3) throw e_3.error; }
|
|
349
244
|
}
|
|
350
245
|
}
|
|
351
246
|
}
|
|
352
247
|
}
|
|
353
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
354
|
-
finally {
|
|
355
|
-
try {
|
|
356
|
-
if (targetNames_1_1 && !targetNames_1_1.done && (_a = targetNames_1.return)) _a.call(targetNames_1);
|
|
357
|
-
}
|
|
358
|
-
finally { if (e_2) throw e_2.error; }
|
|
359
|
-
}
|
|
360
248
|
}
|
|
361
249
|
else {
|
|
362
250
|
// Backwards compatibility pre-CPK
|
|
363
251
|
// if field refers to a belongsTo relation, use the target field instead
|
|
364
|
-
|
|
252
|
+
const key = targetNames || field;
|
|
365
253
|
// check field values by value. Ignore unchanged fields
|
|
366
|
-
if (!util_1.valuesEqual(source[key], originalElement[key])) {
|
|
254
|
+
if (!(0, util_1.valuesEqual)(source[key], originalElement[key])) {
|
|
367
255
|
// if the field was updated to 'undefined', replace with 'null' for compatibility with JSON and GraphQL
|
|
368
256
|
updatedElement[key] =
|
|
369
257
|
originalElement[key] === undefined ? null : originalElement[key];
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
for (var fieldSet_2 = (e_6 = void 0, tslib_1.__values(fieldSet)), fieldSet_2_1 = fieldSet_2.next(); !fieldSet_2_1.done; fieldSet_2_1 = fieldSet_2.next()) {
|
|
377
|
-
var compositeField = fieldSet_2_1.value;
|
|
378
|
-
updatedElement[compositeField] =
|
|
379
|
-
originalElement[compositeField];
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
383
|
-
finally {
|
|
384
|
-
try {
|
|
385
|
-
if (fieldSet_2_1 && !fieldSet_2_1.done && (_e = fieldSet_2.return)) _e.call(fieldSet_2);
|
|
386
|
-
}
|
|
387
|
-
finally { if (e_6) throw e_6.error; }
|
|
388
|
-
}
|
|
258
|
+
for (const fieldSet of compositeKeys) {
|
|
259
|
+
// include all of the fields that comprise the composite key
|
|
260
|
+
if (fieldSet.has(key)) {
|
|
261
|
+
for (const compositeField of fieldSet) {
|
|
262
|
+
updatedElement[compositeField] =
|
|
263
|
+
originalElement[compositeField];
|
|
389
264
|
}
|
|
390
265
|
}
|
|
391
266
|
}
|
|
392
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
393
|
-
finally {
|
|
394
|
-
try {
|
|
395
|
-
if (compositeKeys_2_1 && !compositeKeys_2_1.done && (_d = compositeKeys_2.return)) _d.call(compositeKeys_2);
|
|
396
|
-
}
|
|
397
|
-
finally { if (e_5) throw e_5.error; }
|
|
398
|
-
}
|
|
399
267
|
}
|
|
400
268
|
}
|
|
401
269
|
});
|
|
@@ -405,111 +273,65 @@ var StorageClass = /** @class */ (function () {
|
|
|
405
273
|
}
|
|
406
274
|
// include field(s) from custom PK if one is specified for the model
|
|
407
275
|
if (primaryKey && primaryKey.length) {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
var pkField = primaryKey_1_1.value;
|
|
411
|
-
updatedElement[pkField] = originalElement[pkField];
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
415
|
-
finally {
|
|
416
|
-
try {
|
|
417
|
-
if (primaryKey_1_1 && !primaryKey_1_1.done && (_a = primaryKey_1.return)) _a.call(primaryKey_1);
|
|
418
|
-
}
|
|
419
|
-
finally { if (e_1) throw e_1.error; }
|
|
276
|
+
for (const pkField of primaryKey) {
|
|
277
|
+
updatedElement[pkField] = originalElement[pkField];
|
|
420
278
|
}
|
|
421
279
|
}
|
|
422
|
-
|
|
280
|
+
const { id, _version, _lastChangedAt, _deleted } = originalElement;
|
|
423
281
|
// For update mutations we only want to send fields with changes
|
|
424
282
|
// and the required internal fields
|
|
425
|
-
return
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
283
|
+
return {
|
|
284
|
+
...updatedElement,
|
|
285
|
+
id,
|
|
286
|
+
_version,
|
|
287
|
+
_lastChangedAt,
|
|
288
|
+
_deleted,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
class ExclusiveStorage {
|
|
293
|
+
constructor(schema, namespaceResolver, getModelConstructorByModelName, modelInstanceCreator, adapter, sessionId) {
|
|
294
|
+
this.mutex = new utils_2.Mutex();
|
|
435
295
|
this.storage = new StorageClass(schema, namespaceResolver, getModelConstructorByModelName, modelInstanceCreator, adapter, sessionId);
|
|
436
296
|
}
|
|
437
|
-
|
|
297
|
+
runExclusive(fn) {
|
|
438
298
|
return this.mutex.runExclusive(fn.bind(this, this.storage));
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
return
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
if (util_1.isModelConstructor(modelOrModelConstructor)) {
|
|
454
|
-
var modelConstructor = modelOrModelConstructor;
|
|
455
|
-
return storage.delete(modelConstructor, condition, mutator);
|
|
456
|
-
}
|
|
457
|
-
else {
|
|
458
|
-
var model = modelOrModelConstructor;
|
|
459
|
-
return storage.delete(model, condition, mutator);
|
|
460
|
-
}
|
|
461
|
-
})];
|
|
462
|
-
});
|
|
463
|
-
});
|
|
464
|
-
};
|
|
465
|
-
ExclusiveStorage.prototype.query = function (modelConstructor, predicate, pagination) {
|
|
466
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
467
|
-
return tslib_1.__generator(this, function (_a) {
|
|
468
|
-
return [2 /*return*/, this.runExclusive(function (storage) {
|
|
469
|
-
return storage.query(modelConstructor, predicate, pagination);
|
|
470
|
-
})];
|
|
471
|
-
});
|
|
472
|
-
});
|
|
473
|
-
};
|
|
474
|
-
ExclusiveStorage.prototype.queryOne = function (modelConstructor, firstOrLast) {
|
|
475
|
-
if (firstOrLast === void 0) { firstOrLast = types_1.QueryOne.FIRST; }
|
|
476
|
-
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
477
|
-
return tslib_1.__generator(this, function (_a) {
|
|
478
|
-
return [2 /*return*/, this.runExclusive(function (storage) {
|
|
479
|
-
return storage.queryOne(modelConstructor, firstOrLast);
|
|
480
|
-
})];
|
|
481
|
-
});
|
|
299
|
+
}
|
|
300
|
+
async save(model, condition, mutator, patchesTuple) {
|
|
301
|
+
return this.runExclusive(storage => storage.save(model, condition, mutator, patchesTuple));
|
|
302
|
+
}
|
|
303
|
+
async delete(modelOrModelConstructor, condition, mutator) {
|
|
304
|
+
return this.runExclusive(storage => {
|
|
305
|
+
if ((0, util_1.isModelConstructor)(modelOrModelConstructor)) {
|
|
306
|
+
const modelConstructor = modelOrModelConstructor;
|
|
307
|
+
return storage.delete(modelConstructor, condition, mutator);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
const model = modelOrModelConstructor;
|
|
311
|
+
return storage.delete(model, condition, mutator);
|
|
312
|
+
}
|
|
482
313
|
});
|
|
483
|
-
}
|
|
484
|
-
|
|
314
|
+
}
|
|
315
|
+
async query(modelConstructor, predicate, pagination) {
|
|
316
|
+
return this.runExclusive(storage => storage.query(modelConstructor, predicate, pagination));
|
|
317
|
+
}
|
|
318
|
+
async queryOne(modelConstructor, firstOrLast = types_1.QueryOne.FIRST) {
|
|
319
|
+
return this.runExclusive(storage => storage.queryOne(modelConstructor, firstOrLast));
|
|
320
|
+
}
|
|
321
|
+
static getNamespace() {
|
|
485
322
|
return StorageClass.getNamespace();
|
|
486
|
-
}
|
|
487
|
-
|
|
323
|
+
}
|
|
324
|
+
observe(modelConstructor, predicate, skipOwn) {
|
|
488
325
|
return this.storage.observe(modelConstructor, predicate, skipOwn);
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
case 0: return [4 /*yield*/, this.runExclusive(function (storage) { return storage.clear(); })];
|
|
495
|
-
case 1:
|
|
496
|
-
_a.sent();
|
|
497
|
-
return [2 /*return*/];
|
|
498
|
-
}
|
|
499
|
-
});
|
|
500
|
-
});
|
|
501
|
-
};
|
|
502
|
-
ExclusiveStorage.prototype.batchSave = function (modelConstructor, items) {
|
|
326
|
+
}
|
|
327
|
+
async clear() {
|
|
328
|
+
await this.runExclusive(storage => storage.clear());
|
|
329
|
+
}
|
|
330
|
+
batchSave(modelConstructor, items) {
|
|
503
331
|
return this.storage.batchSave(modelConstructor, items);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
return
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
};
|
|
512
|
-
return ExclusiveStorage;
|
|
513
|
-
}());
|
|
332
|
+
}
|
|
333
|
+
async init() {
|
|
334
|
+
return this.storage.init();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
514
337
|
exports.ExclusiveStorage = ExclusiveStorage;
|
|
515
|
-
//# sourceMappingURL=storage.js.map
|