import { Component, ReactNode, ErrorInfo, JSX } from 'react'; import { StyleProp, ViewStyle, TextStyle } from 'react-native'; import { AdapterDomain, AdapterStatusInfo, DomainAdapterConfig, AdapterStatusType, AdminAdapter, AiAdapter, AuthAdapter, DbAdapter, FileStorageAdapter, LoggerAdapter, PaymentsAdapter, AdapterError } from '@geenius/adapters'; /** * @module ErrorBoundaryBridge * @package @geenius/adapters/react-native * @description Native error boundary bridge for adapter-driven UI surfaces. */ /** * Props for the native adapter error boundary bridge. * * @property children React subtree protected by the error boundary. * @property fallback Optional custom fallback node or render callback. * @property onError Optional callback invoked with the thrown error and info. * @property style Optional native style merged onto the default fallback. * @property testID Optional deterministic selector for tests and Storybook. */ interface ErrorBoundaryBridgeProps { children: ReactNode; fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode); onError?: (error: Error, info: ErrorInfo) => void; style?: StyleProp; testID?: string; } /** Internal state tracked by {@link ErrorBoundaryBridge}. */ interface ErrorBoundaryBridgeState { error: Error | null; } /** * Catches render errors inside native adapter surfaces. * * @param props Error boundary props including children and optional fallback. * @returns The child subtree, custom fallback, or default native error panel. * @example * ```tsx * logger.error(error.message)}> * * * ``` */ declare class ErrorBoundaryBridge extends Component { state: ErrorBoundaryBridgeState; static getDerivedStateFromError(error: Error): ErrorBoundaryBridgeState; componentDidCatch(error: Error, info: ErrorInfo): void; private readonly reset; render(): ReactNode; } /** * @module LoadingBridge * @package @geenius/adapters/react-native * @description Native loading indicator bridge for async adapter states. */ /** * Props for the native loading bridge. * * @property label Accessible label and visible loading text. * @property size Native activity indicator size. * @property style Optional native style merged onto the bridge container. * @property testID Optional deterministic selector for tests and Storybook. */ interface LoadingBridgeProps { label?: string; size?: "small" | "large"; style?: StyleProp; testID?: string; } /** * Renders a native loading indicator for adapter-driven async states. * * @param props Loading bridge props including label and indicator size. * @returns A React Native progressbar-style loading row. * @example * ```tsx * * ``` */ declare function LoadingBridge({ label, size, style, testID, }: LoadingBridgeProps): JSX.Element; /** * @module ToastBridge * @package @geenius/adapters/react-native * @description Native toast-style notification bridge for adapter telemetry. */ /** * Props for the native toast bridge. * * @property kind Semantic tone used for the toast colors. * @property message Required toast body text. * @property onDismiss Optional callback that renders a dismiss action. * @property style Optional native style merged onto the toast container. * @property testID Optional deterministic selector for tests and Storybook. * @property title Optional title shown before the message. * @property visible Controls whether the toast renders. */ interface ToastBridgeProps { kind?: "error" | "info" | "success" | "warning"; message: string; onDismiss?: () => void; style?: StyleProp; testID?: string; title?: string; visible?: boolean; } /** * Renders a native toast-style adapter notification. * * @param props Toast bridge props including message, tone, and dismiss callback. * @returns A native toast surface, or `null` when `visible` is false. * @example * ```tsx * * ``` */ declare function ToastBridge({ kind, message, onDismiss, style, testID, title, visible, }: ToastBridgeProps): JSX.Element | null; /** * @module AdapterCard * @package @geenius/adapters/react-native * @description Renders a native adapter summary card for one adapter domain. */ /** * Props for a native adapter summary card. * * @property domain Adapter domain represented by the card. * @property onClick Optional compatibility callback invoked when pressed. * @property onPress Native press callback invoked when the card is selected. * @property status Provider health metadata displayed on the card. * @property style Optional native style merged onto the card container. * @property testID Optional deterministic selector for tests and Storybook. */ interface AdapterCardProps { domain: AdapterDomain; onClick?: () => void; onPress?: () => void; status: AdapterStatusInfo; style?: StyleProp; testID?: string; } /** * Renders a pressable native summary for one adapter domain. * * @param props Adapter card props including domain, status, and press handlers. * @returns A React Native card rendered through the package runtime bridge. * @example * ```tsx * open("db")} /> * ``` */ declare function AdapterCard({ domain, status, onClick, onPress, style, testID, }: AdapterCardProps): JSX.Element; /** * @module AdapterConfigForm * @package @geenius/adapters/react-native * @description Renders a native provider selection and credential form for an * adapter domain. */ /** * Props for the native adapter configuration form. * * @property domain Adapter domain being configured. * @property initialConfig Optional provider configuration used to hydrate inputs. * @property onCancel Optional callback fired when the user dismisses the form. * @property onSave Callback receiving the validated provider configuration. * @property style Optional native style merged onto the form container. * @property testID Optional deterministic selector for tests and Storybook. * @property titleId Optional title identifier retained for parity with web forms. */ interface AdapterConfigFormProps { domain: AdapterDomain; initialConfig?: DomainAdapterConfig; onCancel?: () => void; onSave: (config: DomainAdapterConfig) => Promise | void; style?: StyleProp; testID?: string; titleId?: string; } /** * Renders the native provider picker and credential form for one domain. * * @param props Configuration form props including domain and save callback. * @returns A React Native form surface for provider selection. * @example * ```tsx * save(config)} /> * ``` */ declare function AdapterConfigForm({ domain, initialConfig, onSave, onCancel, style, testID, }: AdapterConfigFormProps): JSX.Element; /** * @module AdapterList * @package @geenius/adapters/react-native * @description Renders the searchable native adapter list with FlatList. */ /** * Props for the searchable native adapter list. * * @property filterStatus Optional lifecycle status used to filter domains. * @property onRefresh Optional native pull-to-refresh callback. * @property onSelect Optional callback fired when a domain card is pressed. * @property refreshing Whether the native pull-to-refresh control is active. * @property style Optional native style merged onto the list container. * @property testID Optional deterministic selector for tests and Storybook. */ interface AdapterListProps { filterStatus?: AdapterStatusType; onRefresh?: () => void | Promise; onSelect?: (domain: AdapterDomain) => void; refreshing?: boolean; style?: StyleProp; testID?: string; } /** * Renders a searchable native list of adapter domains. * * @param props List props including optional status filter and select callback. * @returns A React Native list with loading, empty, and filtered states. * @example * ```tsx * open(domain)} /> * ``` */ declare function AdapterList({ onSelect, filterStatus, onRefresh, refreshing, style, testID, }: AdapterListProps): JSX.Element; /** * @module AdapterStatusBadge * @package @geenius/adapters/react-native * @description Renders a compact native status badge for adapter lifecycle * state using View/Text and testID selectors. */ /** * Props for the native adapter status badge. * * @property showLabel Whether to render the text label next to the status dot. * @property size Visual size for the badge. * @property status Adapter lifecycle status to display. * @property style Optional native style merged onto the badge container. * @property textStyle Optional native text style merged onto the label. * @property testID Optional deterministic selector for tests and Storybook. */ interface AdapterStatusBadgeProps { showLabel?: boolean; size?: "sm" | "md"; status: AdapterStatusType; style?: StyleProp; textStyle?: StyleProp; testID?: string; } /** * Renders a compact native badge for an adapter lifecycle status. * * @param props Badge props including status, size, and visibility options. * @returns A native status badge with semantic colors and accessibility label. * @example * ```tsx * * ``` */ declare function AdapterStatusBadge({ status, showLabel, size, style, textStyle, testID, }: AdapterStatusBadgeProps): JSX.Element; /** * @module hooks * @package @geenius/adapters/react-native * @description Defines React hooks for reading adapter instances and status * state from the React Native provider context. */ /** * Reads the configured database adapter from the nearest native provider. * * @returns The DB adapter registered for the `db` domain. * @example * ```tsx * const db = useDb(); * const users = await db.list("users"); * ``` */ declare function useDb(): DbAdapter; /** * Reads the configured auth adapter from the nearest native provider. * * @returns The auth adapter registered for the `auth` domain. * @example * ```tsx * const auth = useAuth(); * const session = await auth.getSession(); * ``` */ declare function useAuth(): AuthAdapter; /** * Alias for {@link useAuth} retained for consumers that prefer explicit names. * * @returns The auth adapter registered for the `auth` domain. * @example * ```tsx * const auth = useAuthAdapter(); * ``` */ declare function useAuthAdapter(): AuthAdapter; /** * Reads the configured payments adapter from the nearest native provider. * * @returns The payments adapter registered for the `payments` domain. * @example * ```tsx * const payments = usePayments(); * const plans = await payments.listPlans(); * ``` */ declare function usePayments(): PaymentsAdapter; /** * Reads the configured AI adapter from the nearest native provider. * * @returns The AI adapter registered for the `ai` domain. * @example * ```tsx * const ai = useAi(); * const answer = await ai.complete({ prompt: "Summarize" }); * ``` */ declare function useAi(): AiAdapter; /** * Reads the configured file storage adapter from the nearest native provider. * * @returns The storage adapter registered for the `storage` domain. * @example * ```tsx * const storage = useFileStorage(); * await storage.upload({ path: "avatars/a.png", data }); * ``` */ declare function useFileStorage(): FileStorageAdapter; /** * Alias for {@link useFileStorage} used by storage-focused screens. * * @returns The storage adapter registered for the `storage` domain. * @example * ```tsx * const storage = useStorage(); * ``` */ declare function useStorage(): FileStorageAdapter; /** * Reads the configured admin adapter from the nearest native provider. * * @returns The admin adapter registered for the `admin` domain. * @example * ```tsx * const admin = useAdmin(); * const roles = await admin.listRoles(); * ``` */ declare function useAdmin(): AdminAdapter; /** * Reads the configured logger adapter from the nearest native provider. * * @returns The logger adapter registered for the `logger` domain. * @example * ```tsx * const logger = useLogger(); * logger.info("native screen mounted"); * ``` */ declare function useLogger(): LoggerAdapter; /** * Reads the status map for every adapter domain. * * @returns A record keyed by adapter domain with provider status metadata. * @example * ```tsx * const statuses = useAdapterStatuses(); * const dbStatus = statuses.db.status; * ``` */ declare function useAdapterStatuses(): Record; /** * Reads the status metadata for a single adapter domain. * * @param domain Adapter domain to inspect. * @returns The status payload for the requested domain. * @example * ```tsx * const status = useAdapterStatus("auth"); * ``` */ declare function useAdapterStatus(domain: AdapterDomain): AdapterStatusInfo; /** * Reports whether a configured adapter is currently connected. * * @param domain Adapter domain to inspect. * @returns `true` when the domain has an adapter and its status is connected. * @example * ```tsx * const canSubmit = useIsAdapterReady("payments"); * ``` */ declare function useIsAdapterReady(domain: AdapterDomain): boolean; /** * Reads the full native adapter bundle and provider status helpers. * * @returns Adapter instances, status records, loading state, and readiness helper. * @example * ```tsx * const { db, statuses, isReady } = useAdapters(); * ``` */ declare function useAdapters(): { admin: AdminAdapter; ai: AiAdapter; auth: AuthAdapter; db: DbAdapter; fileStorage: FileStorageAdapter; isLoading: boolean; isReady: (domain: AdapterDomain) => boolean; logger: LoggerAdapter; payments: PaymentsAdapter; statuses: Record; storage: FileStorageAdapter; }; /** * @module AdapterDetailPage * @package @geenius/adapters/react-native * @description Renders the native single-domain adapter detail view. */ /** * Props for the native single-domain adapter detail page. * * @property domain Adapter domain shown by the detail page. * @property onBack Optional callback used to render and handle the back action. * @property onConfigure Optional callback invoked with submitted adapter configuration. * @property style Optional native style merged onto the page container. * @property testID Optional deterministic selector for tests and Storybook. */ interface AdapterDetailPageProps { domain: AdapterDomain; onBack?: () => void; onConfigure?: (domain: AdapterDomain, config: DomainAdapterConfig) => Promise | void; style?: StyleProp; testID?: string; } /** * Renders provider metadata, status, and configuration for one adapter domain. * * @param props Detail page props including the target domain and optional back action. * @returns A React Native detail page for the requested adapter domain. * @example * ```tsx * navigation.goBack()} /> * ``` */ declare function AdapterDetailPage({ domain, onBack, onConfigure, style, testID, }: AdapterDetailPageProps): JSX.Element; /** * @module AdaptersPage * @package @geenius/adapters/react-native * @description Renders the native adapters overview page. */ type RegistryEntry = { domain: AdapterDomain; provider: string; status: AdapterStatusType; }; /** * Props for the native adapters overview page. * * @property configByDomain Optional configuration snapshot used to hydrate modal forms. * @property onNavigateDetail Optional navigation callback for external routers. * @property onConfigure Optional callback invoked with submitted adapter configuration. * @property reducedMotion Disables modal slide animation when `true`. * @property registryEntries Optional provider registry rows shown above the list. * @property style Optional native style merged onto the page container. * @property testID Optional deterministic selector for tests and Storybook. */ interface AdaptersPageProps { configByDomain?: Partial>; onNavigateDetail?: (domain: AdapterDomain) => void; onConfigure?: (domain: AdapterDomain, config: DomainAdapterConfig) => Promise | void; reducedMotion?: boolean; registryEntries?: RegistryEntry[]; style?: StyleProp; testID?: string; } /** * Renders the native overview dashboard for all adapter domains. * * @param props Overview page props including optional navigation and registry rows. * @returns A React Native adapters page with metrics, filters, and configuration modal. * @example * ```tsx * router.push(domain)} /> * ``` */ declare function AdaptersPage(props: AdaptersPageProps): JSX.Element; /** * @module defaultAdapters * @package @geenius/adapters/react-native * @description Provides React Native-safe default adapter implementations. * They use an AsyncStorage-compatible key/value store when one is supplied and * fall back to an in-process Map for tests, previews, and offline prototypes. */ interface ReactNativeAsyncStorage { getItem(key: string): Promise | string | null; removeItem(key: string): Promise | void; setItem(key: string, value: string): Promise | void; } /** * @module provider * @package @geenius/adapters/react-native * @description Implements the React Native adapter provider and context access * helpers with native-safe default adapters. */ type AnyAdapter = DbAdapter | AuthAdapter | PaymentsAdapter | AiAdapter | FileStorageAdapter | AdminAdapter | LoggerAdapter; type AdapterForDomain = D extends "db" ? DbAdapter : D extends "auth" ? AuthAdapter : D extends "payments" ? PaymentsAdapter : D extends "ai" ? AiAdapter : D extends "storage" ? FileStorageAdapter : D extends "admin" ? AdminAdapter : D extends "logger" ? LoggerAdapter : never; type AdapterByDomain = { [D in AdapterDomain]: AdapterForDomain; }; type ResolvedAdapterSet = AdapterByDomain & { fileStorage: FileStorageAdapter; }; /** * Adapter instances that may be supplied to the native provider. * * @property admin Optional admin adapter override. * @property ai Optional AI adapter override. * @property auth Optional auth adapter override. * @property db Optional DB adapter override. * @property fileStorage Optional legacy alias for the storage adapter. * @property logger Optional logger adapter override. * @property payments Optional payments adapter override. * @property storage Optional file storage adapter override. */ interface AdapterSet extends Partial> { admin?: AdminAdapter; ai?: AiAdapter; auth?: AuthAdapter; db?: DbAdapter; fileStorage?: FileStorageAdapter; logger?: LoggerAdapter; payments?: PaymentsAdapter; storage?: FileStorageAdapter; } /** * Registry shape accepted by {@link AdapterProvider} for adapter overrides. * * @example * ```tsx * * ``` */ type AdapterRegistry = AdapterSet; /** * Runtime context value exposed by {@link useAdapterContext}. * * @property adapters Fully resolved adapter instances. * @property getAdapter Typed adapter lookup helper by domain. * @property isLoading Whether provider health checks are still running. * @property isReady Readiness helper for a single domain. * @property statuses Status metadata keyed by adapter domain. */ interface AdapterContextValue { adapters: ResolvedAdapterSet; getAdapter: (domain: K) => AdapterByDomain[K]; isLoading: boolean; isReady: (domain: AdapterDomain) => boolean; statuses: Record; } type AdapterHealthProbeMap = Partial<{ [D in AdapterDomain]: (adapter: AdapterByDomain[D], adapters: ResolvedAdapterSet) => Promise | void; }>; /** * Props for the native adapter provider. * * @property adapters Optional bundle of adapter overrides. * @property asyncStorage Async storage implementation used by local native defaults. * @property children React subtree receiving the adapter context. * @property healthCheck Enables startup health checks for configured adapters. * @property healthProbes Optional domain-specific health probes supplied by the host app. * @property namespace Storage namespace used by default local adapters. * @property onError Optional callback for health-check adapter errors. * @property registry Optional registry alias for adapter overrides. * @property statusOverrides Optional status metadata overrides for stories/tests. */ interface AdapterProviderProps extends Partial { adapters?: AdapterSet; asyncStorage?: ReactNativeAsyncStorage; children: ReactNode; healthCheck?: boolean; healthProbes?: AdapterHealthProbeMap; namespace?: string; onError?: (error: AdapterError) => void; registry?: Partial; statusOverrides?: Partial>>; } /** * Provides native adapter instances, status metadata, and readiness helpers. * * @param props Provider props including adapter overrides and local defaults. * @returns A React context provider for React Native adapter consumers. * @example * ```tsx * * * * ``` */ declare function AdapterProvider(props: AdapterProviderProps): JSX.Element; /** * Alias for {@link AdapterProvider} retained for naming parity with web variants. * * @example * ```tsx * * ``` */ declare const AdaptersProvider: typeof AdapterProvider; /** * Reads the native adapter context from the nearest provider. * * @returns The resolved adapter context value. * @throws AdapterContextError when rendered outside an {@link AdapterProvider}. * @example * ```tsx * const { statuses, getAdapter } = useAdapterContext(); * ``` */ declare function useAdapterContext(): AdapterContextValue; /** * @module index * @package @geenius/adapters/react-native * @description Re-exports the public React Native adapter package surface. * The provider and UI affordances mirror the React reference contract while * rendering through native primitives instead of DOM nodes or CSS. */ /** @doc Public React Native loading, error, and toast bridge components. */ /** * Joins truthy class-name fragments for compatibility with shared examples. * * @param classes Class-name fragments or falsy placeholders. * @returns A space-delimited class-name string. * @example * ```ts * const className = cn("base", isActive && "active"); * ``` */ declare function cn(...classes: (string | false | null | undefined)[]): string; export { AdapterCard, type AdapterCardProps, AdapterConfigForm, type AdapterConfigFormProps, type AdapterContextValue, AdapterDetailPage, type AdapterDetailPageProps, type AdapterHealthProbeMap, AdapterList, type AdapterListProps, AdapterProvider, type AdapterProviderProps, type AdapterRegistry, type AdapterSet, AdapterStatusBadge, type AdapterStatusBadgeProps, AdaptersPage, type AdaptersPageProps, AdaptersProvider, ErrorBoundaryBridge, type ErrorBoundaryBridgeProps, LoadingBridge, type LoadingBridgeProps, type ReactNativeAsyncStorage, ToastBridge, type ToastBridgeProps, cn, useAdapterContext, useAdapterStatus, useAdapterStatuses, useAdapters, useAdmin, useAi, useAuth, useAuthAdapter, useDb, useFileStorage, useIsAdapterReady, useLogger, usePayments, useStorage };