diff --git a/docs/_sidebar.md b/docs/_sidebar.md index 5a2d938f..6fc511cc 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -47,17 +47,6 @@ - [generateCommitDescriptor](api/woqlClient.js?id=generateCommitDescriptor) - [prepareRevisionControlArgs](api/woqlClient.js?id=prepareRevisionControlArgs) - [updateDatabase](api/woqlClient.js?id=updateDatabase) - - [createUser](api/woqlClient.js?id=createUser) - - [getUser](api/woqlClient.js?id=getUser) - - [updateUser](api/woqlClient.js?id=updateUser) - - [deleteUser](api/woqlClient.js?id=deleteUser) - - [createOrganization](api/woqlClient.js?id=createOrganization) - - [setOrganizationRoles](api/woqlClient.js?id=setOrganizationRoles) - - [getOrganization](api/woqlClient.js?id=getOrganization) - - [updateOrganization](api/woqlClient.js?id=updateOrganization) - - [deleteOrganization](api/woqlClient.js?id=deleteOrganization) - - [getRoles](api/woqlClient.js?id=getRoles) - - [updateRoles](api/woqlClient.js?id=updateRoles) - [addDocument](api/woqlClient.js?id=addDocument) - [queryDocument](api/woqlClient.js?id=queryDocument) - [getDocument](api/woqlClient.js?id=getDocument) @@ -75,7 +64,8 @@ - [comment](api/woql.js?id=comment) - [select](api/woql.js?id=select) - [distinct](api/woql.js?id=distinct) - - [and](api/woql.js?id=an) + - [and](api/woql.js?id=and) + - [read_object](api/woql.js?id=read_object) - [or](api/woql.js?id=or) - [from](api/woql.js?id=from) - [into](api/woql.js?id=into) diff --git a/docs/api/typedef.js.md b/docs/api/typedef.js.md index dc6aa631..1fd374c6 100644 --- a/docs/api/typedef.js.md +++ b/docs/api/typedef.js.md @@ -1,49 +1,4 @@ ## Typedefs - -
-
DocParamsGet : Object
-

the GET document interface query parameters

-
-
DocParamsPost : Object
-

the POST document interface query parameters

-
-
DocParamsPut : Object
-

the PUT document interface query parameters

-
-
DocParamsDelete : Object
-

the DELETE document interface query parameters

-
-
GraphRef : "schema/main" | "instance/main" | string
-
-
DataFormatObj : Object
-

(export/import)

-
-
FuntionType : "add_quad" | "delete_quad" | "add_triple" | "delete_triple" | "quad" | "triple"
-
-
ResourceType : "commits" | "meta" | "branch" | "ref" | "repo" | "db"
-
-
GraphType : "instance" | "schema"
-
-
CredentialObj : Object
-
-
ActionType : 'graph' | 'db' | 'clone' | 'triples' | 'woql' | 'fetch' | 'pull' | 'rebase' | 'branch' | 'reset' | 'push' | 'squash'
-
-
ParamsObj : Object
-
-
RolesObj : Object
-
-
RepoType : "local" | "remote"
-
-
DbDetails : Object
-
-
RemoteRepoDetails : Object
-

{remote: "origin", "remote_branch": "main", "author": "admin", "message": "message"}

