Skip to content

createStatusNormalizer

createStatusNormalizer<Known>(map): (raw) => NormalizedStatusResult

Defined in: packages/core/src/order-status.ts:49

Build a status normalizer from an SDK-owned, exhaustive map of that marketplace’s known statuses. Because the map key type is a closed union, forgetting to map a newly added known status is a compile-time error in the SDK — while an unknown value arriving on the wire stays safe at runtime ({ normalized: 'unknown', mapped: false }).

Known extends string

Record<Known, NormalizedOrderStatus>

(raw) => NormalizedStatusResult

const statusMap = { Created: 'created', Shipped: 'shipped' } as const;
const normalizeStatus = createStatusNormalizer(statusMap);
normalizeStatus('Shipped'); // { normalized: 'shipped', raw: 'Shipped', mapped: true }
normalizeStatus('Martian'); // { normalized: 'unknown', raw: 'Martian', mapped: false }

Unofficial. Lonca is an independent, community-maintained project — not affiliated with, endorsed by, or supported by Trendyol, Hepsiburada, or any other marketplace. All marketplace names and trademarks belong to their respective owners.