cozy-pouch-link 60.9.0 → 60.10.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/dist/PouchManager.js +17 -8
- package/dist/localStorage.js +167 -134
- package/package.json +2 -2
- package/types/localStorage.d.ts +8 -0
package/dist/PouchManager.js
CHANGED
|
@@ -82,7 +82,7 @@ var PouchManager = /*#__PURE__*/function () {
|
|
|
82
82
|
var _init = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
83
83
|
var _this = this;
|
|
84
84
|
|
|
85
|
-
var pouchPlugins, pouchOptions;
|
|
85
|
+
var pouchPlugins, pouchOptions, dbNames, pouchDbNames;
|
|
86
86
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
87
87
|
while (1) {
|
|
88
88
|
switch (_context.prev = _context.next) {
|
|
@@ -102,23 +102,32 @@ var PouchManager = /*#__PURE__*/function () {
|
|
|
102
102
|
var pouch = new _this.PouchDB((0, _utils.getDatabaseName)(_this.options.prefix, doctype), pouchOptions);
|
|
103
103
|
return [dbName, pouch];
|
|
104
104
|
}));
|
|
105
|
-
Object.keys(this.pouches)
|
|
105
|
+
dbNames = Object.keys(this.pouches);
|
|
106
|
+
dbNames.forEach(function (dbName) {
|
|
106
107
|
// Set query engine for all databases
|
|
107
108
|
var doctype = (0, _utils.getDoctypeFromDatabaseName)(dbName);
|
|
108
109
|
|
|
109
110
|
_this.setQueryEngine(dbName, doctype);
|
|
111
|
+
}); // Persist db names for old browsers not supporting indexeddb.databases()
|
|
112
|
+
// This is useful for cleanup.
|
|
113
|
+
// Note PouchDB adds itself the _pouch_ prefix
|
|
114
|
+
|
|
115
|
+
pouchDbNames = dbNames.map(function (dbName) {
|
|
116
|
+
return "_pouch_".concat(dbName);
|
|
110
117
|
});
|
|
111
|
-
|
|
118
|
+
_context.next = 10;
|
|
119
|
+
return this.storage.persistDatabasesNames(pouchDbNames);
|
|
112
120
|
|
|
113
|
-
|
|
121
|
+
case 10:
|
|
122
|
+
_context.next = 12;
|
|
114
123
|
return this.storage.getPersistedSyncedDoctypes();
|
|
115
124
|
|
|
116
|
-
case
|
|
125
|
+
case 12:
|
|
117
126
|
this.syncedDoctypes = _context.sent;
|
|
118
|
-
_context.next =
|
|
127
|
+
_context.next = 15;
|
|
119
128
|
return this.storage.getPersistedWarmedUpQueries();
|
|
120
129
|
|
|
121
|
-
case
|
|
130
|
+
case 15:
|
|
122
131
|
this.warmedUpQueries = _context.sent;
|
|
123
132
|
this.getReplicationURL = this.options.getReplicationURL;
|
|
124
133
|
this.doctypesReplicationOptions = this.options.doctypesReplicationOptions || {};
|
|
@@ -135,7 +144,7 @@ var PouchManager = /*#__PURE__*/function () {
|
|
|
135
144
|
this.replications = undefined;
|
|
136
145
|
(0, _pouchdb.destroyOldDatabases)();
|
|
137
146
|
|
|
138
|
-
case
|
|
147
|
+
case 26:
|
|
139
148
|
case "end":
|
|
140
149
|
return _context.stop();
|
|
141
150
|
}
|
package/dist/localStorage.js
CHANGED
|
@@ -20,7 +20,8 @@ var LOCALSTORAGE_STORAGE_KEYS = {
|
|
|
20
20
|
WARMUPEDQUERIES: 'cozy-client-pouch-link-warmupedqueries',
|
|
21
21
|
LASTSEQUENCES: 'cozy-client-pouch-link-lastreplicationsequence',
|
|
22
22
|
LASTREPLICATEDDOCID: 'cozy-client-pouch-link-lastreplicateddocid',
|
|
23
|
-
ADAPTERNAME: 'cozy-client-pouch-link-adaptername'
|
|
23
|
+
ADAPTERNAME: 'cozy-client-pouch-link-adaptername',
|
|
24
|
+
DB_NAMES: 'cozy-client-pouch-link-db-names'
|
|
24
25
|
};
|
|
25
26
|
exports.LOCALSTORAGE_STORAGE_KEYS = LOCALSTORAGE_STORAGE_KEYS;
|
|
26
27
|
|
|
@@ -61,6 +62,38 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
61
62
|
|
|
62
63
|
return destroy;
|
|
63
64
|
}()
|
|
65
|
+
/**
|
|
66
|
+
* Persist the databases names
|
|
67
|
+
*
|
|
68
|
+
* @param {Array<string>} dbNames - The db names
|
|
69
|
+
* @returns {Promise<void>}
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
}, {
|
|
73
|
+
key: "persistDatabasesNames",
|
|
74
|
+
value: function () {
|
|
75
|
+
var _persistDatabasesNames = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(dbNames) {
|
|
76
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
77
|
+
while (1) {
|
|
78
|
+
switch (_context2.prev = _context2.next) {
|
|
79
|
+
case 0:
|
|
80
|
+
_context2.next = 2;
|
|
81
|
+
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.DB_NAMES, JSON.stringify(dbNames));
|
|
82
|
+
|
|
83
|
+
case 2:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context2.stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, _callee2, this);
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
function persistDatabasesNames(_x) {
|
|
92
|
+
return _persistDatabasesNames.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return persistDatabasesNames;
|
|
96
|
+
}()
|
|
64
97
|
/**
|
|
65
98
|
* Persist the last replicated doc id for a doctype
|
|
66
99
|
*
|
|
@@ -73,30 +106,30 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
73
106
|
}, {
|
|
74
107
|
key: "persistLastReplicatedDocID",
|
|
75
108
|
value: function () {
|
|
76
|
-
var _persistLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
109
|
+
var _persistLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(doctype, id) {
|
|
77
110
|
var docids;
|
|
78
|
-
return _regenerator.default.wrap(function
|
|
111
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
79
112
|
while (1) {
|
|
80
|
-
switch (
|
|
113
|
+
switch (_context3.prev = _context3.next) {
|
|
81
114
|
case 0:
|
|
82
|
-
|
|
115
|
+
_context3.next = 2;
|
|
83
116
|
return this.getAllLastReplicatedDocID();
|
|
84
117
|
|
|
85
118
|
case 2:
|
|
86
|
-
docids =
|
|
119
|
+
docids = _context3.sent;
|
|
87
120
|
docids[doctype] = id;
|
|
88
|
-
|
|
121
|
+
_context3.next = 6;
|
|
89
122
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.LASTREPLICATEDDOCID, JSON.stringify(docids));
|
|
90
123
|
|
|
91
124
|
case 6:
|
|
92
125
|
case "end":
|
|
93
|
-
return
|
|
126
|
+
return _context3.stop();
|
|
94
127
|
}
|
|
95
128
|
}
|
|
96
|
-
},
|
|
129
|
+
}, _callee3, this);
|
|
97
130
|
}));
|
|
98
131
|
|
|
99
|
-
function persistLastReplicatedDocID(
|
|
132
|
+
function persistLastReplicatedDocID(_x2, _x3) {
|
|
100
133
|
return _persistLastReplicatedDocID.apply(this, arguments);
|
|
101
134
|
}
|
|
102
135
|
|
|
@@ -109,25 +142,25 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
109
142
|
}, {
|
|
110
143
|
key: "getAllLastReplicatedDocID",
|
|
111
144
|
value: function () {
|
|
112
|
-
var _getAllLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
145
|
+
var _getAllLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
113
146
|
var item;
|
|
114
|
-
return _regenerator.default.wrap(function
|
|
147
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
115
148
|
while (1) {
|
|
116
|
-
switch (
|
|
149
|
+
switch (_context4.prev = _context4.next) {
|
|
117
150
|
case 0:
|
|
118
|
-
|
|
151
|
+
_context4.next = 2;
|
|
119
152
|
return this.storageEngine.getItem(LOCALSTORAGE_STORAGE_KEYS.LASTREPLICATEDDOCID);
|
|
120
153
|
|
|
121
154
|
case 2:
|
|
122
|
-
item =
|
|
123
|
-
return
|
|
155
|
+
item = _context4.sent;
|
|
156
|
+
return _context4.abrupt("return", item ? JSON.parse(item) : {});
|
|
124
157
|
|
|
125
158
|
case 4:
|
|
126
159
|
case "end":
|
|
127
|
-
return
|
|
160
|
+
return _context4.stop();
|
|
128
161
|
}
|
|
129
162
|
}
|
|
130
|
-
},
|
|
163
|
+
}, _callee4, this);
|
|
131
164
|
}));
|
|
132
165
|
|
|
133
166
|
function getAllLastReplicatedDocID() {
|
|
@@ -146,28 +179,28 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
146
179
|
}, {
|
|
147
180
|
key: "getLastReplicatedDocID",
|
|
148
181
|
value: function () {
|
|
149
|
-
var _getLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
182
|
+
var _getLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(doctype) {
|
|
150
183
|
var docids;
|
|
151
|
-
return _regenerator.default.wrap(function
|
|
184
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
152
185
|
while (1) {
|
|
153
|
-
switch (
|
|
186
|
+
switch (_context5.prev = _context5.next) {
|
|
154
187
|
case 0:
|
|
155
|
-
|
|
188
|
+
_context5.next = 2;
|
|
156
189
|
return this.getAllLastReplicatedDocID();
|
|
157
190
|
|
|
158
191
|
case 2:
|
|
159
|
-
docids =
|
|
160
|
-
return
|
|
192
|
+
docids = _context5.sent;
|
|
193
|
+
return _context5.abrupt("return", docids[doctype]);
|
|
161
194
|
|
|
162
195
|
case 4:
|
|
163
196
|
case "end":
|
|
164
|
-
return
|
|
197
|
+
return _context5.stop();
|
|
165
198
|
}
|
|
166
199
|
}
|
|
167
|
-
},
|
|
200
|
+
}, _callee5, this);
|
|
168
201
|
}));
|
|
169
202
|
|
|
170
|
-
function getLastReplicatedDocID(
|
|
203
|
+
function getLastReplicatedDocID(_x4) {
|
|
171
204
|
return _getLastReplicatedDocID.apply(this, arguments);
|
|
172
205
|
}
|
|
173
206
|
|
|
@@ -182,20 +215,20 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
182
215
|
}, {
|
|
183
216
|
key: "destroyAllLastReplicatedDocID",
|
|
184
217
|
value: function () {
|
|
185
|
-
var _destroyAllLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
186
|
-
return _regenerator.default.wrap(function
|
|
218
|
+
var _destroyAllLastReplicatedDocID = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
|
219
|
+
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
187
220
|
while (1) {
|
|
188
|
-
switch (
|
|
221
|
+
switch (_context6.prev = _context6.next) {
|
|
189
222
|
case 0:
|
|
190
|
-
|
|
223
|
+
_context6.next = 2;
|
|
191
224
|
return this.storageEngine.removeItem(LOCALSTORAGE_STORAGE_KEYS.LASTREPLICATEDDOCID);
|
|
192
225
|
|
|
193
226
|
case 2:
|
|
194
227
|
case "end":
|
|
195
|
-
return
|
|
228
|
+
return _context6.stop();
|
|
196
229
|
}
|
|
197
230
|
}
|
|
198
|
-
},
|
|
231
|
+
}, _callee6, this);
|
|
199
232
|
}));
|
|
200
233
|
|
|
201
234
|
function destroyAllLastReplicatedDocID() {
|
|
@@ -215,23 +248,23 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
215
248
|
}, {
|
|
216
249
|
key: "persistSyncedDoctypes",
|
|
217
250
|
value: function () {
|
|
218
|
-
var _persistSyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
219
|
-
return _regenerator.default.wrap(function
|
|
251
|
+
var _persistSyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(syncedDoctypes) {
|
|
252
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
220
253
|
while (1) {
|
|
221
|
-
switch (
|
|
254
|
+
switch (_context7.prev = _context7.next) {
|
|
222
255
|
case 0:
|
|
223
|
-
|
|
256
|
+
_context7.next = 2;
|
|
224
257
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.SYNCED, JSON.stringify(syncedDoctypes));
|
|
225
258
|
|
|
226
259
|
case 2:
|
|
227
260
|
case "end":
|
|
228
|
-
return
|
|
261
|
+
return _context7.stop();
|
|
229
262
|
}
|
|
230
263
|
}
|
|
231
|
-
},
|
|
264
|
+
}, _callee7, this);
|
|
232
265
|
}));
|
|
233
266
|
|
|
234
|
-
function persistSyncedDoctypes(
|
|
267
|
+
function persistSyncedDoctypes(_x5) {
|
|
235
268
|
return _persistSyncedDoctypes.apply(this, arguments);
|
|
236
269
|
}
|
|
237
270
|
|
|
@@ -246,35 +279,35 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
246
279
|
}, {
|
|
247
280
|
key: "getPersistedSyncedDoctypes",
|
|
248
281
|
value: function () {
|
|
249
|
-
var _getPersistedSyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
282
|
+
var _getPersistedSyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
250
283
|
var item, parsed;
|
|
251
|
-
return _regenerator.default.wrap(function
|
|
284
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
252
285
|
while (1) {
|
|
253
|
-
switch (
|
|
286
|
+
switch (_context8.prev = _context8.next) {
|
|
254
287
|
case 0:
|
|
255
|
-
|
|
288
|
+
_context8.next = 2;
|
|
256
289
|
return this.storageEngine.getItem(LOCALSTORAGE_STORAGE_KEYS.SYNCED);
|
|
257
290
|
|
|
258
291
|
case 2:
|
|
259
|
-
item =
|
|
292
|
+
item = _context8.sent;
|
|
260
293
|
parsed = item ? JSON.parse(item) : {};
|
|
261
294
|
|
|
262
295
|
if (!(typeof parsed !== 'object')) {
|
|
263
|
-
|
|
296
|
+
_context8.next = 6;
|
|
264
297
|
break;
|
|
265
298
|
}
|
|
266
299
|
|
|
267
|
-
return
|
|
300
|
+
return _context8.abrupt("return", {});
|
|
268
301
|
|
|
269
302
|
case 6:
|
|
270
|
-
return
|
|
303
|
+
return _context8.abrupt("return", parsed);
|
|
271
304
|
|
|
272
305
|
case 7:
|
|
273
306
|
case "end":
|
|
274
|
-
return
|
|
307
|
+
return _context8.stop();
|
|
275
308
|
}
|
|
276
309
|
}
|
|
277
|
-
},
|
|
310
|
+
}, _callee8, this);
|
|
278
311
|
}));
|
|
279
312
|
|
|
280
313
|
function getPersistedSyncedDoctypes() {
|
|
@@ -292,20 +325,20 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
292
325
|
}, {
|
|
293
326
|
key: "destroySyncedDoctypes",
|
|
294
327
|
value: function () {
|
|
295
|
-
var _destroySyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
296
|
-
return _regenerator.default.wrap(function
|
|
328
|
+
var _destroySyncedDoctypes = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
|
329
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
297
330
|
while (1) {
|
|
298
|
-
switch (
|
|
331
|
+
switch (_context9.prev = _context9.next) {
|
|
299
332
|
case 0:
|
|
300
|
-
|
|
333
|
+
_context9.next = 2;
|
|
301
334
|
return this.storageEngine.removeItem(LOCALSTORAGE_STORAGE_KEYS.SYNCED);
|
|
302
335
|
|
|
303
336
|
case 2:
|
|
304
337
|
case "end":
|
|
305
|
-
return
|
|
338
|
+
return _context9.stop();
|
|
306
339
|
}
|
|
307
340
|
}
|
|
308
|
-
},
|
|
341
|
+
}, _callee9, this);
|
|
309
342
|
}));
|
|
310
343
|
|
|
311
344
|
function destroySyncedDoctypes() {
|
|
@@ -326,30 +359,30 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
326
359
|
}, {
|
|
327
360
|
key: "persistDoctypeLastSequence",
|
|
328
361
|
value: function () {
|
|
329
|
-
var _persistDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
362
|
+
var _persistDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(doctype, sequence) {
|
|
330
363
|
var seqs;
|
|
331
|
-
return _regenerator.default.wrap(function
|
|
364
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
332
365
|
while (1) {
|
|
333
|
-
switch (
|
|
366
|
+
switch (_context10.prev = _context10.next) {
|
|
334
367
|
case 0:
|
|
335
|
-
|
|
368
|
+
_context10.next = 2;
|
|
336
369
|
return this.getAllLastSequences();
|
|
337
370
|
|
|
338
371
|
case 2:
|
|
339
|
-
seqs =
|
|
372
|
+
seqs = _context10.sent;
|
|
340
373
|
seqs[doctype] = sequence;
|
|
341
|
-
|
|
374
|
+
_context10.next = 6;
|
|
342
375
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.LASTSEQUENCES, JSON.stringify(seqs));
|
|
343
376
|
|
|
344
377
|
case 6:
|
|
345
378
|
case "end":
|
|
346
|
-
return
|
|
379
|
+
return _context10.stop();
|
|
347
380
|
}
|
|
348
381
|
}
|
|
349
|
-
},
|
|
382
|
+
}, _callee10, this);
|
|
350
383
|
}));
|
|
351
384
|
|
|
352
|
-
function persistDoctypeLastSequence(
|
|
385
|
+
function persistDoctypeLastSequence(_x6, _x7) {
|
|
353
386
|
return _persistDoctypeLastSequence.apply(this, arguments);
|
|
354
387
|
}
|
|
355
388
|
|
|
@@ -362,25 +395,25 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
362
395
|
}, {
|
|
363
396
|
key: "getAllLastSequences",
|
|
364
397
|
value: function () {
|
|
365
|
-
var _getAllLastSequences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
398
|
+
var _getAllLastSequences = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11() {
|
|
366
399
|
var item;
|
|
367
|
-
return _regenerator.default.wrap(function
|
|
400
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
368
401
|
while (1) {
|
|
369
|
-
switch (
|
|
402
|
+
switch (_context11.prev = _context11.next) {
|
|
370
403
|
case 0:
|
|
371
|
-
|
|
404
|
+
_context11.next = 2;
|
|
372
405
|
return this.storageEngine.getItem(LOCALSTORAGE_STORAGE_KEYS.LASTSEQUENCES);
|
|
373
406
|
|
|
374
407
|
case 2:
|
|
375
|
-
item =
|
|
376
|
-
return
|
|
408
|
+
item = _context11.sent;
|
|
409
|
+
return _context11.abrupt("return", item ? JSON.parse(item) : {});
|
|
377
410
|
|
|
378
411
|
case 4:
|
|
379
412
|
case "end":
|
|
380
|
-
return
|
|
413
|
+
return _context11.stop();
|
|
381
414
|
}
|
|
382
415
|
}
|
|
383
|
-
},
|
|
416
|
+
}, _callee11, this);
|
|
384
417
|
}));
|
|
385
418
|
|
|
386
419
|
function getAllLastSequences() {
|
|
@@ -400,28 +433,28 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
400
433
|
}, {
|
|
401
434
|
key: "getDoctypeLastSequence",
|
|
402
435
|
value: function () {
|
|
403
|
-
var _getDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
436
|
+
var _getDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(doctype) {
|
|
404
437
|
var seqs;
|
|
405
|
-
return _regenerator.default.wrap(function
|
|
438
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
406
439
|
while (1) {
|
|
407
|
-
switch (
|
|
440
|
+
switch (_context12.prev = _context12.next) {
|
|
408
441
|
case 0:
|
|
409
|
-
|
|
442
|
+
_context12.next = 2;
|
|
410
443
|
return this.getAllLastSequences();
|
|
411
444
|
|
|
412
445
|
case 2:
|
|
413
|
-
seqs =
|
|
414
|
-
return
|
|
446
|
+
seqs = _context12.sent;
|
|
447
|
+
return _context12.abrupt("return", seqs[doctype]);
|
|
415
448
|
|
|
416
449
|
case 4:
|
|
417
450
|
case "end":
|
|
418
|
-
return
|
|
451
|
+
return _context12.stop();
|
|
419
452
|
}
|
|
420
453
|
}
|
|
421
|
-
},
|
|
454
|
+
}, _callee12, this);
|
|
422
455
|
}));
|
|
423
456
|
|
|
424
|
-
function getDoctypeLastSequence(
|
|
457
|
+
function getDoctypeLastSequence(_x8) {
|
|
425
458
|
return _getDoctypeLastSequence.apply(this, arguments);
|
|
426
459
|
}
|
|
427
460
|
|
|
@@ -436,20 +469,20 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
436
469
|
}, {
|
|
437
470
|
key: "destroyAllDoctypeLastSequence",
|
|
438
471
|
value: function () {
|
|
439
|
-
var _destroyAllDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
440
|
-
return _regenerator.default.wrap(function
|
|
472
|
+
var _destroyAllDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13() {
|
|
473
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
441
474
|
while (1) {
|
|
442
|
-
switch (
|
|
475
|
+
switch (_context13.prev = _context13.next) {
|
|
443
476
|
case 0:
|
|
444
|
-
|
|
477
|
+
_context13.next = 2;
|
|
445
478
|
return this.storageEngine.removeItem(LOCALSTORAGE_STORAGE_KEYS.LASTSEQUENCES);
|
|
446
479
|
|
|
447
480
|
case 2:
|
|
448
481
|
case "end":
|
|
449
|
-
return
|
|
482
|
+
return _context13.stop();
|
|
450
483
|
}
|
|
451
484
|
}
|
|
452
|
-
},
|
|
485
|
+
}, _callee13, this);
|
|
453
486
|
}));
|
|
454
487
|
|
|
455
488
|
function destroyAllDoctypeLastSequence() {
|
|
@@ -469,30 +502,30 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
469
502
|
}, {
|
|
470
503
|
key: "destroyDoctypeLastSequence",
|
|
471
504
|
value: function () {
|
|
472
|
-
var _destroyDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
505
|
+
var _destroyDoctypeLastSequence = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(doctype) {
|
|
473
506
|
var seqs;
|
|
474
|
-
return _regenerator.default.wrap(function
|
|
507
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
475
508
|
while (1) {
|
|
476
|
-
switch (
|
|
509
|
+
switch (_context14.prev = _context14.next) {
|
|
477
510
|
case 0:
|
|
478
|
-
|
|
511
|
+
_context14.next = 2;
|
|
479
512
|
return this.getAllLastSequences();
|
|
480
513
|
|
|
481
514
|
case 2:
|
|
482
|
-
seqs =
|
|
515
|
+
seqs = _context14.sent;
|
|
483
516
|
delete seqs[doctype];
|
|
484
|
-
|
|
517
|
+
_context14.next = 6;
|
|
485
518
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.LASTSEQUENCES, JSON.stringify(seqs));
|
|
486
519
|
|
|
487
520
|
case 6:
|
|
488
521
|
case "end":
|
|
489
|
-
return
|
|
522
|
+
return _context14.stop();
|
|
490
523
|
}
|
|
491
524
|
}
|
|
492
|
-
},
|
|
525
|
+
}, _callee14, this);
|
|
493
526
|
}));
|
|
494
527
|
|
|
495
|
-
function destroyDoctypeLastSequence(
|
|
528
|
+
function destroyDoctypeLastSequence(_x9) {
|
|
496
529
|
return _destroyDoctypeLastSequence.apply(this, arguments);
|
|
497
530
|
}
|
|
498
531
|
|
|
@@ -509,23 +542,23 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
509
542
|
}, {
|
|
510
543
|
key: "persistWarmedUpQueries",
|
|
511
544
|
value: function () {
|
|
512
|
-
var _persistWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
513
|
-
return _regenerator.default.wrap(function
|
|
545
|
+
var _persistWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(warmedUpQueries) {
|
|
546
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
514
547
|
while (1) {
|
|
515
|
-
switch (
|
|
548
|
+
switch (_context15.prev = _context15.next) {
|
|
516
549
|
case 0:
|
|
517
|
-
|
|
550
|
+
_context15.next = 2;
|
|
518
551
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.WARMUPEDQUERIES, JSON.stringify(warmedUpQueries));
|
|
519
552
|
|
|
520
553
|
case 2:
|
|
521
554
|
case "end":
|
|
522
|
-
return
|
|
555
|
+
return _context15.stop();
|
|
523
556
|
}
|
|
524
557
|
}
|
|
525
|
-
},
|
|
558
|
+
}, _callee15, this);
|
|
526
559
|
}));
|
|
527
560
|
|
|
528
|
-
function persistWarmedUpQueries(
|
|
561
|
+
function persistWarmedUpQueries(_x10) {
|
|
529
562
|
return _persistWarmedUpQueries.apply(this, arguments);
|
|
530
563
|
}
|
|
531
564
|
|
|
@@ -540,34 +573,34 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
540
573
|
}, {
|
|
541
574
|
key: "getPersistedWarmedUpQueries",
|
|
542
575
|
value: function () {
|
|
543
|
-
var _getPersistedWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
576
|
+
var _getPersistedWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
|
|
544
577
|
var item;
|
|
545
|
-
return _regenerator.default.wrap(function
|
|
578
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
546
579
|
while (1) {
|
|
547
|
-
switch (
|
|
580
|
+
switch (_context16.prev = _context16.next) {
|
|
548
581
|
case 0:
|
|
549
|
-
|
|
582
|
+
_context16.next = 2;
|
|
550
583
|
return this.storageEngine.getItem(LOCALSTORAGE_STORAGE_KEYS.WARMUPEDQUERIES);
|
|
551
584
|
|
|
552
585
|
case 2:
|
|
553
|
-
item =
|
|
586
|
+
item = _context16.sent;
|
|
554
587
|
|
|
555
588
|
if (item) {
|
|
556
|
-
|
|
589
|
+
_context16.next = 5;
|
|
557
590
|
break;
|
|
558
591
|
}
|
|
559
592
|
|
|
560
|
-
return
|
|
593
|
+
return _context16.abrupt("return", {});
|
|
561
594
|
|
|
562
595
|
case 5:
|
|
563
|
-
return
|
|
596
|
+
return _context16.abrupt("return", JSON.parse(item));
|
|
564
597
|
|
|
565
598
|
case 6:
|
|
566
599
|
case "end":
|
|
567
|
-
return
|
|
600
|
+
return _context16.stop();
|
|
568
601
|
}
|
|
569
602
|
}
|
|
570
|
-
},
|
|
603
|
+
}, _callee16, this);
|
|
571
604
|
}));
|
|
572
605
|
|
|
573
606
|
function getPersistedWarmedUpQueries() {
|
|
@@ -585,20 +618,20 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
585
618
|
}, {
|
|
586
619
|
key: "destroyWarmedUpQueries",
|
|
587
620
|
value: function () {
|
|
588
|
-
var _destroyWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
589
|
-
return _regenerator.default.wrap(function
|
|
621
|
+
var _destroyWarmedUpQueries = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
|
|
622
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
590
623
|
while (1) {
|
|
591
|
-
switch (
|
|
624
|
+
switch (_context17.prev = _context17.next) {
|
|
592
625
|
case 0:
|
|
593
|
-
|
|
626
|
+
_context17.next = 2;
|
|
594
627
|
return this.storageEngine.removeItem(LOCALSTORAGE_STORAGE_KEYS.WARMUPEDQUERIES);
|
|
595
628
|
|
|
596
629
|
case 2:
|
|
597
630
|
case "end":
|
|
598
|
-
return
|
|
631
|
+
return _context17.stop();
|
|
599
632
|
}
|
|
600
633
|
}
|
|
601
|
-
},
|
|
634
|
+
}, _callee17, this);
|
|
602
635
|
}));
|
|
603
636
|
|
|
604
637
|
function destroyWarmedUpQueries() {
|
|
@@ -616,23 +649,23 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
616
649
|
}, {
|
|
617
650
|
key: "getAdapterName",
|
|
618
651
|
value: function () {
|
|
619
|
-
var _getAdapterName = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
620
|
-
return _regenerator.default.wrap(function
|
|
652
|
+
var _getAdapterName = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
653
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
621
654
|
while (1) {
|
|
622
|
-
switch (
|
|
655
|
+
switch (_context18.prev = _context18.next) {
|
|
623
656
|
case 0:
|
|
624
|
-
|
|
657
|
+
_context18.next = 2;
|
|
625
658
|
return this.storageEngine.getItem(LOCALSTORAGE_STORAGE_KEYS.ADAPTERNAME);
|
|
626
659
|
|
|
627
660
|
case 2:
|
|
628
|
-
return
|
|
661
|
+
return _context18.abrupt("return", _context18.sent);
|
|
629
662
|
|
|
630
663
|
case 3:
|
|
631
664
|
case "end":
|
|
632
|
-
return
|
|
665
|
+
return _context18.stop();
|
|
633
666
|
}
|
|
634
667
|
}
|
|
635
|
-
},
|
|
668
|
+
}, _callee18, this);
|
|
636
669
|
}));
|
|
637
670
|
|
|
638
671
|
function getAdapterName() {
|
|
@@ -652,23 +685,23 @@ var PouchLocalStorage = /*#__PURE__*/function () {
|
|
|
652
685
|
}, {
|
|
653
686
|
key: "persistAdapterName",
|
|
654
687
|
value: function () {
|
|
655
|
-
var _persistAdapterName = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
656
|
-
return _regenerator.default.wrap(function
|
|
688
|
+
var _persistAdapterName = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(adapter) {
|
|
689
|
+
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
657
690
|
while (1) {
|
|
658
|
-
switch (
|
|
691
|
+
switch (_context19.prev = _context19.next) {
|
|
659
692
|
case 0:
|
|
660
|
-
|
|
693
|
+
_context19.next = 2;
|
|
661
694
|
return this.storageEngine.setItem(LOCALSTORAGE_STORAGE_KEYS.ADAPTERNAME, adapter);
|
|
662
695
|
|
|
663
696
|
case 2:
|
|
664
697
|
case "end":
|
|
665
|
-
return
|
|
698
|
+
return _context19.stop();
|
|
666
699
|
}
|
|
667
700
|
}
|
|
668
|
-
},
|
|
701
|
+
}, _callee19, this);
|
|
669
702
|
}));
|
|
670
703
|
|
|
671
|
-
function persistAdapterName(
|
|
704
|
+
function persistAdapterName(_x11) {
|
|
672
705
|
return _persistAdapterName.apply(this, arguments);
|
|
673
706
|
}
|
|
674
707
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-pouch-link",
|
|
3
|
-
"version": "60.
|
|
3
|
+
"version": "60.10.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"typecheck": "tsc -p tsconfig.json"
|
|
42
42
|
},
|
|
43
43
|
"sideEffects": false,
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "5f378a0a86e81b803b23b3b5d4d1d47abcaa76c6"
|
|
45
45
|
}
|
package/types/localStorage.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export namespace LOCALSTORAGE_STORAGE_KEYS {
|
|
|
4
4
|
const LASTSEQUENCES: string;
|
|
5
5
|
const LASTREPLICATEDDOCID: string;
|
|
6
6
|
const ADAPTERNAME: string;
|
|
7
|
+
const DB_NAMES: string;
|
|
7
8
|
}
|
|
8
9
|
export class PouchLocalStorage {
|
|
9
10
|
constructor(storageEngine: any);
|
|
@@ -14,6 +15,13 @@ export class PouchLocalStorage {
|
|
|
14
15
|
* @returns {Promise<void>}
|
|
15
16
|
*/
|
|
16
17
|
destroy(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Persist the databases names
|
|
20
|
+
*
|
|
21
|
+
* @param {Array<string>} dbNames - The db names
|
|
22
|
+
* @returns {Promise<void>}
|
|
23
|
+
*/
|
|
24
|
+
persistDatabasesNames(dbNames: Array<string>): Promise<void>;
|
|
17
25
|
/**
|
|
18
26
|
* Persist the last replicated doc id for a doctype
|
|
19
27
|
*
|