@blinkdotnew/dev-sdk 2.1.5 → 2.1.7

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
@@ -1161,10 +1011,6 @@ declare class BlinkAuth {
1161
1011
  * Redirect to Blink auth page
1162
1012
  */
1163
1013
  login(nextUrl?: string): void;
1164
- /**
1165
- * Set up listener for tokens from parent window (for iframe OAuth delegation)
1166
- */
1167
- private setupParentTokenListener;
1168
1014
  /**
1169
1015
  * Logout and clear stored tokens
1170
1016
  */
@@ -1787,50 +1633,6 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
1787
1633
  private detectChannel;
1788
1634
  }
1789
1635
 
1790
- /**
1791
- * Blink Functions - Edge function invocation helper
1792
- * Provides a simple interface for calling Blink Edge Functions with automatic JWT attachment
1793
- */
1794
-
1795
- interface FunctionsInvokeOptions {
1796
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1797
- body?: any;
1798
- headers?: Record<string, string>;
1799
- searchParams?: Record<string, string>;
1800
- }
1801
- interface FunctionsInvokeResponse<T = any> {
1802
- data: T;
1803
- status: number;
1804
- headers: Headers;
1805
- }
1806
- interface BlinkFunctions {
1807
- /**
1808
- * Invoke a Blink Edge Function.
1809
- *
1810
- * Automatically attaches the user's JWT for authenticated requests.
1811
- * The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
1812
- *
1813
- * @param functionSlug - The slug of the edge function to invoke
1814
- * @param options - Request options (method, body, headers, etc.)
1815
- * @returns The function response
1816
- *
1817
- * @example
1818
- * // Simple POST request
1819
- * const { data } = await blink.functions.invoke('my-function', {
1820
- * method: 'POST',
1821
- * body: { message: 'Hello' }
1822
- * })
1823
- *
1824
- * @example
1825
- * // GET request with query params
1826
- * const { data } = await blink.functions.invoke('my-function', {
1827
- * method: 'GET',
1828
- * searchParams: { limit: '10' }
1829
- * })
1830
- */
1831
- invoke<T = any>(functionSlug: string, options?: FunctionsInvokeOptions): Promise<FunctionsInvokeResponse<T>>;
1832
- }
1833
-
1834
1636
  /**
1835
1637
  * Blink Client - Main SDK entry point
1836
1638
  * Factory function and client class for the Blink SDK
@@ -1845,8 +1647,6 @@ interface BlinkClient {
1845
1647
  realtime: BlinkRealtime;
1846
1648
  notifications: BlinkNotifications;
1847
1649
  analytics: BlinkAnalytics;
1848
- connectors: BlinkConnectors;
1849
- functions: BlinkFunctions;
1850
1650
  }
1851
1651
  /**
1852
1652
  * Create a new Blink client instance
@@ -2321,82 +2121,6 @@ declare class BlinkAIImpl implements BlinkAI {
2321
2121
  n?: number;
2322
2122
  signal?: AbortSignal;
2323
2123
  }): Promise<ImageGenerationResponse>;
2324
- /**
2325
- * Generates videos from text prompts or images using AI video generation models.
2326
- *
2327
- * @param options - Object containing:
2328
- * - `prompt`: Text description of the video to generate (required)
2329
- * - `model`: Video model to use (optional). Available models:
2330
- * **Text-to-Video Models:**
2331
- * - `"fal-ai/veo3.1"` - Google Veo 3.1 (best quality)
2332
- * - `"fal-ai/veo3.1/fast"` (default) - Veo 3.1 fast mode (faster, cheaper)
2333
- * - `"fal-ai/sora-2/text-to-video/pro"` - OpenAI Sora 2
2334
- * - `"fal-ai/kling-video/v2.6/pro/text-to-video"` - Kling 2.6
2335
- * **Image-to-Video Models:**
2336
- * - `"fal-ai/veo3.1/image-to-video"` - Veo 3.1 I2V
2337
- * - `"fal-ai/veo3.1/fast/image-to-video"` - Veo 3.1 fast I2V
2338
- * - `"fal-ai/sora-2/image-to-video/pro"` - Sora 2 I2V
2339
- * - `"fal-ai/kling-video/v2.6/pro/image-to-video"` - Kling 2.6 I2V
2340
- * - `image_url`: Source image URL for image-to-video (required for I2V models)
2341
- * - `duration`: Video duration ("4s", "5s", "6s", "8s", "10s", "12s")
2342
- * - `aspect_ratio`: Aspect ratio ("16:9", "9:16", "1:1")
2343
- * - `resolution`: Resolution ("720p", "1080p") - Veo/Sora only
2344
- * - `negative_prompt`: What to avoid in generation - Veo/Kling only
2345
- * - `generate_audio`: Generate audio with video (default: true)
2346
- * - `seed`: For reproducibility - Veo only
2347
- * - `cfg_scale`: Guidance scale (0-1) - Kling only
2348
- * - Plus optional signal parameter
2349
- *
2350
- * @example
2351
- * ```ts
2352
- * // Basic text-to-video generation (uses default fast model)
2353
- * const { result } = await blink.ai.generateVideo({
2354
- * prompt: "A serene sunset over the ocean with gentle waves"
2355
- * });
2356
- * console.log("Video URL:", result.video.url);
2357
- *
2358
- * // High quality with Veo 3.1
2359
- * const { result } = await blink.ai.generateVideo({
2360
- * prompt: "A cinematic shot of a futuristic city at night",
2361
- * model: "fal-ai/veo3.1",
2362
- * resolution: "1080p",
2363
- * aspect_ratio: "16:9"
2364
- * });
2365
- *
2366
- * // Image-to-video animation
2367
- * const { result } = await blink.ai.generateVideo({
2368
- * prompt: "Animate this image with gentle camera movement",
2369
- * model: "fal-ai/veo3.1/fast/image-to-video",
2370
- * image_url: "https://example.com/my-image.jpg",
2371
- * duration: "5s"
2372
- * });
2373
- *
2374
- * // Using Sora 2 for creative videos
2375
- * const { result } = await blink.ai.generateVideo({
2376
- * prompt: "A magical forest with glowing fireflies",
2377
- * model: "fal-ai/sora-2/text-to-video/pro",
2378
- * duration: "8s"
2379
- * });
2380
- *
2381
- * // Using Kling for detailed videos
2382
- * const { result, usage } = await blink.ai.generateVideo({
2383
- * prompt: "A professional cooking tutorial scene",
2384
- * model: "fal-ai/kling-video/v2.6/pro/text-to-video",
2385
- * negative_prompt: "blur, distort, low quality",
2386
- * cfg_scale: 0.7
2387
- * });
2388
- * console.log("Credits charged:", usage?.creditsCharged);
2389
- * ```
2390
- *
2391
- * @returns Promise<VideoGenerationResponse> - Object containing:
2392
- * - `result.video.url`: URL to the generated video
2393
- * - `result.video.content_type`: MIME type (video/mp4)
2394
- * - `result.video.file_name`: Generated filename
2395
- * - `result.video.file_size`: File size in bytes
2396
- * - `metadata`: Generation metadata (projectId, timestamp, model)
2397
- * - `usage`: Credits charged and cost information
2398
- */
2399
- generateVideo(options: VideoGenerationRequest): Promise<VideoGenerationResponse>;
2400
2124
  /**
2401
2125
  * Converts text to speech using AI voice synthesis models.
2402
2126
  *
@@ -2572,14 +2296,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
2572
2296
  onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
2573
2297
  }
2574
2298
 
2575
- declare class BlinkConnectorsImpl implements BlinkConnectors {
2576
- private httpClient;
2577
- constructor(httpClient: HttpClient);
2578
- status(provider: ConnectorProvider, options?: {
2579
- account_id?: string;
2580
- }): Promise<ConnectorStatusResponse>;
2581
- execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
2582
- saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
2583
- }
2584
-
2585
- 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 };