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

inflow-get

v0.3.4

Published

SQLite database seeded from Inflow Inventory API

Readme

inflow-get

A reusable library for seeding a local SQLite database from any Inflow Inventory account. Uses inflow-api-types for schema validation.

Installation

npm install inflow-get

Also install the API client:

npm install inflow-client

Usage

Option 1: Seed from Inflow API

Fetch all data from your Inflow account and store it locally:

import { createDb, seedAll } from 'inflow-get';
import { createClient } from 'inflow-client';

// Create database at your chosen path
const db = createDb('./my-inventory.db');

// Create API client with your credentials
const client = createClient({
  apiKey: process.env.INFLOW_API_KEY,
  companyId: process.env.INFLOW_COMPANY_ID,
});

// Seed all data (one-time)
await seedAll({ db, client });

// Now query your data with full type safety
import { products, salesOrders, customers } from 'inflow-get';
import { eq } from 'drizzle-orm';

const activeProducts = db
  .select()
  .from(products)
  .where(eq(products.isActive, true))
  .all();

Option 2: Schema Only (No Seeding)

Use the Drizzle schema tables in your own project without seeding from Inflow:

import { createDb, products, customers, salesOrders } from 'inflow-get';
import { eq } from 'drizzle-orm';

// Create database
const db = createDb('./my-data.db');

// Import tables and use with Drizzle ORM
// Full TypeScript support - IDE shows all columns
const results = db.select().from(products).all();
//    ^? Array<{ productId: string, name: string, sku: string, ... }>

// Joins work with full type inference
const ordersWithCustomers = db
  .select({
    orderNumber: salesOrders.orderNumber,
    customerName: customers.name,
    total: salesOrders.total,
  })
  .from(salesOrders)
  .leftJoin(customers, eq(salesOrders.customerId, customers.customerId))
  .all();

Option 3: Selective Seeding

Seed only specific entities:

import { createDb, seedAllReference, seedProducts, seedVendors } from 'inflow-get';
import { createClient } from 'inflow-client';

const db = createDb('./inventory.db');
const client = createClient({ apiKey: '...', companyId: '...' });

// Seed only what you need
await seedAllReference({ db, client });  // Categories, locations, etc.
await seedProducts({ db, client });       // Products with prices, inventory
await seedVendors({ db, client });        // Vendors with vendor items

Available Exports

// Database factory
import { createDb } from 'inflow-get';

// Seed functions
import {
  seedAll,              // Everything
  seedAllReference,     // Reference tables only
  seedProducts,         // Products + nested tables
  seedVendors,          // Vendors + vendor items
  seedCustomers,        // Customers
  seedAllOrders,        // PO, SO, MO
  seedAllTransactions,  // Transfers, adjustments
  seedAllStockCounts,   // Stock counts
  seedAllCustomFields,  // Custom field definitions
  seedProductSummary,   // Inventory metrics (opt-in)
} from 'inflow-get';

// Schema tables (for querying)
import {
  // Reference
  categories, locations, currencies, pricingSchemes,
  paymentTerms, taxCodes, taxingSchemes, operationTypes,
  adjustmentReasons, teamMembers,

  // Custom Fields
  customFieldDefinitions, customFieldDropdownOptions, customFields,

  // Products
  products, productPrices, productBarcodes, inventoryLines,
  itemBoms, productOperations, reorderSettings,

  // Vendors & Customers
  vendors, vendorItems, customers,

  // Orders
  purchaseOrders, purchaseOrderLines,
  salesOrders, salesOrderLines,
  manufacturingOrders,

  // Transactions
  stockTransfers, stockTransferLines,
  stockAdjustments, stockAdjustmentLines,
  productCostAdjustments, productCostAdjustmentLines,

  // Inventory Operations
  stockCounts, countSheets, countSheetLines,

  // Reporting
  productSummary,
} from 'inflow-get';

// Types
import type { SeedContext, InflowDb } from 'inflow-get';

Schema Reference

All tables are Drizzle schema definitions with full TypeScript types. Import them and get IDE autocomplete for all columns.

Reference Tables

