@blinkdotnew/sdk 0.4.1 → 0.5.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/dist/index.mjs CHANGED
@@ -38,6 +38,12 @@ var BlinkAIError = class extends BlinkError {
38
38
  this.name = "BlinkAIError";
39
39
  }
40
40
  };
41
+ var BlinkDataError = class extends BlinkError {
42
+ constructor(message, status, details) {
43
+ super(message, "DATA_ERROR", status, details);
44
+ this.name = "BlinkDataError";
45
+ }
46
+ };
41
47
 
42
48
  // ../core/src/query-builder.ts
43
49
  function buildFilterQuery(condition) {
@@ -562,6 +568,12 @@ var HttpClient = class {
562
568
  body: JSON.stringify(request)
563
569
  });
564
570
  }
571
+ async dataFetch(projectId, request) {
572
+ return this.post(`/api/data/${projectId}/fetch`, request);
573
+ }
574
+ async dataSearch(projectId, request) {
575
+ return this.post(`/api/data/${projectId}/search`, request);
576
+ }
565
577
  /**
566
578
  * Private helper methods
567
579
  */
@@ -2390,6 +2402,32 @@ var BlinkDataImpl = class {
2390
2402
  const response = await this.httpClient.dataScreenshot(this.projectId, request);
2391
2403
  return response.data.url;
2392
2404
  }
2405
+ async fetch(request) {
2406
+ const response = await this.httpClient.dataFetch(this.projectId, request);
2407
+ if ("status" in response.data && "headers" in response.data) {
2408
+ return response.data;
2409
+ }
2410
+ throw new BlinkDataError("Unexpected response format from fetch endpoint");
2411
+ }
2412
+ async fetchAsync(request) {
2413
+ const asyncRequest = { ...request, async: true };
2414
+ const response = await this.httpClient.dataFetch(this.projectId, asyncRequest);
2415
+ if ("status" in response.data && response.data.status === "triggered") {
2416
+ return response.data;
2417
+ }
2418
+ throw new BlinkDataError("Unexpected response format from async fetch endpoint");
2419
+ }
2420
+ async search(query, options) {
2421
+ const request = {
2422
+ q: query,
2423
+ location: options?.location,
2424
+ hl: options?.language || "en",
2425
+ tbm: options?.type === "news" ? "nws" : options?.type === "images" ? "isch" : options?.type === "videos" ? "vid" : options?.type === "shopping" ? "shop" : void 0,
2426
+ num: options?.limit
2427
+ };
2428
+ const response = await this.httpClient.dataSearch(this.projectId, request);
2429
+ return response.data;
2430
+ }
2393
2431
  };
2394
2432
 
2395
2433
  // src/client.ts