Skip to content

Commit e7079f3

Browse files
Kitty JoseKitty Jose
authored andcommitted
2 parents 818e3db + f8f4ac0 commit e7079f3

File tree

6 files changed

+54
-16
lines changed

6 files changed

+54
-16
lines changed

docs/api/accesscontrol.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
**License**: Apache Version 2
55

66
## new AccessControl()
7-
The AccessControl object has various methods to control the access for users.
8-
for the credential you can use the JWT token or the API token
7+
The AccessControl is a driver to work with
8+
TerminusDB and TerminusX access control api
9+
for the credential you can use the JWT token, the API token or
10+
the basic authentication with username and password
911

1012
**Example**
1113
```javascript
@@ -92,6 +94,16 @@ Get a API url from cloudAPIUrl
9294
| cloudAPIUrl | <code>string</code> | The base url for cloud |
9395

9496

97+
## customHeaders
98+
##### accessControl.customHeaders(customHeaders) ⇒ <code>object</code>
99+
add extra headers to your request
100+
101+
102+
| Param | Type |
103+
| --- | --- |
104+
| customHeaders | <code>object</code> |
105+
106+
95107
## getAllOrganizations
96108
##### accessControl.getAllOrganizations() ⇒ <code>Promise</code>
97109
-- TerminusDB API ---

docs/api/woql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ Performs a path regular expression match on the graph
11321132
| Param | Type | Description |
11331133
| --- | --- | --- |
11341134
| subject | <code>string</code> | An IRI or variable that refers to an IRI representing the subject, i.e. the starting point of the path |
1135-
| pattern | <code>string</code> | (string) - A path regular expression describing a pattern through multiple edges of the graph Path regular expressions consist of a sequence of predicates and / or a set of alternatives, with quantification operators The characters that are interpreted specially are the following: | representing alternative choices , - representing a sequence of predcitates + - Representing a quantification of 1 or more of the preceding pattern in a sequence {min, max} - Representing at least min examples and at most max examples of the preceding pattern - Representing any predicate () - Parentheses, interpreted in the normal way to group clauses |
1135+
| pattern | <code>string</code> | (string) - A path regular expression describing a pattern through multiple edges of the graph (see: https://terminusdb.com/docs/index/terminusx-db/how-to-guides/path-queries) |
11361136
| object | <code>string</code> | An IRI or variable that refers to an IRI representing the object, i.e. ending point of the path |
11371137
| [resultVarName] | <code>string</code> | A variable in which the actual paths traversed will be stored |
11381138

lib/accessControl.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-underscore-dangle */
12
const DispatchRequest = require('./dispatchRequest');
23
const ErrorMessage = require('./errorMessage');
34
const CONST = require('./const');
@@ -8,8 +9,10 @@ const typedef = require('./typedef');
89
* @license Apache Version 2
910
* @module AccessControl
1011
* @constructor AccessControl
11-
* @description The AccessControl object has various methods to control the access for users.
12-
* for the credential you can use the JWT token or the API token
12+
* @description The AccessControl is a driver to work with
13+
* TerminusDB and TerminusX access control api
14+
* for the credential you can use the JWT token, the API token or
15+
* the basic authentication with username and password
1316
* @example
1417
* //connect with the API token
1518
* //(to request a token create an account in https://terminusdb.com/)
@@ -139,9 +142,23 @@ AccessControl.prototype.dispatch = function (requestUrl, action, payload) {
139142
action,
140143
payload,
141144
{ type: this.apiType, key: this.apiKey, user: this.user },
145+
null,
146+
this.customHeaders(),
142147
);
143148
};
144149

150+
/**
151+
* add extra headers to your request
152+
* @param {object} customHeaders
153+
* @returns {object}
154+
*/
155+
156+
// eslint-disable-next-line consistent-return
157+
AccessControl.prototype.customHeaders = function (customHeaders) {
158+
if (customHeaders) this._customHeaders = customHeaders;
159+
else return this._customHeaders;
160+
};
161+
145162
/**
146163
* -- TerminusDB API ---
147164
* This end point works in basic authentication, admin user

lib/woql.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,16 +1053,7 @@ WOQL.true = function () {
10531053
* @param {string} subject - An IRI or variable that refers to an IRI representing the subject,
10541054
* i.e. the starting point of the path
10551055
* @param {string} pattern -(string) - A path regular expression describing a pattern through
1056-
* multiple edges of the graph
1057-
* Path regular expressions consist of a sequence of predicates and / or a set of alternatives,
1058-
* with quantification operators
1059-
* The characters that are interpreted specially are the following:
1060-
* | representing alternative choices
1061-
* , - representing a sequence of predcitates
1062-
* + - Representing a quantification of 1 or more of the preceding pattern in a sequence
1063-
* {min, max} - Representing at least min examples and at most max examples of the preceding pattern
1064-
* - Representing any predicate
1065-
* () - Parentheses, interpreted in the normal way to group clauses
1056+
* multiple edges of the graph (see: https://terminusdb.com/docs/index/terminusx-db/how-to-guides/path-queries)
10661057
* @param {string} object - An IRI or variable that refers to an IRI representing the object,
10671058
* i.e. ending point of the path
10681059
* @param {string} [resultVarName] - A variable in which the actual paths traversed will be stored

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@terminusdb/terminusdb-client",
3-
"version": "10.0.13",
3+
"version": "10.0.14",
44
"description": "TerminusDB client library",
55
"main": "index.js",
66
"types": "./dist/typescript/index.d.ts",

test/accessControl.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const { expect } = require('chai');
2+
const AccessControl = require('../lib/accessControl');
3+
4+
describe('AccessControl tests', () => {
5+
const startServerUrl = 'http://localhost:6363/';
6+
const organization = 'admin';
7+
const user = 'admin';
8+
const key ='mykey'
9+
10+
const accessContol = new AccessControl(startServerUrl,{user,organization,key})
11+
12+
it('check set headers in accessControl', () => {
13+
const customHeaders = { "Custom-header-01":"test-headers", "Custom-header-02": "test"}
14+
accessContol.customHeaders(customHeaders)
15+
expect(accessContol.customHeaders()).to.eql(customHeaders);
16+
})
17+
18+
})

0 commit comments

Comments
 (0)