@aws-amplify/datastore 3.10.0 → 3.10.1-unstable.4
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 +70 -17
- package/dist/aws-amplify-datastore.js.map +1 -1
- package/dist/aws-amplify-datastore.min.js +2 -2
- package/dist/aws-amplify-datastore.min.js.map +1 -1
- package/lib/datastore/datastore.js +9 -4
- package/lib/datastore/datastore.js.map +1 -1
- package/lib/storage/adapter/IndexedDBAdapter.d.ts +1 -0
- package/lib/storage/adapter/IndexedDBAdapter.js +39 -7
- package/lib/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib/storage/storage.js +11 -0
- package/lib/storage/storage.js.map +1 -1
- package/lib-esm/datastore/datastore.js +9 -4
- package/lib-esm/datastore/datastore.js.map +1 -1
- package/lib-esm/storage/adapter/IndexedDBAdapter.d.ts +1 -0
- package/lib-esm/storage/adapter/IndexedDBAdapter.js +39 -7
- package/lib-esm/storage/adapter/IndexedDBAdapter.js.map +1 -1
- package/lib-esm/storage/storage.js +11 -0
- package/lib-esm/storage/storage.js.map +1 -1
- package/package.json +7 -7
- package/src/datastore/datastore.ts +10 -1
- package/src/storage/adapter/IndexedDBAdapter.ts +49 -11
- package/src/storage/storage.ts +12 -0
|
@@ -71106,7 +71106,7 @@ var getAmplifyUserAgent = function getAmplifyUserAgent() {
|
|
|
71106
71106
|
__webpack_require__.r(__webpack_exports__);
|
|
71107
71107
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
|
|
71108
71108
|
// generated by genversion
|
|
71109
|
-
var version = '4.5.
|
|
71109
|
+
var version = '4.5.2';
|
|
71110
71110
|
|
|
71111
71111
|
/***/ }),
|
|
71112
71112
|
|
|
@@ -83219,12 +83219,21 @@ function () {
|
|
|
83219
83219
|
return __generator(this, function (_a) {
|
|
83220
83220
|
switch (_a.label) {
|
|
83221
83221
|
case 0:
|
|
83222
|
-
if (this.storage === undefined)
|
|
83223
|
-
|
|
83224
|
-
|
|
83225
|
-
|
|
83226
|
-
|
|
83222
|
+
if (!(this.storage === undefined)) return [3
|
|
83223
|
+
/*break*/
|
|
83224
|
+
, 2]; // connect to storage so that it can be cleared without fully starting DataStore
|
|
83225
|
+
|
|
83226
|
+
this.storage = new _storage_storage__WEBPACK_IMPORTED_MODULE_6__["ExclusiveStorage"](schema, namespaceResolver, getModelConstructorByModelName, modelInstanceCreator, this.storageAdapter, this.sessionId);
|
|
83227
|
+
return [4
|
|
83228
|
+
/*yield*/
|
|
83229
|
+
, this.storage.init()];
|
|
83227
83230
|
|
|
83231
|
+
case 1:
|
|
83232
|
+
_a.sent();
|
|
83233
|
+
|
|
83234
|
+
_a.label = 2;
|
|
83235
|
+
|
|
83236
|
+
case 2:
|
|
83228
83237
|
if (syncSubscription && !syncSubscription.closed) {
|
|
83229
83238
|
syncSubscription.unsubscribe();
|
|
83230
83239
|
}
|
|
@@ -83233,7 +83242,7 @@ function () {
|
|
|
83233
83242
|
/*yield*/
|
|
83234
83243
|
, this.storage.clear()];
|
|
83235
83244
|
|
|
83236
|
-
case
|
|
83245
|
+
case 3:
|
|
83237
83246
|
_a.sent();
|
|
83238
83247
|
|
|
83239
83248
|
if (this.sync) {
|
|
@@ -87019,16 +87028,7 @@ function () {
|
|
|
87019
87028
|
Object.keys(namespace.models).forEach(function (modelName) {
|
|
87020
87029
|
var storeName = _this.getStorename(namespaceName, modelName);
|
|
87021
87030
|
|
|
87022
|
-
|
|
87023
|
-
autoIncrement: true
|
|
87024
|
-
});
|
|
87025
|
-
var indexes = _this.schema.namespaces[namespaceName].relationships[modelName].indexes;
|
|
87026
|
-
indexes.forEach(function (index) {
|
|
87027
|
-
return store.createIndex(index, index);
|
|
87028
|
-
});
|
|
87029
|
-
store.createIndex('byId', 'id', {
|
|
87030
|
-
unique: true
|
|
87031
|
-
});
|
|
87031
|
+
_this.createObjectStoreForModel(db, namespaceName, storeName, modelName);
|
|
87032
87032
|
});
|
|
87033
87033
|
});
|
|
87034
87034
|
return [2
|
|
@@ -87138,6 +87138,27 @@ function () {
|
|
|
87138
87138
|
];
|
|
87139
87139
|
|
|
87140
87140
|
case 13:
|
|
87141
|
+
// add new models created after IndexedDB, but before migration
|
|
87142
|
+
// this case may happen when a user has not opened an app for
|
|
87143
|
+
// some time and a new model is added during that time
|
|
87144
|
+
Object.keys(theSchema.namespaces).forEach(function (namespaceName) {
|
|
87145
|
+
var namespace = theSchema.namespaces[namespaceName];
|
|
87146
|
+
var objectStoreNames = new Set(txn.objectStoreNames);
|
|
87147
|
+
Object.keys(namespace.models).map(function (modelName) {
|
|
87148
|
+
return [modelName, _this.getStorename(namespaceName, modelName)];
|
|
87149
|
+
}).filter(function (_a) {
|
|
87150
|
+
var _b = __read(_a, 2),
|
|
87151
|
+
storeName = _b[1];
|
|
87152
|
+
|
|
87153
|
+
return !objectStoreNames.has(storeName);
|
|
87154
|
+
}).forEach(function (_a) {
|
|
87155
|
+
var _b = __read(_a, 2),
|
|
87156
|
+
modelName = _b[0],
|
|
87157
|
+
storeName = _b[1];
|
|
87158
|
+
|
|
87159
|
+
_this.createObjectStoreForModel(db, namespaceName, storeName, modelName);
|
|
87160
|
+
});
|
|
87161
|
+
});
|
|
87141
87162
|
return [3
|
|
87142
87163
|
/*break*/
|
|
87143
87164
|
, 15];
|
|
@@ -88889,6 +88910,27 @@ function () {
|
|
|
88889
88910
|
});
|
|
88890
88911
|
};
|
|
88891
88912
|
|
|
88913
|
+
IndexedDBAdapter.prototype.createObjectStoreForModel = function (db, namespaceName, storeName, modelName) {
|
|
88914
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88915
|
+
var store, indexes;
|
|
88916
|
+
return __generator(this, function (_a) {
|
|
88917
|
+
store = db.createObjectStore(storeName, {
|
|
88918
|
+
autoIncrement: true
|
|
88919
|
+
});
|
|
88920
|
+
indexes = this.schema.namespaces[namespaceName].relationships[modelName].indexes;
|
|
88921
|
+
indexes.forEach(function (index) {
|
|
88922
|
+
return store.createIndex(index, index);
|
|
88923
|
+
});
|
|
88924
|
+
store.createIndex('byId', 'id', {
|
|
88925
|
+
unique: true
|
|
88926
|
+
});
|
|
88927
|
+
return [2
|
|
88928
|
+
/*return*/
|
|
88929
|
+
];
|
|
88930
|
+
});
|
|
88931
|
+
});
|
|
88932
|
+
};
|
|
88933
|
+
|
|
88892
88934
|
return IndexedDBAdapter;
|
|
88893
88935
|
}();
|
|
88894
88936
|
|
|
@@ -89267,6 +89309,17 @@ function () {
|
|
|
89267
89309
|
// is called by Merger, i.e., when processing an AppSync response
|
|
89268
89310
|
|
|
89269
89311
|
if (opType === _types__WEBPACK_IMPORTED_MODULE_3__["OpType"].UPDATE && !syncResponse) {
|
|
89312
|
+
//
|
|
89313
|
+
// TODO: LOOK!!!
|
|
89314
|
+
// the `model` used here is in effect regardless of what model
|
|
89315
|
+
// comes back from adapter.save().
|
|
89316
|
+
// Prior to fix, SQLite adapter had been returning two models
|
|
89317
|
+
// of different types, resulting in invalid outbox entries.
|
|
89318
|
+
//
|
|
89319
|
+
// the bug is essentially fixed in SQLite adapter.
|
|
89320
|
+
// leaving as-is, because it's currently unclear whether anything
|
|
89321
|
+
// depends on this remaining as-is.
|
|
89322
|
+
//
|
|
89270
89323
|
updateMutationInput = _this.getUpdateMutationInput(model, savedElement, patchesTuple); // // an update without changed user fields
|
|
89271
89324
|
// => don't create mutationEvent
|
|
89272
89325
|
|