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

@commercelayer/commercelayer-seeder

v1.6.1

Published

> A Node JS library that lets you import predefines seed data into a Commerce Layer organization.

Downloads

31

Readme

Commerce Layer Seeder

A Node JS library that lets you import predefines seed data into a Commerce Layer organization.

What is Commerce Layer?

Commerce Layer is a headless platform that lets you easily build enterprise-grade ecommerce into any website, by using the language, CMS, and tools you already master and love.

Table of contents

How it works

This seeder is the easiest way to bulk import a set of products, the related prices, and inventory — based on one of the available business models — into your organization and start using Commerce Layer right away.

This seeder is built for Node.js and doesn't run in the browser.

Getting Started

To be ready to use the Commerce Layer Seeder, you need to install it and then get the credentials that will allow you to manage your organization in Commerce Layer.

Installation

Commerce Layer Seeder is available as an npm package:

// npm
npm install @commercelayer/commercelayer-seeder

// yarn
yarn add @commercelayer/commercelayer-seeder

Import

You can use the ES6 default import as follows:

import seeder from '@commercelayer/commercelayer-seeder'

Usage

The seeder function

The seeder function returns a promise and you need to pass to it as a parameter an object containing:

  • clientId: string — your Commerce Layer application client ID (required)
  • clientSecret: string — your Commerce Layer application client secret (required)
  • endpoint: string — your Commerce Layer organization endpoint (required)
  • businessModel: string — the kind of business model you want to import (required / choose among this list)
  • maxItems: number — the maximum number of SKUs that will be imported (optional / default: all)
  • resourcesUrl: string — the resources URL or local path (optional / default: our seeds directory)
  • infoLog: boolean - view the information log during the process (optional / default: true)
// default import — all the products, with related prices and inventory

seeder({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  endpoint: 'https://yourdomain.commercelayer.io',
  businessModel: 'multi_market'
}).then((result) => {
  console.log(result)
})

// custom import — 50 SKUs, local path, with related prices and inventory

seeder({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  endpoint: 'https://yourdomain.commercelayer.io',
  businessModel: 'custom',
  resourcesUrl: 'your-local-resources-directory'
  maxItems: 50,
}).then((result) => {
  console.log(result)
})

Product import into Commerce Layer

Prices import into Commerce Layer

Inventory import into Commerce Layer

The returned object

The promise returned by the seeder function is an array of objects, containing the full list the items imported, by ID:

[
    {'address_1': 'byPVuGvQAW'},
    // ...
    { merchant_1: 'eMBwVHdKmn' },
    // ...
    { stock_location_1: 'gnWomumDNn' },
    { stock_location_2: 'vMQwjuwrbG' },
    // ...
    { inventory_model_1: 'KaozeSXKdZ' },
    { inventory_model_2: 'kLpovSAjMW' },
    // ...
    { inventory_stock_location_1: 'VWRmvInEve' },
    { inventory_stock_location_2: 'lkVMVIlXbW' },
    // ...
    { price_list_1: 'zBMxECjbOL' },
    { price_list_2: 'AkebyCEWRl' },
    // ...
    { market_1: 'wjvKBhQGag' },
    { market_2: 'YoPmehRpdj' },
    { market_3: 'EjDkXhMZao' },
    // ...
    { shipping_category_1: 'ywpRoFraeK' },
    // ...
    { shipping_zone_1: 'BOEwrtpzwv' },
    // ...
    { shipping_method_1: 'XVzWbFkkrE' },
    { shipping_method_2: 'qOWbjFLnZE' },
    // ...
    {'SKUCODE0001XXXX': 'zBMxECjbOL'},
    {'SKUCODE0002XXXX': 'cBKdCEgObJ'},
    {'SKUCODE0003XXXX': 'rVDxESjeKG'},
    // ...
    { price_1: 'BqkxSEzLDZ' },
    { price_2: 'WGDMSkgaAB' },
    { price_3: 'BwpOSbaKAn' },
    // ...
    { stock_item_1: 'nOpOSvyGgZ' },
    { stock_item_2: 'nzPQSGebpW' },
    { stock_item_3: 'ZrxeSRlqbB' },
    // ...

]

Available business models

Commerce Layer provides a set of predefined business models so that you can choose and import your stater one based on your needs and business requirements. These are the business models available at the moment (more to come):

  • Multi-marketbusinessModel: 'multi_market'
  • Custom — businessModel: 'custom'

License

This repository is published under the MIT license.