2021-03-03 - Catalog Standard- Functions
Jump to navigation
Jump to search
Lambda Functions
Catalog/Get
/**
* Get details of one catalog record
* @param {string} catalogId
*
* @returns {Object} catalog object
*/
HdrApi
- Validator: (standard)
Authorizer
- AppLevel
handler logic
- (standard)
logic
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- const catalog = NPM module - izara-shared#graphSharedLib.getVertexByVertexTagAndVertexUniqueId
- graphServiceName: catalogGraphServiceName
- vertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
- vertexUniqueId: catalogId
- return catalog
Catalog/Create
/**
* Create a catalog in the category tree
* @param {string} categoryTreeServiceNameTag
* @param {string} searchType
* @param {string (or object?)} filter
* @param {string (or object?)} requiredData
* @param {numeric} defaultBrowseQuantity
* @param {string} catalogName
* @param {string} languageCode
* @param {string} userId
*
*/
Authorizer
- App level
HdrApi
- Validator: (standard)
handler logic
- userId = ?_izContext.authorized/signedInUser..?
logic
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- const catalogServiceNameTag = {from Config table: CatalogServiceNameTag}
- const translationsGraphServiceName = {from Config table: TranslationsServiceName}
- // create the catalog vertex with settings
- const catalogId = random uuid
- const catalogSettingsVertexProperties =
- catalogServiceNameTag: catalogServiceNameTag
- categoryTreeServiceNameTag: categoryTreeServiceNameTag
- searchType: searchType
- filter: filter
- requiredData: requiredData
- defaultBrowseQuantity: defaultBrowseQuantity
- publish message to catalogGraphServiceName InCreateNodeWithVersionedData topic:
- vertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
- vertexUniqueId: catalogId
- createdByUserId: userId
- versionedDataTag: NPM module - izara-shared#graphSharedLib.settingsVersionedDataTag
- dataVertexProperties: catalogSettingsVertexProperties
- // create catalog name translation
- publish message to translationsGraphServiceName InCreateNewSubjectAndTranslation topic:
- subjectVertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogNameGraphTag
- subjectVertexUniqueId: catalogId
- languageCode: languageCode
- translation: catalogName
- createdByUserId: userId
- // report the new catalog
- send message to own OutCatalogCreated topic
- catalogId: catalogId
- catalogName: catalogName
- languageCode: languageCode
- userId: userId
Catalog/UpdateSettings
/**
* Create a catalog in the category tree
* @param {string} catalogId
* @param {string} searchType
* @param {string (or object?)} filter
* @param {string (or object?)} requiredData
* @param {numeric} defaultBrowseQuantity
* @param {string} categoryTreeServiceNameTag
* @param {string} userId
*
*/
Authorizer
- App level
HdrApi
- Validator: (standard)
handler logic
- userId = ?_izContext.authorized/signedInUser..?
logic
- const catalogGraphServiceName = {from Config table: CatalogGraphServiceName}
- const catalogServiceNameTag = {from Config table: CatalogServiceNameTag}
- // get existing settings
- existingSettings = NPM module - izara-shared#graphSharedLib.getCurrentVersionedDataByVertexTagAndVertexUniqueId
- graphServiceName: catalogGraphServiceName
- vertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
- vertexUniqueId: catalogId
- versionedDataTag: NPM module - izara-shared#graphSharedLib.settingsVersionedDataTag
- if data in existingSettings matches new settings
- return
- // setup the new dataVertexProperties
- const dataVertexProperties =
- catalogServiceNameTag: catalogServiceNameTag
- categoryTreeServiceNameTag: categoryTreeServiceNameTag
- searchType: searchType
- filter: filter
- requiredData: requiredData
- defaultBrowseQuantity: defaultBrowseQuantity
- // set the timestamp here so we can use this to avoid race conditions when recalculating categoryNode settings
- const timestamp = current timestamp
- // create new versioned data vertex and edges
- publish message to catalogGraphServiceName InCreateVersionedData topic:
- vertexTag: NPM module - izara-market-shared#CatalogStandardLib.catalogGraphTag
- vertexUniqueId: catalogId
- createdByUserId: userId
- versionedDataTag: NPM module - izara-shared#graphSharedLib.settingsVersionedDataTag
- dataVertexProperties: dataVertexProperties
- timestamp: timestamp
- // **** start process to rebuild/regenerate other nodes according to these changes, not yet worked out how to do this serverless and avoid race conditions
- // report this catalog updated
- send message to own OutCatalogUpdated topic
- catalogId: catalogId
- userId: userId
Functions
...