@strimz/shared-types
v0.1.1
Published
Zod schemas and inferred TypeScript types for every Strimz platform entity, API input, and webhook event.
Downloads
272
Readme
@strimz/shared-types
Zod schemas and inferred TypeScript types for every Strimz entity, API input, and webhook event.
The Zod schema is the source of truth. TypeScript types are inferred
through z.infer<>, so the wire format and the compile-time shape
can never drift apart. The Strimz SDK consumes this package
internally, but you can use the schemas and types directly if you
prefer to validate the wire format in your own code.
Install
pnpm add @strimz/shared-types
# npm install @strimz/shared-types
# yarn add @strimz/shared-typesQuick start
import {
createPaymentSessionInputSchema,
type CreatePaymentSessionInput,
} from '@strimz/shared-types'
const parsed: CreatePaymentSessionInput = createPaymentSessionInputSchema.parse(req.body)Exhaustive webhook handling
import { webhookEventSchema, type StrimzWebhookEvent } from '@strimz/shared-types/events'
function handle(event: StrimzWebhookEvent) {
switch (event.type) {
case 'payment.completed':
// event.data is typed as { session, transaction }
break
case 'subscription.charge_failed':
// event.data is typed as { subscription, charge }
break
// TypeScript enforces exhaustiveness over the discriminated union.
}
}Modules
Every group is also available as a subpath import for tree-shaking.
| Subpath | Contains |
| ------------------- | ------------------------------------------------------------------------------------------------------- |
| /common | Primitives: ids, EVM address, tx hash, email, URL, money, pagination, metadata, mode, tier, environment |
| /merchants | Merchant entity, login, member invites, tier changes |
| /api-keys | Secret and publishable keys, scopes, rotation |
| /customers | Payer identity |
| /payment-sessions | One-shot session entity, state machine, createPaymentSessionInputSchema |
| /transactions | Confirmed on-chain payment records |
| /subscriptions | Plans, active subscriptions, per-period charges (with chargeAttemptId) |
| /refunds | Merchant-initiated refund entity + signature flow |
| /webhooks | Endpoints, deliveries, replay |
| /compliance | Sanctions screening log |
| /agents | Identity, merchant config, activity log, ERC-8183 jobs |
| /storefronts | Storefront + product |
| /invoices | Invoice + line items |
| /events | Discriminated StrimzWebhookEvent union covering every webhook payload shape |
The package root re-exports every subpath.
Runtime support
Pure TypeScript with zod as the only runtime dependency. Works in
Node 22+, every modern browser, Vercel Edge, Cloudflare Workers,
Deno, and Bun.
Design notes
- Schemas describe wire format. No business logic, no persistence, no side effects.
- Amounts are decimal strings of the token's smallest unit (USDC has 6 decimals, so
"1000000"is 1 USDC). This preserves precision beyondNumber.MAX_SAFE_INTEGER. - EVM addresses are normalised to lowercase on parse. Transaction hashes are preserved verbatim.
- Optional vs nullable is a real distinction. Fields marked
.optional()accept omission. Fields marked.nullable()accept explicitnull. The two are not interchangeable on the wire.
Links
License
MIT © Strimz