/** * TypeScript type definitions for IOTA SDK Applet Core * Matches Go backend types from pkg/applet/types.go */ interface InitialContext { user: UserContext; tenant: TenantContext; locale: LocaleContext; config: AppConfig; route: RouteContext; session: SessionContext; error: ErrorContext | null; extensions?: Record; } interface UserContext { id: number; email: string; firstName: string; lastName: string; permissions: string[]; } interface TenantContext { id: string; name: string; } interface LocaleContext { language: string; translations: Record; } interface AppConfig { graphQLEndpoint?: string; streamEndpoint?: string; restEndpoint?: string; basePath?: string; assetsBasePath?: string; rpcUIEndpoint?: string; shellMode?: 'embedded' | 'standalone'; } interface RouteContext { path: string; params: Record; query: Record; } interface SessionContext { expiresAt: number; refreshURL: string; csrfToken: string; } interface ErrorContext { supportEmail?: string; debugMode: boolean; errorCodes?: Record; retryConfig?: RetryConfig; } interface RetryConfig { maxAttempts: number; backoffMs: number; } /** * Hook return types */ interface TranslationHook { t: (key: string, params?: Record) => string; language: string; } interface PermissionsHook { hasPermission: (permission: string) => boolean; hasAnyPermission: (...permissions: string[]) => boolean; permissions: string[]; } interface SessionHook { isExpiringSoon: boolean; refreshSession: () => Promise; csrfToken: string; expiresAt: number; } interface StreamingHook { isStreaming: boolean; processStream: (generator: AsyncGenerator, onChunk: (chunk: T) => void, signal?: AbortSignal) => Promise; cancel: () => void; reset: () => void; } export type { AppConfig as A, InitialContext as I, LocaleContext as L, PermissionsHook as P, RouteContext as R, SessionContext as S, TenantContext as T, UserContext as U, SessionHook as a, StreamingHook as b, TranslationHook as c };