A reusable library for seeding a local SQLite database from any Inflow Inventory account. Uses inflow-api-types for schema validation.
Installation
npminstall inflow-get
Also install the API client:
npminstall 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 pathconst db =createDb('./my-inventory.db');// Create API client with your credentialsconst client =createClient({
apiKey: process.env.INFLOW_API_KEY,
companyId: process.env.INFLOW_COMPANY_ID,});// Seed all data (one-time)awaitseedAll({ db, client });// Now query your data with full type safetyimport{ 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 databaseconst db =createDb('./my-data.db');// Import tables and use with Drizzle ORM// Full TypeScript support - IDE shows all columnsconst results = db.select().from(products).all();// ^? Array<{ productId: string, name: string, sku: string, ... }>// Joins work with full type inferenceconst 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 needawaitseedAllReference({ db, client });// Categories, locations, etc.awaitseedProducts({ db, client });// Products with prices, inventoryawaitseedVendors({ db, client });// Vendors with vendor items
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 dependenciesnpminstall# Generate and run migrationsnpm run db:generate
npm run db:migrate
# Seed from your Inflow accountINFLOW_API_KEY=xxx INFLOW_COMPANY_ID=yyy npm run seed
# Browse datanpm run db:studio