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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@epcc-sdk/sdks-inventories

v0.0.4

Published

Below you’ll find instructions on how to install, set up, and use the client, along with a list of available operations.

Readme

@epcc-sdk/sdks-inventories SDK

Below you’ll find instructions on how to install, set up, and use the client, along with a list of available operations.

Features

  • type-safe response data and errors
  • response data validation and transformation
  • access to the original request and response
  • granular request and response customization options
  • minimal learning curve thanks to extending the underlying technology

Installation

npm install @epcc-sdk/sdks-inventories
# or
pnpm install @epcc-sdk/sdks-inventories
# or
yarn add @epcc-sdk/sdks-inventories

Client Usage

Clients are responsible for sending the actual HTTP requests.

The Fetch client is built as a thin wrapper on top of Fetch API, extending its functionality. If you're already familiar with Fetch, configuring your client will feel like working directly with Fetch API.

You can configure the client in two ways:

  • Configuring the internal client instance directly
  • Using the createClient function

When using the operation function to make requests, by default the global client will be used unless another is provided.

1. Configure the internal client instance directly

This is the simpler approach. You can call the setConfig() method at the beginning of your application or anytime you need to update the client configuration. You can pass any Fetch API configuration option to setConfig(), and even your own Fetch implementation.

import { client } from "@epcc-sdk/sdks-inventories";

client.setConfig({
// set default base url for requests
baseUrl: 'https://euwest.api.elasticpath.com',

// set default headers for requests
headers: {
Authorization: 'Bearer YOUR_AUTH_TOKEN',
},
});

The disadvantage of this approach is that your code may call the client instance before it's configured for the first time. Depending on your use case, you might need to use the second approach.

2. Using the createClient function

This is useful when you want to use a different instance of the client for different parts of your application or when you want to use different configurations for different parts of your application.

import { createClient } from "@epcc-sdk/sdks-inventories";

// Create the client with your API base URL.
const client = createClient({
    // set default base url for requests
    baseUrl: "https://euwest.api.elasticpath.com",
    /**
    * Set default headers only for requests made by this client.
    */
    headers: {
        "Custom-Header": 'My Value',
    },
});

You can also pass this instance to any SDK function through the client option. This will override the default instance from `import { client } from "@epcc-sdk/sdks-inventories>".

const response = await getStock({
    client: myClient,
});

Direct configuration

Alternatively, you can pass the client configuration options to each SDK function. This is useful if you don't want to create a client instance for one-off use cases.

const response = await getStock({
    baseUrl: 'https://example.com', // <-- override default configuration
});

Interceptors (Middleware)

Interceptors (middleware) can be used to modify requests before they're sent or responses before they're returned to your application. They can be added with use and removed with eject. Below is an example request interceptor

import { client } from "@epcc-sdk/sdks-inventories";

// Supports async functions
client.interceptors.request.use(async (request) => {
    // do something
    return request;
});

client.interceptors.request.eject((request) => {
    // do something
    return request;
});

and an example response interceptor

import { client } from "@epcc-sdk/sdks-inventories";

client.interceptors.response.use((response) => {
    // do something
    return response;
});

client.interceptors.response.eject((response) => {
    // do something
    return response;
});

Tip: To eject, you must provide a reference to the function that was passed to use().

Authentication

We are working to provide helpers to handle auth easier for you but for now using an interceptor is the easiest method.

import { client } from "@epcc-sdk/sdks-inventories";

client.interceptors.request.use((request, options) => {
  request.headers.set('Authorization', 'Bearer MY_TOKEN');
  return request;
});

Build URL

If you need to access the compiled URL, you can use the buildUrl() method. It's loosely typed by default to accept almost any value; in practice, you will want to pass a type hint.

type FooData = {
  path: {
    fooId: number;
  };
  query?: {
    bar?: string;
  };
  url: '/foo/{fooId}';
};

const url = client.buildUrl<FooData>({
  path: {
    fooId: 1,
  },
  query: {
    bar: 'baz',
  },
  url: '/foo/{fooId}',
});
console.log(url); // prints '/foo/1?bar=baz'

Operation Usage

The following examples demonstrate how to use the operation function to make requests.

import { getStock } from "@epcc-sdk/sdks-inventories";

const product = await getStock({
  // client: localClient, // optional if you have a client instance you want to use otherwise the global client will be used
  path: {
    ...
  },
  query: {
    ...
  },
});

Available Operations

  • listStock (GET /inventories)

  • createStock (POST /inventories)

  • getStockForProducts (POST /inventories/multiple)

  • deleteStock (DELETE /inventories/{product_uuid})

  • getStock (GET /inventories/{product_uuid})

  • updateStock (PUT /inventories/{product_uuid})

  • listTransactions (GET /inventories/{product_uuid}/transactions)

  • createTransaction (POST /inventories/{product_uuid}/transactions)

  • getTransaction (GET /inventories/{product_uuid}/transactions/{transaction_uuid})

  • listLocations (GET /inventories/locations)

  • createLocation (POST /inventories/locations)

  • deleteLocation (DELETE /inventories/locations/{location_uuid})

  • getLocation (GET /inventories/locations/{location_uuid})

  • updateLocation (PUT /inventories/locations/{location_uuid})