Skip to content

Commit ffe75be

Browse files
committed
Updating to v1.5.5
1 parent 33c6f7c commit ffe75be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+7424
-6980
lines changed

.DS_Store

8 KB
Binary file not shown.

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
dist
22
node_modules
3-
temp
3+
temp

Gruntfile.js

+127-67
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
/*global module:false*/
22
module.exports = function (grunt) {
3+
var fs = require('fs');
4+
var path = require('path');
5+
6+
var karmaSetup = {
7+
optSourceFolder : 'src/',
8+
karmaTestFolder : 'test/karma-mocha-tests/',
9+
karmaPreProcessorFiles : {},
10+
karmaPreProcessorExcludedFiles : ['src/impl/fetch.js'],
11+
karmaTestFiles : [],
12+
testTasks : []
13+
};
14+
15+
var helper = {
16+
fetchFilesFromDirectory : function(directory, callback) {
17+
fs.readdirSync(directory).forEach(file => {
18+
var fullPath = path.join(directory, file);
19+
if (fs.lstatSync(fullPath).isDirectory()) {
20+
this.fetchFilesFromDirectory(fullPath, callback);
21+
} else {
22+
callback(fullPath, file);
23+
}
24+
});
25+
}
26+
}
27+
28+
var generateKarmaPreProcessorFiles = function(file) {
29+
if(!karmaSetup.karmaPreProcessorExcludedFiles.includes(file)) {
30+
let _filePath = file.replace("src","dist/debug");
31+
karmaSetup.karmaPreProcessorFiles[_filePath] = ['coverage'];
32+
}
33+
};
34+
35+
var setKarmaTestFiles = function(fileFullPath, fileName) {
36+
var testFileData = {
37+
testFile : null,
38+
coverageFile : null
39+
};
40+
testFileData.testFile = fileFullPath;
41+
testFileData.coverageFile = fileName.replace('.js','.json');
42+
karmaSetup.karmaTestFiles.push(testFileData);
43+
};
44+
345
// Project configuration.
446
grunt.initConfig({
547
// Metadata.
@@ -17,17 +59,19 @@ module.exports = function (grunt) {
1759
node_modules: 'node_modules',
1860
temp: 'temp',
1961
docs: 'docs',
20-
config: 'config'
62+
config: 'config',
63+
karma_coverage: 'temp/coverage',
64+
coverage_report: 'coverage'
2165
},
2266
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
2367
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
2468
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
2569
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
2670
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
2771
copyRightBanner: '/**\n' +
28-
' * Copyright (c) 2017, Oracle and/or its affiliates.\n' +
29-
' * All rights reserved.\n' +
30-
' */\n',
72+
' * Copyright (c) 2017, Oracle and/or its affiliates.\n' +
73+
' * All rights reserved.\n' +
74+
' */\n',
3175
watch: {
3276
gruntfile: {
3377
files: '<%= jshint.gruntfile.src %>'
@@ -41,7 +85,9 @@ module.exports = function (grunt) {
4185
'<%= paths.docs %>',
4286
'<%= paths.temp %>'],
4387
bundles_debug: '<%= paths.dist_bundles_debug %>',
44-
bundles_min: '<%= paths.dist_bundles_min %>'
88+
bundles: '<%= paths.dist_bundles %>',
89+
bundles_min: '<%= paths.dist_bundles_min %>',
90+
karmaCoverage: '<%= paths.karma_coverage %>'
4591
},
4692
browserify: {
4793
pouchDB_browser_bundle: {
@@ -201,10 +247,6 @@ module.exports = function (grunt) {
201247
{
202248
src: '<%= paths.dist_bundles_debug %>/persist/defaultResponseProxy.js',
203249
dest: '<%= paths.dist_bundles_debug %>/persist/offline-persistence-toolkit-responseproxy-<%= pkg.version %>.js'
204-
},
205-
{
206-
src: 'coverage/dist/debug/require-config-coverage.js',
207-
dest: 'coverage/dist/debug/bundles-config.js'
208250
}
209251
]
210252
}
@@ -268,36 +310,6 @@ module.exports = function (grunt) {
268310
}
269311
]
270312
},
271-
config_coverage: {
272-
files: [
273-
{
274-
expand: true,
275-
cwd: 'config',
276-
src: 'require-config-coverage.js',
277-
dest: 'coverage/dist/debug'
278-
}
279-
]
280-
},
281-
test_coverage: {
282-
files: [
283-
{
284-
expand: true,
285-
cwd: 'test',
286-
src: '**',
287-
dest: 'coverage/test'
288-
}
289-
]
290-
},
291-
lib_coverage: {
292-
files: [
293-
{
294-
expand: true,
295-
cwd: 'lib',
296-
src: '**',
297-
dest: 'coverage/lib'
298-
}
299-
]
300-
},
301313
temp_debug: {
302314
files: [
303315
{
@@ -337,7 +349,7 @@ module.exports = function (grunt) {
337349
dest: '<%= paths.dist_min %>'
338350
}
339351
]
340-
},
352+
}
341353
},
342354
jsdoc: {
343355
dist: {
@@ -389,29 +401,16 @@ module.exports = function (grunt) {
389401
}]
390402
}
391403
},
392-
qunit: {
393-
files: ['test/**/*.html'],
394-
options: {
395-
puppeteer: {
396-
headless: true,
397-
args: ['--disable-web-security']
398-
}
399-
}
400-
},
401-
run_java: {
402-
jscover: {
403-
command: 'java',
404-
jarName: 'coverage/JSCover-all.jar',
405-
javaArgs: '-fs dist/debug coverage/dist/debug --no-instrument=impl/sql-where-parser.min.js --no-instrument=impl/fetch.js --no-instrument=<%= pouchdb_bundle %>'
406-
}
407-
},
408404
shell: {
409405
start_test_server: {
410406
command: 'node ./test/lib/testServer/server.js',
411407
options: {
412408
stdout: true,
413-
async: true,
409+
async:true,
414410
}
411+
},
412+
karma_coverage_report: {
413+
command: 'node_modules/nyc/bin/nyc.js -t <%= paths.karma_coverage %>/**/ report --reporter=html --report-dir=<%= coverage_report %>'
415414
}
416415
},
417416
usebanner:{
@@ -430,9 +429,19 @@ module.exports = function (grunt) {
430429
"!<%= paths.dist_min %>/**/fetch.js"],
431430
}
432431
}
432+
},
433+
karma: {
434+
unit: {
435+
configFile: 'karma.conf.js',
436+
fileToTest: '',
437+
karmaPreProcessorFiles: karmaSetup.karmaPreProcessorFiles,
438+
browser: 'ChromeHeadless',
439+
singleRun: true,
440+
coverageDir: '<%= paths.karma_coverage %>'
441+
}
433442
}
434443
});
435-
444+
436445
// These plugins provide necessary tasks.
437446
grunt.loadNpmTasks('grunt-contrib-watch');
438447
grunt.loadNpmTasks('grunt-contrib-clean');
@@ -441,30 +450,25 @@ module.exports = function (grunt) {
441450
grunt.loadNpmTasks('grunt-jsdoc');
442451
grunt.loadNpmTasks('grunt-terser');
443452
grunt.loadNpmTasks('gruntify-eslint');
444-
grunt.loadNpmTasks('grunt-contrib-qunit');
445-
grunt.loadNpmTasks('grunt-run-java');
446453
grunt.loadNpmTasks('grunt-browserify');
447454
grunt.loadNpmTasks('grunt-contrib-rename');
448455
grunt.loadNpmTasks('grunt-string-replace');
449456
grunt.loadNpmTasks('grunt-shell-spawn');
450457
grunt.loadNpmTasks('grunt-banner');
458+
grunt.loadNpmTasks('grunt-karma');
451459

452460
// Default task.
453461
grunt.registerTask('build', ['clean:all',
454462
'browserify',
455463
'eslint',
456464
'copy:dist_debug',
457465
'copy:dist_ext_lib',
458-
'copy:config_coverage',
459-
'copy:test_coverage',
460-
'copy:lib_coverage',
461466
'copy:temp_debug',
462467
'terser:minifyMinForBundleWithComments',
463468
'terser:minifyMinForBundleWithoutComments',
464469
'copy:temp_min',
465470
'requirejs:compileBundles_min',
466471
'requirejs:compileBundles_debug',
467-
'run_java',
468472
'rename',
469473
'string-replace',
470474
'copy:dist_bundles_debug',
@@ -473,9 +477,65 @@ module.exports = function (grunt) {
473477
'clean:bundles_debug',
474478
'clean:bundles_min',
475479
'usebanner',
476-
'shell:start_test_server',
477-
'qunit',
480+
'run-karma-mocha',
478481
'jsdoc',
479482
'copy:oracle_logo'
480-
]);
483+
]);
484+
485+
function buildKarmaMochaTestTasks() {
486+
karmaSetup.testTasks.push('clean:karmaCoverage');
487+
karmaSetup.testTasks.push('shell:start_test_server');
488+
karmaSetup.karmaTestFiles.forEach((file, index) => {
489+
var taskName = 'run-karma-mocha-test-'+ (index+1);
490+
karmaSetup.testTasks.push(taskName);
491+
grunt.task.registerTask(taskName, function() {
492+
grunt.config.set('karma.unit.fileToTest', file.testFile);
493+
grunt.config.set('karma.unit.coverageFile', file.coverageFile);
494+
grunt.task.run('karma');
495+
});
496+
})
497+
karmaSetup.testTasks.push('shell:karma_coverage_report'); // Task to generate coverage report
498+
}
499+
500+
function runTargetTestFiles(testFileParam) {
501+
karmaSetup.karmaTestFiles = [];
502+
var testFiles = testFileParam.split(',');
503+
testFiles.forEach(file => {
504+
var fileName = file+'.js',
505+
filePath = karmaSetup.karmaTestFolder + fileName;
506+
if(fs.existsSync(filePath)) {
507+
setKarmaTestFiles(filePath, fileName);
508+
}
509+
else {
510+
grunt.fail.warn(`No test file named ${fileName} exists in karma test directory`)
511+
}
512+
})
513+
}
514+
515+
516+
grunt.task.registerTask('run-karma-mocha', function() {
517+
helper.fetchFilesFromDirectory(karmaSetup.karmaTestFolder, setKarmaTestFiles);
518+
helper.fetchFilesFromDirectory(karmaSetup.optSourceFolder, generateKarmaPreProcessorFiles); // Generate Preprocessors for Karma
519+
520+
if(grunt.option('test')) {
521+
var testFileParam = grunt.option('test');
522+
if(typeof testFileParam === 'string')
523+
runTargetTestFiles(testFileParam);
524+
else
525+
grunt.fail.warn("No test file provided as input!!");
526+
}
527+
if(grunt.option('browser')) {
528+
var browser = grunt.option('browser');
529+
grunt.config.set('karma.unit.browser', browser);
530+
}
531+
if(typeof grunt.option('singleRun') === 'boolean')
532+
grunt.config.set('karma.unit.singleRun', grunt.option('singleRun'));
533+
534+
buildKarmaMochaTestTasks(); // Generates batch of karma mocha tests
535+
grunt.task.run(karmaSetup.testTasks);
536+
});
537+
538+
grunt.task.registerTask('run-karma-coverage', function() {
539+
grunt.task.run('run-karma-mocha');
540+
});
481541
};

