@vaiftech/sdk-expo 1.0.10 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
- import { VaifClientConfig, User, VaifClient, AuthResponse, OAuthProviderType, MFAMethod, MFASetupResponse, QueryOptions, WhereFilter, OrderByClause, DbOperation, SubscriptionFilter, DbChangeEvent, ConnectionState, PresenceState, PresenceEntry, UploadResult, FileMetadata, RetryConfig, VaifFunction } from '@vaiftech/client';
3
+ import { VaifClientConfig, User, VaifClient, AuthResponse, OAuthProviderType, MFAMethod, MFASetupResponse, QueryOptions, WhereFilter, OrderByClause, DbOperation, SubscriptionFilter, DbChangeEvent, ConnectionState, PresenceState, PresenceEntry, UploadResult, FileMetadata, RetryConfig, VaifFunction, ProjectMetrics, SecurityAuditLog, IncidentStatus, IncidentAlert, StatusComponent, RealtimeStats, RealtimeMonitoringEvent, MongoCollectionClient, MongoFilter, MongoSort, MongoProjection, MongoPipelineStage, MongoInsertOneResult, MongoInsertManyResult, MongoUpdateResult, MongoUpdateOperators, MongoDeleteResult } from '@vaiftech/client';
4
4
  export { AuthResponse, ConnectionState, DbChangeEvent, DbOperation, FileMetadata, InvokeResult, OrderByClause, PresenceState, QueryOptions, UploadResult, User, VaifClient, VaifClientConfig, VaifFunction, WhereFilter } from '@vaiftech/client';
5
+ import { AppStateStatus } from 'react-native';
5
6
  export { AuthChangeEvent, AuthClientConfig, AuthEventType, AuthProvider, AuthProviderProps, Session as AuthSession, AuthSubscription, MFAFactor, VaifAuthClient, createAuthClient, useAuthClient, useIdentities, useIsAuthenticated, usePassword, useSession, useSessions, useAuth as useStandaloneAuth, useMFA as useStandaloneMFA } from '@vaiftech/auth/react';
6
7
 
7
8
  /**
@@ -1218,4 +1219,802 @@ declare function useBatchInvoke<TOutput = unknown>(): {
1218
1219
  */
1219
1220
  declare function useScheduledFunction<TInput = unknown>(functionId: string): UseScheduledFunctionReturn<TInput>;
1220
1221
 
