@blinkdotnew/dev-sdk 2.1.6 → 2.1.8

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.mts CHANGED
@@ -61,39 +61,6 @@ interface BlinkClientConfig {
61
61
  projectId: string;
62
62
  authRequired?: boolean;
63
63
  auth?: BlinkAuthConfig;
64
- /**
65
- * Publishable key (client-safe).
66
- *
67
- * Used for **public endpoints** when no user JWT is present (e.g. analytics ingest, storage upload,
68
- * optional public DB reads). Never use for privileged operations.
69
- */
70
- publishableKey?: string;
71
- /**
72
- * Secret key (server-only, privileged). Permanent, never expires.
73
- *
74
- * Used in **server runtimes** (Edge Functions, Workers) for privileged operations that require
75
- * service-role access (e.g. raw SQL, bypassing row-level security).
76
- *
77
- * Format: `blnk_sk_{projectId-last-8}_{random}` (similar to Stripe's `sk_live_...`)
78
- *
79
- * **Security**: Never expose this key in client-side code. It is injected by the platform
80
- * into edge function environments as `BLINK_SECRET_KEY`.
81
- *
82
- * When present, this key takes precedence over user JWTs for all requests.
83
- *
84
- * @example
85
- * // Edge function (Deno)
86
- * const blink = createClient({
87
- * projectId: Deno.env.get('BLINK_PROJECT_ID')!,
88
- * secretKey: Deno.env.get('BLINK_SECRET_KEY'),
89
- * })
90
- */
91
- secretKey?: string;
92
- /**
93
- * @deprecated Use `secretKey` instead. Service tokens are JWT-based and expire after 365 days.
94
- * Secret keys are permanent and never expire.
95
- */
96
- serviceToken?: string;
97
64
  /**
98
65
  * Storage adapter for cross-platform token persistence
99
66
  *
@@ -314,9 +281,6 @@ declare class BlinkError extends Error {
314
281
  constructor(message: string, code?: string | undefined, status?: number | undefined, details?: any);
315
282
  }
316
283
  interface StorageUploadOptions {
317
- /**
318
- * @deprecated Blink storage uploads are add-only by default. This option is ignored.
319
- */
320
284
  upsert?: boolean;
321
285
  onProgress?: (percent: number) => void;
322
286
  }
@@ -481,45 +445,6 @@ interface TranscriptionRequest {
481
445
  response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
482
446
  signal?: AbortSignal;
483
447
  }
484
- interface VideoGenerationRequest {
485
- prompt: string;
486
- model?: string;
487
- image_url?: string;
488
- duration?: string;
489
- aspect_ratio?: string;
490
- resolution?: string;
491
- negative_prompt?: string;
492
- generate_audio?: boolean;
493
- seed?: number;
494
- cfg_scale?: number;
495
- signal?: AbortSignal;
496
- }
497
- interface VideoGenerationResponse {
498
- result: {
499
- video: {
500
- url: string;
501
- content_type?: string;
502
- file_name?: string;
503
- file_size?: number;
504
- };
505
- seed?: number;
506
- video_id?: string;
507
- thumbnail?: {
508
- url: string;
509
- };
510
- };
511
- metadata?: {
512
- projectId: string;
513
- timestamp: string;
514
- provider: string;
515
- model: string;
516
- };
517
- usage?: {
518
- creditsCharged: number;
519
- costUSD: number;
520
- model: string;
521
- };
522
- }
523
448
  interface TranscriptionResponse {
524
449
  text: string;
525
450
  transcript?: string;
@@ -558,7 +483,6 @@ interface BlinkAI {
558
483
  background?: "auto" | "transparent" | "opaque";
559
484
  signal?: AbortSignal;
560
485
  }): Promise<ImageGenerationResponse>;
561
- generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
562
486
  generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
563
487
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
564
488
  }
@@ -807,61 +731,13 @@ interface BlinkNotifications {
807
731
  email(params: SendEmailRequest): Promise<SendEmailResponse>;
808
732
  }
809
733
 
