Tools
TypeScript SDK
End-to-end types, cursor helpers and error handling without ceremony.
Install
The SDK targets Node.js 24+ and modern edge runtimes. It has no runtime dependencies.
bash
pnpm add @viraj/sdkResources
Every resource is available as a property on the client. Methods return parsed, typed values and throw a VirajError on failure.
ts
import { Viraj, VirajError } from '@viraj/sdk'
const viraj = new Viraj({ apiKey: process.env.VIRAJ_API_KEY })
try {
const order = await viraj.orders.create({
locationId: 'loc_sfo_02',
customerId: 'cus_118',
lines: [{ sku: 'HW-COF-001', quantity: 2 }],
})
console.log(order.id)
} catch (error) {
if (error instanceof VirajError && error.code === 'validation_failed') {
console.warn(error.field, error.message)
}
}Auto-pagination
Use .autoPaging() to iterate all pages lazily. Prefer it to manual cursor loops in background jobs.
ts
for await (const product of viraj.products.list({ limit: 100 }).autoPaging()) {
await index(product)
}Webhook helper
The SDK ships the same constant-time verifier used by the platform, so you do not have to hand-roll HMAC comparison.
ts
import { verifyWebhookSignature } from '@viraj/sdk/webhooks'
const valid = verifyWebhookSignature({
rawBody,
signature: request.headers.get('viraj-signature') ?? '',
secret: process.env.VIRAJ_WEBHOOK_SECRET ?? '',
})