UNPKG

33.5 kBJavaScriptView Raw
1"use strict";
2
3var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4
5function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
7var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
8 return new (P || (P = Promise))(function (resolve, reject) {
9 function fulfilled(value) {
10 try {
11 step(generator.next(value));
12 } catch (e) {
13 reject(e);
14 }
15 }
16 function rejected(value) {
17 try {
18 step(generator.throw(value));
19 } catch (e) {
20 reject(e);
21 }
22 }
23 function step(result) {
24 result.done ? resolve(result.value) : new P(function (resolve) {
25 resolve(result.value);
26 }).then(fulfilled, rejected);
27 }
28 step((generator = generator.apply(thisArg, _arguments)).next());
29 });
30};
31var dexie_1 = require('dexie');
32var typestore_1 = require('typestore');
33var IndexedDBRepoPlugin_1 = require("./IndexedDBRepoPlugin");
34var log = typestore_1.Log.create(__filename);
35/**
36 * Default options
37 */
38exports.LocalStorageOptionDefaults = {
39 databaseName: 'typestore-db',
40 version: 1
41};
42/**
43 * Uses dexie under the covers - its a mature library - and i'm lazy
44 */
45
46var IndexedDBPlugin = function () {
47 function IndexedDBPlugin() {
48 var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
49
50 _classCallCheck(this, IndexedDBPlugin);
51
52 this.opts = opts;
53 this.type = typestore_1.PluginType.Store;
54 this.repoPlugins = {};
55 this.opts = Object.assign({}, exports.LocalStorageOptionDefaults, opts);
56
57 for (var _len = arguments.length, supportedModels = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
58 supportedModels[_key - 1] = arguments[_key];
59 }
60
61 this.supportedModels = supportedModels;
62 }
63
64 _createClass(IndexedDBPlugin, [{
65 key: 'newDexie',
66 value: function newDexie() {
67 return new dexie_1.default(this.opts.databaseName, this.opts.provider);
68 }
69 }, {
70 key: 'open',
71 value: function open() {
72 this.internalDb = this.newDexie();
73 return this.internalDb;
74 }
75 }, {
76 key: 'handle',
77 value: function handle(eventType) {
78 switch (eventType) {
79 case typestore_1.PluginEventType.RepoInit:
80 return typestore_1.repoAttachIfSupported(arguments.length <= 1 ? undefined : arguments[1], this);
81 }
82 return false;
83 }
84 }, {
85 key: 'table',
86 value: function table(modelType) {
87 var table = this.tables[modelType.name];
88 if (!table) throw new Error('Unable to find a table definition for ' + modelType.name);
89 return table;
90 }
91 }, {
92 key: 'init',
93 value: function init(coordinator, opts) {
94 return __awaiter(this, void 0, void 0, regeneratorRuntime.mark(function _callee() {
95 return regeneratorRuntime.wrap(function _callee$(_context) {
96 while (1) {
97 switch (_context.prev = _context.next) {
98 case 0:
99 this.coordinator = coordinator;
100 return _context.abrupt('return', coordinator);
101
102 case 2:
103 case 'end':
104 return _context.stop();
105 }
106 }
107 }, _callee, this);
108 }));
109 }
110 }, {
111 key: 'start',
112 value: function start() {
113 return __awaiter(this, void 0, void 0, regeneratorRuntime.mark(function _callee2() {
114 var _this = this;
115
116 var models, schemaAttrNameMap, schema,
117 // Check for an existing database, version, schema
118 version;
119 return regeneratorRuntime.wrap(function _callee2$(_context2) {
120 while (1) {
121 switch (_context2.prev = _context2.next) {
122 case 0:
123 models = this.coordinator.getModels();
124 // 1. Create the current schema config
125 // TODO: Should only use indexed attributes for schema
126
127 schemaAttrNameMap = {};
128 schema = models.reduce(function (newSchema, modelType) {
129 // Get all the known attributes for the table
130 var attrs = modelType.options.attrs.filter(function (attr) {
131 return !attr.transient;
132 });
133 schemaAttrNameMap[modelType.name] = attrs.map(function (attr) {
134 return attr.name;
135 });
136 var attrDescs = attrs.map(function (attr) {
137 var index = attr.index;
138 var name = attr.name;
139 var primaryKey = attr.primaryKey;
140 var isArray = attr.isArray;var unique = primaryKey || index && index.unique;var prefix = unique ? '&' : isArray ? '*' : '';
141 return '' + prefix + name;
142 });
143 // Added the attribute descriptor to the new schema
144 newSchema[modelType.name] = attrDescs.join(',');
145 log.debug('Created schema for ' + modelType.name, newSchema[modelType.name]);
146 return newSchema;
147 }, {});
148 version = this.opts.version;
149 _context2.next = 6;
150 return new Promise(function (resolve, reject) {
151 var db = _this.newDexie();
152 db.open().then(function () {
153 log.info('Opened existing database', db.name, ' with existing version ', db.verno);
154 var tables = db.tables,
155 tableNames = tables.map(function (table) {
156 return table.name;
157 }),
158 newTableNames = Object.keys(schema),
159
160 // New table defined
161 newTable = !newTableNames.every(function (tableName) {
162 return tableNames.includes(tableName);
163 }),
164
165 // Table removed??
166 removedTable = !tableNames.every(function (tableName) {
167 return newTableNames.includes(tableName);
168 });
169 var attrChanged = false;
170 // If no new tables then check indexes
171 if (!newTable && !removedTable) {
172 var _iteratorNormalCompletion = true;
173 var _didIteratorError = false;
174 var _iteratorError = undefined;
175
176 try {
177 var _loop = function _loop() {
178 var table = _step.value;
179 var newAttrNames = schemaAttrNameMap[table.name];var _table$schema = table.schema;
180 var indexes = _table$schema.indexes;
181 var primKey = _table$schema.primKey;var oldAttrNames = indexes.map(function (index) {
182 return index.name;
183 }).concat([primKey.name]);
184 if (newAttrNames.length !== oldAttrNames.length || !oldAttrNames.every(function (attrName) {
185 return newAttrNames.includes(attrName);
186 })) {
187 log.info('Attributes have changed on table, bumping version. New attrs ', newAttrNames, ' old attr names ', oldAttrNames);
188 attrChanged = true;
189 return 'break';
190 }
191 };
192
193 for (var _iterator = tables[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
194 var _ret = _loop();
195
196 if (_ret === 'break') break;
197 }
198 } catch (err) {
199 _didIteratorError = true;
200 _iteratorError = err;
201 } finally {
202 try {
203 if (!_iteratorNormalCompletion && _iterator.return) {
204 _iterator.return();
205 }
206 } finally {
207 if (_didIteratorError) {
208 throw _iteratorError;
209 }
210 }
211 }
212 }
213 if (attrChanged || newTable || removedTable) {
214 log.info('Schema changes detected, bumping version, everntually auto-upgrade', attrChanged, newTable, removedTable);
215 version = db.verno + 1;
216 }
217 log.debug('Closing db check');
218 db.close();
219 resolve(true);
220 }).catch('NoSuchDatabaseError', function (e) {
221 log.info('Database does not exist, creating: ', _this.opts.databaseName);
222 resolve(false);
223 }).catch(function (e) {
224 log.error("Unknown error", e);
225 reject(e);
226 });
227 });
228
229 case 6:
230 // Table needs to be created
231 log.debug('Creating schema', schema);
232 this.open().version(version).stores(schema);
233 _context2.next = 10;
234 return new Promise(function (resolve, reject) {
235 _this.internalDb.open().then(resolve).catch(reject);
236 });
237
238 case 10:
239 this.tables = models.reduce(function (newTables, modelType) {
240 newTables[modelType.name] = _this.internalDb.table(modelType.name);
241 return newTables;
242 }, {});
243 log.debug('IndexedDB store is ready');
244 return _context2.abrupt('return', this.coordinator);
245
246 case 13:
247 case 'end':
248 return _context2.stop();
249 }
250 }
251 }, _callee2, this);
252 }));
253 }
254 }, {
255 key: 'stop',
256 value: function stop() {
257 return __awaiter(this, void 0, void 0, regeneratorRuntime.mark(function _callee3() {
258 return regeneratorRuntime.wrap(function _callee3$(_context3) {
259 while (1) {
260 switch (_context3.prev = _context3.next) {
261 case 0:
262 if (!this.internalDb) {
263 _context3.next = 3;
264 break;
265 }
266
267 _context3.next = 3;
268 return this.internalDb.close();
269
270 case 3:
271 return _context3.abrupt('return', this.coordinator);
272
273 case 4:
274 case 'end':
275 return _context3.stop();
276 }
277 }
278 }, _callee3, this);
279 }));
280 }
281 }, {
282 key: 'syncModels',
283 value: function syncModels() {
284 log.debug('Currently the localstorage plugin does not sync models');
285 return Promise.resolve(this.coordinator);
286 }
287 /**
288 * Initialize a new repo
289 * TODO: verify this logic works - just reading it makes me think we could be
290 * asked to init a repo a second time with the same type and do nothing
291 *
292 * @param repo
293 * @returns {T}
294 */
295
296 }, {
297 key: 'initRepo',
298 value: function initRepo(repo) {
299 var plugin = this.repoPlugins[repo.modelType.name];
300 if (plugin) return plugin.repo;
301 plugin = new IndexedDBRepoPlugin_1.IndexedDBRepoPlugin(this, repo);
302 return plugin.repo;
303 }
304 }, {
305 key: 'db',
306 get: function get() {
307 return this.internalDb;
308 }
309 }]);
310
311 return IndexedDBPlugin;
312}();
313
314exports.IndexedDBPlugin = IndexedDBPlugin;
315//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIkluZGV4ZWREQlBsdWdpbi5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0FBQ0EsSUFBSSxZQUFhLGFBQVEsVUFBSyxTQUFkLElBQTRCLFVBQVUsT0FBVixFQUFtQixVQUFuQixFQUErQixDQUEvQixFQUFrQyxTQUFsQyxFQUE2QztBQUNyRixXQUFPLEtBQUssTUFBTSxJQUFJLE9BQVYsQ0FBTCxFQUF5QixVQUFVLE9BQVYsRUFBbUIsTUFBbkIsRUFBMkI7QUFDdkQsaUJBQVMsU0FBVCxDQUFtQixLQUFuQixFQUEwQjtBQUFFLGdCQUFJO0FBQUUscUJBQUssVUFBVSxJQUFWLENBQWUsS0FBZixDQUFMO0FBQThCLGFBQXBDLENBQXFDLE9BQU8sQ0FBUCxFQUFVO0FBQUUsdUJBQU8sQ0FBUDtBQUFZO0FBQUU7QUFDM0YsaUJBQVMsUUFBVCxDQUFrQixLQUFsQixFQUF5QjtBQUFFLGdCQUFJO0FBQUUscUJBQUssVUFBVSxLQUFWLENBQWdCLEtBQWhCLENBQUw7QUFBK0IsYUFBckMsQ0FBc0MsT0FBTyxDQUFQLEVBQVU7QUFBRSx1QkFBTyxDQUFQO0FBQVk7QUFBRTtBQUMzRixpQkFBUyxJQUFULENBQWMsTUFBZCxFQUFzQjtBQUFFLG1CQUFPLElBQVAsR0FBYyxRQUFRLE9BQU8sS0FBZixD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GUobW9kZWxUeXBlKSB7XG4gICAgICAgIGxldCB0YWJsZSA9IHRoaXMudGFibGVzW21vZGVsVHlwZS5uYW1lXTtcbiAgICAgICAgaWYgKCF0YWJsZSlcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcihgVW5hYmxlIHRvIGZpbmQgYSB0YWJsZSBkZWZpbml0aW9uIGZvciAke21vZGVsVHlwZS5uYW1lfWApO1xuICAgICAgICByZXR1cm4gdGFibGU7XG4gICAgfVxuICAgIGluaXQoY29vcmRpbmF0b3IsIG9wdHMpIHtcbiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHtcbiAgICAgICAgICAgIHRoaXMuY29vcmRpbmF0b3IgPSBjb29yZGluYXRvcjtcbiAgICAgICAgICAgIHJldHVybiBjb29yZGluYXRvcjtcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN0YXJ0KCkge1xuICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkge1xuICAgICAgICAgICAgY29uc3QgbW9kZWxzID0gdGhpcy5jb29yZGluYXRvci5nZXRNb2RlbHMoKTtcbiAgICAgICAgICAgIC8vIDEuIENyZWF0ZSB0aGUgY3VycmVudCBzY2hlbWEgY29uZmlnXG4gICAgICAgICAgICAvLyBUT0RPOiBTaG91bGQgb25seSB1c2UgaW5kZXhlZCBhdHRyaWJ1dGVzIGZvciBzY2hlbWFcbiAgICAgICAgICAgIGNvbnN0IHNjaGVtYUF0dHJOYW1lTWFwID0ge307XG4gICAgICAgICAgICBjb25zdCBzY2hlbWEgPSBtb2RlbHMucmVkdWNlKChuZXdTY2hlbWEsIG1vZGVsVHlwZSkgPT4ge1xuICAgICAgICAgICAgICAgIC8vIEdldCBhbGwgdGhlIGtub3duIGF0dHJpYnV0ZXMgZm9yIHRoZSB0YWJsZVxuICAgICAgICAgICAgICAgI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WJsZSAmJiAhcmVtb3ZlZFRhYmxlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGxldCB0YWJsZSBvZiB0YWJsZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBuZXdBdHRyTmFtZXMgPSBzY2hlbWFBdHRyTmFtZU1hcFt0YWJsZS5uYW1lXSwgeyBpbmRleGVzLCBwcmltS2V5IH0gPSB0YWJsZS5zY2hlbWEsIG9sZEF0dHJOYW1lcyA9IGluZGV4ZXMubWFwKGluZGV4ID0+IGluZGV4Lm5hbWUpLmNvbmNhdChbcHJpbUtleS5uYW1lXSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKG5ld0F0dHJOYW1lcy5sZW5ndGggIT09IG9sZEF0dHJOYW1lcy5sZW5ndGggfHwgIW9sZEF0dHJOYW1lcy5ldmVyeShhdHRyTmFtZSA9PiBuZXdBdHRyTmFtZXMuaW5jbHVkZXMoYXR0ck5hbWUpKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsb2cuaW5mbygnQXR0cmlidXRlcyBoYXZlIGNoYW5nZWQgb24gdGFibGUsIGJ1bXBpbmcgdmVyc2lvbi4gIE5ldyBhdHRycyAnLCBuZXdBdHRyTmFtZXMsICcgb2xkIGF0dHIgbmFtZXMgJywgb2xkQXR0ck5hbWVzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYXR0ckNoYW5nZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGF0dHJDaGFuZ2VkIHx8IG5ld1RhYmxlIHx8IHJlbW92ZWRUYWJsZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgbG9nLmluZm8oJ1NjaGVtYSBjaGFuZ2VzIGRldGVjdGVkLCBidW1waW5nIHZlcnNpb24sIGV2ZXJudHVhbGx5IGF1dG8tdXBncmFkZScsIGF0dHJDaGFuZ2VkLCBuZXdUYWJsZSwgcmVtb3ZlZFRhYmxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZlcnNpb24gPSBkYi52ZXJubyArIDE7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgbG9nLmRlYnVnKCdDbG9zaW5nIGRiIGNoZWNrJyk7XG4gICAgICAgICAgICAgICAgICAgIGRiLmNsb3NlKCk7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUodHJ1ZSk7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAgICAgLmNhdGNoKCdOb1N1Y2hEYXRhYmFzZUVycm9yJywgKGUpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgbG9nLmluZm8oJ0RhdGFiYXNlIGRvZXMgbm90IGV4aXN0LCBjcmVhdGluZzogJywgdGhpcy5vcHRzLmRhdGFiYXNlTmFtZSk7XG4gICAgICAgICAgICAgICAgICAgIHJlc29sdmUoZmFsc2UpO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgIC5jYXRjaCgoZSkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBsb2cuZXJyb3IoXCJVbmtub3duIGVycm9yXCIsIGUpO1xuICAgICAgICAgICAgICAgICAgICByZWplY3QoZSk7XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIC8vIFRhYmxlIG5lZWRzIHRvIGJlIGNyZWF0ZWRcbiAgICAgICAgICAgIGxvZy5kZWJ1ZyhgQ3JlYXRpbmcgc2NoZW1hYCwgc2NoZW1hKTtcbiAgICAgICAgICAgIHRoaXMub3BlbigpXG4gICAgICAgICAgICAgICAgLnZlcnNpb24odmVyc2lvbilcbiAgICAgICAgICAgICAgICAuc3RvcmVzKHNjaGVtYSk7XG4gICAgICAgICAgICB5aWVsZCBuZXcgUHJvbWlzZSgocmVzb2x2ZSwgcmVqZWN0KSA9PiB7XG4gICAgICAgICAgICAgICAgdGhpcy5pbnRlcm5hbERiLm9wZW4oKS50aGVuKHJlc29sdmUpLmNhdGNoKHJlamVjdCk7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIHRoaXMudGFibGVzID0gbW9kZWxzLnJlZHVjZSgobmV3VGFibGVzLCBtb2RlbFR5cGUpID0+IHtcbiAgICAgICAgICAgICAgICBuZXdUYWJsZXNbbW9kZWxUeXBlLm5hbWVdID0gdGhpcy5pbnRlcm5hbERiLnRhYmxlKG1vZGVsVHlwZS5uYW1lKTtcbiAgICAgICAgICAgICAgICByZXR1cm4gbmV3VGFibGVzO1xuICAgICAgICAgICAgfSwge30pO1xuICAgICAgICAgICAgbG9nLmRlYnVnKCdJbmRleGVkREIgc3RvcmUgaXMgcmVhZHknKTtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmNvb3JkaW5hdG9yO1xuICAgICAgICB9KTtcbiAgICB9XG4gICAgc3RvcCgpIHtcbiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHtcbiAgICAgICAgICAgIGlmICh0aGlzLmludGVybmFsRGIpXG4gICAgICAgICAgICAgICAgeWllbGQgdGhpcy5pbnRlcm5hbERiLmNsb3NlKCk7XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5jb29yZGluYXRvcjtcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHN5bmNNb2RlbHMoKSB7XG4gICAgICAgIGxvZy5kZWJ1ZygnQ3VycmVudGx5IHRoZSBsb2NhbHN0b3JhZ2UgcGx1Z2luIGRvZXMgbm90IHN5bmMgbW9kZWxzJyk7XG4gICAgICAgIHJldHVybiBQcm9taXNlLnJlc29sdmUodGhpcy5jb29yZGluYXRvcik7XG4gICAgfVxuICAgIC8qKlxuICAgICAqIEluaXRpYWxpemUgYSBuZXcgcmVwb1xuICAgICAqIFRPRE86IHZlcmlmeSB0aGlzIGxvZ2ljIHdvcmtzIC0ganVzdCByZWFkaW5nIGl0IG1ha2VzIG1lIHRoaW5rIHdlIGNvdWxkIGJlXG4gICAgICogIGFza2VkIHRvIGluaXQgYSByZXBvIGEgc2Vjb25kIHRpbWUgd2l0aCB0aGUgc2FtZSB0eXBlIGFuZCBkbyBub3RoaW5nXG4gICAgICpcbiAgICAgKiBAcGFyYW0gcmVwb1xuICAgICAqIEByZXR1cm5zIHtUfVxuICAgICAqL1xuICAgIGluaXRSZXBvKHJlcG8pIHtcbiAgICAgICAgbGV0IHBsdWdpbiA9IHRoaXMucmVwb1BsdWdpbnNbcmVwby5tb2RlbFR5cGUubmFtZV07XG4gICAgICAgIGlmIChwbHVnaW4pXG4gICAgICAgICAgICByZXR1cm4gcGx1Z2luLnJlcG87XG4gICAgICAgIHBsdWdpbiA9IG5ldyBJbmRleGVkREJSZXBvUGx1Z2luXzEuSW5kZXhlZERCUmVwb1BsdWdpbih0aGlzLCByZXBvKTtcbiAgICAgICAgcmV0dXJuIHBsdWdpbi5yZXBvO1xuICAgIH1cbn1cbmV4cG9ydHMuSW5kZXhlZERCUGx1Z2luID0gSW5kZXhlZERCUGx1Z2luO1xuIl19
316//# sourceMappingURL=IndexedDBPlugin.js.map