1.2.3 - paginate true, exporting function for grapher live, fixed package implying

This commit is contained in:
Theodor Diaconu 2016-11-07 18:44:09 +02:00
parent 52de82ed6f
commit 35511bec7c
10 changed files with 130 additions and 22 deletions

View file

@ -1,14 +1,79 @@
{
"dependencies": {
"balanced-match": {
"version": "0.4.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz",
"from": "balanced-match@>=0.4.1 <0.5.0"
},
"brace-expansion": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.6.tgz",
"from": "brace-expansion@>=1.0.0 <2.0.0"
},
"commander": {
"version": "2.9.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz",
"from": "commander@>=2.9.0 <3.0.0"
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"from": "concat-map@0.0.1"
},
"dot-object": {
"version": "1.5.4",
"resolved": "https://registry.npmjs.org/dot-object/-/dot-object-1.5.4.tgz",
"from": "dot-object@1.5.4"
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"from": "fs.realpath@>=1.0.0 <2.0.0"
},
"glob": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz",
"from": "glob@>=7.0.5 <8.0.0"
},
"graceful-readlink": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz",
"from": "graceful-readlink@>=1.0.0"
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"from": "inflight@>=1.0.4 <2.0.0"
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"from": "inherits@>=2.0.0 <3.0.0"
},
"minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.3.tgz",
"from": "minimatch@>=3.0.2 <4.0.0"
},
"once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"from": "once@>=1.3.0 <2.0.0"
},
"path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"from": "path-is-absolute@>=1.0.0 <2.0.0"
},
"sift": {
"version": "3.2.6",
"resolved": "https://registry.npmjs.org/sift/-/sift-3.2.6.tgz",
"from": "sift@3.2.6"
},
"underscore": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
"from": "underscore@1.8.3"
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"from": "wrappy@>=1.0.0 <2.0.0"
}
}
}

View file

@ -1,3 +1,8 @@
## 1.2.3
- Added $paginate: true, at the first level body which puts as options limit and skip from params automatically
- Exported "prepareForProcess" so Grapher Live can use it
- Fixed implying packages for broader adoption
## 1.2.2_x
- Bug fixes and improvements

View file