-
-
CloneSourceDetails : Object
-
-
- - ## DocParamsGet #### DocParamsGet : Object the GET document interface query parameters diff --git a/docs/api/woql.js.md b/docs/api/woql.js.md index 9eabd620..c02226f8 100644 --- a/docs/api/woql.js.md +++ b/docs/api/woql.js.md @@ -92,6 +92,19 @@ WOQL.and( WOQL.triple("v:Start", "label", "v:Start_Label")) ``` +### read_object +#### WOQL.read\_object(IRI, output, formatObj) ⇒ object +Read a node identified by an IRI as a JSON-LD document + +**Returns**: object - WOQLQuery + +| Param | Type | Description | +| --- | --- | --- | +| IRI | string | The document id or a variable | +| output | string | variable name | +| formatObj | object | | + + ### or #### WOQL.or(...subqueries) ⇒ WOQLQuery Creates a logical OR of the arguments @@ -964,7 +977,7 @@ Casts the value of Input to a new value of type Type and stores the result in Ca **Example** ```js -typecast("22/3/98", "xsd:dateTime", "v:time") +cast("22/3/98", "xsd:dateTime", "v:time") ``` ### order_by diff --git a/docs/api/woqlClient.js.md b/docs/api/woqlClient.js.md index edff77a0..3c160268 100644 --- a/docs/api/woqlClient.js.md +++ b/docs/api/woqlClient.js.md @@ -648,141 +648,6 @@ update the database details | dbDoc | object | an object that describe the database details | -### createUser -#### woqlClient.createUser(userId, userDoc) ⇒ Promise -For creating an user - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| userId | string | the userId | -| userDoc | object | the user's object description | - - -### getUser -#### woqlClient.getUser(userId) ⇒ Promise -Get the logged user details. - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | -| --- | --- | -| userId | string | - - -### updateUser -#### woqlClient.updateUser(userId, userDoc) ⇒ Promise -Update an user from the database. - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| userId | string | | -| userDoc | object | User Object details | - - -### deleteUser -#### woqlClient.deleteUser(userId) ⇒ Promise -Delete an user from the database Only a user with DBA authority can delete a user. - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | -| --- | --- | -| userId | string | - - -### createOrganization -#### woqlClient.createOrganization(orgId, orgDoc) ⇒ Promise -Create a new organization for the registered user - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| orgId | string | the organization id | -| orgDoc | object | An object that describe the organization's details | - - -### setOrganizationRoles -#### woqlClient.setOrganizationRoles(orgId, orgDoc) ⇒ Promise -Create a new organization for the registered user - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| orgId | string | the organization id | -| orgDoc | object | An object that describe the organization's details | - - -### getOrganization -#### woqlClient.getOrganization(orgId, [action]) ⇒ Promise -Gets all the information about the given organization - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| orgId | string | the organization id | -| [action] | string | set an action like recommendations | invitations | collaborators | - - -### updateOrganization -#### woqlClient.updateOrganization(orgId, orgDoc) ⇒ Promise -only if you have the permission you can delete an organization - Before you can delete the organization, you must first remove all accounts and databases - from the organization - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| orgId | string | the organization id | -| orgDoc | object | the organization details description | - - -### deleteOrganization -#### woqlClient.deleteOrganization(orgId) ⇒ Promise -only if you have the permission you can delete an organization - Before you can delete the organization, you must first remove all accounts and databases - from the organization - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| orgId | string | the organization id | - - -### getRoles -#### woqlClient.getRoles([userId], [orgId], [dbId]) ⇒ Promise -get all the user roles (for the current logged user) -or the user roles for a specific database and user -(the logged used need to have the permission to see the roles info for another user) - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | Description | -| --- | --- | --- | -| [userId] | string | the user id | -| [orgId] | string | the organization id | -| [dbId] | string | the dbId | - - -### updateRoles -#### woqlClient.updateRoles(newRolesObj) ⇒ Promise -Change the user role for existing users in your organization, including your own - -**Returns**: Promise - A promise that returns the call response object, or an Error if rejected. - -| Param | Type | -| --- | --- | -| newRolesObj | typedef.RolesObj | - - ### addDocument #### woqlClient.addDocument(json, [params], [dbId], [string]) ⇒ Promise to add a new document or a list of new documents into the instance or the schema graph. diff --git a/lib/woql.js b/lib/woql.js index aa509691..1be886b2 100644 --- a/lib/woql.js +++ b/lib/woql.js @@ -91,6 +91,14 @@ WOQL.and = function(...subqueries) { } +/** + * Read a node identified by an IRI as a JSON-LD document + * @param {string} IRI - The document id or a variable + * @param {string} output - variable name + * @param {object} formatObj + * @return {object} WOQLQuery + */ + WOQL.read_object = function(IRI, output, formatObj) { return new WOQLQuery().read_object(IRI, output, formatObj) } diff --git a/lib/woqlClient.js b/lib/woqlClient.js index bfbc927a..b5777bc0 100755 --- a/lib/woqlClient.js +++ b/lib/woqlClient.js @@ -821,194 +821,6 @@ WOQLClient.prototype.updateDatabase = function(dbDoc) { return this.createDatabase(dbid, dbDoc, org) } - -/** - * For creating an user - * @param {string} userId - the userId - * @param {object} userDoc - the user's object description - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.createUser = function(userId, userDoc) { - if (userId) { - return this.dispatch(CONST.POST, this.connectionConfig.userURL(), userDoc) - } - let errmsg = `Create user parameter error - you must specify a valid user id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.CREATE_USER, errmsg)), - ) -} - -/** - * Get the logged user details. - * @param {string} userId - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.getUser = function(userId) { - return this.dispatch(CONST.GET, this.connectionConfig.userURL(userId)) -} - -/** - * Update an user from the database. - * @param {string} userId - * @param {object} userDoc - User Object details - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.updateUser = function(userId, userDoc) { - if (userId) { - return this.dispatch(CONST.UPDATE_USER, this.connectionConfig.userURL(userId), userDoc) - } - let errmsg = `Update user parameter error - you must specify a valid user id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.UPDATE_USER, errmsg)), - ) -} - -/** - * Delete an user from the database Only a user with DBA authority can delete a user. - * @param {string} userId - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.deleteUser = function(userId) { - if (userId) { - return this.dispatch(CONST.DELETE, this.connectionConfig.userURL(userId)) - } - let errmsg = `Delete user parameter error - you must specify a valid user id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.USER, errmsg)), - ) -} - -/** - * Create a new organization for the registered user - * @param {string} orgId - the organization id - * @param {object} orgDoc - An object that describe the organization's details - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.createOrganization = function(orgId, orgDoc) { - if (orgId) { - return this.dispatch( - CONST.CREATE_ORGANIZATION, - this.connectionConfig.organizationURL(), - orgDoc, - ) - } - let errmsg = `Create organization parameter error - you must specify a valid organization id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.CREATE_ORGANIZATION, errmsg)), - ) -} - - -/** - * Create a new organization for the registered user - * @param {string} orgId - the organization id - * @param {object} orgDoc - An object that describe the organization's details - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - - WOQLClient.prototype.setOrganizationRoles = function(payload, orgDoc) { - //if (orgId) { - return this.dispatch( - CONST.CREATE_ORGANIZATION, - this.connectionConfig.updateOrganizationRoleURL(), - payload, - ) - //} - //let errmsg = `Create organization parameter error - you must specify a valid organization id` - /* return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.CREATE_ORGANIZATION, errmsg)), - )*/ -} - -/** - * Gets all the information about the given organization - * @param {string} orgId - the organization id - * @param {string} [action] - set an action like recommendations | invitations | collaborators - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.getOrganization = function(orgId, action) { - return this.dispatch( - CONST.GET, - this.connectionConfig.organizationURL(orgId, action), - ) -} - -/** - * only if you have the permission you can delete an organization - * Before you can delete the organization, you must first remove all accounts and databases - * from the organization - * @param {string} orgId - the organization id - * @param {object} orgDoc - the organization details description - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.updateOrganization = function(orgId, orgDoc) { - if (orgId) { - return this.dispatch( - CONST.CREATE_ORGANIZATION, - this.connectionConfig.organizationURL(orgId), - orgDoc, - ) - } - let errmsg = `Update organization parameter error - you must specify a valid organization id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.UPDATE_ORGANIZATION, errmsg)), - ) -} - -/** - * only if you have the permission you can delete an organization - * Before you can delete the organization, you must first remove all accounts and databases - * from the organization - * @param {string} orgId - the organization id - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.deleteOrganization = function(orgId) { - if (orgId) { - return this.dispatch( - CONST.ORGANIZATION, - this.connectionConfig.organizationURL(orgId), - ) - } - let errmsg = `Delete organization parameter error - you must specify a valid organization id` - return Promise.reject( - new Error(ErrorMessage.getInvalidParameterMessage(CONST.ORGANIZATION, errmsg)), - ) -} - -/** - * get all the user roles (for the current logged user) - * or the user roles for a specific database and user - * (the logged used need to have the permission to see the roles info for another user) - * @param {string} [userId] - the user id - * @param {string} [orgId] - the organization id - * @param {string} [dbId] - the dbId - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ -WOQLClient.prototype.getRoles = function(userId, orgId, dbId) { - let roleURL = this.connectionConfig.rolesURL() - if (userId && orgId && dbId) { - roleURL = `${roleURL}/${userId}/${orgId}/${dbId}` - } - return this.dispatch(CONST.GET, roleURL) -} - -/** - * Change the user role for existing users in your organization, including your own - * @param {typedef.RolesObj} newRolesObj - * @returns {Promise} A promise that returns the call response object, or an Error if rejected. - */ - -WOQLClient.prototype.updateRoles = function(newRolesObj) { - return this.dispatch(CONST.UPDATE_ROLES, this.connectionConfig.updateRolesURL(), newRolesObj) -} /** * to add a new document or a list of new documents into the instance or the schema graph. * @param {object} json