spaps-types
v1.0.58
Published
Shared TypeScript types for SPAPS ecosystem
Maintainers
Readme
spaps-types
Shared TypeScript type definitions for the Sweet Potato Authentication & Payment Service (SPAPS) ecosystem.
Overview
This package provides a single source of truth for all TypeScript types used across the SPAPS server and SDK. It ensures type consistency and prevents drift between different parts of the system.
Installation
npm install spaps-typesUsage
import type {
User,
UserProfile,
ApiResponse,
TokenPair,
CheckoutSession,
Product,
Price
} from 'spaps-types';
// Use the types in your code
const user: User = {
id: '123',
email: '[email protected]',
role: 'user'
};
const response: ApiResponse<User> = {
success: true,
data: user
};Available Types
Core Domain Models
Application- Client application configurationUser- Basic user informationUserProfile- Extended user profileUserWallet- Multi-wallet associations
Authentication & Session
TokenPayload- JWT token payloadRefreshTokenPayload- Refresh token payloadTokenPair- Access/refresh token pairAuthResponse- Authentication responseSessionData- Session information
Payments & Subscriptions
Product- Stripe productPrice- Stripe priceCheckoutSession- Stripe checkout sessionSubscription- Active subscriptionUsageBalance- Usage-based balance
API Types
ApiResponse<T>- Standard API response wrapperApiKeyValidationResult- API key validation resultTokenValidationResult- Token validation result
Admin Types
AdminUser- Admin user informationAdminAction- Audit log entrySecurityAlert- Security alertAdminRole- Admin role typesAdminPermission- Permission types
Request/Response DTOs
CreateProductRequest- Create product payloadUpdateProductRequest- Update product payloadCreatePriceRequest- Create price payloadProductSyncResult- Product sync result
Type Guards
The package includes runtime type guards for validation:
import { isAdminRole, isValidPermission } from 'spaps-types';
if (isAdminRole(user.role)) {
// User is an admin
}
if (isValidPermission(permission)) {
// Permission is valid
}Development
# Build the types
npm run build
# Run type tests
npm run test:types
# Type check
npm run typecheckLicense
MIT
