diff --git a/README.md b/README.md index 797daa54..90dcd5f3 100755 --- a/README.md +++ b/README.md @@ -1,8 +1,20 @@ -# TerminusDB-Client +TerminusDB Client Javascript +========================== -[![build status](https://api.travis-ci.com/terminusdb/terminusdb-client.svg?branch=master)](https://travis-ci.com/terminusdb/terminusdb-client) +[![Discord online](https://img.shields.io/discord/689805612053168129?color=7289da&logo=Discord&label=Discord%20chat)](https://discord.gg/yTJKAma) +[![Discourse topics](https://img.shields.io/discourse/topics?color=yellow&logo=Discourse&server=https%3A%2F%2Fdiscuss.terminusdb.com%2F)](https://discuss.terminusdb.com/) +[![Follow on Twitter](https://img.shields.io/twitter/follow/terminusdb?color=skyblue&label=Follow%20on%20Twitter&logo=twitter&style=flat)](https://twitter.com/TerminusDB) + +**Development status ⚙️** + +[![build status](https://api.travis-ci.com/terminusdb/terminusdb-client.svg?branch=main)](https://travis-ci.com/terminusdb/terminusdb-client) [![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) +**NPM Package status 📦** + +[![npm version shields.io](https://img.shields.io/npm/v/@terminusdb/terminusdb-client?logo=npm)](https://www.npmjs.com/package/@terminusdb/terminusdb-client) +[![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) + Promise based terminus client for the browser and node.js ## Requirements @@ -132,7 +144,7 @@ const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", { ## API -The API of the most recent release is documented at: +The API of the most recent release is documented at: ## Report Issues diff --git a/docs/README.md b/docs/README.md index 3283c20e..90dcd5f3 100755 --- a/docs/README.md +++ b/docs/README.md @@ -1,8 +1,20 @@ -# TerminusDB-Client +TerminusDB Client Javascript +========================== -[![build status](https://api.travis-ci.com/terminusdb/terminusdb-client.svg?branch=master)](https://travis-ci.com/terminusdb/terminusdb-client) +[![Discord online](https://img.shields.io/discord/689805612053168129?color=7289da&logo=Discord&label=Discord%20chat)](https://discord.gg/yTJKAma) +[![Discourse topics](https://img.shields.io/discourse/topics?color=yellow&logo=Discourse&server=https%3A%2F%2Fdiscuss.terminusdb.com%2F)](https://discuss.terminusdb.com/) +[![Follow on Twitter](https://img.shields.io/twitter/follow/terminusdb?color=skyblue&label=Follow%20on%20Twitter&logo=twitter&style=flat)](https://twitter.com/TerminusDB) + +**Development status ⚙️** + +[![build status](https://api.travis-ci.com/terminusdb/terminusdb-client.svg?branch=main)](https://travis-ci.com/terminusdb/terminusdb-client) [![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) +**NPM Package status 📦** + +[![npm version shields.io](https://img.shields.io/npm/v/@terminusdb/terminusdb-client?logo=npm)](https://www.npmjs.com/package/@terminusdb/terminusdb-client) +[![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) + Promise based terminus client for the browser and node.js ## Requirements @@ -47,7 +59,7 @@ Download the terminusdb-client.min.js file from the /dist directory and save it This example creates a simple dataProduct, starting to create a database model the schema and insert a simple document -For the [full Documentation](https://terminusdb.com/docs/reference/js-client) +For the [full Documentation](https://terminusdb.github.io/terminusdb-client-js/) ```javascript const TerminusClient = require("@terminusdb/terminusdb-client"); @@ -132,13 +144,13 @@ const client = new TerminusClient.WOQLClient("http://127.0.0.1:6363/", { ## API -The API is documented at: https://terminusdb.com/docs/reference/js-client/core/#terminusdb-client-api +The API of the most recent release is documented at: ## Report Issues If you have encounter any issues, please report it with your os and environment setup, version that you are using and a simple reproducible case. -If you encounter other questions, you can ask in our community [forum](https://community.terminusdb.com/) or [Slack channel](http://bit.ly/terminusdb-slack). +If you encounter other questions, you can ask in our [Discord Server](https://discord.gg/hTU3XWSzuZ). ## Contribute @@ -150,4 +162,4 @@ Please check [Contributing.md](Contributing.md) for more information. The APACHE 2.0 License -Copyright (c) 2019 \ No newline at end of file +Copyright (c) 2019 diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 6fc511cc..4e695277 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -22,6 +22,7 @@ - [user](api/woqlClient.js?id=user) - [userOrganization](api/woqlClient.js?id=userOrganization) - [databases](api/woqlClient.js?id=databases) + - [userOrganizations](api/woqlClient.js?id=userOrganizations) - [databaseInfo](api/woqlClient.js?id=databaseInfo) - [db](api/woqlClient.js?id=db) - [setSystemDb](api/woqlClient.js?id=setSystemDb) @@ -152,7 +153,7 @@ - [commits](api/woqlLibrary.js?id=commits) - [previousCommits](api/woqlLibrary.js?id=previousCommits) - [first_commit](api/woqlLibrary.js?id=first_commit) -- [TypeDef](api/typedef.js?id=Typedefs) +- [TypeDef](api/typedef.js?id=TypeDef) - [DocParamsGet](api/typedef.js?id=DocParamsGet) - [DocParamsPost](api/typedef.js?id=DocParamsPost) - [DocParamsPut](api/typedef.js?id=DocParamsPut) diff --git a/docs/api/typedef.js.md b/docs/api/typedef.js.md index b4b53cca..dd22be54 100644 --- a/docs/api/typedef.js.md +++ b/docs/api/typedef.js.md @@ -1,65 +1,70 @@ -## Typedefs -## DocParamsGet -#### DocParamsGet : Object + +## TypeDef +#### TypeDef +Type definations + + +### DocParamsGet +#### DocParamsGet: ` Object` the GET document interface query parameters **Properties** -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| [graph_type] | string | "instance" | instance|schema default value is instance. Used to switch between getting documents from the instance or the schema graph. | -| [type] | string | | only documents of the given type are returned. | -| [id] | string | | only the document with the given ID is returned. | -| [prefixed] | boolean | true | return IRIs using a prefixed notation wherever possible. If false, full IRIs are used. | -| [minimized] | boolean | false | return the documents with very little whitespace. Each json document will be on its own line. | -| [unfold] | boolean | true | any subdocuments contained in the returned document are returned too. If false, these are referred to by their ID instead. | -| [skip] | number | 0 | How many results to skip | -| [count] | number | | count - How many results to return. If this option is absent, all results are returned. | -| [as_list] | boolean | false | If true, don't return a stream of json objects, but a json list. | -| [graph_type] | string | | instance|schema default value is instance | - - -## DocParamsPost -#### DocParamsPost : Object +| Name | Type | Description | +| --- | --- | --- | +| [graph_type] | GraphType | instance|schema, default value is instance. Used to switch between getting documents from the instance or the schema graph. | +| [type] | string | only documents of the given type are returned. | +| [id] | string | only the document with the given ID is returned. | +| [prefixed] | boolean | default is true, return IRIs using a prefixed notation wherever possible. If false, full IRIs are used. | +| [minimized] | boolean | default is false, return the documents with very little whitespace. Each json document will be on its own line. | +| [unfold] | boolean | default is false, any subdocuments contained in the returned document are returned too. If false, these are referred to by their ID instead. | +| [skip] | number | default is 0, How many results to skip | +| [count] | number | count - How many results to return. If this option is absent, all results are returned. | +| [as_list] | boolean | default is false, If true, don't return a stream of json objects, but a json list. | +| [graph_type] | string | instance|schema default value is instance | + + +### DocParamsPost +#### DocParamsPost: ` Object` the POST document interface query parameters **Properties** -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| [graph_type] | string | "instance" | instance|schema Used to switch between getting documents from the instance or the schema graph. | -| [full_replace] | boolean | false | If true, all existing documents are deleted before inserting the posted documents. This allows the full replacement of the contents of a database. This is especially useful for replacing the schema. | +| Name | Type | Description | +| --- | --- | --- | +| [graph_type] | GraphType | default is instance instance|schema Used to switch between getting documents from the instance or the schema graph. | +| [full_replace] | boolean | default is false, If true, all existing documents are deleted before inserting the posted documents. This allows the full replacement of the contents of a database. This is especially useful for replacing the schema. | -## DocParamsPut -#### DocParamsPut : Object +### DocParamsPut +#### DocParamsPut: ` Object` the PUT document interface query parameters **Properties** -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| [graph_type] | string | "instance" | instance|schema Used to switch between getting documents from the instance or the schema graph. | +| Name | Type | Description | +| --- | --- | --- | +| [graph_type] | GraphType | default is instance, instance|schema Used to switch between getting documents from the instance or the schema graph. | -## DocParamsDelete -#### DocParamsDelete : Object +### DocParamsDelete +#### DocParamsDelete: ` Object` the DELETE document interface query parameters **Properties** -| Name | Type | Default | Description | -| --- | --- | --- | --- | -| [graph_type] | string | "instance" | instance|schema Used to switch between getting documents from the instance or the schema graph. | -| id | string \| array | | a single id or a list of ids to delete. | -| [nuke] | booleam | false | If true, delete everything at this resource location (dangerous!). | +| Name | Type | Description | +| --- | --- | --- | +| [graph_type] | GraphType | default is instance, instance|schema Used to switch between getting documents from the instance or the schema graph. | +| id | string \| array | a single id or a list of ids to delete. | +| [nuke] | booleam | default is false, If true, delete everything at this resource location (dangerous!). | -## GraphRef -#### GraphRef : "schema/main" \| "instance/main" \| string +### GraphRef +#### GraphRef: ` "schema/main"` | ` "instance/main" ` | ` string ` -## DataFormatObj -#### DataFormatObj : Object +### DataFormatObj +#### DataFormatObj: ` Object` (export/import) **Properties** @@ -70,17 +75,17 @@ the DELETE document interface query parameters | [format_header] | string | header format type | -## FuntionType -#### FuntionType : "add\_quad" \| "delete\_quad" \| "add\_triple" \| "delete\_triple" \| "quad" \| "triple" +### FuntionType +#### FuntionType: ` "add_quad"` | ` "delete_quad" ` | ` "add_triple" ` | ` "delete_triple" ` | ` "quad" ` | ` "triple" ` -## ResourceType -#### ResourceType : "commits" \| "meta" \| "branch" \| "ref" \| "repo" \| "db" +### ResourceType +#### ResourceType: ` "commits"` | ` "meta" ` | ` "branch" ` | ` "ref" ` | ` "repo" ` | ` "db" ` -## GraphType -#### GraphType : "instance" \| "schema" +### GraphType +#### GraphType: ` "instance"` | ` "schema" ` -## CredentialObj -#### CredentialObj : Object +### CredentialObj +#### CredentialObj: ` Object` **Properties** | Name | Type | Description | @@ -90,11 +95,11 @@ the DELETE document interface query parameters | key | string | the connection key | -## ActionType -#### ActionType : 'graph' \| 'db' \| 'clone' \| 'triples' \| 'woql' \| 'fetch' \| 'pull' \| 'rebase' \| 'branch' \| 'reset' \| 'push' \| 'squash' +### ActionType +#### ActionType: ` 'graph'` | ` 'db' ` | ` 'clone' ` | ` 'triples' ` | ` 'woql' ` | ` 'fetch' ` | ` 'pull' ` | ` 'rebase' ` | ` 'branch' ` | ` 'reset' ` | ` 'push' ` | ` 'squash' ` -## ParamsObj -#### ParamsObj : Object +### ParamsObj +#### ParamsObj: ` Object` **Properties** | Name | Type | Description | @@ -104,14 +109,14 @@ the DELETE document interface query parameters | [user] | string | the user id, we use this for basic authentication and for identify the commits author | | [organization] | string | set organization to this id | | [db] | string | set cursor to this db | -| [repo] | [RepoType](#RepoType) \| string | set cursor to this repo | +| [repo] | RepoType \| string | set cursor to this repo | | [branch] | string | set branch to this id | | [ref] | string | set commit ref | | [default_branch_id] | string | set the default branch id | -## RolesObj -#### RolesObj : Object +### RolesObj +#### RolesObj: ` Object` **Properties** | Name | Type | Description | @@ -123,11 +128,11 @@ the DELETE document interface query parameters | [invitation] | string | - | -## RepoType -#### RepoType : "local" \| "remote" +### RepoType +#### RepoType: ` "local"` | ` "remote" ` -## DbDetails -#### DbDetails : Object +### DbDetails +#### DbDetails: ` Object` **Properties** | Name | Type | Description | @@ -142,8 +147,8 @@ the DELETE document interface query parameters | [schema] | boolean | if set to true, a schema graph will be created | -## RemoteRepoDetails -#### RemoteRepoDetails : Object +### RemoteRepoDetails +#### RemoteRepoDetails: ` Object` {remote: "origin", "remote_branch": "main", "author": "admin", "message": "message"} **Properties** @@ -156,8 +161,8 @@ the DELETE document interface query parameters | [message] | string | the update commit message | -## CloneSourceDetails -#### CloneSourceDetails : Object +### CloneSourceDetails +#### CloneSourceDetails: ` Object` **Properties** | Name | Type | Description | diff --git a/docs/api/woql.js.md b/docs/api/woql.js.md index c02226f8..a04ba573 100644 --- a/docs/api/woql.js.md +++ b/docs/api/woql.js.md @@ -988,11 +988,11 @@ Orders the results of the contained subquery by a precedence list of variables | Param | Type | Description | | --- | --- | --- | -| ...varNames | string | A sequence of variables, by which to order the results, each optionally followed by either “asc” or “desc” to represent order | +| ...varNames | string | A sequence of variables, by which to order the results, each optionally followed by either “asc” or “desc” to represent order as a list, by default it will sort the variable in ascending order | **Example** ```js -WOQL.order_by("v:A", "v:B asc", "v:C desc").triple("v:A", "v:B", "v:C"); +WOQL.order_by("v:A", ["v:B", "asc"], ["v:C", "desc"]).triple("v:A", "v:B", "v:C"); ``` ### group_by diff --git a/docs/api/woqlClient.js.md b/docs/api/woqlClient.js.md index 21d470e7..0998e83a 100644 --- a/docs/api/woqlClient.js.md +++ b/docs/api/woqlClient.js.md @@ -341,6 +341,21 @@ Retrieves a list of databases (id, organization, label, comment) that the curren const my_dbs = client.databases() ``` +### userOrganizations +#### woqlClient.userOrganizations([orgList]) ⇒ array +Retrieves a list of databases (id, organization, label, comment) that the current user has access to on the server. Note that this requires the client to call connect() first. + +**Returns**: array - the user databases list + +| Param | Type | Description | +| --- | --- | --- | +| [orgList] | array | a list of databases the user has access to on the server, each having: | + +**Example** +```js +const my_dbs = client.databases() +``` + ### databaseInfo #### woqlClient.databaseInfo([dbId]) ⇒ object Gets the database's details @@ -447,12 +462,7 @@ client.remoteAuth({"key":"dhfmnmjglkrelgkptohkn","type":"jwt"}) #### woqlClient.author() ⇒ string Gets the string that will be written into the commit log for the current user -**Returns**: string - the current user - -| Param | Type | Description | -| --- | --- | --- | -| [aName] | string | the id to write into commit logs as the author string (normally an email address) | - +**Returns**: string - the current user **Example** ```js client.author() diff --git a/docs/api/woqlLibrary.js.md b/docs/api/woqlLibrary.js.md index 5797620f..ffe3c0b8 100644 --- a/docs/api/woqlLibrary.js.md +++ b/docs/api/woqlLibrary.js.md @@ -1,6 +1,9 @@ ## WOQLLibrary -#### WOQLLibrary() +#### WOQLLibrary +**License**: Apache Version 2 + +#### new WOQLLibrary() Library Functions to manage the commits graph **Example** diff --git a/docs/createDocs.js b/docs/createDocs.js index 87791b89..e435064f 100644 --- a/docs/createDocs.js +++ b/docs/createDocs.js @@ -69,6 +69,10 @@ function createFile(filePath, options, outputDir) { } ////([\w-]+)(.js)/ function getFileName(filePath) { + + if(filePath === '_sidebar.js') { + return '_sidebar'; + } const regEx = /[\w-]+\.js/; return filePath.match(regEx)[0] } diff --git a/docs/helper/format.js b/docs/helper/format.js index 3696435e..0389fe22 100644 --- a/docs/helper/format.js +++ b/docs/helper/format.js @@ -54,6 +54,26 @@ exports.addSigName = function(options) { return true } +exports.getSigType = function() { + + let outputString = ` \` ${this.type.names[0]}\`` + if(this.type.names.length===1) return outputString; + + for (let index = 1; index < this.type.names.length; index++) { + const element = this.type.names[index]; + outputString+= ` | \` ${element} \` `; + } + return outputString; +} + +exports.ifKindTypeDef = function() { + + if(this.kind === 'typedef') { + return true; + } + return false +} + exports.makeAnchor = function(anchorName) { if (typeof anchorName === 'string') { const arr = anchorName.split(/\+|\./) @@ -61,7 +81,14 @@ exports.makeAnchor = function(anchorName) { return arr[1] } } - return anchorName + // removing module_ from header + if(this.kind === 'module' && anchorName.includes('module_')) { + return anchorName.substr(7); + } else if (this.kind === 'typedef' && anchorName.includes('module_TypeDef..')) { + return anchorName.substr(16); + } + + return anchorName; } exports.docsFilter = function(data, options) { diff --git a/docs/index.html b/docs/index.html index fad956dc..0b443d2b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -13,7 +13,7 @@