fansunited-data-layer 0.0.7 → 0.0.9

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.
Files changed (51) hide show
  1. package/README.md +44 -0
  2. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts +148 -0
  3. package/dist/api/sportal365-sports/football/competitions/competition.types.d.ts.map +1 -0
  4. package/dist/api/sportal365-sports/football/competitions/index.d.ts +51 -0
  5. package/dist/api/sportal365-sports/football/competitions/index.d.ts.map +1 -0
  6. package/dist/api/sportal365-sports/football/competitions/utils.d.ts +14 -0
  7. package/dist/api/sportal365-sports/football/competitions/utils.d.ts.map +1 -0
  8. package/dist/api/sportal365-sports/football/index.d.ts +2 -0
  9. package/dist/api/sportal365-sports/football/index.d.ts.map +1 -1
  10. package/dist/api/sportal365-sports/football/matches/index.d.ts.map +1 -1
  11. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts +3 -0
  12. package/dist/api/sportal365-sports/football/matches/types/commentary.types.d.ts.map +1 -1
  13. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts +13 -0
  14. package/dist/api/sportal365-sports/football/matches/types/option.types.d.ts.map +1 -1
  15. package/dist/api/sportal365-sports/football/standings/http.d.ts.map +1 -1
  16. package/dist/api/sportal365-sports/football/standings/index.d.ts.map +1 -1
  17. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts +3 -0
  18. package/dist/api/sportal365-sports/football/standings/standing.types.d.ts.map +1 -1
  19. package/dist/api/sportal365-sports/football/teams/index.d.ts.map +1 -1
  20. package/dist/api/sportal365-sports/football/teams/team.types.d.ts +3 -0
  21. package/dist/api/sportal365-sports/football/teams/team.types.d.ts.map +1 -1
  22. package/dist/api/sportal365-sports/http.d.ts +12 -0
  23. package/dist/api/sportal365-sports/http.d.ts.map +1 -1
  24. package/dist/api/sportal365-sports/index.d.ts +3 -2
  25. package/dist/api/sportal365-sports/index.d.ts.map +1 -1
  26. package/dist/client.cjs +6 -0
  27. package/dist/client.d.ts +20 -0
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +451 -0
  30. package/dist/fansunited-data-layer.cjs +1 -0
  31. package/dist/fansunited-data-layer.js +52 -1093
  32. package/dist/helpers/competition.helpers.d.ts +22 -0
  33. package/dist/helpers/competition.helpers.d.ts.map +1 -0
  34. package/dist/helpers/index.d.ts +6 -0
  35. package/dist/helpers/index.d.ts.map +1 -0
  36. package/dist/helpers/team.helpers.d.ts +45 -0
  37. package/dist/helpers/team.helpers.d.ts.map +1 -0
  38. package/dist/index-4gbkCyy3.cjs +1 -0
  39. package/dist/index-C8byrMrI.js +806 -0
  40. package/dist/index.d.ts +5 -4
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/providers/competition.provider.d.ts +1 -1
  43. package/dist/providers/competition.provider.d.ts.map +1 -1
  44. package/dist/providers/competition.types.d.ts +21 -3
  45. package/dist/providers/competition.types.d.ts.map +1 -1
  46. package/dist/types/canonical/base.types.d.ts +51 -0
  47. package/dist/types/canonical/base.types.d.ts.map +1 -1
  48. package/dist/types/canonical/index.d.ts +1 -1
  49. package/dist/types/canonical/index.d.ts.map +1 -1
  50. package/package.json +8 -3
  51. package/dist/fansunited-data-layer.umd.cjs +0 -6
