fansunited-data-layer 0.0.3 → 0.0.5
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/README.md +28 -19
- package/dist/client.cjs +1 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +117 -0
- package/dist/fansunited-data-layer.cjs +1 -0
- package/dist/fansunited-data-layer.js +23 -1755
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/prepareTeamMatches.server-B9jIHuIg.js +680 -0
- package/dist/prepareTeamMatches.server-D7tk1Z_n.cjs +1 -0
- package/dist/use-cases/index.d.ts +2 -4
- package/dist/use-cases/index.d.ts.map +1 -1
- package/dist/use-cases/match/index.d.ts +8 -4
- package/dist/use-cases/match/index.d.ts.map +1 -1
- package/dist/use-cases/match/{prepareMatchList.d.ts → prepareMatchList.server.d.ts} +2 -20
- package/dist/use-cases/match/prepareMatchList.server.d.ts.map +1 -0
- package/dist/use-cases/match/prepareMatchScore.server.d.ts +33 -0
- package/dist/use-cases/match/prepareMatchScore.server.d.ts.map +1 -0
- package/dist/use-cases/match/usePrepareMatchList.d.ts +20 -0
- package/dist/use-cases/match/usePrepareMatchList.d.ts.map +1 -0
- package/dist/use-cases/match/usePrepareMatchScore.d.ts +31 -0
- package/dist/use-cases/match/usePrepareMatchScore.d.ts.map +1 -0
- package/dist/use-cases/team/index.d.ts +4 -2
- package/dist/use-cases/team/index.d.ts.map +1 -1
- package/dist/use-cases/team/{prepareTeamMatches.d.ts → prepareTeamMatches.server.d.ts} +3 -26
- package/dist/use-cases/team/prepareTeamMatches.server.d.ts.map +1 -0
- package/dist/use-cases/team/usePrepareTeamMatches.d.ts +26 -0
- package/dist/use-cases/team/usePrepareTeamMatches.d.ts.map +1 -0
- package/package.json +7 -2
- package/dist/fansunited-data-layer.umd.cjs +0 -6
- package/dist/use-cases/match/prepareMatchList.d.ts.map +0 -1
- package/dist/use-cases/match/prepareMatchScore.d.ts +0 -62
- package/dist/use-cases/match/prepareMatchScore.d.ts.map +0 -1
- package/dist/use-cases/team/prepareTeamMatches.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -135,8 +135,18 @@ console.log(team.assets?.logo);
|
|
|
135
135
|
|
|
136
136
|
Use-cases bridge the data layer and UI components from `fansunited-sports-ui`. Each use-case provides:
|
|
137
137
|
|
|
138
|
-
- **Server function** (`prepareX`) - Pure async function for SSR/SSG
|
|
139
|
-
- **Client hook** (`usePrepareX`) - React Query wrapper for client-side
|
|
138
|
+
- **Server function** (`prepareX`) - Pure async function for SSR/SSG - import from `fansunited-data-layer`
|
|
139
|
+
- **Client hook** (`usePrepareX`) - React Query wrapper for client-side - import from `fansunited-data-layer/client`
|
|
140
|
+
|
|
141
|
+
### Import Pattern
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
// Server Components - import from main entry point
|
|
145
|
+
import { prepareTeamFixtures } from "fansunited-data-layer";
|
|
146
|
+
|
|
147
|
+
// Client Components - import from /client entry point
|
|
148
|
+
import { usePrepareTeamFixtures } from "fansunited-data-layer/client";
|
|
149
|
+
```
|
|
140
150
|
|
|
141
151
|
### Match Use-Cases
|
|
142
152
|
|
|
@@ -145,13 +155,13 @@ Use-cases bridge the data layer and UI components from `fansunited-sports-ui`. E
|
|
|
145
155
|
Single match score display.
|
|
146
156
|
|
|
147
157
|
```typescript
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const data = await prepareMatchScore({ matchId: "7576255" });
|
|
158
|
+
// Server Component
|
|
159
|
+
import { prepareMatchScore } from "fansunited-data-layer";
|
|
160
|
+
const data = await prepareMatchScore("7576255");
|
|
152
161
|
|
|
153
|
-
// Client
|
|
154
|
-
|
|
162
|
+
// Client Component
|
|
163
|
+
import { usePrepareMatchScore } from "fansunited-data-layer/client";
|
|
164
|
+
const { data, isLoading } = usePrepareMatchScore("7576255");
|
|
155
165
|
```
|
|
156
166
|
|
|
157
167
|
#### `prepareMatchList` / `usePrepareMatchList`
|
|
@@ -163,7 +173,6 @@ import { prepareMatchList } from "fansunited-data-layer";
|
|
|
163
173
|
|
|
164
174
|
const data = await prepareMatchList({
|
|
165
175
|
variant: "daily",
|
|
166
|
-
date: new Date(),
|
|
167
176
|
tournamentIds: ["premier-league"],
|
|
168
177
|
limit: 20,
|
|
169
178
|
});
|
|
@@ -176,19 +185,19 @@ const data = await prepareMatchList({
|
|
|
176
185
|
Convenience wrappers for team-specific match queries.
|
|
177
186
|
|
|
178
187
|
```typescript
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
// Get past matches for a team
|
|
182
|
-
const results = await prepareTeamResults("team-123", {
|
|
183
|
-
groupByCompetition: true,
|
|
184
|
-
limit: 20,
|
|
185
|
-
});
|
|
188
|
+
// Server-side
|
|
189
|
+
import { prepareTeamResults, prepareTeamFixtures } from "fansunited-data-layer";
|
|
186
190
|
|
|
187
|
-
|
|
191
|
+
const results = await prepareTeamResults("team-123", { groupByCompetition: true });
|
|
188
192
|
const fixtures = await prepareTeamFixtures("team-123");
|
|
189
193
|
|
|
190
|
-
//
|
|
191
|
-
|
|
194
|
+
// Client-side with hydration
|
|
195
|
+
import { usePrepareTeamFixtures } from "fansunited-data-layer/client";
|
|
196
|
+
|
|
197
|
+
const { data } = usePrepareTeamFixtures("team-123", {
|
|
198
|
+
initialData, // from server
|
|
199
|
+
refetchInterval: 60000,
|
|
200
|
+
});
|
|
192
201
|
```
|
|
193
202
|
|
|
194
203
|
## Canonical Types
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@tanstack/react-query"),u=require("./prepareTeamMatches.server-D7tk1Z_n.cjs");function l(a,e){return t.useQuery({queryKey:["match-score",a,{lang:e?.languageCode}],queryFn:()=>u.prepareMatchScore(a,{languageCode:e?.languageCode}),initialData:e?.initialData,enabled:e?.enabled??!0,refetchInterval:e?.refetchInterval??!1,refetchIntervalInBackground:!1,staleTime:3e4})}function n(a){const e=["match-list",a.variant,{fromDate:a.fromDate,toDate:a.toDate,tournamentIds:a.tournamentIds,teamId:a.teamId,roundIds:a.roundIds,seasonIds:a.seasonIds,statusTypes:a.statusTypes,limit:a.limit,offset:a.offset,lang:a.languageCode}];return t.useQuery({queryKey:e,queryFn:()=>u.prepareMatchList(a),initialData:a.initialData,enabled:a.enabled??!0,refetchInterval:a.refetchInterval??!1,refetchIntervalInBackground:!1,staleTime:6e4})}function s(a,e){const r=e?.groupByCompetition?"teamResultsByCompetition":"teamResults";return t.useQuery({queryKey:["team-results",a,r,{seasonId:e?.seasonId,tournamentIds:e?.tournamentIds,limit:e?.limit,offset:e?.offset,lang:e?.languageCode}],queryFn:()=>u.prepareTeamResults(a,e),initialData:e?.initialData,enabled:e?.enabled??!0,refetchInterval:e?.refetchInterval??!1,staleTime:6e4})}function m(a,e){const r=e?.groupByCompetition?"teamFixturesByCompetition":"teamFixtures";return t.useQuery({queryKey:["team-fixtures",a,r,{seasonId:e?.seasonId,tournamentIds:e?.tournamentIds,limit:e?.limit,offset:e?.offset,lang:e?.languageCode}],queryFn:()=>u.prepareTeamFixtures(a,e),initialData:e?.initialData,enabled:e?.enabled??!0,refetchInterval:e?.refetchInterval??!1,staleTime:6e4})}function c(a,e){const r=e?.groupByCompetition?"teamMatchesByCompetition":"teamMatches";return t.useQuery({queryKey:["team-matches",a,r,{seasonId:e?.seasonId,tournamentIds:e?.tournamentIds,limit:e?.limit,offset:e?.offset,lang:e?.languageCode}],queryFn:()=>u.prepareTeamMatches(a,e),initialData:e?.initialData,enabled:e?.enabled??!0,refetchInterval:e?.refetchInterval??!1,staleTime:6e4})}exports.usePrepareMatchList=n;exports.usePrepareMatchScore=l;exports.usePrepareTeamFixtures=m;exports.usePrepareTeamMatches=c;exports.usePrepareTeamResults=s;
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* fansunited-data-layer/client
|
|
3
|
+
*
|
|
4
|
+
* Client-side exports with React Query hooks.
|
|
5
|
+
* Use this entry point in Client Components.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* "use client"
|
|
10
|
+
* import { usePrepareTeamFixtures } from 'fansunited-data-layer/client';
|
|
11
|
+
*
|
|
12
|
+
* function TeamFixtures({ teamId, initialData }) {
|
|
13
|
+
* const { data } = usePrepareTeamFixtures(teamId, { initialData });
|
|
14
|
+
* return <MatchListBlock items={data.items} />;
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export { usePrepareMatchScore } from "./use-cases/match/usePrepareMatchScore";
|
|
19
|
+
export type { UsePrepareMatchScoreOptions } from "./use-cases/match/usePrepareMatchScore";
|
|
20
|
+
export { usePrepareMatchList } from "./use-cases/match/usePrepareMatchList";
|
|
21
|
+
export type { UsePrepareMatchListOptions } from "./use-cases/match/usePrepareMatchList";
|
|
22
|
+
export { usePrepareTeamResults, usePrepareTeamFixtures, usePrepareTeamMatches, } from "./use-cases/team/usePrepareTeamMatches";
|
|
23
|
+
export type { UseTeamMatchesHookOptions } from "./use-cases/team/usePrepareTeamMatches";
|
|
24
|
+
export type { PrepareMatchScoreResult } from "./use-cases/match/prepareMatchScore.server";
|
|
25
|
+
export type { PrepareMatchListResult, MatchListVariant } from "./use-cases/match/prepareMatchList.server";
|
|
26
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/lib/client.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,YAAY,EAAE,2BAA2B,EAAE,MAAM,wCAAwC,CAAC;AAE1F,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,YAAY,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AAGxF,OAAO,EACH,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,GACxB,MAAM,wCAAwC,CAAC;AAChD,YAAY,EAAE,yBAAyB,EAAE,MAAM,wCAAwC,CAAC;AAGxF,YAAY,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAC1F,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { useQuery as r } from "@tanstack/react-query";
|
|
2
|
+
import { p as l, k as u, l as n, m, n as s } from "./prepareTeamMatches.server-B9jIHuIg.js";
|
|
3
|
+
function i(a, e) {
|
|
4
|
+
return r({
|
|
5
|
+
queryKey: ["match-score", a, { lang: e?.languageCode }],
|
|
6
|
+
queryFn: () => l(a, {
|
|
7
|
+
languageCode: e?.languageCode
|
|
8
|
+
}),
|
|
9
|
+
initialData: e?.initialData,
|
|
10
|
+
enabled: e?.enabled ?? !0,
|
|
11
|
+
refetchInterval: e?.refetchInterval ?? !1,
|
|
12
|
+
refetchIntervalInBackground: !1,
|
|
13
|
+
staleTime: 3e4
|
|
14
|
+
// 30 seconds
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function c(a) {
|
|
18
|
+
const e = [
|
|
19
|
+
"match-list",
|
|
20
|
+
a.variant,
|
|
21
|
+
{
|
|
22
|
+
fromDate: a.fromDate,
|
|
23
|
+
toDate: a.toDate,
|
|
24
|
+
tournamentIds: a.tournamentIds,
|
|
25
|
+
teamId: a.teamId,
|
|
26
|
+
roundIds: a.roundIds,
|
|
27
|
+
seasonIds: a.seasonIds,
|
|
28
|
+
statusTypes: a.statusTypes,
|
|
29
|
+
limit: a.limit,
|
|
30
|
+
offset: a.offset,
|
|
31
|
+
lang: a.languageCode
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
return r({
|
|
35
|
+
queryKey: e,
|
|
36
|
+
queryFn: () => u(a),
|
|
37
|
+
initialData: a.initialData,
|
|
38
|
+
enabled: a.enabled ?? !0,
|
|
39
|
+
refetchInterval: a.refetchInterval ?? !1,
|
|
40
|
+
refetchIntervalInBackground: !1,
|
|
41
|
+
staleTime: 6e4
|
|
42
|
+
// 1 minute
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function I(a, e) {
|
|
46
|
+
const t = e?.groupByCompetition ? "teamResultsByCompetition" : "teamResults";
|
|
47
|
+
return r({
|
|
48
|
+
queryKey: [
|
|
49
|
+
"team-results",
|
|
50
|
+
a,
|
|
51
|
+
t,
|
|
52
|
+
{
|
|
53
|
+
seasonId: e?.seasonId,
|
|
54
|
+
tournamentIds: e?.tournamentIds,
|
|
55
|
+
limit: e?.limit,
|
|
56
|
+
offset: e?.offset,
|
|
57
|
+
lang: e?.languageCode
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
queryFn: () => n(a, e),
|
|
61
|
+
initialData: e?.initialData,
|
|
62
|
+
enabled: e?.enabled ?? !0,
|
|
63
|
+
refetchInterval: e?.refetchInterval ?? !1,
|
|
64
|
+
staleTime: 6e4
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function g(a, e) {
|
|
68
|
+
const t = e?.groupByCompetition ? "teamFixturesByCompetition" : "teamFixtures";
|
|
69
|
+
return r({
|
|
70
|
+
queryKey: [
|
|
71
|
+
"team-fixtures",
|
|
72
|
+
a,
|
|
73
|
+
t,
|
|
74
|
+
{
|
|
75
|
+
seasonId: e?.seasonId,
|
|
76
|
+
tournamentIds: e?.tournamentIds,
|
|
77
|
+
limit: e?.limit,
|
|
78
|
+
offset: e?.offset,
|
|
79
|
+
lang: e?.languageCode
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
queryFn: () => m(a, e),
|
|
83
|
+
initialData: e?.initialData,
|
|
84
|
+
enabled: e?.enabled ?? !0,
|
|
85
|
+
refetchInterval: e?.refetchInterval ?? !1,
|
|
86
|
+
staleTime: 6e4
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
function y(a, e) {
|
|
90
|
+
const t = e?.groupByCompetition ? "teamMatchesByCompetition" : "teamMatches";
|
|
91
|
+
return r({
|
|
92
|
+
queryKey: [
|
|
93
|
+
"team-matches",
|
|
94
|
+
a,
|
|
95
|
+
t,
|
|
96
|
+
{
|
|
97
|
+
seasonId: e?.seasonId,
|
|
98
|
+
tournamentIds: e?.tournamentIds,
|
|
99
|
+
limit: e?.limit,
|
|
100
|
+
offset: e?.offset,
|
|
101
|
+
lang: e?.languageCode
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
queryFn: () => s(a, e),
|
|
105
|
+
initialData: e?.initialData,
|
|
106
|
+
enabled: e?.enabled ?? !0,
|
|
107
|
+
refetchInterval: e?.refetchInterval ?? !1,
|
|
108
|
+
staleTime: 6e4
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
export {
|
|
112
|
+
c as usePrepareMatchList,
|
|
113
|
+
i as usePrepareMatchScore,
|
|
114
|
+
g as usePrepareTeamFixtures,
|
|
115
|
+
y as usePrepareTeamMatches,
|
|
116
|
+
I as usePrepareTeamResults
|
|
117
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./prepareTeamMatches.server-D7tk1Z_n.cjs");function l(e){return{id:e.id,name:e.name,shortName:e.short_name??void 0,threeLetterCode:e.three_letter_code,slug:e.slug,type:e.type==="placeholder"?"club":e.type,gender:e.gender,country:e.country?{id:e.country.id,name:e.country.name,code:e.country.code??void 0,flag:e.country.assets?.flag?.url}:void 0,assets:e.assets?{logo:e.assets.logo?.url,homeKit:e.assets.home_kit?.url,awayKit:e.assets.away_kit?.url,squadImage:e.assets.squad_image?.url}:void 0}}async function r(e,a={}){const{sportal365Sports:o}=t.getConfig(),s=await t.footballHttp.get({path:`/v2/teams/${e}`,params:{language_code:a.languageCode??o?.languageCode??"en",optional_data:"form"}});return l(s)}exports.getConfig=t.getConfig;exports.getFootballMatch=t.getFootballMatch;exports.getFootballMatchCommentary=t.getFootballMatchCommentary;exports.getFootballMatchEvents=t.getFootballMatchEvents;exports.getFootballMatchLineups=t.getFootballMatchLineups;exports.getFootballMatchOdds=t.getFootballMatchOdds;exports.getFootballMatchStatistics=t.getFootballMatchStatistics;exports.getFootballMatches=t.getFootballMatches;exports.isConfigured=t.isConfigured;exports.prepareMatchList=t.prepareMatchList;exports.prepareMatchScore=t.prepareMatchScore;exports.prepareTeamFixtures=t.prepareTeamFixtures;exports.prepareTeamMatches=t.prepareTeamMatches;exports.prepareTeamResults=t.prepareTeamResults;exports.setConfig=t.setConfig;exports.getFootballTeam=r;
|