Skip to content

Commit 9dcfc1c

Browse files
refactored code for generating type definations
Signed-off-by: NeelParihar <[email protected]>
1 parent 8e80e8b commit 9dcfc1c

22 files changed

+85
-63
lines changed

lib/query/woqlCore.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const { Var, Doc } = require('./woqlDoc');
2222
* @module WOQLQuery
2323
* @constructor
2424
* @param {object} [query] json-ld query for initialisation
25+
* @returns {WOQLQuery}
2526
*/
2627
function WOQLQuery(query) {
2728
this.query = query || {};

lib/typedef.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
* @property {string} [branch] - set branch to this id
9494
* @property {string} [ref] - set commit ref
9595
* @property {string} [default_branch_id] - set the default branch id
96+
* @property {string} [token] - Api token to connect with TerminusX
9697
*/
9798

9899
/**

lib/viewer/chartConfig.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ function WOQLChartConfig() {
1010
this.type = 'chart';
1111
}
1212

13-
WOQLChartConfig.prototype = Object.create(Config.ViewConfig.prototype);
14-
WOQLChartConfig.prototype.constructor = Config.ViewConfig;
13+
Object.setPrototypeOf(WOQLChartConfig.prototype, Config.ViewConfig.prototype);
1514

1615
WOQLChartConfig.prototype.prettyPrint = function () {
1716
let str = 'view = View.chart();\n';
@@ -214,8 +213,7 @@ function WOQLChartRule() {
214213
Config.WOQLViewRule.call(this);
215214
}
216215

217-
WOQLChartRule.prototype = Object.create(Config.WOQLViewRule.prototype);
218-
WOQLChartRule.prototype.constructor = Config.WOQLViewRule;
216+
Object.setPrototypeOf(WOQLChartRule.prototype, Config.WOQLViewRule.prototype);
219217

220218
WOQLChartRule.prototype.style = function (key, value) {
221219
if (value) {

lib/viewer/chooserConfig.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function WOQLChooserConfig() {
99
this.type = 'chooser';
1010
}
1111

12-
WOQLChooserConfig.prototype = Object.create(Config.ViewConfig.prototype);
13-
WOQLChooserConfig.prototype.constructor = Config.ViewConfig;
12+
Object.setPrototypeOf(WOQLChooserConfig.prototype, Config.ViewConfig.prototype);
1413

1514
WOQLChooserConfig.prototype.create = function (client) {
1615
const wqt = new WOQLChooser(client, this);
@@ -180,8 +179,7 @@ function WOQLChooserRule(scope) {
180179
Config.WOQLViewRule.call(this, scope);
181180
}
182181

183-
WOQLChooserRule.prototype = Object.create(Config.WOQLViewRule.prototype);
184-
WOQLChooserRule.prototype.constructor = Config.WOQLViewRule;
182+
Object.setPrototypeOf(WOQLChooserRule.prototype, Config.WOQLViewRule.prototype);
185183

186184
WOQLChooserRule.prototype.label = function (l) {
187185
if (l) {

lib/viewer/frameConfig.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/* eslint-disable no-plusplus */
1111
/* eslint-disable import/extensions */
1212
const Config = require('./viewConfig.js');
13-
const FrameRule = require('./frameRule.js');
13+
const { FrameRule } = require('./frameRule.js');
1414
const DocumentFrame = require('./documentFrame.js');
1515

1616
/**
@@ -22,8 +22,7 @@ function FrameConfig() {
2222
this.type = 'document';
2323
}
2424

25-
FrameConfig.prototype = Object.create(Config.ViewConfig.prototype);
26-
FrameConfig.prototype.constructor = Config.ViewConfig;
25+
Object.setPrototypeOf(FrameConfig.prototype, Config.ViewConfig.prototype);
2726

2827
FrameConfig.prototype.create = function (client) {
2928
const tf = new DocumentFrame(client, this);
@@ -192,8 +191,7 @@ function DocumentRule() {
192191
this.rule = {};
193192
}
194193

195-
DocumentRule.prototype = Object.create(FrameRule.prototype);
196-
DocumentRule.prototype.constructor = FrameRule;
194+
Object.setPrototypeOf(DocumentRule.prototype, FrameRule.prototype);
197195

198196
DocumentRule.prototype.renderer = function (rend) {
199197
if (typeof rend === 'undefined') {

lib/viewer/frameRule.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function FrameRule() {
1717
TerminusRule.TerminusRule.call(this);
1818
this.pattern = new FramePattern();
1919
}
20-
FrameRule.prototype = Object.create(TerminusRule.TerminusRule.prototype);
21-
FrameRule.prototype.constructor = TerminusRule.TerminusRule;
20+
21+
Object.setPrototypeOf(FrameRule.prototype, TerminusRule.TerminusRule.prototype);
2222

2323
/**
2424
* Returns an array of rules that match the paased frame
@@ -189,8 +189,7 @@ function FramePattern() {
189189
TerminusRule.TerminusPattern.call(this);
190190
}
191191

192-
FramePattern.prototype = Object.create(TerminusRule.TerminusPattern.prototype);
193-
FramePattern.prototype.constructor = TerminusRule.TerminusPattern;
192+
Object.setPrototypeOf(FramePattern.prototype, TerminusRule.TerminusPattern.prototype);
194193

195194
FramePattern.prototype.setPattern = function (pattern) {
196195
if (pattern.scope) this.scope = pattern.scope;
@@ -513,4 +512,4 @@ FramePattern.prototype.getRendererType = function (frame) {
513512
return false;
514513
};
515514

516-
module.exports = FrameRule;
515+
module.exports = { FrameRule, FramePattern };

lib/viewer/graphConfig.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ function WOQLGraphConfig() {
1313
this.type = 'graph';
1414
}
1515

16-
WOQLGraphConfig.prototype = Object.create(Config.ViewConfig.prototype);
17-
WOQLGraphConfig.prototype.constructor = Config.ViewConfig;
16+
Object.setPrototypeOf(WOQLGraphConfig.prototype, Config.ViewConfig.prototype);
1817

1918
WOQLGraphConfig.prototype.create = function (client) {
2019
const wqt = new WOQLGraph(client, this);
@@ -107,6 +106,11 @@ WOQLGraphConfig.prototype.height = function (size) {
107106
return this.gheight;
108107
};
109108

109+
/**
110+
*
111+
* @param {...any} edges
112+
* @returns {any[][]}
113+
*/
110114
WOQLGraphConfig.prototype.edges = function (...edges) {
111115
if (edges && edges.length) {
112116
const nedges = [];
@@ -265,8 +269,7 @@ function WOQLGraphRule(scope) {
265269
Config.WOQLViewRule.call(this, scope);
266270
}
267271

268-
WOQLGraphRule.prototype = Object.create(Config.WOQLViewRule.prototype);
269-
WOQLGraphRule.prototype.constructor = Config.WOQLViewRule;
272+
Object.setPrototypeOf(WOQLGraphRule.prototype, Config.WOQLViewRule.prototype);
270273

271274
WOQLGraphRule.prototype.charge = function (v) {
272275
if (typeof v === 'undefined') {

lib/viewer/objectFrame.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/* eslint-disable no-restricted-syntax */
1616
/* eslint-disable no-use-before-define */
1717
const FrameHelper = require('../utils');
18-
const FrameRule = require('./frameRule');
18+
const { FrameRule } = require('./frameRule');
1919
const WOQL = require('../woql');
2020

2121
/**

lib/viewer/streamConfig.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ function WOQLStreamConfig() {
66
this.type = 'stream';
77
}
88

9-
WOQLStreamConfig.prototype = Object.create(Config.ViewConfig.prototype);
10-
WOQLStreamConfig.prototype.constructor = Config.ViewConfig;
9+
Object.setPrototypeOf(WOQLStreamConfig.prototype, Config.ViewConfig.prototype);
1110

1211
WOQLStreamConfig.prototype.create = function (client) {
1312
const wqt = new WOQLStream(client, this);
@@ -72,8 +71,7 @@ function WOQLStreamRule() {
7271
Config.WOQLViewRule.call(this);
7372
}
7473

75-
WOQLStreamRule.prototype = Object.create(Config.WOQLViewRule.prototype);
76-
WOQLStreamRule.prototype.constructor = Config.WOQLViewRule;
74+
Object.setPrototypeOf(WOQLStreamRule.prototype, Config.WOQLViewRule.prototype);
7775

7876
WOQLStreamRule.prototype.template = function (template) {
7977
if (!template) return this.rule.template;

lib/viewer/tableConfig.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ function WOQLTableConfig() {
99
this.type = 'table';
1010
}
1111

12-
WOQLTableConfig.prototype = Object.create(Config.ViewConfig.prototype);
13-
WOQLTableConfig.prototype.constructor = Config.ViewConfig;
12+
Object.setPrototypeOf(WOQLTableConfig.prototype, Config.ViewConfig.prototype);
1413

1514
WOQLTableConfig.prototype.create = function (client) {
1615
const wqt = new WOQLTable(client, this);
@@ -121,6 +120,10 @@ WOQLTableConfig.prototype.header = function (theader) {
121120
return this;
122121
};
123122

123+
/**
124+
* @param {...any} val
125+
* @returns {object}
126+
*/
124127
WOQLTableConfig.prototype.column_order = function (...val) {
125128
if (typeof val === 'undefined' || val.length === 0) {
126129
return this.order;
@@ -180,8 +183,7 @@ function WOQLTableRule() {
180183
Config.WOQLViewRule.call(this);
181184
}
182185

183-
WOQLTableRule.prototype = Object.create(Config.WOQLViewRule.prototype);
184-
WOQLTableRule.prototype.constructor = Config.WOQLViewRule;
186+
Object.setPrototypeOf(WOQLTableRule.prototype, Config.WOQLViewRule.prototype);
185187

186188
WOQLTableRule.prototype.header = function (hdr) {
187189
if (typeof hdr === 'undefined') {

0 commit comments

Comments
 (0)