@liberfi.io/react-predict 0.3.55 → 0.3.57

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/server.mjs CHANGED
@@ -23,7 +23,8 @@ function resolveEventsParams(input = {}) {
23
23
  minVolume,
24
24
  minLiquidity,
25
25
  timeRemaining,
26
- markets_limit = 3
26
+ markets_limit = 3,
27
+ lang
27
28
  } = input;
28
29
  const tag_slug = resolveTagSlug(tagSlugSelection);
29
30
  const min_volume = minVolume !== void 0 && minVolume !== "" ? Number(minVolume) : void 0;
@@ -40,7 +41,8 @@ function resolveEventsParams(input = {}) {
40
41
  ...min_volume !== void 0 && !isNaN(min_volume) ? { min_volume } : {},
41
42
  ...min_liquidity !== void 0 && !isNaN(min_liquidity) ? { min_liquidity } : {},
42
43
  ...end_before ? { end_before } : {},
43
- ...markets_limit ? { markets_limit } : {}
44
+ ...markets_limit ? { markets_limit } : {},
45
+ ...lang ? { lang } : {}
44
46
  };
45
47
  }
46
48
  function infiniteEventsQueryKey(params) {
@@ -93,8 +95,20 @@ function buildQuery(params) {
93
95
  return str ? `?${str}` : "";
94
96
  }
95
97
  var PredictClient = class {
96
- constructor(endpoint) {
98
+ constructor(endpoint, options = {}) {
97
99
  this.endpoint = endpoint;
100
+ this.options = options;
101
+ }
102
+ requestOptions(options) {
103
+ const baseHeaders = typeof this.options.headers === "function" ? this.options.headers() : this.options.headers;
104
+ if (!baseHeaders && !options) return void 0;
105
+ return {
106
+ ...options,
107
+ headers: {
108
+ ...baseHeaders ? Object.fromEntries(new Headers(baseHeaders)) : {},
109
+ ...options?.headers ? Object.fromEntries(new Headers(options.headers)) : {}
110
+ }
111
+ };
98
112
  }
99
113
  // -------------------------------------------------------------------------
100
114
  // Events
@@ -110,7 +124,7 @@ var PredictClient = class {
110
124
  async listEvents(params) {
111
125
  const query = buildQuery(params ?? {});
112
126
  const url = `${this.endpoint}/api/v1/events${query}`;
113
- return await httpGet(url);
127
+ return await httpGet(url, this.requestOptions());
114
128
  }
115
129
  /**
116
130
  * Fetch a single prediction event by its slug.
@@ -126,7 +140,7 @@ var PredictClient = class {
126
140
  async getEvent(slug, source) {
127
141
  const query = source ? buildQuery({ source }) : "";
128
142
  const url = `${this.endpoint}/api/v1/events/${encodeURIComponent(slug)}${query}`;
129
- return await httpGet(url);
143
+ return await httpGet(url, this.requestOptions());
130
144
  }
131
145
  /**
132
146
  * Fetch aggregate statistics for all open events.
@@ -617,8 +631,8 @@ var PredictClient = class {
617
631
  return await httpPost(url, body);
618
632
  }
619
633
  };
620
- function createPredictClient(endpoint) {
621
- return new PredictClient(endpoint);
634
+ function createPredictClient(endpoint, options) {
635
+ return new PredictClient(endpoint, options);
622
636
  }
623
637
 
624
638
  // src/client/ws.ts