Small JavaScript SDK for a REST-style inventory backend. It wraps common inventory, movement, quote comparison, medicine batch, spreadsheet sync, purchase record, and product catalog endpoints behind a single fetch-based client.
This repository contains only SDK source and examples. It does not include runtime databases, spreadsheet exports, credentials, service-account files, uploaded images, operational records, or deployment state.
git clone <your-repo-url>
cd generic-inventory-sdkThe package can also be copied directly into another Node.js project by using
src/index.js.
- Node.js 18 or newer
- Or any runtime with a standards-compatible
fetch
If your runtime does not provide fetch, pass one explicitly:
import { createInventorySDK } from "./src/index.js";
const sdk = createInventorySDK({
baseUrl: "http://127.0.0.1:8780",
fetch: yourFetchImplementation
});import { createInventorySDK } from "./src/index.js";
const sdk = createInventorySDK({
baseUrl: "http://127.0.0.1:8780"
});
const health = await sdk.health();
console.log(health);const dashboard = await sdk.getDashboard();
console.log(dashboard);const items = await sdk.getItems();
console.log(items);const movement = await sdk.createMovement({
item_id: "ITEM-001",
date: "2026-05-12",
movement_type: "in",
quantity: 12,
unit: "piece",
purpose: "restock",
note: "SDK smoke test"
});
console.log(movement);await sdk.syncSpreadsheet();
await sdk.writebackMovementsToSpreadsheet();const compare = await sdk.comparePrices({
keyword: "cleaning bag",
itemId: "CLN-001"
});
console.log(compare);health()getDashboard()
getItems()getItem(itemId)createItem(payload)updateItem(itemId, payload)deleteItem(itemId)
getMovements()createMovement(payload)updateMovement(movementId, payload)deleteMovement(movementId)
getQuotes()getQuoteAnalysis()createQuote(payload)updateQuote(quoteId, payload)deleteQuote(quoteId)comparePrices({ keyword, itemId })
getMedicineBatches()createMedicineBatch(payload)updateMedicineBatch(batchId, payload)deleteMedicineBatch(batchId)
getSpreadsheetStatus()syncSpreadsheet()writebackMovementsToSpreadsheet()
Compatibility helpers are also exported for existing spreadsheet-backed endpoints:
getGoogleSheetStatus()syncGoogleSheet()writebackMovementsToGoogleSheet()
getPurchaseItems()createPurchaseItem(payload)updatePurchaseItem(purchaseId, payload)deletePurchaseItem(purchaseId)getPurchaseCandidates(purchaseId)uploadPurchaseImage(payload)extractPurchaseImage(payload)
getStandardProducts()createStandardProduct(payload)updateStandardProduct(productId, payload)deleteStandardProduct(productId)getStandardProductDetail(productId)createProductGrouping(payload)splitProductGrouping(payload)createProductAlias(payload)
Failed requests throw an Error with:
error.messageerror.statuserror.payload
try {
await sdk.getItems();
} catch (error) {
console.error(error.message);
console.error(error.status);
console.error(error.payload);
}- Keep credentials, spreadsheet service-account files, uploaded purchase images, and runtime databases outside the repository.
- The default
baseUrlis localhost. Configure deployment URLs from your own environment rather than committing them. - Treat spreadsheet sync endpoints as privileged operations in production.
- TypeScript declarations
- npm publishing
- Browser bundle
- Retry, timeout, and logger options
- Auth middleware hooks
- Webhook/event helpers