1221
- export { type AsyncStorageInterface, type BroadcastMessage, type MutationStatus, type QueryStatus, type UploadOptions, type UseAuthReturn, type UseBatchDeleteReturn, type UseBatchUpdateReturn, type UseBroadcastReturn, type UseChannelOptions, type UseChannelReturn, type UseCountOptions, type UseCountReturn, type UseCreateReturn, type UseDeleteReturn, type UseDownloadReturn, type UseEmailVerificationReturn, type UseFileReturn, type UseFilesReturn, type UseFunctionListReturn, type UseFunctionOptions, type UseFunctionReturn, type UseInfiniteQueryOptions, type UseInfiniteQueryReturn, type UseMFAReturn, type UseMagicLinkReturn, type UseMutationReturn, type UseOAuthReturn, type UseOptimisticMutationReturn, type UsePaginatedQueryOptions, type UsePaginatedQueryReturn, type UsePasswordResetReturn, type UsePresenceOptions, type UsePresenceReturn, type UseQueryFirstReturn, type UseQueryOptions, type UseQueryReturn, type UseRpcReturn, type UseScheduledFunctionReturn, type UseSubscriptionOptions, type UseSubscriptionReturn, type UseUpdateReturn, type UseUploadReturn, type UseUpsertReturn, type VaifContextValue, VaifProvider, type VaifProviderProps, useAuth, useBatchCreate, useBatchDelete, useBatchInvoke, useBatchUpdate, useBroadcast, useChannel, useCount, useCreate, useDelete, useDownload, useEmailVerification, useFile, useFiles, useFunction, useFunctionList, useFunctionQuery, useInfiniteQuery, useMFA, useMagicLink, useOAuth, useOptimisticMutation, usePaginatedQuery, usePasswordReset, usePresence, usePublicUrl, useQuery, useQueryById, useQueryFirst, useRealtimeConnection, useRpc, useScheduledFunction, useSubscription, useToken, useUpdate, useUpload, useUpsert, useUser, useVaif, useVaifClient };
1222
+ interface UseMetricsOptions {
1223
+ /** Auto-refresh interval in ms (0 = disabled) */
1224
+ refetchInterval?: number;
1225
+ /** Enable/disable the query */
1226
+ enabled?: boolean;
1227
+ /** Callback on success */
1228
+ onSuccess?: (metrics: ProjectMetrics) => void;
1229
+ /** Callback on error */
1230
+ onError?: (error: Error) => void;
1231
+ }
1232
+ interface UseMetricsReturn {
1233
+ /** Project metrics data */
1234
+ metrics: ProjectMetrics | null;
1235
+ /** Loading state */
1236
+ isLoading: boolean;
1237
+ /** Error state */
1238
+ error: Error | null;
1239
+ /** Refetch metrics */
1240
+ refetch: () => Promise<void>;
1241
+ }
1242
+ interface UseAuditLogsOptions {
1243
+ /** Page size */
1244
+ limit?: number;
1245
+ /** Page offset */
1246
+ offset?: number;
1247
+ /** Enable/disable the query */
1248
+ enabled?: boolean;
1249
+ /** Auto-refresh interval in ms (0 = disabled) */
1250
+ refetchInterval?: number;
1251
+ /** Callback on success */
1252
+ onSuccess?: (logs: SecurityAuditLog[], total: number) => void;
1253
+ /** Callback on error */
1254
+ onError?: (error: Error) => void;
1255
+ }
1256
+ interface UseAuditLogsReturn {
1257
+ /** Audit log entries */
1258
+ logs: SecurityAuditLog[];
1259
+ /** Total count */
1260
+ total: number;
1261
+ /** Loading state */
1262
+ isLoading: boolean;
1263
+ /** Error state */
1264
+ error: Error | null;
1265
+ /** Refetch logs */
1266
+ refetch: () => Promise<void>;
1267
+ /** Load next page */
1268
+ loadMore: () => void;
1269
+ /** Whether there are more pages */
1270
+ hasMore: boolean;
1271
+ }
1272
+ interface UseIncidentsOptions {
1273
+ /** Filter by status */
1274
+ status?: IncidentStatus;
1275
+ /** Auto-refresh interval in ms (0 = disabled) */
1276
+ refetchInterval?: number;
1277
+ /** Enable/disable the query */
1278
+ enabled?: boolean;
1279
+ /** Callback on success */
1280
+ onSuccess?: (incidents: IncidentAlert[]) => void;
1281
+ /** Callback on error */
1282
+ onError?: (error: Error) => void;
1283
+ }
1284
+ interface UseIncidentsReturn {
1285
+ /** Incident alerts */
1286
+ incidents: IncidentAlert[];
1287
+ /** Loading state */
1288
+ isLoading: boolean;
1289
+ /** Error state */
1290
+ error: Error | null;
1291
+ /** Refetch incidents */
1292
+ refetch: () => Promise<void>;
1293
+ /** Acknowledge an incident */
1294
+ acknowledge: (incidentId: string) => Promise<void>;
1295
+ /** Resolve an incident */
1296
+ resolve: (incidentId: string) => Promise<void>;
1297
+ /** Count by severity */
1298
+ countBySeverity: Record<string, number>;
1299
+ }
1300
+ interface UseSystemHealthOptions {
1301
+ /** Auto-refresh interval in ms (0 = disabled) */
1302
+ refetchInterval?: number;
1303
+ /** Enable/disable the query */
1304
+ enabled?: boolean;
1305
+ /** Callback on status change */
1306
+ onStatusChange?: (components: StatusComponent[]) => void;
1307
+ /** Callback on error */
1308
+ onError?: (error: Error) => void;
1309
+ }
1310
+ interface UseSystemHealthReturn {
1311
+ /** Health components */
1312
+ components: StatusComponent[];
1313
+ /** Overall status */
1314
+ overallStatus: "operational" | "degraded" | "partial_outage" | "major_outage";
1315
+ /** Loading state */
1316
+ isLoading: boolean;
1317
+ /** Error state */
1318
+ error: Error | null;
1319
+ /** Refetch health status */
1320
+ refetch: () => Promise<void>;
1321
+ /** Check if a specific component is healthy */
1322
+ isHealthy: (componentName: string) => boolean;
1323
+ }
1324
+ interface UseRealtimeStatsOptions {
1325
+ /** Auto-refresh interval in ms (0 = disabled) */
1326
+ refetchInterval?: number;
1327
+ /** Enable/disable the query */
1328
+ enabled?: boolean;
1329
+ /** Include recent events */
1330
+ includeEvents?: boolean;
1331
+ /** Max events to fetch */
1332
+ eventsLimit?: number;
1333
+ /** Callback on success */
1334
+ onSuccess?: (stats: RealtimeStats, events?: RealtimeMonitoringEvent[]) => void;
1335
+ /** Callback on error */
1336
+ onError?: (error: Error) => void;
1337
+ }
1338
+ interface UseRealtimeStatsReturn {
1339
+ /** Realtime statistics */
1340
+ stats: RealtimeStats | null;
1341
+ /** Recent realtime events */
1342
+ events: RealtimeMonitoringEvent[];
1343
+ /** Loading state */
1344
+ isLoading: boolean;
1345
+ /** Error state */
1346
+ error: Error | null;
1347
+ /** Refetch stats */
1348
+ refetch: () => Promise<void>;
1349
+ }
1350
+ interface UseErrorTrackingOptions {
1351
+ /** Time window in hours (default: 24) */
1352
+ timeWindowHours?: number;
1353
+ /** Auto-refresh interval in ms (0 = disabled) */
1354
+ refetchInterval?: number;
1355
+ /** Enable/disable the query */
1356
+ enabled?: boolean;
1357
+ /** Callback on high error rate */
1358
+ onHighErrorRate?: (errorRate: number) => void;
1359
+ /** Error rate threshold (default: 0.05 = 5%) */
1360
+ errorRateThreshold?: number;
1361
+ /** Refetch when app comes to foreground */
1362
+ refetchOnForeground?: boolean;
1363
+ }
1364
+ interface UseErrorTrackingReturn {
1365
+ /** Total requests */
1366
+ requestCount: number;
1367
+ /** Total errors */
1368
+ errorCount: number;
1369
+ /** Error rate (0-1) */
1370
+ errorRate: number;
1371
+ /** Average latency in ms */
1372
+ avgLatencyMs: number;
1373
+ /** Whether error rate is above threshold */
1374
+ isHighErrorRate: boolean;
1375
+ /** Loading state */
1376
+ isLoading: boolean;
1377
+ /** Error state */
1378
+ error: Error | null;
1379
+ /** Refetch stats */
1380
+ refetch: () => Promise<void>;
1381
+ }
1382
+ /**
1383
+ * Hook for fetching project metrics
1384
+ *
1385
+ * @example
1386
+ * ```tsx
1387
+ * function MetricsDashboard({ projectId }: { projectId: string }) {
1388
+ * const { metrics, isLoading, error } = useMetrics(projectId, {
1389
+ * refetchInterval: 30000, // Refresh every 30 seconds
1390
+ * });
1391
+ *
1392
+ * if (isLoading) return <ActivityIndicator />;
1393
+ * if (error) return <Text>Error: {error.message}</Text>;
1394
+ *
1395
+ * return (
1396
+ * <View>
1397
+ * <Stat label="Requests (24h)" value={metrics?.requestsLast24h} />
1398
+ * <Stat label="Errors (24h)" value={metrics?.errorsLast24h} />
1399
+ * <Stat label="Avg Latency" value={`${metrics?.avgLatencyMs}ms`} />
1400
+ * </View>
1401
+ * );
1402
+ * }
1403
+ * ```
1404
+ */
1405
+ declare function useMetrics(projectId: string, options?: UseMetricsOptions): UseMetricsReturn;
1406
+ /**
1407
+ * Hook for fetching security audit logs
1408
+ *
1409
+ * @example
1410
+ * ```tsx
1411
+ * function AuditLogViewer({ projectId }: { projectId: string }) {
1412
+ * const { logs, total, isLoading, loadMore, hasMore } = useAuditLogs(projectId, {
1413
+ * limit: 50,
1414
+ * });
1415
+ *
1416
+ * return (
1417
+ * <View>
1418
+ * <Text>Audit Logs ({total})</Text>
1419
+ * <FlatList
1420
+ * data={logs}
1421
+ * keyExtractor={(log) => log.id}
1422
+ * renderItem={({ item }) => <LogEntry log={item} />}
1423
+ * onEndReached={hasMore ? loadMore : undefined}
1424
+ * />
1425
+ * </View>
1426
+ * );
1427
+ * }
1428
+ * ```
1429
+ */
1430
+ declare function useAuditLogs(projectId: string, options?: UseAuditLogsOptions): UseAuditLogsReturn;
1431
+ /**
1432
+ * Hook for monitoring incidents
1433
+ *
1434
+ * @example
1435
+ * ```tsx
1436
+ * function IncidentMonitor() {
1437
+ * const {
1438
+ * incidents,
1439
+ * countBySeverity,
1440
+ * acknowledge,
1441
+ * resolve,
1442
+ * isLoading,
1443
+ * } = useIncidents({
1444
+ * status: 'open',
1445
+ * refetchInterval: 60000, // Check every minute
1446
+ * });
1447
+ *
1448
+ * return (
1449
+ * <View>
1450
+ * <SeverityBadges counts={countBySeverity} />
1451
+ * <FlatList
1452
+ * data={incidents}
1453
+ * keyExtractor={(item) => item.id}
1454
+ * renderItem={({ item }) => (
1455
+ * <IncidentCard
1456
+ * incident={item}
1457
+ * onAcknowledge={() => acknowledge(item.id)}
1458
+ * onResolve={() => resolve(item.id)}
1459
+ * />
1460
+ * )}
1461
+ * />
1462
+ * </View>
1463
+ * );
1464
+ * }
1465
+ * ```
1466
+ */
1467
+ declare function useIncidents(options?: UseIncidentsOptions): UseIncidentsReturn;
1468
+ /**
1469
+ * Hook for monitoring system health
1470
+ *
1471
+ * @example
1472
+ * ```tsx
1473
+ * function SystemStatus() {
1474
+ * const {
1475
+ * components,
1476
+ * overallStatus,
1477
+ * isHealthy,
1478
+ * isLoading,
1479
+ * } = useSystemHealth({
1480
+ * refetchInterval: 30000,
1481
+ * onStatusChange: (components) => {
1482
+ * const degraded = components.filter(c => c.status !== 'operational');
1483
+ * if (degraded.length > 0) {
1484
+ * Alert.alert('System Alert', 'System degradation detected');
1485
+ * }
1486
+ * },
1487
+ * });
1488
+ *
1489
+ * return (
1490
+ * <View>
1491
+ * <StatusBadge status={overallStatus} />
1492
+ * {components.map(component => (
1493
+ * <ComponentStatus key={component.id} component={component} />
1494
+ * ))}
1495
+ * </View>
1496
+ * );
1497
+ * }
1498
+ * ```
1499
+ */
1500
+ declare function useSystemHealth(options?: UseSystemHealthOptions): UseSystemHealthReturn;
1501
+ /**
1502
+ * Hook for monitoring realtime stats
1503
+ *
1504
+ * @example
1505
+ * ```tsx
1506
+ * function RealtimeMonitor({ projectId }: { projectId: string }) {
1507
+ * const { stats, events, isLoading } = useRealtimeStats(projectId, {
1508
+ * refetchInterval: 10000,
1509
+ * includeEvents: true,
1510
+ * eventsLimit: 20,
1511
+ * });
1512
+ *
1513
+ * return (
1514
+ * <View>
1515
+ * <StatCard label="Connections" value={stats?.connections} />
1516
+ * <StatCard label="Subscriptions" value={stats?.subscriptions} />
1517
+ * <StatCard label="Events (24h)" value={stats?.eventsDelivered24h} />
1518
+ * <EventList events={events} />
1519
+ * </View>
1520
+ * );
1521
+ * }
1522
+ * ```
1523
+ */
1524
+ declare function useRealtimeStats(projectId: string, options?: UseRealtimeStatsOptions): UseRealtimeStatsReturn;
1525
+ /**
1526
+ * Hook for error tracking and alerting
1527
+ *
1528
+ * @example
1529
+ * ```tsx
1530
+ * function ErrorRateMonitor({ projectId }: { projectId: string }) {
1531
+ * const {
1532
+ * requestCount,
1533
+ * errorCount,
1534
+ * errorRate,
1535
+ * avgLatencyMs,
1536
+ * isHighErrorRate,
1537
+ * } = useErrorTracking(projectId, {
1538
+ * refetchInterval: 60000,
1539
+ * refetchOnForeground: true,
1540
+ * errorRateThreshold: 0.05, // 5%
1541
+ * onHighErrorRate: (rate) => {
1542
+ * Alert.alert('High Error Rate', `Error rate: ${(rate * 100).toFixed(1)}%`);
1543
+ * },
1544
+ * });
1545
+ *
1546
+ * return (
1547
+ * <View style={isHighErrorRate ? styles.alert : undefined}>
1548
+ * <Stat label="Requests" value={requestCount} />
1549
+ * <Stat label="Errors" value={errorCount} />
1550
+ * <Stat label="Error Rate" value={`${(errorRate * 100).toFixed(2)}%`} />
1551
+ * <Stat label="Avg Latency" value={`${avgLatencyMs}ms`} />
1552
+ * </View>
1553
+ * );
1554
+ * }
1555
+ * ```
1556
+ */
1557
+ declare function useErrorTracking(projectId: string, options?: UseErrorTrackingOptions): UseErrorTrackingReturn;
1558
+
1559
+ type MongoQueryStatus = "idle" | "loading" | "success" | "error";
1560
+ interface UseMongoFindOptions<T extends Record<string, unknown>> {
1561
+ filter?: MongoFilter<T>;
1562
+ sort?: MongoSort<T>;
1563
+ projection?: MongoProjection<T>;
1564
+ skip?: number;
1565
+ limit?: number;
1566
+ enabled?: boolean;
1567
+ refetchOnForeground?: boolean;
1568
+ refetchInterval?: number;
1569
+ keepPreviousData?: boolean;
1570
+ onSuccess?: (data: T[]) => void;
1571
+ onError?: (error: Error) => void;
1572
+ staleTime?: number;
1573
+ }
1574
+ interface UseMongoFindReturn<T> {
1575
+ data: T[];
1576
+ isLoading: boolean;
1577
+ isFetching: boolean;
1578
+ error: Error | null;
1579
+ status: MongoQueryStatus;
1580
+ refetch: () => Promise<void>;
1581
+ isStale: boolean;
1582
+ isEnabled: boolean;
1583
+ }
1584
+ interface UseMongoFindOneOptions<T extends Record<string, unknown>> {
1585
+ filter?: MongoFilter<T>;
1586
+ projection?: MongoProjection<T>;
1587
+ enabled?: boolean;
1588
+ onSuccess?: (data: T | null) => void;
1589
+ onError?: (error: Error) => void;
1590
+ }
1591
+ interface UseMongoFindOneReturn<T> {
1592
+ data: T | null;
1593
+ isLoading: boolean;
1594
+ error: Error | null;
1595
+ isNotFound: boolean;
1596
+ refetch: () => Promise<void>;
1597
+ }
1598
+ interface UseMongoAggregateOptions {
1599
+ enabled?: boolean;
1600
+ allowDiskUse?: boolean;
1601
+ maxTimeMS?: number;
1602
+ onSuccess?: (data: unknown[]) => void;
1603
+ onError?: (error: Error) => void;
1604
+ }
1605
+ interface UseMongoAggregateReturn<T> {
1606
+ data: T[];
1607
+ isLoading: boolean;
1608
+ error: Error | null;
1609
+ refetch: () => Promise<void>;
1610
+ }
1611
+ interface UseMongoMutationReturn<TData, TVariables> {
1612
+ mutate: (variables: TVariables) => Promise<TData>;
1613
+ mutateAsync: (variables: TVariables) => Promise<TData>;
1614
+ isLoading: boolean;
1615
+ error: Error | null;
1616
+ isSuccess: boolean;
1617
+ data: TData | null;
1618
+ reset: () => void;
1619
+ }
1620
+ interface UseMongoInsertOneVariables<T> {
1621
+ document: Omit<T, "_id">;
1622
+ }
1623
+ interface UseMongoInsertManyVariables<T> {
1624
+ documents: Omit<T, "_id">[];
1625
+ }
1626
+ interface UseMongoUpdateOneVariables<T extends Record<string, unknown>> {
1627
+ filter: MongoFilter<T>;
1628
+ update: MongoUpdateOperators<T>;
1629
+ upsert?: boolean;
1630
+ }
1631
+ interface UseMongoUpdateManyVariables<T extends Record<string, unknown>> {
1632
+ filter: MongoFilter<T>;
1633
+ update: MongoUpdateOperators<T>;
1634
+ upsert?: boolean;
1635
+ }
1636
+ interface UseMongoDeleteOneVariables<T extends Record<string, unknown>> {
1637
+ filter: MongoFilter<T>;
1638
+ }
1639
+ interface UseMongoDeleteManyVariables<T extends Record<string, unknown>> {
1640
+ filter: MongoFilter<T>;
1641
+ }
1642
+ interface UseMongoInfiniteFindOptions<T extends Record<string, unknown>> {
1643
+ filter?: MongoFilter<T>;
1644
+ sort?: MongoSort<T>;
1645
+ projection?: MongoProjection<T>;
1646
+ pageSize?: number;
1647
+ onSuccess?: (data: T[], hasMore: boolean) => void;
1648
+ onError?: (error: Error) => void;
1649
+ }
1650
+ interface UseMongoInfiniteFindReturn<T> {
1651
+ data: T[];
1652
+ pages: T[][];
1653
+ hasMore: boolean;
1654
+ isLoading: boolean;
1655
+ isFetchingNextPage: boolean;
1656
+ error: Error | null;
1657
+ fetchNextPage: () => Promise<void>;
1658
+ refetch: () => Promise<void>;
1659
+ reset: () => void;
1660
+ }
1661
+ interface UseMongoCountOptions<T extends Record<string, unknown>> {
1662
+ filter?: MongoFilter<T>;
1663
+ enabled?: boolean;
1664
+ }
1665
+ /**
1666
+ * Get a MongoDB collection client for direct operations
1667
+ *
1668
+ * @example
1669
+ * ```tsx
1670
+ * function MyComponent() {
1671
+ * const users = useMongoCollection<User>('users');
1672
+ *
1673
+ * const handleCreate = async () => {
1674
+ * await users.insertOne({ name: 'John', email: 'john@example.com' });
1675
+ * };
1676
+ *
1677
+ * return <Button onPress={handleCreate} title="Create User" />;
1678
+ * }
1679
+ * ```
1680
+ */
1681
+ declare function useMongoCollection<T extends Record<string, unknown>>(collectionName: string): MongoCollectionClient<T>;
1682
+ /**
1683
+ * Find documents in a MongoDB collection
1684
+ *
1685
+ * @example
1686
+ * ```tsx
1687
+ * function UserList() {
1688
+ * const { data: users, isLoading } = useMongoFind<User>('users', {
1689
+ * filter: { status: 'active' },
1690
+ * sort: { createdAt: -1 },
1691
+ * limit: 20,
1692
+ * refetchOnForeground: true,
1693
+ * });
1694
+ *
1695
+ * if (isLoading) return <ActivityIndicator />;
1696
+ *
1697
+ * return (
1698
+ * <FlatList
1699
+ * data={users}
1700
+ * keyExtractor={item => item._id}
1701
+ * renderItem={({ item }) => <Text>{item.name}</Text>}
1702
+ * />
1703
+ * );
1704
+ * }
1705
+ * ```
1706
+ */
1707
+ declare function useMongoFind<T extends Record<string, unknown>>(collection: string, options?: UseMongoFindOptions<T>): UseMongoFindReturn<T>;
1708
+ /**
1709
+ * Find a single document in a MongoDB collection
1710
+ *
1711
+ * @example
1712
+ * ```tsx
1713
+ * function UserProfile({ userId }) {
1714
+ * const { data: user, isLoading, isNotFound } = useMongoFindOne<User>('users', {
1715
+ * filter: { _id: userId },
1716
+ * });
1717
+ *
1718
+ * if (isLoading) return <ActivityIndicator />;
1719
+ * if (isNotFound) return <Text>User not found</Text>;
1720
+ *
1721
+ * return <Text>{user?.name}</Text>;
1722
+ * }
1723
+ * ```
1724
+ */
1725
+ declare function useMongoFindOne<T extends Record<string, unknown>>(collection: string, options?: UseMongoFindOneOptions<T>): UseMongoFindOneReturn<T>;
1726
+ /**
1727
+ * Run an aggregation pipeline on a MongoDB collection
1728
+ *
1729
+ * @example
1730
+ * ```tsx
1731
+ * function UserStats() {
1732
+ * const { data: stats, isLoading } = useMongoAggregate('users', [
1733
+ * { $match: { status: 'active' } },
1734
+ * { $group: { _id: '$role', count: { $sum: 1 } } },
1735
+ * ]);
1736
+ *
1737
+ * if (isLoading) return <ActivityIndicator />;
1738
+ *
1739
+ * return (
1740
+ * <View>
1741
+ * {stats.map(stat => (
1742
+ * <Text key={stat._id}>{stat._id}: {stat.count}</Text>
1743
+ * ))}
1744
+ * </View>
1745
+ * );
1746
+ * }
1747
+ * ```
1748
+ */
1749
+ declare function useMongoAggregate<TResult = unknown>(collection: string, pipeline: MongoPipelineStage[], options?: UseMongoAggregateOptions): UseMongoAggregateReturn<TResult>;
1750
+ /**
1751
+ * Insert a single document into a MongoDB collection
1752
+ *
1753
+ * @example
1754
+ * ```tsx
1755
+ * function CreateUser() {
1756
+ * const { mutate, isLoading } = useMongoInsertOne<User>('users');
1757
+ *
1758
+ * const handleCreate = async () => {
1759
+ * await mutate({ document: { name: 'John', email: 'john@example.com' } });
1760
+ * Alert.alert('Success', 'User created!');
1761
+ * };
1762
+ *
1763
+ * return <Button onPress={handleCreate} disabled={isLoading} title="Create" />;
1764
+ * }
1765
+ * ```
1766
+ */
1767
+ declare function useMongoInsertOne<T extends Record<string, unknown>>(collection: string, options?: {
1768
+ onSuccess?: (result: MongoInsertOneResult) => void;
1769
+ onError?: (error: Error) => void;
1770
+ }): UseMongoMutationReturn<MongoInsertOneResult, UseMongoInsertOneVariables<T>>;
1771
+ /**
1772
+ * Insert multiple documents into a MongoDB collection
1773
+ */
1774
+ declare function useMongoInsertMany<T extends Record<string, unknown>>(collection: string, options?: {
1775
+ onSuccess?: (result: MongoInsertManyResult) => void;
1776
+ onError?: (error: Error) => void;
1777
+ }): UseMongoMutationReturn<MongoInsertManyResult, UseMongoInsertManyVariables<T>>;
1778
+ /**
1779
+ * Update a single document in a MongoDB collection
1780
+ *
1781
+ * @example
1782
+ * ```tsx
1783
+ * function UpdateUser({ userId }) {
1784
+ * const { mutate, isLoading } = useMongoUpdateOne<User>('users');
1785
+ *
1786
+ * const handleUpdate = async () => {
1787
+ * await mutate({
1788
+ * filter: { _id: userId },
1789
+ * update: { $set: { status: 'premium' } },
1790
+ * });
1791
+ * };
1792
+ *
1793
+ * return <Button onPress={handleUpdate} disabled={isLoading} title="Upgrade" />;
1794
+ * }
1795
+ * ```
1796
+ */
1797
+ declare function useMongoUpdateOne<T extends Record<string, unknown>>(collection: string, options?: {
1798
+ onSuccess?: (result: MongoUpdateResult) => void;
1799
+ onError?: (error: Error) => void;
1800
+ }): UseMongoMutationReturn<MongoUpdateResult, UseMongoUpdateOneVariables<T>>;
1801
+ /**
1802
+ * Update multiple documents in a MongoDB collection
1803
+ */
1804
+ declare function useMongoUpdateMany<T extends Record<string, unknown>>(collection: string, options?: {
1805
+ onSuccess?: (result: MongoUpdateResult) => void;
1806
+ onError?: (error: Error) => void;
1807
+ }): UseMongoMutationReturn<MongoUpdateResult, UseMongoUpdateManyVariables<T>>;
1808
+ /**
1809
+ * Delete a single document from a MongoDB collection
1810
+ *
1811
+ * @example
1812
+ * ```tsx
1813
+ * function DeleteUser({ userId }) {
1814
+ * const { mutate, isLoading } = useMongoDeleteOne<User>('users');
1815
+ *
1816
+ * return (
1817
+ * <Button
1818
+ * onPress={() => mutate({ filter: { _id: userId } })}
1819
+ * disabled={isLoading}
1820
+ * title="Delete"
1821
+ * />
1822
+ * );
1823
+ * }
1824
+ * ```
1825
+ */
1826
+ declare function useMongoDeleteOne<T extends Record<string, unknown>>(collection: string, options?: {
1827
+ onSuccess?: (result: MongoDeleteResult) => void;
1828
+ onError?: (error: Error) => void;
1829
+ }): UseMongoMutationReturn<MongoDeleteResult, UseMongoDeleteOneVariables<T>>;
1830
+ /**
1831
+ * Delete multiple documents from a MongoDB collection
1832
+ */
1833
+ declare function useMongoDeleteMany<T extends Record<string, unknown>>(collection: string, options?: {
1834
+ onSuccess?: (result: MongoDeleteResult) => void;
1835
+ onError?: (error: Error) => void;
1836
+ }): UseMongoMutationReturn<MongoDeleteResult, UseMongoDeleteManyVariables<T>>;
1837
+ /**
1838
+ * Infinite scroll for MongoDB collections
1839
+ *
1840
+ * @example
1841
+ * ```tsx
1842
+ * function InfinitePostList() {
1843
+ * const {
1844
+ * data,
1845
+ * hasMore,
1846
+ * fetchNextPage,
1847
+ * isFetchingNextPage,
1848
+ * } = useMongoInfiniteFind<Post>('posts', {
1849
+ * filter: { published: true },
1850
+ * sort: { createdAt: -1 },
1851
+ * pageSize: 20,
1852
+ * });
1853
+ *
1854
+ * return (
1855
+ * <FlatList
1856
+ * data={data}
1857
+ * keyExtractor={item => item._id}
1858
+ * renderItem={({ item }) => <PostCard post={item} />}
1859
+ * onEndReached={hasMore ? fetchNextPage : undefined}
1860
+ * onEndReachedThreshold={0.5}
1861
+ * ListFooterComponent={isFetchingNextPage ? <ActivityIndicator /> : null}
1862
+ * />
1863
+ * );
1864
+ * }
1865
+ * ```
1866
+ */
1867
+ declare function useMongoInfiniteFind<T extends Record<string, unknown>>(collection: string, options?: UseMongoInfiniteFindOptions<T>): UseMongoInfiniteFindReturn<T>;
1868
+ /**
1869
+ * Count documents in a MongoDB collection
1870
+ *
1871
+ * @example
1872
+ * ```tsx
1873
+ * function UserStats() {
1874
+ * const { count, isLoading } = useMongoCount<User>('users', {
1875
+ * filter: { status: 'active' },
1876
+ * });
1877
+ *
1878
+ * return <Text>Active users: {isLoading ? '...' : count}</Text>;
1879
+ * }
1880
+ * ```
1881
+ */
1882
+ declare function useMongoCount<T extends Record<string, unknown>>(collection: string, options?: UseMongoCountOptions<T>): {
1883
+ count: number;
1884
+ isLoading: boolean;
1885
+ error: Error | null;
1886
+ refetch: () => Promise<void>;
1887
+ };
1888
+ /**
1889
+ * Get distinct values for a field in a MongoDB collection
1890
+ *
1891
+ * @example
1892
+ * ```tsx
1893
+ * function RolePicker() {
1894
+ * const { values: roles, isLoading } = useMongoDistinct<User, string>('users', 'role');
1895
+ *
1896
+ * if (isLoading) return <ActivityIndicator />;
1897
+ *
1898
+ * return (
1899
+ * <Picker>
1900
+ * {roles.map(role => (
1901
+ * <Picker.Item key={role} label={role} value={role} />
1902
+ * ))}
1903
+ * </Picker>
1904
+ * );
1905
+ * }
1906
+ * ```
1907
+ */
1908
+ declare function useMongoDistinct<T extends Record<string, unknown>, TValue = unknown>(collection: string, field: keyof T & string, options?: {
1909
+ filter?: MongoFilter<T>;
1910
+ enabled?: boolean;
1911
+ }): {
1912
+ values: TValue[];
1913
+ isLoading: boolean;
1914
+ error: Error | null;
1915
+ refetch: () => Promise<void>;
1916
+ };
1917
+
1918
+ interface UseAppStateOptions {
1919
+ /** Reconnect realtime on foreground (default: true) */
1920
+ reconnectOnForeground?: boolean;
1921
+ /** Refresh auth session on foreground (default: true) */
1922
+ refreshSessionOnForeground?: boolean;
1923
+ /** Callback when app comes to foreground */
1924
+ onForeground?: () => void;
1925
+ /** Callback when app goes to background */
1926
+ onBackground?: () => void;
1927
+ }
1928
+ interface UseAppStateReturn {
1929
+ /** Current app state */
1930
+ appState: AppStateStatus;
1931
+ /** Whether app is in foreground */
1932
+ isActive: boolean;
1933
+ /** Whether app is in background */
1934
+ isBackground: boolean;
1935
+ /** Time spent in background (ms) */
1936
+ backgroundDuration: number | null;
1937
+ }
1938
+ /**
1939
+ * React Native app state hook with auto-reconnection
1940
+ *
1941
+ * Automatically handles realtime reconnection and session refresh
1942
+ * when the app transitions from background to foreground.
1943
+ *
1944
+ * @example
1945
+ * ```tsx
1946
+ * function App() {
1947
+ * const { appState, isActive } = useAppState({
1948
+ * reconnectOnForeground: true,
1949
+ * refreshSessionOnForeground: true,
1950
+ * onForeground: () => console.log('App foregrounded'),
1951
+ * onBackground: () => console.log('App backgrounded'),
1952
+ * });
1953
+ *
1954
+ * return <Text>App state: {appState}</Text>;
1955
+ * }
1956
+ * ```
1957
+ */
1958
+ declare function useAppState(options?: UseAppStateOptions): UseAppStateReturn;
1959
+ /**
1960
+ * Hook for network-aware data fetching
1961
+ *
1962
+ * Provides network connectivity state for React Native apps.
1963
+ * Uses a simple polling approach that works without @react-native-community/netinfo.
1964
+ *
1965
+ * @example
1966
+ * ```tsx
1967
+ * function DataFetcher() {
1968
+ * const { isConnected, checkConnection } = useNetworkState();
1969
+ *
1970
+ * if (!isConnected) {
1971
+ * return <Text>You are offline</Text>;
1972
+ * }
1973
+ *
1974
+ * return <MyDataComponent />;
1975
+ * }
1976
+ * ```
1977
+ */
1978
+ declare function useNetworkState(): {
1979
+ isConnected: boolean;
1980
+ checkConnection: () => Promise<boolean>;
1981
+ };
1982
+ /**
1983
+ * OAuth deep linking hook for mobile apps
1984
+ *
1985
+ * Handles OAuth callback URLs via deep linking in React Native / Expo.
1986
+ *
1987
+ * @example
1988
+ * ```tsx
1989
+ * import * as Linking from 'expo-linking';
1990
+ *
1991
+ * function AuthScreen() {
1992
+ * const { handleDeepLink, isProcessing, error } = useDeepLinkAuth();
1993
+ *
1994
+ * useEffect(() => {
1995
+ * const subscription = Linking.addEventListener('url', ({ url }) => {
1996
+ * handleDeepLink(url);
1997
+ * });
1998
+ *
1999
+ * // Handle initial URL (app opened from deep link)
2000
+ * Linking.getInitialURL().then(url => {
2001
+ * if (url) handleDeepLink(url);
2002
+ * });
2003
+ *
2004
+ * return () => subscription.remove();
2005
+ * }, [handleDeepLink]);
2006
+ *
2007
+ * if (isProcessing) return <ActivityIndicator />;
2008
+ * if (error) return <Text>Auth failed: {error.message}</Text>;
2009
+ *
2010
+ * return <OAuthButtons />;
2011
+ * }
2012
+ * ```
2013
+ */
2014
+ declare function useDeepLinkAuth(): {
2015
+ handleDeepLink: (url: string) => Promise<void>;
2016
+ isProcessing: boolean;
2017
+ error: Error | null;
2018
+ };
2019
+
2020
+ export { type AsyncStorageInterface, type BroadcastMessage, type MongoQueryStatus, type MutationStatus, type QueryStatus, type UploadOptions, type UseAppStateOptions, type UseAppStateReturn, type UseAuditLogsOptions, type UseAuditLogsReturn, type UseAuthReturn, type UseBatchDeleteReturn, type UseBatchUpdateReturn, type UseBroadcastReturn, type UseChannelOptions, type UseChannelReturn, type UseCountOptions, type UseCountReturn, type UseCreateReturn, type UseDeleteReturn, type UseDownloadReturn, type UseEmailVerificationReturn, type UseErrorTrackingOptions, type UseErrorTrackingReturn, type UseFileReturn, type UseFilesReturn, type UseFunctionListReturn, type UseFunctionOptions, type UseFunctionReturn, type UseIncidentsOptions, type UseIncidentsReturn, type UseInfiniteQueryOptions, type UseInfiniteQueryReturn, type UseMFAReturn, type UseMagicLinkReturn, type UseMetricsOptions, type UseMetricsReturn, type UseMongoAggregateOptions, type UseMongoAggregateReturn, type UseMongoCountOptions, type UseMongoDeleteManyVariables, type UseMongoDeleteOneVariables, type UseMongoFindOneOptions, type UseMongoFindOneReturn, type UseMongoFindOptions, type UseMongoFindReturn, type UseMongoInfiniteFindOptions, type UseMongoInfiniteFindReturn, type UseMongoInsertManyVariables, type UseMongoInsertOneVariables, type UseMongoMutationReturn, type UseMongoUpdateManyVariables, type UseMongoUpdateOneVariables, type UseMutationReturn, type UseOAuthReturn, type UseOptimisticMutationReturn, type UsePaginatedQueryOptions, type UsePaginatedQueryReturn, type UsePasswordResetReturn, type UsePresenceOptions, type UsePresenceReturn, type UseQueryFirstReturn, type UseQueryOptions, type UseQueryReturn, type UseRealtimeStatsOptions, type UseRealtimeStatsReturn, type UseRpcReturn, type UseScheduledFunctionReturn, type UseSubscriptionOptions, type UseSubscriptionReturn, type UseSystemHealthOptions, type UseSystemHealthReturn, type UseUpdateReturn, type UseUploadReturn, type UseUpsertReturn, type VaifContextValue, VaifProvider, type VaifProviderProps, useAppState, useAuditLogs, useAuth, useBatchCreate, useBatchDelete, useBatchInvoke, useBatchUpdate, useBroadcast, useChannel, useCount, useCreate, useDeepLinkAuth, useDelete, useDownload, useEmailVerification, useErrorTracking, useFile, useFiles, useFunction, useFunctionList, useFunctionQuery, useIncidents, useInfiniteQuery, useMFA, useMagicLink, useMetrics, useMongoAggregate, useMongoCollection, useMongoCount, useMongoDeleteMany, useMongoDeleteOne, useMongoDistinct, useMongoFind, useMongoFindOne, useMongoInfiniteFind, useMongoInsertMany, useMongoInsertOne, useMongoUpdateMany, useMongoUpdateOne, useNetworkState, useOAuth, useOptimisticMutation, usePaginatedQuery, usePasswordReset, usePresence, usePublicUrl, useQuery, useQueryById, useQueryFirst, useRealtimeConnection, useRealtimeStats, useRpc, useScheduledFunction, useSubscription, useSystemHealth, useToken, useUpdate, useUpload, useUpsert, useUser, useVaif, useVaifClient };