| Table | Key Columns | Description | |-------|-------------|-------------| | categories | categoryId, name, parentCategoryId | Hierarchical product categories | | locations | locationId, name, address | Warehouses, stores | | currencies | currencyId, code, exchangeRate | Currency definitions | | pricingSchemes | pricingSchemeId, name | Price tier schemes | | paymentTerms | paymentTermsId, name, netDays | Payment terms | | taxCodes | taxCodeId, name, rate | Tax rates | | taxingSchemes | taxingSchemeId, name | Tax scheme groups | | operationTypes | operationTypeId, name | Manufacturing operations | | adjustmentReasons | adjustmentReasonId, name | Stock adjustment reasons | | teamMembers | teamMemberId, name, email | Users |

Products

| Table | Key Columns | Description | |-------|-------------|-------------| | products | productId, name, sku, categoryId | Main product records | | productPrices | productPriceId, productId, unitPrice | Prices per pricing scheme | | productBarcodes | productBarcodeId, productId, barcode | Product barcodes | | inventoryLines | inventoryLineId, productId, locationId, quantityOnHand | Stock by location | | itemBoms | itemBomId, productId, childProductId, quantity | Bill of materials | | productOperations | productOperationId, productId, operationTypeId | Manufacturing steps | | reorderSettings | reorderSettingsId, productId, reorderPoint | Reorder configuration |

Vendors & Customers

| Table | Key Columns | Description | |-------|-------------|-------------| | vendors | vendorId, name, currencyId, paymentTermsId | Vendor records | | vendorItems | vendorItemId, vendorId, productId, cost | Vendor-product links | | customers | customerId, name, pricingSchemeId | Customer records |

Orders

| Table | Key Columns | Description | |-------|-------------|-------------| | purchaseOrders | purchaseOrderId, orderNumber, vendorId, status | Purchase orders | | purchaseOrderLines | purchaseOrderLineId, purchaseOrderId, productId | PO line items | | salesOrders | salesOrderId, orderNumber, customerId, status | Sales orders | | salesOrderLines | salesOrderLineId, salesOrderId, productId | SO line items | | manufacturingOrders | manufacturingOrderId, orderNumber, productId | Work orders |

Transactions

| Table | Key Columns | Description | |-------|-------------|-------------| | stockTransfers | stockTransferId, fromLocationId, toLocationId | Inventory transfers | | stockTransferLines | stockTransferLineId, stockTransferId, productId | Transfer line items | | stockAdjustments | stockAdjustmentId, locationId, adjustmentReasonId | Stock adjustments | | stockAdjustmentLines | stockAdjustmentLineId, stockAdjustmentId, productId | Adjustment lines | | productCostAdjustments | productCostAdjustmentId, adjustmentNumber | Cost adjustments | | productCostAdjustmentLines | productCostAdjustmentLineId, productId, oldCost, newCost | Cost adjustment lines |

Inventory Operations

| Table | Key Columns | Description | |-------|-------------|-------------| | stockCounts | stockCountId, stockCountNumber, locationId, status | Inventory counts | | countSheets | countSheetId, stockCountId, sheetNumber | Count sheets | | countSheetLines | countSheetLineId, countSheetId, productId, countedQuantity | Count lines |

Reporting

| Table | Key Columns | Description | |-------|-------------|-------------| | productSummary | productSummaryId, productId, quantityOnHand, quantityAvailable | Inventory metrics |

Custom Fields

| Table | Key Columns | Description | |-------|-------------|-------------| | customFieldDefinitions | customFieldDefinitionId, label, entityType | Field definitions | | customFieldDropdownOptions | id, entityType, dropdownOptions | Dropdown choices | | customFields | customFieldsId, *Print settings | Print configuration |

Full Column Details

For complete column definitions, see src/db/schema.ts. All columns have TypeScript types inferred automatically when you use the Drizzle tables.

Local Development

If you're contributing to this repo (not consuming as a library):

# Install dependencies
npm install

# Generate and run migrations
npm run db:generate
npm run db:migrate

# Seed from your Inflow account
INFLOW_API_KEY=xxx INFLOW_COMPANY_ID=yyy npm run seed

# Browse data
npm run db:studio

Scripts

| Script | Description | |--------|-------------| | npm run typecheck | TypeScript type checking | | npm run db:generate | Generate migrations from schema | | npm run db:migrate | Run pending migrations | | npm run db:studio | Open Drizzle Studio GUI | | npm run seed | Seed all entities | | npm run seed:reference | Seed reference tables only | | npm run seed:products | Seed products only | | npm run seed:vendors | Seed vendors only | | npm run seed:customers | Seed customers only | | npm run seed:orders | Seed orders only | | npm run seed:transactions | Seed transactions only | | npm run seed:stock-counts | Seed stock counts only |

Related Packages