@oracle/offline-persistence-toolkit
Advanced tools
Comparing version 1.2.8 to 1.2.9
@@ -5,3 +5,3 @@ (function(){ | ||
{ | ||
'persist/offline-persistence-toolkit-core-1.2.8': [ | ||
'persist/offline-persistence-toolkit-core-1.2.9': [ | ||
'persist/persistenceUtils', | ||
@@ -18,3 +18,3 @@ 'persist/impl/logger', | ||
], | ||
'persist/offline-persistence-toolkit-pouchdbstore-1.2.8': [ | ||
'persist/offline-persistence-toolkit-pouchdbstore-1.2.9': [ | ||
'persist/PersistenceStore', | ||
@@ -27,3 +27,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-arraystore-1.2.8': [ | ||
'persist/offline-persistence-toolkit-arraystore-1.2.9': [ | ||
'persist/PersistenceStore', | ||
@@ -36,3 +36,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-localstore-1.2.8': [ | ||
'persist/offline-persistence-toolkit-localstore-1.2.9': [ | ||
'persist/PersistenceStore', | ||
@@ -45,3 +45,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-filesystemstore-1.2.8': [ | ||
'persist/offline-persistence-toolkit-filesystemstore-1.2.9': [ | ||
'persist/impl/storageUtils', | ||
@@ -52,3 +52,3 @@ 'persist/impl/keyValuePersistenceStore', | ||
], | ||
'persist/offline-persistence-toolkit-responseproxy-1.2.8': [ | ||
'persist/offline-persistence-toolkit-responseproxy-1.2.9': [ | ||
'persist/fetchStrategies', | ||
@@ -55,0 +55,0 @@ 'persist/cacheStrategies', |
@@ -538,2 +538,6 @@ /** | ||
if (request.method === 'DELETE') { | ||
if (!shreddedDataItem || shreddedDataItem.length === 0) { | ||
var deletedItemId = _getRequestUrlId(request); | ||
shreddedDataItem = [{key: deletedItemId}]; | ||
} | ||
return _updateShreddedDataStoreForDeleteRequest(storename, shreddedDataItem, undoRedoArray); | ||
@@ -546,2 +550,10 @@ } else { | ||
function _getRequestUrlId(request) { | ||
var urlTokens = request.url.split('/'); | ||
if (urlTokens.length > 1) { | ||
return urlTokens[urlTokens.length - 1].split('?')[0]; | ||
} | ||
return null; | ||
}; | ||
function _getUndoRedoDataForShreddedDataItem(request, storename, shreddedDataItem) { | ||
@@ -548,0 +560,0 @@ var undoRedoArray = []; |
@@ -80,3 +80,9 @@ /** | ||
if (storeageData) { | ||
return Promise.resolve(JSON.parse(storeageData)); | ||
try { | ||
var item = JSON.parse(storeageData); | ||
item.key = key; | ||
return Promise.resolve(item); | ||
} catch (err) { | ||
return Promise.resolve(); | ||
} | ||
} else { | ||
@@ -83,0 +89,0 @@ return Promise.resolve(); |
@@ -386,3 +386,10 @@ /** | ||
name: element.name, | ||
keys: element.keys, | ||
keys: element.keys ? element.keys.reduce(function(processedKeys, key) { | ||
if (key) { | ||
processedKeys.push(key.toString()); | ||
} else { | ||
logger.warn("should not have undefined key in the shredded data"); | ||
} | ||
return processedKeys; | ||
}, []) : element.keys, | ||
resourceType: element.resourceType | ||
@@ -389,0 +396,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(){requirejs.config({bundles:{"persist/offline-persistence-toolkit-core-1.2.8":["persist/persistenceUtils","persist/impl/logger","persist/impl/PersistenceXMLHttpRequest","persist/persistenceStoreManager","persist/impl/defaultCacheHandler","persist/impl/PersistenceSyncManager","persist/impl/OfflineCache","persist/impl/offlineCacheManager","persist/impl/fetch","persist/persistenceManager"],"persist/offline-persistence-toolkit-pouchdbstore-1.2.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/pouchdb-browser-7.0.0","persist/impl/pouchDBPersistenceStore","persist/pouchDBPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-arraystore-1.2.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/arrayPersistenceStore","persist/arrayPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-localstore-1.2.8":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/localPersistenceStore","persist/localPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-filesystemstore-1.2.8":["persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/fileSystemPersistenceStore","persist/fileSystemPersistenceStoreFactory"],"persist/offline-persistence-toolkit-responseproxy-1.2.8":["persist/fetchStrategies","persist/cacheStrategies","persist/defaultResponseProxy","persist/simpleJsonShredding","persist/oracleRestJsonShredding","persist/simpleBinaryDataShredding","persist/queryHandlers"]}})}(); | ||
!function(){requirejs.config({bundles:{"persist/offline-persistence-toolkit-core-1.2.9":["persist/persistenceUtils","persist/impl/logger","persist/impl/PersistenceXMLHttpRequest","persist/persistenceStoreManager","persist/impl/defaultCacheHandler","persist/impl/PersistenceSyncManager","persist/impl/OfflineCache","persist/impl/offlineCacheManager","persist/impl/fetch","persist/persistenceManager"],"persist/offline-persistence-toolkit-pouchdbstore-1.2.9":["persist/PersistenceStore","persist/impl/storageUtils","persist/pouchdb-browser-7.0.0","persist/impl/pouchDBPersistenceStore","persist/pouchDBPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-arraystore-1.2.9":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/arrayPersistenceStore","persist/arrayPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-localstore-1.2.9":["persist/PersistenceStore","persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/localPersistenceStore","persist/localPersistenceStoreFactory","persist/persistenceStoreFactory"],"persist/offline-persistence-toolkit-filesystemstore-1.2.9":["persist/impl/storageUtils","persist/impl/keyValuePersistenceStore","persist/impl/fileSystemPersistenceStore","persist/fileSystemPersistenceStoreFactory"],"persist/offline-persistence-toolkit-responseproxy-1.2.9":["persist/fetchStrategies","persist/cacheStrategies","persist/defaultResponseProxy","persist/simpleJsonShredding","persist/oracleRestJsonShredding","persist/simpleBinaryDataShredding","persist/queryHandlers"]}})}(); |
@@ -1,1 +0,1 @@ | ||
define(["./persistenceManager","./persistenceUtils","./fetchStrategies","./cacheStrategies","./persistenceStoreManager","./impl/defaultCacheHandler","./impl/logger"],function(a,b,c,d,e,f,g){"use strict";function h(a){a=a||{},null==a.fetchStrategy&&(a.fetchStrategy=c.getCacheIfOfflineStrategy()),null==a.cacheStrategy&&(a.cacheStrategy=d.getHttpCacheHeaderStrategy()),a.requestHandlerOverride=a.requestHandlerOverride||{},null==a.requestHandlerOverride.handleGet&&(a.requestHandlerOverride.handleGet=this.handleGet),null==a.requestHandlerOverride.handlePost&&(a.requestHandlerOverride.handlePost=this.handlePost),null==a.requestHandlerOverride.handlePut&&(a.requestHandlerOverride.handlePut=this.handlePut),null==a.requestHandlerOverride.handlePatch&&(a.requestHandlerOverride.handlePatch=this.handlePatch),null==a.requestHandlerOverride.handleDelete&&(a.requestHandlerOverride.handleDelete=this.handleDelete),null==a.requestHandlerOverride.handleHead&&(a.requestHandlerOverride.handleHead=this.handleHead),null==a.requestHandlerOverride.handleOptions&&(a.requestHandlerOverride.handleOptions=this.handleOptions),Object.defineProperty(this,"_options",{value:a})}function i(a){return new h(a)}function j(a,b){var c=a,d=c._options,e=null;return"POST"===b.method?e=d.requestHandlerOverride.handlePost:"GET"===b.method?e=d.requestHandlerOverride.handleGet:"PUT"===b.method?e=d.requestHandlerOverride.handlePut:"PATCH"===b.method?e=d.requestHandlerOverride.handlePatch:"DELETE"===b.method?e=d.requestHandlerOverride.handleDelete:"HEAD"===b.method?e=d.requestHandlerOverride.handleHead:"OPTIONS"===b.method&&(e=d.requestHandlerOverride.handleOptions),e}function k(b){if(a.isOnline())return a.browserFetch(b);var c={status:503,statusText:"Must provide handlePost override for offline"};return Promise.resolve(new Response(null,c))}function l(a,b){var c=a;return(0,c._options.fetchStrategy)(b,c._options)}function m(b,c){var d=b;return a.isOnline()?a.browserFetch(c.clone()).then(function(a){return a.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for default PUT Handler"),a):q(d,c,a,n)},function(a){return n(d,c)}):n(d,c)}function n(a,c){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing offline logic for default PUT Handler"),b.requestToJSON(c).then(function(a){a.status=200,a.statusText="OK",a.headers["content-type"]="application/json",a.headers["x-oracle-jscpt-cache-expiration-date"]="";var c=a.headers["if-match"],d=a.headers["if-none-match"];if(c||d){g.log("Offline Persistence Toolkit DefaultResponseProxy: Generating ETag for offline Response for default PUT Handler");var e=Math.floor(1e6*Math.random());a.headers.etag=(Date.now()+e).toString(),a.headers["x-oracle-jscpt-etag-generated"]=a.headers.etag,delete a.headers["if-match"],delete a.headers["if-none-match"]}return b.responseFromJSON(a)})}function o(b,c){var d=b;return a.isOnline()?a.browserFetch(c.clone()).then(function(a){return a.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for default DELETE Handler"),a):q(d,c,a,p)},function(a){return p(d,c)}):p(d,c)}function p(a,c){var d=a;return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing offline logic for default DELETE Handler"),b.requestToJSON(c).then(function(a){return a.status=200,a.statusText="OK",a.headers["content-type"]="application/json",a.headers["x-oracle-jscpt-cache-expiration-date"]="",b.responseFromJSON(a).then(function(f){var g=r(c),h=null;return d._options&&d._options.jsonProcessor&&d._options.jsonProcessor.shredder&&(h=d._options.jsonProcessor.shredder),h?h(f).then(function(c){if(c){var d=c[0].name;return e.openStore(d).then(function(c){return c.findByKey(g).then(function(c){return c?b.responseFromJSON(a).then(function(a){return b.setResponsePayload(a,c).then(function(a){return a})}):f})})}return f}):f})})}function q(a,b,c,d){var e=a;return c.status<500?Promise.resolve(c):d(e,b)}function r(a){var b=a.url.split("/");return b[b.length-1]}function s(a,b,c){var d=a;if("GET"===b.method||"HEAD"===b.method){return(0,d._options.cacheStrategy)(b,c,d._options)}return Promise.resolve(c)}function t(b,c,d){return!a.isOnline()||d?a.getSyncManager().insertRequest(b,{undoRedoDataArray:c}):Promise.resolve()}function u(a,b){return"GET"==a.method||"HEAD"==a.method?Promise.resolve():v(a,b)}function v(a,b){return f.constructShreddedData(a,b).then(function(b){return b?w(a,b):Promise.resolve()})}function w(a,b){var c=[];return b.forEach(function(b){var d=Object.keys(b)[0];c.push(x(a,d,b[d]))}),Promise.all(c)}function x(a,b,c){return y(a,b,c).then(function(d){return"DELETE"===a.method?A(b,c,d):z(b,c,d)})}function y(a,b,c){var d,f,g=[],h=function(c,i){return c<i.length&&"GET"!==a.method&&"HEAD"!==a.method?(d=i[c].key.toString(),f="DELETE"!==a.method?i[c].value:null,e.openStore(b).then(function(a){return a.findByKey(d).then(function(a){return g.push({key:d,undo:a,redo:f}),h(++c,i)},function(a){return g.push({key:d,undo:null,redo:f}),h(++c,i)})})):Promise.resolve(g)};return h(0,c)}function z(a,b,c){return e.openStore(a).then(function(a){return a.upsertAll(b)}).then(function(){return c.length>0?{storeName:a,operation:"upsert",undoRedoData:c}:null})}function A(a,b,c){return e.openStore(a).then(function(a){return a.removeByKey(b[0].key)}).then(function(){return c.length>0?{storeName:a,operation:"remove",undoRedoData:c}:null})}return h.prototype.getFetchEventListener=function(){var a=this;return function(b){b.respondWith(a.processRequest(b.request))}},h.prototype.processRequest=function(a){var c=this,d=b.buildEndpointKey(a);return new Promise(function(e,h){f.registerEndpointOptions(d,c._options);var i=j(c,a),k={},l=a.clone();g.log("Offline Persistence Toolkit DefaultResponseProxy: Calling requestHandler for request with enpointKey: "+d),i.call(c,a).then(function(e){return b.isCachedResponse(e)&&(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is cached for request with enpointKey: "+d),k.isCachedResponse=!0),e.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for request with enpointKey: "+d),s(c,a,e)):(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is not ok for request with enpointKey: "+d),e)}).then(function(b){return k.response=b,b.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok after cacheStrategy for request with enpointKey: "+d),u(a,b)):(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is not ok after cacheStrategy for request with enpointKey: "+d),null)}).then(function(b){return t(a,b,k.isCachedResponse)}).then(function(){f.unregisterEndpointOptions(d),e(k.response)}).catch(function(a){g.log("Offline Persistence Toolkit DefaultResponseProxy: Insert Response in syncManager after error for request with enpointKey: "+d),t(l,null,!0).then(function(){f.unregisterEndpointOptions(d),h(a)},function(){f.unregisterEndpointOptions(d),h(a)})})})},h.prototype.handlePost=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default POST Handler"),k(a)},h.prototype.handleGet=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default GET Handler"),l(this,a)},h.prototype.handleHead=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default HEAD Handler"),l(this,a)},h.prototype.handleOptions=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default OPTIONS Handler"),k(a)},h.prototype.handlePut=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default PUT Handler"),m(this,a)},h.prototype.handlePatch=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default PATCH Handler"),k(a)},h.prototype.handleDelete=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default DELETE Handler"),o(this,a)},{getResponseProxy:i}}); | ||
define(["./persistenceManager","./persistenceUtils","./fetchStrategies","./cacheStrategies","./persistenceStoreManager","./impl/defaultCacheHandler","./impl/logger"],function(a,b,c,d,e,f,g){"use strict";function h(a){a=a||{},null==a.fetchStrategy&&(a.fetchStrategy=c.getCacheIfOfflineStrategy()),null==a.cacheStrategy&&(a.cacheStrategy=d.getHttpCacheHeaderStrategy()),a.requestHandlerOverride=a.requestHandlerOverride||{},null==a.requestHandlerOverride.handleGet&&(a.requestHandlerOverride.handleGet=this.handleGet),null==a.requestHandlerOverride.handlePost&&(a.requestHandlerOverride.handlePost=this.handlePost),null==a.requestHandlerOverride.handlePut&&(a.requestHandlerOverride.handlePut=this.handlePut),null==a.requestHandlerOverride.handlePatch&&(a.requestHandlerOverride.handlePatch=this.handlePatch),null==a.requestHandlerOverride.handleDelete&&(a.requestHandlerOverride.handleDelete=this.handleDelete),null==a.requestHandlerOverride.handleHead&&(a.requestHandlerOverride.handleHead=this.handleHead),null==a.requestHandlerOverride.handleOptions&&(a.requestHandlerOverride.handleOptions=this.handleOptions),Object.defineProperty(this,"_options",{value:a})}function i(a){return new h(a)}function j(a,b){var c=a,d=c._options,e=null;return"POST"===b.method?e=d.requestHandlerOverride.handlePost:"GET"===b.method?e=d.requestHandlerOverride.handleGet:"PUT"===b.method?e=d.requestHandlerOverride.handlePut:"PATCH"===b.method?e=d.requestHandlerOverride.handlePatch:"DELETE"===b.method?e=d.requestHandlerOverride.handleDelete:"HEAD"===b.method?e=d.requestHandlerOverride.handleHead:"OPTIONS"===b.method&&(e=d.requestHandlerOverride.handleOptions),e}function k(b){if(a.isOnline())return a.browserFetch(b);var c={status:503,statusText:"Must provide handlePost override for offline"};return Promise.resolve(new Response(null,c))}function l(a,b){var c=a;return(0,c._options.fetchStrategy)(b,c._options)}function m(b,c){var d=b;return a.isOnline()?a.browserFetch(c.clone()).then(function(a){return a.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for default PUT Handler"),a):q(d,c,a,n)},function(a){return n(d,c)}):n(d,c)}function n(a,c){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing offline logic for default PUT Handler"),b.requestToJSON(c).then(function(a){a.status=200,a.statusText="OK",a.headers["content-type"]="application/json",a.headers["x-oracle-jscpt-cache-expiration-date"]="";var c=a.headers["if-match"],d=a.headers["if-none-match"];if(c||d){g.log("Offline Persistence Toolkit DefaultResponseProxy: Generating ETag for offline Response for default PUT Handler");var e=Math.floor(1e6*Math.random());a.headers.etag=(Date.now()+e).toString(),a.headers["x-oracle-jscpt-etag-generated"]=a.headers.etag,delete a.headers["if-match"],delete a.headers["if-none-match"]}return b.responseFromJSON(a)})}function o(b,c){var d=b;return a.isOnline()?a.browserFetch(c.clone()).then(function(a){return a.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for default DELETE Handler"),a):q(d,c,a,p)},function(a){return p(d,c)}):p(d,c)}function p(a,c){var d=a;return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing offline logic for default DELETE Handler"),b.requestToJSON(c).then(function(a){return a.status=200,a.statusText="OK",a.headers["content-type"]="application/json",a.headers["x-oracle-jscpt-cache-expiration-date"]="",b.responseFromJSON(a).then(function(f){var g=r(c),h=null;return d._options&&d._options.jsonProcessor&&d._options.jsonProcessor.shredder&&(h=d._options.jsonProcessor.shredder),h?h(f).then(function(c){if(c){var d=c[0].name;return e.openStore(d).then(function(c){return c.findByKey(g).then(function(c){return c?b.responseFromJSON(a).then(function(a){return b.setResponsePayload(a,c).then(function(a){return a})}):f})})}return f}):f})})}function q(a,b,c,d){var e=a;return c.status<500?Promise.resolve(c):d(e,b)}function r(a){var b=a.url.split("/");return b[b.length-1]}function s(a,b,c){var d=a;if("GET"===b.method||"HEAD"===b.method){return(0,d._options.cacheStrategy)(b,c,d._options)}return Promise.resolve(c)}function t(b,c,d){return!a.isOnline()||d?a.getSyncManager().insertRequest(b,{undoRedoDataArray:c}):Promise.resolve()}function u(a,b){return"GET"==a.method||"HEAD"==a.method?Promise.resolve():v(a,b)}function v(a,b){return f.constructShreddedData(a,b).then(function(b){return b?w(a,b):Promise.resolve()})}function w(a,b){var c=[];return b.forEach(function(b){var d=Object.keys(b)[0];c.push(x(a,d,b[d]))}),Promise.all(c)}function x(a,b,c){return y(a,b,c).then(function(d){if("DELETE"===a.method){if(!c||0===c.length){var e=r(a);c=[{key:e}]}return A(b,c,d)}return z(b,c,d)})}function r(a){var b=a.url.split("/");return b.length>1?b[b.length-1].split("?")[0]:null}function y(a,b,c){var d,f,g=[],h=function(c,i){return c<i.length&&"GET"!==a.method&&"HEAD"!==a.method?(d=i[c].key.toString(),f="DELETE"!==a.method?i[c].value:null,e.openStore(b).then(function(a){return a.findByKey(d).then(function(a){return g.push({key:d,undo:a,redo:f}),h(++c,i)},function(a){return g.push({key:d,undo:null,redo:f}),h(++c,i)})})):Promise.resolve(g)};return h(0,c)}function z(a,b,c){return e.openStore(a).then(function(a){return a.upsertAll(b)}).then(function(){return c.length>0?{storeName:a,operation:"upsert",undoRedoData:c}:null})}function A(a,b,c){return e.openStore(a).then(function(a){return a.removeByKey(b[0].key)}).then(function(){return c.length>0?{storeName:a,operation:"remove",undoRedoData:c}:null})}return h.prototype.getFetchEventListener=function(){var a=this;return function(b){b.respondWith(a.processRequest(b.request))}},h.prototype.processRequest=function(a){var c=this,d=b.buildEndpointKey(a);return new Promise(function(e,h){f.registerEndpointOptions(d,c._options);var i=j(c,a),k={},l=a.clone();g.log("Offline Persistence Toolkit DefaultResponseProxy: Calling requestHandler for request with enpointKey: "+d),i.call(c,a).then(function(e){return b.isCachedResponse(e)&&(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is cached for request with enpointKey: "+d),k.isCachedResponse=!0),e.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok for request with enpointKey: "+d),s(c,a,e)):(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is not ok for request with enpointKey: "+d),e)}).then(function(b){return k.response=b,b.ok?(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is ok after cacheStrategy for request with enpointKey: "+d),u(a,b)):(g.log("Offline Persistence Toolkit DefaultResponseProxy: Response is not ok after cacheStrategy for request with enpointKey: "+d),null)}).then(function(b){return t(a,b,k.isCachedResponse)}).then(function(){f.unregisterEndpointOptions(d),e(k.response)}).catch(function(a){g.log("Offline Persistence Toolkit DefaultResponseProxy: Insert Response in syncManager after error for request with enpointKey: "+d),t(l,null,!0).then(function(){f.unregisterEndpointOptions(d),h(a)},function(){f.unregisterEndpointOptions(d),h(a)})})})},h.prototype.handlePost=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default POST Handler"),k(a)},h.prototype.handleGet=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default GET Handler"),l(this,a)},h.prototype.handleHead=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default HEAD Handler"),l(this,a)},h.prototype.handleOptions=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default OPTIONS Handler"),k(a)},h.prototype.handlePut=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default PUT Handler"),m(this,a)},h.prototype.handlePatch=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default PATCH Handler"),k(a)},h.prototype.handleDelete=function(a){return g.log("Offline Persistence Toolkit DefaultResponseProxy: Processing Request with default DELETE Handler"),o(this,a)},{getResponseProxy:i}}); |
@@ -1,1 +0,1 @@ | ||
define(["./keyValuePersistenceStore","./logger"],function(a,b){"use strict";var c=function(b){a.call(this,b)};return c.prototype=new a,c.prototype.Init=function(a){return this._version=a&&a.version||"0",Promise.resolve()},c.prototype._insert=function(a,b,c){var d=this._createRawKey(a),e={metadata:b,value:c},f=JSON.stringify(e);return localStorage.setItem(d,f),Promise.resolve()},c.prototype.removeByKey=function(a){b.log("Offline Persistence Toolkit localPersistenceStore: removeByKey() with key: "+a);var c=this;return this.findByKey(a).then(function(b){if(b){var d=c._createRawKey(a);return localStorage.removeItem(d),Promise.resolve(!0)}return Promise.resolve(!1)})},c.prototype._createRawKey=function(a){return this._name+this._version+a.toString()},c.prototype._extractKey=function(a){var b=this._name+this._version,c=b.length;return 0===a.indexOf(b)?a.slice(c):null},c.prototype.keys=function(){b.log("Offline Persistence Toolkit localPersistenceStore: keys()");for(var a=Object.keys(localStorage),c=[],d=0;d<a.length;d++){var e=this._extractKey(a[d]);e&&c.push(e)}return Promise.resolve(c)},c.prototype.getItem=function(a){b.log("Offline Persistence Toolkit localPersistenceStore: getItem() with key: "+a);var c=this._createRawKey(a),d=localStorage.getItem(c);return d?Promise.resolve(JSON.parse(d)):Promise.resolve()},c}); | ||
define(["./keyValuePersistenceStore","./logger"],function(a,b){"use strict";var c=function(b){a.call(this,b)};return c.prototype=new a,c.prototype.Init=function(a){return this._version=a&&a.version||"0",Promise.resolve()},c.prototype._insert=function(a,b,c){var d=this._createRawKey(a),e={metadata:b,value:c},f=JSON.stringify(e);return localStorage.setItem(d,f),Promise.resolve()},c.prototype.removeByKey=function(a){b.log("Offline Persistence Toolkit localPersistenceStore: removeByKey() with key: "+a);var c=this;return this.findByKey(a).then(function(b){if(b){var d=c._createRawKey(a);return localStorage.removeItem(d),Promise.resolve(!0)}return Promise.resolve(!1)})},c.prototype._createRawKey=function(a){return this._name+this._version+a.toString()},c.prototype._extractKey=function(a){var b=this._name+this._version,c=b.length;return 0===a.indexOf(b)?a.slice(c):null},c.prototype.keys=function(){b.log("Offline Persistence Toolkit localPersistenceStore: keys()");for(var a=Object.keys(localStorage),c=[],d=0;d<a.length;d++){var e=this._extractKey(a[d]);e&&c.push(e)}return Promise.resolve(c)},c.prototype.getItem=function(a){b.log("Offline Persistence Toolkit localPersistenceStore: getItem() with key: "+a);var c=this._createRawKey(a),d=localStorage.getItem(c);if(!d)return Promise.resolve();try{var e=JSON.parse(d);return e.key=a,Promise.resolve(e)}catch(a){return Promise.resolve()}},c}); |
@@ -1,1 +0,1 @@ | ||
define(["./defaultCacheHandler","../persistenceStoreManager","./logger"],function(a,b,c){"use strict";function d(a,b){if(!a)throw TypeError("A name must be provided to create an OfflineCache!");if(!b)throw TypeError("A persistence store must be provided to create an OfflineCache!");this._name=a,this._storeName=b,this._store=null}function e(a,b,c){if(c&&c.length)for(var d=0;d<c.length;d++){var e=c[d];if(h(a,b,e))return e.responseData}return null}function f(a,b,c){var d=[];if(c&&c.length){d=c.filter(g(a,b)).map(function(a){return a.responseData})}return d}function g(a,b,c){return function(d){var e;return e=c?d[c]:d,h(a,b,e)}}function h(a,b,d){if(a)return!0;if(!d||!b)return!1;var e=d.requestData.headers,f=d.responseData.headers,g=b.headers,h=f.vary;if(c.log("Offline Persistence Toolkit OfflineCache: Processing HTTP Vary header"),!h)return!0;if("*"===h.trim())return!1;for(var i=h.split(","),j=0;j<i.length;j++){var k=i[j].toLowerCase();k=k.trim();var l=g.get(k),m=e[k];if(c.log("Offline Persistence Toolkit OfflineCache: HTTP Vary header name: "+k),c.log("Offline Persistence Toolkit OfflineCache: Request HTTP Vary header value: "+l),c.log("Offline Persistence Toolkit OfflineCache: Cached HTTP Vary header value: "+m),!(!m&&!l||m&&l&&m===l))return!1}return!0}function i(b){if(b){c.log("Offline Persistence Toolkit OfflineCache: Converting cached entry to Response object");var d=[],e=b.bodyAbstract;return e?(d.push(Promise.resolve(JSON.parse(e))),delete b.bodyAbstract):d.push(Promise.resolve()),d.push(a.constructResponse(b)),Promise.all(d)}return Promise.resolve()}function j(a){if(a&&a.length){var b=a.map(function(a){return i(a)});return Promise.all(b)}return Promise.resolve()}function k(a){var b=a.map(function(a){return{name:a.name,keys:a.keys,resourceType:a.resourceType}});return JSON.stringify(b)}return d.prototype.getName=function(){return this._name},d.prototype.add=function(a){c.log("Offline Persistence Toolkit OfflineCache: add()");var b=this;return fetch(a).then(function(c){var d=c.clone();return b.put(a,c).then(function(){Promise.resolve(d)})})},d.prototype.addAll=function(a){c.log("Offline Persistence Toolkit OfflineCache: addAll()");var b=a.map(this.add,this);return Promise.all(b)},d.prototype.match=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: match() for Request with url: "+b.url);var f=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return f._getStore().then(function(a){return a.find(g)}).then(function(a){return i(e(h,b,a))}).then(function(c){if(c){var d=c[0],e=c[1];return a.fillResponseBodyWithShreddedData(b,d,e)}return Promise.resolve()})},d.prototype.matchAll=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: matchAll() for Request with url: "+b.url);var e=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return e._getStore().then(function(a){return a.find(g)}).then(function(a){return j(f(h,b,a))}).then(function(c){if(c&&c.length){var d=c.map(function(c){var d=c[0],e=c[1];return a.fillResponseBodyWithShreddedData(b,d,e)});return Promise.all(d)}return Promise.resolve([])})},d.prototype._getStore=function(){var a=this;return a._store?Promise.resolve(a._store):b.openStore(a._storeName).then(function(b){return a._store=b,a._store})},d.prototype.put=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: put() for Request with url: "+b.url);var e=this,f=[];return f.push(a.constructRequestResponseCacheData(b,d)),f.push(a.shredResponse(b,d)),Promise.all(f).then(function(b){return e._getStore().then(function(c){var d=b[0],e=b[1];if(e){var f=[];return d.value.responseData.bodyAbstract=k(e),f.push(c.upsert(d.key,d.metadata,d.value)),f.push(a.cacheShreddedData(e)),Promise.all(f)}return c.upsert(d.key,d.metadata,d.value)})})},d.prototype.delete=function(a,b){a?c.log("Offline Persistence Toolkit OfflineCache: delete() for Request with url: "+a.url):c.log("Offline Persistence Toolkit OfflineCache: delete()");var d=this;return d.keys(a,b).then(function(a){return d._getStore().then(function(b){if(a&&a.length){var c=a.map(b.removeByKey,b);return Promise.all(c)}return!1})}).then(function(a){return!(!a||!a.length)})},d.prototype.keys=function(b,d){return b?c.log("Offline Persistence Toolkit OfflineCache: keys() for Request with url: "+b.url):c.log("Offline Persistence Toolkit OfflineCache: keys()"),this._getStore().then(function(c){if(b){var e=a.constructSearchCriteria(b,d);e.fields=["key","value"];var f=d&&d.ignoreVary;return c.find(e).then(function(a){return a&&a.length?a.filter(g(f,b,"value")).map(function(a){return a.key}):[]})}return c.keys()})},d.prototype.hasMatch=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: hasMatch() for Request with url: "+b.url);var f=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return f._getStore().then(function(a){return a.find(g).then(function(a){return null!==e(h,b,a)})})},d}); | ||
define(["./defaultCacheHandler","../persistenceStoreManager","./logger"],function(a,b,c){"use strict";function d(a,b){if(!a)throw TypeError("A name must be provided to create an OfflineCache!");if(!b)throw TypeError("A persistence store must be provided to create an OfflineCache!");this._name=a,this._storeName=b,this._store=null}function e(a,b,c){if(c&&c.length)for(var d=0;d<c.length;d++){var e=c[d];if(h(a,b,e))return e.responseData}return null}function f(a,b,c){var d=[];if(c&&c.length){d=c.filter(g(a,b)).map(function(a){return a.responseData})}return d}function g(a,b,c){return function(d){var e;return e=c?d[c]:d,h(a,b,e)}}function h(a,b,d){if(a)return!0;if(!d||!b)return!1;var e=d.requestData.headers,f=d.responseData.headers,g=b.headers,h=f.vary;if(c.log("Offline Persistence Toolkit OfflineCache: Processing HTTP Vary header"),!h)return!0;if("*"===h.trim())return!1;for(var i=h.split(","),j=0;j<i.length;j++){var k=i[j].toLowerCase();k=k.trim();var l=g.get(k),m=e[k];if(c.log("Offline Persistence Toolkit OfflineCache: HTTP Vary header name: "+k),c.log("Offline Persistence Toolkit OfflineCache: Request HTTP Vary header value: "+l),c.log("Offline Persistence Toolkit OfflineCache: Cached HTTP Vary header value: "+m),!(!m&&!l||m&&l&&m===l))return!1}return!0}function i(b){if(b){c.log("Offline Persistence Toolkit OfflineCache: Converting cached entry to Response object");var d=[],e=b.bodyAbstract;return e?(d.push(Promise.resolve(JSON.parse(e))),delete b.bodyAbstract):d.push(Promise.resolve()),d.push(a.constructResponse(b)),Promise.all(d)}return Promise.resolve()}function j(a){if(a&&a.length){var b=a.map(function(a){return i(a)});return Promise.all(b)}return Promise.resolve()}function k(a){var b=a.map(function(a){return{name:a.name,keys:a.keys?a.keys.reduce(function(a,b){return b?a.push(b.toString()):c.warn("should not have undefined key in the shredded data"),a},[]):a.keys,resourceType:a.resourceType}});return JSON.stringify(b)}return d.prototype.getName=function(){return this._name},d.prototype.add=function(a){c.log("Offline Persistence Toolkit OfflineCache: add()");var b=this;return fetch(a).then(function(c){var d=c.clone();return b.put(a,c).then(function(){Promise.resolve(d)})})},d.prototype.addAll=function(a){c.log("Offline Persistence Toolkit OfflineCache: addAll()");var b=a.map(this.add,this);return Promise.all(b)},d.prototype.match=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: match() for Request with url: "+b.url);var f=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return f._getStore().then(function(a){return a.find(g)}).then(function(a){return i(e(h,b,a))}).then(function(c){if(c){var d=c[0],e=c[1];return a.fillResponseBodyWithShreddedData(b,d,e)}return Promise.resolve()})},d.prototype.matchAll=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: matchAll() for Request with url: "+b.url);var e=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return e._getStore().then(function(a){return a.find(g)}).then(function(a){return j(f(h,b,a))}).then(function(c){if(c&&c.length){var d=c.map(function(c){var d=c[0],e=c[1];return a.fillResponseBodyWithShreddedData(b,d,e)});return Promise.all(d)}return Promise.resolve([])})},d.prototype._getStore=function(){var a=this;return a._store?Promise.resolve(a._store):b.openStore(a._storeName).then(function(b){return a._store=b,a._store})},d.prototype.put=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: put() for Request with url: "+b.url);var e=this,f=[];return f.push(a.constructRequestResponseCacheData(b,d)),f.push(a.shredResponse(b,d)),Promise.all(f).then(function(b){return e._getStore().then(function(c){var d=b[0],e=b[1];if(e){var f=[];return d.value.responseData.bodyAbstract=k(e),f.push(c.upsert(d.key,d.metadata,d.value)),f.push(a.cacheShreddedData(e)),Promise.all(f)}return c.upsert(d.key,d.metadata,d.value)})})},d.prototype.delete=function(a,b){a?c.log("Offline Persistence Toolkit OfflineCache: delete() for Request with url: "+a.url):c.log("Offline Persistence Toolkit OfflineCache: delete()");var d=this;return d.keys(a,b).then(function(a){return d._getStore().then(function(b){if(a&&a.length){var c=a.map(b.removeByKey,b);return Promise.all(c)}return!1})}).then(function(a){return!(!a||!a.length)})},d.prototype.keys=function(b,d){return b?c.log("Offline Persistence Toolkit OfflineCache: keys() for Request with url: "+b.url):c.log("Offline Persistence Toolkit OfflineCache: keys()"),this._getStore().then(function(c){if(b){var e=a.constructSearchCriteria(b,d);e.fields=["key","value"];var f=d&&d.ignoreVary;return c.find(e).then(function(a){return a&&a.length?a.filter(g(f,b,"value")).map(function(a){return a.key}):[]})}return c.keys()})},d.prototype.hasMatch=function(b,d){c.log("Offline Persistence Toolkit OfflineCache: hasMatch() for Request with url: "+b.url);var f=this,g=a.constructSearchCriteria(b,d),h=d&&d.ignoreVary;return f._getStore().then(function(a){return a.find(g).then(function(a){return null!==e(h,b,a)})})},d}); |
{ | ||
"name": "@oracle/offline-persistence-toolkit", | ||
"title": "Offline Persistence Toolkit", | ||
"version": "1.2.8", | ||
"version": "1.2.9", | ||
"description": "Offline Persistence Toolkit by Oracle Corp.", | ||
@@ -6,0 +6,0 @@ "author": "oraclejet", |
@@ -1,2 +0,2 @@ | ||
# offline-persistence-toolkit 1.2.8 # | ||
# offline-persistence-toolkit 1.2.9 # | ||
@@ -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.2.8/min' | ||
'persist' : 'js/libs/persist/v1.2.9/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.2.8/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.2.9/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.2.8/min'`. | ||
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.2.9/min'`. | ||
@@ -96,3 +96,3 @@ Versions of the toolkit are also available on CDN under the latest JET release. e.g. | ||
'pouchfind': 'js/libs/pouchdb.find', | ||
'persist' : 'js/libs/persist/v1.2.8/min' | ||
'persist' : 'js/libs/persist/v1.2.9/min' | ||
@@ -99,0 +99,0 @@ // Other path mappings here |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
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
46827
3703166
144
35