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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sonic-commerce/storefront-types

v0.22.0

Published

TypeScript types for the Sonic Commerce storefront API (/api/v1).

Readme

@sonic-commerce/storefront-types

TypeScript types for the Sonic Commerce storefront API (/api/v1).

Types only — no runtime code, nothing to import at run time, nothing added to your bundle. Generated from the API's OpenAPI document, which is itself generated from the Zod schemas that serialize every response, so these types describe what the server actually sends.

Install

npm i -D @sonic-commerce/storefront-types
npm i openapi-fetch

openapi-fetch (~6 kB) turns the paths type into a checked client. It is optional — the named types work with fetch, axios, or anything else.

Use

import createClient from "openapi-fetch";
import type { paths, Product } from "@sonic-commerce/storefront-types";

const api = createClient<paths>({
  baseUrl: "https://acme.example.com/api/v1",
  headers: { "x-publishable-key": process.env.PUBLISHABLE_KEY! },
});

// Path, query params and response are all typed and checked.
const { data, error } = await api.GET("/products", {
  params: { query: { limit: 20, sort: "-created_at" } },
});

const products: Product[] | undefined = data?.data;

Every named schema in the spec is exported as a type alias — Product, Cart, Order, Store, Category, Collection, AuthSession, the request bodies, and so on — alongside the raw paths, components and operations that openapi-typescript emits.

import type { Cart, CartTotals, AddCartItemBody } from "@sonic-commerce/storefront-types";

One openapi-fetch quirk

openapi-fetch (0.17.0, checked) drops properties typed as exactly null from the response types it infers. Two fields are affected: shipping_total on CartTotals and on OrderTotals, both deliberately null because shipping is not modelled — an absent charge, not a zero one.

They are still there at run time. If you need them in the type, annotate with the named schema rather than the inferred response:

import type { Cart } from "@sonic-commerce/storefront-types";

const { data } = await api.GET("/carts/{id}", { params: { path: { id } } });
const cart = data?.data as Cart | undefined;   // shipping_total present

Versioning

The package version tracks the API version: 0.10.1 describes the /api/v1 surface as of release 0.10.1.

While the API is pre-1.0, breaking changes ship in a minor bump (0.10 → 0.11), per the project's versioning policy. Pin accordingly:

{ "devDependencies": { "@sonic-commerce/storefront-types": "~0.10.1" } }

~ accepts patches and stays off the next minor. Switch to ^ once the API reaches 1.0.

Other languages

The OpenAPI 3.1 document these types are generated from is served live at GET /api/v1/openapi.json. Any generator that reads OpenAPI can target it.