Skip to content

Commit

Permalink
Fixes #236.
Browse files Browse the repository at this point in the history
Stable Version 2.6.0
  • Loading branch information
jmdobry committed Oct 9, 2015
1 parent 29b33e3 commit 95409f7
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 18 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,12 @@
##### 2.6.0 - 08 October 2015

###### Backwards compatible API changes
- #234 - findAll should query adapter if previous query is expired.
- #235 - Support maxAge in find/findAll requests by @antoinebrault

###### Bug fixes
- #236 - actions defined in defineResource are shared across definitions

##### 2.5.0 - 04 October 2015

###### Backwards compatible API changes
Expand Down
26 changes: 20 additions & 6 deletions dist/js-data-debug.js
@@ -1,6 +1,6 @@
/*!
* js-data
* @version 2.5.0 - Homepage <http://www.js-data.io/>
* @version 2.6.0 - Homepage <http://www.js-data.io/>
* @author Jason Dobry <jason.dobry@gmail.com>
* @copyright (c) 2014-2015 Jason Dobry
* @license MIT <https://github.com/js-data/js-data/blob/master/LICENSE>
Expand Down Expand Up @@ -84,9 +84,9 @@ return /******/ (function(modules) { // webpackBootstrap
return new _datastoreIndex['default'](options);
},
version: {
full: '2.5.0',
full: '2.6.0',
major: parseInt('2', 10),
minor: parseInt('5', 10),
minor: parseInt('6', 10),
patch: parseInt('0', 10),
alpha: true ? 'false' : false,
beta: true ? 'false' : false
Expand Down Expand Up @@ -3371,6 +3371,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.methods = {};
this.computed = {};
this.scopes = {};
this.actions = {};
_utils['default'].deepMixIn(this, options);
var parent = _this.defaults;
if (definition['extends'] && definitions[definition['extends']]) {
Expand All @@ -3380,6 +3381,7 @@ return /******/ (function(modules) { // webpackBootstrap
_utils['default'].fillIn(this.methods, parent.methods);
_utils['default'].fillIn(this.computed, parent.computed);
_utils['default'].fillIn(this.scopes, parent.scopes);
_utils['default'].fillIn(this.actions, parent.actions);
this.endpoint = 'endpoint' in options ? options.endpoint : this.name;
}

Expand Down Expand Up @@ -3705,11 +3707,17 @@ return /******/ (function(modules) { // webpackBootstrap
config.url = _utils['default'].makePath.apply(null, args);
}
config.method = config.method || 'GET';
config.resourceName = def.name;
_utils['default'].deepMixIn(config, options);
return new _utils['default'].Promise(function (resolve) {
return resolve(config);
}).then(options.request || action.request).then(function (config) {
return adapter.HTTP(config);
}).then(function (data) {
if (data && data.config) {
data.config.resourceName = def.name;
}
return data;
}).then(options.response || action.response, options.responseError || action.responseError);
};
});
Expand Down Expand Up @@ -4629,7 +4637,10 @@ return /******/ (function(modules) { // webpackBootstrap
if (options.bypassCache || !options.cacheResponse) {
delete resource.completedQueries[id];
}
if ((!options.findStrictCache || id in resource.completedQueries) && definition.get(id) && !options.bypassCache) {

var expired = options.maxAge && id in resource.completedQueries && resource.completedQueries[id] + options.maxAge < new Date().getTime();

if ((!options.findStrictCache || id in resource.completedQueries) && definition.get(id) && !options.bypassCache && !expired) {
// resolve immediately with the cached item
resolve(definition.get(id));
} else {
Expand Down Expand Up @@ -4780,7 +4791,10 @@ return /******/ (function(modules) { // webpackBootstrap
delete resource.completedQueries[queryHash];
delete resource.queryData[queryHash];
}
if (queryHash in resource.completedQueries) {

var expired = options.maxAge && queryHash in resource.completedQueries && resource.completedQueries[queryHash] + options.maxAge < new Date().getTime();

if (queryHash in resource.completedQueries && !expired) {
if (options.useFilter) {
if (options.localKeys) {
resolve(definition.getAll(options.localKeys, options.orig()));
Expand All @@ -4797,7 +4811,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
}).then(function (items) {
if (!(queryHash in resource.completedQueries)) {
if (!items) {
if (!(queryHash in resource.pendingQueries)) {
var promise = undefined;
var strategy = options.findAllStrategy || options.strategy;
Expand Down
26 changes: 20 additions & 6 deletions dist/js-data.js
@@ -1,6 +1,6 @@
/*!
* js-data
* @version 2.5.0 - Homepage <http://www.js-data.io/>
* @version 2.6.0 - Homepage <http://www.js-data.io/>
* @author Jason Dobry <jason.dobry@gmail.com>
* @copyright (c) 2014-2015 Jason Dobry
* @license MIT <https://github.com/js-data/js-data/blob/master/LICENSE>
Expand Down Expand Up @@ -84,9 +84,9 @@ return /******/ (function(modules) { // webpackBootstrap
return new _datastoreIndex['default'](options);
},
version: {
full: '2.5.0',
full: '2.6.0',
major: parseInt('2', 10),
minor: parseInt('5', 10),
minor: parseInt('6', 10),
patch: parseInt('0', 10),
alpha: true ? 'false' : false,
beta: true ? 'false' : false
Expand Down Expand Up @@ -3361,6 +3361,7 @@ return /******/ (function(modules) { // webpackBootstrap
this.methods = {};
this.computed = {};
this.scopes = {};
this.actions = {};
_utils['default'].deepMixIn(this, options);
var parent = _this.defaults;
if (definition['extends'] && definitions[definition['extends']]) {
Expand All @@ -3370,6 +3371,7 @@ return /******/ (function(modules) { // webpackBootstrap
_utils['default'].fillIn(this.methods, parent.methods);
_utils['default'].fillIn(this.computed, parent.computed);
_utils['default'].fillIn(this.scopes, parent.scopes);
_utils['default'].fillIn(this.actions, parent.actions);
this.endpoint = 'endpoint' in options ? options.endpoint : this.name;
}

Expand Down Expand Up @@ -3694,11 +3696,17 @@ return /******/ (function(modules) { // webpackBootstrap
config.url = _utils['default'].makePath.apply(null, args);
}
config.method = config.method || 'GET';
config.resourceName = def.name;
_utils['default'].deepMixIn(config, options);
return new _utils['default'].Promise(function (resolve) {
return resolve(config);
}).then(options.request || action.request).then(function (config) {
return adapter.HTTP(config);
}).then(function (data) {
if (data && data.config) {
data.config.resourceName = def.name;
}
return data;
}).then(options.response || action.response, options.responseError || action.responseError);
};
});
Expand Down Expand Up @@ -4607,7 +4615,10 @@ return /******/ (function(modules) { // webpackBootstrap
if (options.bypassCache || !options.cacheResponse) {
delete resource.completedQueries[id];
}
if ((!options.findStrictCache || id in resource.completedQueries) && definition.get(id) && !options.bypassCache) {

var expired = options.maxAge && id in resource.completedQueries && resource.completedQueries[id] + options.maxAge < new Date().getTime();

if ((!options.findStrictCache || id in resource.completedQueries) && definition.get(id) && !options.bypassCache && !expired) {
// resolve immediately with the cached item
resolve(definition.get(id));
} else {
Expand Down Expand Up @@ -4757,7 +4768,10 @@ return /******/ (function(modules) { // webpackBootstrap
delete resource.completedQueries[queryHash];
delete resource.queryData[queryHash];
}
if (queryHash in resource.completedQueries) {

var expired = options.maxAge && queryHash in resource.completedQueries && resource.completedQueries[queryHash] + options.maxAge < new Date().getTime();

if (queryHash in resource.completedQueries && !expired) {
if (options.useFilter) {
if (options.localKeys) {
resolve(definition.getAll(options.localKeys, options.orig()));
Expand All @@ -4774,7 +4788,7 @@ return /******/ (function(modules) { // webpackBootstrap
}
}
}).then(function (items) {
if (!(queryHash in resource.completedQueries)) {
if (!items) {
if (!(queryHash in resource.pendingQueries)) {
var promise = undefined;
var strategy = options.findAllStrategy || options.strategy;
Expand Down
6 changes: 3 additions & 3 deletions dist/js-data.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js-data.min.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "js-data",
"description": "Robust, framework-agnostic in-memory data store.",
"version": "2.5.0",
"version": "2.6.0",
"homepage": "http://www.js-data.io",
"repository": {
"type": "git",
Expand Down Expand Up @@ -50,7 +50,7 @@
"jshint-loader": "0.8.3",
"karma": "0.13.10",
"karma-chai": "0.1.0",
"karma-chrome-launcher": "0.2.0",
"karma-chrome-launcher": "0.2.1",
"karma-coverage": "0.5.2",
"karma-firefox-launcher": "0.1.6",
"karma-mocha": "0.2.0",
Expand Down
9 changes: 9 additions & 0 deletions src/datastore/sync_methods/defineResource.js
Expand Up @@ -61,6 +61,7 @@ module.exports = function defineResource (definition) {
this.methods = {}
this.computed = {}
this.scopes = {}
this.actions = {}
DSUtils.deepMixIn(this, options)
let parent = _this.defaults
if (definition.extends && definitions[definition.extends]) {
Expand All @@ -70,6 +71,7 @@ module.exports = function defineResource (definition) {
DSUtils.fillIn(this.methods, parent.methods)
DSUtils.fillIn(this.computed, parent.computed)
DSUtils.fillIn(this.scopes, parent.scopes)
DSUtils.fillIn(this.actions, parent.actions)
this.endpoint = ('endpoint' in options) ? options.endpoint : this.name
}

Expand Down Expand Up @@ -350,10 +352,17 @@ module.exports = function defineResource (definition) {
config.url = DSUtils.makePath.apply(null, args)
}
config.method = config.method || 'GET'
config.resourceName = def.name
DSUtils.deepMixIn(config, options)
return new DSUtils.Promise(function (resolve) { return resolve(config) })
.then(options.request || action.request)
.then(function (config) { return adapter.HTTP(config) })
.then(function (data) {
if (data && data.config) {
data.config.resourceName = def.name
}
return data
})
.then(options.response || action.response, options.responseError || action.responseError)
}
})
Expand Down

0 comments on commit 95409f7

Please sign in to comment.