NPM module - izara-shared: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 470: | Line 470: | ||
## vertexId: ''vertexId'' | ## vertexId: ''vertexId'' | ||
## versionedDataTag: ''versionedDataTag'' | ## versionedDataTag: ''versionedDataTag'' | ||
= Working documents = | |||
[[:Category:Working_documents - NPM module - izara-shared|Working_documents - NPM module - izara-shared]] |
Revision as of 12:04, 3 May 2021
Overview
Shared libraries used across multiple izara projects
Repository
https://bitbucket.org/stb_working/izara-shared/src/master/
constants
- {string} systemTextGraphTag ("systemText")
- {string} systemTextServiceNameGraphTag ("systemTextServiceName")
Helper functions for interacting with Lambda resources.
/**
* Executes a Get query to DynamoDB
* @param {string} serviceName
* @param {string} functionName
*
* @returns {string} deployed Lambda service name
*/
- concatenate with env stage setting
Helper functions for interacting with DynamoDB resources.
/**
* Executes a Get query to DynamoDB
* @param {string} tableName
* @param {object} keyValues
*
* @returns {object} single record return value from the query, or Null if none found
*/
- return the .Item property
/**
* Executes a Query on DynamoDB
* @param {string} tableName
* @param {object} partitionKeyValue
* @param {[object]} sortKeyConditions
* @param {[object]} ExclusiveStartKey
* @param {object} ... other variables needed
*
* @returns {object[], object} array of records from .Items in query result, and query details such as LastEvaluatedKey
*/
/**
* Executes a PutItem query on DynamoDB
* @param {string} tableName
* @param {object} keyValues
* @param {object} attributes
* @param {[object]} conditionalExpression
* @param {object} ... other variables needed
*
* @returns {} .. maybe nothing
*/
- standardize method of handling errors, eg conditionalExpression not pass or unexpected failures
/**
* Executes a PutItem query on DynamoDB
* @param {string} tableName
* @param {object} keyValues
* @param {object} attributes
* @param {[object]} conditionalExpressions
* @param {object} ... other variables needed
*
* @returns {} .. maybe nothing
*/
- standardize method of handling errors, eg conditionalExpression not pass or unexpected failures
/**
* Creates a string set element for use with documentClient
* @param {string[]} stringSet
*
* @returns {string} String formatted as a string set for Dynamo
*/
Helper functions for Config tables.
/**
* @param {string} configTag
* @param {string} configKey
*
* @returns {Object} returns the configValue for a single config record, or null if none found
*/
Helper functions for interacting with Neptune graph databases from any service.
constants
- {string} userGraphTag ("user")
- {string} createdByEdgeLabel ("createdBy")
- {string} hasEdgeLabelPrefix ("has_")
- {string} settingsVersionedDataTag ("Settings")
- {string} versionedDataFromPropertyName ("from")
- {string} versionedDataToPropertyName ("to")
/**
* Creates vertexId from vertexTag and unique id
* @param {string} vertexTag - is the type of object
* @param {string} vertexUniqueId
*
* @returns {string} vertexId
*/
- Concatenate vertexTag + '_' + vertexUniqueId
/**
* Creates standardized edgeId
* @param {string} subjectVertexId
* @param {string} edgeLabel
* @param {string} [objectVertexId=""]
*
* @returns {string} edgeId
*/
- let edgeid = subjectVertexId + '_' + edgeLabel
- if(objectVertexId)
- edgeid = edgeid + '_' + objectVertexId
- return edgeid
/**
* Creates standardized edgeId
* @param {string} subjectVertexTag
* @param {string} subjectVertexUniqueId
* @param {string} edgeLabel
* @param {string} [objectVertexTag=""]
* @param {string} [objectVertexUniqueId=""]
*
* @returns {string} edgeId
*/
- const subjectVertexId = graphSharedLib.createVertexId
- vertexTag = subjectVertexTag
- uniqueId = subjectVertexUniqueId
- let objectVertexId = ""
- if(objectVertexTag)
- objectVertexId = graphSharedLib.createVertexId
- vertexTag = objectVertexTag
- uniqueId = objectVertexUniqueId
- objectVertexId = graphSharedLib.createVertexId
- return = graphSharedLib.createEdgeIdFromVertexIds
- subjectVertexId: subjectVertexId'
- edgeLabel: edgeLabel
- objectVertexId: objectVertexId
/**
* Creates standardized versionedDataVertexLabel
* @param {string} subjectVertexTag
* @param {string} versionedDataTag
*
* @returns {string} versionedDataVertexLabel
*/
- let versionedDataVertexTag = subjectVertexTag + versionedDataTag
- return versionedDataVertexTag
/**
* Creates standardized versionedDataEdgeLabel
* @param {string} ''versionedDataTag''
*
* @returns {string} versionedDataEdgeLabel
*/
- return NPM module - izara-shared#graphSharedLib.hasEdgeLabelPrefix + versionedDataTag
/**
* Returns all vertices that match the vertex label for the given graph
* @param {string} graphServiceName
* @param {string} vertexLabel
*
* @returns {string} vertexId
*/
- ..
/**
* Returns vertex that matched the vertex id
* @param {string} graphServiceName
* @param {string} vertexId
*
* @returns {string} vertexId
*/
- ..
/**
* Returns vertex that matched the vertex id
* @param {string} graphServiceName
* @param {string} vertexTag
* @param {string} vertexUniqueId
*
* @returns {object} vertex
*/
- const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
- vertexTag: vertexTag
- vertexUniqueId: vertexUniqueId
- const vertex = invoke #graphSharedLib.getVertexByVertexId
- graphServiceName: graphServiceName
- vertexId: vertexId
- return vertex
/**
* Returns all edges, allowing label and property filters
* @param {string} graphServiceName
* @param {string} subjectVertexId
* @param {string} [edgeLabel=""]
* @param {object} [edgeProperties={}]
*
* @returns {string} vertexId
*/
- ..
/**
* Returns all edges, allowing label and property filters
* @param {string} graphServiceName
* @param {string} subjectVertexTag
* @param {string} subjectVertexUniqueId
* @param {string} [edgeLabel=""]
* @param {object} [edgeProperties={}]
*
* @returns {string} vertexId
*/
- const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
- vertexTag: subjectVertexTag
- vertexUniqueId: subjectVertexUniqueId
- const edges = invoke #graphSharedLib.getVertexOutEdgesByVertexId
- graphServiceName: graphServiceName
- vertexId: vertexId
- edgeLabel: edgeLabel
- edgeProperties: edgeProperties
- return edges
/**
* 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
*/
- ..
/**
* Find related vertices and their connecting edges, including properties, allowing label and property filters
* @param {string} graphServiceName
* @param {string} subjectVertexTag
* @param {string} subjectVertexUniqueId
* @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
*/
- const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
- vertexTag: subjectVertexTag
- vertexUniqueId: subjectVertexUniqueId
- const vertexAndEdges = invoke #graphSharedLib.getVertexOutEdgesAndVerticesByVertexId
- graphServiceName: graphServiceName
- vertexId: vertexId
- edgeLabel: edgeLabel
- edgeProperties: edgeProperties
- return vertexAndEdges
/**
* Find related vertices and their connecting edges, including properties, allowing label and property filters
* @param {string} graphServiceName
* @param {string} objectVertexId
* @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
*/
- ..
/**
* Find related vertices and their connecting edges, including properties, allowing label and property filters
* @param {string} graphServiceName
* @param {string} objectVertexTag
* @param {string} objectVertexUniqueId
* @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
*/
- const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
- vertexTag: objectVertexTag
- vertexUniqueId: objectVertexUniqueId
- const vertexAndEdges = invoke #graphSharedLib.getVertexOutEdgesAndVerticesByVertexId
- graphServiceName: graphServiceName
- vertexId: vertexId
- edgeLabel: edgeLabel
- edgeProperties: edgeProperties
- return vertexAndEdges
/**
* Find the object/target vertex for a specific edgeId
* @param {string} graphServiceName
* @param {string} edgeId - edge label to filter edges by
*
* @returns {Object} vertex or null if not found
*/
- ..
/**
* Returns vertex that matched the vertex id
* @param {string} graphServiceName
* @param {string} edgeId
*
* @returns {object} edge/subject/object vertices
*/
- ..
/**
* @param {string} graphServiceName
* @param {string} vertexId
* @param {string} versionedDataTag
*
* @returns {Object} versionedData object
*/
- .. needs to filter edge by currently active versioned data..
- ... work through queries to get the current versioned data
- // will need versionedDataEdgeLabel to find edges that are versioned data
- const versionedDataEdgeLabel = #createVersionedDataEdgeLabel
- versionedDataTag: versionedDataTag
/**
* @param {string} graphServiceName
* @param {string} vertexTag
* @param {string} vertexUniqueId
* @param {string} versionedDataTag
*
* @returns {string} versionedData object
*/
- const vertexId = NPM module - izara-shared#graphSharedLib.createVertexId
- vertexTag: vertexTag
- vertexUniqueId: vertexUniqueId
- const versionedDataVertexTag = #graphSharedLib.getCurrentVersionedDataByVertexId
- graphServiceName: graphServiceName
- vertexId: vertexId
- versionedDataTag: versionedDataTag