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 { 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, 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

Targeted additions for 0.3.x:

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