@oracle/offline-persistence-toolkit
Advanced tools
Comparing version 1.5.6 to 1.5.7
@@ -5,3 +5,3 @@ (function(){ | ||
{ | ||
'persist/offline-persistence-toolkit-core-1.5.6': [ | ||
'persist/offline-persistence-toolkit-core-1.5.7': [ | ||
'persist/persistenceUtils', | ||
@@ -18,3 +18,3 @@ 'persist/impl/logger', | ||
], | ||
'persist/offline-persistence-toolkit-pouchdbstore-1.5.6': [ | ||
'persist/offline-persistence-toolkit-pouchdbstore-1.5.7': [ | ||
'persist/PersistenceStore', | ||
@@ -28,3 +28,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-arraystore-1.5.6': [ | ||
'persist/offline-persistence-toolkit-arraystore-1.5.7': [ | ||
'persist/PersistenceStore', | ||
@@ -37,3 +37,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-localstore-1.5.6': [ | ||
'persist/offline-persistence-toolkit-localstore-1.5.7': [ | ||
'persist/PersistenceStore', | ||
@@ -46,3 +46,3 @@ 'persist/impl/storageUtils', | ||
], | ||
'persist/offline-persistence-toolkit-filesystemstore-1.5.6': [ | ||
'persist/offline-persistence-toolkit-filesystemstore-1.5.7': [ | ||
'persist/impl/storageUtils', | ||
@@ -53,3 +53,3 @@ 'persist/impl/keyValuePersistenceStore', | ||
], | ||
'persist/offline-persistence-toolkit-responseproxy-1.5.6': [ | ||
'persist/offline-persistence-toolkit-responseproxy-1.5.7': [ | ||
'persist/fetchStrategies', | ||
@@ -56,0 +56,0 @@ 'persist/cacheStrategies', |
@@ -93,3 +93,3 @@ /** | ||
function _isTextPayload(headers) { | ||
function _isTextPayload(headers, isAppJsonText) { | ||
@@ -100,6 +100,15 @@ var contentType = headers.get('Content-Type'); | ||
// pattern text/ or application/*json . | ||
if (contentType && | ||
if (isAppJsonText) { | ||
if (contentType && | ||
(contentType.match(/.*text\/.*/) || | ||
contentType.match(/.*application\/.*json.*/))) { | ||
return true; | ||
} | ||
} else { | ||
if (contentType && | ||
(contentType.match(/.*text\/.*/))) { | ||
return true; | ||
return true; | ||
} | ||
} | ||
return false; | ||
@@ -201,3 +210,3 @@ }; | ||
if ((source instanceof Request) || | ||
_isTextPayload(source.headers)) { | ||
_isTextPayload(source.headers, true)) { | ||
return source.text().then(function (text) { | ||
@@ -204,0 +213,0 @@ targetObj.body.text = text; |
@@ -6,2 +6,2 @@ /** | ||
define(["./impl/logger"],(function(e){"use strict";function t(e){return e.headers.has("x-oracle-jscpt-cache-expiration-date")}function r(e){var t=e.get("Content-Type");return!(!t||!t.match(/.*text\/.*/))}function n(t,r){e.log("Offline Persistence Toolkit persistenceUtils: requestToJSON()"),r&&r._noClone||(t=t.clone());var n={};return a(t,n,["body","headers","signal"]),n.headers=o(t.headers),s(t,n)}function a(e,t,r){for(var n in e)"function"!=typeof e[n]&&0!==n.indexOf("_")&&-1===r.indexOf(n)&&(t[n]=e[n])}function o(t){var r={};if(t.entries){var n,a,o,s=t.entries();do{(n=s.next()).value&&(a=n.value[0],o=n.value[1],r[a]=o)}while(!n.done)}else t.forEach&&t.forEach((function(e,t){r[t]=e}));return function(t){var r=t.date;r||(e.log("Offline Persistence Toolkit persistenceUtils: Setting HTTP date header since it's null or not exposed"),r=(new Date).toUTCString(),t.date=r)}(r),r}function s(t,n){return n.body={},t instanceof Request&&((a=t.headers.get("Content-Type"))&&-1!==a.indexOf("multipart/"))?function(t,r){if(e.log("Offline Persistence Toolkit persistenceUtils: Copying multipart payload"),"function"==typeof t.formData)return t.formData().then((function(e){var t,n,a,o,s={},i=e.entries();do{(n=(t=i.next()).value)&&(a=n[0],o=n[1],s[a]=o)}while(!t.done);return r.body.formData=s,r}));var n=t.headers.get("Content-Type");return t.text().then((function(e){for(var t=c(e,n),a={},o=0;o<t.length;o++)a[t[o].headers.name]=t[o].data;return r.body.formData=a,r}))}(t,n):t instanceof Request||r(t.headers)?t.text().then((function(e){return n.body.text=e,n})):t instanceof Request||"function"!=typeof t.arrayBuffer?Promise.reject(new Error({message:"payload body type is not supported"})):t.arrayBuffer().then((function(e){return e.byteLength>0&&(n.body.arrayBuffer=e),n}));var a}function i(t,r){e.log("Offline Persistence Toolkit persistenceUtils: responseToJSON()"),r&&r._noClone||(t=t.clone());var n={};return a(t,n,["body","headers"]),n.headers=o(t.headers),r&&r.excludeBody?Promise.resolve(n):s(t,n)}function l(t){if(e.log("Offline Persistence Toolkit persistenceUtils: requestFromJSON()"),!t)return Promise.resolve();var r={};a(t,r,["headers","body","signal"]);var n=function(e,t){var r=!1,n=e.body;if(n.text&&n.text.length>0)t.body=n.text;else if(n.arrayBuffer)t.body=n.arrayBuffer;else if(n.formData){r=!0;var a=new FormData,o=n.formData;Object.keys(o).forEach((function(e){a.append(e,o[e])})),t.body=a}return r}(t,r);return r.headers=u(t,n),Promise.resolve(new Request(t.url,r))}function u(e,t){var r=new Headers;return Object.keys(e.headers).forEach((function(n){("content-type"!==n||!t&&"content-type"===n)&&r.append(n,e.headers[n])})),r}function f(t){e.log("Offline Persistence Toolkit persistenceUtils: responseFromJSON()");var r={};return a(t,r,["headers","body"]),r.headers=u(t,!1),Promise.resolve(function(e,t){var r,n=e.body;return n&&n.text?r=new Response(n.text,t):n&&n.arrayBuffer?(t.responseType="blob",r=new Response(n.arrayBuffer,t)):n&&n.blob?(t.responseType="blob",r=new Response(n.blob,t)):r=new Response(null,t),r}(t,r))}function c(t,r){e.log("Offline Persistence Toolkit persistenceUtils: parseMultipartFormData()");var n=r.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new Error("not a valid multipart form data value.");var a,o=function(e){for(var t={},r={},n=e.split("\r\n"),a=0;a<n.length;a++){var o=n[a];if(0!==o.length){var s=o.split(";");if(1===s.length&&0===s[0].indexOf("Content-Type"))t.contentType=s[0].split(":")[1].trim();else for(var i=0;i<s.length;i++)if(-1!==s[i].indexOf("=")){var l=s[i].split("=");r[l[0].trim()]=l[1].substring(1,l[1].length-1)}}}return t.headers=r,t},s=function(e,t){var r=e.split("\r\n");return t&&t.indexOf("image")>=0?i(r[0],t):r[0]},i=function(e,t){var r=null;try{r=atob(e)}catch(e){return null}for(var n=new ArrayBuffer(r.length),a=new Uint8Array(n),o=0;o<r.length;o++)a[o]=r.charCodeAt(o);return new Blob([n],{type:t})},l=n[1]||n[2];if("string"==typeof t)a=t;else{var u=new Uint8Array(t);a=String.fromCharCode.apply(null,u)}for(var f=a.split(new RegExp(l)),c=[],d=1;d<f.length-1;d++){var p={},y=f[d].split("\r\n\r\n"),h=y[0],v=y[1],g=o(h);p.headers=g.headers,p.data=s(v,g.contentType),c.push(p)}return c}function d(e){if(e){var t={};return Object.keys(e).forEach((function(r){if(r.startsWith("value.")){var n=e[r];n instanceof Object?(t.op=Object.keys(n)[0],t.value=n[t.op]):(t.op="$eq",t.value=n),t.attribute=r.substr(6,r.length)}else{var a=r;"$and"!=a&&"$or"!=a||(t.op=a,t.value=[],e[a].forEach((function(e,r){t.value[r]=d(e)})))}})),t}return null}function p(e){if(e){var t={},r=e.op;return"$and"==r||"$or"==r?(t[r]=[],e.value.forEach((function(e,n){t[r][n]=p(e)}))):(t["value."+e.attribute]={},t["value."+e.attribute][e.op]=e.value),t}return null}return{requestToJSON:n,requestFromJSON:l,responseToJSON:i,responseFromJSON:f,setResponsePayload:function(t,r){return e.log("Offline Persistence Toolkit persistenceUtils: setResponsePayload()"),i(t).then((function(e){var t=e.body;return t.arrayBuffer=null,t.blob=null,t.text=null,r instanceof ArrayBuffer?t.arrayBuffer=r:r instanceof Blob?t.blob=r:t.text=JSON.stringify(r),f(e)}))},parseMultipartFormData:c,isCachedResponse:t,isGeneratedEtagResponse:function(e){return e.headers.has("x-oracle-jscpt-etag-generated")},_isTextPayload:r,buildEndpointKey:function(t){e.log("Offline Persistence Toolkit persistenceUtils: buildEndpointKey() for Request with url: "+t.url);var r={url:t.url,id:Math.random().toString(36).replace(/[^a-z]+/g,"")};return JSON.stringify(r)},_cloneRequest:function(e){return n(e,{_noClone:!0}).then((function(e){return l(e).then((function(e){return e}))}))},_cloneResponse:function(e,t){return t=t||{},i(e,{_noClone:!0}).then((function(e){return f(e).then((function(e){return null!=t.url&&t.url.length>0&&null==e.headers.get("x-oracle-jscpt-response-url")&&e.headers.set("x-oracle-jscpt-response-url",t.url),e}))}))},_derivePayloadType:function(e,n){var a=n.headers.get("Content-Type"),o=e.responseType,s=a&&-1!==a.indexOf("image/svg+xml");return r(n.headers)||s?"text":t(n)||"blob"===o?"blob":a&&-1!==a.indexOf("image/")||"arraybuffer"===o?"arraybuffer":a&&-1!==a.indexOf("multipart/form-data")?"multipart":"text"},_mapData:function(e,t,r){var n=e||[],a=t||[];if(r){n=[],a=[];var o,s=null!=e?e.length:t.length;for(o=0;o<s;o++){var i=null!=e?{key:e[o]}:{key:null},l=null!=t?{metadata:i,data:t[o]}:{metadata:i,data:null},u=r.mapFields(l);n[o]=u.metadata.key,a[o]=u.data}}return{keys:n,data:a}},_unmapData:function(e,t,r){var n=e||[],a=t||[];if(r){n=[],a=[];var o,s=null!=e?e.length:t.length;for(o=0;o<s;o++){var i=null!=e?{key:e[o]}:{key:null},l=null!=t?{metadata:i,data:t[o]}:{metadata:i,data:null},u=r.unmapFields(l);n[o]=u.metadata.key,a[o]=u.data}}return{keys:n,data:a}},_mapFindQuery:function(e,t,r){if(e&&t){var n=d(e.selector);n&&(e.selector=p(t.mapFilterCriterion(n)))}return r&&r.length&&(e.sort=r),e},isReplayRequest:function(e){return e.headers.has("x-oracle-jscpt-sync-replay")},markReplayRequest:function(e,t){t?e.headers.set("x-oracle-jscpt-sync-replay",""):e.headers.delete("x-oracle-jscpt-sync-replay")}}})); | ||
define(["./impl/logger"],(function(e){"use strict";function t(e){return e.headers.has("x-oracle-jscpt-cache-expiration-date")}function r(e,t){var r=e.get("Content-Type");if(t){if(r&&(r.match(/.*text\/.*/)||r.match(/.*application\/.*json.*/)))return!0}else if(r&&r.match(/.*text\/.*/))return!0;return!1}function n(t,r){e.log("Offline Persistence Toolkit persistenceUtils: requestToJSON()"),r&&r._noClone||(t=t.clone());var n={};return a(t,n,["body","headers","signal"]),n.headers=o(t.headers),s(t,n)}function a(e,t,r){for(var n in e)"function"!=typeof e[n]&&0!==n.indexOf("_")&&-1===r.indexOf(n)&&(t[n]=e[n])}function o(t){var r={};if(t.entries){var n,a,o,s=t.entries();do{(n=s.next()).value&&(a=n.value[0],o=n.value[1],r[a]=o)}while(!n.done)}else t.forEach&&t.forEach((function(e,t){r[t]=e}));return function(t){var r=t.date;r||(e.log("Offline Persistence Toolkit persistenceUtils: Setting HTTP date header since it's null or not exposed"),r=(new Date).toUTCString(),t.date=r)}(r),r}function s(t,n){return n.body={},t instanceof Request&&((a=t.headers.get("Content-Type"))&&-1!==a.indexOf("multipart/"))?function(t,r){if(e.log("Offline Persistence Toolkit persistenceUtils: Copying multipart payload"),"function"==typeof t.formData)return t.formData().then((function(e){var t,n,a,o,s={},i=e.entries();do{(n=(t=i.next()).value)&&(a=n[0],o=n[1],s[a]=o)}while(!t.done);return r.body.formData=s,r}));var n=t.headers.get("Content-Type");return t.text().then((function(e){for(var t=c(e,n),a={},o=0;o<t.length;o++)a[t[o].headers.name]=t[o].data;return r.body.formData=a,r}))}(t,n):t instanceof Request||r(t.headers,!0)?t.text().then((function(e){return n.body.text=e,n})):t instanceof Request||"function"!=typeof t.arrayBuffer?Promise.reject(new Error({message:"payload body type is not supported"})):t.arrayBuffer().then((function(e){return e.byteLength>0&&(n.body.arrayBuffer=e),n}));var a}function i(t,r){e.log("Offline Persistence Toolkit persistenceUtils: responseToJSON()"),r&&r._noClone||(t=t.clone());var n={};return a(t,n,["body","headers"]),n.headers=o(t.headers),r&&r.excludeBody?Promise.resolve(n):s(t,n)}function l(t){if(e.log("Offline Persistence Toolkit persistenceUtils: requestFromJSON()"),!t)return Promise.resolve();var r={};a(t,r,["headers","body","signal"]);var n=function(e,t){var r=!1,n=e.body;if(n.text&&n.text.length>0)t.body=n.text;else if(n.arrayBuffer)t.body=n.arrayBuffer;else if(n.formData){r=!0;var a=new FormData,o=n.formData;Object.keys(o).forEach((function(e){a.append(e,o[e])})),t.body=a}return r}(t,r);return r.headers=u(t,n),Promise.resolve(new Request(t.url,r))}function u(e,t){var r=new Headers;return Object.keys(e.headers).forEach((function(n){("content-type"!==n||!t&&"content-type"===n)&&r.append(n,e.headers[n])})),r}function f(t){e.log("Offline Persistence Toolkit persistenceUtils: responseFromJSON()");var r={};return a(t,r,["headers","body"]),r.headers=u(t,!1),Promise.resolve(function(e,t){var r,n=e.body;return n&&n.text?r=new Response(n.text,t):n&&n.arrayBuffer?(t.responseType="blob",r=new Response(n.arrayBuffer,t)):n&&n.blob?(t.responseType="blob",r=new Response(n.blob,t)):r=new Response(null,t),r}(t,r))}function c(t,r){e.log("Offline Persistence Toolkit persistenceUtils: parseMultipartFormData()");var n=r.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!n)throw new Error("not a valid multipart form data value.");var a,o=function(e){for(var t={},r={},n=e.split("\r\n"),a=0;a<n.length;a++){var o=n[a];if(0!==o.length){var s=o.split(";");if(1===s.length&&0===s[0].indexOf("Content-Type"))t.contentType=s[0].split(":")[1].trim();else for(var i=0;i<s.length;i++)if(-1!==s[i].indexOf("=")){var l=s[i].split("=");r[l[0].trim()]=l[1].substring(1,l[1].length-1)}}}return t.headers=r,t},s=function(e,t){var r=e.split("\r\n");return t&&t.indexOf("image")>=0?i(r[0],t):r[0]},i=function(e,t){var r=null;try{r=atob(e)}catch(e){return null}for(var n=new ArrayBuffer(r.length),a=new Uint8Array(n),o=0;o<r.length;o++)a[o]=r.charCodeAt(o);return new Blob([n],{type:t})},l=n[1]||n[2];if("string"==typeof t)a=t;else{var u=new Uint8Array(t);a=String.fromCharCode.apply(null,u)}for(var f=a.split(new RegExp(l)),c=[],d=1;d<f.length-1;d++){var p={},y=f[d].split("\r\n\r\n"),h=y[0],v=y[1],g=o(h);p.headers=g.headers,p.data=s(v,g.contentType),c.push(p)}return c}function d(e){if(e){var t={};return Object.keys(e).forEach((function(r){if(r.startsWith("value.")){var n=e[r];n instanceof Object?(t.op=Object.keys(n)[0],t.value=n[t.op]):(t.op="$eq",t.value=n),t.attribute=r.substr(6,r.length)}else{var a=r;"$and"!=a&&"$or"!=a||(t.op=a,t.value=[],e[a].forEach((function(e,r){t.value[r]=d(e)})))}})),t}return null}function p(e){if(e){var t={},r=e.op;return"$and"==r||"$or"==r?(t[r]=[],e.value.forEach((function(e,n){t[r][n]=p(e)}))):(t["value."+e.attribute]={},t["value."+e.attribute][e.op]=e.value),t}return null}return{requestToJSON:n,requestFromJSON:l,responseToJSON:i,responseFromJSON:f,setResponsePayload:function(t,r){return e.log("Offline Persistence Toolkit persistenceUtils: setResponsePayload()"),i(t).then((function(e){var t=e.body;return t.arrayBuffer=null,t.blob=null,t.text=null,r instanceof ArrayBuffer?t.arrayBuffer=r:r instanceof Blob?t.blob=r:t.text=JSON.stringify(r),f(e)}))},parseMultipartFormData:c,isCachedResponse:t,isGeneratedEtagResponse:function(e){return e.headers.has("x-oracle-jscpt-etag-generated")},_isTextPayload:r,buildEndpointKey:function(t){e.log("Offline Persistence Toolkit persistenceUtils: buildEndpointKey() for Request with url: "+t.url);var r={url:t.url,id:Math.random().toString(36).replace(/[^a-z]+/g,"")};return JSON.stringify(r)},_cloneRequest:function(e){return n(e,{_noClone:!0}).then((function(e){return l(e).then((function(e){return e}))}))},_cloneResponse:function(e,t){return t=t||{},i(e,{_noClone:!0}).then((function(e){return f(e).then((function(e){return null!=t.url&&t.url.length>0&&null==e.headers.get("x-oracle-jscpt-response-url")&&e.headers.set("x-oracle-jscpt-response-url",t.url),e}))}))},_derivePayloadType:function(e,n){var a=n.headers.get("Content-Type"),o=e.responseType,s=a&&-1!==a.indexOf("image/svg+xml");return r(n.headers)||s?"text":t(n)||"blob"===o?"blob":a&&-1!==a.indexOf("image/")||"arraybuffer"===o?"arraybuffer":a&&-1!==a.indexOf("multipart/form-data")?"multipart":"text"},_mapData:function(e,t,r){var n=e||[],a=t||[];if(r){n=[],a=[];var o,s=null!=e?e.length:t.length;for(o=0;o<s;o++){var i=null!=e?{key:e[o]}:{key:null},l=null!=t?{metadata:i,data:t[o]}:{metadata:i,data:null},u=r.mapFields(l);n[o]=u.metadata.key,a[o]=u.data}}return{keys:n,data:a}},_unmapData:function(e,t,r){var n=e||[],a=t||[];if(r){n=[],a=[];var o,s=null!=e?e.length:t.length;for(o=0;o<s;o++){var i=null!=e?{key:e[o]}:{key:null},l=null!=t?{metadata:i,data:t[o]}:{metadata:i,data:null},u=r.unmapFields(l);n[o]=u.metadata.key,a[o]=u.data}}return{keys:n,data:a}},_mapFindQuery:function(e,t,r){if(e&&t){var n=d(e.selector);n&&(e.selector=p(t.mapFilterCriterion(n)))}return r&&r.length&&(e.sort=r),e},isReplayRequest:function(e){return e.headers.has("x-oracle-jscpt-sync-replay")},markReplayRequest:function(e,t){t?e.headers.set("x-oracle-jscpt-sync-replay",""):e.headers.delete("x-oracle-jscpt-sync-replay")}}})); |
{ | ||
"name": "@oracle/offline-persistence-toolkit", | ||
"title": "Offline Persistence Toolkit", | ||
"version": "1.5.6", | ||
"version": "1.5.7", | ||
"description": "Offline Persistence Toolkit by Oracle Corp.", | ||
@@ -6,0 +6,0 @@ "author": "oraclejet", |
@@ -1,2 +0,2 @@ | ||
# offline-persistence-toolkit 1.5.6 # | ||
# offline-persistence-toolkit 1.5.7 # | ||
@@ -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.5.6/min' | ||
'persist' : 'js/libs/persist/v1.5.7/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.5.6/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.5.7/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.5.6/min'`. | ||
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.5.7/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.5.6/min' | ||
'persist' : 'js/libs/persist/v1.5.7/min' | ||
@@ -99,0 +99,0 @@ // Other path mappings here |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
5230737
100604
44