@duabalabs/sellub-types
Zero-dependency, runtime-free TypeScript types shared by every Sellub SDK. Use them in your own code so signatures stay consistent across surfaces.
Install
pnpm add -D @duabalabs/sellub-typesWhat’s exported
import type {
Cents, Iso8601, CurrencyCode,
Money, CustomerRef, OrderRef, OrderStatus,
Subscription, ApiResult,
} from "@duabalabs/sellub-types";| Type | Shape |
|---|---|
Cents | number — minor currency units (e.g. pesewas for GHS) |
Iso8601 | string — ISO 8601 timestamp |
CurrencyCode | string — ISO 4217 code, e.g. "GHS", "USD" |
Money | { amount: Cents; currency: CurrencyCode } |
CustomerRef | { id?, email, name?, phone? } |
OrderRef | { id, code?, channelToken?, appId? } |
OrderStatus | "pending" | "paid" | "fulfilled" | "cancelled" | "refunded" | "expired" |
Subscription | { id?, appId, customerEmail, tier?, status, expiresAt? } |
ApiResult<T> | { success, data?, error?: { code?, message } } |
When to use it
- In your storefront / app when you need to type a Sellub order, payment result or subscription returned by the SDK or your own webhook handler.
- In server code to model the same shapes you store in your DB so the edges (UI, webhooks, your DB) line up.
Example: typing a webhook handler
import type { WebhookEvent } from "@duabalabs/sellub-types";
import { isWebhookEvent } from "@duabalabs/sellub-types";
export async function POST(req: Request) {
const raw = await req.text();
// Verify the Sellub-Signature header first — see
// https://docs.duabaforge.com/sellub/developers/commerce-api#verification-node
const event = JSON.parse(raw) as WebhookEvent;
if (isWebhookEvent(event, "order.placed")) {
// event.data is typed for order.placed
}
return Response.json({ ok: true });
}What’s new in 0.3.0
StockMovement,StockMovementType- Four inventory events on
WebhookEvent:inventory.updated,inventory.low_stock,inventory.out_of_stock,stock.movement
Added in 0.2.x
PaymentRef,PaymentMethod,PaymentStatePlanVariant(andSubscription.variant)PriceQuoteInventoryItem,FulfillmentLine,FulfillmentGroup,FulfillmentStateWebhookEventdiscriminated union +isWebhookEventpredicate- Sub-path exports:
@duabalabs/sellub-types/{primitives,money,customer,payment,subscription,inventory,webhook,api}
Roadmap
Planned additions:
TaxLine,RefundRefShippingQuote,AddressPrintProductMetadata,ServiceBooking
Open an issue if you need any of these sooner.
Related
sellub-client— the runtime client whose return types reference these.sellub-pricing— re-usesCents/Moneyfor its fee calculator.
Last updated on