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

commerce-sdk-isomorphic

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commerce-sdk-isomorphic

Salesforce Commerce SDK Isomorphic

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.3K
decreased by-15.47%
Maintainers
1
Weekly downloads
 
Created
Source

commerce-sdk-isomorphic

CircleCI

The Salesforce Commerce SDK Isomorphic allows easy interaction with the Salesforce B2C Commerce platform Shopper APIs through a lightweight SDK that works both on browsers and nodejs applications. For a more robust SDK, which includes our B2C Data APIS and Shopper APIs, see our Node.js Commerce SDK.

Building

To create the SDK package:

# Install dependencies needed to run generation
$ yarn install

# Parse API files, render templates to src/lib folder and copy static files to src/lib
$ yarn run renderTemplates

# Launch sample application
$ yarn start

# Transpile and minify
$ yarn build:lib

# Run tests
$ yarn test

Usage

An example React App is available at ./src/environment/App directory. To use the sample application, configure these parameters in ./src/environment/config.js file.

Note: These are required parameters.

ParameterDescription
clientIdID of the client account created with Salesforce Commerce.
organizationIdThe unique identifier for your Salesforce identity.
shortCodeRegion specific merchant ID.
siteIdA unique site ID (for example, RefArch or SiteGenesis).
/**
 * Configure required parameters
 * 
 * To learn more about the parameters please refer to https://developer.commercecloud.com/s/article/CommerceAPI-Get-Started
 */
// Create a configuration to use when creating API clients
const config = {
    proxy: 'https://localhost:3000',
    headers: {},
    parameters: {
      clientId: '<your-client-id>',
      organizationId: '<your-org-id>',
      shortCode: '<your-short-code>',
      siteId: '<your-site-id>'
    }
}

Launch the sample application using yarn start. Access the sample application using a new browser window at this url localhost:3000.

Advanced options

Commerce SDK Isomorphic supports advanced Fetch API options by a simple configuration. This sample code shows how to configure HTTP timeout and agent options in ./src/environment/config.js file

 /**
  * Configure advanced timeout and agent parameters
  * 
  * To learn more about the parameters please refer to https://developer.commercecloud.com/s/article/CommerceAPI-Get-Started
  */
 // Create a configuration to use when creating API clients
const https = require("https");

const config = {
    proxy: 'https://localhost:3000',
    headers: {},
    parameters: {
        clientId: '<your-client-id>',
        organizationId: '<your-org-id>',
        shortCode: '<your-short-code>',
        siteId: '<your-site-id>'
    },
    fetchOptions: {
      timeout: 2000, //request times out after 2 seconds
      agent: new https.agent({ // a custom http agent
        keepAlive: true
      })
    } 
}

Testing

Two types of tests occur when running yarn test. First, unit tests are executed with jest including an enforced coverage level. This is all tests not contained within the sample app path of src/environment. If that passes, tests within the sample app path are executed using the react-scripts configuration. These allow for testing of the SDK within a sample React application.

License Information

The Commerce SDK Isomorphic is licensed under BSD-3-Clause license. See the license for details.

FAQs

Package last updated on 23 Jun 2021

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