810
- type ConnectorProvider = 'discord' | 'notion' | 'google_drive' | 'google_calendar' | 'ai';
811
- type ConnectorAuthMode = 'oauth' | 'api_key' | 'blink_managed' | 'hybrid';
812
- interface ConnectorStatusData {
813
- connected: boolean;
814
- provider: ConnectorProvider;
815
- auth_mode?: ConnectorAuthMode;
816
- account_id?: string;
817
- metadata?: Record<string, unknown>;
818
- expires_at?: any;
819
- scopes?: string[];
820
- }
821
- interface ConnectorStatusResponse {
822
- success: boolean;
823
- data: ConnectorStatusData;
824
- }
825
- interface ConnectorExecuteRequest<TParams = Record<string, unknown>> {
826
- method: string;
827
- params?: TParams;
828
- account_id?: string;
829
- http_method?: string;
830
- }
831
- interface ConnectorExecuteResponse<TData = any> {
832
- success: boolean;
833
- data: TData;
834
- }
835
- interface ConnectorApiKeyRequest<TMetadata = Record<string, unknown>> {
836
- api_key: string;
837
- account_id?: string;
838
- metadata?: TMetadata;
839
- }
840
- interface ConnectorApiKeyResponse {
841
- success: boolean;
842
- data: {
843
- id: string;
844
- account_id?: string;
845
- };
846
- }
847
- interface BlinkConnectors {
848
- status(provider: ConnectorProvider, options?: {
849
- account_id?: string;
850
- }): Promise<ConnectorStatusResponse>;
851
- execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
852
- saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
853
- }
854
- declare class BlinkConnectorError extends BlinkError {
855
- constructor(message: string, status?: number, details?: any);
856
- }
857
-
858
734
  /**
859
735
  * HTTP client for Blink API requests
860
736
  * Handles authentication, error handling, and request/response processing
861
737
  */
862
738
 