JSDOC.md

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

33
## Introduction ##
44

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# offline-persistence-toolkit 1.5.4 #
1+
# offline-persistence-toolkit 1.5.5 #
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.5.4/min'
61+
'persist' : 'js/libs/persist/v1.5.5/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.5.4/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.5.5/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.5.4/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.5.5/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-7.2.2',
9393
'pouchfind': 'js/libs/pouchdb.find',
94-
'persist' : 'js/libs/persist/v1.5.4/min'
94+
'persist' : 'js/libs/persist/v1.5.5/min'
9595

9696
// Other path mappings here
9797
}
@@ -305,23 +305,23 @@ The simpleJsonShredding implementation assumes that the response payload is eith
305305
As the structure of response payloads can vary from endpoint to endpoint, applications can also implement their own custom shredders and unshredders to meet their own needs.
306306
307307
If the backend resource exposed through a collection endpoint allows delete, there are always race conditions where
308-
rows are deleted behind the scenes. If the resource is cached and shredded on the client, it is possible that even
309-
though a row is deleted at the backend, it can still exist on the client. If queryHandler is configured to support
308+
rows are deleted behind the scenes. If the resource is cached and shredded on the client, it is possible that even
309+
though a row is deleted at the backend, it can still exist on the client. If queryHandler is configured to support
310310
querying the shredded client data, that row that does not exist on server will be served from client cache. Application
311-
needs to accept that staleness is a possibility. There is one scenario that Offline Persistence Toolkit can help dealing
311+
needs to accept that staleness is a possibility. There is one scenario that Offline Persistence Toolkit can help dealing
312312
with staleness is when a returned collection from server is known to be complete. A complete collection response contains
313-
all rows of the resources, thus any client side rows that are not in the list will be removed from the shredded store.
313+
all rows of the resources, thus any client side rows that are not in the list will be removed from the shredded store.
314314
A complete collection response is a collection response that is either one of the following:
315315
316316
1. It is a response that is served to a request which does not contain any query parameters
317-
2. It is a response that is served to a request which only contains offset or limit query parameters where offset is 0
317+
2. It is a response that is served to a request which only contains offset or limit query parameters where offset is 0
318318
and the response contains less rows than the specified limit when limit is bigger than 0.
319-
319+
320320
In order for Offline Persistence Toolkit to figure our the offset and limit of the request, queryHandler can
321-
have an optional method normalizeQueryParameter which takes a url and returns a structure as defined in
321+
have an optional method normalizeQueryParameter which takes a url and returns a structure as defined in
322322
[NormalizedQuery](https://oracle.github.io/offline-persistence-toolkit/NormalizedQuery.html "NormalizedQuery").
323323
The two out-of-box queryHandlers support normalizeQueryParameter. Any custom queryHandler that would like to
324-
leverage this feature needs to implement normalizeQueryParameter.
324+
leverage this feature needs to implement normalizeQueryParameter.
325325
326326
327327
## Modifications: PUT and DELETE ##

USAGE.md

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

33
# Introduction #
44

0 commit comments

Comments
 (0)