Skip to content

Commit 3f995af

Browse files
Merge pull request #185 from terminusdb/generate-types
Generate type definitions for typescript
2 parents 54d8b83 + 087ce70 commit 3f995af

26 files changed

+102
-77
lines changed

.github/workflows/production.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
registry-url: 'https://registry.npmjs.org'
1919
- run: npm install
2020
- run: npm run build
21+
- run: npm run generate-types
2122
- run: npm publish
2223
env:
2324
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

docs/api/typedef.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ the DELETE document interface query parameters
113113
| [branch] | <code>string</code> | set branch to this id |
114114
| [ref] | <code>string</code> | set commit ref |
115115
| [default_branch_id] | <code>string</code> | set the default branch id |
116+
| [token] | <code>string</code> | Api token to connect with TerminusX |
116117

117118

118119
## RolesObj

docs/api/woql.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@ Syntactic sugar to allow writing WOQL.triple()... instead of new WOQLQuery().tri
99
Every function matches one of the public api functions of the woql query object
1010

1111

12-
## eval
13-
##### WOQL.eval ⇒ <code>WOQLQuery</code>
14-
Evaluates the passed arithmetic expression and generates or matches the result value
15-
16-
**Returns**: <code>WOQLQuery</code> - WOQLQuery
17-
18-
| Param | Type | Description |
19-
| --- | --- | --- |
20-
| arithExp | <code>object</code> \| <code>WOQLQuery</code> \| <code>string</code> | query or JSON-LD representing the query |
21-
| resultVarName | <code>string</code> | output variable |
22-
23-
2412
## using
2513
##### WOQL.using(refPath, subquery) ⇒ <code>WOQLQuery</code>
2614
Query running against any specific commit Id
@@ -531,6 +519,18 @@ let [result] = vars("result")
531519
evaluate(plus(2, minus(3, 1)), result)
532520
```
533521

522+
## eval
523+
##### WOQL.eval(arithExp, resultVarName) ⇒ <code>WOQLQuery</code>
524+
Evaluates the passed arithmetic expression and generates or matches the result value
525+
526+
**Returns**: <code>WOQLQuery</code> - WOQLQuery
527+
528+
| Param | Type | Description |
529+
| --- | --- | --- |
530+
| arithExp | <code>object</code> \| <code>WOQLQuery</code> \| <code>string</code> | query or JSON-LD representing the query |
531+
| resultVarName | <code>string</code> | output variable |
532+
533+
534534
## plus
535535
##### WOQL.plus(...args) ⇒ <code>WOQLQuery</code>
536536
Adds the numbers together

docs/api/woqlclient.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ client.organization("admin")
339339
```
340340
341341
## getDatabases
342-
##### woqlClient.getDatabases() ⇒ <code>string</code> \| <code>boolean</code>
342+
##### woqlClient.getDatabases() ⇒ <code>Promise</code>
343343
Gets the organization's databases list.
344344
345345
If no organization has been set up, the function throws an exception

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 };

0 commit comments

Comments
 (0)