@blinkdotnew/sdk 0.4.0 → 0.4.2

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.request(`/api/data/${projectId}/fetch`, {
573
+ method: "POST",
574
+ body: JSON.stringify(request)
575
+ });
576
+ }
565
577
  /**
566
578
  * Private helper methods
567
579
  */
@@ -2390,6 +2402,21 @@ 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
+ }
2393
2420
  };
2394
2421
 
2395
2422
  // src/client.ts