NPM module - izara-shared: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 106: Line 106:


# ..
# ..
== graphSharedLib.getVertexByVertexTagAndVertexUniqueId ==
<syntaxhighlight lang="JavaScript">
/**
* Returns vertex that matched the vertex id
* @param {string} graphServiceName
* @param {string} vertexTag
* @param {string} vertexUniqueId
*
* @returns {string} vertexId
*/
</syntaxhighlight>
# const ''vertexId'' = [[NPM module - izara-shared#graphSharedLib.createVertexId]]
## vertexTag: ''vertexTag''
## vertexUniqueId: ''vertexUniqueId''
# const ''vertex'' = invoke [[#graphSharedLib.getVertexByVertexId]]
## graphServiceName: ''graphServiceName''
## vertexId: ''vertexId''
# return ''vertex''


== graphSharedLib.getVertexOutEdges ==
== graphSharedLib.getVertexOutEdges ==

Revision as of 05:55, 6 March 2021

Overview

Shared libraries used across multiple izara projects

Repository

https://bitbucket.org/stb_working/izara-shared/src/master/

dynamodbSharedLib

Helper functions for interacting with DynamoDB resources.

dynamodbSharedLib.createStringSet

/**
 * Creates a string set element for use with documentClient
 * @param {string[]} stringSet
 *
 * @returns {string} String formatted as a string set for Dynamo
 */

configSharedLib

Helper functions for Config tables.

configSharedLib.getConfigValue

/**
 * @param {string} configTag
 * @param {string} configKey
 *
 * @returns {Object} returns the configValue for a single config record, or null if none found
 */

graphSharedLib

Helper functions for interacting with Neptune graph databases from any service.

constants

  • {string} userGraphTag ("user")
  • {string} createdByEdgeLabel ("createdBy")
  • {string} hasEdgeLabelPrefix ("has_")

graphSharedLib.createVertexId

/**
 * Creates vertexId from vertexTag and unique id
 * @param {string} vertexTag - is the type of object
 * @param {string} vertexUniqueId
 *
 * @returns {string} vertexId
 */
  1. Concatenate vertexTag + "_" + vertexUniqueId

graphSharedLib.createEdgeId

/**
 * Creates standardized edgeId
 * @param {string} subjectVertexId
 * @param {string} edgeLabel
 * @param {string} [objectVertexId=""]
 *
 * @returns {string} edgeId
 */
  1. let edgeid = subjectVertexId + '_' + edgeLabel
  2. if(objectVertexId)
    1. edgeid = edgeid + '_' + objectVertexId
  3. return edgeid

graphSharedLib.getVerticesByVertexLabel

/**
 * Returns all vertices that match the vertex label for the given graph
 * @param {string} graphServiceName
 * @param {string} vertexLabel
 *
 * @returns {string} vertexId
 */
  1. ..

graphSharedLib.getVertexByVertexId

/**
 * Returns vertex that matched the vertex id
 * @param {string} graphServiceName
 * @param {string} vertexId
 *
 * @returns {string} vertexId
 */
  1. ..

graphSharedLib.getVertexByVertexTagAndVertexUniqueId

/**
 * Returns vertex that matched the vertex id
 * @param {string} graphServiceName
 * @param {string} vertexTag
 * @param {string} vertexUniqueId
 *
 * @returns {string} vertexId
 */
  1. const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
    1. vertexTag: vertexTag
    2. vertexUniqueId: vertexUniqueId
  2. const vertex = invoke #graphSharedLib.getVertexByVertexId
    1. graphServiceName: graphServiceName
    2. vertexId: vertexId
  3. return vertex

graphSharedLib.getVertexOutEdges

/**
 * Returns all edges, allowing label and property filters
 * @param {string} graphServiceName
 * @param {string} subjectVertexId
 * @param {string} [edgeLabel=""]
 * @param {object} [edgeProperties={}]
 *
 * @returns {string} vertexId
 */
  1. ..

graphSharedLib.getVertexOutEdgesAndVertices

/**
 * Find related vertices and their connecting edges, including properties, allowing label and property filters
 * @param {string} graphServiceName
 * @param {string} subjectVertexId
 * @param {string} [edgeLabel=""] - edge label to filter edges by
 * @param {object} [edgeProperties={}] - edge properties to filter by, is an array of key > value pairs
 * @param {object} [vertexProperties={}] - object vertex properties to filter by, is an array of key > value pairs
 *
 * @returns {Object[]} array of vertices and the connecting edges
 */
  1. ..

graphSharedLib.getObjectVertexByEdgeId

/**
 * Find the object/target vertex for a specific edgeId
 * @param {string} edgeId - edge label to filter edges by
 *
 * @returns {Object} vertex or null if not found
 */
  1. ..