@ -3,7 +3,7 @@ import ExposeSchema from './schema.js';
import mergeDeep from './lib/mergeDeep.js';
import createGraph from '../../query/lib/createGraph.js';
import recursiveCompose from '../../query/lib/recursiveCompose.js';
import applyFilterFunction from '../../query/lib/applyFilterFunction.js';
import prepareForProcess from '../../query/lib/prepareForProcess.js';
import deepClone from '../../query/lib/deepClone.js';
_.extend(NamedQuery.prototype, {
@ -84,7 +84,7 @@ _.extend(NamedQuery.prototype, {
}
let params = _.extend({}, self.params, newParams);
let body = applyFilterFunction(self.body, params);
let body = prepareForProcess(self.body, params);
const rootNode = createGraph(self.collection, body);

View file

@ -1,6 +1,6 @@
import createGraph from '../query/lib/createGraph.js';
import recursiveFetch from '../query/lib/recursiveFetch.js';
import applyFilterFunction from '../query/lib/applyFilterFunction.js';
import prepareForProcess from '../query/lib/prepareForProcess.js';
import Base from './namedQuery.base';
export default class extends Base {
@ -86,7 +86,7 @@ export default class extends Base {
* @private
*/
_fetchReactive(options = {}) {
let body = applyFilterFunction(this.body, this.params);
let body = prepareForProcess(this.body, this.params);
if (!options.allowSkip && body.$options && body.$options.skip) {
delete body.$options.skip;
}

View file

@ -1,4 +1,4 @@
import applyFilterFunction from '../query/lib/applyFilterFunction.js';
import prepareForProcess from '../query/lib/prepareForProcess.js';
import deepClone from '../query/lib/deepClone.js';
import Base from './namedQuery.base';
@ -30,7 +30,7 @@ export default class extends Base {
* @returns {any}
*/
getCount() {
let body = applyFilterFunction(this.body, this.params);
let body = prepareForProcess(this.body, this.params);
return this.collection.find(body.$filters || {}, {}).count();
}
}

View file

@ -22,10 +22,33 @@ function applyFilterRecursive(data, params = {}) {
})
}
function applyPagination(body, _params) {
if (body['$paginate'] && _params) {
if (!body.$options) {
body.$options = {};
}
if (_params.limit) {
_.extend(body.$options, {
limit: _params.limit
})
}
if (_params.skip) {
_.extend(body.$options, {
skip: _params.skip
})
}
delete body['$paginate'];
}
}
export default (_body, _params = {}) => {
let body = deepClone(_body);
let params = deepClone(_params);
applyPagination(body, params);
applyFilterRecursive(body, params);
return body;

View file

@ -1,6 +1,6 @@
import createGraph from './lib/createGraph.js';
import recursiveFetch from './lib/recursiveFetch.js';
import applyFilterFunction from './lib/applyFilterFunction.js';
import prepareForProcess from './lib/prepareForProcess.js';
import deepClone from './lib/deepClone.js';
import Base from './query.base';
@ -14,7 +14,7 @@ export default class Query extends Base {
subscribe(callback) {
this.subscriptionHandle = Meteor.subscribe(
this.name,
applyFilterFunction(this.body, this.params),
prepareForProcess(this.body, this.params),
callback
);
@ -55,7 +55,7 @@ export default class Query extends Base {
throw new Meteor.Error('not-allowed', 'You are on client so you must either provide a callback to get the count.');
}
return Meteor.call(this.name + '.count', applyFilterFunction(this.body, this.params), callback);
return Meteor.call(this.name + '.count', prepareForProcess(this.body, this.params), callback);
}
/**
@ -68,7 +68,7 @@ export default class Query extends Base {
throw new Meteor.Error('not-allowed', 'You are on client so you must either provide a callback to get the data or subscribe first.');
}
Meteor.call(this.name, applyFilterFunction(this.body, this.params), callback);
Meteor.call(this.name, prepareForProcess(this.body, this.params), callback);
}
/**
@ -79,7 +79,7 @@ export default class Query extends Base {
* @private
*/
_fetchReactive(options = {}) {
let body = applyFilterFunction(this.body, this.params);
let body = prepareForProcess(this.body, this.params);
if (!options.allowSkip && body.$options && body.$options.skip) {
delete body.$options.skip;
}

View file

@ -1,5 +1,5 @@
import createGraph from './lib/createGraph.js';
import applyFilterFunction from './lib/applyFilterFunction.js';
import prepareForProcess from './lib/prepareForProcess.js';
import hypernova from './hypernova/hypernova.js';
import Base from './query.base';
@ -12,7 +12,7 @@ export default class Query extends Base {
fetch(options = {}) {
const node = createGraph(
this.collection,
applyFilterFunction(this.body, this.params)
prepareForProcess(this.body, this.params)
);
return hypernova(node, options.userId);

View file

@ -9,3 +9,7 @@ export {
export {
default as createNamedQuery
} from './lib/namedQuery/createNamedQuery.js';
export {
default as prepareForProcess
} from './lib/query/lib/prepareForProcess';

View file

@ -1,6 +1,6 @@
Package.describe({
name: 'cultofcoders:grapher',
version: '1.2.2_2',
version: '1.2.3',
// Brief, one-line summary of the package.
summary: 'Grapher makes linking collections easily. And fetching data as a graph.',
// URL to the Git repository containing the source code for this package.
@ -31,7 +31,6 @@ Package.onUse(function (api) {
];
api.use(packages);
api.imply(packages);
api.mainModule('main.client.js', 'client');
api.mainModule('main.server.js', 'server');
@ -40,7 +39,20 @@ Package.onUse(function (api) {
Package.onTest(function (api) {
api.use('cultofcoders:grapher');
api.use('ecmascript');
var packages = [
'ecmascript',
'underscore',
'aldeed:simple-schema@1.5.3',
'aldeed:collection2@2.10.0',
'matb33:collection-hooks@0.8.4',
'reywood:publish-composite@1.4.2',
'dburles:mongo-collection-instances@0.3.5',
'tmeasday:check-npm-versions@0.3.1',
'meteorhacks:aggregate@1.3.0',
'mongo'
];
api.use(packages);
api.use('tracker');
api.use('practicalmeteor:mocha');
@ -69,5 +81,4 @@ Package.onTest(function (api) {
api.addFiles('lib/namedQuery/testing/server.test.js', 'server');
api.addFiles('lib/namedQuery/testing/client.test.js', 'client');
});