@blinkdotnew/sdk 0.2.2 → 0.3.0

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/README.md CHANGED
@@ -46,9 +46,11 @@ const { text } = await blink.ai.generateText({
46
46
  })
47
47
 
48
48
  // Data operations (extract text from documents)
49
- const { chunks } = await blink.data.extractFromUrl(
50
- "https://example.com/document.pdf"
51
- )
49
+ const text = await blink.data.extractFromUrl("https://example.com/document.pdf")
50
+
51
+ // Website scraping and screenshots (crystal clear results!)
52
+ const { markdown, metadata, links } = await blink.data.scrape("https://competitor.com")
53
+ const screenshotUrl = await blink.data.screenshot("https://competitor.com")
52
54
 
53
55
  // Storage operations (instant - returns public URL directly)
54
56
  const { publicUrl } = await blink.storage.upload(
@@ -277,6 +279,28 @@ const chunks = await blink.data.extractFromBlob(file, {
277
279
  chunkSize: 3000
278
280
  });
279
281
 
282
+ // Website scraping (NEW!) - Crystal clear destructuring
283
+ const { markdown, metadata, links, extract } = await blink.data.scrape('https://example.com');
284
+ console.log(markdown); // Clean markdown content
285
+ console.log(metadata.title); // Page title
286
+ console.log(links.length); // Number of links found
287
+
288
+ // Even cleaner - destructure only what you need
289
+ const { metadata, extract } = await blink.data.scrape('https://blog.example.com/article');
290
+ console.log(metadata.title); // Always available
291
+ console.log(extract.headings); // Always an array
292
+
293
+ // Website screenshots (NEW!)
294
+ const screenshotUrl = await blink.data.screenshot('https://example.com');
295
+ console.log(screenshotUrl); // Direct URL to screenshot image
296
+
297
+ // Full-page screenshot with custom dimensions
298
+ const fullPageUrl = await blink.data.screenshot('https://example.com', {
299
+ fullPage: true,
300
+ width: 1920,
301
+ height: 1080
302
+ });
303
+
280
304
  // Error handling for data extraction
281
305
  try {
282
306
  const result = await blink.data.extractFromUrl('https://example.com/huge-file.pdf');
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, BlinkData, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, DataExtraction } from '@blink/core';
1
+ import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
2
2
  export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
3
3
 
4
4
  /**
@@ -196,6 +196,42 @@ declare class BlinkDatabase {
196
196
  }>;
197
197
  }
198
198
 
199
+ interface BlinkData {
200
+ extractFromUrl(url: string, options?: {
201
+ chunking?: boolean;
202
+ chunkSize?: number;
203
+ }): Promise<string | string[]>;
204
+ extractFromBlob(file: File, options?: {
205
+ chunking?: boolean;
206
+ chunkSize?: number;
207
+ }): Promise<string | string[]>;
208
+ scrape(url: string): Promise<ScrapeResult>;
209
+ screenshot(url: string, options?: {
210
+ fullPage?: boolean;
211
+ width?: number;
212
+ height?: number;
213
+ }): Promise<string>;
214
+ }
215
+ declare class BlinkDataImpl implements BlinkData {
216
+ private httpClient;
217
+ private projectId;
218
+ constructor(httpClient: HttpClient, projectId: string);
219
+ extractFromUrl(url: string, options?: {
220
+ chunking?: boolean;
221
+ chunkSize?: number;
222
+ }): Promise<string | string[]>;
223
+ extractFromBlob(file: File, options?: {
224
+ chunking?: boolean;
225
+ chunkSize?: number;
226
+ }): Promise<string | string[]>;
227
+ scrape(url: string): Promise<ScrapeResult>;
228
+ screenshot(url: string, options?: {
229
+ fullPage?: boolean;
230
+ width?: number;
231
+ height?: number;
232
+ }): Promise<string>;
233
+ }
234
+
199
235
  /**
200
236
  * Blink Client - Main SDK entry point
201
237
  * Factory function and client class for the Blink SDK
@@ -597,10 +633,4 @@ declare class BlinkAIImpl implements BlinkAI {
597
633
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
598
634
  }
599
635
 
600
- declare class BlinkDataImpl implements BlinkData {
601
- private httpClient;
602
- constructor(httpClient: HttpClient);
603
- extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
604
- }
605
-
606
636
  export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, BlinkStorage, BlinkAI, BlinkData, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse, DataExtraction } from '@blink/core';
1
+ import { BlinkClientConfig, BlinkUser, AuthState, HttpClient, TableOperations, CreateOptions, UpsertOptions, QueryOptions, ListResponse, UpdateOptions, FilterCondition, ScrapeResult, BlinkStorage, BlinkAI, StorageUploadOptions, StorageUploadResponse, TextGenerationRequest, TextGenerationResponse, ObjectGenerationRequest, ObjectGenerationResponse, ImageGenerationRequest, ImageGenerationResponse, SpeechGenerationRequest, SpeechGenerationResponse, TranscriptionRequest, TranscriptionResponse } from '@blink/core';
2
2
  export { AuthState, AuthTokens, BlinkAI, BlinkClientConfig, BlinkData, BlinkStorage, BlinkUser, CreateOptions, DataExtraction, FileObject, FilterCondition, ImageGenerationRequest, ImageGenerationResponse, ListResponse, Message, ObjectGenerationRequest, ObjectGenerationResponse, QueryOptions, SpeechGenerationRequest, SpeechGenerationResponse, StorageUploadOptions, StorageUploadResponse, TableOperations, TextGenerationRequest, TextGenerationResponse, TokenUsage, TranscriptionRequest, TranscriptionResponse, UpdateOptions, UpsertOptions } from '@blink/core';
3
3
 
4
4
  /**
@@ -196,6 +196,42 @@ declare class BlinkDatabase {
196
196
  }>;
197
197
  }
198
198
 
199
+ interface BlinkData {
200
+ extractFromUrl(url: string, options?: {
201
+ chunking?: boolean;
202
+ chunkSize?: number;
203
+ }): Promise<string | string[]>;
204
+ extractFromBlob(file: File, options?: {
205
+ chunking?: boolean;
206
+ chunkSize?: number;
207
+ }): Promise<string | string[]>;
208
+ scrape(url: string): Promise<ScrapeResult>;
209
+ screenshot(url: string, options?: {
210
+ fullPage?: boolean;
211
+ width?: number;
212
+ height?: number;
213
+ }): Promise<string>;
214
+ }
215
+ declare class BlinkDataImpl implements BlinkData {
216
+ private httpClient;
217
+ private projectId;
218
+ constructor(httpClient: HttpClient, projectId: string);
219
+ extractFromUrl(url: string, options?: {
220
+ chunking?: boolean;
221
+ chunkSize?: number;
222
+ }): Promise<string | string[]>;
223
+ extractFromBlob(file: File, options?: {
224
+ chunking?: boolean;
225
+ chunkSize?: number;
226
+ }): Promise<string | string[]>;
227
+ scrape(url: string): Promise<ScrapeResult>;
228
+ screenshot(url: string, options?: {
229
+ fullPage?: boolean;
230
+ width?: number;
231
+ height?: number;
232
+ }): Promise<string>;
233
+ }
234
+
199
235
  /**
200
236
  * Blink Client - Main SDK entry point
201
237
  * Factory function and client class for the Blink SDK
@@ -597,10 +633,4 @@ declare class BlinkAIImpl implements BlinkAI {
597
633
  transcribeAudio(options: TranscriptionRequest): Promise<TranscriptionResponse>;
598
634
  }
599
635
 
600
- declare class BlinkDataImpl implements BlinkData {
601
- private httpClient;
602
- constructor(httpClient: HttpClient);
603
- extractFromUrl(url: string, filename?: string): Promise<DataExtraction>;
604
- }
605
-
606
636
  export { type AuthStateChangeCallback, BlinkAIImpl, type BlinkClient, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
package/dist/index.js CHANGED
@@ -40,12 +40,6 @@ var BlinkAIError = class extends BlinkError {
40
40
  this.name = "BlinkAIError";
41
41
  }
42
42
  };
43
- var BlinkDataError = class extends BlinkError {
44
- constructor(message, status, details) {
45
- super(message, "DATA_ERROR", status, details);
46
- this.name = "BlinkDataError";
47
- }
48
- };
49
43
 
50
44
  // ../core/src/query-builder.ts
51
45
  function buildFilterQuery(condition) {
@@ -538,10 +532,36 @@ var HttpClient = class {
538
532
  /**
539
533
  * Data-specific requests
540
534
  */
541
- async dataExtractFromUrl(url, filename) {
542
- return this.request(`/api/data/${this.projectId}/extract-from-url`, {
535
+ async dataExtractFromUrl(projectId, request) {
536
+ return this.request(`/api/data/${projectId}/extract-from-url`, {
537
+ method: "POST",
538
+ body: JSON.stringify(request)
539
+ });
540
+ }
541
+ async dataExtractFromBlob(projectId, file, chunking, chunkSize) {
542
+ const formData = new FormData();
543
+ formData.append("file", file);
544
+ if (chunking !== void 0) {
545
+ formData.append("chunking", String(chunking));
546
+ }
547
+ if (chunkSize !== void 0) {
548
+ formData.append("chunkSize", String(chunkSize));
549
+ }
550
+ return this.request(`/api/data/${projectId}/extract-from-blob`, {
543
551
  method: "POST",
544
- body: { url, filename }
552
+ body: formData
553
+ });
554
+ }
555
+ async dataScrape(projectId, request) {
556
+ return this.request(`/api/data/${projectId}/scrape`, {
557
+ method: "POST",
558
+ body: JSON.stringify(request)
559
+ });
560
+ }
561
+ async dataScreenshot(projectId, request) {
562
+ return this.request(`/api/data/${projectId}/screenshot`, {
563
+ method: "POST",
564
+ body: JSON.stringify(request)
545
565
  });
546
566
  }
547
567
  /**
@@ -2296,29 +2316,59 @@ var BlinkAIImpl = class {
2296
2316
 
2297
2317
  // src/data.ts
2298
2318
  var BlinkDataImpl = class {
2299
- constructor(httpClient) {
2319
+ constructor(httpClient, projectId) {
2300
2320
  this.httpClient = httpClient;
2301
- }
2302
- async extractFromUrl(url, filename) {
2303
- try {
2304
- const response = await this.httpClient.dataExtractFromUrl(url, filename);
2305
- if (response.data?.chunks) {
2306
- return {
2307
- chunks: response.data.chunks
2308
- };
2309
- } else {
2310
- throw new BlinkDataError("Invalid response format: missing chunks");
2311
- }
2312
- } catch (error) {
2313
- if (error instanceof BlinkDataError) {
2314
- throw error;
2321
+ this.projectId = projectId;
2322
+ }
2323
+ async extractFromUrl(url, options = {}) {
2324
+ const { chunking = false, chunkSize } = options;
2325
+ const request = { url, chunking, chunkSize };
2326
+ const response = await this.httpClient.dataExtractFromUrl(this.projectId, request);
2327
+ return chunking ? response.data.chunks : response.data.text;
2328
+ }
2329
+ async extractFromBlob(file, options = {}) {
2330
+ const { chunking = false, chunkSize } = options;
2331
+ const response = await this.httpClient.dataExtractFromBlob(this.projectId, file, chunking, chunkSize);
2332
+ return chunking ? response.data.chunks : response.data.text;
2333
+ }
2334
+ async scrape(url) {
2335
+ const request = {
2336
+ url,
2337
+ formats: ["markdown", "html", "links", "extract", "metadata"]
2338
+ };
2339
+ const response = await this.httpClient.dataScrape(this.projectId, request);
2340
+ const data = response.data;
2341
+ return {
2342
+ markdown: data.markdown || "",
2343
+ html: data.html || "",
2344
+ metadata: {
2345
+ title: data.metadata?.title || "",
2346
+ description: data.metadata?.description || "",
2347
+ url: data.metadata?.url || url,
2348
+ domain: data.metadata?.domain || new URL(url).hostname,
2349
+ favicon: data.metadata?.favicon,
2350
+ image: data.metadata?.image,
2351
+ author: data.metadata?.author,
2352
+ publishedTime: data.metadata?.publishedTime,
2353
+ modifiedTime: data.metadata?.modifiedTime,
2354
+ type: data.metadata?.type,
2355
+ siteName: data.metadata?.siteName,
2356
+ locale: data.metadata?.locale,
2357
+ keywords: data.metadata?.keywords || []
2358
+ },
2359
+ links: data.links || [],
2360
+ extract: {
2361
+ title: data.extract?.title || data.metadata?.title || "",
2362
+ description: data.extract?.description || data.metadata?.description || "",
2363
+ headings: data.extract?.headings || [],
2364
+ text: data.extract?.text || data.markdown || ""
2315
2365
  }
2316
- throw new BlinkDataError(
2317
- `Data extraction failed: ${error instanceof Error ? error.message : "Unknown error"}`,
2318
- void 0,
2319
- { originalError: error }
2320
- );
2321
- }
2366
+ };
2367
+ }
2368
+ async screenshot(url, options = {}) {
2369
+ const request = { url, ...options };
2370
+ const response = await this.httpClient.dataScreenshot(this.projectId, request);
2371
+ return response.data.url;
2322
2372
  }
2323
2373
  };
2324
2374
 
@@ -2340,7 +2390,7 @@ var BlinkClientImpl = class {
2340
2390
  this.db = new BlinkDatabase(this.httpClient);
2341
2391
  this.storage = new BlinkStorageImpl(this.httpClient);
2342
2392
  this.ai = new BlinkAIImpl(this.httpClient);
2343
- this.data = new BlinkDataImpl(this.httpClient);
2393
+ this.data = new BlinkDataImpl(this.httpClient, config.projectId);
2344
2394
  }
2345
2395
  };
2346
2396
  function createClient(config) {