863
739
  interface RequestOptions {
864
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
740
+ method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
865
741
  headers?: Record<string, string>;
866
742
  body?: any;
867
743
  searchParams?: Record<string, string>;
@@ -876,14 +752,9 @@ declare class HttpClient {
876
752
  private readonly authUrl;
877
753
  private readonly coreUrl;
878
754
  readonly projectId: string;
879
- private readonly publishableKey?;
880
- private readonly secretKey?;
881
755
  private getToken;
882
756
  private getValidToken?;
883
757
  constructor(config: BlinkClientConfig, getToken: () => string | null, getValidToken?: () => Promise<string | null>);
884
- private shouldAttachPublishableKey;
885
- private shouldSkipSecretKey;
886
- private getAuthorizationHeader;
887
758
  /**
888
759
  * Make an authenticated request to the Blink API
889
760
  */
@@ -965,7 +836,7 @@ declare class HttpClient {
965
836
  signal?: AbortSignal;
966
837
  }): Promise<BlinkResponse<any>>;
967
838
  /**
968
- * Stream AI text generation - uses Vercel AI SDK's pipeUIMessageStreamToResponse (Data Stream Protocol)
839
+ * Stream AI text generation with Vercel AI SDK data stream format
969
840
  */
970
841
  streamAiText(prompt: string, options: {
971
842
  model?: string | undefined;
@@ -989,7 +860,7 @@ declare class HttpClient {
989
860
  signal?: AbortSignal;
990
861
  }): Promise<BlinkResponse<any>>;
991
862
  /**
992
- * Stream AI object generation - uses Vercel AI SDK's pipeTextStreamToResponse
863
+ * Stream AI object generation with Vercel AI SDK data stream format
993
864
  */
994
865
  streamAiObject(prompt: string, options: {
995
866
  model?: string | undefined;
@@ -1024,18 +895,6 @@ declare class HttpClient {
1024
895
  response_format?: string;
1025
896
  signal?: AbortSignal;
1026
897
  }): Promise<BlinkResponse<any>>;
1027
- aiVideo(prompt: string, options?: {
1028
- model?: string;
1029
- image_url?: string;
1030
- duration?: string;
1031
- aspect_ratio?: string;
1032
- resolution?: string;
1033
- negative_prompt?: string;
1034
- generate_audio?: boolean;
1035
- seed?: number;
1036
- cfg_scale?: number;
1037
- signal?: AbortSignal;
1038
- }): Promise<BlinkResponse<any>>;
1039
898
  /**
1040
899
  * Data-specific requests
1041
900
  */
@@ -1045,13 +904,6 @@ declare class HttpClient {
1045
904
  dataScreenshot(projectId: string, request: ScreenshotRequest): Promise<BlinkResponse<ScreenshotResponse>>;
1046
905
  dataFetch(projectId: string, request: FetchRequest): Promise<BlinkResponse<FetchResponse | AsyncFetchResponse>>;
1047
906
  dataSearch(projectId: string, request: SearchRequest): Promise<BlinkResponse<SearchResponse>>;
1048
- /**
1049
- * Connector requests
1050
- */
1051
- private formatProviderForPath;
1052
- connectorStatus(provider: ConnectorProvider): Promise<BlinkResponse<ConnectorStatusResponse>>;
1053
- connectorExecute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<BlinkResponse<ConnectorExecuteResponse<TData>>>;
1054
- connectorSaveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<BlinkResponse<ConnectorApiKeyResponse>>;
1055
907
  /**
1056
908
  * Realtime-specific requests
1057
909
  */
@@ -1089,17 +941,17 @@ declare class HttpClient {
1089
941
  private parseResponse;
1090
942
  private handleErrorResponse;
1091
943
  /**
1092
- * Parse Vercel AI SDK v5 Data Stream Protocol (Server-Sent Events)
1093
- * Supports all event types from the UI Message Stream protocol
944
+ * Parse Vercel AI SDK data stream format
945
+ * Handles text chunks (0:"text"), partial objects (2:[...]), and metadata (d:, e:)
1094
946
  */
1095
- private parseDataStreamProtocol;
947
+ private parseDataStream;
1096
948
  }
1097
949
 
1098
950
  /**
1099
951
  * Platform detection for cross-platform compatibility
1100
- * Detects whether code is running on web, React Native, Node.js, or Deno
952
+ * Detects whether code is running on web, React Native, or Node.js
1101
953
  */
1102
- type Platform = 'web' | 'react-native' | 'node' | 'deno';
954
+ type Platform = 'web' | 'react-native' | 'node';
1103
955
  /**
1104
956
  * Current platform
1105
957
  */
@@ -1110,9 +962,7 @@ declare const platform: Platform;
1110
962
  declare const isWeb: boolean;
1111
963
  declare const isReactNative: boolean;
1112
964
  declare const isNode: boolean;
1113
- declare const isDeno: boolean;
1114
965
  declare const isBrowser: boolean;
1115
- declare const isServer: boolean;
1116
966
 
1117
967
  /**
1118
968
  * Blink Auth Module - Client-side authentication management
@@ -1783,50 +1633,6 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1783
1633
  private detectChannel;
1784
1634
  }
1785
1635
 
1786
- /**
1787
- * Blink Functions - Edge function invocation helper
1788
- * Provides a simple interface for calling Blink Edge Functions with automatic JWT attachment
1789
- */
1790
-
1791
- interface FunctionsInvokeOptions {
1792
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1793
- body?: any;
1794
- headers?: Record<string, string>;
1795
- searchParams?: Record<string, string>;
1796
- }
1797
- interface FunctionsInvokeResponse<T = any> {
1798
- data: T;
1799
- status: number;
1800
- headers: Headers;
1801
- }
1802
- interface BlinkFunctions {
1803
- /**
1804
- * Invoke a Blink Edge Function.
1805
- *
1806
- * Automatically attaches the user's JWT for authenticated requests.
1807
- * The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
1808
- *
1809
- * @param functionSlug - The slug of the edge function to invoke
1810
- * @param options - Request options (method, body, headers, etc.)
1811
- * @returns The function response
1812
- *
1813
- * @example
1814
- * // Simple POST request
1815
- * const { data } = await blink.functions.invoke('my-function', {
1816
- * method: 'POST',
1817
- * body: { message: 'Hello' }
1818
- * })
1819
- *
1820
- * @example
1821
- * // GET request with query params
1822
- * const { data } = await blink.functions.invoke('my-function', {
1823
- * method: 'GET',
1824
- * searchParams: { limit: '10' }
1825
- * })
1826
- */
1827
- invoke<T = any>(functionSlug: string, options?: FunctionsInvokeOptions): Promise<FunctionsInvokeResponse<T>>;
1828
- }
1829
-
1830
1636
  /**
1831
1637
  * Blink Client - Main SDK entry point
1832
1638
  * Factory function and client class for the Blink SDK
@@ -1841,8 +1647,6 @@ interface BlinkClient {
1841
1647
  realtime: BlinkRealtime;
1842
1648
  notifications: BlinkNotifications;
1843
1649
  analytics: BlinkAnalytics;
1844
- connectors: BlinkConnectors;
1845
- functions: BlinkFunctions;
1846
1650
  }
1847
1651
  /**
1848
1652
  * Create a new Blink client instance
@@ -2317,82 +2121,6 @@ declare class BlinkAIImpl implements BlinkAI {
2317
2121
  n?: number;
2318
2122
  signal?: AbortSignal;
2319
2123
  }): Promise<ImageGenerationResponse>;
2320
- /**
2321
- * Generates videos from text prompts or images using AI video generation models.
2322
- *
2323
- * @param options - Object containing:
2324
- * - `prompt`: Text description of the video to generate (required)
2325
- * - `model`: Video model to use (optional). Available models:
2326
- * **Text-to-Video Models:**
2327
- * - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
2328
- * - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
2329
- * - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
2330
- * - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
2331
- * **Image-to-Video Models:**
2332
- * - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
2333
- * - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
2334
- * - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
2335
- * - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
2336
- * - `image_url`: Source image URL for image-to-video (required for I2V models)
2337
- * - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
2338
- * - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
2339
- * - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
2340
- * - `negative_prompt`: What to avoid in generation - Veo/Kling only
2341
- * - `generate_audio`: Generate audio with video (default: true)
2342
- * - `seed`: For reproducibility - Veo only
2343
- * - `cfg_scale`: Guidance scale (0-1) - Kling only
2344
- * - Plus optional signal parameter
2345
- *
2346
- * @example
2347
- * ```ts
2348
- * // Basic text-to-video generation (uses default fast model)
2349
- * const { result } = await blink.ai.generateVideo({
2350
- * prompt: "A serene sunset over the ocean with gentle waves"
2351
- * });
2352
- * console.log("Video URL:", result.video.url);
2353
- *
2354
- * // High quality with Veo 3.1
2355
- * const { result } = await blink.ai.generateVideo({
2356
- * prompt: "A cinematic shot of a futuristic city at night",
2357
- * model: "fal-ai/veo3.1",
2358
- * resolution: "1080p",
2359
- * aspect_ratio: "16:9"
2360
- * });
2361
- *
2362
- * // Image-to-video animation
2363
- * const { result } = await blink.ai.generateVideo({
2364
- * prompt: "Animate this image with gentle camera movement",
2365
- * model: "fal-ai/veo3.1/fast/image-to-video",
2366
- * image_url: "https://example.com/my-image.jpg",
2367
- * duration: "5s"
2368
- * });
2369
- *
2370
- * // Using Sora 2 for creative videos
2371
- * const { result } = await blink.ai.generateVideo({
2372
- * prompt: "A magical forest with glowing fireflies",
2373
- * model: "fal-ai/sora-2/text-to-video/pro",
2374
- * duration: "8s"
2375
- * });
2376
- *
2377
- * // Using Kling for detailed videos
2378
- * const { result, usage } = await blink.ai.generateVideo({
2379
- * prompt: "A professional cooking tutorial scene",
2380
- * model: "fal-ai/kling-video/v2.6/pro/text-to-video",
2381
- * negative_prompt: "blur, distort, low quality",
2382
- * cfg_scale: 0.7
2383
- * });
2384
- * console.log("Credits charged:", usage?.creditsCharged);
2385
- * ```
2386
- *
2387
- * @returns Promise<VideoGenerationResponse> - Object containing:
2388
- * - `result.video.url`: URL to the generated video
2389
- * - `result.video.content_type`: MIME type (video/mp4)
2390
- * - `result.video.file_name`: Generated filename
2391
- * - `result.video.file_size`: File size in bytes
2392
- * - `metadata`: Generation metadata (projectId, timestamp, model)
2393
- * - `usage`: Credits charged and cost information
2394
- */
2395
- generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
2396
2124
  /**
2397
2125
  * Converts text to speech using AI voice synthesis models.
2398
2126
  *
@@ -2568,14 +2296,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
2568
2296
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
2569
2297
  }
2570
2298
 
2571
- declare class BlinkConnectorsImpl implements BlinkConnectors {
2572
- private httpClient;
2573
- constructor(httpClient: HttpClient);
2574
- status(provider: ConnectorProvider, options?: {
2575
- account_id?: string;
2576
- }): Promise<ConnectorStatusResponse>;
2577
- execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
2578
- saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
2579
- }
2580
-
2581
- export { type AnalyticsEvent, AsyncStorageAdapter, type AuthState, type AuthStateChangeCallback, type AuthTokens, type BlinkAI, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkClientConfig, BlinkConnectorError, type BlinkConnectors, BlinkConnectorsImpl, type BlinkData, BlinkDataImpl, BlinkDatabase, type BlinkRealtime, BlinkRealtimeChannel, BlinkRealtimeError, BlinkRealtimeImpl, type BlinkStorage, BlinkStorageImpl, BlinkTable, type BlinkUser, type ConnectorApiKeyRequest, type ConnectorApiKeyResponse, type ConnectorAuthMode, type ConnectorExecuteRequest, type ConnectorExecuteResponse, type ConnectorProvider, type ConnectorStatusResponse, 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, type WebBrowserModule, WebStorageAdapter, createClient, getDefaultStorageAdapter, isBrowser, isDeno, isNode, isReactNative, isServer, isWeb, platform };
2299
+ 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, type WebBrowserModule, WebStorageAdapter, createClient, getDefaultStorageAdapter, isBrowser, isNode, isReactNative, isWeb, platform };