@circles-market/sales
v0.1.0
Published
Seller-scoped read-only endpoints for the Market API (requires a valid seller session token in `AuthContext`).
Readme
@circles-market/sales
Seller-scoped read-only endpoints for the Market API (requires a valid seller session token in AuthContext).
Install
pnpm add @circles-market/sales @circles-market/core @circles-market/sessionQuickstart (list seller orders)
import { FetchHttpTransport } from "@circles-market/core";
import { InMemoryAuthContext } from "@circles-market/session";
import { SalesClient } from "@circles-market/sales";
async function listSellerOrders(marketApiBase: string) {
const http = new FetchHttpTransport();
const session = new InMemoryAuthContext();
const sales = new SalesClient(marketApiBase, http, session);
return await sales.list({ page: 1, pageSize: 20 });
}Quickstart (get one by id)
import { SalesClient, isOrderId } from "@circles-market/sales";
async function getOrder(sales: SalesClient, id: string) {
if (!isOrderId(id)) return null;
const order = await sales.get(id);
return order; // `null` when not found (404)
}Reference
Concepts
- Seller-only view over orders created by buyers.
- Requires a valid JWT in
AuthContextbelonging to the seller avatar (address lowercased) and the rightchainId. - Pagination uses
page+pageSizequery params.
API and return values
list({ page?, pageSize? })→SellerOrdersPageitems: array ofSellerOrderDto
get(orderId)→SellerOrderDto | null(returnsnullon 404)
Types
SellerOrderDto
Minimal schema (selected fields):
@context: "https://schema.org/"@type: "Order"orderNumber: stringorderStatus: IRI stringorderDate: ISO date/time stringpaymentReference: string | nullbroker: opaque backend objectacceptedOffer:any[](filtered to this seller)orderedItem:any[](filtered to this seller)totalPaymentDue:any | nulloutbox?:any[][k: string]: unknownfor forward compatibility
SellerOrdersPage
Fields:
items:SellerOrderDto[]
OrderId and isOrderId(s)
OrderId: branded string typeisOrderId(s: string)→ boolean (expectsord_+ 32 uppercase hex chars)
Runtime notes
- Requires global
fetch(Node 18+ is fine).
Related packages
@circles-market/auth+@circles-market/sessionto obtain and store the seller JWT@circles-market/ordersfor buyer-scoped order views@circles-market/sdkif you want a single client wiring auth/catalog/cart/orders (and optionally offers)
