Package Exports
- @relipay/shared-types
Readme
@relipay/shared-types
The Zod schemas + TypeScript types shared between the ReliPay API and its SDKs. Anything serialized over the wire lives here, so there's a single source of truth for every shape.
npm i @relipay/shared-types
# or: pnpm add @relipay/shared-types / yarn add @relipay/shared-typesWhen you need this
Most consumers don't install this directly — the types you'll use day-to-day are re-exported from @relipay/node, so import { PlanDto, RelipayError } from '@relipay/node' already works.
Reach for @relipay/shared-types when you want the runtime Zod schemas (not just the static types) — e.g. to validate a payload you received out-of-band, or to share validation between your own backend and a worker without pulling in the full server SDK. It has zero deps beyond zod.
Setup
No keys, no client, no env vars. Pure types + schemas — import and use.
import {
RelipayError,
PlanDtoSchema,
type PlanDto,
type AuthResultDto,
} from '@relipay/shared-types';
// Static type:
function priceLabel(plan: PlanDto): string {
return `${(plan.amount / 100).toFixed(2)} ${plan.currency}`; // amount is integer cents
}
// Runtime validation (the schema, not just the type):
const plan = PlanDtoSchema.parse(await res.json());What's inside
Each DTO ships as both a Zod schema (…Schema) and an inferred type. Highlights:
| Area | Types |
|---|---|
| Errors | RelipayError (class), RelipayErrorShape, ApiResponseSchema (the { success, data } | { success, error } envelope) |
| Application config | ApplicationDto, AuthConfig, BillingConfig, BillingProvider, AccessConfig |
| Auth | SignUpRequest, SignInRequest, AuthResultDto, SignInOutcomeDto, MfaChallengeResultDto, MfaVerifyRequest, ForgotPasswordRequest, ResetPasswordRequest, EndUserDto, ApiKeyDto |
| Billing | PlanDto, PlanKindType (SUBSCRIPTION / LICENSE / USAGE / CREDIT), SubscriptionDto, CreateCheckoutRequest, CheckoutResultDto, ProvidersListDto |
| Coupons | CouponDto, ValidateCouponRequest, ValidateCouponResultDto |
| Credits | CreditBalanceDto, CreditLedgerEntryDto, ConsumeCreditsRequest, ConsumeCreditsResultDto, GrantCreditsRequest |
| Organizations | OrganizationDto, OrganizationWithRoleDto, OrganizationMemberDto, OrganizationInvitationDto, OrganizationRole |
| Licenses | LicenseDto, LicenseKindType, LicenseVerifyResultDto |
| Usage | UsageRecordDto, UsageAggregateDto |
| MCP / OAuth | OAuthIntrospectionResponse, OAuthAuthServerMetadata, SecurityEventDto |
Gotchas
RelipayErroris the canonical class.@relipay/nodeand@relipay/reactre-export this same class, soinstanceof RelipayErroris consistent across packages.- Money is integer-only, in the smallest currency unit (cents/paise/sen).
PlanDto.amount,CheckoutResultDto.discountAmount, etc. are never floats. - Coupon
amountOff: PERCENT is basis-points × 10 (1500= 15%); AMOUNT is the smallest currency unit. - Discriminated unions: branch on the discriminator before reading fields —
SignInOutcomeDtoonmfaRequired,LicenseVerifyResultDtoonok.
Links
- Docs: /docs · SDK guide · API reference · agent prompt
- Server SDK that re-exports these:
@relipay/node
License
MIT