@liberfi.io/react-predict 0.3.56 → 0.3.58

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
@@ -16,8 +16,20 @@ function buildQuery(params) {
16
16
  return str ? `?${str}` : "";
17
17
  }
18
18
  var PredictClient = class {
19
- constructor(endpoint) {
19
+ constructor(endpoint, options = {}) {
20
20
  this.endpoint = endpoint;
21
+ this.options = options;
22
+ }
23
+ requestOptions(options) {
24
+ const baseHeaders = typeof this.options.headers === "function" ? this.options.headers() : this.options.headers;
25
+ if (!baseHeaders && !options) return void 0;
26
+ return {
27
+ ...options,
28
+ headers: {
29
+ ...baseHeaders ? Object.fromEntries(new Headers(baseHeaders)) : {},
30
+ ...options?.headers ? Object.fromEntries(new Headers(options.headers)) : {}
31
+ }
32
+ };
21
33
  }
22
34
  // -------------------------------------------------------------------------
23
35
  // Events
@@ -33,7 +45,7 @@ var PredictClient = class {
33
45
  async listEvents(params) {
34
46
  const query = buildQuery(params ?? {});
35
47
  const url = `${this.endpoint}/api/v1/events${query}`;
36
- return await httpGet(url);
48
+ return await httpGet(url, this.requestOptions());
37
49
  }
38
50
  /**
39
51
  * Fetch a single prediction event by its slug.
@@ -49,7 +61,7 @@ var PredictClient = class {
49
61
  async getEvent(slug, source) {
50
62
  const query = source ? buildQuery({ source }) : "";
51
63
  const url = `${this.endpoint}/api/v1/events/${encodeURIComponent(slug)}${query}`;
52
- return await httpGet(url);
64
+ return await httpGet(url, this.requestOptions());
53
65
  }
54
66
  /**
55
67
  * Fetch aggregate statistics for all open events.
@@ -540,8 +552,8 @@ var PredictClient = class {
540
552
  return await httpPost(url, body);
541
553
  }
542
554
  };
543
- function createPredictClient(endpoint) {
544
- return new PredictClient(endpoint);
555
+ function createPredictClient(endpoint, options) {
556
+ return new PredictClient(endpoint, options);
545
557
  }
546
558
 
547
559
  // src/client/ws.ts
@@ -1145,7 +1157,8 @@ function resolveEventsParams(input = {}) {
1145
1157
  minVolume,
1146
1158
  minLiquidity,
1147
1159
  timeRemaining,
1148
- markets_limit = 3
1160
+ markets_limit = 3,
1161
+ lang
1149
1162
  } = input;
1150
1163
  const tag_slug = resolveTagSlug(tagSlugSelection);
1151
1164
  const min_volume = minVolume !== void 0 && minVolume !== "" ? Number(minVolume) : void 0;
@@ -1162,7 +1175,8 @@ function resolveEventsParams(input = {}) {
1162
1175
  ...min_volume !== void 0 && !isNaN(min_volume) ? { min_volume } : {},
1163
1176
  ...min_liquidity !== void 0 && !isNaN(min_liquidity) ? { min_liquidity } : {},
1164
1177
  ...end_before ? { end_before } : {},
1165
- ...markets_limit ? { markets_limit } : {}
1178
+ ...markets_limit ? { markets_limit } : {},
1179
+ ...lang ? { lang } : {}
1166
1180
  };
1167
1181
  }
1168
1182
  function infiniteEventsQueryKey(params) {