Skip to content

Commit b7b9603

Browse files
Merge branch 'main' of https://github.com/terminusdb/terminusdb-client-js into fixWQPost
Signed-off-by: NeelParihar <[email protected]>
2 parents d2831ec + e2547de commit b7b9603

15 files changed

+467
-217
lines changed

.babelrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
{
2-
"presets": ["@babel/preset-env"]
2+
"presets": ["@babel/preset-env"],
3+
"plugins": ["@babel/plugin-transform-regenerator",
4+
"@babel/plugin-transform-runtime"]
35
}

README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
[![npm version](https://img.shields.io/npm/v/@terminusdb/terminusdb-client?logo=npm)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
1212
[![npm downloads](https://img.shields.io/npm/dw/@terminusdb/terminusdb-client?color=red&label=npm%20package&logo=npm&style=flat)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
1313

14-
> This repository is for the JavaScript client for TerminusDB and TerminusX. The
15-
> JavaScript client runs in the browser and on Node.js.
14+
> This repository is for the JavaScript client library for TerminusDB and
15+
> TerminusX.
1616
1717
[**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database
1818
and document store. It allows you to link JSON documents in a powerful knowledge
@@ -30,40 +30,41 @@ TerminusX is in public beta and you can [sign up now][dashboard].
3030

3131
## Requirements
3232

33-
- [NodeJS 10+](https://nodejs.org/en/)
33+
- Node.js version 10+ if using the TerminusDB client library as a Node.js package
3434

3535
## Installation
3636

37-
TerminusDB Client can be used as either a Node.js module available through the npm registry, or directly included in web-sites by including the script tag below.
37+
The TerminusDB JavaScript client library can be used either as a Node.js package
38+
or as a script that runs in the browser.
3839

39-
### NPM Module
40+
### NPM Package
4041

41-
Before installing, download and install Node.js.<br>
42-
NodeJS version 10.X or higher is required. NodeJS version 14.X is recommended.
42+
> :memo: If you don't already have Node.js installed, [install it][node-install] first.
4343
44-
Installation is done using the npm install command:
44+
[node-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
4545

46-
Using npm:
46+
To install the `terminusdb-client` package as a dependency in an existing
47+
package, run:
4748

48-
```bash
49+
```sh
4950
$ npm install --save @terminusdb/terminusdb-client
5051
```
5152

52-
### Minified Script
53+
This command update your `package.json`.
5354

54-
Using cdn:
55+
### Script
56+
57+
To use the `terminusdb-client` script on a webpage sourced from a CDN, add this
58+
to your HTML:
5559

5660
```html
5761
<script src="https://unpkg.com/@terminusdb/terminusdb-client/dist/terminusdb-client.min.js"></script>
5862
```
5963

60-
Downloading:
64+
Alternatively, you can download the latest [`terminusdb-client.min.js`][js], add
65+
it to your sources, and use that in the `<script>` instead.
6166

62-
Download the terminusdb-client.min.js file from the /dist directory and save it to your location of choice, then:
63-
64-
```html
65-
<script src="http://my.saved.location/terminusdb-client.min.js"></script>
66-
```
67+
[js]: https://unpkg.com/@terminusdb/terminusdb-client/dist/terminusdb-client.min.js
6768

6869
## Usage
6970

@@ -110,7 +111,7 @@ const bankerSchema = [
110111

111112
async function createDataProduct(){
112113
try{
113-
await client.connect()
114+
114115
await client.createDatabase("banker", {label: "Banker Account",
115116
comment: "Testing", schema: true})
116117
//add the schema documents

RELEASE_NOTES.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# TerminusDB Client v10.0.5
2+
3+
## New 🚀
4+
5+
* Add new [getDatabases](https://terminusdb.github.io/terminusdb-client-js/#/api/woqlClient.js?id=getdatabases) method [#121](/../../pull/121)
6+
* Add track version id [#116](/../../pull/116)
7+
8+
## Fixes 🛠
9+
10+
* Fixed tests [#123](/../../pull/123)
11+
* Modified AccessControl documentations, added api token [#124](/../../pull/124)
12+
* UPDATED packages [#126](/../../pull/126)
13+
14+
## Deprecated ☠️
15+
16+
* Deprecated connect function [#114](/../../pull/114)
17+
18+
---
19+
120
# TerminusDB Client v10.0.4
221

322
## New 🚀

docs/README.md

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,77 @@
1-
TerminusDB Client Javascript
2-
==========================
1+
[![TerminusDB JavaScript Client](https://assets.terminusdb.com/readmes/terminusdb-client-js/header.gif)][terminusdb-client-js-docs]
32

4-
[![Discord online](https://img.shields.io/discord/689805612053168129?color=7289da&logo=Discord&label=Discord%20chat)](https://discord.gg/yTJKAma)
5-
[![Discourse topics](https://img.shields.io/discourse/topics?color=yellow&logo=Discourse&server=https%3A%2F%2Fdiscuss.terminusdb.com%2F)](https://discuss.terminusdb.com/)
6-
[![Follow on Twitter](https://img.shields.io/twitter/follow/terminusdb?color=skyblue&label=Follow%20on%20Twitter&logo=twitter&style=flat)](https://twitter.com/TerminusDB)
3+
[terminusdb-client-js-docs]: https://terminusdb.github.io/terminusdb-client-js/
74

8-
**Development status ⚙️**
5+
---
96

10-
[![build status](https://api.travis-ci.com/terminusdb/terminusdb-client.svg?branch=main)](https://travis-ci.com/terminusdb/terminusdb-client)
11-
[![Coverage Status](https://coveralls.io/repos/github/terminusdb/terminusdb-client/badge.svg?branch=master)](https://coveralls.io/repos/github/terminusdb/terminusdb-client/badge.svg?branch=master)
7+
[![Discord](https://img.shields.io/discord/689805612053168129?label=Discord&logo=Discord&style=plastic)](https://discord.gg/yTJKAma)
8+
[![Discourse](https://img.shields.io/discourse/topics?color=yellow&logo=Discourse&server=https%3A%2F%2Fdiscuss.terminusdb.com%2F&style=plastic)](https://discuss.terminusdb.com/)
9+
[![Twitter](https://img.shields.io/twitter/follow/terminusdb?color=skyblue&label=Follow%20on%20Twitter&logo=twitter&style=flat)](https://twitter.com/TerminusDB)
1210

13-
**NPM Package status 📦**
11+
[![npm version](https://img.shields.io/npm/v/@terminusdb/terminusdb-client?logo=npm)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
12+
[![npm downloads](https://img.shields.io/npm/dw/@terminusdb/terminusdb-client?color=red&label=npm%20package&logo=npm&style=flat)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
1413

15-
[![npm version shields.io](https://img.shields.io/npm/v/@terminusdb/terminusdb-client?logo=npm)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
16-
[![PyPI download month](https://img.shields.io/npm/dw/@terminusdb/terminusdb-client?color=red&label=npm%20package&logo=npm&style=flat)](https://www.npmjs.com/package/@terminusdb/terminusdb-client)
14+
> This repository is for the JavaScript client library for TerminusDB and
15+
> TerminusX.
1716
18-
Promise based terminus client for the browser and node.js
17+
[**TerminusDB**][terminusdb] is an [open-source][terminusdb-repo] graph database
18+
and document store. It allows you to link JSON documents in a powerful knowledge
19+
graph all through a simple document API.
20+
21+
[terminusdb]: https://terminusdb.com/
22+
[terminusdb-docs]: https://terminusdb.com/docs/
23+
[terminusdb-repo]: https://github.com/terminusdb/terminusdb
24+
25+
**TerminusX** is a self-service data platform that allows you to build, deploy,
26+
execute, monitor, and share versioned data products. It is built on TerminusDB.
27+
TerminusX is in public beta and you can [sign up now][dashboard].
28+
29+
[dashboard]: https://dashboard.terminusdb.com/
1930

2031
## Requirements
2132

22-
- [NodeJS 10+](https://nodejs.org/en/)
33+
- Node.js version 10+ if using the TerminusDB client library as a Node.js package
2334

2435
## Installation
2536

26-
TerminusDB Client can be used as either a Node.js module available through the npm registry, or directly included in web-sites by including the script tag below.
37+
The TerminusDB JavaScript client library can be used either as a Node.js package
38+
or as a script that runs in the browser.
2739

28-
### NPM Module
40+
### NPM Package
2941

30-
Before installing, download and install Node.js.<br>
31-
NodeJS version 10.X or higher is required. NodeJS version 14.X is recommended.
42+
> :memo: If you don't already have Node.js installed, [install it][node-install] first.
3243
33-
Installation is done using the npm install command:
44+
[node-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
3445

35-
Using npm:
46+
To install the `terminusdb-client` package as a dependency in an existing
47+
package, run:
3648

37-
```bash
49+
```sh
3850
$ npm install --save @terminusdb/terminusdb-client
3951
```
4052

41-
### Minified Script
53+
This command update your `package.json`.
54+
55+
### Script
4256

43-
Using cdn:
57+
To use the `terminusdb-client` script on a webpage sourced from a CDN, add this
58+
to your HTML:
4459

4560
```html
4661
<script src="https://unpkg.com/@terminusdb/terminusdb-client/dist/terminusdb-client.min.js"></script>
4762
```
4863

49-
Downloading:
64+
Alternatively, you can download the latest [`terminusdb-client.min.js`][js], add
65+
it to your sources, and use that in the `<script>` instead.
5066

51-
Download the terminusdb-client.min.js file from the /dist directory and save it to your location of choice, then:
52-
53-
```html
54-
<script src="http://my.saved.location/terminusdb-client.min.js"></script>
55-
```
67+
[js]: https://unpkg.com/@terminusdb/terminusdb-client/dist/terminusdb-client.min.js
5668

5769
## Usage
5870

5971
This example creates a simple dataProduct, starting to create a database model the schema
6072
and insert a simple document
6173

62-
For the [full Documentation](https://terminusdb.github.io/terminusdb-client-js/)
74+
For the [full Documentation][terminusdb-client-js-docs]
6375

6476
```javascript
6577
const TerminusClient = require("@terminusdb/terminusdb-client");
@@ -99,7 +111,7 @@ const bankerSchema = [
99111

100112
async function createDataProduct(){
101113
try{
102-
await client.connect()
114+
103115
await client.createDatabase("banker", {label: "Banker Account",
104116
comment: "Testing", schema: true})
105117
//add the schema documents
@@ -144,7 +156,7 @@ const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", {
144156

145157
## API
146158

147-
The API of the most recent release is documented at: <https://terminusdb.com/docs/v10.0/#/reference/reference-api>
159+
The TerminusDB API can be found at the [TerminusDB Documentation][terminusdb-docs].
148160

149161
## Report Issues
150162

docs/_sidebar.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<!-- docs/_sidebar.md -->
22
- [WOQLClient](api/woqlClient.js?id=WOQLClient)
33
- [TerminusDB Client API](api/woqlClient.js?id=terminusdb-client-api)
4-
- [Connect](api/woqlClient.js?id=connect)
54
- [Create Database](api/woqlClient.js?id=create-database)
65
- [Delete Database](api/woqlClient.js?id=delete-database)
76
- [Get Triples](api/woqlClient.js?id=get-triples)
@@ -19,10 +18,10 @@
1918
- [server](api/woqlClient.js?id=server)
2019
- [api](api/woqlClient.js?id=api)
2120
- [organization](api/woqlClient.js?id=organization)
21+
- [getDatabases](api/woqlClient.js?id=getDatabases)
22+
- [databases](api/woqlClient.js?id=databases)
2223
- [user](api/woqlClient.js?id=user)
2324
- [userOrganization](api/woqlClient.js?id=userOrganization)
24-
- [databases](api/woqlClient.js?id=databases)
25-
- [userOrganizations](api/woqlClient.js?id=userOrganizations)
2625
- [databaseInfo](api/woqlClient.js?id=databaseInfo)
2726
- [db](api/woqlClient.js?id=db)
2827
- [setSystemDb](api/woqlClient.js?id=setSystemDb)
@@ -59,6 +58,8 @@
5958
- [getEnums](api/woqlClient.js?id=getEnums)
6059
- [getClassDocuments](api/woqlClient.js?id=getClassDocuments)
6160
- [getBranches](api/woqlClient.js?id=getBranches)
61+
- [getUserOrganizations](api/woqlClient.js?id=getUserOrganizations)
62+
- [userOrganizations](api/woqlClient.js?id=userOrganizations)
6263
- [getDiff](api/woqlClient.js?id=getDiff)
6364
- [patch](api/woqlClient.js?id=patch)
6465
- [WOQL](api/woql.js?id=WOQL)
@@ -161,8 +162,8 @@
161162
- [first_commit](api/woqlLibrary.js?id=first_commit)
162163
- [AccessControl](api/accessControl.js?id=AccessControl)
163164
- [getDefaultOrganization](api/accessControl.js?id=getDefaultOrganization)
164-
- [getJwtToken](api/accessControl.js?id=getJwtToken)
165165
- [setJwtToken](api/accessControl.js?id=setJwtToken)
166+
- [setApiToken](api/accessControl.js?id=setApiToken)
166167
- [getAPIUrl](api/accessControl.js?id=getAPIUrl)
167168
- [getAccessRoles](api/accessControl.js?id=getAccessRoles)
168169
- [createOrganization](api/accessControl.js?id=createOrganization)

docs/api/accessControl.js.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,30 @@
55

66
#### new AccessControl()
77
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
89

910
**Example**
1011
```js
12+
//connect with the API token
13+
//(to request a token create an account in https://terminusdb.com/)
14+
const accessContol = new AccessControl("https://servername.com",
15+
{organization:"my_team_name",
16+
token:"dGVybWludXNkYjovLy9kYXRhL2tleXNfYXB........"})
17+
accessControl.getOrgUsers().then(result=>{
18+
console.log(result)
19+
})
20+
21+
//connect with the jwt token this type of connection is only for the dashboard
22+
//or for application integrate with our login workflow
1123
const accessContol = new AccessControl("https://servername.com",
1224
{organization:"my_team_name",
1325
jwt:"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYyeTFORUd........"})
1426
accessControl.getOrgUsers().then(result=>{
1527
console.log(result)
1628
})
29+
1730
//if the jwt is expired you can change it with
18-
accessControl.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYyeTFORUd.......")
31+
accessControl.setJwtToken("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkpXUjBIOXYyeTFORUd.......")
1932
```
2033

2134
### getDefaultOrganization
@@ -29,25 +42,24 @@ Get a organization from parameters.
2942
| params | <code>object</code> | The parameters |
3043

3144

32-
### getJwtToken
33-
#### accessControl.getJwtToken(params) ⇒ <code>string</code>
34-
Get a API token from parameters.
45+
### setJwtToken
46+
#### accessControl.setJwtToken(jwt)
47+
Sets the Jwt token for the object
3548

36-
**Returns**: <code>string</code> - jwt api token
3749

3850
| Param | Type | Description |
3951
| --- | --- | --- |
40-
| params | <code>object</code> | The parameters |
52+
| jwt | <code>string</code> | The jwt api token to use |
4153

4254

43-
### setJwtToken
44-
#### accessControl.setJwtToken(jwt)
45-
Sets the API token for the object
55+
### setApiToken
56+
#### accessControl.setApiToken(atokenpi)
57+
Sets the API token for the object, to request a token create an account in https://terminusdb.com/
4658

4759

4860
| Param | Type | Description |
4961
| --- | --- | --- |
50-
| jwt | <code>string</code> | The jwt api token to use |
62+
| atokenpi | <code>string</code> | The API token to use to connect with TerminusX |
5163

5264

5365
### getAPIUrl
@@ -70,6 +82,7 @@ Get all the system database roles types.
7082
### createOrganization
7183
#### accessControl.createOrganization(orgName) ⇒ <code>Promise</code>
7284
Any user can create their own organization.
85+
IMPORTANT This does not work with the API-TOKEN.
7386

7487
**Returns**: <code>Promise</code> - A promise that returns the call response object, or an Error if rejected.
7588

@@ -87,6 +100,7 @@ accessControl.createOrganization("my_org_name").then(result=>{
87100
### ifOrganizationExists
88101
#### accessControl.ifOrganizationExists(orgName) ⇒ <code>Promise</code>
89102
Check if the organization exists. it is a Head call .
103+
IMPORTANT This does not work with the API-TOKEN.
90104

91105
**Returns**: <code>Promise</code> - A promise that returns the call status object, 200: if the organization exists and 404: if the organization does not exist
92106

0 commit comments

Comments
 (0)