Skip to content

Commit 040405d

Browse files
committed
fix lint
1 parent 9570270 commit 040405d

13 files changed

+10568
-87
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jspm_packages
3535

3636

3737
# npm package lock
38-
package-lock.json
38+
#package-lock.json
3939
yarn.lock
4040

4141
others

dist/terminus-client.min.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/terminus-client.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/connectionCapabilities.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,8 @@ ConnectionCapabilities.prototype.capabilitiesPermit = function (action, dbid, se
9292

9393
if (action === CONST.CREATE_DATABASE) {
9494
rec = this.getServerRecord(server);
95-
} else {
96-
if(dbid) rec = this.getDBRecord(dbid);
97-
else console.log("no dbid", server, dbid);
98-
}
95+
} else if (dbid) rec = this.getDBRecord(dbid);
96+
else console.log('no dbid', server, dbid);
9997
if (rec) {
10098
const auths = rec['terminus:authority'];
10199
if (auths && auths.indexOf(`terminus:${action}`) !== -1) return true;
@@ -110,7 +108,7 @@ ConnectionCapabilities.prototype.getServerRecord = function (srvr) {
110108
const url = (srvr || this.connectionConfig.server);
111109
const connectionObj = this.connection[url] || {};
112110
const okeys = Object.keys(connectionObj);
113-
111+
114112
for (const oid of okeys) {
115113
if (this.connection[url][oid]['@type'] === 'terminus:Server') {
116114
return this.connection[url][oid];
@@ -159,7 +157,7 @@ ConnectionCapabilities.prototype.removeDB = function (dbid, srvr) {
159157

160158
const url = srvr || this.connectionConfig.server;
161159
const dbidCap = this.dbCapabilityID(dbid);
162-
if(dbidCap && this.connection[url] && this.connection[url][dbidCap]){
160+
if (dbidCap && this.connection[url] && this.connection[url][dbidCap]) {
163161
delete this.connection[url][dbidCap];
164162
}
165163
};

lib/dispatchRequest.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Access-Control-Allow-Methods GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
99
Access-Control-Allow-Origin: http://localhost:3000 // WILD CARD WILL NOT WORK WHEN POSTING
1010
*/
1111

12-
function btoaImplementation (str){
13-
try {
14-
return btoa(str);
15-
} catch(err) {
16-
//console.log('in buffer')
17-
return Buffer.from(str).toString('base64')
18-
}
19-
};
12+
function btoaImplementation(str) {
13+
try {
14+
return btoa(str);
15+
} catch (err) {
16+
// console.log('in buffer')
17+
return Buffer.from(str).toString('base64');
18+
}
19+
}
2020

2121
function DispatchRequest(url, action, payload) {
2222
const options = {
@@ -26,17 +26,17 @@ function DispatchRequest(url, action, payload) {
2626
// url:url,
2727
// no-referrer, *client
2828
};
29-
if(payload && payload['terminus:user_key']){
30-
options.headers = {'Authorization': 'Basic ' + btoaImplementation(":" + payload['terminus:user_key'])};
31-
delete(payload['terminus:user_key']);
29+
if (payload && payload['terminus:user_key']) {
30+
options.headers = { Authorization: `Basic ${btoaImplementation(`:${payload['terminus:user_key']}`)}` };
31+
delete (payload['terminus:user_key']);
3232
}
3333

3434
switch (action) {
3535
case CONST.DELETE_DATABASE:
3636
case CONST.DELETE_DOCUMENT:
37-
if (payload){
37+
if (payload) {
3838
const ext = UTILS.URIEncodePayload(payload);
39-
if(ext) url += "?" + ext;
39+
if (ext) url += `?${ext}`;
4040
}
4141
return axios.delete(url, options)
4242
.then(response => response.data)
@@ -53,8 +53,8 @@ function DispatchRequest(url, action, payload) {
5353
return axios.post(url, JSON.stringify(payload), options)
5454
.then(response => response.data)
5555
.catch((err) => {
56-
var e = new Error(ErrorMessage.getAPIErrorMessage(url, options, err));
57-
if(err.response && err.response.data) e.data = err.response.data;
56+
const e = new Error(ErrorMessage.getAPIErrorMessage(url, options, err));
57+
if (err.response && err.response.data) e.data = err.response.data;
5858
throw e;
5959
});
6060
case CONST.GET_SCHEMA:
@@ -63,9 +63,9 @@ function DispatchRequest(url, action, payload) {
6363
case CONST.WOQL_SELECT:
6464
case CONST.GET_DOCUMENT:
6565
default:
66-
if (payload){
66+
if (payload) {
6767
const ext = UTILS.URIEncodePayload(payload);
68-
if(ext) url += "?" + ext;
68+
if (ext) url += `?${ext}`;
6969
}
7070
return axios.get(url, options)
7171
.then((response => response.data))

lib/errorMessage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function getErrorAsMessage(url, api, err) {
1414
return str;
1515
}
1616

17-
function formatErrorMessage(msg){
18-
if(typeof msg == "object"){
19-
var nmsg = "";
20-
for(var key in msg){
21-
nmsg += key + " " + msg[key] + " ";
17+
function formatErrorMessage(msg) {
18+
if (typeof msg === 'object') {
19+
let nmsg = '';
20+
for (const key of Object.keys(msg)) {
21+
nmsg += `${key} ${msg[key]} `;
2222
}
2323
return nmsg;
2424
}

lib/frameHelper.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ FrameHelper.genBNID = function () {
5656
};
5757

5858
FrameHelper.getShorthand = function (link) {
59-
if(typeof link == "object" && link.length) link = link[0];
59+
if (typeof link === 'object' && link.length) link = link[0];
6060
if (link && typeof link === 'string') {
6161
for (const pref of Object.keys(this.standard_urls)) {
6262
const full = this.standard_urls[pref];
@@ -92,28 +92,28 @@ FrameHelper.unshorten = function (url) {
9292
return url;
9393
};
9494

95-
//Valid URLs are those that start with http:// or https://
95+
// Valid URLs are those that start with http:// or https://
9696
FrameHelper.validURL = function (str) {
97-
if(str && str.substring(0, 7) == 'http://' || str.substring(0, 8) == 'https://') return true;
97+
if (str && (str.substring(0, 7) === 'http://' || str.substring(0, 8) === 'https://')) return true;
9898
return false;
9999
};
100100

101101

102102
FrameHelper.labelFromURL = function (url) {
103103
let nurl = this.urlFragment(url);
104104
nurl = (nurl || url);
105-
if(nurl.lastIndexOf("/") < nurl.length-1){
106-
nurl = nurl.substring(nurl.lastIndexOf("/") + 1);
105+
if (nurl.lastIndexOf('/') < nurl.length - 1) {
106+
nurl = nurl.substring(nurl.lastIndexOf('/') + 1);
107107
}
108-
nurl = nurl.replace("_", " ");
108+
nurl = nurl.replace('_', ' ');
109109
return nurl.charAt(0).toUpperCase() + nurl.slice(1);
110110
};
111111

112112
FrameHelper.urlFragment = function (url) {
113113
url = (typeof url !== 'string') ? window.location.href : url;
114114
let bits = url.split('#');
115115
if (bits.length <= 1) {
116-
if(!this.validURL(url)){
116+
if (!this.validURL(url)) {
117117
bits = url.split(':');
118118
}
119119
}
@@ -238,10 +238,9 @@ FrameHelper.parseXsdDate = function (val) {
238238
let parsed;
239239
if (year && Math.abs(year) < 10000) {
240240
let month = val.substring(year.length + 1, year.length + 3);
241-
if (month) { month = parseInt(month)}
242-
else return false;
241+
if (month) { month = parseInt(month, 10); } else return false;
243242
let day = val.substring(year.length + 4);
244-
if (day) day = parseInt(day);
243+
if (day) day = parseInt(day, 10);
245244
else return false;
246245
parsed = {
247246
year,
@@ -296,8 +295,7 @@ FrameHelper.xsdFromParsed = function (parsed, ty) {
296295
let ret;
297296
if (ty === 'xsd:gYear') {
298297
ret = (xparsed.year ? xparsed.year : false);
299-
}
300-
else if (ty === 'xsd:time') {
298+
} else if (ty === 'xsd:time') {
301299
return (xparsed.hour && xparsed.minute && xparsed.second) ? `${xparsed.hour}:${xparsed.minute}:${xparsed.second}` : false;
302300
} else if (ty === 'xsd:date') {
303301
return (xparsed.year && xparsed.month && xparsed.day) ? `${xparsed.year}-${xparsed.month}-${xparsed.day}` : false;

lib/objectFrame.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ DataFrame.prototype.isObject = function () {
679679
DataFrame.prototype.getTypeShorthand = function () {
680680
if (this.isDocument()) return 'document';
681681
if (this.isChoice()) return 'choice';
682-
var sh = FrameHelper.getShorthand(this.getType());
683-
return (sh ? sh : this.getType());
682+
const sh = FrameHelper.getShorthand(this.getType());
683+
return (sh || this.getType());
684684
};
685685

686686
DataFrame.prototype.get = function () {
@@ -791,7 +791,7 @@ ClassFrame.prototype.clone = function (newid, other) {
791791

792792
ClassFrame.prototype.getClassChoices = function () {
793793
const choices = [];
794-
if(this.frame.operands){
794+
if (this.frame.operands) {
795795
for (let i = 0; i < this.frame.operands.length; i += 1) {
796796
for (let j = 0; j < this.frame.operands[i].length; j += 1) {
797797
const domcls = this.frame.operands[i][j].domain;

lib/terminusIDParser.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ IDParser.prototype.parseDocumentURL = function (str) {
9595
}
9696
if (this.parseDBID(dbURL) === false) return false;
9797
}
98-
if(str.substring(0, 4) === "doc:") str = str.substring(4);
98+
if (str.substring(0, 4) === 'doc:') str = str.substring(4);
9999
// check if the document's name hasn't space or '/'
100100
if (this.validIDString(str)) {
101101
this.doc = str;
@@ -139,9 +139,9 @@ IDParser.prototype.parseClassFrameURL = function (str) {
139139
return this.parseDBID(str);
140140
};
141141

142-
//Valid URLs are those that start with http:// or https://
142+
// Valid URLs are those that start with http:// or https://
143143
IDParser.prototype.validURL = function (str) {
144-
if(str.substring(0, 7) == "http://" || str.substring(0, 8) == "https://") return true;
144+
if (str.substring(0, 7) === 'http://' || str.substring(0, 8) === 'https://') return true;
145145
return false;
146146
};
147147

@@ -154,7 +154,7 @@ IDParser.prototype.validPrefixedURL = function (str, context) {
154154
return false;
155155
};
156156

157-
IDParser.prototype.validIDString = function (str) {
157+
IDParser.prototype.validIDString = function (str) {
158158
if (typeof str !== 'string') return false;
159159
if (str.indexOf(':') !== -1 || str.indexOf(' ') !== -1 || str.indexOf('/') !== -1) return false;
160160
return true;

lib/woqlClient.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ WOQLClient.prototype.connect = function (curl, key) {
5151
if (key) {
5252
this.connection.setClientKey(serverURL, key);
5353
}
54-
//unset the current server setting until successful connect
54+
// unset the current server setting until successful connect
5555
this.connectionConfig.server = false;
5656
const self = this;
5757
return this.dispatch(serverURL, CONST.CONNECT).then((response) => {
@@ -146,7 +146,7 @@ WOQLClient.prototype.getSchema = function (schurl, opts) {
146146
new URIError(ErrorMessage.getInvalidURIMessage(schurl, 'Get Schema'))
147147
);
148148
}
149-
//consoleco.log('schemaURL', this.connectionConfig.schemaURL());
149+
// consoleco.log('schemaURL', this.connectionConfig.schemaURL());
150150
return this.dispatch(this.connectionConfig.schemaURL(), CONST.GET_SCHEMA, opts);
151151
};
152152

@@ -238,7 +238,7 @@ WOQLClient.prototype.updateDocument = function (docurl, doc, opts) {
238238
return Promise.reject(
239239
new URIError(ErrorMessage.getInvalidURIMessage(docurl, 'Update Document'))
240240
);
241-
}
241+
}
242242
if (doc && doc['@id']
243243
&& !this.connectionConfig.setDocument(doc['@id'], doc['@context'])
244244
) {
@@ -342,8 +342,8 @@ WOQLClient.prototype.addOptionsToWOQL = function (woql, opts) {
342342
WOQLClient.prototype.addOptionsToDocument = function (doc, opts) {
343343
const pdoc = {};
344344
pdoc['@context'] = doc['@context'];
345-
if(pdoc['@context'] && doc['@id']){ //add blank node prefix as document base url
346-
pdoc['@context']["_"] = doc['@id'] + "/"
345+
if (pdoc['@context'] && doc['@id']) { // add blank node prefix as document base url
346+
pdoc['@context']._ = `${doc['@id']}/`;
347347
}
348348
if (opts && opts['terminus:encoding'] && opts['terminus:encoding'] === 'terminus:turtle') {
349349
pdoc['terminus:turtle'] = doc;
@@ -370,8 +370,7 @@ WOQLClient.prototype.addKeyToPayload = function (payload, url) {
370370
delete payload.key;
371371
} else if (this.connection.getClientKey()) {
372372
payload['terminus:user_key'] = this.connection.getClientKey();
373-
}
374-
else if (this.connection.getClientKey(url)) {
373+
} else if (this.connection.getClientKey(url)) {
375374
payload['terminus:user_key'] = this.connection.getClientKey(url);
376375
}
377376
return payload;
@@ -399,13 +398,13 @@ WOQLClient.prototype.dispatchFetch = function (url, action, payload) {
399398
redirect: 'follow', // manual, *follow, error
400399
referrer: 'client', // no-referrer, *client
401400
};
402-
var hdrs = {};
401+
let hdrs = {};
403402
if (this.connectionConfig.platformEndpoint()) {
404403
api.credentials = 'include'; // include, *same-origin, omit
405404
}
406-
if(payload && payload['terminus:user_key']){
407-
hdrs = {'Authorization': 'Basic ' + btoa(":" + payload['terminus:user_key'])};
408-
delete(payload['terminus:user_key']);
405+
if (payload && payload['terminus:user_key']) {
406+
hdrs = { Authorization: `Basic ${btoa(`:${payload['terminus:user_key']}`)}` };
407+
delete (payload['terminus:user_key']);
409408
}
410409
// read only API calls - use GET
411410
switch (action) {
@@ -435,7 +434,7 @@ WOQLClient.prototype.dispatchFetch = function (url, action, payload) {
435434
if (Object.keys(payload).length > 0) url += `?${UTILS.URIEncodePayload(payload)}`;
436435
}
437436
const self = this;
438-
if(Object.keys(hdrs).length > 0){
437+
if (Object.keys(hdrs).length > 0) {
439438
api.headers = new Headers(hdrs);
440439
}
441440
return fetch(url, api).then((response) => {

0 commit comments

Comments
 (0)