NPM module - izara-shared: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 80: | Line 80: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
# //get currently active versioned data edge, if exists, allow for an array in case race conditions previously caused two versions to be set as active | |||
# const ''previouslyActiveVertices'' = invoke [[#neptuneGraphSharedLib.getVertexOutEdges]] | |||
## graphServiceName: ''graphServiceName'' | |||
## subjectVertexId: ''subjectVertexId'' | |||
## edgeLabel: ''edgeLabel'' | |||
## edgeProperties: | |||
### to: 0 | |||
# const ''timestamp'' = current timestamp | # const ''timestamp'' = current timestamp | ||
# | # publish message to ''graphServiceName'' MsgIn queue (msgTag: 'CreateEdge'): | ||
## subjectVertexId: ''subjectVertexId'' | ## subjectVertexId: ''subjectVertexId'' | ||
## edgeLabel: ''edgeLabel'' | ## edgeLabel: ''edgeLabel'' | ||
## edgeId: ''subjectVertexId'' + '_' + ''edgeLabel'' + '_' + ''newVersionedDataVertexId'' | ## edgeId: ''subjectVertexId'' + '_' + ''edgeLabel'' + '_' + ''newVersionedDataVertexId'' | ||
## objectId: ''newVersionedDataVertexId'' | |||
## edgeProperties: | |||
### from: ''timestamp'' | |||
### to: 0 | |||
# // update previously active versioned data | |||
# for each ''previouslyActiveVertices'' | |||
## publish message to ''graphServiceName'' MsgIn queue (msgTag: 'UpdateEdgeProperties'): | |||
### edgeId: ''previouslyActiveVertex''.id(?) | |||
### edgeProperties: | |||
#### to: ''timestamp'' | |||
# // link to user who created new versioned data | |||
# const ''userVertexId'' = [[#neptuneGraphSharedLib.createVertexId]] | |||
## vertexTag: 'user' | |||
## uniqueId: ?_izContext.authorized/signedInUser..? | |||
# publish message to ''graphServiceName'' MsgIn queue (msgTag: 'CreateEdge'): | |||
## subjectVertexId: ''subjectVertexId'' | |||
## edgeLabel: ''edgeLabel'' | |||
## edgeId: ''subjectVertexId'' + '_' + ''edgeLabel'' + '_' + ''newVersionedDataVertexId'' | |||
## objectId: ''newVersionedDataVertexId'' | |||
# const ''createdByEdgeId'' = [[#neptuneGraphSharedLib.createCreatedByEdgeId]] | |||
## vertexId: ''newVersionedDataVertexId'' | |||
# publish message to ''graphServiceName'' MsgIn queue (msgTag: 'CreateEdge'): | |||
## subjectVertexId: ''newVersionedDataVertexId'' | |||
## edgeLabel: 'createdBy' | |||
## edgeId: ''createdByEdgeId'' | |||
## objectId: ''userVertexId'' | ## objectId: ''userVertexId'' | ||
== neptuneGraphSharedLib.getVerticesByLabel == | == neptuneGraphSharedLib.getVerticesByLabel == | ||
Line 109: | Line 140: | ||
* @param {string} graphServiceName | * @param {string} graphServiceName | ||
* @param {string} vertexId | * @param {string} vertexId | ||
* | |||
* @returns {string} vertexId | |||
*/ | |||
</syntaxhighlight> | |||
# .. | |||
== neptuneGraphSharedLib.getVertexOutEdges == | |||
<syntaxhighlight lang="JavaScript"> | |||
/** | |||
* Returns all edges, allowing label and property filters | |||
* @param {string} graphServiceName | |||
* @param {string} subjectVertexId | |||
* @param {string} [edgeLabel=""] | |||
* @param {object} [edgeProperties={}] | |||
* | * | ||
* @returns {string} vertexId | * @returns {string} vertexId |
Revision as of 09:56, 3 March 2021
Overview
Shared libraries
Repository
https://bitbucket.org/stb_working/izara-shared/src/master/
Helper functions for interacting with DynamoDB resources.
/**
* 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.
/**
* Creates vertexId from vertexTag and unique id
* @param {string} vertexTag - is the type of object
* @param {string} uniqueId
*
* @returns {string} vertexId
*/
- Concatenate vertexTag + "_" + uniqueId
/**
* @param {string} vertexId
*
* @returns {string} createdByEdgeId
*/
- return vertexId + '_CreatedBy'
/**
* Creates an edge linking a subjectVertex to it's new versioned data vertex, and updates the old current vertex's To timestamp
* @param {string} graphServiceName
* @param {string} subjectVertexId
* @param {string} newVersionedDataVertexId
* @param {string} edgeLabel
*
*/
- //get currently active versioned data edge, if exists, allow for an array in case race conditions previously caused two versions to be set as active
- const previouslyActiveVertices = invoke #neptuneGraphSharedLib.getVertexOutEdges
- graphServiceName: graphServiceName
- subjectVertexId: subjectVertexId
- edgeLabel: edgeLabel
- edgeProperties:
- to: 0
- const timestamp = current timestamp
- publish message to graphServiceName MsgIn queue (msgTag: 'CreateEdge'):
- subjectVertexId: subjectVertexId
- edgeLabel: edgeLabel
- edgeId: subjectVertexId + '_' + edgeLabel + '_' + newVersionedDataVertexId
- objectId: newVersionedDataVertexId
- edgeProperties:
- from: timestamp
- to: 0
- // update previously active versioned data
- for each previouslyActiveVertices
- publish message to graphServiceName MsgIn queue (msgTag: 'UpdateEdgeProperties'):
- edgeId: previouslyActiveVertex.id(?)
- edgeProperties:
- to: timestamp
- publish message to graphServiceName MsgIn queue (msgTag: 'UpdateEdgeProperties'):
- // link to user who created new versioned data
- const userVertexId = #neptuneGraphSharedLib.createVertexId
- vertexTag: 'user'
- uniqueId: ?_izContext.authorized/signedInUser..?
- publish message to graphServiceName MsgIn queue (msgTag: 'CreateEdge'):
- subjectVertexId: subjectVertexId
- edgeLabel: edgeLabel
- edgeId: subjectVertexId + '_' + edgeLabel + '_' + newVersionedDataVertexId
- objectId: newVersionedDataVertexId
- const createdByEdgeId = #neptuneGraphSharedLib.createCreatedByEdgeId
- vertexId: newVersionedDataVertexId
- publish message to graphServiceName MsgIn queue (msgTag: 'CreateEdge'):
- subjectVertexId: newVersionedDataVertexId
- edgeLabel: 'createdBy'
- edgeId: createdByEdgeId
- objectId: userVertexId
/**
* Returns all vertices that match the vertex label for the given graph
* @param {string} graphServiceName
* @param {string} vertexLabel
*
* @returns {string} vertexId
*/
- ..
/**
* Returns all vertices that match the vertex label for the given graph
* @param {string} graphServiceName
* @param {string} vertexId
*
* @returns {string} vertexId
*/
- ..
/**
* Returns all edges, allowing label and property filters
* @param {string} graphServiceName
* @param {string} subjectVertexId
* @param {string} [edgeLabel=""]
* @param {object} [edgeProperties={}]
*
* @returns {string} vertexId
*/
- ..