Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@teamfabric/xpm

Package Overview
Dependencies
Maintainers
3
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teamfabric/xpm

library used to integrate XPM with client application

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
72
decreased by-51.02%
Maintainers
3
Weekly downloads
 
Created
Source

lib-xpm

getEnrichedData

getEnrichedData function hydrates component's content (component data) by replacing template string with provided data. The output is hydrated/non-hydrated data.

For example, if we have a component with content that says "TODAY ONLY: {%= product.title %} IS 50% OFF!", it returns "TODAY ONLY: HAIRBRUSH IS 50% OFF!" by replacing {%= product.title %} with HAIRBRUSH.

Dependency

getEnrichData function uses npm package EJS to hydrate template string.

EJS: Documentation

Behaviors

Returns hydrated data if these conditions are satisfied
  • Data validation against schema passes
  • Component data contains template string
  • Data contains corresponding value to each template string
Returns component data as it is when
  • Provided component data doesn't contain template string
Throws error in these cases
  • Data validation against schema fails
  • Invalid component data (null | empty object) is provided

Usage Example

const { getEnrichedData } = require('@teamfabric/xpm')

/**
 * Hydrates component data and returns it.
 * @param {Object} componentData The component data possibly contains template string.
 * @param {Object} data The data to map template string.
 * @param {Object} schema The schema validates data type.
 * @returns {Object} Hydrated or none-hydrated component data
 */
const data = getEnrichedData({ componentData, data, schema })

FAQs

Package last updated on 25 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc