Skip to Content
SellubSDKssellub-types

@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.

npm

Install

pnpm add -D @duabalabs/sellub-types

What’s exported

import type { Cents, Iso8601, CurrencyCode, Money, CustomerRef, OrderRef, OrderStatus, Subscription, ApiResult, } from "@duabalabs/sellub-types";
TypeShape
Centsnumber — minor currency units (e.g. pesewas for GHS)
Iso8601string — ISO 8601 timestamp
CurrencyCodestring — 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, PaymentState
  • PlanVariant (and Subscription.variant)
  • PriceQuote
  • InventoryItem, FulfillmentLine, FulfillmentGroup, FulfillmentState
  • WebhookEvent discriminated union + isWebhookEvent predicate
  • Sub-path exports: @duabalabs/sellub-types/{primitives,money,customer,payment,subscription,inventory,webhook,api}

Roadmap

Planned additions:

  • TaxLine, RefundRef
  • ShippingQuote, Address
  • PrintProductMetadata, ServiceBooking

Open an issue if you need any of these sooner.

  • sellub-client — the runtime client whose return types reference these.
  • sellub-pricing — re-uses Cents / Money for its fee calculator.
Last updated on