@blinkdotnew/dev-sdk 0.0.2 → 2.1.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.mts +163 -9
- package/dist/index.d.ts +163 -9
- package/dist/index.js +304 -137
- package/dist/index.mjs +302 -138
- package/package.json +5 -3
package/dist/index.d.mts
CHANGED
|
@@ -61,6 +61,39 @@ 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;
|
|
64
97
|
/**
|
|
65
98
|
* Storage adapter for cross-platform token persistence
|
|
66
99
|
*
|
|
@@ -281,6 +314,9 @@ declare class BlinkError extends Error {
|
|
|
281
314
|
constructor(message: string, code?: string | undefined, status?: number | undefined, details?: any);
|
|
282
315
|
}
|
|
283
316
|
interface StorageUploadOptions {
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated Blink storage uploads are add-only by default. This option is ignored.
|
|
319
|
+
*/
|
|
284
320
|
upsert?: boolean;
|
|
285
321
|
onProgress?: (percent: number) => void;
|
|
286
322
|
}
|
|
@@ -731,13 +767,61 @@ interface BlinkNotifications {
|
|
|
731
767
|
email(params: SendEmailRequest): Promise<SendEmailResponse>;
|
|
732
768
|
}
|
|
733
769
|
|
|
770
|
+
type ConnectorProvider = 'discord' | 'notion' | 'google_drive' | 'google_calendar' | 'ai';
|
|
771
|
+
type ConnectorAuthMode = 'oauth' | 'api_key' | 'blink_managed' | 'hybrid';
|
|
772
|
+
interface ConnectorStatusData {
|
|
773
|
+
connected: boolean;
|
|
774
|
+
provider: ConnectorProvider;
|
|
775
|
+
auth_mode?: ConnectorAuthMode;
|
|
776
|
+
account_id?: string;
|
|
777
|
+
metadata?: Record<string, unknown>;
|
|
778
|
+
expires_at?: any;
|
|
779
|
+
scopes?: string[];
|
|
780
|
+
}
|
|
781
|
+
interface ConnectorStatusResponse {
|
|
782
|
+
success: boolean;
|
|
783
|
+
data: ConnectorStatusData;
|
|
784
|
+
}
|
|
785
|
+
interface ConnectorExecuteRequest<TParams = Record<string, unknown>> {
|
|
786
|
+
method: string;
|
|
787
|
+
params?: TParams;
|
|
788
|
+
account_id?: string;
|
|
789
|
+
http_method?: string;
|
|
790
|
+
}
|
|
791
|
+
interface ConnectorExecuteResponse<TData = any> {
|
|
792
|
+
success: boolean;
|
|
793
|
+
data: TData;
|
|
794
|
+
}
|
|
795
|
+
interface ConnectorApiKeyRequest<TMetadata = Record<string, unknown>> {
|
|
796
|
+
api_key: string;
|
|
797
|
+
account_id?: string;
|
|
798
|
+
metadata?: TMetadata;
|
|
799
|
+
}
|
|
800
|
+
interface ConnectorApiKeyResponse {
|
|
801
|
+
success: boolean;
|
|
802
|
+
data: {
|
|
803
|
+
id: string;
|
|
804
|
+
account_id?: string;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
interface BlinkConnectors {
|
|
808
|
+
status(provider: ConnectorProvider, options?: {
|
|
809
|
+
account_id?: string;
|
|
810
|
+
}): Promise<ConnectorStatusResponse>;
|
|
811
|
+
execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
|
|
812
|
+
saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
|
|
813
|
+
}
|
|
814
|
+
declare class BlinkConnectorError extends BlinkError {
|
|
815
|
+
constructor(message: string, status?: number, details?: any);
|
|
816
|
+
}
|
|
817
|
+
|
|
734
818
|
/**
|
|
735
819
|
* HTTP client for Blink API requests
|
|
736
820
|
* Handles authentication, error handling, and request/response processing
|
|
737
821
|
*/
|
|
738
822
|
|
|
739
823
|
interface RequestOptions {
|
|
740
|
-
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
824
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
741
825
|
headers?: Record<string, string>;
|
|
742
826
|
body?: any;
|
|
743
827
|
searchParams?: Record<string, string>;
|
|
@@ -752,9 +836,14 @@ declare class HttpClient {
|
|
|
752
836
|
private readonly authUrl;
|
|
753
837
|
private readonly coreUrl;
|
|
754
838
|
readonly projectId: string;
|
|
839
|
+
private readonly publishableKey?;
|
|
840
|
+
private readonly secretKey?;
|
|
755
841
|
private getToken;
|
|
756
842
|
private getValidToken?;
|
|
757
843
|
constructor(config: BlinkClientConfig, getToken: () => string | null, getValidToken?: () => Promise<string | null>);
|
|
844
|
+
private shouldAttachPublishableKey;
|
|
845
|
+
private shouldSkipSecretKey;
|
|
846
|
+
private getAuthorizationHeader;
|
|
758
847
|
/**
|
|
759
848
|
* Make an authenticated request to the Blink API
|
|
760
849
|
*/
|
|
@@ -836,7 +925,7 @@ declare class HttpClient {
|
|
|
836
925
|
signal?: AbortSignal;
|
|
837
926
|
}): Promise<BlinkResponse<any>>;
|
|
838
927
|
/**
|
|
839
|
-
* Stream AI text generation
|
|
928
|
+
* Stream AI text generation - uses Vercel AI SDK's pipeUIMessageStreamToResponse (Data Stream Protocol)
|
|
840
929
|
*/
|
|
841
930
|
streamAiText(prompt: string, options: {
|
|
842
931
|
model?: string | undefined;
|
|
@@ -860,7 +949,7 @@ declare class HttpClient {
|
|
|
860
949
|
signal?: AbortSignal;
|
|
861
950
|
}): Promise<BlinkResponse<any>>;
|
|
862
951
|
/**
|
|
863
|
-
* Stream AI object generation
|
|
952
|
+
* Stream AI object generation - uses Vercel AI SDK's pipeTextStreamToResponse
|
|
864
953
|
*/
|
|
865
954
|
streamAiObject(prompt: string, options: {
|
|
866
955
|
model?: string | undefined;
|
|
@@ -904,6 +993,13 @@ declare class HttpClient {
|
|
|
904
993
|
dataScreenshot(projectId: string, request: ScreenshotRequest): Promise<BlinkResponse<ScreenshotResponse>>;
|
|
905
994
|
dataFetch(projectId: string, request: FetchRequest): Promise<BlinkResponse<FetchResponse | AsyncFetchResponse>>;
|
|
906
995
|
dataSearch(projectId: string, request: SearchRequest): Promise<BlinkResponse<SearchResponse>>;
|
|
996
|
+
/**
|
|
997
|
+
* Connector requests
|
|
998
|
+
*/
|
|
999
|
+
private formatProviderForPath;
|
|
1000
|
+
connectorStatus(provider: ConnectorProvider): Promise<BlinkResponse<ConnectorStatusResponse>>;
|
|
1001
|
+
connectorExecute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<BlinkResponse<ConnectorExecuteResponse<TData>>>;
|
|
1002
|
+
connectorSaveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<BlinkResponse<ConnectorApiKeyResponse>>;
|
|
907
1003
|
/**
|
|
908
1004
|
* Realtime-specific requests
|
|
909
1005
|
*/
|
|
@@ -941,17 +1037,17 @@ declare class HttpClient {
|
|
|
941
1037
|
private parseResponse;
|
|
942
1038
|
private handleErrorResponse;
|
|
943
1039
|
/**
|
|
944
|
-
* Parse Vercel AI SDK
|
|
945
|
-
*
|
|
1040
|
+
* Parse Vercel AI SDK v5 Data Stream Protocol (Server-Sent Events)
|
|
1041
|
+
* Supports all event types from the UI Message Stream protocol
|
|
946
1042
|
*/
|
|
947
|
-
private
|
|
1043
|
+
private parseDataStreamProtocol;
|
|
948
1044
|
}
|
|
949
1045
|
|
|
950
1046
|
/**
|
|
951
1047
|
* Platform detection for cross-platform compatibility
|
|
952
|
-
* Detects whether code is running on web, React Native,
|
|
1048
|
+
* Detects whether code is running on web, React Native, Node.js, or Deno
|
|
953
1049
|
*/
|
|
954
|
-
type Platform = 'web' | 'react-native' | 'node';
|
|
1050
|
+
type Platform = 'web' | 'react-native' | 'node' | 'deno';
|
|
955
1051
|
/**
|
|
956
1052
|
* Current platform
|
|
957
1053
|
*/
|
|
@@ -962,7 +1058,9 @@ declare const platform: Platform;
|
|
|
962
1058
|
declare const isWeb: boolean;
|
|
963
1059
|
declare const isReactNative: boolean;
|
|
964
1060
|
declare const isNode: boolean;
|
|
1061
|
+
declare const isDeno: boolean;
|
|
965
1062
|
declare const isBrowser: boolean;
|
|
1063
|
+
declare const isServer: boolean;
|
|
966
1064
|
|
|
967
1065
|
/**
|
|
968
1066
|
* Blink Auth Module - Client-side authentication management
|
|
@@ -1633,6 +1731,50 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
|
|
|
1633
1731
|
private detectChannel;
|
|
1634
1732
|
}
|
|
1635
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* Blink Functions - Edge function invocation helper
|
|
1736
|
+
* Provides a simple interface for calling Blink Edge Functions with automatic JWT attachment
|
|
1737
|
+
*/
|
|
1738
|
+
|
|
1739
|
+
interface FunctionsInvokeOptions {
|
|
1740
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1741
|
+
body?: any;
|
|
1742
|
+
headers?: Record<string, string>;
|
|
1743
|
+
searchParams?: Record<string, string>;
|
|
1744
|
+
}
|
|
1745
|
+
interface FunctionsInvokeResponse<T = any> {
|
|
1746
|
+
data: T;
|
|
1747
|
+
status: number;
|
|
1748
|
+
headers: Headers;
|
|
1749
|
+
}
|
|
1750
|
+
interface BlinkFunctions {
|
|
1751
|
+
/**
|
|
1752
|
+
* Invoke a Blink Edge Function.
|
|
1753
|
+
*
|
|
1754
|
+
* Automatically attaches the user's JWT for authenticated requests.
|
|
1755
|
+
* The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
|
|
1756
|
+
*
|
|
1757
|
+
* @param functionSlug - The slug of the edge function to invoke
|
|
1758
|
+
* @param options - Request options (method, body, headers, etc.)
|
|
1759
|
+
* @returns The function response
|
|
1760
|
+
*
|
|
1761
|
+
* @example
|
|
1762
|
+
* // Simple POST request
|
|
1763
|
+
* const { data } = await blink.functions.invoke('my-function', {
|
|
1764
|
+
* method: 'POST',
|
|
1765
|
+
* body: { message: 'Hello' }
|
|
1766
|
+
* })
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* // GET request with query params
|
|
1770
|
+
* const { data } = await blink.functions.invoke('my-function', {
|
|
1771
|
+
* method: 'GET',
|
|
1772
|
+
* searchParams: { limit: '10' }
|
|
1773
|
+
* })
|
|
1774
|
+
*/
|
|
1775
|
+
invoke<T = any>(functionSlug: string, options?: FunctionsInvokeOptions): Promise<FunctionsInvokeResponse<T>>;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1636
1778
|
/**
|
|
1637
1779
|
* Blink Client - Main SDK entry point
|
|
1638
1780
|
* Factory function and client class for the Blink SDK
|
|
@@ -1647,6 +1789,8 @@ interface BlinkClient {
|
|
|
1647
1789
|
realtime: BlinkRealtime;
|
|
1648
1790
|
notifications: BlinkNotifications;
|
|
1649
1791
|
analytics: BlinkAnalytics;
|
|
1792
|
+
connectors: BlinkConnectors;
|
|
1793
|
+
functions: BlinkFunctions;
|
|
1650
1794
|
}
|
|
1651
1795
|
/**
|
|
1652
1796
|
* Create a new Blink client instance
|
|
@@ -2296,4 +2440,14 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
|
|
|
2296
2440
|
onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
|
|
2297
2441
|
}
|
|
2298
2442
|
|
|
2299
|
-
|
|
2443
|
+
declare class BlinkConnectorsImpl implements BlinkConnectors {
|
|
2444
|
+
private httpClient;
|
|
2445
|
+
constructor(httpClient: HttpClient);
|
|
2446
|
+
status(provider: ConnectorProvider, options?: {
|
|
2447
|
+
account_id?: string;
|
|
2448
|
+
}): Promise<ConnectorStatusResponse>;
|
|
2449
|
+
execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
|
|
2450
|
+
saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -61,6 +61,39 @@ 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;
|
|
64
97
|
/**
|
|
65
98
|
* Storage adapter for cross-platform token persistence
|
|
66
99
|
*
|
|
@@ -281,6 +314,9 @@ declare class BlinkError extends Error {
|
|
|
281
314
|
constructor(message: string, code?: string | undefined, status?: number | undefined, details?: any);
|
|
282
315
|
}
|
|
283
316
|
interface StorageUploadOptions {
|
|
317
|
+
/**
|
|
318
|
+
* @deprecated Blink storage uploads are add-only by default. This option is ignored.
|
|
319
|
+
*/
|
|
284
320
|
upsert?: boolean;
|
|
285
321
|
onProgress?: (percent: number) => void;
|
|
286
322
|
}
|
|
@@ -731,13 +767,61 @@ interface BlinkNotifications {
|
|
|
731
767
|
email(params: SendEmailRequest): Promise<SendEmailResponse>;
|
|
732
768
|
}
|
|
733
769
|
|
|
770
|
+
type ConnectorProvider = 'discord' | 'notion' | 'google_drive' | 'google_calendar' | 'ai';
|
|
771
|
+
type ConnectorAuthMode = 'oauth' | 'api_key' | 'blink_managed' | 'hybrid';
|
|
772
|
+
interface ConnectorStatusData {
|
|
773
|
+
connected: boolean;
|
|
774
|
+
provider: ConnectorProvider;
|
|
775
|
+
auth_mode?: ConnectorAuthMode;
|
|
776
|
+
account_id?: string;
|
|
777
|
+
metadata?: Record<string, unknown>;
|
|
778
|
+
expires_at?: any;
|
|
779
|
+
scopes?: string[];
|
|
780
|
+
}
|
|
781
|
+
interface ConnectorStatusResponse {
|
|
782
|
+
success: boolean;
|
|
783
|
+
data: ConnectorStatusData;
|
|
784
|
+
}
|
|
785
|
+
interface ConnectorExecuteRequest<TParams = Record<string, unknown>> {
|
|
786
|
+
method: string;
|
|
787
|
+
params?: TParams;
|
|
788
|
+
account_id?: string;
|
|
789
|
+
http_method?: string;
|
|
790
|
+
}
|
|
791
|
+
interface ConnectorExecuteResponse<TData = any> {
|
|
792
|
+
success: boolean;
|
|
793
|
+
data: TData;
|
|
794
|
+
}
|
|
795
|
+
interface ConnectorApiKeyRequest<TMetadata = Record<string, unknown>> {
|
|
796
|
+
api_key: string;
|
|
797
|
+
account_id?: string;
|
|
798
|
+
metadata?: TMetadata;
|
|
799
|
+
}
|
|
800
|
+
interface ConnectorApiKeyResponse {
|
|
801
|
+
success: boolean;
|
|
802
|
+
data: {
|
|
803
|
+
id: string;
|
|
804
|
+
account_id?: string;
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
interface BlinkConnectors {
|
|
808
|
+
status(provider: ConnectorProvider, options?: {
|
|
809
|
+
account_id?: string;
|
|
810
|
+
}): Promise<ConnectorStatusResponse>;
|
|
811
|
+
execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
|
|
812
|
+
saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
|
|
813
|
+
}
|
|
814
|
+
declare class BlinkConnectorError extends BlinkError {
|
|
815
|
+
constructor(message: string, status?: number, details?: any);
|
|
816
|
+
}
|
|
817
|
+
|
|
734
818
|
/**
|
|
735
819
|
* HTTP client for Blink API requests
|
|
736
820
|
* Handles authentication, error handling, and request/response processing
|
|
737
821
|
*/
|
|
738
822
|
|
|
739
823
|
interface RequestOptions {
|
|
740
|
-
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
824
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
741
825
|
headers?: Record<string, string>;
|
|
742
826
|
body?: any;
|
|
743
827
|
searchParams?: Record<string, string>;
|
|
@@ -752,9 +836,14 @@ declare class HttpClient {
|
|
|
752
836
|
private readonly authUrl;
|
|
753
837
|
private readonly coreUrl;
|
|
754
838
|
readonly projectId: string;
|
|
839
|
+
private readonly publishableKey?;
|
|
840
|
+
private readonly secretKey?;
|
|
755
841
|
private getToken;
|
|
756
842
|
private getValidToken?;
|
|
757
843
|
constructor(config: BlinkClientConfig, getToken: () => string | null, getValidToken?: () => Promise<string | null>);
|
|
844
|
+
private shouldAttachPublishableKey;
|
|
845
|
+
private shouldSkipSecretKey;
|
|
846
|
+
private getAuthorizationHeader;
|
|
758
847
|
/**
|
|
759
848
|
* Make an authenticated request to the Blink API
|
|
760
849
|
*/
|
|
@@ -836,7 +925,7 @@ declare class HttpClient {
|
|
|
836
925
|
signal?: AbortSignal;
|
|
837
926
|
}): Promise<BlinkResponse<any>>;
|
|
838
927
|
/**
|
|
839
|
-
* Stream AI text generation
|
|
928
|
+
* Stream AI text generation - uses Vercel AI SDK's pipeUIMessageStreamToResponse (Data Stream Protocol)
|
|
840
929
|
*/
|
|
841
930
|
streamAiText(prompt: string, options: {
|
|
842
931
|
model?: string | undefined;
|
|
@@ -860,7 +949,7 @@ declare class HttpClient {
|
|
|
860
949
|
signal?: AbortSignal;
|
|
861
950
|
}): Promise<BlinkResponse<any>>;
|
|
862
951
|
/**
|
|
863
|
-
* Stream AI object generation
|
|
952
|
+
* Stream AI object generation - uses Vercel AI SDK's pipeTextStreamToResponse
|
|
864
953
|
*/
|
|
865
954
|
streamAiObject(prompt: string, options: {
|
|
866
955
|
model?: string | undefined;
|
|
@@ -904,6 +993,13 @@ declare class HttpClient {
|
|
|
904
993
|
dataScreenshot(projectId: string, request: ScreenshotRequest): Promise<BlinkResponse<ScreenshotResponse>>;
|
|
905
994
|
dataFetch(projectId: string, request: FetchRequest): Promise<BlinkResponse<FetchResponse | AsyncFetchResponse>>;
|
|
906
995
|
dataSearch(projectId: string, request: SearchRequest): Promise<BlinkResponse<SearchResponse>>;
|
|
996
|
+
/**
|
|
997
|
+
* Connector requests
|
|
998
|
+
*/
|
|
999
|
+
private formatProviderForPath;
|
|
1000
|
+
connectorStatus(provider: ConnectorProvider): Promise<BlinkResponse<ConnectorStatusResponse>>;
|
|
1001
|
+
connectorExecute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<BlinkResponse<ConnectorExecuteResponse<TData>>>;
|
|
1002
|
+
connectorSaveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<BlinkResponse<ConnectorApiKeyResponse>>;
|
|
907
1003
|
/**
|
|
908
1004
|
* Realtime-specific requests
|
|
909
1005
|
*/
|
|
@@ -941,17 +1037,17 @@ declare class HttpClient {
|
|
|
941
1037
|
private parseResponse;
|
|
942
1038
|
private handleErrorResponse;
|
|
943
1039
|
/**
|
|
944
|
-
* Parse Vercel AI SDK
|
|
945
|
-
*
|
|
1040
|
+
* Parse Vercel AI SDK v5 Data Stream Protocol (Server-Sent Events)
|
|
1041
|
+
* Supports all event types from the UI Message Stream protocol
|
|
946
1042
|
*/
|
|
947
|
-
private
|
|
1043
|
+
private parseDataStreamProtocol;
|
|
948
1044
|
}
|
|
949
1045
|
|
|
950
1046
|
/**
|
|
951
1047
|
* Platform detection for cross-platform compatibility
|
|
952
|
-
* Detects whether code is running on web, React Native,
|
|
1048
|
+
* Detects whether code is running on web, React Native, Node.js, or Deno
|
|
953
1049
|
*/
|
|
954
|
-
type Platform = 'web' | 'react-native' | 'node';
|
|
1050
|
+
type Platform = 'web' | 'react-native' | 'node' | 'deno';
|
|
955
1051
|
/**
|
|
956
1052
|
* Current platform
|
|
957
1053
|
*/
|
|
@@ -962,7 +1058,9 @@ declare const platform: Platform;
|
|
|
962
1058
|
declare const isWeb: boolean;
|
|
963
1059
|
declare const isReactNative: boolean;
|
|
964
1060
|
declare const isNode: boolean;
|
|
1061
|
+
declare const isDeno: boolean;
|
|
965
1062
|
declare const isBrowser: boolean;
|
|
1063
|
+
declare const isServer: boolean;
|
|
966
1064
|
|
|
967
1065
|
/**
|
|
968
1066
|
* Blink Auth Module - Client-side authentication management
|
|
@@ -1633,6 +1731,50 @@ declare class BlinkAnalyticsImpl implements BlinkAnalytics {
|
|
|
1633
1731
|
private detectChannel;
|
|
1634
1732
|
}
|
|
1635
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* Blink Functions - Edge function invocation helper
|
|
1736
|
+
* Provides a simple interface for calling Blink Edge Functions with automatic JWT attachment
|
|
1737
|
+
*/
|
|
1738
|
+
|
|
1739
|
+
interface FunctionsInvokeOptions {
|
|
1740
|
+
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
1741
|
+
body?: any;
|
|
1742
|
+
headers?: Record<string, string>;
|
|
1743
|
+
searchParams?: Record<string, string>;
|
|
1744
|
+
}
|
|
1745
|
+
interface FunctionsInvokeResponse<T = any> {
|
|
1746
|
+
data: T;
|
|
1747
|
+
status: number;
|
|
1748
|
+
headers: Headers;
|
|
1749
|
+
}
|
|
1750
|
+
interface BlinkFunctions {
|
|
1751
|
+
/**
|
|
1752
|
+
* Invoke a Blink Edge Function.
|
|
1753
|
+
*
|
|
1754
|
+
* Automatically attaches the user's JWT for authenticated requests.
|
|
1755
|
+
* The function URL is constructed as: https://{projectSuffix}--{functionSlug}.functions.blink.new
|
|
1756
|
+
*
|
|
1757
|
+
* @param functionSlug - The slug of the edge function to invoke
|
|
1758
|
+
* @param options - Request options (method, body, headers, etc.)
|
|
1759
|
+
* @returns The function response
|
|
1760
|
+
*
|
|
1761
|
+
* @example
|
|
1762
|
+
* // Simple POST request
|
|
1763
|
+
* const { data } = await blink.functions.invoke('my-function', {
|
|
1764
|
+
* method: 'POST',
|
|
1765
|
+
* body: { message: 'Hello' }
|
|
1766
|
+
* })
|
|
1767
|
+
*
|
|
1768
|
+
* @example
|
|
1769
|
+
* // GET request with query params
|
|
1770
|
+
* const { data } = await blink.functions.invoke('my-function', {
|
|
1771
|
+
* method: 'GET',
|
|
1772
|
+
* searchParams: { limit: '10' }
|
|
1773
|
+
* })
|
|
1774
|
+
*/
|
|
1775
|
+
invoke<T = any>(functionSlug: string, options?: FunctionsInvokeOptions): Promise<FunctionsInvokeResponse<T>>;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1636
1778
|
/**
|
|
1637
1779
|
* Blink Client - Main SDK entry point
|
|
1638
1780
|
* Factory function and client class for the Blink SDK
|
|
@@ -1647,6 +1789,8 @@ interface BlinkClient {
|
|
|
1647
1789
|
realtime: BlinkRealtime;
|
|
1648
1790
|
notifications: BlinkNotifications;
|
|
1649
1791
|
analytics: BlinkAnalytics;
|
|
1792
|
+
connectors: BlinkConnectors;
|
|
1793
|
+
functions: BlinkFunctions;
|
|
1650
1794
|
}
|
|
1651
1795
|
/**
|
|
1652
1796
|
* Create a new Blink client instance
|
|
@@ -2296,4 +2440,14 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
|
|
|
2296
2440
|
onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
|
|
2297
2441
|
}
|
|
2298
2442
|
|
|
2299
|
-
|
|
2443
|
+
declare class BlinkConnectorsImpl implements BlinkConnectors {
|
|
2444
|
+
private httpClient;
|
|
2445
|
+
constructor(httpClient: HttpClient);
|
|
2446
|
+
status(provider: ConnectorProvider, options?: {
|
|
2447
|
+
account_id?: string;
|
|
2448
|
+
}): Promise<ConnectorStatusResponse>;
|
|
2449
|
+
execute<TParams = Record<string, unknown>, TData = any>(provider: ConnectorProvider, request: ConnectorExecuteRequest<TParams>): Promise<ConnectorExecuteResponse<TData>>;
|
|
2450
|
+
saveApiKey<TMetadata = Record<string, unknown>>(provider: ConnectorProvider, request: ConnectorApiKeyRequest<TMetadata>): Promise<ConnectorApiKeyResponse>;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
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 };
|