package/dist/client.js ADDED
@@ -0,0 +1,451 @@
1
+ "use client";
2
+ import oe, { createContext as ae, useContext as se, useState as S, useEffect as y, useCallback as u, useMemo as ie } from "react";
3
+ import { j as ce, m as le, k as ue, l as Q } from "./index-C8byrMrI.js";
4
+ var X = { exports: {} }, M = {};
5
+ var K;
6
+ function fe() {
7
+ if (K) return M;
8
+ K = 1;
9
+ var c = Symbol.for("react.transitional.element"), E = Symbol.for("react.fragment");
10
+ function v(_, l, f) {
11
+ var R = null;
12
+ if (f !== void 0 && (R = "" + f), l.key !== void 0 && (R = "" + l.key), "key" in l) {
13
+ f = {};
14
+ for (var d in l)
15
+ d !== "key" && (f[d] = l[d]);
16
+ } else f = l;
17
+ return l = f.ref, {
18
+ $$typeof: c,
19
+ type: _,
20
+ key: R,
21
+ ref: l !== void 0 ? l : null,
22
+ props: f
23
+ };
24
+ }
25
+ return M.Fragment = E, M.jsx = v, M.jsxs = v, M;
26
+ }
27
+ var F = {};
28
+ var ee;
29
+ function me() {
30
+ return ee || (ee = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ function c(e) {
32
+ if (e == null) return null;
33
+ if (typeof e == "function")
34
+ return e.$$typeof === B ? null : e.displayName || e.name || null;
35
+ if (typeof e == "string") return e;
36
+ switch (e) {
37
+ case i:
38
+ return "Fragment";
39
+ case T:
40
+ return "Profiler";
41
+ case W:
42
+ return "StrictMode";
43
+ case J:
44
+ return "Suspense";
45
+ case H:
46
+ return "SuspenseList";
47
+ case z:
48
+ return "Activity";
49
+ }
50
+ if (typeof e == "object")
51
+ switch (typeof e.tag == "number" && console.error(
52
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
53
+ ), e.$$typeof) {
54
+ case U:
55
+ return "Portal";
56
+ case V:
57
+ return e.displayName || "Context";
58
+ case I:
59
+ return (e._context.displayName || "Context") + ".Consumer";
60
+ case q:
61
+ var n = e.render;
62
+ return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
63
+ case h:
64
+ return n = e.displayName || null, n !== null ? n : c(e.type) || "Memo";
65
+ case P:
66
+ n = e._payload, e = e._init;
67
+ try {
68
+ return c(e(n));
69
+ } catch {
70
+ }
71
+ }
72
+ return null;
73
+ }
74
+ function E(e) {
75
+ return "" + e;
76
+ }
77
+ function v(e) {
78
+ try {
79
+ E(e);
80
+ var n = !1;
81
+ } catch {
82
+ n = !0;
83
+ }
84
+ if (n) {
85
+ n = console;
86
+ var a = n.error, t = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
87
+ return a.call(
88
+ n,
89
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
90
+ t
91
+ ), E(e);
92
+ }
93
+ }
94
+ function _(e) {
95
+ if (e === i) return "<>";
96
+ if (typeof e == "object" && e !== null && e.$$typeof === P)
97
+ return "<...>";
98
+ try {
99
+ var n = c(e);
100
+ return n ? "<" + n + ">" : "<...>";
101
+ } catch {
102
+ return "<...>";
103
+ }
104
+ }
105
+ function l() {
106
+ var e = w.A;
107
+ return e === null ? null : e.getOwner();
108
+ }
109
+ function f() {
110
+ return Error("react-stack-top-frame");
111
+ }
112
+ function R(e) {
113
+ if (x.call(e, "key")) {
114
+ var n = Object.getOwnPropertyDescriptor(e, "key").get;
115
+ if (n && n.isReactWarning) return !1;
116
+ }
117
+ return e.key !== void 0;
118
+ }
119
+ function d(e, n) {
120
+ function a() {
121
+ p || (p = !0, console.error(
122
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
123
+ n
124
+ ));
125
+ }
126
+ a.isReactWarning = !0, Object.defineProperty(e, "key", {
127
+ get: a,
128
+ configurable: !0
129
+ });
130
+ }
131
+ function Y() {
132
+ var e = c(this.type);
133
+ return j[e] || (j[e] = !0, console.error(
134
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
135
+ )), e = this.props.ref, e !== void 0 ? e : null;
136
+ }
137
+ function $(e, n, a, t, r, s) {
138
+ var o = a.ref;
139
+ return e = {
140
+ $$typeof: m,
141
+ type: e,
142
+ key: n,
143
+ props: a,
144
+ _owner: t
145
+ }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
146
+ enumerable: !1,
147
+ get: Y
148
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
149
+ configurable: !1,
150
+ enumerable: !1,
151
+ writable: !0,
152
+ value: 0
153
+ }), Object.defineProperty(e, "_debugInfo", {
154
+ configurable: !1,
155
+ enumerable: !1,
156
+ writable: !0,
157
+ value: null
158
+ }), Object.defineProperty(e, "_debugStack", {
159
+ configurable: !1,
160
+ enumerable: !1,
161
+ writable: !0,
162
+ value: r
163
+ }), Object.defineProperty(e, "_debugTask", {
164
+ configurable: !1,
165
+ enumerable: !1,
166
+ writable: !0,
167
+ value: s
168
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
169
+ }
170
+ function A(e, n, a, t, r, s) {
171
+ var o = n.children;
172
+ if (o !== void 0)
173
+ if (t)
174
+ if (G(o)) {
175
+ for (t = 0; t < o.length; t++)
176
+ L(o[t]);
177
+ Object.freeze && Object.freeze(o);
178
+ } else
179
+ console.error(
180
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
181
+ );
182
+ else L(o);
183
+ if (x.call(n, "key")) {
184
+ o = c(e);
185
+ var g = Object.keys(n).filter(function(ne) {
186
+ return ne !== "key";
187
+ });
188
+ t = 0 < g.length ? "{key: someKey, " + g.join(": ..., ") + ": ...}" : "{key: someKey}", D[o + t] || (g = 0 < g.length ? "{" + g.join(": ..., ") + ": ...}" : "{}", console.error(
189
+ `A props object containing a "key" prop is being spread into JSX:
190
+ let props = %s;
191
+ <%s {...props} />
192
+ React keys must be passed directly to JSX without using spread:
193
+ let props = %s;
194
+ <%s key={someKey} {...props} />`,
195
+ t,
196
+ o,
197
+ g,
198
+ o
199
+ ), D[o + t] = !0);
200
+ }
201
+ if (o = null, a !== void 0 && (v(a), o = "" + a), R(n) && (v(n.key), o = "" + n.key), "key" in n) {
202
+ a = {};
203
+ for (var Z in n)
204
+ Z !== "key" && (a[Z] = n[Z]);
205
+ } else a = n;
206
+ return o && d(
207
+ a,
208
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
209
+ ), $(
210
+ e,
211
+ o,
212
+ a,
213
+ l(),
214
+ r,
215
+ s
216
+ );
217
+ }
218
+ function L(e) {
219
+ b(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === P && (e._payload.status === "fulfilled" ? b(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
220
+ }
221
+ function b(e) {
222
+ return typeof e == "object" && e !== null && e.$$typeof === m;
223
+ }
224
+ var k = oe, m = Symbol.for("react.transitional.element"), U = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), W = Symbol.for("react.strict_mode"), T = Symbol.for("react.profiler"), I = Symbol.for("react.consumer"), V = Symbol.for("react.context"), q = Symbol.for("react.forward_ref"), J = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), P = Symbol.for("react.lazy"), z = Symbol.for("react.activity"), B = Symbol.for("react.client.reference"), w = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, x = Object.prototype.hasOwnProperty, G = Array.isArray, O = console.createTask ? console.createTask : function() {
225
+ return null;
226
+ };
227
+ k = {
228
+ react_stack_bottom_frame: function(e) {
229
+ return e();
230
+ }
231
+ };
232
+ var p, j = {}, C = k.react_stack_bottom_frame.bind(
233
+ k,
234
+ f
235
+ )(), N = O(_(f)), D = {};
236
+ F.Fragment = i, F.jsx = function(e, n, a) {
237
+ var t = 1e4 > w.recentlyCreatedOwnerStacks++;
238
+ return A(
239
+ e,
240
+ n,
241
+ a,
242
+ !1,
243
+ t ? Error("react-stack-top-frame") : C,
244
+ t ? O(_(e)) : N
245
+ );
246
+ }, F.jsxs = function(e, n, a) {
247
+ var t = 1e4 > w.recentlyCreatedOwnerStacks++;
248
+ return A(
249
+ e,
250
+ n,
251
+ a,
252
+ !0,
253
+ t ? Error("react-stack-top-frame") : C,
254
+ t ? O(_(e)) : N
255
+ );
256
+ };
257
+ })()), F;
258
+ }
259
+ var te;
260
+ function de() {
261
+ return te || (te = 1, process.env.NODE_ENV === "production" ? X.exports = fe() : X.exports = me()), X.exports;
262
+ }
263
+ var Ee = de();
264
+ const re = ae(null);
265
+ function ge() {
266
+ const c = se(re);
267
+ if (!c)
268
+ throw new Error("useCompetition must be used within CompetitionProvider");
269
+ return c;
270
+ }
271
+ function _e({
272
+ competitionId: c,
273
+ seasonId: E,
274
+ stageId: v,
275
+ competition: _,
276
+ season: l,
277
+ matches: f,
278
+ standings: R,
279
+ previousSeasons: d,
280
+ config: Y,
281
+ autoRefresh: $ = !0,
282
+ refreshInterval: A = 3e4,
283
+ children: L
284
+ }) {
285
+ const [b, k] = S(_), [m, U] = S(l), [i, W] = S(f ?? []), [T, I] = S(R ?? []), [V, q] = S(!1), [J, H] = S(void 0);
286
+ y(() => {
287
+ k(_);
288
+ }, [_]), y(() => {
289
+ U(l);
290
+ }, [l]), y(() => {
291
+ W(f ?? []);
292
+ }, [f]), y(() => {
293
+ I(R ?? []);
294
+ }, [R]), y(() => {
295
+ if (b && m) return;
296
+ (async () => {
297
+ try {
298
+ const r = E ?? m?.id, [s, o] = await Promise.all([
299
+ b ? Promise.resolve(b) : ue(c),
300
+ m ? Promise.resolve(m) : r ? Q({ seasonId: r }) : Q({ competitionId: c, status: "CURRENT" })
301
+ ]);
302
+ b || k(s), m || U(o);
303
+ } catch (r) {
304
+ console.error("[CompetitionProvider] Error fetching initial data:", r);
305
+ }
306
+ })();
307
+ }, [c, E]);
308
+ const h = u(async () => {
309
+ const t = E ?? m?.id;
310
+ if (t) {
311
+ q(!0);
312
+ try {
313
+ const r = v ?? m?.stages?.find((g) => g.status === "ACTIVE")?.id, [s, o] = await Promise.all([
314
+ ce({
315
+ tournamentIds: [c],
316
+ seasonIds: [t],
317
+ stageIds: r ? [r] : void 0,
318
+ limit: 552,
319
+ offset: 0
320
+ }),
321
+ r ? le({
322
+ stageId: r
323
+ }) : Promise.resolve({ entries: [], metadata: void 0, legend: void 0 })
324
+ ]);
325
+ W(s), I(o.entries), H(/* @__PURE__ */ new Date());
326
+ } catch (r) {
327
+ console.error("[CompetitionProvider] Error refreshing matches/standings:", r);
328
+ } finally {
329
+ q(!1);
330
+ }
331
+ }
332
+ }, [c, E, v, m?.id, m?.stages]);
333
+ y(() => {
334
+ if (!$ || !i.some((s) => s.status.code === "live")) return;
335
+ const r = setInterval(() => {
336
+ h();
337
+ }, A);
338
+ return () => clearInterval(r);
339
+ }, [$, A, i, h]);
340
+ const P = u((t) => i.find((r) => r.id === t), [i]), z = u(
341
+ (t) => i.filter((r) => r.competitorOne.id === t || r.competitorTwo.id === t),
342
+ [i]
343
+ ), B = u(
344
+ (t) => i.filter((r) => r.timing.kickoffTime.toISOString().startsWith(t)),
345
+ [i]
346
+ ), w = u(
347
+ (t) => i.filter((r) => r.round?.id === t),
348
+ [i]
349
+ ), x = u(() => i.filter((t) => t.status.code === "live"), [i]), G = u(
350
+ (t) => {
351
+ const r = /* @__PURE__ */ new Date();
352
+ let s = i.filter((o) => o.status.code === "not_started" && o.timing.kickoffTime > r);
353
+ return t && (s = s.filter((o) => o.competitorOne.id === t || o.competitorTwo.id === t)), s.sort((o, g) => o.timing.kickoffTime.getTime() - g.timing.kickoffTime.getTime());
354
+ },
355
+ [i]
356
+ ), O = u(
357
+ (t) => {
358
+ let r = i.filter((s) => s.status.code === "finished");
359
+ return t && (r = r.filter((s) => s.competitorOne.id === t || s.competitorTwo.id === t)), r.sort((s, o) => o.timing.kickoffTime.getTime() - s.timing.kickoffTime.getTime());
360
+ },
361
+ [i]
362
+ ), p = u(
363
+ (t) => T.find((r) => r.competitor.id === t),
364
+ [T]
365
+ ), j = u((t) => p(t)?.form?.formString, [p]), C = u((t) => p(t)?.stats, [p]), N = u(
366
+ (t) => [...T].sort((r, s) => r.rank - s.rank).slice(0, t),
367
+ [T]
368
+ ), D = u(
369
+ (t) => [...T].sort((r, s) => s.rank - r.rank).slice(0, t),
370
+ [T]
371
+ ), e = u(
372
+ (t) => d?.find((r) => r.id === t)?.matches,
373
+ [d]
374
+ ), n = u(
375
+ (t) => d?.find((r) => r.id === t)?.standings,
376
+ [d]
377
+ ), a = ie(
378
+ () => ({
379
+ // Core identifiers
380
+ competitionId: c,
381
+ seasonId: E,
382
+ stageId: v,
383
+ // Competition and season info
384
+ competition: b,
385
+ season: m,
386
+ // Loading and refresh state
387
+ isRefreshing: V,
388
+ lastRefreshed: J,
389
+ // Core data
390
+ matches: i,
391
+ standings: T,
392
+ // Historical data
393
+ previousSeasons: d,
394
+ // Custom configuration
395
+ config: Y,
396
+ // Refresh method
397
+ refresh: h,
398
+ // Match helpers
399
+ getMatch: P,
400
+ getMatchesByTeam: z,
401
+ getMatchesByDate: B,
402
+ getMatchesByRound: w,
403
+ getLiveMatches: x,
404
+ getUpcomingMatches: G,
405
+ getFinishedMatches: O,
406
+ // Standings helpers
407
+ getTeamStanding: p,
408
+ getTeamForm: j,
409
+ getTeamStats: C,
410
+ getTopTeams: N,
411
+ getBottomTeams: D,
412
+ // Historical helpers
413
+ getSeasonMatches: e,
414
+ getSeasonStandings: n
415
+ }),
416
+ [
417
+ c,
418
+ E,
419
+ v,
420
+ b,
421
+ m,
422
+ V,
423
+ J,
424
+ i,
425
+ T,
426
+ d,
427
+ Y,
428
+ h,
429
+ P,
430
+ z,
431
+ B,
432
+ w,
433
+ x,
434
+ G,
435
+ O,
436
+ p,
437
+ j,
438
+ C,
439
+ N,
440
+ D,
441
+ e,
442
+ n
443
+ ]
444
+ );
445
+ return /* @__PURE__ */ Ee.jsx(re.Provider, { value: a, children: L });
446
+ }
447
+ export {
448
+ re as CompetitionContext,
449
+ _e as CompetitionProvider,
450
+ ge as useCompetition
451
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-4gbkCyy3.cjs");function c(t){return{id:t.id,name:t.name,shortName:t.short_name??void 0,threeLetterCode:t.three_letter_code,slug:t.slug,type:t.type==="placeholder"?"club":t.type,gender:t.gender,country:t.country?{id:t.country.id,name:t.country.name,code:t.country.code??void 0,flag:t.country.assets?.flag?.url}:void 0,assets:t.assets?{logo:t.assets.logo?.url,homeKit:t.assets.home_kit?.url,awayKit:t.assets.away_kit?.url,squadImage:t.assets.squad_image?.url}:void 0}}async function r(t,s={}){const{sportal365Sports:n}=o.getConfig(),a=await o.footballHttp.get({path:`/v2/teams/${t}`,params:{language_code:s.languageCode??n?.languageCode??"en",optional_data:"form"},next:s.next});return c(a)}function u(t){return!t.seasons||t.seasons.length===0?void 0:t.seasons.find(n=>n.active)??t.seasons[0]}function m(t,s){const n=new Date,a=s.filter(e=>{const i=e.competitorOne.id===t||e.competitorTwo.id===t,l=e.status.type==="NOT_STARTED"||e.status.type==="LIVE",g=new Date(e.timing.kickoffTime)>=n||e.status.type==="LIVE";return i&&l&&g});return a.sort((e,i)=>new Date(e.timing.kickoffTime).getTime()-new Date(i.timing.kickoffTime).getTime()),a[0]}function d(t,s){const n=new Date,a=s.filter(e=>{const i=e.competitorOne.id===t||e.competitorTwo.id===t,l=e.status.type==="FINISHED",g=new Date(e.timing.kickoffTime)<=n;return i&&l&&g});return a.sort((e,i)=>new Date(i.timing.kickoffTime).getTime()-new Date(e.timing.kickoffTime).getTime()),a[0]}const f="0.0.2";exports.getConfig=o.getConfig;exports.getFootballCompetition=o.getFootballCompetition;exports.getFootballMatch=o.getFootballMatch;exports.getFootballMatchCommentary=o.getFootballMatchCommentary;exports.getFootballMatchEvents=o.getFootballMatchEvents;exports.getFootballMatchLineups=o.getFootballMatchLineups;exports.getFootballMatchOdds=o.getFootballMatchOdds;exports.getFootballMatchStatistics=o.getFootballMatchStatistics;exports.getFootballMatches=o.getFootballMatches;exports.getFootballSeasonDetails=o.getFootballSeasonDetails;exports.getFootballStandings=o.getFootballStandings;exports.isConfigured=o.isConfigured;exports.setConfig=o.setConfig;exports.getActiveSeason=u;exports.getFootballTeam=r;exports.getTeamNextMatch=m;exports.getTeamPreviousMatch=d;exports.version=f;