
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
commerce-integrations
Advanced tools
The Integration Manager is an API abstraction layer for ecommerce backends.
Our Merlins connector shows how to build a data layer for ecommerce backends that do not provide an API. By isolating browser dependencies like this, we can open up opportunities for reuse in other contexts - AMP, Desktop, etc.
A crash course, with React/Redux:
import {SalesforceConnector} from 'commerce-integrations/dist/sfcc'
import {createStore, applyMiddleware, combineReducers} from 'redux'
import thunk from 'redux-thunk'
// 1. Import and extend a Connector
class CustomSalesforceConnector extends SalesforceConnector {
searchProducts(searchParams, opts = {}) {
// Customize the built-in method to add logging, as an example.
console.log('Before call')
return Promise.resolve()
.then(() => super.searchProducts(searchParams, opts)
.then((result) => {
console.log('After call')
return result
}))
}
}
const connector = CustomSalesforceConnector.fromConfig({
basePath: 'https://mobify-tech-prtnr-na03-dw.demandware.net/s/2017refresh/dw/shop/v17_8',
defaultHeaders: {
'x-dw-client-id': '5640cc6b-f5e9-466e-9134-9853e9f9db93'
}
})
// 2. Write Redux reducers
const products = (state = null, action) => {
switch (action.type) {
case 'PRODUCTS_RECEIVED':
return action.products
default:
return state
}
}
const reducer = combineReducers({products})
// 3. Initialize the Redux store and make the connector available in
// all redux-thunk actions, using `withExtraArgument`.
const store = createStore(
reducer,
applyMiddleware(thunk.withExtraArgument({connector: connector}))
)
// 4. Write Redux actions, as usual
export const productsReceived = (products) => {
return {
type: 'PRODUCTS_RECEIVED',
products,
}
}
export const searchProducts = (searchParams) => (dispatch, getState, {connector}) => {
// Note: We can access the injected connector here
return connector.searchProducts(searchParams)
.then((products) => dispatch(productsReceived(products)))
}
// 5. To demo, log all state changes
store.subscribe((action) => {
console.log('Action:')
console.log(JSON.stringify(action, null, 4))
console.log('State:')
console.log(JSON.stringify(store.getState(), null, 4))
})
store.dispatch(searchProducts({filters: {categoryId: 'root'}}))
FAQs
TODO: Fill this
The npm package commerce-integrations receives a total of 2 weekly downloads. As such, commerce-integrations popularity was classified as not popular.
We found that commerce-integrations demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.