2020-12-18 - Catalog Manager - Functions

From Izara Wiki
Jump to navigation Jump to search

Service - Catalog Manager

Lambda Functions

CatalogServiceName/ListServiceNameTags

/**
 * List all catalogServiceNameTags from Config table
 *
 * @returns {object[]} catalogServiceNameTags
 */

HdrApi

  • Validator: (standard/none)

Authorizer

  • AppLevel

handler logic

  • (standard)

logic

  1. query DynamoDB Config table for configTag = "catalogServiceName" and return an array of the serviceNameTags (configKeys)

CategoryTreeServiceName/ListServiceNameTags

/**
 * List all categoryTreeServiceNameTags from Config table
 *
 * @returns {object[]} categoryTreeServiceNameTags
 */

HdrApi

  • Validator: (standard/none)

Authorizer

  • AppLevel

handler logic

  • (standard)

logic

  1. query DynamoDB Config table for configTag = "categoryTreeServiceName" and return array of the serviceNameTags (configKeys)

Catalog/List

/**
 * List catalogs
 * @param {string} catalogNameFilter
 *
 * @returns {object[]} catalogs
 */

HdrApi

  • Validator: (standard/none)

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. const catalogs = NPM module - izara-shared#graphSharedLib.getVerticesByVertexLabel
    1. graphServiceName: catalogGraphServiceName
    2. vertexLabel: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
  3. return catalogs

Category/List

/**
 * List categories
 * @param {string} categoryNameFilter
 *
 * @returns {object[]} catalogs
 */

HdrApi

  • Validator: (standard/none)

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. const categories = NPM module - izara-shared#graphSharedLib.getVerticesByVertexLabel
    1. graphServiceName: catalogGraphServiceName
    2. vertexLabel: NPM module - izara-market-shared#CategoryStandardLib.categoryGraphTag
  3. return categories

Catalog/Browse

/**
 * Client request to browse a category in a catalog, including any additional filters
 * @param {string} catalogId
 * @param {string} [categoryNodeId=""] - if empty will browse catalog level
 * @param {numeric} [browseQuantity=0]
 * @param {numeric} [locationNodeId=""] - if empty will not filter by locationNodeId
 * @param {string} [searchType=""] - overwrite default searchType
 * @param {Object} [filter={}] - complex filter object, adds additional filters
 * @param {Object} [requiredData={}] - overwrite default requiredData
 *
 * @returns {Object} if successful returns object with searchResultId and requestDetailId, or sortResultId
 */

HdrApi

  • Validator: (standard/none)

Authorizer

  • AppLevel

handler logic

  • (standard)

logic

  1. const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
  2. const catalog = NPM module - izara-shared#graphSharedLib.getVertexByVertexTagAndVertexUniqueId
    1. graphServiceName: catalogGraphServiceName
    2. vertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
    3. vertexUniqueId: catalogId
  3. if not exist return error object to handler, which then ?throws error for API client

// adjust to default values

  1. if browseQuantity empty
    1. browseQuantity = catalog.defaultBrowseQuantity

// get browseRequest from category tree service

  1. const searchResultRequest = invoke sync 2020-12-19 - Category Tree Standard - Functions#CategoryNode/BuildBrowseRequest
    1. catalogId: catalogId
    2. categoryNodeId: categoryNodeId
    3. searchType: searchType
    4. filter: filter
    5. requiredData: requiredData
  2. // add in additionalParams
  3. searchResultRequest.additionalParams = {
    1. browseQuantity: browseQuantity
    2. locationNodeId = locationNodeId
  4. const searchTypeConfig = {from Config table: searchType matching ...browseConfig setting after building in category tree service}
  5. const searchResultId = invoke sync ... search result request in service set by ''searchTypeConfig.serviceName''
    1. searchResultRequest: searchResultRequest
    2. ..
  6. return searchResultId

Functions

...

/**
 * ...
 * @param {string} ...
 *
 * @returns {string} ...
 */

logic

...