@oracle/offline-persistence-toolkit
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -5,3 +5,3 @@ (function(){ | ||
{ | ||
'opt/offline-persistence-toolkit-core-1.1.3': [ | ||
'opt/offline-persistence-toolkit-core-1.1.4': [ | ||
'persistenceUtils', | ||
@@ -18,3 +18,3 @@ 'impl/logger', | ||
], | ||
'opt/offline-persistence-toolkit-pouchdbstore-1.1.3': [ | ||
'opt/offline-persistence-toolkit-pouchdbstore-1.1.4': [ | ||
'PersistenceStore', | ||
@@ -27,3 +27,3 @@ 'impl/storageUtils', | ||
], | ||
'opt/offline-persistence-toolkit-localstore-1.1.3': [ | ||
'opt/offline-persistence-toolkit-localstore-1.1.4': [ | ||
'PersistenceStore', | ||
@@ -36,3 +36,3 @@ 'impl/storageUtils', | ||
], | ||
'opt/offline-persistence-toolkit-filesystemstore-1.1.3': [ | ||
'opt/offline-persistence-toolkit-filesystemstore-1.1.4': [ | ||
'impl/storageUtils', | ||
@@ -43,3 +43,3 @@ 'impl/keyValuePersistenceStore', | ||
], | ||
'opt/offline-persistence-toolkit-responseproxy-1.1.3': [ | ||
'opt/offline-persistence-toolkit-responseproxy-1.1.4': [ | ||
'fetchStrategies', | ||
@@ -46,0 +46,0 @@ 'cacheStrategies', |
@@ -25,12 +25,15 @@ /** | ||
this._db = new PouchDB(dbname); | ||
this._index = (options && options.index) ? options.index : null; | ||
return this._createIndex(); | ||
}; | ||
if (!options || !options.index) { | ||
PouchDBPersistenceStore.prototype._createIndex = function () { | ||
if (!this._index || !this._db.createIndex) { | ||
return Promise.resolve(); | ||
} else { | ||
var self = this; | ||
var indexArray = options.index; | ||
var indexName = self._name + indexArray.toString().replace(",", "").replace(".",""); | ||
var indexName = self._name + self._index.toString().replace(",", "").replace(".",""); | ||
var indexSyntax = { | ||
index: { | ||
fields: indexArray, | ||
fields: self._index, | ||
name: indexName | ||
@@ -40,9 +43,3 @@ } | ||
// createIndex if using the find plugin | ||
if (self._db.createIndex) { | ||
return self._db.createIndex(indexSyntax).then(function () { | ||
return Promise.resolve(); | ||
}); | ||
} else { | ||
return Promise.resolve(); | ||
} | ||
return self._db.createIndex(indexSyntax); | ||
} | ||
@@ -301,13 +298,6 @@ }; | ||
} else { | ||
return self._db.allDocs({include_docs: true}).then(function (result) { | ||
if (result && result.rows && result.rows.length) { | ||
var promises = result.rows.map(function (element) { | ||
this._db.remove(element.doc); | ||
}, self); | ||
return Promise.all(promises); | ||
} else { | ||
return Promise.resolve(); | ||
} | ||
}).then(function () { | ||
return Promise.resolve(); | ||
return self._db.destroy().then(function () { | ||
var dbname = self._name + self._version; | ||
self._db = new PouchDB(dbname); | ||
return self._createIndex(); | ||
}); | ||
@@ -314,0 +304,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(){requirejs.config({bundles:{"opt/offline-persistence-toolkit-core-1.1.3":["persistenceUtils","impl/logger","impl/PersistenceXMLHttpRequest","persistenceStoreManager","impl/defaultCacheHandler","impl/PersistenceSyncManager","impl/OfflineCache","impl/offlineCacheManager","impl/fetch","persistenceManager"],"opt/offline-persistence-toolkit-pouchdbstore-1.1.3":["PersistenceStore","impl/storageUtils","pouchdb-browser-6.3.4","impl/pouchDBPersistenceStore","pouchDBPersistenceStoreFactory","persistenceStoreFactory"],"opt/offline-persistence-toolkit-localstore-1.1.3":["PersistenceStore","impl/storageUtils","impl/keyValuePersistenceStore","impl/localPersistenceStore","localPersistenceStoreFactory","persistenceStoreFactory"],"opt/offline-persistence-toolkit-filesystemstore-1.1.3":["impl/storageUtils","impl/keyValuePersistenceStore","impl/fileSystemPersistenceStore","fileSystemPersistenceStoreFactory"],"opt/offline-persistence-toolkit-responseproxy-1.1.3":["fetchStrategies","cacheStrategies","defaultResponseProxy","simpleJsonShredding","oracleRestJsonShredding","simpleBinaryDataShredding","queryHandlers"]}})}(); | ||
!function(){requirejs.config({bundles:{"opt/offline-persistence-toolkit-core-1.1.4":["persistenceUtils","impl/logger","impl/PersistenceXMLHttpRequest","persistenceStoreManager","impl/defaultCacheHandler","impl/PersistenceSyncManager","impl/OfflineCache","impl/offlineCacheManager","impl/fetch","persistenceManager"],"opt/offline-persistence-toolkit-pouchdbstore-1.1.4":["PersistenceStore","impl/storageUtils","pouchdb-browser-6.3.4","impl/pouchDBPersistenceStore","pouchDBPersistenceStoreFactory","persistenceStoreFactory"],"opt/offline-persistence-toolkit-localstore-1.1.4":["PersistenceStore","impl/storageUtils","impl/keyValuePersistenceStore","impl/localPersistenceStore","localPersistenceStoreFactory","persistenceStoreFactory"],"opt/offline-persistence-toolkit-filesystemstore-1.1.4":["impl/storageUtils","impl/keyValuePersistenceStore","impl/fileSystemPersistenceStore","fileSystemPersistenceStoreFactory"],"opt/offline-persistence-toolkit-responseproxy-1.1.4":["fetchStrategies","cacheStrategies","defaultResponseProxy","simpleJsonShredding","oracleRestJsonShredding","simpleBinaryDataShredding","queryHandlers"]}})}(); | ||
//# sourceMappingURL=bundles-config.js.map |
@@ -1,2 +0,2 @@ | ||
define(["../PersistenceStore","../impl/storageUtils","pouchdb","./logger"],function(a,b,c,d){"use strict";var e=function(b){a.call(this,b)};e.prototype=new a,e.prototype.Init=function(a){this._version=a&&a.version||"0";var b=this._name+this._version;if(this._db=new c(b),a&&a.index){var d=this,e=a.index,f=d._name+e.toString().replace(",","").replace(".",""),g={index:{fields:e,name:f}};return d._db.createIndex?d._db.createIndex(g).then(function(){return Promise.resolve()}):Promise.resolve()}return Promise.resolve()},e.prototype.upsert=function(a,b,c,e){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: upsert() for key: "+a);var g=this,h=a.toString(),i=[];return this._prepareUpsert(c,i),g._db.get(h).then(function(a){return f(e,a)?a:Promise.reject({status:409})}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve():Promise.reject(a)}).then(function(a){return g._put(h,b,c,e,i,a)}).then(function(){return Promise.resolve()})},e.prototype._put=function(a,b,c,d,e,g){var h={_id:a,metadata:b,value:c};g&&(h._rev=g._rev);var i=this;return i._db.put(h).then(function(a){return Promise.resolve(a)}).catch(function(b){return 409===b.status?i._db.get(a).then(function(a){return d?f(d,a)?Promise.resolve(a):Promise.reject({status:409}):Promise.resolve(a)}):Promise.reject(b)}).then(function(a){return i._addAttachments(a,e)}).then(function(){return Promise.resolve()})};var f=function(a,b){if(a){return b.metadata.versionIdentifier===a}return!0};return e.prototype._addAttachments=function(a,b){if(b&&b.length){var c=b.map(function(b){var c;return c=b.value instanceof Blob?b.value:new Blob([b.value]),this._db.putAttachment(a.id,b.path,a.rev,c,"binary")},this);return Promise.all(c)}return Promise.resolve()},e.prototype.upsertAll=function(a){if(d.log("Offline Persistence Toolkit pouchDBPersistenceStore: upsertAll()"),a&&a.length){var b=a.map(function(a){return this.upsert(a.key,a.metadata,a.value,a.expectedVersionIdentifier)},this);return Promise.all(b)}return Promise.resolve()},e.prototype.find=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: find() for expression: "+JSON.stringify(a));var c=this,e=c._prepareFind(a);return c._db.find?c._db.find(e).then(function(a){if(a&&a.docs&&a.docs.length){var b=a.docs.map(c._findResultCallback(e.fields),c);return Promise.all(b)}return Promise.resolve([])}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve([]):Promise.reject(a)}):c._db.allDocs({include_docs:!0}).then(function(d){if(d&&d.rows&&d.rows.length){var f=d.rows.filter(function(c){return!!b.satisfy(a.selector,c.doc)}),g=f.map(function(a){return c._findResultCallback(e.fields).bind(c)(a.doc)});return Promise.all(g)}return Promise.resolve([])})},e.prototype._findResultCallback=function(a){return function(b){return this._fixValue(b).then(function(b){return a?b:b.value})}},e.prototype._fixValue=function(a){var b=a._id||a.id||a.key;b&&(a.key=b);var c=a._attachments;if(c){var d=this,e=Object.keys(c)[0];return d._db.getAttachment(b,e).then(function(b){for(var c=e.split("."),d=a.value,f=0;f<c.length-1;f++)d=d[c[f]];return d[c[c.length-1]]=b,a})}return Promise.resolve(a)},e.prototype.findByKey=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: findByKey() for key: "+a);var b=this,c=a.toString();return b._db.get(c).then(function(a){return a.value}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve():Promise.reject(a)})},e.prototype.removeByKey=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: removeByKey() for key: "+a);var b=this,c=a.toString();return b._db.get(c).then(function(a){return b._db.remove(a)}).then(function(){return!0}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve(!1):Promise.reject(a)})},e.prototype.delete=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: delete() for expression: "+JSON.stringify(a));var b=this;if(a){var c=a;return c.fields=["_id","_rev"],b.find(c).then(function(a){if(a&&a.length){var c=a.map(function(a){return this._db.remove(a._id,a._rev)},b);return Promise.all(c)}return Promise.resolve()}).then(function(){return Promise.resolve()})}return b._db.allDocs({include_docs:!0}).then(function(a){if(a&&a.rows&&a.rows.length){var c=a.rows.map(function(a){this._db.remove(a.doc)},b);return Promise.all(c)}return Promise.resolve()}).then(function(){return Promise.resolve()})},e.prototype.keys=function(){return d.log("Offline Persistence Toolkit pouchDBPersistenceStore: keys()"),this._db.allDocs().then(function(a){var b=a.rows,c=[];return b&&b.length&&(c=b.map(function(a){return a.id})),c})},e.prototype._prepareFind=function(a){var b=a||{};void 0!==b.sort&&delete b.sort,b.selector||(b.selector={_id:{$gt:null}});var c=b.fields;if(c&&c.length){var d=c.map(function(a){return"key"===a?"_id":a});b.fields=d}return b},e.prototype._prepareUpsert=function(a,b){this._inspectValue("",a,b)},e.prototype._inspectValue=function(a,b,c){for(var d in b)if(b.hasOwnProperty(d)){var e=b[d];if(e&&"object"==typeof e)if(e instanceof Blob||e instanceof ArrayBuffer){var f=a;f.length>0&&(f+=".");var g={path:f+d,value:e};c.push(g),b.key=null}else if(void 0===e.length){var h=a;a.length>0&&(a+="."),a+=d,this._inspectValue(a,e,c),a=h}}},e}); | ||
define(["../PersistenceStore","../impl/storageUtils","pouchdb","./logger"],function(a,b,c,d){"use strict";var e=function(b){a.call(this,b)};e.prototype=new a,e.prototype.Init=function(a){this._version=a&&a.version||"0";var b=this._name+this._version;return this._db=new c(b),this._index=a&&a.index?a.index:null,this._createIndex()},e.prototype._createIndex=function(){if(this._index&&this._db.createIndex){var a=this,b=a._name+a._index.toString().replace(",","").replace(".",""),c={index:{fields:a._index,name:b}};return a._db.createIndex(c)}return Promise.resolve()},e.prototype.upsert=function(a,b,c,e){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: upsert() for key: "+a);var g=this,h=a.toString(),i=[];return this._prepareUpsert(c,i),g._db.get(h).then(function(a){return f(e,a)?a:Promise.reject({status:409})}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve():Promise.reject(a)}).then(function(a){return g._put(h,b,c,e,i,a)}).then(function(){return Promise.resolve()})},e.prototype._put=function(a,b,c,d,e,g){var h={_id:a,metadata:b,value:c};g&&(h._rev=g._rev);var i=this;return i._db.put(h).then(function(a){return Promise.resolve(a)}).catch(function(b){return 409===b.status?i._db.get(a).then(function(a){return d?f(d,a)?Promise.resolve(a):Promise.reject({status:409}):Promise.resolve(a)}):Promise.reject(b)}).then(function(a){return i._addAttachments(a,e)}).then(function(){return Promise.resolve()})};var f=function(a,b){if(a){return b.metadata.versionIdentifier===a}return!0};return e.prototype._addAttachments=function(a,b){if(b&&b.length){var c=b.map(function(b){var c;return c=b.value instanceof Blob?b.value:new Blob([b.value]),this._db.putAttachment(a.id,b.path,a.rev,c,"binary")},this);return Promise.all(c)}return Promise.resolve()},e.prototype.upsertAll=function(a){if(d.log("Offline Persistence Toolkit pouchDBPersistenceStore: upsertAll()"),a&&a.length){var b=a.map(function(a){return this.upsert(a.key,a.metadata,a.value,a.expectedVersionIdentifier)},this);return Promise.all(b)}return Promise.resolve()},e.prototype.find=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: find() for expression: "+JSON.stringify(a));var c=this,e=c._prepareFind(a);return c._db.find?c._db.find(e).then(function(a){if(a&&a.docs&&a.docs.length){var b=a.docs.map(c._findResultCallback(e.fields),c);return Promise.all(b)}return Promise.resolve([])}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve([]):Promise.reject(a)}):c._db.allDocs({include_docs:!0}).then(function(d){if(d&&d.rows&&d.rows.length){var f=d.rows.filter(function(c){return!!b.satisfy(a.selector,c.doc)}),g=f.map(function(a){return c._findResultCallback(e.fields).bind(c)(a.doc)});return Promise.all(g)}return Promise.resolve([])})},e.prototype._findResultCallback=function(a){return function(b){return this._fixValue(b).then(function(b){return a?b:b.value})}},e.prototype._fixValue=function(a){var b=a._id||a.id||a.key;b&&(a.key=b);var c=a._attachments;if(c){var d=this,e=Object.keys(c)[0];return d._db.getAttachment(b,e).then(function(b){for(var c=e.split("."),d=a.value,f=0;f<c.length-1;f++)d=d[c[f]];return d[c[c.length-1]]=b,a})}return Promise.resolve(a)},e.prototype.findByKey=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: findByKey() for key: "+a);var b=this,c=a.toString();return b._db.get(c).then(function(a){return a.value}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve():Promise.reject(a)})},e.prototype.removeByKey=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: removeByKey() for key: "+a);var b=this,c=a.toString();return b._db.get(c).then(function(a){return b._db.remove(a)}).then(function(){return!0}).catch(function(a){return 404===a.status&&"missing"===a.message?Promise.resolve(!1):Promise.reject(a)})},e.prototype.delete=function(a){d.log("Offline Persistence Toolkit pouchDBPersistenceStore: delete() for expression: "+JSON.stringify(a));var b=this;if(a){var e=a;return e.fields=["_id","_rev"],b.find(e).then(function(a){if(a&&a.length){var c=a.map(function(a){return this._db.remove(a._id,a._rev)},b);return Promise.all(c)}return Promise.resolve()}).then(function(){return Promise.resolve()})}return b._db.destroy().then(function(){var a=b._name+b._version;return b._db=new c(a),b._createIndex()})},e.prototype.keys=function(){return d.log("Offline Persistence Toolkit pouchDBPersistenceStore: keys()"),this._db.allDocs().then(function(a){var b=a.rows,c=[];return b&&b.length&&(c=b.map(function(a){return a.id})),c})},e.prototype._prepareFind=function(a){var b=a||{};void 0!==b.sort&&delete b.sort,b.selector||(b.selector={_id:{$gt:null}});var c=b.fields;if(c&&c.length){var d=c.map(function(a){return"key"===a?"_id":a});b.fields=d}return b},e.prototype._prepareUpsert=function(a,b){this._inspectValue("",a,b)},e.prototype._inspectValue=function(a,b,c){for(var d in b)if(b.hasOwnProperty(d)){var e=b[d];if(e&&"object"==typeof e)if(e instanceof Blob||e instanceof ArrayBuffer){var f=a;f.length>0&&(f+=".");var g={path:f+d,value:e};c.push(g),b.key=null}else if(void 0===e.length){var h=a;a.length>0&&(a+="."),a+=d,this._inspectValue(a,e,c),a=h}}},e}); | ||
//# sourceMappingURL=pouchDBPersistenceStore.js.map |
{ | ||
"name": "@oracle/offline-persistence-toolkit", | ||
"title": "Offline Persistence Toolkit", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Offline Persistence Toolkit by Oracle Corp.", | ||
@@ -6,0 +6,0 @@ "author": "oraclejet", |
@@ -1,2 +0,2 @@ | ||
# offline-persistence-toolkit 1.1.3 # | ||
# offline-persistence-toolkit 1.1.4 # | ||
@@ -61,3 +61,3 @@ offline-persistence-toolkit is a client-side JavaScript library that provides caching and offline support at the HTTP request layer. This support is transparent to the user and is done through the Fetch API and an XHR adapter. HTTP requests made while the client device is offline are captured for replay when connection to the server is restored. Additional capabilities include a persistent storage layer, synchronization manager, binary data support and various configuration APIs for customizing the default behavior. This framework can be used in both ServiceWorker and non-ServiceWorker contexts within web and hybrid mobile apps. | ||
paths: { | ||
'persist' : 'js/libs/persist/v1.1.3/min' | ||
'persist' : 'js/libs/persist/v1.1.4/min' | ||
@@ -67,7 +67,7 @@ // Other path mappings here | ||
``` | ||
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.1.3/min'` entry to the list of paths. | ||
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.1.4/min'` entry to the list of paths. | ||
You can choose the name of the paths prefix. That is, you can use a different value to the ‘persist’ value shown in the examples. | ||
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.1.3/min'`. | ||
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.1.4/min'`. | ||
@@ -88,3 +88,3 @@ The toolkit makes heavy use of the [Promise API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise "Promise API"). If you are targeting environments that do not support the Promise API, you will need to polyfill this feature. We recommend the [es6-promise polyfill](https://github.com/stefanpenner/es6-promise "es6-promise polyfill"). | ||
'pouchfind': 'js/libs/pouchdb.find', | ||
'persist' : 'js/libs/persist/v1.1.3/min' | ||
'persist' : 'js/libs/persist/v1.1.4/min' | ||
@@ -91,0 +91,0 @@ // Other path mappings here |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
4378114
64928