2021-02-15 - Category Standard - Functions

From Izara Wiki
Jump to navigation Jump to search

Service - Category Standard

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
  1. const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
  2. use NPM module - izara-shared#graphSharedLib.getVerticesByVertexLabel to pull list of Category vertices:
    1. graphServiceName: catalogGraphServiceName
    2. 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

  1. const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
  2. const category = NPM module - izara-shared#graphSharedLib.getVertexByVertexTagAndVertexUniqueId
    1. graphServiceName: catalogGraphServiceName
    2. vertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
    3. vertexUniqueId: categoryId
  3. 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

  1. const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
  2. const translationsGraphServiceName = {from Config table: TranslationsServiceName}
  3. const categoryServiceNameTag = {from Config table: CategoryServiceNameTag}
  4. const categoryId = create new uuid
  5. // create category vertex
  6. const vertexProperties = {
    1. categoryServiceNameTag: categoryServiceNameTag
  7. publish to catalogGraphServiceName InCreateNode topic
    1. vertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
    2. vertexUniqueId: categoryId
    3. createdByUserId: userId
    4. createdByEdgeProperties: createdByEdgeProperties
    5. vertexProperties: vertexProperties
  8. // create translation for catalogCategoryName
  9. publish message to translationsGraphServiceName InCreateNewSubjectAndTranslation topic:
    1. subjectVertexTag: NPM module - izara-market-shared#CategoryStandardLib.categoryNameGraphTag
    2. subjectVertexUniqueId: categoryId
    3. languageCode: languageCode
    4. translation: categoryName
    5. createdByUserId: userId
  10. // report the new catalog
  11. send message to own OutCategoryCreated topic
    1. categoryId: categoryId
    2. userId: userId

Functions

...