Skip to content

Commit a5dbdbf

Browse files
added apiURLInfo in connection config
Signed-off-by: NeelParihar <[email protected]>
1 parent 20cab81 commit a5dbdbf

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

docs/_sidebar.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
- [copy](api/woqlClient.js?id=copy)
1919
- [server](api/woqlClient.js?id=server)
2020
- [api](api/woqlClient.js?id=api)
21-
- [apiInfo](api/woqlClient.js?id=apiInfo)
2221
- [organization](api/woqlClient.js?id=organization)
2322
- [user](api/woqlClient.js?id=user)
2423
- [userOrganization](api/woqlClient.js?id=userOrganization)

docs/api/woqlClient.js.md

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function getSchema() {
4444
### TerminusDB Client API
4545

4646
### Connect
47-
#### woqlClient.connect() ⇒ <code>Promise</code>
47+
#### woqlClient.connect([params]) ⇒ <code>Promise</code>
4848
Connect to a Terminus server at the given URI with an API key
4949
Stores the system:ServerCapability document returned
5050
in the connection register which stores, the url, key, capabilities,
@@ -53,6 +53,11 @@ this.connectionConfig.server will be used if present,
5353
or the promise will be rejected.
5454

5555
**Returns**: <code>Promise</code> - the connection capabilities response object or an error object
56+
57+
| Param | Type | Description |
58+
| --- | --- | --- |
59+
| [params] | <code>typedef.ParamsObj</code> | TerminusDB Server connection parameters |
60+
5661
**Example**
5762
```js
5863
client.connect()
@@ -296,16 +301,6 @@ Retrieve the URL of the server’s API base that we are currently connected to
296301
let api_url = client.api()
297302
```
298303
299-
### apiInfo
300-
#### woqlClient.apiInfo() ⇒ <code>string</code>
301-
Retrieve the URL of the server’s Info API that we are currently connected to
302-
303-
**Returns**: <code>string</code> - the URL of the TerminusDB server info api endpoint we are connected to (typically server() + “api/info”)
304-
**Example**
305-
```js
306-
let api_url = client.apiInfo()
307-
```
308-
309304
### organization
310305
#### woqlClient.organization([orgId]) ⇒ <code>string</code> \| <code>boolean</code>
311306
Gets/Sets the client’s internal organization context value

lib/connectionConfig.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,14 @@ ConnectionConfig.prototype.apiURL = function() {
123123
return this.server + this.api_extension
124124
}
125125

126+
/**
127+
* Gets the server connection url info
128+
* @returns {string}
129+
*/
130+
ConnectionConfig.prototype.apiURLInfo = function() {
131+
return this.apiURL() + "info"
132+
}
133+
126134
/**
127135
* Gets the current database id
128136
* @returns {string | boolean}

lib/woqlClient.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ WOQLClient.prototype.api = function() {
110110
return this.connectionConfig.apiURL()
111111
}
112112

113-
/**
114-
* Retrieve the URL of the server’s Info API that we are currently connected to
115-
* @returns {string} the URL of the TerminusDB server info api endpoint we are connected to (typically server() + “api/info”)
116-
* @example
117-
* let api_url = client.apiInfo()
118-
*/
119-
WOQLClient.prototype.apiInfo = function() {
120-
return this.connectionConfig.apiURL() + 'info'
121-
}
122-
123113
/**
124114
* Gets/Sets the client’s internal organization context value
125115
* @param {string | boolean} [orgId] the organization id to set the context to
@@ -356,14 +346,15 @@ WOQLClient.prototype.resource = function(resourceType, resourceId) {
356346
* and database meta-data for the connected server
357347
* this.connectionConfig.server will be used if present,
358348
* or the promise will be rejected.
349+
* @param {typedef.ParamsObj} [params] - TerminusDB Server connection parameters
359350
* @returns {Promise} the connection capabilities response object or an error object
360351
* @example
361352
* client.connect()
362353
*/
363354
WOQLClient.prototype.connect = function(params) {
364355
if (params) this.connectionConfig.update(params)
365356
// unset the current server setting until successful connect
366-
return this.dispatch(CONST.GET, this.apiInfo()).then(response => {
357+
return this.dispatch(CONST.GET, this.connectionConfig.apiURLInfo()).then(response => {
367358
this.databases(response)
368359
return response
369360
})

0 commit comments

Comments
 (0)