@tesser-payments/types
v0.0.2
Published
Shared TypeScript types and Zod schemas for the Tesser Payments platform
Downloads
93
Maintainers
Readme
@tesser-payments/types
Shared TypeScript types and Zod schemas for the Tesser Payments platform. This package provides a single source of truth for type definitions used across both backend and frontend applications.
📁 Structure
The package is organized by domain:
src/
├── common/ # Shared utilities and types
│ ├── currency.ts
│ ├── validations.ts
│ ├── pagination.ts
│ └── api-response.ts
├── payments/ # Payment-related types
│ ├── payment.types.ts
│ └── payment.schemas.ts
├── entities/ # Entity management types
│ ├── entity.types.ts
│ └── entity.schemas.ts
├── wallets/ # Wallet and account types
│ ├── wallet.types.ts
│ └── wallet.schemas.ts
├── accounts/ # Fiat account types
│ ├── account.types.ts
│ └── account.schemas.ts
├── ramps/ # Onramp/Offramp types
│ ├── ramp.types.ts
│ └── ramp.schemas.ts
├── apps/ # App management types
│ ├── app.types.ts
│ └── app.schemas.ts
├── organizations/ # Organization types
│ ├── organization.types.ts
│ └── organization.schemas.ts
├── users/ # User management types
│ ├── user.types.ts
│ └── user.schemas.ts
└── webhooks/ # Webhook types
├── webhook.types.ts
└── webhook.schemas.ts🚀 Usage
Frontend Usage (Type Imports Only)
Import TypeScript types for type-checking:
import type { PaymentDto, PaymentStatus } from "@tesser-payments/types/payments";
import type { PaginationInfo } from "@tesser-payments/types/common";Frontend Usage (With Validation)
Import Zod schemas for runtime validation:
import {
sendPaymentIntentRequestSchema,
type SendPaymentIntentDto,
} from "@tesser-payments/types/payments";
// Use schema for validation
const result = sendPaymentIntentRequestSchema.safeParse(data);
if (result.success) {
// data is valid
}Backend Usage (NestJS DTOs)
Import schemas and create NestJS DTOs:
import { sendPaymentIntentRequestSchema } from "@tesser-payments/types/payments";
import { createZodDto } from "nestjs-zod";
export class SendPaymentIntentRequestDto extends createZodDto(
sendPaymentIntentRequestSchema
) {}📦 Available Domains
Common (@tesser-payments/types/common)
- Currency utilities (
SupportedCurrency, conversion functions) - Payment limits
- Validation utilities (
isIBAN,validateEmail, etc.) - Pagination types (
PaginationInfo,PaginatedResponse) - API response wrappers (
ApiResponse,ApiSuccessResponse)
Payments (@tesser-payments/types/payments)
PaymentDto- Full payment objectPaymentStatus- Payment status enumSendPaymentIntentDto- Payment intent requestSendPaymentDto- Send payment request- Related schemas
Entities (@tesser-payments/types/entities)
EntityDto- Entity detailsEntityType- Entity type enumCreateEntityDto- Create requestUpdateEntityDto- Update request- Related schemas
Wallets (@tesser-payments/types/wallets)
WalletDto- Wallet detailsWalletQueryDto- Query parameters- Related schemas
Accounts (@tesser-payments/types/accounts)
FiatAccountDto- Fiat account detailsAccountType- Account type enum ("PIX" | "SPEI" | "COELSA")createFiatAccountRequestSchema- Base schema for fiat account creation (KYB endpoint)createFiatAccountWithEntitySchema- Extended schema with entityId (Entities endpoint)CreateFiatAccountRequest- Inferred type from base schemaCreateFiatAccountWithEntity- Inferred type from extended schema
See Schema Guidelines below for usage details.
Ramps (@tesser-payments/types/ramps)
- Onramp/Offramp transaction types
- Quote request types
- Alfred-specific types
- Status enums
- Related schemas
Apps (@tesser-payments/types/apps)
AppDto- App detailsCreateAppDto- Create request- Related schemas
Organizations (@tesser-payments/types/organizations)
RiskProfileDto- Risk profile detailsUpdateRiskProfileDto- Update request- Related schemas
Users (@tesser-payments/types/users)
UserProfileDto- User profileSignupRequest/SignupResponse- Signup flowOrgUserDto- Organization user- Related schemas
Webhooks (@tesser-payments/types/webhooks)
WebhookPaymentDto- Webhook payloadWebhookEventType- Event type enumWebhookEvent- Event structure- Related schemas
🎯 Design Principles
- Single Source of Truth: All types defined once, used everywhere
- Domain Organization: Types grouped by business domain for easy navigation
- Dual Exports: Both TypeScript types and Zod schemas available
- Framework Agnostic: Core types don't depend on NestJS or React
- Tree Shakeable: Import only what you need
- Schema Consistency: Shared base schemas prevent validation mismatches
📋 Schema Guidelines
Fiat Account Creation
Two endpoint-specific schemas are provided, both extending a unified base:
// For KYB endpoint (POST /kyb/fiat-accounts)
import { createFiatAccountRequestSchema } from "@tesser-payments/types/accounts";
// For Entities endpoint (POST /entities/fiat-accounts)
import { createFiatAccountWithEntitySchema } from "@tesser-payments/types/accounts";Key differences:
createFiatAccountRequestSchema: Standard fiat account creationcreateFiatAccountWithEntitySchema: Includes optionalentityIdfield for linking to entities
Common validation rules:
provider: Must be "ALFRED"country: 2-character country codeaccountType: "PIX" | "SPEI" | "COELSA"accountNumber: Required, min 1 characteraccountDetails: Structured object withaccountTypeandfinancialInstitutionIDisExternal: Optional boolean, defaults to falseexternalId: Optional string for client-provided identifiers
🔄 Type Safety Guarantees
- Backend DTOs use the same schemas as frontend validation
- API contracts automatically propagate to both sides
- Validation rules stay in sync
- Compile-time errors catch mismatches
🛠️ Development
Building
cd packages/types
bun run buildThis compiles src/ to dist/ with TypeScript declarations and generates a publish-ready dist/package.json. Local development does not require building — Bun resolves the src/*.ts exports directly in the workspace.
Publishing to npm
The version is managed in packages/types/package.json (source of truth). Publishing is done via the Publish @tesser-payments/types GitHub Action (workflow_dispatch):
- Bump the
versioninpackages/types/package.jsonin a PR and merge tomain - Go to Actions → Publish @tesser-payments/types → Run workflow
- Optionally set the npm dist-tag (default:
latest) and whether to dry-run - The action reads the version from
package.json, checks that it hasn't already been published, builds, publishes to npm, and creates atypes-v{version}git tag and GitHub release
The workflow will fail if the version in package.json is already published to npm — you must bump the version first.
Prerequisites:
NPM_TOKENrepository secret must be configured in GitHub Settings → Secrets → Actions@tesser-paymentsnpm org must exist with publish access
To preview locally what would be published:
cd packages/types
bun run build
cd dist
npm pack --dry-runAdding New Types
- Choose the appropriate domain directory (or create a new one)
- Create
*.types.tsfor TypeScript interfaces - Create
*.schemas.tsfor Zod schemas and inferred types - Export from domain's
index.ts - Update root
src/index.tsif needed
Pattern to Follow
// my-domain/my-domain.types.ts
export interface MyDto {
id: string;
name: string;
}
// my-domain/my-domain.schemas.ts
import { z } from "zod";
export const mySchema = z.object({
name: z.string().min(1),
});
export type MyCreateDto = z.infer<typeof mySchema>;
// my-domain/index.ts
export * from "./my-domain.types";
export * from "./my-domain.schemas";📝 Migration Notes
This package was reorganized from a flat structure to domain-based organization. Legacy imports from the root still work but are deprecated:
// ❌ Deprecated (still works)
import { SupportedCurrency } from "@tesser-payments/types";
// ✅ Preferred
import type { SupportedCurrency } from "@tesser-payments/types/common";🤝 Contributing
When adding or modifying types:
- Ensure types match backend DTOs exactly
- Include JSDoc comments for complex types
- Export both schemas and inferred types
- Update this README if adding new domains
- Run type checks before committing
📚 Related Packages
@tesser-payments/sdk- SDK using these types- Backend (
apps/backend) - NestJS backend consuming types - Frontend (
apps/frontend) - Next.js frontend consuming types
