@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 { ApiResult, OrderRef } from "@duabalabs/sellub-types";
import { verifySignature } from "@duabalabs/sellub-webhooks";
export async function POST(req: Request) {
const raw = await req.text();
const sig = req.headers.get("x-sellub-signature") ?? "";
if (!verifySignature({ secret: process.env.SELLUB_WEBHOOK_SECRET!, payload: raw, signature: sig })) {
return new Response("invalid signature", { status: 401 });
}
const event = JSON.parse(raw) as { type: string; order: OrderRef };
// …
return Response.json({ success: true } satisfies ApiResult<unknown>);
}What’s new 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
Targeted additions for 0.3.x:
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.