@blinkdotnew/sdk 0.2.1 → 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 +71 -1
- package/dist/index.d.mts +40 -3
- package/dist/index.d.ts +40 -3
- package/dist/index.js +96 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +96 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -527,6 +527,41 @@ var HttpClient = class {
|
|
|
527
527
|
signal
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
|
+
/**
|
|
531
|
+
* Data-specific requests
|
|
532
|
+
*/
|
|
533
|
+
async dataExtractFromUrl(projectId, request) {
|
|
534
|
+
return this.request(`/api/data/${projectId}/extract-from-url`, {
|
|
535
|
+
method: "POST",
|
|
536
|
+
body: JSON.stringify(request)
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
async dataExtractFromBlob(projectId, file, chunking, chunkSize) {
|
|
540
|
+
const formData = new FormData();
|
|
541
|
+
formData.append("file", file);
|
|
542
|
+
if (chunking !== void 0) {
|
|
543
|
+
formData.append("chunking", String(chunking));
|
|
544
|
+
}
|
|
545
|
+
if (chunkSize !== void 0) {
|
|
546
|
+
formData.append("chunkSize", String(chunkSize));
|
|
547
|
+
}
|
|
548
|
+
return this.request(`/api/data/${projectId}/extract-from-blob`, {
|
|
549
|
+
method: "POST",
|
|
550
|
+
body: formData
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
async dataScrape(projectId, request) {
|
|
554
|
+
return this.request(`/api/data/${projectId}/scrape`, {
|
|
555
|
+
method: "POST",
|
|
556
|
+
body: JSON.stringify(request)
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
async dataScreenshot(projectId, request) {
|
|
560
|
+
return this.request(`/api/data/${projectId}/screenshot`, {
|
|
561
|
+
method: "POST",
|
|
562
|
+
body: JSON.stringify(request)
|
|
563
|
+
});
|
|
564
|
+
}
|
|
530
565
|
/**
|
|
531
566
|
* Private helper methods
|
|
532
567
|
*/
|
|
@@ -2277,12 +2312,71 @@ var BlinkAIImpl = class {
|
|
|
2277
2312
|
}
|
|
2278
2313
|
};
|
|
2279
2314
|
|
|
2315
|
+
// src/data.ts
|
|
2316
|
+
var BlinkDataImpl = class {
|
|
2317
|
+
constructor(httpClient, projectId) {
|
|
2318
|
+
this.httpClient = httpClient;
|
|
2319
|
+
this.projectId = projectId;
|
|
2320
|
+
}
|
|
2321
|
+
async extractFromUrl(url, options = {}) {
|
|
2322
|
+
const { chunking = false, chunkSize } = options;
|
|
2323
|
+
const request = { url, chunking, chunkSize };
|
|
2324
|
+
const response = await this.httpClient.dataExtractFromUrl(this.projectId, request);
|
|
2325
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2326
|
+
}
|
|
2327
|
+
async extractFromBlob(file, options = {}) {
|
|
2328
|
+
const { chunking = false, chunkSize } = options;
|
|
2329
|
+
const response = await this.httpClient.dataExtractFromBlob(this.projectId, file, chunking, chunkSize);
|
|
2330
|
+
return chunking ? response.data.chunks : response.data.text;
|
|
2331
|
+
}
|
|
2332
|
+
async scrape(url) {
|
|
2333
|
+
const request = {
|
|
2334
|
+
url,
|
|
2335
|
+
formats: ["markdown", "html", "links", "extract", "metadata"]
|
|
2336
|
+
};
|
|
2337
|
+
const response = await this.httpClient.dataScrape(this.projectId, request);
|
|
2338
|
+
const data = response.data;
|
|
2339
|
+
return {
|
|
2340
|
+
markdown: data.markdown || "",
|
|
2341
|
+
html: data.html || "",
|
|
2342
|
+
metadata: {
|
|
2343
|
+
title: data.metadata?.title || "",
|
|
2344
|
+
description: data.metadata?.description || "",
|
|
2345
|
+
url: data.metadata?.url || url,
|
|
2346
|
+
domain: data.metadata?.domain || new URL(url).hostname,
|
|
2347
|
+
favicon: data.metadata?.favicon,
|
|
2348
|
+
image: data.metadata?.image,
|
|
2349
|
+
author: data.metadata?.author,
|
|
2350
|
+
publishedTime: data.metadata?.publishedTime,
|
|
2351
|
+
modifiedTime: data.metadata?.modifiedTime,
|
|
2352
|
+
type: data.metadata?.type,
|
|
2353
|
+
siteName: data.metadata?.siteName,
|
|
2354
|
+
locale: data.metadata?.locale,
|
|
2355
|
+
keywords: data.metadata?.keywords || []
|
|
2356
|
+
},
|
|
2357
|
+
links: data.links || [],
|
|
2358
|
+
extract: {
|
|
2359
|
+
title: data.extract?.title || data.metadata?.title || "",
|
|
2360
|
+
description: data.extract?.description || data.metadata?.description || "",
|
|
2361
|
+
headings: data.extract?.headings || [],
|
|
2362
|
+
text: data.extract?.text || data.markdown || ""
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
}
|
|
2366
|
+
async screenshot(url, options = {}) {
|
|
2367
|
+
const request = { url, ...options };
|
|
2368
|
+
const response = await this.httpClient.dataScreenshot(this.projectId, request);
|
|
2369
|
+
return response.data.url;
|
|
2370
|
+
}
|
|
2371
|
+
};
|
|
2372
|
+
|
|
2280
2373
|
// src/client.ts
|
|
2281
2374
|
var BlinkClientImpl = class {
|
|
2282
2375
|
auth;
|
|
2283
2376
|
db;
|
|
2284
2377
|
storage;
|
|
2285
2378
|
ai;
|
|
2379
|
+
data;
|
|
2286
2380
|
httpClient;
|
|
2287
2381
|
constructor(config) {
|
|
2288
2382
|
this.auth = new BlinkAuth(config);
|
|
@@ -2294,6 +2388,7 @@ var BlinkClientImpl = class {
|
|
|
2294
2388
|
this.db = new BlinkDatabase(this.httpClient);
|
|
2295
2389
|
this.storage = new BlinkStorageImpl(this.httpClient);
|
|
2296
2390
|
this.ai = new BlinkAIImpl(this.httpClient);
|
|
2391
|
+
this.data = new BlinkDataImpl(this.httpClient, config.projectId);
|
|
2297
2392
|
}
|
|
2298
2393
|
};
|
|
2299
2394
|
function createClient(config) {
|
|
@@ -2307,6 +2402,6 @@ function createClient(config) {
|
|
|
2307
2402
|
return new BlinkClientImpl(clientConfig);
|
|
2308
2403
|
}
|
|
2309
2404
|
|
|
2310
|
-
export { BlinkAIImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
|
2405
|
+
export { BlinkAIImpl, BlinkDataImpl, BlinkDatabase, BlinkStorageImpl, BlinkTable, createClient };
|
|
2311
2406
|
//# sourceMappingURL=index.mjs.map
|
|
2312
2407
|
//# sourceMappingURL=index.mjs.map
|