@aws-amplify/datastore 4.7.5 → 5.0.1-console-preview.4208d73.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 +81 -24
- package/lib/datastore/datastore.d.ts +3 -4
- package/lib/datastore/datastore.js +361 -227
- package/lib/index.d.ts +1 -1
- package/lib/index.js +25 -12
- package/lib/predicates/index.js +46 -12
- package/lib/predicates/next.d.ts +2 -2
- package/lib/predicates/next.js +172 -74
- package/lib/predicates/sort.js +3 -4
- package/lib/ssr/index.js +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js +240 -128
- package/lib/storage/adapter/AsyncStorageDatabase.js +100 -39
- package/lib/storage/adapter/InMemoryStore.js +68 -17
- package/lib/storage/adapter/InMemoryStore.native.js +5 -3
- package/lib/storage/adapter/IndexedDBAdapter.js +355 -199
- package/lib/storage/adapter/StorageAdapterBase.js +154 -85
- package/lib/storage/adapter/getDefaultAdapter/index.js +8 -9
- package/lib/storage/adapter/getDefaultAdapter/index.native.js +4 -3
- package/lib/storage/adapter/index.js +0 -1
- package/lib/storage/relationship.js +31 -21
- package/lib/storage/storage.d.ts +3 -3
- package/lib/storage/storage.js +143 -61
- package/lib/sync/datastoreConnectivity.d.ts +1 -1
- package/lib/sync/datastoreConnectivity.js +57 -9
- package/lib/sync/datastoreReachability/index.js +3 -3
- package/lib/sync/datastoreReachability/index.native.js +7 -5
- package/lib/sync/index.d.ts +1 -1
- package/lib/sync/index.js +193 -125
- package/lib/sync/merger.js +81 -10
- package/lib/sync/outbox.js +101 -30
- package/lib/sync/processors/errorMaps.d.ts +1 -1
- package/lib/sync/processors/errorMaps.js +41 -6
- package/lib/sync/processors/mutation.d.ts +1 -1
- package/lib/sync/processors/mutation.js +192 -101
- package/lib/sync/processors/subscription.d.ts +4 -1
- package/lib/sync/processors/subscription.js +190 -178
- package/lib/sync/processors/sync.d.ts +1 -1
- package/lib/sync/processors/sync.js +113 -47
- package/lib/sync/utils.d.ts +4 -4
- package/lib/sync/utils.js +162 -81
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/types.d.ts +138 -140
- package/lib/types.js +40 -5
- package/lib/util.d.ts +9 -17
- package/lib/util.js +216 -100
- package/lib-esm/authModeStrategies/defaultAuthStrategy.js +0 -1
- package/lib-esm/authModeStrategies/index.js +0 -1
- package/lib-esm/authModeStrategies/multiAuthStrategy.js +76 -21
- package/lib-esm/datastore/datastore.d.ts +3 -4
- package/lib-esm/datastore/datastore.js +206 -77
- package/lib-esm/index.d.ts +1 -1
- package/lib-esm/index.js +0 -1
- package/lib-esm/predicates/index.js +40 -7
- package/lib-esm/predicates/next.d.ts +2 -2
- package/lib-esm/predicates/next.js +148 -52
- package/lib-esm/predicates/sort.js +2 -4
- package/lib-esm/ssr/index.js +0 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +203 -95
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +66 -5
- package/lib-esm/storage/adapter/InMemoryStore.js +52 -2
- package/lib-esm/storage/adapter/InMemoryStore.native.js +0 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +271 -138
- package/lib-esm/storage/adapter/StorageAdapterBase.js +130 -62
- package/lib-esm/storage/adapter/getDefaultAdapter/index.js +2 -5
- package/lib-esm/storage/adapter/getDefaultAdapter/index.native.js +0 -1
- package/lib-esm/storage/adapter/index.js +1 -1
- package/lib-esm/storage/relationship.js +27 -18
- package/lib-esm/storage/storage.d.ts +3 -3
- package/lib-esm/storage/storage.js +87 -9
- package/lib-esm/sync/datastoreConnectivity.d.ts +1 -1
- package/lib-esm/sync/datastoreConnectivity.js +48 -3
- package/lib-esm/sync/datastoreReachability/index.js +1 -2
- package/lib-esm/sync/datastoreReachability/index.native.js +1 -2
- package/lib-esm/sync/index.d.ts +1 -1
- package/lib-esm/sync/index.js +136 -72
- package/lib-esm/sync/merger.js +73 -3
- package/lib-esm/sync/outbox.js +75 -5
- package/lib-esm/sync/processors/errorMaps.d.ts +1 -1
- package/lib-esm/sync/processors/errorMaps.js +39 -5
- package/lib-esm/sync/processors/mutation.d.ts +1 -1
- package/lib-esm/sync/processors/mutation.js +130 -44
- package/lib-esm/sync/processors/subscription.d.ts +4 -1
- package/lib-esm/sync/processors/subscription.js +134 -126
- package/lib-esm/sync/processors/sync.d.ts +1 -1
- package/lib-esm/sync/processors/sync.js +74 -12
- package/lib-esm/sync/utils.d.ts +4 -4
- package/lib-esm/sync/utils.js +135 -55
- package/lib-esm/tsconfig.tsbuildinfo +1 -0
- package/lib-esm/types.d.ts +138 -140
- package/lib-esm/types.js +36 -2
- package/lib-esm/util.d.ts +9 -17
- package/lib-esm/util.js +96 -16
- package/package.json +139 -132
- package/src/authModeStrategies/multiAuthStrategy.ts +11 -12
- package/src/datastore/datastore.ts +32 -25
- package/src/predicates/sort.ts +3 -1
- package/src/storage/adapter/InMemoryStore.ts +1 -1
- package/src/storage/adapter/IndexedDBAdapter.ts +1 -1
- package/src/storage/adapter/StorageAdapterBase.ts +1 -1
- package/src/storage/adapter/getDefaultAdapter/index.ts +2 -3
- package/src/storage/storage.ts +1 -1
- package/src/sync/datastoreConnectivity.ts +2 -2
- package/src/sync/datastoreReachability/index.native.ts +1 -1
- package/src/sync/datastoreReachability/index.ts +1 -1
- package/src/sync/index.ts +69 -78
- package/src/sync/processors/mutation.ts +16 -10
- package/src/sync/processors/subscription.ts +55 -127
- package/src/sync/processors/sync.ts +8 -4
- package/src/sync/utils.ts +7 -8
- package/src/types.ts +4 -8
- package/src/util.ts +5 -6
- 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
|
@@ -1,4 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
53
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
54
|
+
var m = o[Symbol.asyncIterator], i;
|
|
55
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
56
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
57
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
58
|
+
};
|
|
59
|
+
var __values = (this && this.__values) || function(o) {
|
|
60
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
61
|
+
if (m) return m.call(o);
|
|
62
|
+
if (o && typeof o.length === "number") return {
|
|
63
|
+
next: function () {
|
|
64
|
+
if (o && i >= o.length) o = void 0;
|
|
65
|
+
return { value: o && o[i++], done: !o };
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
69
|
+
};
|
|
2
70
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
71
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
72
|
import AsyncStorageDatabase from './AsyncStorageDatabase';
|
|
@@ -119,59 +187,82 @@ var AsyncStorageAdapter = /** @class */ (function (_super) {
|
|
|
119
187
|
});
|
|
120
188
|
};
|
|
121
189
|
AsyncStorageAdapter.prototype.save = function (model, condition) {
|
|
122
|
-
var e_2,
|
|
190
|
+
var _a, e_2, _b, _c;
|
|
123
191
|
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
-
var
|
|
125
|
-
return __generator(this, function (
|
|
126
|
-
switch (
|
|
192
|
+
var _d, storeName, connectionStoreNames, modelKeyValues, fromDB, result, _loop_2, this_2, _e, connectionStoreNames_1, connectionStoreNames_1_1, e_2_1;
|
|
193
|
+
return __generator(this, function (_f) {
|
|
194
|
+
switch (_f.label) {
|
|
127
195
|
case 0:
|
|
128
|
-
|
|
196
|
+
_d = this.saveMetadata(model), storeName = _d.storeName, connectionStoreNames = _d.connectionStoreNames, modelKeyValues = _d.modelKeyValues;
|
|
129
197
|
return [4 /*yield*/, this._get(storeName, modelKeyValues)];
|
|
130
198
|
case 1:
|
|
131
|
-
fromDB =
|
|
199
|
+
fromDB = _f.sent();
|
|
132
200
|
this.validateSaveCondition(condition, fromDB);
|
|
133
201
|
result = [];
|
|
134
|
-
|
|
202
|
+
_f.label = 2;
|
|
135
203
|
case 2:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
204
|
+
_f.trys.push([2, 8, 9, 14]);
|
|
205
|
+
_loop_2 = function () {
|
|
206
|
+
var resItem, storeName_1, item, instance, keys, itemKeyValues, fromDB_1, opType;
|
|
207
|
+
return __generator(this, function (_g) {
|
|
208
|
+
switch (_g.label) {
|
|
209
|
+
case 0:
|
|
210
|
+
_c = connectionStoreNames_1_1.value;
|
|
211
|
+
_e = false;
|
|
212
|
+
_g.label = 1;
|
|
213
|
+
case 1:
|
|
214
|
+
_g.trys.push([1, , 5, 6]);
|
|
215
|
+
resItem = _c;
|
|
216
|
+
storeName_1 = resItem.storeName, item = resItem.item, instance = resItem.instance, keys = resItem.keys;
|
|
217
|
+
itemKeyValues = keys.map(function (key) { return item[key]; });
|
|
218
|
+
return [4 /*yield*/, this_2._get(storeName_1, itemKeyValues)];
|
|
219
|
+
case 2:
|
|
220
|
+
fromDB_1 = _g.sent();
|
|
221
|
+
opType = fromDB_1 ? OpType.UPDATE : OpType.INSERT;
|
|
222
|
+
if (!(keysEqual(itemKeyValues, modelKeyValues) ||
|
|
223
|
+
opType === OpType.INSERT)) return [3 /*break*/, 4];
|
|
224
|
+
return [4 /*yield*/, this_2.db.save(item, storeName_1, keys, itemKeyValues.join(DEFAULT_PRIMARY_KEY_VALUE_SEPARATOR))];
|
|
225
|
+
case 3:
|
|
226
|
+
_g.sent();
|
|
227
|
+
result.push([instance, opType]);
|
|
228
|
+
_g.label = 4;
|
|
229
|
+
case 4: return [3 /*break*/, 6];
|
|
230
|
+
case 5:
|
|
231
|
+
_e = true;
|
|
232
|
+
return [7 /*endfinally*/];
|
|
233
|
+
case 6: return [2 /*return*/];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
this_2 = this;
|
|
238
|
+
_e = true, connectionStoreNames_1 = __asyncValues(connectionStoreNames);
|
|
239
|
+
_f.label = 3;
|
|
139
240
|
case 3: return [4 /*yield*/, connectionStoreNames_1.next()];
|
|
140
241
|
case 4:
|
|
141
|
-
if (!(connectionStoreNames_1_1 =
|
|
142
|
-
|
|
143
|
-
storeName_1 = resItem.storeName, item = resItem.item, instance = resItem.instance, keys = resItem.keys;
|
|
144
|
-
itemKeyValues = keys.map(function (key) { return item[key]; });
|
|
145
|
-
return [4 /*yield*/, this._get(storeName_1, itemKeyValues)];
|
|
242
|
+
if (!(connectionStoreNames_1_1 = _f.sent(), _a = connectionStoreNames_1_1.done, !_a)) return [3 /*break*/, 7];
|
|
243
|
+
return [5 /*yield**/, _loop_2()];
|
|
146
244
|
case 5:
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
_c.sent();
|
|
154
|
-
result.push([instance, opType]);
|
|
155
|
-
_c.label = 7;
|
|
156
|
-
case 7: return [3 /*break*/, 3];
|
|
157
|
-
case 8: return [3 /*break*/, 15];
|
|
158
|
-
case 9:
|
|
159
|
-
e_2_1 = _c.sent();
|
|
245
|
+
_f.sent();
|
|
246
|
+
_f.label = 6;
|
|
247
|
+
case 6: return [3 /*break*/, 3];
|
|
248
|
+
case 7: return [3 /*break*/, 14];
|
|
249
|
+
case 8:
|
|
250
|
+
e_2_1 = _f.sent();
|
|
160
251
|
e_2 = { error: e_2_1 };
|
|
161
|
-
return [3 /*break*/,
|
|
252
|
+
return [3 /*break*/, 14];
|
|
253
|
+
case 9:
|
|
254
|
+
_f.trys.push([9, , 12, 13]);
|
|
255
|
+
if (!(!_e && !_a && (_b = connectionStoreNames_1.return))) return [3 /*break*/, 11];
|
|
256
|
+
return [4 /*yield*/, _b.call(connectionStoreNames_1)];
|
|
162
257
|
case 10:
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
case
|
|
167
|
-
_c.sent();
|
|
168
|
-
_c.label = 12;
|
|
169
|
-
case 12: return [3 /*break*/, 14];
|
|
170
|
-
case 13:
|
|
258
|
+
_f.sent();
|
|
259
|
+
_f.label = 11;
|
|
260
|
+
case 11: return [3 /*break*/, 13];
|
|
261
|
+
case 12:
|
|
171
262
|
if (e_2) throw e_2.error;
|
|
172
263
|
return [7 /*endfinally*/];
|
|
173
|
-
case
|
|
174
|
-
case
|
|
264
|
+
case 13: return [7 /*endfinally*/];
|
|
265
|
+
case 14: return [2 /*return*/, result];
|
|
175
266
|
}
|
|
176
267
|
});
|
|
177
268
|
});
|
|
@@ -277,73 +368,91 @@ var AsyncStorageAdapter = /** @class */ (function (_super) {
|
|
|
277
368
|
});
|
|
278
369
|
};
|
|
279
370
|
AsyncStorageAdapter.prototype.deleteItem = function (deleteQueue) {
|
|
280
|
-
var e_3,
|
|
371
|
+
var _a, e_3, _b, _c, _d, e_4, _e, _f;
|
|
281
372
|
return __awaiter(this, void 0, void 0, function () {
|
|
282
|
-
var
|
|
283
|
-
return __generator(this, function (
|
|
284
|
-
switch (
|
|
373
|
+
var _g, _h, _j, deleteItem, storeName, items, _k, items_2, items_2_1, item, keyValuesPath, e_4_1, e_3_1;
|
|
374
|
+
return __generator(this, function (_l) {
|
|
375
|
+
switch (_l.label) {
|
|
285
376
|
case 0:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
case 1: return [4 /*yield*/,
|
|
377
|
+
_l.trys.push([0, 23, 24, 29]);
|
|
378
|
+
_g = true, _h = __asyncValues(deleteQueue);
|
|
379
|
+
_l.label = 1;
|
|
380
|
+
case 1: return [4 /*yield*/, _h.next()];
|
|
290
381
|
case 2:
|
|
291
|
-
if (!(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
382
|
+
if (!(_j = _l.sent(), _a = _j.done, !_a)) return [3 /*break*/, 22];
|
|
383
|
+
_c = _j.value;
|
|
384
|
+
_g = false;
|
|
385
|
+
_l.label = 3;
|
|
295
386
|
case 3:
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
case
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
387
|
+
_l.trys.push([3, , 20, 21]);
|
|
388
|
+
deleteItem = _c;
|
|
389
|
+
storeName = deleteItem.storeName, items = deleteItem.items;
|
|
390
|
+
_l.label = 4;
|
|
391
|
+
case 4:
|
|
392
|
+
_l.trys.push([4, 13, 14, 19]);
|
|
393
|
+
_k = true, items_2 = (e_4 = void 0, __asyncValues(items));
|
|
394
|
+
_l.label = 5;
|
|
395
|
+
case 5: return [4 /*yield*/, items_2.next()];
|
|
396
|
+
case 6:
|
|
397
|
+
if (!(items_2_1 = _l.sent(), _d = items_2_1.done, !_d)) return [3 /*break*/, 12];
|
|
398
|
+
_f = items_2_1.value;
|
|
399
|
+
_k = false;
|
|
400
|
+
_l.label = 7;
|
|
401
|
+
case 7:
|
|
402
|
+
_l.trys.push([7, , 10, 11]);
|
|
403
|
+
item = _f;
|
|
404
|
+
if (!item) return [3 /*break*/, 9];
|
|
405
|
+
if (!(typeof item === 'object')) return [3 /*break*/, 9];
|
|
305
406
|
keyValuesPath = this.getIndexKeyValuesPath(item);
|
|
306
407
|
return [4 /*yield*/, this.db.delete(keyValuesPath, storeName)];
|
|
307
|
-
case
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
case
|
|
311
|
-
case 8: return [3 /*break*/, 15];
|
|
312
|
-
case 9:
|
|
313
|
-
e_4_1 = _e.sent();
|
|
314
|
-
e_4 = { error: e_4_1 };
|
|
315
|
-
return [3 /*break*/, 15];
|
|
408
|
+
case 8:
|
|
409
|
+
_l.sent();
|
|
410
|
+
_l.label = 9;
|
|
411
|
+
case 9: return [3 /*break*/, 11];
|
|
316
412
|
case 10:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
case
|
|
321
|
-
_e.sent();
|
|
322
|
-
_e.label = 12;
|
|
323
|
-
case 12: return [3 /*break*/, 14];
|
|
413
|
+
_k = true;
|
|
414
|
+
return [7 /*endfinally*/];
|
|
415
|
+
case 11: return [3 /*break*/, 5];
|
|
416
|
+
case 12: return [3 /*break*/, 19];
|
|
324
417
|
case 13:
|
|
418
|
+
e_4_1 = _l.sent();
|
|
419
|
+
e_4 = { error: e_4_1 };
|
|
420
|
+
return [3 /*break*/, 19];
|
|
421
|
+
case 14:
|
|
422
|
+
_l.trys.push([14, , 17, 18]);
|
|
423
|
+
if (!(!_k && !_d && (_e = items_2.return))) return [3 /*break*/, 16];
|
|
424
|
+
return [4 /*yield*/, _e.call(items_2)];
|
|
425
|
+
case 15:
|
|
426
|
+
_l.sent();
|
|
427
|
+
_l.label = 16;
|
|
428
|
+
case 16: return [3 /*break*/, 18];
|
|
429
|
+
case 17:
|
|
325
430
|
if (e_4) throw e_4.error;
|
|
326
431
|
return [7 /*endfinally*/];
|
|
327
|
-
case
|
|
328
|
-
case
|
|
329
|
-
case
|
|
330
|
-
|
|
331
|
-
|
|
432
|
+
case 18: return [7 /*endfinally*/];
|
|
433
|
+
case 19: return [3 /*break*/, 21];
|
|
434
|
+
case 20:
|
|
435
|
+
_g = true;
|
|
436
|
+
return [7 /*endfinally*/];
|
|
437
|
+
case 21: return [3 /*break*/, 1];
|
|
438
|
+
case 22: return [3 /*break*/, 29];
|
|
439
|
+
case 23:
|
|
440
|
+
e_3_1 = _l.sent();
|
|
332
441
|
e_3 = { error: e_3_1 };
|
|
333
|
-
return [3 /*break*/,
|
|
334
|
-
case
|
|
335
|
-
|
|
336
|
-
if (!(
|
|
337
|
-
return [4 /*yield*/,
|
|
338
|
-
case
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
case
|
|
342
|
-
case
|
|
442
|
+
return [3 /*break*/, 29];
|
|
443
|
+
case 24:
|
|
444
|
+
_l.trys.push([24, , 27, 28]);
|
|
445
|
+
if (!(!_g && !_a && (_b = _h.return))) return [3 /*break*/, 26];
|
|
446
|
+
return [4 /*yield*/, _b.call(_h)];
|
|
447
|
+
case 25:
|
|
448
|
+
_l.sent();
|
|
449
|
+
_l.label = 26;
|
|
450
|
+
case 26: return [3 /*break*/, 28];
|
|
451
|
+
case 27:
|
|
343
452
|
if (e_3) throw e_3.error;
|
|
344
453
|
return [7 /*endfinally*/];
|
|
345
|
-
case
|
|
346
|
-
case
|
|
454
|
+
case 28: return [7 /*endfinally*/];
|
|
455
|
+
case 29: return [2 /*return*/];
|
|
347
456
|
}
|
|
348
457
|
});
|
|
349
458
|
});
|
|
@@ -362,4 +471,3 @@ var AsyncStorageAdapter = /** @class */ (function (_super) {
|
|
|
362
471
|
}(StorageAdapterBase));
|
|
363
472
|
export { AsyncStorageAdapter };
|
|
364
473
|
export default new AsyncStorageAdapter();
|
|
365
|
-
//# sourceMappingURL=AsyncStorageAdapter.js.map
|
|
@@ -1,4 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __values = (this && this.__values) || function(o) {
|
|
38
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
39
|
+
if (m) return m.call(o);
|
|
40
|
+
if (o && typeof o.length === "number") return {
|
|
41
|
+
next: function () {
|
|
42
|
+
if (o && i >= o.length) o = void 0;
|
|
43
|
+
return { value: o && o[i++], done: !o };
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
47
|
+
};
|
|
48
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
49
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
50
|
+
if (!m) return o;
|
|
51
|
+
var i = m.call(o), r, ar = [], e;
|
|
52
|
+
try {
|
|
53
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
54
|
+
}
|
|
55
|
+
catch (error) { e = { error: error }; }
|
|
56
|
+
finally {
|
|
57
|
+
try {
|
|
58
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
59
|
+
}
|
|
60
|
+
finally { if (e) throw e.error; }
|
|
61
|
+
}
|
|
62
|
+
return ar;
|
|
63
|
+
};
|
|
2
64
|
import { OpType, QueryOne, } from '../../types';
|
|
3
65
|
import { DEFAULT_PRIMARY_KEY_VALUE_SEPARATOR, indexNameFromKeys, monotonicUlidFactory, } from '../../util';
|
|
4
66
|
import { createInMemoryStore } from './InMemoryStore';
|
|
@@ -449,15 +511,14 @@ var AsyncStorageDatabase = /** @class */ (function () {
|
|
|
449
511
|
});
|
|
450
512
|
};
|
|
451
513
|
AsyncStorageDatabase.prototype.getKeyForItem = function (storeName, id, ulid) {
|
|
452
|
-
return this.getKeyPrefixForStoreItems(storeName)
|
|
514
|
+
return "".concat(this.getKeyPrefixForStoreItems(storeName), "::").concat(ulid, "::").concat(id);
|
|
453
515
|
};
|
|
454
516
|
AsyncStorageDatabase.prototype.getLegacyKeyForItem = function (storeName, id) {
|
|
455
|
-
return this.getKeyPrefixForStoreItems(storeName)
|
|
517
|
+
return "".concat(this.getKeyPrefixForStoreItems(storeName), "::").concat(id);
|
|
456
518
|
};
|
|
457
519
|
AsyncStorageDatabase.prototype.getKeyPrefixForStoreItems = function (storeName) {
|
|
458
|
-
return DB_NAME
|
|
520
|
+
return "".concat(DB_NAME, "::").concat(storeName, "::").concat(DATA);
|
|
459
521
|
};
|
|
460
522
|
return AsyncStorageDatabase;
|
|
461
523
|
}());
|
|
462
524
|
export default AsyncStorageDatabase;
|
|
463
|
-
//# sourceMappingURL=AsyncStorageDatabase.js.map
|
|
@@ -1,4 +1,55 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
38
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
39
|
+
if (!m) return o;
|
|
40
|
+
var i = m.call(o), r, ar = [], e;
|
|
41
|
+
try {
|
|
42
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
43
|
+
}
|
|
44
|
+
catch (error) { e = { error: error }; }
|
|
45
|
+
finally {
|
|
46
|
+
try {
|
|
47
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
48
|
+
}
|
|
49
|
+
finally { if (e) throw e.error; }
|
|
50
|
+
}
|
|
51
|
+
return ar;
|
|
52
|
+
};
|
|
2
53
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
54
|
// SPDX-License-Identifier: Apache-2.0
|
|
4
55
|
var InMemoryStore = /** @class */ (function () {
|
|
@@ -57,4 +108,3 @@ export { InMemoryStore };
|
|
|
57
108
|
export function createInMemoryStore() {
|
|
58
109
|
return new InMemoryStore();
|
|
59
110
|
}
|
|
60
|
-
//# sourceMappingURL=InMemoryStore.js.map
|