@blinkdotnew/sdk 0.18.8 → 0.19.1

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,10 +1,84 @@
1
+ /**
2
+ * Storage adapter for cross-platform compatibility
3
+ * Allows using AsyncStorage on React Native and localStorage on web
4
+ */
5
+ /**
6
+ * Storage adapter interface
7
+ * Supports both synchronous (web localStorage) and asynchronous (React Native AsyncStorage) implementations
8
+ */
9
+ interface StorageAdapter {
10
+ getItem(key: string): Promise<string | null> | string | null;
11
+ setItem(key: string, value: string): Promise<void> | void;
12
+ removeItem(key: string): Promise<void> | void;
13
+ clear(): Promise<void> | void;
14
+ }
15
+ /**
16
+ * Web localStorage adapter (synchronous)
17
+ * Used automatically on web browsers
18
+ */
19
+ declare class WebStorageAdapter implements StorageAdapter {
20
+ getItem(key: string): string | null;
21
+ setItem(key: string, value: string): void;
22
+ removeItem(key: string): void;
23
+ clear(): void;
24
+ }
25
+ /**
26
+ * Async storage adapter wrapper (for React Native AsyncStorage)
27
+ * Usage:
28
+ * ```typescript
29
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
30
+ * const storage = new AsyncStorageAdapter(AsyncStorage)
31
+ * ```
32
+ */
33
+ declare class AsyncStorageAdapter implements StorageAdapter {
34
+ private asyncStorage;
35
+ constructor(asyncStorage: any);
36
+ getItem(key: string): Promise<string | null>;
37
+ setItem(key: string, value: string): Promise<void>;
38
+ removeItem(key: string): Promise<void>;
39
+ clear(): Promise<void>;
40
+ }
41
+ /**
42
+ * No-op storage adapter (for server-side or when storage is disabled)
43
+ * Used automatically on Node.js or when no storage is available
44
+ */
45
+ declare class NoOpStorageAdapter implements StorageAdapter {
46
+ getItem(_key: string): null;
47
+ setItem(_key: string, _value: string): void;
48
+ removeItem(_key: string): void;
49
+ clear(): void;
50
+ }
51
+ /**
52
+ * Get default storage adapter based on platform
53
+ */
54
+ declare function getDefaultStorageAdapter(): StorageAdapter;
55
+
1
56
  /**
2
57
  * Core type definitions for Blink SDK
3
58
  */
59
+
4
60
  interface BlinkClientConfig {
5
61
  projectId: string;
6
62
  authRequired?: boolean;
7
63
  auth?: BlinkAuthConfig;
64
+ /**
65
+ * Storage adapter for cross-platform token persistence
66
+ *
67
+ * Web: Uses localStorage by default
68
+ * React Native: Pass AsyncStorageAdapter(AsyncStorage)
69
+ * Node.js: Uses NoOpStorageAdapter by default
70
+ *
71
+ * @example
72
+ * // React Native
73
+ * import AsyncStorage from '@react-native-async-storage/async-storage'
74
+ * import { AsyncStorageAdapter } from '@blinkdotnew/sdk'
75
+ *
76
+ * const blink = createClient({
77
+ * projectId: 'your-project',
78
+ * storage: new AsyncStorageAdapter(AsyncStorage)
79
+ * })
80
+ */
81
+ storage?: StorageAdapter;
8
82
  }
