puntersedge 1.1.0 → 1.2.1

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/src/http.ts CHANGED
@@ -18,6 +18,9 @@ import {
18
18
  } from "./errors.js";
19
19
  import { parseCredits, parseUpgrade, type Credits } from "./credits.js";
20
20
 
21
+ /** The verbs this API uses. */
22
+ export type HttpMethod = "GET" | "POST" | "PATCH" | "DELETE";
23
+
21
24
  /** A query value the client knows how to serialise. */
22
25
  export type QueryValue = string | number | boolean | null | undefined | (string | number)[];
23
26
  export type Query = Record<string, QueryValue>;
@@ -38,6 +41,11 @@ export interface RequestOptions {
38
41
  timeoutMs?: number;
39
42
  /** Extra headers for this call. */
40
43
  headers?: Record<string, string>;
44
+ /**
45
+ * `binary` returns the body as bytes (`Uint8Array`) instead of parsing it, for the bulk
46
+ * dataset files, which are Parquet or gzip-CSV. Default: JSON, with text as the fallback.
47
+ */
48
+ responseType?: "json" | "binary";
41
49
  }
42
50
 
43
51
  export interface TransportConfig {
@@ -209,7 +217,7 @@ function withTimeout(signal: AbortSignal | undefined, ms: number): {
209
217
 
210
218
  export async function request<T>(
211
219
  config: TransportConfig,
212
- method: "GET" | "POST" | "DELETE",
220
+ method: HttpMethod,
213
221
  path: string,
214
222
  params?: Query,
215
223
  jsonBody?: unknown,
@@ -256,6 +264,10 @@ export async function request<T>(
256
264
 
257
265
  // 204 and an empty 200 (DELETE /v1/webhooks/{id}) have no body to parse.
258
266
  if (res.status === 204) return { data: undefined as T, credits, headers: res.headers };
267
+ if (options.responseType === "binary") {
268
+ const bytes = new Uint8Array(await res.arrayBuffer());
269
+ return { data: bytes as unknown as T, credits, headers: res.headers };
270
+ }
259
271
  const body = await readBody(res);
260
272
  if (body.text === undefined || body.text === "") {
261
273
  return { data: undefined as T, credits, headers: res.headers };
package/src/index.ts CHANGED
@@ -37,6 +37,8 @@ export {
37
37
  type SportOddsOptions,
38
38
  type ArbOptions,
39
39
  type WebhookCreateInput,
40
+ type BulkDownloadOptions,
41
+ type BulkDownload,
40
42
  } from "./client.js";
41
43
 
42
44
  export {
@@ -61,7 +63,9 @@ export {
61
63
  type UpgradeHint,
62
64
  } from "./credits.js";
63
65
 
64
- export { buildQuery, type Query, type QueryValue, type Result, type RequestOptions } from "./http.js";
66
+ export {
67
+ buildQuery, type HttpMethod, type Query, type QueryValue, type Result, type RequestOptions,
68
+ } from "./http.js";
65
69
 
66
70
  export { verifyWebhookSignature, type VerifyOptions } from "./webhook.js";
67
71