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

sos-inventory-db

v1.0.4

Published

A schema‑driven relational database model for SOS Inventory, including full API contract definitions and ingestion support for SQLite, PostgreSQL, MariaDB, MySQL, and SQL Server.

Readme

sos-inventory-db

A schema‑driven relational database model for SOS Inventory, including:

  • Fully documented API contract definitions
  • Deterministic ingestion of all SOS objects
  • Multi‑engine database support (SQLite, PostgreSQL, MariaDB, MySQL, SQL Server)
  • A single, stable entry point: downloadSOS()
  • Clean, normalized relational tables generated from real SOS payloads

This package gives you a local, queryable mirror of your SOS Inventory data — built from the actual API payloads, not the inconsistent documentation.


Features

  • 🚀 One function: downloadSOS(params)
  • 🧱 Schema‑driven: every table is defined in db/definitions.js
  • 🔄 Deterministic ingestion: same results across all engines
  • 🗄️ Multi‑database support:
    • SQLite (default, zero config)
    • PostgreSQL
    • MariaDB
    • MySQL
    • SQL Server
  • 📦 Dual‑module build: CommonJS + ESM
  • 🧪 Optional DB drivers — install only what you need

Installation

npm install sos-inventory-db

Optional: install the driver for your database engine:

npm install better-sqlite3
npm install pg
npm install mariadb
npm install mysql2
npm install mssql

Quickstart

ESM

import downloadSOS from 'sos-inventory-db'
// or: const downloadSOS = require('sos-inventory-db')

await downloadSOS({
  database: {
    engine: 'sqlite',
    filename: './sos.db'
  },
  sosAuthorization: process.env.SOS_AUTH
})

CommonJS

const downloadSOS = require('sos-inventory-db')

downloadSOS({
  database: {
    engine: 'sqlite',
    filename: './sos.db'
  },
  sosAuthorization: process.env.SOS_AUTH
})

This will:

  • Create all tables defined in db/definitions.js
  • Fetch all SOS Inventory objects
  • Normalize them into relational tables
  • Insert them into your chosen database engine

Engine Configuration

sos-inventory-db accepts a database object describing the engine and connection parameters.

Here is the full interface:

const testDatabases = {
  sqlite: {
    engine: 'sqlite',
    filename: 'db/wdm.db'
  },
  mariadb: {
    engine: 'mariadb',
    host: process.env.MARIADB_HOST,
    port: process.env.MARIADB_PORT,
    user: process.env.MARIADB_USER,
    password: process.env.MARIADB_PASSWORD,
    database: process.env.MARIADB_DATABASE
  },
  postgres: {
    engine: 'postgres',
    host: process.env.POSTGRESQL_HOST,
    port: process.env.POSTGRESQL_PORT,
    user: process.env.POSTGRESQL_USER,
    password: process.env.POSTGRESQL_PASSWORD,
    database: process.env.POSTGRESQL_DATABASE
  },
  mssql: {
    engine: 'mssql',
    server: process.env.MSSQL_SERVER,
    port: Number(process.env.MSSQL_PORT),
    authentication: {
      type: 'default',
      options: {
        userName: process.env.MSSQL_USER,
        password: process.env.MSSQL_PASSWORD
      }
    },
    options: {
      database: process.env.MSSQL_DATABASE,
      encrypt: true,
      trustServerCertificate: true,
      enableArithAbort: true
    }
  }
}

Pass one of these objects to downloadSOS():

await downloadSOS({
  database: testDatabases.postgres,
  sosAuthorization: process.env.SOS_AUTH
})

Authentication

You must provide a valid SOS Inventory API token:

await downloadSOS({
  database,
  sosAuthorization: 'Bearer <your-token-here>'
})

Or via environment variable:

export SOS_AUTH="Bearer <token>"

What Gets Created

sos-inventory-db builds a complete relational mirror of your SOS Inventory account, including:

  • Items
  • Item BOMs
  • Customers
  • Vendors
  • Sales Orders
  • Purchase Orders
  • Invoices
  • Payments
  • Locations
  • Categories
  • Adjustments
  • And all supporting lookup tables

Every table is defined in:

db/definitions.js

This file is the single source of truth for:

  • Table names
  • Field types
  • Nullability
  • Primary keys
  • Reference mappings
  • Read‑only fields
  • API contract definitions

Why This Exists

SOS Inventory’s API documentation is:

  • incomplete
  • inconsistent
  • sometimes incorrect
  • and often out of sync with real payloads

This package solves that by:

  • capturing the actual API responses
  • documenting the real schema
  • normalizing everything into relational tables
  • providing a deterministic ingestion engine
  • supporting multiple SQL backends

The result is a stable, queryable, local mirror of your SOS data.


License

MIT