npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

commerce-integrations

v0.0.1-preview.1

Published

TODO: Fill this

Downloads

3

Readme

The Integration Manager is an API abstraction layer for ecommerce backends.

What does it include?

  1. A well-defined interface for ecommerce API Connectors.
  2. Salesforce and Hybris Connectors that you can use or extend right away.
  3. The Merlins Connector - a demo implementation of the interface using a screen-scraping backend.

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.

Getting started

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'}}))