@reverbia/sdk 1.0.0-next.20251217134403 → 1.0.0-next.20251217144159
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/react/index.cjs +869 -0
- package/dist/react/index.d.mts +350 -1
- package/dist/react/index.d.ts +350 -1
- package/dist/react/index.mjs +866 -0
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Database, Model } from '@nozbe/watermelondb';
|
|
|
2
2
|
import * as _nozbe_watermelondb_Schema_migrations from '@nozbe/watermelondb/Schema/migrations';
|
|
3
3
|
import * as _nozbe_watermelondb_Schema from '@nozbe/watermelondb/Schema';
|
|
4
4
|
import { Associations } from '@nozbe/watermelondb/Model';
|
|
5
|
+
import { ReactNode, JSX } from 'react';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* ExtraFields contains additional metadata
|
|
@@ -1757,4 +1758,352 @@ declare function executeTool(tool: ClientTool, params: Record<string, unknown>):
|
|
|
1757
1758
|
error?: string;
|
|
1758
1759
|
}>;
|
|
1759
1760
|
|
|
1760
|
-
|
|
1761
|
+
/**
|
|
1762
|
+
* Dropbox API utilities
|
|
1763
|
+
*
|
|
1764
|
+
* Uses Dropbox HTTP API for file operations.
|
|
1765
|
+
* Dropbox uses OAuth 2.0 with PKCE for browser apps.
|
|
1766
|
+
*/
|
|
1767
|
+
/** Default folder path for Dropbox backups */
|
|
1768
|
+
declare const DEFAULT_BACKUP_FOLDER = "/ai-chat-app/conversations";
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* Dropbox Backup Implementation
|
|
1772
|
+
*
|
|
1773
|
+
* Generic backup/restore functionality for Dropbox storage.
|
|
1774
|
+
* Works directly with WatermelonDB database.
|
|
1775
|
+
*/
|
|
1776
|
+
|
|
1777
|
+
interface DropboxExportResult {
|
|
1778
|
+
success: boolean;
|
|
1779
|
+
uploaded: number;
|
|
1780
|
+
skipped: number;
|
|
1781
|
+
total: number;
|
|
1782
|
+
}
|
|
1783
|
+
interface DropboxImportResult {
|
|
1784
|
+
success: boolean;
|
|
1785
|
+
restored: number;
|
|
1786
|
+
failed: number;
|
|
1787
|
+
total: number;
|
|
1788
|
+
/** True if no backups were found in Dropbox */
|
|
1789
|
+
noBackupsFound?: boolean;
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* Options for useDropboxBackup hook
|
|
1794
|
+
*/
|
|
1795
|
+
interface UseDropboxBackupOptions {
|
|
1796
|
+
/** WatermelonDB database instance */
|
|
1797
|
+
database: Database;
|
|
1798
|
+
/** Current user address (null if not signed in) */
|
|
1799
|
+
userAddress: string | null;
|
|
1800
|
+
/** Request encryption key for the user address */
|
|
1801
|
+
requestEncryptionKey: (address: string) => Promise<void>;
|
|
1802
|
+
/** Export a conversation to an encrypted blob */
|
|
1803
|
+
exportConversation: (conversationId: string, userAddress: string) => Promise<{
|
|
1804
|
+
success: boolean;
|
|
1805
|
+
blob?: Blob;
|
|
1806
|
+
}>;
|
|
1807
|
+
/** Import a conversation from an encrypted blob */
|
|
1808
|
+
importConversation: (blob: Blob, userAddress: string) => Promise<{
|
|
1809
|
+
success: boolean;
|
|
1810
|
+
}>;
|
|
1811
|
+
/** Dropbox folder path for backups (default: '/ai-chat-app/conversations') */
|
|
1812
|
+
backupFolder?: string;
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Result returned by useDropboxBackup hook
|
|
1816
|
+
*/
|
|
1817
|
+
interface UseDropboxBackupResult {
|
|
1818
|
+
/** Backup all conversations to Dropbox */
|
|
1819
|
+
backup: (options?: {
|
|
1820
|
+
onProgress?: (current: number, total: number) => void;
|
|
1821
|
+
}) => Promise<DropboxExportResult | {
|
|
1822
|
+
error: string;
|
|
1823
|
+
}>;
|
|
1824
|
+
/** Restore conversations from Dropbox */
|
|
1825
|
+
restore: (options?: {
|
|
1826
|
+
onProgress?: (current: number, total: number) => void;
|
|
1827
|
+
}) => Promise<DropboxImportResult | {
|
|
1828
|
+
error: string;
|
|
1829
|
+
}>;
|
|
1830
|
+
/** Whether Dropbox is configured */
|
|
1831
|
+
isConfigured: boolean;
|
|
1832
|
+
/** Whether user has a Dropbox token */
|
|
1833
|
+
isAuthenticated: boolean;
|
|
1834
|
+
}
|
|
1835
|
+
/**
|
|
1836
|
+
* React hook for Dropbox backup and restore functionality.
|
|
1837
|
+
*
|
|
1838
|
+
* This hook provides methods to backup conversations to Dropbox and restore them.
|
|
1839
|
+
* It handles all the logic for checking timestamps, skipping unchanged files,
|
|
1840
|
+
* authentication, and managing the backup/restore process.
|
|
1841
|
+
*
|
|
1842
|
+
* Must be used within a DropboxAuthProvider.
|
|
1843
|
+
*
|
|
1844
|
+
* @example
|
|
1845
|
+
* ```tsx
|
|
1846
|
+
* import { useDropboxBackup } from "@reverbia/sdk/react";
|
|
1847
|
+
*
|
|
1848
|
+
* function BackupButton() {
|
|
1849
|
+
* const { backup, restore, isConfigured } = useDropboxBackup({
|
|
1850
|
+
* database,
|
|
1851
|
+
* userAddress,
|
|
1852
|
+
* requestEncryptionKey,
|
|
1853
|
+
* exportConversation,
|
|
1854
|
+
* importConversation,
|
|
1855
|
+
* });
|
|
1856
|
+
*
|
|
1857
|
+
* const handleBackup = async () => {
|
|
1858
|
+
* const result = await backup({
|
|
1859
|
+
* onProgress: (current, total) => {
|
|
1860
|
+
* console.log(`Progress: ${current}/${total}`);
|
|
1861
|
+
* },
|
|
1862
|
+
* });
|
|
1863
|
+
*
|
|
1864
|
+
* if ("error" in result) {
|
|
1865
|
+
* console.error(result.error);
|
|
1866
|
+
* } else {
|
|
1867
|
+
* console.log(`Uploaded: ${result.uploaded}, Skipped: ${result.skipped}`);
|
|
1868
|
+
* }
|
|
1869
|
+
* };
|
|
1870
|
+
*
|
|
1871
|
+
* return <button onClick={handleBackup} disabled={!isConfigured}>Backup</button>;
|
|
1872
|
+
* }
|
|
1873
|
+
* ```
|
|
1874
|
+
*
|
|
1875
|
+
* @category Hooks
|
|
1876
|
+
*/
|
|
1877
|
+
declare function useDropboxBackup(options: UseDropboxBackupOptions): UseDropboxBackupResult;
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* Dropbox OAuth 2.0 with PKCE
|
|
1881
|
+
*
|
|
1882
|
+
* Flow:
|
|
1883
|
+
* 1. Generate code_verifier and code_challenge
|
|
1884
|
+
* 2. Redirect user to Dropbox authorization URL
|
|
1885
|
+
* 3. User authorizes and is redirected back with authorization code
|
|
1886
|
+
* 4. Exchange code for access token using code_verifier
|
|
1887
|
+
*/
|
|
1888
|
+
/**
|
|
1889
|
+
* Get the stored access token from session storage
|
|
1890
|
+
*/
|
|
1891
|
+
declare function getStoredToken(): string | null;
|
|
1892
|
+
/**
|
|
1893
|
+
* Store access token in session storage
|
|
1894
|
+
*/
|
|
1895
|
+
declare function storeToken(token: string): void;
|
|
1896
|
+
/**
|
|
1897
|
+
* Clear stored access token
|
|
1898
|
+
*/
|
|
1899
|
+
declare function clearToken(): void;
|
|
1900
|
+
|
|
1901
|
+
/**
|
|
1902
|
+
* Props for DropboxAuthProvider
|
|
1903
|
+
*/
|
|
1904
|
+
interface DropboxAuthProviderProps {
|
|
1905
|
+
/** Dropbox App Key (from Dropbox Developer Console) */
|
|
1906
|
+
appKey: string | undefined;
|
|
1907
|
+
/** OAuth callback path (e.g., "/auth/dropbox/callback") */
|
|
1908
|
+
callbackPath?: string;
|
|
1909
|
+
/** Children to render */
|
|
1910
|
+
children: ReactNode;
|
|
1911
|
+
}
|
|
1912
|
+
/**
|
|
1913
|
+
* Context value for Dropbox authentication
|
|
1914
|
+
*/
|
|
1915
|
+
interface DropboxAuthContextValue {
|
|
1916
|
+
/** Current access token (null if not authenticated) */
|
|
1917
|
+
accessToken: string | null;
|
|
1918
|
+
/** Whether user has authenticated with Dropbox */
|
|
1919
|
+
isAuthenticated: boolean;
|
|
1920
|
+
/** Whether Dropbox is configured (app key exists) */
|
|
1921
|
+
isConfigured: boolean;
|
|
1922
|
+
/** Request Dropbox access - returns token or redirects to OAuth */
|
|
1923
|
+
requestAccess: () => Promise<string>;
|
|
1924
|
+
/** Clear stored token and log out */
|
|
1925
|
+
logout: () => void;
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Provider component for Dropbox OAuth authentication.
|
|
1929
|
+
*
|
|
1930
|
+
* Wrap your app with this provider to enable Dropbox authentication.
|
|
1931
|
+
* It handles the OAuth 2.0 PKCE flow automatically.
|
|
1932
|
+
*
|
|
1933
|
+
* @example
|
|
1934
|
+
* ```tsx
|
|
1935
|
+
* import { DropboxAuthProvider } from "@reverbia/sdk/react";
|
|
1936
|
+
*
|
|
1937
|
+
* function App() {
|
|
1938
|
+
* return (
|
|
1939
|
+
* <DropboxAuthProvider
|
|
1940
|
+
* appKey={process.env.NEXT_PUBLIC_DROPBOX_APP_KEY}
|
|
1941
|
+
* callbackPath="/auth/dropbox/callback"
|
|
1942
|
+
* >
|
|
1943
|
+
* <MyApp />
|
|
1944
|
+
* </DropboxAuthProvider>
|
|
1945
|
+
* );
|
|
1946
|
+
* }
|
|
1947
|
+
* ```
|
|
1948
|
+
*
|
|
1949
|
+
* @category Components
|
|
1950
|
+
*/
|
|
1951
|
+
declare function DropboxAuthProvider({ appKey, callbackPath, children, }: DropboxAuthProviderProps): JSX.Element;
|
|
1952
|
+
/**
|
|
1953
|
+
* Hook to access Dropbox authentication state and methods.
|
|
1954
|
+
*
|
|
1955
|
+
* Must be used within a DropboxAuthProvider.
|
|
1956
|
+
*
|
|
1957
|
+
* @example
|
|
1958
|
+
* ```tsx
|
|
1959
|
+
* import { useDropboxAuth } from "@reverbia/sdk/react";
|
|
1960
|
+
*
|
|
1961
|
+
* function DropboxButton() {
|
|
1962
|
+
* const { isAuthenticated, isConfigured, requestAccess, logout } = useDropboxAuth();
|
|
1963
|
+
*
|
|
1964
|
+
* if (!isConfigured) {
|
|
1965
|
+
* return <p>Dropbox not configured</p>;
|
|
1966
|
+
* }
|
|
1967
|
+
*
|
|
1968
|
+
* if (isAuthenticated) {
|
|
1969
|
+
* return <button onClick={logout}>Disconnect Dropbox</button>;
|
|
1970
|
+
* }
|
|
1971
|
+
*
|
|
1972
|
+
* return <button onClick={requestAccess}>Connect Dropbox</button>;
|
|
1973
|
+
* }
|
|
1974
|
+
* ```
|
|
1975
|
+
*
|
|
1976
|
+
* @category Hooks
|
|
1977
|
+
*/
|
|
1978
|
+
declare function useDropboxAuth(): DropboxAuthContextValue;
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* Google Drive API utilities
|
|
1982
|
+
*
|
|
1983
|
+
* Uses Google Drive API v3 for file operations.
|
|
1984
|
+
* Requires an OAuth 2.0 access token with drive.file scope.
|
|
1985
|
+
*/
|
|
1986
|
+
/** Default root folder name for backups */
|
|
1987
|
+
declare const DEFAULT_ROOT_FOLDER = "ai-chat-app";
|
|
1988
|
+
/** Default subfolder for conversation backups */
|
|
1989
|
+
declare const DEFAULT_CONVERSATIONS_FOLDER = "conversations";
|
|
1990
|
+
|
|
1991
|
+
/**
|
|
1992
|
+
* Google Drive Backup Implementation
|
|
1993
|
+
*
|
|
1994
|
+
* Generic backup/restore functionality for Google Drive storage.
|
|
1995
|
+
* Works directly with WatermelonDB database.
|
|
1996
|
+
*/
|
|
1997
|
+
|
|
1998
|
+
interface GoogleDriveExportResult {
|
|
1999
|
+
success: boolean;
|
|
2000
|
+
uploaded: number;
|
|
2001
|
+
skipped: number;
|
|
2002
|
+
total: number;
|
|
2003
|
+
}
|
|
2004
|
+
interface GoogleDriveImportResult {
|
|
2005
|
+
success: boolean;
|
|
2006
|
+
restored: number;
|
|
2007
|
+
failed: number;
|
|
2008
|
+
total: number;
|
|
2009
|
+
/** True if no backups were found in Google Drive */
|
|
2010
|
+
noBackupsFound?: boolean;
|
|
2011
|
+
}
|
|
2012
|
+
|
|
2013
|
+
/**
|
|
2014
|
+
* Options for useGoogleDriveBackup hook
|
|
2015
|
+
*/
|
|
2016
|
+
interface UseGoogleDriveBackupOptions {
|
|
2017
|
+
/** WatermelonDB database instance */
|
|
2018
|
+
database: Database;
|
|
2019
|
+
/** Current user address (null if not signed in) */
|
|
2020
|
+
userAddress: string | null;
|
|
2021
|
+
/** Current Google Drive access token (null if not authenticated) */
|
|
2022
|
+
accessToken: string | null;
|
|
2023
|
+
/** Request Google Drive access - returns access token */
|
|
2024
|
+
requestDriveAccess: () => Promise<string>;
|
|
2025
|
+
/** Request encryption key for the user address */
|
|
2026
|
+
requestEncryptionKey: (address: string) => Promise<void>;
|
|
2027
|
+
/** Export a conversation to an encrypted blob */
|
|
2028
|
+
exportConversation: (conversationId: string, userAddress: string) => Promise<{
|
|
2029
|
+
success: boolean;
|
|
2030
|
+
blob?: Blob;
|
|
2031
|
+
}>;
|
|
2032
|
+
/** Import a conversation from an encrypted blob */
|
|
2033
|
+
importConversation: (blob: Blob, userAddress: string) => Promise<{
|
|
2034
|
+
success: boolean;
|
|
2035
|
+
}>;
|
|
2036
|
+
/** Root folder name in Google Drive (default: 'ai-chat-app') */
|
|
2037
|
+
rootFolder?: string;
|
|
2038
|
+
/** Subfolder for conversations (default: 'conversations') */
|
|
2039
|
+
conversationsFolder?: string;
|
|
2040
|
+
}
|
|
2041
|
+
/**
|
|
2042
|
+
* Result returned by useGoogleDriveBackup hook
|
|
2043
|
+
*/
|
|
2044
|
+
interface UseGoogleDriveBackupResult {
|
|
2045
|
+
/** Backup all conversations to Google Drive */
|
|
2046
|
+
backup: (options?: {
|
|
2047
|
+
onProgress?: (current: number, total: number) => void;
|
|
2048
|
+
}) => Promise<GoogleDriveExportResult | {
|
|
2049
|
+
error: string;
|
|
2050
|
+
}>;
|
|
2051
|
+
/** Restore conversations from Google Drive */
|
|
2052
|
+
restore: (options?: {
|
|
2053
|
+
onProgress?: (current: number, total: number) => void;
|
|
2054
|
+
}) => Promise<GoogleDriveImportResult | {
|
|
2055
|
+
error: string;
|
|
2056
|
+
}>;
|
|
2057
|
+
/** Whether user has a Google Drive token */
|
|
2058
|
+
isAuthenticated: boolean;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* React hook for Google Drive backup and restore functionality.
|
|
2062
|
+
*
|
|
2063
|
+
* This hook provides methods to backup conversations to Google Drive and restore them.
|
|
2064
|
+
* It handles all the logic for checking timestamps, skipping unchanged files,
|
|
2065
|
+
* and managing the backup/restore process.
|
|
2066
|
+
*
|
|
2067
|
+
* Unlike Dropbox, Google Drive auth requires browser-specific setup (Google Identity Services),
|
|
2068
|
+
* so the auth provider must be implemented in the app. This hook accepts the auth
|
|
2069
|
+
* callbacks as options.
|
|
2070
|
+
*
|
|
2071
|
+
* @example
|
|
2072
|
+
* ```tsx
|
|
2073
|
+
* import { useGoogleDriveBackup } from "@reverbia/sdk/react";
|
|
2074
|
+
*
|
|
2075
|
+
* function BackupButton() {
|
|
2076
|
+
* const { accessToken, requestDriveAccess } = useGoogleAccessToken();
|
|
2077
|
+
* const { backup, restore, isAuthenticated } = useGoogleDriveBackup({
|
|
2078
|
+
* database,
|
|
2079
|
+
* userAddress,
|
|
2080
|
+
* accessToken,
|
|
2081
|
+
* requestDriveAccess,
|
|
2082
|
+
* requestEncryptionKey,
|
|
2083
|
+
* exportConversation,
|
|
2084
|
+
* importConversation,
|
|
2085
|
+
* });
|
|
2086
|
+
*
|
|
2087
|
+
* const handleBackup = async () => {
|
|
2088
|
+
* const result = await backup({
|
|
2089
|
+
* onProgress: (current, total) => {
|
|
2090
|
+
* console.log(`Progress: ${current}/${total}`);
|
|
2091
|
+
* },
|
|
2092
|
+
* });
|
|
2093
|
+
*
|
|
2094
|
+
* if ("error" in result) {
|
|
2095
|
+
* console.error(result.error);
|
|
2096
|
+
* } else {
|
|
2097
|
+
* console.log(`Uploaded: ${result.uploaded}, Skipped: ${result.skipped}`);
|
|
2098
|
+
* }
|
|
2099
|
+
* };
|
|
2100
|
+
*
|
|
2101
|
+
* return <button onClick={handleBackup}>Backup</button>;
|
|
2102
|
+
* }
|
|
2103
|
+
* ```
|
|
2104
|
+
*
|
|
2105
|
+
* @category Hooks
|
|
2106
|
+
*/
|
|
2107
|
+
declare function useGoogleDriveBackup(options: UseGoogleDriveBackupOptions): UseGoogleDriveBackupResult;
|
|
2108
|
+
|
|
2109
|
+
export { Conversation as ChatConversation, Message as ChatMessage, type ChatRole, type ClientTool, type CreateConversationOptions, type CreateMemoryOptions, type CreateMessageOptions, type CreateModelPreferenceOptions, DEFAULT_BACKUP_FOLDER, DEFAULT_CONVERSATIONS_FOLDER as DEFAULT_DRIVE_CONVERSATIONS_FOLDER, DEFAULT_ROOT_FOLDER as DEFAULT_DRIVE_ROOT_FOLDER, DEFAULT_TOOL_SELECTOR_MODEL, type DropboxAuthContextValue, DropboxAuthProvider, type DropboxAuthProviderProps, type DropboxExportResult, type DropboxImportResult, type FileMetadata, type GoogleDriveExportResult, type GoogleDriveImportResult, type MemoryItem, type MemoryType, type OCRFile, type PdfFile, type SearchMessagesOptions, type SearchSource, type SendMessageWithStorageArgs, type SendMessageWithStorageResult, type SignMessageFn, type ChatCompletionUsage as StoredChatCompletionUsage, type StoredConversation, type StoredMemory, Memory as StoredMemoryModel, type StoredMemoryWithSimilarity, type StoredMessage, type StoredMessageWithSimilarity, type StoredModelPreference, ModelPreference as StoredModelPreferenceModel, type ToolExecutionResult, type ToolParameter, type ToolSelectionResult, type UpdateMemoryOptions, type UpdateModelPreferenceOptions, type UseChatStorageOptions, type UseChatStorageResult, type UseDropboxBackupOptions, type UseDropboxBackupResult, type UseGoogleDriveBackupOptions, type UseGoogleDriveBackupResult, type UseMemoryStorageOptions, type UseMemoryStorageResult, type UseSettingsOptions, type UseSettingsResult, chatStorageMigrations, chatStorageSchema, clearToken as clearDropboxToken, createMemoryContextSystemMessage, decryptData, decryptDataBytes, encryptData, executeTool, extractConversationContext, formatMemoriesForChat, generateCompositeKey, generateConversationId, generateUniqueKey, getStoredToken as getDropboxToken, hasEncryptionKey, memoryStorageSchema, requestEncryptionKey, selectTool, settingsStorageSchema, storeToken as storeDropboxToken, useChat, useChatStorage, useDropboxAuth, useDropboxBackup, useEncryption, useGoogleDriveBackup, useImageGeneration, useMemoryStorage, useModels, useOCR, usePdf, useSearch, useSettings };
|