2021-02-15 - Category Standard - Functions
Jump to navigation
Jump to search
Lambda Functions
Category/List
/**
* Lists all categories
* @param {string} categoryNameFilter
*
* @returns {Object[]} array of category objects
*/
HdrApi
- Validator: (standard)
Authorizer
- AppLevel
handler logic
- (standard)
logic
- Not yet sure how to implement categoryNameFilter syntax, will depend on effective graph querying
- Will probably need to work in pagination
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- use NPM module - izara-shared#graphSharedLib.getVerticesByVertexLabel to pull list of Category vertices:
- graphServiceName: catalogGraphServiceName
- vertexLabel: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
Category/Get
/**
* Get details of one category record
* @param {string} categoryId
*
* @returns {Object} category object
*/
HdrApi
- Validator: (standard)
Authorizer
- AppLevel
handler logic
- (standard)
logic
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- const category = NPM module - izara-shared#graphSharedLib.getVertexByVertexTagAndVertexUniqueId
- graphServiceName: catalogGraphServiceName
- vertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
- vertexUniqueId: categoryId
- return category
Category/Create
/**
* Create a new category
* @param {string} categoryName
* @param {string} languageCode
* @param {string} userId
* @param {object} [createdByEdgeProperties={}]
*
*/
HdrApi
- Validator: (standard)
Authorizer
- AppLevel
handler logic
- userId = ?_izContext.authorized/signedInUser..?
logic
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- const translationsGraphServiceName = {from Config table: TranslationsServiceName}
- const categoryServiceNameTag = {from Config table: CategoryServiceNameTag}
- const categoryId = create new uuid
- // create category vertex
- const vertexProperties = {
- categoryServiceNameTag: categoryServiceNameTag
- publish to catalogGraphServiceName InCreateNode topic
- vertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
- vertexUniqueId: categoryId
- createdByUserId: userId
- createdByEdgeProperties: createdByEdgeProperties
- vertexProperties: vertexProperties
- // create translation for catalogCategoryName
- publish message to translationsGraphServiceName InCreateNewSubjectAndTranslation topic:
- subjectVertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryNameGraphTag
- subjectVertexUniqueId: categoryId
- languageCode: languageCode
- translation: categoryName
- createdByUserId: userId
- // report the new catalog
- send message to own OutCategoryCreated topic
- categoryId: categoryId
- userId: userId
Functions
...