Skip to content

Commit f83259c

Browse files
Fixed bugs and updated version to 1.1.7
Fixed bug in Logger in ServiceWorker context. Fixed bug with the pouchDBPersistenceStore. Fixed vary header support.
1 parent 9dc410d commit f83259c

10 files changed

+40
-17
lines changed

JSDOC.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.1.6 #
1+
# offline-persistence-toolkit 1.1.7 #
22

33
## Introduction ##
44

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.1.6 #
1+
# offline-persistence-toolkit 1.1.7 #
22

33
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.
44

@@ -58,16 +58,16 @@ If your app uses [RequireJS](http://www.requirejs.org/ "RequireJS"), update the
5858
```javascript
5959
requirejs.config({
6060
paths: {
61-
'persist' : 'js/libs/persist/v1.1.6/min'
61+
'persist' : 'js/libs/persist/v1.1.7/min'
6262

6363
// Other path mappings here
6464
}
6565
```
66-
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.1.6/min'` entry to the list of paths.
66+
For Oracle JET apps, also open `appDir/src/js/main-release-paths.json` and add the `'persist' : 'js/libs/persist/v1.1.7/min'` entry to the list of paths.
6767
6868
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.
6969
70-
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.1.6/min'`.
70+
It is recommended to add the version number as a convention in your application build step such as `'persist' : 'js/libs/persist/v1.1.7/min'`.
7171
7272
Versions of the toolkit are also available on CDN under the latest JET release. e.g.
7373
@@ -91,7 +91,7 @@ And again, if you are using RequireJS, you will need to map paths for these pack
9191
paths: {
9292
'pouchdb': 'js/libs/pouchdb-6.3.4',
9393
'pouchfind': 'js/libs/pouchdb.find',
94-
'persist' : 'js/libs/persist/v1.1.6/min'
94+
'persist' : 'js/libs/persist/v1.1.7/min'
9595

9696
// Other path mappings here
9797
}

USAGE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.1.6 #
1+
# offline-persistence-toolkit 1.1.7 #
22

33
# Introduction #
44

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ <h3> </h3>
4343

4444

4545
<section>
46-
<article><h1>offline-persistence-toolkit 1.1.6</h1><h2>Introduction</h2><p>This document provides a reference to the offline-persistence-toolkit's JavaScript API. Links to JSDoc for each class can be found to the right.</p>
46+
<article><h1>offline-persistence-toolkit 1.1.7</h1><h2>Introduction</h2><p>This document provides a reference to the offline-persistence-toolkit's JavaScript API. Links to JSDoc for each class can be found to the right.</p>
4747
<p>The toolkit's <a href="https://github.com/oracle/offline-persistence-toolkit/" title="README">README</a> file provides an overview of the toolkit’s capabilities. Having read that document, you can find more information about how to implement a range of common and advanced use cases with the toolkit in the
4848
<a href="https://github.com/oracle/offline-persistence-toolkit/blob/master/USAGE.md" title="Usage guide">Usage guide</a>.</p>
4949
<h2>License</h2><p>Copyright (c) 2017 Oracle and/or its affiliates The Universal Permissive License (UPL), Version 1.0.</p></article>

src/impl/OfflineCache.js

+1
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ define(["./defaultCacheHandler", "./logger"], function (cacheHandler, logger) {
264264
var varyArray = varyValue.split(',');
265265
for (var index = 0; index < varyArray.length; index++) {
266266
var varyHeaderName = varyArray[index].toLowerCase();
267+
varyHeaderName = varyHeaderName.trim();
267268
var requestVaryHeaderValue = requestHeaders.get(varyHeaderName);
268269
var cachedRequestVaryHeaderValue = cacheRequestHeaders[varyHeaderName];
269270
logger.log("Offline Persistence Toolkit OfflineCache: HTTP Vary header name: " + varyHeaderName);

src/impl/defaultCacheHandler.js

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ define(['../persistenceUtils', '../persistenceStoreManager', './logger'],
189189
var varyFields = varyValue.split(',');
190190
for (var index = 0; index < varyFields.length; index++) {
191191
var varyField = varyFields[index];
192+
varyField = varyField.trim();
192193
var varyValue = requestHeaders ? requestHeaders.get(varyField) : 'undefined';
193194
key += varyField + '=' + varyValue;
194195
}

src/impl/logger.js

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ define([], function () {
232232
writer = self.option("writer");
233233
} else if (typeof window !== 'undefined' && window.console !== undefined) {
234234
writer = window.console;
235+
} else if (typeof console !== 'undefined') {
236+
writer = console;
235237
}
236238
return writer;
237239
};

src/impl/pouchDBPersistenceStore.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -182,16 +182,21 @@ define(["../PersistenceStore", "../impl/storageUtils", "pouchdb", "./logger"],
182182
// get all rows and use our own find logic
183183
return self._db.allDocs({include_docs: true}).then(function (result) {
184184
if (result && result.rows && result.rows.length) {
185-
var satisfiedRows = result.rows.filter(function(row) {
186-
if (storageUtils.satisfy(findExpression.selector, row.doc)) {
187-
return true;
188-
}
189-
return false;
185+
var fixedDocPromises = result.rows.map(function(row) {
186+
return self._fixValue(row.doc);
190187
});
191-
var promises = satisfiedRows.map(function(row) {
192-
return self._findResultCallback(modifiedFind.fields).bind(self)(row.doc);
188+
return Promise.all(fixedDocPromises).then(function(docs) {
189+
var satisfiedRows = result.rows.filter(function(row) {
190+
if (storageUtils.satisfy(findExpression.selector, row.doc)) {
191+
return true;
192+
}
193+
return false;
194+
});
195+
var promises = satisfiedRows.map(function(row) {
196+
return self._findResultCallback(modifiedFind.fields).bind(self)(row.doc);
197+
});
198+
return Promise.all(promises);
193199
});
194-
return Promise.all(promises);
195200
} else {
196201
return Promise.resolve([]);
197202
}

test/caches/cachestest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ define(['persist/persistenceStoreManager', 'persist/localPersistenceStoreFactory
185185
response: new Response('response body for all departments compressed with gzip random', {
186186
headers: new Headers({
187187
'Content-Encoding': 'gzip random',
188-
Vary: 'test-accept-encoding'
188+
Vary: 'test-accept-encoding, test-accept-encoding1'
189189
})
190190
})
191191
}];

test/storage/storagetest.js

+14
Original file line numberDiff line numberDiff line change
@@ -971,6 +971,20 @@ define(['persist/persistenceStoreManager', 'persist/localPersistenceStoreFactory
971971
}
972972
return testStore.find(findExpression);
973973
}
974+
}).then(function (valueFound) {
975+
valueFound = valueFound[0].value;
976+
if (!valueFound || !valueFound.logo ||
977+
blobFromStringSize !== valueFound.logo.size) {
978+
assert.ok(false, 'first row cannot be found.');
979+
return Promise.reject({message: 'cannot find the inserted value.'});
980+
} else {
981+
assert.ok(true, 'first row is found.');
982+
var findExpression = {
983+
selector: {key: {$eq: 'testBinaryKey1'}},
984+
fields: ['value.logo']
985+
}
986+
return testStore.find(findExpression);
987+
}
974988
}).then(function (valueFound) {
975989
valueFound = valueFound[0].value;
976990
if (!valueFound || !valueFound.logo ||

0 commit comments

Comments
 (0)