@blinkdotnew/sdk 0.10.4 → 0.10.6
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 +738 -3
- package/dist/index.d.ts +738 -3
- package/dist/index.js +38 -15
- package/dist/index.mjs +38 -15
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,740 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Core type definitions for Blink SDK
|
|
3
|
+
*/
|
|
4
|
+
interface BlinkClientConfig {
|
|
5
|
+
projectId: string;
|
|
6
|
+
authRequired?: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface BlinkUser {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
displayName?: string;
|
|
12
|
+
photoURL?: string;
|
|
13
|
+
emailVerified?: boolean;
|
|
14
|
+
createdAt?: string;
|
|
15
|
+
lastSignInAt?: string;
|
|
16
|
+
}
|
|
17
|
+
interface AuthTokens {
|
|
18
|
+
access_token: string;
|
|
19
|
+
refresh_token?: string;
|
|
20
|
+
token_type: 'Bearer';
|
|
21
|
+
expires_in: number;
|
|
22
|
+
refresh_expires_in?: number;
|
|
23
|
+
issued_at?: number;
|
|
24
|
+
}
|
|
25
|
+
interface AuthState {
|
|
26
|
+
user: BlinkUser | null;
|
|
27
|
+
tokens: AuthTokens | null;
|
|
28
|
+
isAuthenticated: boolean;
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface FilterOperators {
|
|
32
|
+
eq?: any;
|
|
33
|
+
neq?: any;
|
|
34
|
+
gt?: any;
|
|
35
|
+
gte?: any;
|
|
36
|
+
lt?: any;
|
|
37
|
+
lte?: any;
|
|
38
|
+
in?: any[];
|
|
39
|
+
not_in?: any[];
|
|
40
|
+
like?: string;
|
|
41
|
+
ilike?: string;
|
|
42
|
+
is?: null | boolean;
|
|
43
|
+
not?: any;
|
|
44
|
+
}
|
|
45
|
+
interface LogicalOperators {
|
|
46
|
+
AND?: FilterCondition[];
|
|
47
|
+
OR?: FilterCondition[];
|
|
48
|
+
}
|
|
49
|
+
type FilterCondition = Record<string, any> | FilterOperators | LogicalOperators;
|
|
50
|
+
interface QueryOptions {
|
|
51
|
+
where?: FilterCondition;
|
|
52
|
+
orderBy?: Record<string, 'asc' | 'desc'> | string;
|
|
53
|
+
limit?: number;
|
|
54
|
+
offset?: number;
|
|
55
|
+
cursor?: string;
|
|
56
|
+
select?: string[];
|
|
57
|
+
}
|
|
58
|
+
interface ListResponse<T = any> {
|
|
59
|
+
data: T[];
|
|
60
|
+
count?: number;
|
|
61
|
+
nextCursor?: string;
|
|
62
|
+
hasMore?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface CreateOptions {
|
|
65
|
+
returning?: boolean;
|
|
66
|
+
}
|
|
67
|
+
interface UpdateOptions {
|
|
68
|
+
returning?: boolean;
|
|
69
|
+
}
|
|
70
|
+
interface UpsertOptions {
|
|
71
|
+
onConflict?: string;
|
|
72
|
+
returning?: boolean;
|
|
73
|
+
}
|
|
74
|
+
interface TableOperations<T = any> {
|
|
75
|
+
create(data: Partial<T>, options?: CreateOptions): Promise<T>;
|
|
76
|
+
createMany(data: Partial<T>[], options?: CreateOptions): Promise<T[]>;
|
|
77
|
+
upsert(data: Partial<T>, options?: UpsertOptions): Promise<T>;
|
|
78
|
+
upsertMany(data: Partial<T>[], options?: UpsertOptions): Promise<T[]>;
|
|
79
|
+
get(id: string): Promise<T | null>;
|
|
80
|
+
list(options?: QueryOptions): Promise<ListResponse<T>>;
|
|
81
|
+
update(id: string, data: Partial<T>, options?: UpdateOptions): Promise<T>;
|
|
82
|
+
updateMany(updates: Array<{
|
|
83
|
+
id: string;
|
|
84
|
+
} & Partial<T>>, options?: UpdateOptions): Promise<T[]>;
|
|
85
|
+
delete(id: string): Promise<void>;
|
|
86
|
+
deleteMany(options: {
|
|
87
|
+
where: FilterCondition;
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
count(options?: {
|
|
90
|
+
where?: FilterCondition;
|
|
91
|
+
}): Promise<number>;
|
|
92
|
+
exists(options: {
|
|
93
|
+
where: FilterCondition;
|
|
94
|
+
}): Promise<boolean>;
|
|
95
|
+
}
|
|
96
|
+
declare class BlinkError extends Error {
|
|
97
|
+
code?: string | undefined;
|
|
98
|
+
status?: number | undefined;
|
|
99
|
+
details?: any;
|
|
100
|
+
constructor(message: string, code?: string | undefined, status?: number | undefined, details?: any);
|
|
101
|
+
}
|
|
102
|
+
interface StorageUploadOptions {
|
|
103
|
+
upsert?: boolean;
|
|
104
|
+
onProgress?: (percent: number) => void;
|
|
105
|
+
}
|
|
106
|
+
interface StorageUploadResponse {
|
|
107
|
+
publicUrl: string;
|
|
108
|
+
}
|
|
109
|
+
interface FileObject {
|
|
110
|
+
id: string;
|
|
111
|
+
name: string;
|
|
112
|
+
bucket_id: string;
|
|
113
|
+
owner?: string | null;
|
|
114
|
+
owner_id?: string | null;
|
|
115
|
+
version?: string | null;
|
|
116
|
+
created_at: string;
|
|
117
|
+
updated_at: string;
|
|
118
|
+
last_accessed_at: string;
|
|
119
|
+
metadata: {
|
|
120
|
+
size: number;
|
|
121
|
+
mimetype: string;
|
|
122
|
+
cacheControl?: string;
|
|
123
|
+
};
|
|
124
|
+
user_metadata?: Record<string, any>;
|
|
125
|
+
}
|
|
126
|
+
interface BlinkStorage {
|
|
127
|
+
upload(file: File | Blob | Buffer, path: string, options?: StorageUploadOptions): Promise<StorageUploadResponse>;
|
|
128
|
+
remove(...paths: string[]): Promise<void>;
|
|
129
|
+
}
|
|
130
|
+
interface TokenUsage {
|
|
131
|
+
promptTokens: number;
|
|
132
|
+
completionTokens: number;
|
|
133
|
+
totalTokens: number;
|
|
134
|
+
}
|
|
135
|
+
interface TextContent {
|
|
136
|
+
type: 'text';
|
|
137
|
+
text: string;
|
|
138
|
+
}
|
|
139
|
+
interface ImageContent {
|
|
140
|
+
type: 'image';
|
|
141
|
+
image: string;
|
|
142
|
+
}
|
|
143
|
+
type MessageContent = TextContent | ImageContent;
|
|
144
|
+
interface Message {
|
|
145
|
+
role: 'system' | 'user' | 'assistant';
|
|
146
|
+
content: string | MessageContent[];
|
|
147
|
+
}
|
|
148
|
+
interface TextGenerationRequest {
|
|
149
|
+
model?: string;
|
|
150
|
+
prompt?: string;
|
|
151
|
+
messages?: Message[];
|
|
152
|
+
stream?: boolean;
|
|
153
|
+
search?: boolean;
|
|
154
|
+
maxSteps?: number;
|
|
155
|
+
experimental_continueSteps?: boolean;
|
|
156
|
+
maxTokens?: number;
|
|
157
|
+
temperature?: number;
|
|
158
|
+
signal?: AbortSignal;
|
|
159
|
+
}
|
|
160
|
+
interface TextGenerationResponse {
|
|
161
|
+
text: string;
|
|
162
|
+
finishReason?: 'stop' | 'length' | 'content_filter' | 'tool_calls';
|
|
163
|
+
usage?: TokenUsage;
|
|
164
|
+
files?: any[];
|
|
165
|
+
reasoningDetails?: any[];
|
|
166
|
+
toolCalls?: any[];
|
|
167
|
+
toolResults?: any[];
|
|
168
|
+
warnings?: string[];
|
|
169
|
+
request?: {
|
|
170
|
+
body?: string;
|
|
171
|
+
};
|
|
172
|
+
response?: any;
|
|
173
|
+
steps?: Array<{
|
|
174
|
+
stepType?: string;
|
|
175
|
+
text?: string;
|
|
176
|
+
finishReason?: string;
|
|
177
|
+
usage?: TokenUsage;
|
|
178
|
+
}>;
|
|
179
|
+
sources?: any[];
|
|
180
|
+
providerMetadata?: any;
|
|
181
|
+
experimental_providerMetadata?: any;
|
|
182
|
+
}
|
|
183
|
+
interface ObjectGenerationRequest {
|
|
184
|
+
model?: string;
|
|
185
|
+
prompt: string;
|
|
186
|
+
output?: 'object' | 'array' | 'enum';
|
|
187
|
+
schema?: any;
|
|
188
|
+
enum?: string[];
|
|
189
|
+
stream?: boolean;
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}
|
|
192
|
+
interface ObjectGenerationResponse {
|
|
193
|
+
object: any;
|
|
194
|
+
finishReason?: 'stop' | 'length' | 'content_filter';
|
|
195
|
+
usage?: TokenUsage;
|
|
196
|
+
warnings?: string[];
|
|
197
|
+
providerMetadata?: {
|
|
198
|
+
openai?: {
|
|
199
|
+
reasoningTokens?: number;
|
|
200
|
+
acceptedPredictionTokens?: number;
|
|
201
|
+
rejectedPredictionTokens?: number;
|
|
202
|
+
cachedPromptTokens?: number;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
experimental_providerMetadata?: any;
|
|
206
|
+
response?: {
|
|
207
|
+
id?: string;
|
|
208
|
+
timestamp?: string;
|
|
209
|
+
modelId?: string;
|
|
210
|
+
headers?: any;
|
|
211
|
+
body?: any;
|
|
212
|
+
};
|
|
213
|
+
request?: {
|
|
214
|
+
body?: string;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
interface ImageGenerationRequest {
|
|
218
|
+
model?: string;
|
|
219
|
+
prompt: string;
|
|
220
|
+
size?: string;
|
|
221
|
+
quality?: 'standard' | 'hd';
|
|
222
|
+
n?: number;
|
|
223
|
+
response_format?: 'url' | 'b64_json';
|
|
224
|
+
signal?: AbortSignal;
|
|
225
|
+
}
|
|
226
|
+
interface ImageGenerationResponse {
|
|
227
|
+
data: Array<{
|
|
228
|
+
url?: string;
|
|
229
|
+
b64_json?: string;
|
|
230
|
+
}>;
|
|
231
|
+
}
|
|
232
|
+
interface SpeechGenerationRequest {
|
|
233
|
+
model?: string;
|
|
234
|
+
text: string;
|
|
235
|
+
voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
|
|
236
|
+
response_format?: 'mp3' | 'opus' | 'aac' | 'flac' | 'wav' | 'pcm';
|
|
237
|
+
speed?: number;
|
|
238
|
+
signal?: AbortSignal;
|
|
239
|
+
}
|
|
240
|
+
interface SpeechGenerationResponse {
|
|
241
|
+
url: string;
|
|
242
|
+
voice: string;
|
|
243
|
+
format: string;
|
|
244
|
+
mimeType: string;
|
|
245
|
+
}
|
|
246
|
+
interface TranscriptionRequest {
|
|
247
|
+
model?: string;
|
|
248
|
+
audio: string | number[];
|
|
249
|
+
language?: string;
|
|
250
|
+
response_format?: 'json' | 'text' | 'srt' | 'verbose_json' | 'vtt';
|
|
251
|
+
signal?: AbortSignal;
|
|
252
|
+
}
|
|
253
|
+
interface TranscriptionResponse {
|
|
254
|
+
text: string;
|
|
255
|
+
transcript?: string;
|
|
256
|
+
segments?: Array<{
|
|
257
|
+
id: number;
|
|
258
|
+
seek: number;
|
|
259
|
+
start: number;
|
|
260
|
+
end: number;
|
|
261
|
+
text: string;
|
|
262
|
+
tokens: number[];
|
|
263
|
+
temperature: number;
|
|
264
|
+
avg_logprob: number;
|
|
265
|
+
compression_ratio: number;
|
|
266
|
+
no_speech_prob: number;
|
|
267
|
+
}>;
|
|
268
|
+
language?: string;
|
|
269
|
+
duration?: number;
|
|
270
|
+
words?: Array<{
|
|
271
|
+
word: string;
|
|
272
|
+
start: number;
|
|
273
|
+
end: number;
|
|
274
|
+
}>;
|
|
275
|
+
}
|
|
276
|
+
interface BlinkAI {
|
|
277
|
+
generateText(options: TextGenerationRequest): Promise<TextGenerationResponse>;
|
|
278
|
+
streamText(options: TextGenerationRequest, onChunk: (chunk: string) => void): Promise<TextGenerationResponse>;
|
|
279
|
+
generateObject(options: ObjectGenerationRequest): Promise<ObjectGenerationResponse>;
|
|
280
|
+
streamObject(options: ObjectGenerationRequest, onPartial: (partial: any) => void): Promise<ObjectGenerationResponse>;
|
|
281
|
+
generateImage(options: ImageGenerationRequest): Promise<ImageGenerationResponse>;
|
|
282
|
+
generateSpeech(options: SpeechGenerationRequest): Promise<SpeechGenerationResponse>;
|
|
283
|
+
transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
|
|
284
|
+
}
|
|
285
|
+
interface DataExtraction {
|
|
286
|
+
chunks: string[];
|
|
287
|
+
}
|
|
288
|
+
interface ExtractFromUrlRequest {
|
|
289
|
+
url: string;
|
|
290
|
+
chunking?: boolean;
|
|
291
|
+
chunkSize?: number;
|
|
292
|
+
}
|
|
293
|
+
interface ExtractFromUrlResponse {
|
|
294
|
+
chunks?: string[];
|
|
295
|
+
text?: string;
|
|
296
|
+
}
|
|
297
|
+
interface ExtractFromBlobResponse {
|
|
298
|
+
chunks?: string[];
|
|
299
|
+
text?: string;
|
|
300
|
+
}
|
|
301
|
+
interface ScrapeRequest {
|
|
302
|
+
url: string;
|
|
303
|
+
formats?: ('markdown' | 'html' | 'rawHtml' | 'links' | 'extract' | 'metadata')[];
|
|
304
|
+
}
|
|
305
|
+
interface ScrapeResponse {
|
|
306
|
+
markdown?: string;
|
|
307
|
+
html?: string;
|
|
308
|
+
rawHtml?: string;
|
|
309
|
+
links?: Array<{
|
|
310
|
+
text: string;
|
|
311
|
+
url: string;
|
|
312
|
+
type: string;
|
|
313
|
+
}>;
|
|
314
|
+
extract?: {
|
|
315
|
+
title?: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
headings?: string[];
|
|
318
|
+
text?: string;
|
|
319
|
+
};
|
|
320
|
+
metadata?: {
|
|
321
|
+
title?: string;
|
|
322
|
+
description?: string;
|
|
323
|
+
url?: string;
|
|
324
|
+
domain?: string;
|
|
325
|
+
favicon?: string;
|
|
326
|
+
image?: string;
|
|
327
|
+
author?: string;
|
|
328
|
+
publishedTime?: string;
|
|
329
|
+
modifiedTime?: string;
|
|
330
|
+
type?: string;
|
|
331
|
+
siteName?: string;
|
|
332
|
+
locale?: string;
|
|
333
|
+
keywords?: string[];
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
interface ScrapeResult {
|
|
337
|
+
markdown: string;
|
|
338
|
+
html: string;
|
|
339
|
+
metadata: {
|
|
340
|
+
title: string;
|
|
341
|
+
description: string;
|
|
342
|
+
url: string;
|
|
343
|
+
domain: string;
|
|
344
|
+
favicon?: string;
|
|
345
|
+
image?: string;
|
|
346
|
+
author?: string;
|
|
347
|
+
publishedTime?: string;
|
|
348
|
+
modifiedTime?: string;
|
|
349
|
+
type?: string;
|
|
350
|
+
siteName?: string;
|
|
351
|
+
locale?: string;
|
|
352
|
+
keywords?: string[];
|
|
353
|
+
};
|
|
354
|
+
links: Array<{
|
|
355
|
+
text: string;
|
|
356
|
+
url: string;
|
|
357
|
+
type: string;
|
|
358
|
+
}>;
|
|
359
|
+
extract: {
|
|
360
|
+
title: string;
|
|
361
|
+
description: string;
|
|
362
|
+
headings: string[];
|
|
363
|
+
text: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
interface ScreenshotRequest {
|
|
367
|
+
url: string;
|
|
368
|
+
fullPage?: boolean;
|
|
369
|
+
width?: number;
|
|
370
|
+
height?: number;
|
|
371
|
+
}
|
|
372
|
+
interface ScreenshotResponse {
|
|
373
|
+
url: string;
|
|
374
|
+
}
|
|
375
|
+
interface FetchRequest {
|
|
376
|
+
url: string;
|
|
377
|
+
method?: string;
|
|
378
|
+
headers?: Record<string, string>;
|
|
379
|
+
body?: any;
|
|
380
|
+
query?: Record<string, string>;
|
|
381
|
+
async?: boolean;
|
|
382
|
+
}
|
|
383
|
+
interface FetchResponse {
|
|
384
|
+
status: number;
|
|
385
|
+
headers: Record<string, string>;
|
|
386
|
+
body: any;
|
|
387
|
+
durationMs: number;
|
|
388
|
+
}
|
|
389
|
+
interface AsyncFetchResponse {
|
|
390
|
+
status: 'triggered';
|
|
391
|
+
message: string;
|
|
392
|
+
}
|
|
393
|
+
interface SearchRequest {
|
|
394
|
+
q: string;
|
|
395
|
+
location?: string;
|
|
396
|
+
hl?: string;
|
|
397
|
+
tbm?: string;
|
|
398
|
+
num?: number;
|
|
399
|
+
}
|
|
400
|
+
interface SearchResponse {
|
|
401
|
+
organic_results: Array<{
|
|
402
|
+
position: number;
|
|
403
|
+
title: string;
|
|
404
|
+
link: string;
|
|
405
|
+
snippet: string;
|
|
406
|
+
}>;
|
|
407
|
+
total_results?: string;
|
|
408
|
+
related_searches?: string[];
|
|
409
|
+
people_also_ask?: Array<{
|
|
410
|
+
question: string;
|
|
411
|
+
snippet: string;
|
|
412
|
+
link: string;
|
|
413
|
+
}>;
|
|
414
|
+
local_results?: Array<{
|
|
415
|
+
title: string;
|
|
416
|
+
address: string;
|
|
417
|
+
rating: number;
|
|
418
|
+
reviews: number;
|
|
419
|
+
phone?: string;
|
|
420
|
+
}>;
|
|
421
|
+
ads?: Array<{
|
|
422
|
+
title: string;
|
|
423
|
+
link: string;
|
|
424
|
+
snippet: string;
|
|
425
|
+
}>;
|
|
426
|
+
shopping_results?: Array<{
|
|
427
|
+
title: string;
|
|
428
|
+
price: string;
|
|
429
|
+
source: string;
|
|
430
|
+
link: string;
|
|
431
|
+
}>;
|
|
432
|
+
news_results?: Array<{
|
|
433
|
+
title: string;
|
|
434
|
+
link: string;
|
|
435
|
+
snippet: string;
|
|
436
|
+
date: string;
|
|
437
|
+
source: string;
|
|
438
|
+
}>;
|
|
439
|
+
image_results?: Array<{
|
|
440
|
+
title: string;
|
|
441
|
+
link: string;
|
|
442
|
+
original: string;
|
|
443
|
+
thumbnail: string;
|
|
444
|
+
}>;
|
|
445
|
+
}
|
|
446
|
+
interface RealtimeMessage {
|
|
447
|
+
id: string;
|
|
448
|
+
type: string;
|
|
449
|
+
data: any;
|
|
450
|
+
timestamp: number;
|
|
451
|
+
userId?: string;
|
|
452
|
+
metadata?: Record<string, any>;
|
|
453
|
+
}
|
|
454
|
+
interface PresenceUser {
|
|
455
|
+
userId: string;
|
|
456
|
+
metadata?: Record<string, any>;
|
|
457
|
+
joinedAt: number;
|
|
458
|
+
lastSeen: number;
|
|
459
|
+
}
|
|
460
|
+
interface RealtimeChannel {
|
|
461
|
+
subscribe(options?: {
|
|
462
|
+
userId?: string;
|
|
463
|
+
metadata?: Record<string, any>;
|
|
464
|
+
}): Promise<void>;
|
|
465
|
+
unsubscribe(): Promise<void>;
|
|
466
|
+
publish(type: string, data: any, options?: {
|
|
467
|
+
userId?: string;
|
|
468
|
+
metadata?: Record<string, any>;
|
|
469
|
+
}): Promise<string>;
|
|
470
|
+
onMessage(callback: (message: RealtimeMessage) => void): () => void;
|
|
471
|
+
onPresence(callback: (users: PresenceUser[]) => void): () => void;
|
|
472
|
+
getPresence(): Promise<PresenceUser[]>;
|
|
473
|
+
getMessages(options?: {
|
|
474
|
+
limit?: number;
|
|
475
|
+
before?: string;
|
|
476
|
+
after?: string;
|
|
477
|
+
}): Promise<RealtimeMessage[]>;
|
|
478
|
+
}
|
|
479
|
+
interface RealtimeSubscribeOptions {
|
|
480
|
+
userId?: string;
|
|
481
|
+
metadata?: Record<string, any>;
|
|
482
|
+
}
|
|
483
|
+
interface RealtimePublishOptions {
|
|
484
|
+
userId?: string;
|
|
485
|
+
metadata?: Record<string, any>;
|
|
486
|
+
}
|
|
487
|
+
interface RealtimeGetMessagesOptions {
|
|
488
|
+
limit?: number;
|
|
489
|
+
before?: string;
|
|
490
|
+
after?: string;
|
|
491
|
+
}
|
|
492
|
+
interface BlinkRealtime {
|
|
493
|
+
channel(name: string): RealtimeChannel;
|
|
494
|
+
subscribe(channelName: string, callback: (message: RealtimeMessage) => void, options?: RealtimeSubscribeOptions): Promise<() => void>;
|
|
495
|
+
publish(channelName: string, type: string, data: any, options?: RealtimePublishOptions): Promise<string>;
|
|
496
|
+
presence(channelName: string): Promise<PresenceUser[]>;
|
|
497
|
+
onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
|
|
498
|
+
}
|
|
499
|
+
declare class BlinkRealtimeError extends BlinkError {
|
|
500
|
+
constructor(message: string, status?: number, details?: any);
|
|
501
|
+
}
|
|
502
|
+
interface SendEmailAttachment {
|
|
503
|
+
filename: string;
|
|
504
|
+
url: string;
|
|
505
|
+
type?: string;
|
|
506
|
+
content?: string;
|
|
507
|
+
disposition?: 'attachment' | 'inline';
|
|
508
|
+
cid?: string;
|
|
509
|
+
}
|
|
510
|
+
interface SendEmailRequest {
|
|
511
|
+
to: string | string[];
|
|
512
|
+
subject: string;
|
|
513
|
+
html?: string;
|
|
514
|
+
text?: string;
|
|
515
|
+
from?: string;
|
|
516
|
+
replyTo?: string;
|
|
517
|
+
cc?: string | string[];
|
|
518
|
+
bcc?: string | string[];
|
|
519
|
+
attachments?: SendEmailAttachment[];
|
|
520
|
+
}
|
|
521
|
+
interface SendEmailResponse {
|
|
522
|
+
success: boolean;
|
|
523
|
+
messageId: string;
|
|
524
|
+
}
|
|
525
|
+
interface BlinkNotifications {
|
|
526
|
+
email(params: SendEmailRequest): Promise<SendEmailResponse>;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* HTTP client for Blink API requests
|
|
531
|
+
* Handles authentication, error handling, and request/response processing
|
|
532
|
+
*/
|
|
533
|
+
|
|
534
|
+
interface RequestOptions {
|
|
535
|
+
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
|
536
|
+
headers?: Record<string, string>;
|
|
537
|
+
body?: any;
|
|
538
|
+
searchParams?: Record<string, string>;
|
|
539
|
+
signal?: AbortSignal;
|
|
540
|
+
}
|
|
541
|
+
interface BlinkResponse<T = any> {
|
|
542
|
+
data: T;
|
|
543
|
+
status: number;
|
|
544
|
+
headers: Headers;
|
|
545
|
+
}
|
|
546
|
+
declare class HttpClient {
|
|
547
|
+
private readonly authUrl;
|
|
548
|
+
private readonly coreUrl;
|
|
549
|
+
readonly projectId: string;
|
|
550
|
+
private getToken;
|
|
551
|
+
private getValidToken?;
|
|
552
|
+
constructor(config: BlinkClientConfig, getToken: () => string | null, getValidToken?: () => Promise<string | null>);
|
|
553
|
+
/**
|
|
554
|
+
* Make an authenticated request to the Blink API
|
|
555
|
+
*/
|
|
556
|
+
request<T = any>(path: string, options?: RequestOptions): Promise<BlinkResponse<T>>;
|
|
557
|
+
/**
|
|
558
|
+
* GET request
|
|
559
|
+
*/
|
|
560
|
+
get<T = any>(path: string, searchParams?: Record<string, string>): Promise<BlinkResponse<T>>;
|
|
561
|
+
/**
|
|
562
|
+
* POST request
|
|
563
|
+
*/
|
|
564
|
+
post<T = any>(path: string, body?: any, headers?: Record<string, string>): Promise<BlinkResponse<T>>;
|
|
565
|
+
/**
|
|
566
|
+
* PATCH request
|
|
567
|
+
*/
|
|
568
|
+
patch<T = any>(path: string, body?: any, headers?: Record<string, string>): Promise<BlinkResponse<T>>;
|
|
569
|
+
/**
|
|
570
|
+
* DELETE request
|
|
571
|
+
*/
|
|
572
|
+
delete<T = any>(path: string, searchParams?: Record<string, string>): Promise<BlinkResponse<T>>;
|
|
573
|
+
/**
|
|
574
|
+
* Database-specific requests
|
|
575
|
+
*/
|
|
576
|
+
dbGet<T = any>(table: string, searchParams?: Record<string, string>): Promise<BlinkResponse<T[]>>;
|
|
577
|
+
dbPost<T = any>(table: string, body: any, options?: {
|
|
578
|
+
returning?: boolean;
|
|
579
|
+
}): Promise<BlinkResponse<T | T[]>>;
|
|
580
|
+
dbPatch<T = any>(table: string, body: any, searchParams?: Record<string, string>, options?: {
|
|
581
|
+
returning?: boolean;
|
|
582
|
+
}): Promise<BlinkResponse<T[]>>;
|
|
583
|
+
dbDelete<T = any>(table: string, searchParams?: Record<string, string>, options?: {
|
|
584
|
+
returning?: boolean;
|
|
585
|
+
}): Promise<BlinkResponse<T[]>>;
|
|
586
|
+
dbSql<T = any>(query: string, params?: any[]): Promise<BlinkResponse<{
|
|
587
|
+
rows: T[];
|
|
588
|
+
columns: string[];
|
|
589
|
+
rowCount: number;
|
|
590
|
+
executionTime: number;
|
|
591
|
+
}>>;
|
|
592
|
+
dbBatch<T = any>(statements: Array<{
|
|
593
|
+
sql: string;
|
|
594
|
+
args?: any[];
|
|
595
|
+
}>, mode?: 'read' | 'write'): Promise<BlinkResponse<{
|
|
596
|
+
results: Array<{
|
|
597
|
+
rows: T[];
|
|
598
|
+
columns: string[];
|
|
599
|
+
rowCount: number;
|
|
600
|
+
}>;
|
|
601
|
+
executionTime: number;
|
|
602
|
+
success: boolean;
|
|
603
|
+
}>>;
|
|
604
|
+
/**
|
|
605
|
+
* Upload file with progress tracking
|
|
606
|
+
*/
|
|
607
|
+
uploadFile(path: string, file: File | Blob | Buffer, filePath: string, options?: {
|
|
608
|
+
upsert?: boolean;
|
|
609
|
+
onProgress?: (percent: number) => void;
|
|
610
|
+
}): Promise<BlinkResponse<any>>;
|
|
611
|
+
/**
|
|
612
|
+
* Upload with progress tracking using XMLHttpRequest
|
|
613
|
+
*/
|
|
614
|
+
private uploadWithProgress;
|
|
615
|
+
/**
|
|
616
|
+
* AI-specific requests
|
|
617
|
+
*/
|
|
618
|
+
aiText(prompt: string, options?: {
|
|
619
|
+
model?: string;
|
|
620
|
+
messages?: Array<{
|
|
621
|
+
role: string;
|
|
622
|
+
content: string | any[];
|
|
623
|
+
}>;
|
|
624
|
+
stream?: boolean;
|
|
625
|
+
search?: boolean;
|
|
626
|
+
maxSteps?: number;
|
|
627
|
+
experimental_continueSteps?: boolean;
|
|
628
|
+
maxTokens?: number;
|
|
629
|
+
temperature?: number;
|
|
630
|
+
signal?: AbortSignal;
|
|
631
|
+
}): Promise<BlinkResponse<any>>;
|
|
632
|
+
/**
|
|
633
|
+
* Stream AI text generation with Vercel AI SDK data stream format
|
|
634
|
+
*/
|
|
635
|
+
streamAiText(prompt: string, options: {
|
|
636
|
+
model?: string | undefined;
|
|
637
|
+
messages?: {
|
|
638
|
+
role: string;
|
|
639
|
+
content: string | any[];
|
|
640
|
+
}[] | undefined;
|
|
641
|
+
search?: boolean | undefined;
|
|
642
|
+
maxSteps?: number | undefined;
|
|
643
|
+
experimental_continueSteps?: boolean | undefined;
|
|
644
|
+
maxTokens?: number | undefined;
|
|
645
|
+
temperature?: number | undefined;
|
|
646
|
+
signal?: AbortSignal | undefined;
|
|
647
|
+
} | undefined, onChunk: (chunk: string) => void): Promise<any>;
|
|
648
|
+
aiObject(prompt: string, options?: {
|
|
649
|
+
model?: string;
|
|
650
|
+
output?: 'object' | 'array' | 'enum';
|
|
651
|
+
schema?: any;
|
|
652
|
+
enum?: string[];
|
|
653
|
+
stream?: boolean;
|
|
654
|
+
signal?: AbortSignal;
|
|
655
|
+
}): Promise<BlinkResponse<any>>;
|
|
656
|
+
/**
|
|
657
|
+
* Stream AI object generation with Vercel AI SDK data stream format
|
|
658
|
+
*/
|
|
659
|
+
streamAiObject(prompt: string, options: {
|
|
660
|
+
model?: string | undefined;
|
|
661
|
+
output?: "object" | "array" | "enum" | undefined;
|
|
662
|
+
schema?: any;
|
|
663
|
+
enum?: string[] | undefined;
|
|
664
|
+
signal?: AbortSignal | undefined;
|
|
665
|
+
} | undefined, onPartial: (partial: any) => void): Promise<any>;
|
|
666
|
+
aiImage(prompt: string, options?: {
|
|
667
|
+
model?: string;
|
|
668
|
+
size?: string;
|
|
669
|
+
quality?: 'standard' | 'hd';
|
|
670
|
+
n?: number;
|
|
671
|
+
response_format?: 'url' | 'b64_json';
|
|
672
|
+
signal?: AbortSignal;
|
|
673
|
+
}): Promise<BlinkResponse<any>>;
|
|
674
|
+
aiSpeech(text: string, options?: {
|
|
675
|
+
model?: string;
|
|
676
|
+
voice?: string;
|
|
677
|
+
response_format?: string;
|
|
678
|
+
speed?: number;
|
|
679
|
+
signal?: AbortSignal;
|
|
680
|
+
}): Promise<BlinkResponse<any>>;
|
|
681
|
+
aiTranscribe(audio: string | number[], options?: {
|
|
682
|
+
model?: string;
|
|
683
|
+
language?: string;
|
|
684
|
+
response_format?: string;
|
|
685
|
+
signal?: AbortSignal;
|
|
686
|
+
}): Promise<BlinkResponse<any>>;
|
|
687
|
+
/**
|
|
688
|
+
* Data-specific requests
|
|
689
|
+
*/
|
|
690
|
+
dataExtractFromUrl(projectId: string, request: ExtractFromUrlRequest): Promise<BlinkResponse<ExtractFromUrlResponse>>;
|
|
691
|
+
dataExtractFromBlob(projectId: string, file: File, chunking?: boolean, chunkSize?: number): Promise<BlinkResponse<ExtractFromBlobResponse>>;
|
|
692
|
+
dataScrape(projectId: string, request: ScrapeRequest): Promise<BlinkResponse<ScrapeResponse>>;
|
|
693
|
+
dataScreenshot(projectId: string, request: ScreenshotRequest): Promise<BlinkResponse<ScreenshotResponse>>;
|
|
694
|
+
dataFetch(projectId: string, request: FetchRequest): Promise<BlinkResponse<FetchResponse | AsyncFetchResponse>>;
|
|
695
|
+
dataSearch(projectId: string, request: SearchRequest): Promise<BlinkResponse<SearchResponse>>;
|
|
696
|
+
/**
|
|
697
|
+
* Realtime-specific requests
|
|
698
|
+
*/
|
|
699
|
+
realtimePublish(projectId: string, request: {
|
|
700
|
+
channel: string;
|
|
701
|
+
type: string;
|
|
702
|
+
data: any;
|
|
703
|
+
userId?: string;
|
|
704
|
+
metadata?: Record<string, any>;
|
|
705
|
+
}): Promise<BlinkResponse<{
|
|
706
|
+
messageId: string;
|
|
707
|
+
channel: string;
|
|
708
|
+
timestamp: number;
|
|
709
|
+
}>>;
|
|
710
|
+
realtimeGetPresence(projectId: string, channel: string): Promise<BlinkResponse<{
|
|
711
|
+
channel: string;
|
|
712
|
+
users: any[];
|
|
713
|
+
count: number;
|
|
714
|
+
}>>;
|
|
715
|
+
realtimeGetMessages(projectId: string, options: {
|
|
716
|
+
channel: string;
|
|
717
|
+
limit?: number;
|
|
718
|
+
start?: string;
|
|
719
|
+
end?: string;
|
|
720
|
+
}): Promise<BlinkResponse<{
|
|
721
|
+
channel: string;
|
|
722
|
+
messages: any[];
|
|
723
|
+
count: number;
|
|
724
|
+
hasMore: boolean;
|
|
725
|
+
}>>;
|
|
726
|
+
/**
|
|
727
|
+
* Private helper methods
|
|
728
|
+
*/
|
|
729
|
+
private buildUrl;
|
|
730
|
+
private parseResponse;
|
|
731
|
+
private handleErrorResponse;
|
|
732
|
+
/**
|
|
733
|
+
* Parse Vercel AI SDK data stream format
|
|
734
|
+
* Handles text chunks (0:"text"), partial objects (2:[...]), and metadata (d:, e:)
|
|
735
|
+
*/
|
|
736
|
+
private parseDataStream;
|
|
737
|
+
}
|
|
3
738
|
|
|
4
739
|
/**
|
|
5
740
|
* Blink Auth Module - Client-side authentication management
|
|
@@ -810,4 +1545,4 @@ declare class BlinkRealtimeImpl implements BlinkRealtime {
|
|
|
810
1545
|
onPresence(channelName: string, callback: (users: PresenceUser[]) => void): () => void;
|
|
811
1546
|
}
|
|
812
1547
|
|
|
813
|
-
export { type AnalyticsEvent, type AuthStateChangeCallback, BlinkAIImpl, type BlinkAnalytics, BlinkAnalyticsImpl, type BlinkClient, type BlinkData, BlinkDataImpl, BlinkDatabase, BlinkRealtimeChannel, BlinkRealtimeImpl, BlinkStorageImpl, BlinkTable, createClient };
|
|
1548
|
+
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 ListResponse, 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 };
|