@aws-amplify/datastore 3.7.4-custom-pk.80 → 3.7.4-custom-pk.86
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/dist/aws-amplify-datastore.js +356 -168
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +3 -3
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +47 -10
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageAdapter.js +229 -135
- package/lib/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib/storage/adapter/AsyncStorageDatabase.js +3 -2
- package/lib/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/util.d.ts +4 -0
- package/lib/util.js +9 -0
- package/lib/util.js.map +1 -1
- package/lib-esm/datastore/datastore.js +48 -11
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js +229 -135
- package/lib-esm/storage/adapter/AsyncStorageAdapter.js.map +1 -1
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js +4 -3
- package/lib-esm/storage/adapter/AsyncStorageDatabase.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/util.d.ts +4 -0
- package/lib-esm/util.js +8 -0
- package/lib-esm/util.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +60 -12
- package/src/storage/adapter/AsyncStorageAdapter.ts +162 -35
- package/src/storage/adapter/AsyncStorageDatabase.ts +4 -2
- package/src/storage/adapter/IndexedDBAdapter.ts +0 -1
- package/src/util.ts +15 -0
|
@@ -81825,6 +81825,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
81825
81825
|
/* harmony import */ var _sync__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../sync */ "./lib-esm/sync/index.js");
|
|
81826
81826
|
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../types */ "./lib-esm/types.js");
|
|
81827
81827
|
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../util */ "./lib-esm/util.js");
|
|
81828
|
+
/* harmony import */ var _sync_utils__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../sync/utils */ "./lib-esm/sync/utils.js");
|
|
81828
81829
|
function _typeof(obj) {
|
|
81829
81830
|
"@babel/helpers - typeof";
|
|
81830
81831
|
|
|
@@ -82072,6 +82073,7 @@ var __spread = undefined && undefined.__spread || function () {
|
|
|
82072
82073
|
|
|
82073
82074
|
|
|
82074
82075
|
|
|
82076
|
+
|
|
82075
82077
|
Object(immer__WEBPACK_IMPORTED_MODULE_4__["setAutoFreeze"])(true);
|
|
82076
82078
|
Object(immer__WEBPACK_IMPORTED_MODULE_4__["enablePatches"])();
|
|
82077
82079
|
var logger = new _aws_amplify_core__WEBPACK_IMPORTED_MODULE_1__["ConsoleLogger"]('DataStore');
|
|
@@ -82242,6 +82244,10 @@ function modelInstanceCreator(modelConstructor, init) {
|
|
|
82242
82244
|
return new modelConstructor(init);
|
|
82243
82245
|
}
|
|
82244
82246
|
|
|
82247
|
+
function isSchemaModel(m) {
|
|
82248
|
+
return m.attributes !== undefined;
|
|
82249
|
+
}
|
|
82250
|
+
|
|
82245
82251
|
var validateModelFields = function validateModelFields(modelDefinition) {
|
|
82246
82252
|
return function (k, v) {
|
|
82247
82253
|
var fieldDefinition = modelDefinition.fields[k];
|
|
@@ -82257,6 +82263,18 @@ var validateModelFields = function validateModelFields(modelDefinition) {
|
|
|
82257
82263
|
throw new Error("Field " + name_1 + " is required");
|
|
82258
82264
|
}
|
|
82259
82265
|
|
|
82266
|
+
if (isSchemaModel(modelDefinition) && !Object(_util__WEBPACK_IMPORTED_MODULE_12__["isIdManaged"])(modelDefinition)) {
|
|
82267
|
+
var keys = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition);
|
|
82268
|
+
|
|
82269
|
+
if (keys.includes(k) && v === '') {
|
|
82270
|
+
logger.error(_util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].idEmptyString, {
|
|
82271
|
+
k: k,
|
|
82272
|
+
value: v
|
|
82273
|
+
});
|
|
82274
|
+
throw new Error(_util__WEBPACK_IMPORTED_MODULE_12__["errorMessages"].idEmptyString);
|
|
82275
|
+
}
|
|
82276
|
+
}
|
|
82277
|
+
|
|
82260
82278
|
if (Object(_types__WEBPACK_IMPORTED_MODULE_11__["isGraphQLScalarType"])(type)) {
|
|
82261
82279
|
var jsType_1 = _types__WEBPACK_IMPORTED_MODULE_11__["GraphQLScalarType"].getJSType(type);
|
|
82262
82280
|
var validateScalar_1 = _types__WEBPACK_IMPORTED_MODULE_11__["GraphQLScalarType"].getValidationFunction(type);
|
|
@@ -83204,7 +83222,7 @@ function () {
|
|
|
83204
83222
|
}).subscribe({
|
|
83205
83223
|
next: function next(item) {
|
|
83206
83224
|
return __awaiter(_this, void 0, void 0, function () {
|
|
83207
|
-
var message, freshElement;
|
|
83225
|
+
var message, modelDefinition, keyFields, primaryKeysAndValues, freshElement;
|
|
83208
83226
|
return __generator(this, function (_a) {
|
|
83209
83227
|
switch (_a.label) {
|
|
83210
83228
|
case 0:
|
|
@@ -83212,9 +83230,12 @@ function () {
|
|
|
83212
83230
|
if (!(item.opType !== 'DELETE')) return [3
|
|
83213
83231
|
/*break*/
|
|
83214
83232
|
, 2];
|
|
83233
|
+
modelDefinition = getModelDefinition(item.model);
|
|
83234
|
+
keyFields = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeyFieldNames"])(modelDefinition);
|
|
83235
|
+
primaryKeysAndValues = Object(_util__WEBPACK_IMPORTED_MODULE_12__["extractPrimaryKeysAndValues"])(item.element, keyFields);
|
|
83215
83236
|
return [4
|
|
83216
83237
|
/*yield*/
|
|
83217
|
-
, this.query(item.model,
|
|
83238
|
+
, this.query(item.model, primaryKeysAndValues)];
|
|
83218
83239
|
|
|
83219
83240
|
case 1:
|
|
83220
83241
|
freshElement = _a.sent();
|
|
@@ -83327,7 +83348,15 @@ function () {
|
|
|
83327
83348
|
case 1:
|
|
83328
83349
|
// first, query and return any locally-available records
|
|
83329
83350
|
_a.sent().forEach(function (item) {
|
|
83330
|
-
|
|
83351
|
+
var record = item; // TODO: fix query
|
|
83352
|
+
|
|
83353
|
+
if (Array.isArray(item)) {
|
|
83354
|
+
record = item[0];
|
|
83355
|
+
}
|
|
83356
|
+
|
|
83357
|
+
var itemModelDefinition = getModelDefinition(model);
|
|
83358
|
+
var idOrPk = Object(_sync_utils__WEBPACK_IMPORTED_MODULE_13__["getIdentifierValue"])(itemModelDefinition, record);
|
|
83359
|
+
items.set(idOrPk, record);
|
|
83331
83360
|
}); // Observe the model and send a stream of updates (debounced).
|
|
83332
83361
|
// We need to post-filter results instead of passing criteria through
|
|
83333
83362
|
// to have visibility into items that move from in-set to out-of-set.
|
|
@@ -83341,13 +83370,22 @@ function () {
|
|
|
83341
83370
|
|
|
83342
83371
|
var _b, _c;
|
|
83343
83372
|
|
|
83344
|
-
|
|
83345
|
-
|
|
83373
|
+
var record = element; // TODO: fix query
|
|
83374
|
+
|
|
83375
|
+
if (Array.isArray(element)) {
|
|
83376
|
+
record = element[0];
|
|
83377
|
+
}
|
|
83378
|
+
|
|
83379
|
+
var itemModelDefinition = getModelDefinition(model);
|
|
83380
|
+
var idOrPk = Object(_sync_utils__WEBPACK_IMPORTED_MODULE_13__["getIdentifierValue"])(itemModelDefinition, record);
|
|
83381
|
+
|
|
83382
|
+
if (hasPredicate && !Object(_util__WEBPACK_IMPORTED_MODULE_12__["validatePredicate"])(record, predicateGroupType, predicates)) {
|
|
83383
|
+
if (opType === 'UPDATE' && (items.has(idOrPk) || itemsChanged.has(idOrPk))) {
|
|
83346
83384
|
// tracking as a "deleted item" will include the item in
|
|
83347
83385
|
// page limit calculations and ensure it is removed from the
|
|
83348
83386
|
// final items collection, regardless of which collection(s)
|
|
83349
83387
|
// it is currently in. (I mean, it could be in both, right!?)
|
|
83350
|
-
deletedItemIds.push(
|
|
83388
|
+
deletedItemIds.push(idOrPk);
|
|
83351
83389
|
} else {
|
|
83352
83390
|
// ignore updates for irrelevant/filtered items.
|
|
83353
83391
|
return;
|
|
@@ -83359,9 +83397,9 @@ function () {
|
|
|
83359
83397
|
|
|
83360
83398
|
|
|
83361
83399
|
if (opType === 'DELETE') {
|
|
83362
|
-
deletedItemIds.push(
|
|
83400
|
+
deletedItemIds.push(idOrPk);
|
|
83363
83401
|
} else {
|
|
83364
|
-
itemsChanged.set(
|
|
83402
|
+
itemsChanged.set(idOrPk, record);
|
|
83365
83403
|
}
|
|
83366
83404
|
|
|
83367
83405
|
var isSynced = (_c = (_b = _this.sync) === null || _b === void 0 ? void 0 : _b.getModelSyncedStatus(model)) !== null && _c !== void 0 ? _c : false;
|
|
@@ -83416,11 +83454,20 @@ function () {
|
|
|
83416
83454
|
|
|
83417
83455
|
items.clear();
|
|
83418
83456
|
itemsArray.forEach(function (item) {
|
|
83419
|
-
|
|
83457
|
+
// CPK TODO: fix query
|
|
83458
|
+
var record = item;
|
|
83459
|
+
|
|
83460
|
+
if (Array.isArray(item)) {
|
|
83461
|
+
record = item[0];
|
|
83462
|
+
}
|
|
83463
|
+
|
|
83464
|
+
var itemModelDefinition = getModelDefinition(model);
|
|
83465
|
+
var idOrPk = Object(_sync_utils__WEBPACK_IMPORTED_MODULE_13__["getIdentifierValue"])(itemModelDefinition, record);
|
|
83466
|
+
items.set(idOrPk, record);
|
|
83420
83467
|
}); // remove deleted items from the final result set
|
|
83421
83468
|
|
|
83422
|
-
deletedItemIds.forEach(function (
|
|
83423
|
-
return items["delete"](
|
|
83469
|
+
deletedItemIds.forEach(function (idOrPk) {
|
|
83470
|
+
return items["delete"](idOrPk);
|
|
83424
83471
|
});
|
|
83425
83472
|
return {
|
|
83426
83473
|
items: Array.from(items.values()),
|
|
@@ -84417,9 +84464,10 @@ function () {
|
|
|
84417
84464
|
|
|
84418
84465
|
|
|
84419
84466
|
AsyncStorageAdapter.prototype.getIndexKeys = function (namespaceName, modelName) {
|
|
84420
|
-
var _a
|
|
84467
|
+
var _a;
|
|
84421
84468
|
|
|
84422
|
-
var
|
|
84469
|
+
var namespace = this.schema.namespaces[namespaceName];
|
|
84470
|
+
var keyPath = (_a = namespace === null || namespace === void 0 ? void 0 : namespace.keys[modelName]) === null || _a === void 0 ? void 0 : _a.primaryKey;
|
|
84423
84471
|
|
|
84424
84472
|
if (keyPath) {
|
|
84425
84473
|
return keyPath;
|
|
@@ -84711,7 +84759,7 @@ function () {
|
|
|
84711
84759
|
var e_2, _a, e_3, _b, e_4, _c;
|
|
84712
84760
|
|
|
84713
84761
|
return __awaiter(this, void 0, void 0, function () {
|
|
84714
|
-
var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, relationType, storeName, modelConstructor_1, _d, recordItem, getByfield, key, connectionRecord, e_3_1, recordItem, key, connectionRecord, e_4_1, e_2_1;
|
|
84762
|
+
var namespace, relations, connectionStoreNames, modelConstructor, relations_1, relations_1_1, relation, fieldName, modelName, targetName, targetNames, relationType, storeName, modelConstructor_1, _d, recordItem, getByFields, allPresent, keys, connectionRecord, getByfield, key, connectionRecord, e_3_1, recordItem, allPresent, keys, connectionRecord, key, connectionRecord, e_4_1, e_2_1;
|
|
84715
84763
|
|
|
84716
84764
|
var _this = this;
|
|
84717
84765
|
|
|
@@ -84737,7 +84785,7 @@ function () {
|
|
|
84737
84785
|
_e.label = 1;
|
|
84738
84786
|
|
|
84739
84787
|
case 1:
|
|
84740
|
-
_e.trys.push([1,
|
|
84788
|
+
_e.trys.push([1, 38, 39, 44]);
|
|
84741
84789
|
|
|
84742
84790
|
relations_1 = __asyncValues(relations);
|
|
84743
84791
|
_e.label = 2;
|
|
@@ -84750,9 +84798,9 @@ function () {
|
|
|
84750
84798
|
case 3:
|
|
84751
84799
|
if (!(relations_1_1 = _e.sent(), !relations_1_1.done)) return [3
|
|
84752
84800
|
/*break*/
|
|
84753
|
-
,
|
|
84801
|
+
, 37];
|
|
84754
84802
|
relation = relations_1_1.value;
|
|
84755
|
-
fieldName = relation.fieldName, modelName = relation.modelName, targetName = relation.targetName, relationType = relation.relationType;
|
|
84803
|
+
fieldName = relation.fieldName, modelName = relation.modelName, targetName = relation.targetName, targetNames = relation.targetNames, relationType = relation.relationType;
|
|
84756
84804
|
storeName = this.getStorename(namespaceName, modelName);
|
|
84757
84805
|
modelConstructor_1 = this.getModelConstructorByModelName(namespaceName, modelName);
|
|
84758
84806
|
_d = relationType;
|
|
@@ -84766,20 +84814,20 @@ function () {
|
|
|
84766
84814
|
case 'BELONGS_TO':
|
|
84767
84815
|
return [3
|
|
84768
84816
|
/*break*/
|
|
84769
|
-
,
|
|
84817
|
+
, 19];
|
|
84770
84818
|
|
|
84771
84819
|
case 'HAS_MANY':
|
|
84772
84820
|
return [3
|
|
84773
84821
|
/*break*/
|
|
84774
|
-
,
|
|
84822
|
+
, 34];
|
|
84775
84823
|
}
|
|
84776
84824
|
|
|
84777
84825
|
return [3
|
|
84778
84826
|
/*break*/
|
|
84779
|
-
,
|
|
84827
|
+
, 35];
|
|
84780
84828
|
|
|
84781
84829
|
case 4:
|
|
84782
|
-
_e.trys.push([4,
|
|
84830
|
+
_e.trys.push([4, 12, 13, 18]);
|
|
84783
84831
|
|
|
84784
84832
|
records_1 = __asyncValues(records);
|
|
84785
84833
|
_e.label = 5;
|
|
@@ -84792,225 +84840,290 @@ function () {
|
|
|
84792
84840
|
case 6:
|
|
84793
84841
|
if (!(records_1_1 = _e.sent(), !records_1_1.done)) return [3
|
|
84794
84842
|
/*break*/
|
|
84795
|
-
,
|
|
84843
|
+
, 11];
|
|
84796
84844
|
recordItem = records_1_1.value;
|
|
84845
|
+
if (!(targetNames === null || targetNames === void 0 ? void 0 : targetNames.length)) return [3
|
|
84846
|
+
/*break*/
|
|
84847
|
+
, 8];
|
|
84848
|
+
getByFields = [];
|
|
84849
|
+
allPresent = void 0; // iterate through all targetnames to make sure they are all present in the recordItem
|
|
84850
|
+
|
|
84851
|
+
allPresent = targetNames.every(function (targetName) {
|
|
84852
|
+
return recordItem[targetName] != null;
|
|
84853
|
+
});
|
|
84854
|
+
|
|
84855
|
+
if (!allPresent) {
|
|
84856
|
+
return [3
|
|
84857
|
+
/*break*/
|
|
84858
|
+
, 11];
|
|
84859
|
+
}
|
|
84860
|
+
|
|
84861
|
+
getByFields = targetNames;
|
|
84862
|
+
keys = getByFields.map(function (getByField) {
|
|
84863
|
+
return recordItem[getByField];
|
|
84864
|
+
}).join(DEFAULT_PRIMARY_KEY_SEPARATOR);
|
|
84865
|
+
return [4
|
|
84866
|
+
/*yield*/
|
|
84867
|
+
, this.db.get(keys, storeName)];
|
|
84868
|
+
|
|
84869
|
+
case 7:
|
|
84870
|
+
connectionRecord = _e.sent();
|
|
84871
|
+
recordItem[fieldName] = connectionRecord && this.modelInstanceCreator(modelConstructor_1, connectionRecord);
|
|
84872
|
+
return [3
|
|
84873
|
+
/*break*/
|
|
84874
|
+
, 10];
|
|
84875
|
+
|
|
84876
|
+
case 8:
|
|
84797
84877
|
getByfield = recordItem[targetName] ? targetName : fieldName;
|
|
84798
84878
|
if (!recordItem[getByfield]) return [3
|
|
84799
84879
|
/*break*/
|
|
84800
|
-
,
|
|
84880
|
+
, 11];
|
|
84801
84881
|
key = recordItem[getByfield];
|
|
84802
84882
|
return [4
|
|
84803
84883
|
/*yield*/
|
|
84804
84884
|
, this.db.get(key, storeName)];
|
|
84805
84885
|
|
|
84806
|
-
case
|
|
84886
|
+
case 9:
|
|
84807
84887
|
connectionRecord = _e.sent();
|
|
84808
84888
|
recordItem[fieldName] = connectionRecord && this.modelInstanceCreator(modelConstructor_1, connectionRecord);
|
|
84809
|
-
_e.label =
|
|
84889
|
+
_e.label = 10;
|
|
84810
84890
|
|
|
84811
|
-
case
|
|
84891
|
+
case 10:
|
|
84812
84892
|
return [3
|
|
84813
84893
|
/*break*/
|
|
84814
84894
|
, 5];
|
|
84815
84895
|
|
|
84816
|
-
case
|
|
84896
|
+
case 11:
|
|
84817
84897
|
return [3
|
|
84818
84898
|
/*break*/
|
|
84819
|
-
,
|
|
84899
|
+
, 18];
|
|
84820
84900
|
|
|
84821
|
-
case
|
|
84901
|
+
case 12:
|
|
84822
84902
|
e_3_1 = _e.sent();
|
|
84823
84903
|
e_3 = {
|
|
84824
84904
|
error: e_3_1
|
|
84825
84905
|
};
|
|
84826
84906
|
return [3
|
|
84827
84907
|
/*break*/
|
|
84828
|
-
,
|
|
84908
|
+
, 18];
|
|
84829
84909
|
|
|
84830
|
-
case
|
|
84831
|
-
_e.trys.push([
|
|
84910
|
+
case 13:
|
|
84911
|
+
_e.trys.push([13,, 16, 17]);
|
|
84832
84912
|
|
|
84833
84913
|
if (!(records_1_1 && !records_1_1.done && (_b = records_1["return"]))) return [3
|
|
84834
84914
|
/*break*/
|
|
84835
|
-
,
|
|
84915
|
+
, 15];
|
|
84836
84916
|
return [4
|
|
84837
84917
|
/*yield*/
|
|
84838
84918
|
, _b.call(records_1)];
|
|
84839
84919
|
|
|
84840
|
-
case
|
|
84920
|
+
case 14:
|
|
84841
84921
|
_e.sent();
|
|
84842
84922
|
|
|
84843
|
-
_e.label =
|
|
84923
|
+
_e.label = 15;
|
|
84844
84924
|
|
|
84845
|
-
case
|
|
84925
|
+
case 15:
|
|
84846
84926
|
return [3
|
|
84847
84927
|
/*break*/
|
|
84848
|
-
,
|
|
84928
|
+
, 17];
|
|
84849
84929
|
|
|
84850
|
-
case
|
|
84930
|
+
case 16:
|
|
84851
84931
|
if (e_3) throw e_3.error;
|
|
84852
84932
|
return [7
|
|
84853
84933
|
/*endfinally*/
|
|
84854
84934
|
];
|
|
84855
84935
|
|
|
84856
|
-
case
|
|
84936
|
+
case 17:
|
|
84857
84937
|
return [7
|
|
84858
84938
|
/*endfinally*/
|
|
84859
84939
|
];
|
|
84860
84940
|
|
|
84861
|
-
case
|
|
84941
|
+
case 18:
|
|
84862
84942
|
return [3
|
|
84863
84943
|
/*break*/
|
|
84864
|
-
,
|
|
84944
|
+
, 36];
|
|
84865
84945
|
|
|
84866
|
-
case
|
|
84867
|
-
_e.trys.push([
|
|
84946
|
+
case 19:
|
|
84947
|
+
_e.trys.push([19, 27, 28, 33]);
|
|
84868
84948
|
|
|
84869
84949
|
records_2 = __asyncValues(records);
|
|
84870
|
-
_e.label =
|
|
84950
|
+
_e.label = 20;
|
|
84871
84951
|
|
|
84872
|
-
case
|
|
84952
|
+
case 20:
|
|
84873
84953
|
return [4
|
|
84874
84954
|
/*yield*/
|
|
84875
84955
|
, records_2.next()];
|
|
84876
84956
|
|
|
84877
|
-
case
|
|
84957
|
+
case 21:
|
|
84878
84958
|
if (!(records_2_1 = _e.sent(), !records_2_1.done)) return [3
|
|
84879
84959
|
/*break*/
|
|
84880
|
-
,
|
|
84960
|
+
, 26];
|
|
84881
84961
|
recordItem = records_2_1.value;
|
|
84962
|
+
if (!(targetNames === null || targetNames === void 0 ? void 0 : targetNames.length)) return [3
|
|
84963
|
+
/*break*/
|
|
84964
|
+
, 23];
|
|
84965
|
+
allPresent = void 0; // iterate through all targetnames to make sure they are all present in the recordItem
|
|
84966
|
+
|
|
84967
|
+
allPresent = targetNames.every(function (targetName) {
|
|
84968
|
+
return recordItem[targetName] != null;
|
|
84969
|
+
}); // If not present, there is not yet a connected record
|
|
84970
|
+
|
|
84971
|
+
if (!allPresent) {
|
|
84972
|
+
return [3
|
|
84973
|
+
/*break*/
|
|
84974
|
+
, 26];
|
|
84975
|
+
}
|
|
84976
|
+
|
|
84977
|
+
keys = targetNames.map(function (targetName) {
|
|
84978
|
+
return recordItem[targetName];
|
|
84979
|
+
}).join(DEFAULT_PRIMARY_KEY_SEPARATOR);
|
|
84980
|
+
return [4
|
|
84981
|
+
/*yield*/
|
|
84982
|
+
, this.db.get(keys, storeName)];
|
|
84983
|
+
|
|
84984
|
+
case 22:
|
|
84985
|
+
connectionRecord = _e.sent();
|
|
84986
|
+
recordItem[fieldName] = connectionRecord && this.modelInstanceCreator(modelConstructor_1, connectionRecord);
|
|
84987
|
+
targetNames === null || targetNames === void 0 ? void 0 : targetNames.map(function (targetName) {
|
|
84988
|
+
delete recordItem[targetName];
|
|
84989
|
+
});
|
|
84990
|
+
return [3
|
|
84991
|
+
/*break*/
|
|
84992
|
+
, 25];
|
|
84993
|
+
|
|
84994
|
+
case 23:
|
|
84882
84995
|
if (!recordItem[targetName]) return [3
|
|
84883
84996
|
/*break*/
|
|
84884
|
-
,
|
|
84997
|
+
, 25];
|
|
84885
84998
|
key = recordItem[targetName];
|
|
84886
84999
|
return [4
|
|
84887
85000
|
/*yield*/
|
|
84888
85001
|
, this.db.get(key, storeName)];
|
|
84889
85002
|
|
|
84890
|
-
case
|
|
85003
|
+
case 24:
|
|
84891
85004
|
connectionRecord = _e.sent();
|
|
84892
85005
|
recordItem[fieldName] = connectionRecord && this.modelInstanceCreator(modelConstructor_1, connectionRecord);
|
|
84893
85006
|
delete recordItem[targetName];
|
|
84894
|
-
_e.label =
|
|
85007
|
+
_e.label = 25;
|
|
84895
85008
|
|
|
84896
|
-
case
|
|
85009
|
+
case 25:
|
|
84897
85010
|
return [3
|
|
84898
85011
|
/*break*/
|
|
84899
|
-
,
|
|
85012
|
+
, 20];
|
|
84900
85013
|
|
|
84901
|
-
case
|
|
85014
|
+
case 26:
|
|
84902
85015
|
return [3
|
|
84903
85016
|
/*break*/
|
|
84904
|
-
,
|
|
85017
|
+
, 33];
|
|
84905
85018
|
|
|
84906
|
-
case
|
|
85019
|
+
case 27:
|
|
84907
85020
|
e_4_1 = _e.sent();
|
|
84908
85021
|
e_4 = {
|
|
84909
85022
|
error: e_4_1
|
|
84910
85023
|
};
|
|
84911
85024
|
return [3
|
|
84912
85025
|
/*break*/
|
|
84913
|
-
,
|
|
85026
|
+
, 33];
|
|
84914
85027
|
|
|
84915
|
-
case
|
|
84916
|
-
_e.trys.push([
|
|
85028
|
+
case 28:
|
|
85029
|
+
_e.trys.push([28,, 31, 32]);
|
|
84917
85030
|
|
|
84918
85031
|
if (!(records_2_1 && !records_2_1.done && (_c = records_2["return"]))) return [3
|
|
84919
85032
|
/*break*/
|
|
84920
|
-
,
|
|
85033
|
+
, 30];
|
|
84921
85034
|
return [4
|
|
84922
85035
|
/*yield*/
|
|
84923
85036
|
, _c.call(records_2)];
|
|
84924
85037
|
|
|
84925
|
-
case
|
|
85038
|
+
case 29:
|
|
84926
85039
|
_e.sent();
|
|
84927
85040
|
|
|
84928
|
-
_e.label =
|
|
85041
|
+
_e.label = 30;
|
|
84929
85042
|
|
|
84930
|
-
case
|
|
85043
|
+
case 30:
|
|
84931
85044
|
return [3
|
|
84932
85045
|
/*break*/
|
|
84933
|
-
,
|
|
85046
|
+
, 32];
|
|
84934
85047
|
|
|
84935
|
-
case
|
|
85048
|
+
case 31:
|
|
84936
85049
|
if (e_4) throw e_4.error;
|
|
84937
85050
|
return [7
|
|
84938
85051
|
/*endfinally*/
|
|
84939
85052
|
];
|
|
84940
85053
|
|
|
84941
|
-
case
|
|
85054
|
+
case 32:
|
|
84942
85055
|
return [7
|
|
84943
85056
|
/*endfinally*/
|
|
84944
85057
|
];
|
|
84945
85058
|
|
|
84946
|
-
case
|
|
85059
|
+
case 33:
|
|
84947
85060
|
return [3
|
|
84948
85061
|
/*break*/
|
|
84949
|
-
,
|
|
85062
|
+
, 36];
|
|
84950
85063
|
|
|
84951
|
-
case
|
|
85064
|
+
case 34:
|
|
84952
85065
|
// TODO: Lazy loading
|
|
84953
85066
|
return [3
|
|
84954
85067
|
/*break*/
|
|
84955
|
-
,
|
|
85068
|
+
, 36];
|
|
84956
85069
|
|
|
84957
|
-
case
|
|
85070
|
+
case 35:
|
|
84958
85071
|
Object(_util__WEBPACK_IMPORTED_MODULE_4__["exhaustiveCheck"])(relationType);
|
|
84959
85072
|
return [3
|
|
84960
85073
|
/*break*/
|
|
84961
|
-
,
|
|
85074
|
+
, 36];
|
|
84962
85075
|
|
|
84963
|
-
case
|
|
85076
|
+
case 36:
|
|
84964
85077
|
return [3
|
|
84965
85078
|
/*break*/
|
|
84966
85079
|
, 2];
|
|
84967
85080
|
|
|
84968
|
-
case
|
|
85081
|
+
case 37:
|
|
84969
85082
|
return [3
|
|
84970
85083
|
/*break*/
|
|
84971
|
-
,
|
|
85084
|
+
, 44];
|
|
84972
85085
|
|
|
84973
|
-
case
|
|
85086
|
+
case 38:
|
|
84974
85087
|
e_2_1 = _e.sent();
|
|
84975
85088
|
e_2 = {
|
|
84976
85089
|
error: e_2_1
|
|
84977
85090
|
};
|
|
84978
85091
|
return [3
|
|
84979
85092
|
/*break*/
|
|
84980
|
-
,
|
|
85093
|
+
, 44];
|
|
84981
85094
|
|
|
84982
|
-
case
|
|
84983
|
-
_e.trys.push([
|
|
85095
|
+
case 39:
|
|
85096
|
+
_e.trys.push([39,, 42, 43]);
|
|
84984
85097
|
|
|
84985
85098
|
if (!(relations_1_1 && !relations_1_1.done && (_a = relations_1["return"]))) return [3
|
|
84986
85099
|
/*break*/
|
|
84987
|
-
,
|
|
85100
|
+
, 41];
|
|
84988
85101
|
return [4
|
|
84989
85102
|
/*yield*/
|
|
84990
85103
|
, _a.call(relations_1)];
|
|
84991
85104
|
|
|
84992
|
-
case
|
|
85105
|
+
case 40:
|
|
84993
85106
|
_e.sent();
|
|
84994
85107
|
|
|
84995
|
-
_e.label =
|
|
85108
|
+
_e.label = 41;
|
|
84996
85109
|
|
|
84997
|
-
case
|
|
85110
|
+
case 41:
|
|
84998
85111
|
return [3
|
|
84999
85112
|
/*break*/
|
|
85000
|
-
,
|
|
85113
|
+
, 43];
|
|
85001
85114
|
|
|
85002
|
-
case
|
|
85115
|
+
case 42:
|
|
85003
85116
|
if (e_2) throw e_2.error;
|
|
85004
85117
|
return [7
|
|
85005
85118
|
/*endfinally*/
|
|
85006
85119
|
];
|
|
85007
85120
|
|
|
85008
|
-
case
|
|
85121
|
+
case 43:
|
|
85009
85122
|
return [7
|
|
85010
85123
|
/*endfinally*/
|
|
85011
85124
|
];
|
|
85012
85125
|
|
|
85013
|
-
case
|
|
85126
|
+
case 44:
|
|
85014
85127
|
return [2
|
|
85015
85128
|
/*return*/
|
|
85016
85129
|
, records.map(function (record) {
|
|
@@ -85602,14 +85715,14 @@ function () {
|
|
|
85602
85715
|
var e_8, _a, e_9, _b, e_10, _c;
|
|
85603
85716
|
|
|
85604
85717
|
return __awaiter(this, void 0, void 0, function () {
|
|
85605
|
-
var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, index, _d, model,
|
|
85718
|
+
var rel, relationType, modelName, targetName, targetNames, associatedWith, storeName, index, _d, model, hasOneIndex_1, hasConnectedModelFields, keyValuesPath, values_1, allRecords, recordToDelete, hasOneIndex_2, hasOneCustomField, keyValuesPath, value_1, allRecords, recordToDelete, e_9_1, model, keyValues, allRecords, indices, childrenArray, e_10_1, e_8_1;
|
|
85606
85719
|
|
|
85607
85720
|
var _this = this;
|
|
85608
85721
|
|
|
85609
85722
|
return __generator(this, function (_e) {
|
|
85610
85723
|
switch (_e.label) {
|
|
85611
85724
|
case 0:
|
|
85612
|
-
_e.trys.push([0,
|
|
85725
|
+
_e.trys.push([0, 38, 39, 44]);
|
|
85613
85726
|
|
|
85614
85727
|
relations_2 = __asyncValues(relations);
|
|
85615
85728
|
_e.label = 1;
|
|
@@ -85622,7 +85735,7 @@ function () {
|
|
|
85622
85735
|
case 2:
|
|
85623
85736
|
if (!(relations_2_1 = _e.sent(), !relations_2_1.done)) return [3
|
|
85624
85737
|
/*break*/
|
|
85625
|
-
,
|
|
85738
|
+
, 37];
|
|
85626
85739
|
rel = relations_2_1.value;
|
|
85627
85740
|
relationType = rel.relationType, modelName = rel.modelName, targetName = rel.targetName, targetNames = rel.targetNames, associatedWith = rel.associatedWith;
|
|
85628
85741
|
storeName = this.getStorename(nameSpace, modelName);
|
|
@@ -85641,20 +85754,20 @@ function () {
|
|
|
85641
85754
|
case 'HAS_MANY':
|
|
85642
85755
|
return [3
|
|
85643
85756
|
/*break*/
|
|
85644
|
-
,
|
|
85757
|
+
, 20];
|
|
85645
85758
|
|
|
85646
85759
|
case 'BELONGS_TO':
|
|
85647
85760
|
return [3
|
|
85648
85761
|
/*break*/
|
|
85649
|
-
,
|
|
85762
|
+
, 34];
|
|
85650
85763
|
}
|
|
85651
85764
|
|
|
85652
85765
|
return [3
|
|
85653
85766
|
/*break*/
|
|
85654
|
-
,
|
|
85767
|
+
, 35];
|
|
85655
85768
|
|
|
85656
85769
|
case 3:
|
|
85657
|
-
_e.trys.push([3,
|
|
85770
|
+
_e.trys.push([3, 13, 14, 19]);
|
|
85658
85771
|
|
|
85659
85772
|
models_1 = __asyncValues(models);
|
|
85660
85773
|
_e.label = 4;
|
|
@@ -85667,24 +85780,55 @@ function () {
|
|
|
85667
85780
|
case 5:
|
|
85668
85781
|
if (!(models_1_1 = _e.sent(), !models_1_1.done)) return [3
|
|
85669
85782
|
/*break*/
|
|
85670
|
-
,
|
|
85783
|
+
, 12];
|
|
85671
85784
|
model = models_1_1.value;
|
|
85672
|
-
|
|
85673
|
-
|
|
85785
|
+
if (!(targetNames && (targetNames === null || targetNames === void 0 ? void 0 : targetNames.length))) return [3
|
|
85786
|
+
/*break*/
|
|
85787
|
+
, 8];
|
|
85788
|
+
hasOneIndex_1 = index || associatedWith;
|
|
85789
|
+
hasConnectedModelFields = targetNames.every(function (targetName) {
|
|
85790
|
+
return model.hasOwnProperty(targetName);
|
|
85791
|
+
});
|
|
85674
85792
|
keyValuesPath = this.getIndexKeyValuesPath(model);
|
|
85675
|
-
|
|
85676
|
-
if (
|
|
85793
|
+
|
|
85794
|
+
if (hasConnectedModelFields) {
|
|
85795
|
+
// Values will be that of the child model
|
|
85796
|
+
values_1 = targetNames.map(function (targetName) {
|
|
85797
|
+
return model[targetName];
|
|
85798
|
+
});
|
|
85799
|
+
} else {
|
|
85800
|
+
// values will be that of the parent model
|
|
85801
|
+
values_1 = keyValuesPath;
|
|
85802
|
+
}
|
|
85803
|
+
|
|
85804
|
+
if (values_1.length === 0) return [3
|
|
85677
85805
|
/*break*/
|
|
85678
|
-
,
|
|
85806
|
+
, 12];
|
|
85679
85807
|
return [4
|
|
85680
85808
|
/*yield*/
|
|
85681
85809
|
, this.db.getAll(storeName)];
|
|
85682
85810
|
|
|
85683
85811
|
case 6:
|
|
85684
85812
|
allRecords = _e.sent();
|
|
85685
|
-
recordToDelete =
|
|
85686
|
-
|
|
85687
|
-
|
|
85813
|
+
recordToDelete = void 0; // values === targetNames
|
|
85814
|
+
|
|
85815
|
+
if (hasConnectedModelFields) {
|
|
85816
|
+
/**
|
|
85817
|
+
* Retrieve record by finding the record where all
|
|
85818
|
+
* targetNames are present on the connected model
|
|
85819
|
+
*/
|
|
85820
|
+
recordToDelete = allRecords.filter(function (childItem) {
|
|
85821
|
+
return values_1.every(function (value) {
|
|
85822
|
+
return childItem[value] != null;
|
|
85823
|
+
});
|
|
85824
|
+
});
|
|
85825
|
+
} else {
|
|
85826
|
+
// values === keyValuePath
|
|
85827
|
+
recordToDelete = allRecords.filter(function (childItem) {
|
|
85828
|
+
return childItem[hasOneIndex_1] === values_1;
|
|
85829
|
+
});
|
|
85830
|
+
}
|
|
85831
|
+
|
|
85688
85832
|
return [4
|
|
85689
85833
|
/*yield*/
|
|
85690
85834
|
, this.deleteTraverse(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, recordToDelete, modelName, nameSpace, deleteQueue)];
|
|
@@ -85692,216 +85836,247 @@ function () {
|
|
|
85692
85836
|
case 7:
|
|
85693
85837
|
_e.sent();
|
|
85694
85838
|
|
|
85695
|
-
|
|
85839
|
+
return [3
|
|
85840
|
+
/*break*/
|
|
85841
|
+
, 11];
|
|
85696
85842
|
|
|
85697
85843
|
case 8:
|
|
85844
|
+
hasOneIndex_2 = index || associatedWith;
|
|
85845
|
+
hasOneCustomField = targetName in model;
|
|
85846
|
+
keyValuesPath = this.getIndexKeyValuesPath(model);
|
|
85847
|
+
value_1 = hasOneCustomField ? model[targetName] : keyValuesPath;
|
|
85848
|
+
if (!value_1) return [3
|
|
85849
|
+
/*break*/
|
|
85850
|
+
, 12];
|
|
85851
|
+
return [4
|
|
85852
|
+
/*yield*/
|
|
85853
|
+
, this.db.getAll(storeName)];
|
|
85854
|
+
|
|
85855
|
+
case 9:
|
|
85856
|
+
allRecords = _e.sent();
|
|
85857
|
+
recordToDelete = allRecords.filter(function (childItem) {
|
|
85858
|
+
return childItem[hasOneIndex_2] === value_1;
|
|
85859
|
+
});
|
|
85860
|
+
return [4
|
|
85861
|
+
/*yield*/
|
|
85862
|
+
, this.deleteTraverse(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, recordToDelete, modelName, nameSpace, deleteQueue)];
|
|
85863
|
+
|
|
85864
|
+
case 10:
|
|
85865
|
+
_e.sent();
|
|
85866
|
+
|
|
85867
|
+
_e.label = 11;
|
|
85868
|
+
|
|
85869
|
+
case 11:
|
|
85698
85870
|
return [3
|
|
85699
85871
|
/*break*/
|
|
85700
85872
|
, 4];
|
|
85701
85873
|
|
|
85702
|
-
case
|
|
85874
|
+
case 12:
|
|
85703
85875
|
return [3
|
|
85704
85876
|
/*break*/
|
|
85705
|
-
,
|
|
85877
|
+
, 19];
|
|
85706
85878
|
|
|
85707
|
-
case
|
|
85879
|
+
case 13:
|
|
85708
85880
|
e_9_1 = _e.sent();
|
|
85709
85881
|
e_9 = {
|
|
85710
85882
|
error: e_9_1
|
|
85711
85883
|
};
|
|
85712
85884
|
return [3
|
|
85713
85885
|
/*break*/
|
|
85714
|
-
,
|
|
85886
|
+
, 19];
|
|
85715
85887
|
|
|
85716
|
-
case
|
|
85717
|
-
_e.trys.push([
|
|
85888
|
+
case 14:
|
|
85889
|
+
_e.trys.push([14,, 17, 18]);
|
|
85718
85890
|
|
|
85719
85891
|
if (!(models_1_1 && !models_1_1.done && (_b = models_1["return"]))) return [3
|
|
85720
85892
|
/*break*/
|
|
85721
|
-
,
|
|
85893
|
+
, 16];
|
|
85722
85894
|
return [4
|
|
85723
85895
|
/*yield*/
|
|
85724
85896
|
, _b.call(models_1)];
|
|
85725
85897
|
|
|
85726
|
-
case
|
|
85898
|
+
case 15:
|
|
85727
85899
|
_e.sent();
|
|
85728
85900
|
|
|
85729
|
-
_e.label =
|
|
85901
|
+
_e.label = 16;
|
|
85730
85902
|
|
|
85731
|
-
case
|
|
85903
|
+
case 16:
|
|
85732
85904
|
return [3
|
|
85733
85905
|
/*break*/
|
|
85734
|
-
,
|
|
85906
|
+
, 18];
|
|
85735
85907
|
|
|
85736
|
-
case
|
|
85908
|
+
case 17:
|
|
85737
85909
|
if (e_9) throw e_9.error;
|
|
85738
85910
|
return [7
|
|
85739
85911
|
/*endfinally*/
|
|
85740
85912
|
];
|
|
85741
85913
|
|
|
85742
|
-
case
|
|
85914
|
+
case 18:
|
|
85743
85915
|
return [7
|
|
85744
85916
|
/*endfinally*/
|
|
85745
85917
|
];
|
|
85746
85918
|
|
|
85747
|
-
case
|
|
85919
|
+
case 19:
|
|
85748
85920
|
return [3
|
|
85749
85921
|
/*break*/
|
|
85750
|
-
,
|
|
85922
|
+
, 36];
|
|
85751
85923
|
|
|
85752
|
-
case
|
|
85753
|
-
_e.trys.push([
|
|
85924
|
+
case 20:
|
|
85925
|
+
_e.trys.push([20, 27, 28, 33]);
|
|
85754
85926
|
|
|
85755
85927
|
models_2 = __asyncValues(models);
|
|
85756
|
-
_e.label =
|
|
85928
|
+
_e.label = 21;
|
|
85757
85929
|
|
|
85758
|
-
case
|
|
85930
|
+
case 21:
|
|
85759
85931
|
return [4
|
|
85760
85932
|
/*yield*/
|
|
85761
85933
|
, models_2.next()];
|
|
85762
85934
|
|
|
85763
|
-
case
|
|
85935
|
+
case 22:
|
|
85764
85936
|
if (!(models_2_1 = _e.sent(), !models_2_1.done)) return [3
|
|
85765
85937
|
/*break*/
|
|
85766
|
-
,
|
|
85938
|
+
, 26];
|
|
85767
85939
|
model = models_2_1.value;
|
|
85768
|
-
|
|
85940
|
+
keyValues = this.getIndexKeyValues(model);
|
|
85769
85941
|
return [4
|
|
85770
85942
|
/*yield*/
|
|
85771
85943
|
, this.db.getAll(storeName)];
|
|
85772
85944
|
|
|
85773
|
-
case
|
|
85945
|
+
case 23:
|
|
85774
85946
|
allRecords = _e.sent();
|
|
85947
|
+
indices = index.split('-');
|
|
85775
85948
|
childrenArray = allRecords.filter(function (childItem) {
|
|
85776
|
-
return
|
|
85949
|
+
return indices.every(function (index) {
|
|
85950
|
+
return keyValues.includes(childItem[index]);
|
|
85951
|
+
});
|
|
85777
85952
|
});
|
|
85778
85953
|
return [4
|
|
85779
85954
|
/*yield*/
|
|
85780
85955
|
, this.deleteTraverse(this.schema.namespaces[nameSpace].relationships[modelName].relationTypes, childrenArray, modelName, nameSpace, deleteQueue)];
|
|
85781
85956
|
|
|
85782
|
-
case
|
|
85957
|
+
case 24:
|
|
85783
85958
|
_e.sent();
|
|
85784
85959
|
|
|
85785
|
-
_e.label =
|
|
85960
|
+
_e.label = 25;
|
|
85786
85961
|
|
|
85787
|
-
case
|
|
85962
|
+
case 25:
|
|
85788
85963
|
return [3
|
|
85789
85964
|
/*break*/
|
|
85790
|
-
,
|
|
85965
|
+
, 21];
|
|
85791
85966
|
|
|
85792
|
-
case
|
|
85967
|
+
case 26:
|
|
85793
85968
|
return [3
|
|
85794
85969
|
/*break*/
|
|
85795
|
-
,
|
|
85970
|
+
, 33];
|
|
85796
85971
|
|
|
85797
|
-
case
|
|
85972
|
+
case 27:
|
|
85798
85973
|
e_10_1 = _e.sent();
|
|
85799
85974
|
e_10 = {
|
|
85800
85975
|
error: e_10_1
|
|
85801
85976
|
};
|
|
85802
85977
|
return [3
|
|
85803
85978
|
/*break*/
|
|
85804
|
-
,
|
|
85979
|
+
, 33];
|
|
85805
85980
|
|
|
85806
|
-
case
|
|
85807
|
-
_e.trys.push([
|
|
85981
|
+
case 28:
|
|
85982
|
+
_e.trys.push([28,, 31, 32]);
|
|
85808
85983
|
|
|
85809
85984
|
if (!(models_2_1 && !models_2_1.done && (_c = models_2["return"]))) return [3
|
|
85810
85985
|
/*break*/
|
|
85811
|
-
,
|
|
85986
|
+
, 30];
|
|
85812
85987
|
return [4
|
|
85813
85988
|
/*yield*/
|
|
85814
85989
|
, _c.call(models_2)];
|
|
85815
85990
|
|
|
85816
|
-
case
|
|
85991
|
+
case 29:
|
|
85817
85992
|
_e.sent();
|
|
85818
85993
|
|
|
85819
|
-
_e.label =
|
|
85994
|
+
_e.label = 30;
|
|
85820
85995
|
|
|
85821
|
-
case
|
|
85996
|
+
case 30:
|
|
85822
85997
|
return [3
|
|
85823
85998
|
/*break*/
|
|
85824
|
-
,
|
|
85999
|
+
, 32];
|
|
85825
86000
|
|
|
85826
|
-
case
|
|
86001
|
+
case 31:
|
|
85827
86002
|
if (e_10) throw e_10.error;
|
|
85828
86003
|
return [7
|
|
85829
86004
|
/*endfinally*/
|
|
85830
86005
|
];
|
|
85831
86006
|
|
|
85832
|
-
case
|
|
86007
|
+
case 32:
|
|
85833
86008
|
return [7
|
|
85834
86009
|
/*endfinally*/
|
|
85835
86010
|
];
|
|
85836
86011
|
|
|
85837
|
-
case
|
|
86012
|
+
case 33:
|
|
85838
86013
|
return [3
|
|
85839
86014
|
/*break*/
|
|
85840
|
-
,
|
|
86015
|
+
, 36];
|
|
85841
86016
|
|
|
85842
|
-
case
|
|
86017
|
+
case 34:
|
|
85843
86018
|
// Intentionally blank
|
|
85844
86019
|
return [3
|
|
85845
86020
|
/*break*/
|
|
85846
|
-
,
|
|
86021
|
+
, 36];
|
|
85847
86022
|
|
|
85848
|
-
case
|
|
86023
|
+
case 35:
|
|
85849
86024
|
Object(_util__WEBPACK_IMPORTED_MODULE_4__["exhaustiveCheck"])(relationType);
|
|
85850
86025
|
return [3
|
|
85851
86026
|
/*break*/
|
|
85852
|
-
,
|
|
86027
|
+
, 36];
|
|
85853
86028
|
|
|
85854
|
-
case
|
|
86029
|
+
case 36:
|
|
85855
86030
|
return [3
|
|
85856
86031
|
/*break*/
|
|
85857
86032
|
, 1];
|
|
85858
86033
|
|
|
85859
|
-
case
|
|
86034
|
+
case 37:
|
|
85860
86035
|
return [3
|
|
85861
86036
|
/*break*/
|
|
85862
|
-
,
|
|
86037
|
+
, 44];
|
|
85863
86038
|
|
|
85864
|
-
case
|
|
86039
|
+
case 38:
|
|
85865
86040
|
e_8_1 = _e.sent();
|
|
85866
86041
|
e_8 = {
|
|
85867
86042
|
error: e_8_1
|
|
85868
86043
|
};
|
|
85869
86044
|
return [3
|
|
85870
86045
|
/*break*/
|
|
85871
|
-
,
|
|
86046
|
+
, 44];
|
|
85872
86047
|
|
|
85873
|
-
case
|
|
85874
|
-
_e.trys.push([
|
|
86048
|
+
case 39:
|
|
86049
|
+
_e.trys.push([39,, 42, 43]);
|
|
85875
86050
|
|
|
85876
86051
|
if (!(relations_2_1 && !relations_2_1.done && (_a = relations_2["return"]))) return [3
|
|
85877
86052
|
/*break*/
|
|
85878
|
-
,
|
|
86053
|
+
, 41];
|
|
85879
86054
|
return [4
|
|
85880
86055
|
/*yield*/
|
|
85881
86056
|
, _a.call(relations_2)];
|
|
85882
86057
|
|
|
85883
|
-
case
|
|
86058
|
+
case 40:
|
|
85884
86059
|
_e.sent();
|
|
85885
86060
|
|
|
85886
|
-
_e.label =
|
|
86061
|
+
_e.label = 41;
|
|
85887
86062
|
|
|
85888
|
-
case
|
|
86063
|
+
case 41:
|
|
85889
86064
|
return [3
|
|
85890
86065
|
/*break*/
|
|
85891
|
-
,
|
|
86066
|
+
, 43];
|
|
85892
86067
|
|
|
85893
|
-
case
|
|
86068
|
+
case 42:
|
|
85894
86069
|
if (e_8) throw e_8.error;
|
|
85895
86070
|
return [7
|
|
85896
86071
|
/*endfinally*/
|
|
85897
86072
|
];
|
|
85898
86073
|
|
|
85899
|
-
case
|
|
86074
|
+
case 43:
|
|
85900
86075
|
return [7
|
|
85901
86076
|
/*endfinally*/
|
|
85902
86077
|
];
|
|
85903
86078
|
|
|
85904
|
-
case
|
|
86079
|
+
case 44:
|
|
85905
86080
|
deleteQueue.push({
|
|
85906
86081
|
storeName: this.getStorename(nameSpace, srcModel),
|
|
85907
86082
|
items: models.map(function (record) {
|
|
@@ -86391,11 +86566,12 @@ function () {
|
|
|
86391
86566
|
|
|
86392
86567
|
AsyncStorageDatabase.prototype.save = function (item, storeName, keys, keyValuesPath) {
|
|
86393
86568
|
return __awaiter(this, void 0, void 0, function () {
|
|
86394
|
-
var ulid, itemKey;
|
|
86569
|
+
var idxName, ulid, itemKey;
|
|
86395
86570
|
return __generator(this, function (_a) {
|
|
86396
86571
|
switch (_a.label) {
|
|
86397
86572
|
case 0:
|
|
86398
|
-
|
|
86573
|
+
idxName = Object(_util__WEBPACK_IMPORTED_MODULE_1__["indexNameFromKeys"])(keys);
|
|
86574
|
+
ulid = this.getCollectionIndex(storeName).get(idxName) || this.getMonotonicFactory(storeName)();
|
|
86399
86575
|
itemKey = this.getKeyForItem(storeName, keyValuesPath, ulid); // Set key in collection index
|
|
86400
86576
|
|
|
86401
86577
|
this.getCollectionIndex(storeName).set(keyValuesPath, ulid); // Save item in db
|
|
@@ -97092,14 +97268,16 @@ var LimitTimerRaceResolvedValues;
|
|
|
97092
97268
|
/*!*************************!*\
|
|
97093
97269
|
!*** ./lib-esm/util.js ***!
|
|
97094
97270
|
\*************************/
|
|
97095
|
-
/*! exports provided: extractKeyIfExists, extractPrimaryKeyFieldNames, extractPrimaryKeyValues, isIdManaged, isIdOptionallyManaged, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, USER_AGENT_SUFFIX_DATASTORE, exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver, mergePatches, extractTargetNamesFromSrc, indexNameFromKeys */
|
|
97271
|
+
/*! exports provided: errorMessages, extractKeyIfExists, extractPrimaryKeyFieldNames, extractPrimaryKeyValues, extractPrimaryKeysAndValues, isIdManaged, isIdOptionallyManaged, NAMESPACES, USER, SYNC, STORAGE, DATASTORE, USER_AGENT_SUFFIX_DATASTORE, exhaustiveCheck, isNullOrUndefined, validatePredicate, validatePredicateField, isModelConstructor, registerNonModelClass, isNonModelConstructor, processCompositeKeys, establishRelationAndKeys, traverseModel, getIndex, getIndexFromAssociation, isPrivateMode, monotonicUlidFactory, getNow, sortCompareFunction, valuesEqual, isAWSDate, isAWSTime, isAWSDateTime, isAWSTimestamp, isAWSEmail, isAWSJSON, isAWSURL, isAWSPhone, isAWSIPAddress, DeferredPromise, DeferredCallbackResolver, mergePatches, extractTargetNamesFromSrc, indexNameFromKeys */
|
|
97096
97272
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
97097
97273
|
|
|
97098
97274
|
"use strict";
|
|
97099
97275
|
__webpack_require__.r(__webpack_exports__);
|
|
97276
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "errorMessages", function() { return errorMessages; });
|
|
97100
97277
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractKeyIfExists", function() { return extractKeyIfExists; });
|
|
97101
97278
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractPrimaryKeyFieldNames", function() { return extractPrimaryKeyFieldNames; });
|
|
97102
97279
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractPrimaryKeyValues", function() { return extractPrimaryKeyValues; });
|
|
97280
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractPrimaryKeysAndValues", function() { return extractPrimaryKeysAndValues; });
|
|
97103
97281
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdManaged", function() { return isIdManaged; });
|
|
97104
97282
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isIdOptionallyManaged", function() { return isIdOptionallyManaged; });
|
|
97105
97283
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAMESPACES", function() { return NAMESPACES; });
|
|
@@ -97359,6 +97537,9 @@ var __values = undefined && undefined.__values || function (o) {
|
|
|
97359
97537
|
|
|
97360
97538
|
|
|
97361
97539
|
var ID = 'id';
|
|
97540
|
+
var errorMessages = {
|
|
97541
|
+
idEmptyString: 'An index field cannot contain an empty string value'
|
|
97542
|
+
};
|
|
97362
97543
|
function extractKeyIfExists(modelDefinition) {
|
|
97363
97544
|
var _c;
|
|
97364
97545
|
|
|
@@ -97378,6 +97559,13 @@ function extractPrimaryKeyValues(model, keyFields) {
|
|
|
97378
97559
|
return keyFields.map(function (key) {
|
|
97379
97560
|
return model[key];
|
|
97380
97561
|
});
|
|
97562
|
+
}
|
|
97563
|
+
function extractPrimaryKeysAndValues(model, keyFields) {
|
|
97564
|
+
var primaryKeysAndValues = {};
|
|
97565
|
+
keyFields.forEach(function (key) {
|
|
97566
|
+
return primaryKeysAndValues[key] = model[key];
|
|
97567
|
+
});
|
|
97568
|
+
return primaryKeysAndValues;
|
|
97381
97569
|
} // IdentifierFields<ManagedIdentifier>
|
|
97382
97570
|
// Default behavior without explicit @primaryKey defined
|
|
97383
97571
|
|