Skip to content

Commit 5b5e6c0

Browse files
committed
=BG= stub methods for fluent interface API
- also add a very minimal test just to be able to run the test task
1 parent 4b9b1d2 commit 5b5e6c0

File tree

4 files changed

+144
-2
lines changed

4 files changed

+144
-2
lines changed

graph.js

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
'use strict';
2+
3+
var Q = require('q');
4+
5+
function qryqGraph(context) {
6+
var api = context.api;
7+
if (typeof api !== 'object') {
8+
throw new Error('Expected an API object');
9+
}
10+
11+
var fluent = {
12+
queries: [],
13+
query: query,
14+
api: api,
15+
input: input,
16+
depends: depends,
17+
filterOutput: filterOutput,
18+
allQueries: allQueries,
19+
run: run,
20+
};
21+
var currentQuery;
22+
23+
/**
24+
* query begins describing a new query.
25+
* subsequent calls to input, depends, and filterOutput will apply to this query
26+
*
27+
* @param id {string}
28+
* @return {Fluent}
29+
*/
30+
function query(id) {
31+
//TODO
32+
return fluent;
33+
}
34+
35+
/**
36+
* api specifies the name of the API the current query should invoke
37+
*
38+
* @param name {string}
39+
* @return {Fluent}
40+
*/
41+
function api(name) {
42+
//TODO
43+
return fluent;
44+
}
45+
46+
/**
47+
* input specifies what the input to pass to the identified API function.
48+
*
49+
* Input fields may be specified as strings such as `'#{ANOTHER_QUERYS_NAME}'`
50+
* or `'#{ANOTHER_QUERYS_NAME}.foo.bar'`.
51+
* qryq will then identify these other queries as the current query's dependents,
52+
* and wait for them to complete execution before beginning this one.
53+
* It will also substitute the correct values from the return value of the
54+
* dependent queries.
55+
*
56+
* @param data {Object}
57+
* @return {Fluent}
58+
*/
59+
function input(data) {
60+
//TODO
61+
return fluent;
62+
}
63+
64+
/**
65+
* depends specifies which other queries need to complete
66+
* execution prior to beginning executing the current one.
67+
*
68+
* This is **optional**, as if this is not specified,
69+
* qryq will parse the input object for expressions.
70+
*
71+
* @param dependIds {Array<string>}
72+
* @return {Fluent}
73+
*/
74+
function depends(dependIds) {
75+
//TODO
76+
return fluent;
77+
}
78+
79+
/**
80+
* filterOutput, when called with `true`, specifies that the output of the
81+
* current query should be **excluded** from the final result returned.
82+
*
83+
* This is **optional**, as is this is not specified,
84+
* qryq simply inlcudes the results in the output by default.
85+
*
86+
* @param shouldFilter {boolean}
87+
* @return {Fluent}
88+
*/
89+
function filterOutput(shouldFilter) {
90+
//TODO
91+
return fluent;
92+
}
93+
94+
/**
95+
* allQueries specifies the entire list of queries.
96+
*
97+
* This should only be called once,
98+
* and other queries should not be manually specified if this is used.
99+
*
100+
* @param {Array<GraphQuery>}
101+
* @return {Fluent}
102+
*/
103+
function allQueries(list) {
104+
//TODO
105+
return fluent;
106+
}
107+
108+
/**
109+
* run finalises the list of queries and then executes them.
110+
* The promise it returns will resolve the final results of the
111+
* dependent set of queries.
112+
*
113+
* @return {Promise}
114+
*/
115+
function run() {
116+
var deferred = Q.defer();
117+
//TODO execute graph of queries using deferred and fluent.queries
118+
return deferred.promise;
119+
}
120+
121+
return fluent;
122+
}
123+
124+
module.exports = qryqGraph;

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "qryq",
33
"preferGlobal": false,
4-
"description": "qryq allows one to express a series of queries and define dependencies between them either in parallel, in sequence, or in a directed acyclic graph",
4+
"description": "express and run arbitrary sets of dependent queries as directed acyclic graphs.",
55
"author": ["bguiz"],
66
"config": {
77
"defaults": {},
@@ -11,7 +11,7 @@
1111
"bugs": {
1212
"url": "https://github.com/bguiz/qryq/issues"
1313
},
14-
"version": "0.0.10",
14+
"version": "1.0.0-alpha",
1515
"engines": {
1616
"node": ">= 0.8.10"
1717
},

qryq.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
module.exports = {
4+
graph: require('./graph'),
5+
};

test/qryq.spec.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
4+
describe('[main]', function() {
5+
it('Should get a qryq instance', function(done) {
6+
var qryq;
7+
expect(function() {
8+
qryq = require('../qryq');
9+
}).not.toThrow();
10+
expect(typeof qryq.graph).toEqual('function');
11+
done();
12+
})
13+
});

0 commit comments

Comments
 (0)