9
83
  interface BlinkAuthConfig {
10
84
  mode?: 'managed' | 'headless';
@@ -34,6 +108,11 @@ interface BlinkAuthConfig {
34
108
  redirectUrl?: string;
35
109
  authUrl?: string;
36
110
  coreUrl?: string;
111
+ /**
112
+ * Storage adapter for auth token persistence (overrides global storage)
113
+ * If not provided, uses the global storage from BlinkClientConfig
114
+ */
115
+ storage?: StorageAdapter;
37
116
  }
38
117
  type AuthProvider = 'email' | 'google' | 'github' | 'apple' | 'microsoft' | 'twitter' | 'linkedin' | 'discord';
39
118
  interface AuthOptions {
@@ -808,6 +887,23 @@ declare class HttpClient {
808
887
  private parseDataStream;
809
888
  }
810
889
 
890
+ /**
891
+ * Platform detection for cross-platform compatibility
892
+ * Detects whether code is running on web, React Native, or Node.js
893
+ */
894
+ type Platform = 'web' | 'react-native' | 'node';
895
+ /**
896
+ * Current platform
897
+ */
898
+ declare const platform: Platform;
899
+ /**
900
+ * Platform detection helpers
901
+ */
902
+ declare const isWeb: boolean;
903
+ declare const isReactNative: boolean;
904
+ declare const isNode: boolean;
905
+ declare const isBrowser: boolean;
906
+
811
907
  /**
812
908
  * Blink Auth Module - Client-side authentication management
813
909
  * Handles token storage, user state, and authentication flows
@@ -825,6 +921,7 @@ declare class BlinkAuth {
825
921
  private isIframe;
826
922
  private initializationPromise;
827
923
  private isInitialized;
924
+ private storage;
828
925
  constructor(config: BlinkClientConfig);
829
926
  /**
830
927
  * Generate project-scoped storage key
@@ -1636,55 +1733,99 @@ declare class BlinkAIImpl implements BlinkAI {
1636
1733
  */
1637
1734
  streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
1638
1735
  /**
1639
- * Generates images from text descriptions using Gemini 2.5 Flash Image.
1736
+ * Generates images from text descriptions using AI image models.
1640
1737
  *
1641
1738
  * @param options - Object containing:
1642
1739
  * - `prompt`: Text description of the desired image (required, up to 100k characters)
1740
+ * - `model`: AI model to use (optional). Available models:
1741
+ * **Fal.ai Models (Recommended):**
1742
+ * - `"fal-ai/nano-banana"` (default) - Gemini 2.5 Flash Image (Fast)
1743
+ * - `"fal-ai/nano-banana-pro"` - Gemini 3 Pro Image (High quality)
1744
+ * - `"fal-ai/gemini-25-flash-image"` - Alias for nano-banana
1745
+ * - `"fal-ai/gemini-3-pro-image-preview"` - Alias for nano-banana-pro
1746
+ * **Legacy Gemini Models:**
1747
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1748
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1643
1749
  * - `n`: Number of images to generate (default: 1)
1750
+ * - `size`: Image dimensions (e.g., "1024x1024", "512x512")
1644
1751
  * - Plus optional signal parameter
1645
1752
  *
1646
1753
  * @example
1647
1754
  * ```ts
1648
- * // Basic image generation
1755
+ * // Basic image generation (uses default fast model)
1649
1756
  * const { data } = await blink.ai.generateImage({
1650
1757
  * prompt: "A serene landscape with mountains and a lake at sunset"
1651
1758
  * });
1652
1759
  * console.log("Image URL:", data[0].url);
1653
1760
  *
1654
- * // Multiple images
1761
+ * // High quality generation with Pro model
1762
+ * const { data } = await blink.ai.generateImage({
1763
+ * prompt: "A detailed infographic about AI with charts and diagrams",
1764
+ * model: "fal-ai/nano-banana-pro",
1765
+ * n: 2
1766
+ * });
1767
+ *
1768
+ * // Fast generation with specific size
1655
1769
  * const { data } = await blink.ai.generateImage({
1656
1770
  * prompt: "A futuristic city skyline with flying cars",
1771
+ * model: "fal-ai/nano-banana",
1772
+ * size: "1024x1024",
1657
1773
  * n: 3
1658
1774
  * });
1659
1775
  * data.forEach((img, i) => console.log(`Image ${i+1}:`, img.url));
1660
1776
  *
1661
- * // Detailed prompt for better results
1777
+ * // Using legacy Gemini model
1662
1778
  * const { data } = await blink.ai.generateImage({
1663
- * prompt: "A cute robot mascot for a tech company, digital art style, vibrant colors, modern design, friendly expression"
1779
+ * prompt: "A cute robot mascot for a tech company",
1780
+ * model: "gemini-2.5-flash-image-preview"
1664
1781
  * });
1665
1782
  * ```
1666
1783
  *
1667
1784
  * @returns Promise<ImageGenerationResponse> - Object containing:
1668
1785
  * - `data`: Array of generated images with URLs
1669
1786
  * - `created`: Timestamp of generation
1670
- * - `model`: Always "gemini-2.5-flash-image-preview"
1787
+ * - `model`: The model used for generation
1671
1788
  */
1672
1789
  generateImage(options: {
1673
1790
  prompt: string;
1791
+ model?: string;
1674
1792
  n?: number;
1793
+ size?: string;
1675
1794
  signal?: AbortSignal;
1676
1795
  }): Promise<ImageGenerationResponse>;
1677
1796
  /**
1678
- * Modifies existing images using Gemini 2.5 Flash Image with text prompts for image-to-image editing.
1797
+ * Modifies existing images using AI image editing models with text prompts for image-to-image editing.
1679
1798
  *
1680
1799
  * @param options - Object containing:
1681
1800
  * - `images`: Array of public image URLs to modify (required, up to 50 images)
1682
1801
  * - `prompt`: Text description of desired modifications (required, up to 100k characters)
1802
+ * - `model`: AI model to use (optional). Available editing models:
1803
+ * **Fal.ai Editing Models (Recommended):**
1804
+ * - `"fal-ai/nano-banana/edit"` (default) - Flash editing (Fast)
1805
+ * - `"fal-ai/nano-banana-pro/edit"` - Pro editing (High quality)
1806
+ * - `"fal-ai/gemini-25-flash-image/edit"` - Alias for nano-banana/edit
1807
+ * - `"fal-ai/gemini-3-pro-image-preview/edit"` - Alias for nano-banana-pro/edit
1808
+ * **Legacy Gemini Models:**
1809
+ * - `"gemini-2.5-flash-image-preview"` - Direct Gemini API
1810
+ * - `"gemini-3-pro-image-preview"` - Direct Gemini API
1683
1811
  * - `n`: Number of output images to generate (default: 1)
1684
1812
  * - Plus optional signal parameter
1685
1813
  *
1686
1814
  * @example
1687
1815
  * ```ts
1816
+ * // Fast editing with default model
1817
+ * const { data } = await blink.ai.modifyImage({
1818
+ * images: ["https://storage.example.com/photo.jpg"],
1819
+ * prompt: "make it green"
1820
+ * });
1821
+ *
1822
+ * // High quality editing with Pro model
1823
+ * const { data } = await blink.ai.modifyImage({
1824
+ * images: ["https://storage.example.com/landscape.jpg"],
1825
+ * prompt: "add a tree in the background",
1826
+ * model: "fal-ai/nano-banana-pro/edit"
1827
+ * });
1828
+ *
1688
1829
  * // Professional headshots from casual photos
1689
1830
  * const { data } = await blink.ai.modifyImage({
1690
1831
  * images: [
@@ -1692,6 +1833,7 @@ declare class BlinkAIImpl implements BlinkAI {
1692
1833
  * "https://storage.example.com/user-photo-2.jpg"
1693
1834
  * ],
1694
1835
  * prompt: "Transform into professional business headshots with studio lighting",
1836
+ * model: "fal-ai/nano-banana/edit",
1695
1837
  * n: 4
1696
1838
  * });
1697
1839
  * data.forEach((img, i) => console.log(`Headshot ${i+1}:`, img.url));
@@ -1699,7 +1841,8 @@ declare class BlinkAIImpl implements BlinkAI {
1699
1841
  * // Artistic style transformation
1700
1842
  * const { data } = await blink.ai.modifyImage({
1701
1843
  * images: ["https://storage.example.com/portrait.jpg"],
1702
- * prompt: "Transform into oil painting style with dramatic lighting"
1844
+ * prompt: "Transform into oil painting style with dramatic lighting",
1845
+ * model: "fal-ai/nano-banana-pro/edit"
1703
1846
  * });
1704
1847
  *
1705
1848
  * // Background replacement
@@ -1737,11 +1880,12 @@ declare class BlinkAIImpl implements BlinkAI {
1737
1880
  * @returns Promise<ImageGenerationResponse> - Object containing:
1738
1881
  * - `data`: Array of modified images with URLs
1739
1882
  * - `created`: Timestamp of generation
1740
- * - `model`: Always "gemini-2.5-flash-image-preview"
1883
+ * - `model`: The model used for editing
1741
1884
  */
1742
1885
  modifyImage(options: {
1743
1886
  images: string[];
1744
1887
  prompt: string;
1888
+ model?: string;
1745
1889
  n?: number;
1746
1890
  signal?: AbortSignal;
1747
1891
  }): Promise<ImageGenerationResponse>;
@@ -1920,4 +2064,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
1920
2064
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
1921
2065
  }
1922
2066
 
1923
- export { type AnalyticsEvent, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, createClient };
2067
+ export { type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type CreateOptions, type DataExtraction, type FileObject, type FilterCondition, type ImageGenerationRequest, type ImageGenerationResponse, type Message, NoOpStorageAdapter, type ObjectGenerationRequest, type ObjectGenerationResponse, type PresenceUser, type QueryOptions, type RealtimeChannel, type RealtimeGetMessagesOptions, type RealtimeMessage, type RealtimePublishOptions, type RealtimeSubscribeOptions, type SearchRequest, type SearchResponse, type SpeechGenerationRequest, type SpeechGenerationResponse, type StorageAdapter, type StorageUploadOptions, type StorageUploadResponse, type TableOperations, type TextGenerationRequest, type TextGenerationResponse, type TokenUsage, type TranscriptionRequest, type TranscriptionResponse, type UpdateOptions, type UpsertOptions, WebStorageAdapter, createClient, getDefaultStorageAdapter, isBrowser, isNode, isReactNative, isWeb, platform };