UNPKG

spaps-types

Version:

Shared TypeScript types for SPAPS ecosystem

387 lines 10.5 kB
/** * @spaps/types - Shared TypeScript types for SPAPS ecosystem * Single source of truth for types across server and SDK */ export interface Application { id: string; name: string; slug: string; api_key: string; description?: string; webhook_url?: string; allowed_origins?: string[]; settings: { supported_chains: string[]; pii_enabled?: boolean; rate_limit?: { window_ms: number; max_requests: number; }; }; created_at: string; } export interface UserProfile { id: string; stripe_customer_id?: string; default_payment_method?: string; username?: string; email?: string; phone_number?: string; tier?: string; metadata: Record<string, any>; created_at: string; } export interface User { id: string; email?: string; wallet_address?: string; chain_type?: string; role: string; tier?: string; created_at?: string; } export interface UserWallet { id: string; user_id: string; wallet_address: string; chain_type: 'solana' | 'ethereum' | 'bitcoin' | 'base' | 'bitcoin-lightning'; verified: boolean; metadata?: Record<string, any>; created_at: string; updated_at: string; } export interface ApiResponse<T = any> { success: boolean; data?: T; error?: { code: string; message: string; details?: any; }; metadata?: { timestamp: string; request_id: string; }; } export interface TokenPayload { sub: string; app_id: string; wallets: string[]; tier: string; iat: number; exp: number; jti: string; iss: string; aud: string; email?: string; roles?: string[]; permissions?: string[]; isAdmin?: boolean; isSuperAdmin?: boolean; } export interface RefreshTokenPayload { sub: string; app_id: string; token_family: string; iat: number; exp: number; jti: string; iss: string; aud: string; email?: string; roles?: string[]; isAdmin?: boolean; } export interface TokenPair { access_token: string; refresh_token: string; expires_in: number; token_type: 'Bearer'; } export interface AuthResponse { access_token: string; refresh_token: string; user: User; expires_in?: number; token_type?: 'Bearer'; } export interface CheckoutSession { sessionId: string; url: string; success_url?: string; cancel_url?: string; customer_email?: string; metadata?: Record<string, any>; } export interface Subscription { id: string; status: string; plan: string; current_period_end: string; customer_id?: string; price_id?: string; quantity?: number; metadata?: Record<string, any>; } export interface Product { id: string; name: string; description?: string; category: string; active: boolean; images?: string[]; metadata?: Record<string, string>; statement_descriptor?: string; unit_label?: string; created?: number; updated?: number; } export interface Price { id: string; product: string; unit_amount: number; currency: string; recurring?: { interval: 'day' | 'week' | 'month' | 'year'; interval_count: number; }; nickname?: string; active: boolean; metadata?: Record<string, any>; } export interface UsageBalance { balance: number; currency: string; updated_at: string; user_id?: string; } export interface SecureMessage<Metadata extends Record<string, any> = Record<string, any>> { id: string; application_id: string; patient_id: string; practitioner_id: string; content: string; metadata: Metadata; created_at: string; } export interface CreateSecureMessageRequest<Metadata extends Record<string, any> = Record<string, any>> { patientId: string; practitionerId: string; content: string; metadata?: Metadata; } export type CryptoAsset = 'USDC' | 'BTC'; export type CryptoNetwork = 'solana' | 'ethereum' | 'bitcoin' | 'base' | 'bitcoin-lightning'; export type CryptoInvoiceStatus = 'pending' | 'settled' | 'expired' | 'cancelled'; export interface CryptoInvoiceDestination { type: 'address' | 'invoice'; address?: string; invoice?: string; network: CryptoNetwork; asset: CryptoAsset; } export interface CryptoInvoiceBeneficiary { user_id?: string; email?: string; [key: string]: any; } export interface CreateCryptoInvoiceRequest { asset: CryptoAsset; network: CryptoNetwork; amount: string; expiresInSeconds?: number; beneficiary?: CryptoInvoiceBeneficiary; metadata?: Record<string, any>; } export interface CryptoInvoice { id: string; asset: CryptoAsset; network: CryptoNetwork; amount: string; status: CryptoInvoiceStatus; expires_at: string; underpaid: boolean; overpaid: boolean; beneficiary?: CryptoInvoiceBeneficiary; metadata?: Record<string, any>; destination: CryptoInvoiceDestination; created_at: string; updated_at?: string; settled_at?: string; settlement?: Record<string, any>; } export interface CryptoInvoiceResponse { invoice: CryptoInvoice; } export interface CryptoInvoiceStatusSnapshot { id: string; status: CryptoInvoiceStatus; asset: CryptoAsset; network: CryptoNetwork; expires_at: string; underpaid: boolean; overpaid: boolean; } export interface CryptoReconcileRequest { cursor?: Record<string, any>; reconToken?: string; } export interface VerifyCryptoWebhookSignatureOptions { body: string | Uint8Array | Record<string, any>; signature: string | null | undefined; secret: string; toleranceSeconds?: number; } export interface CreateProductRequest { name: string; description?: string; category: string; images?: string[]; metadata?: Record<string, string>; active?: boolean; statement_descriptor?: string; unit_label?: string; } export interface UpdateProductRequest { name?: string; description?: string; category?: string; images?: string[]; metadata?: Record<string, string>; active?: boolean; statement_descriptor?: string; unit_label?: string; } export interface CreatePriceRequest { product_id: string; unit_amount: number; currency: string; interval?: 'day' | 'week' | 'month' | 'year'; interval_count?: number; nickname?: string; metadata?: Record<string, any>; } export interface ProductSyncResult { synced_count: number; updated_count: number; created_count: number; errors: any[]; sync_time: string; } export interface AdminUser { id: string; email?: string; wallet_address?: string; roles?: string[]; permissions?: string[]; isAdmin?: boolean; isSuperAdmin?: boolean; created_at?: string; updated_at?: string; } export interface AdminAction { adminUserId: string; adminEmail: string; action: string; resourceType: string; resourceId: string; resourceData?: Record<string, any>; ipAddress?: string; userAgent?: string; applicationId?: string; severity?: AuditSeverity; timestamp?: string; } export interface SecurityAlert { id?: string; alert_type: string; user_id: string; elevated_by?: string; severity: AlertSeverity; details: Record<string, any>; timestamp: string; resolved?: boolean; created_at?: string; } export interface SessionData { user_id: string; application_id: string; wallets: UserWallet[]; tier: string; created_at: Date; last_activity: Date; user_agent?: string; ip_address?: string; email?: string; user_profile?: UserProfile; } export interface BlacklistedToken { jti: string; user_id: string; expires_at: Date; blacklisted_at: Date; reason: 'logout' | 'refresh' | 'security' | 'admin'; } export interface TokenValidationResult { valid: boolean; payload?: TokenPayload; error?: string; expired?: boolean; } export interface RefreshTokenValidationResult { valid: boolean; payload?: RefreshTokenPayload; error?: string; expired?: boolean; } export interface ApiKeyValidationResult { valid: boolean; application?: Application; error?: string; } export type AdminRole = 'admin' | 'super_admin' | 'security_admin' | 'billing_admin'; export type UserRole = 'user' | AdminRole; export type AdminPermission = 'view_products' | 'create_orders' | 'access_premium_features' | 'manage_products' | 'access_admin' | 'view_analytics' | 'manage_subscriptions' | 'access_audit_logs' | 'manage_users' | 'system_settings'; export type AuditSeverity = 'INFO' | 'WARN' | 'HIGH' | 'ERROR' | 'CRITICAL'; export type AlertSeverity = 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL'; export type ChainType = 'solana' | 'ethereum' | 'bitcoin' | 'base'; export type PaymentInterval = 'day' | 'week' | 'month' | 'year'; export interface RateLimitConfig { window_ms: number; max_requests: number; skip_failed_requests?: boolean; skip_successful_requests?: boolean; } export interface LocalModeConfig { environment: string; isDocker: boolean; defaultUser: 'user' | 'admin' | 'premium'; features: { autoAuth: boolean; corsEnabled: boolean; verboseLogging: boolean; }; } export interface TestUser { id: string; email: string; role: string; tier: string; created_at: string; } export declare function isAdminRole(role: string): role is AdminRole; export declare function isValidPermission(permission: string): permission is AdminPermission; export declare function isValidSeverity(severity: string): severity is AuditSeverity; export declare function isValidAlertSeverity(severity: string): severity is AlertSeverity; export declare function isValidChainType(chain: string): chain is ChainType; export { createSecureMessageRequestSchema, secureMessageSchema, secureMessageMetadataSchema, type CreateSecureMessageInput, type SecureMessageOutput } from './schemas/secureMessages'; export type JWTPayload = TokenPayload; export type DecodedToken = { payload: TokenPayload; header: { alg: string; typ: string; }; }; export type { DocsManifest, DocsManifestEndpoint, DocsManifestEndpointSDKRef, DocsManifestMetadata, DocsManifestBaseUrls, DocsManifestPackage, } from './docs'; //# sourceMappingURL=index.d.ts.map