@crawlora-org/flashscore 0.1.0

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/index.d.ts ADDED
@@ -0,0 +1,175 @@
1
+ import type {
2
+ CrawloraGeneratedGroups,
3
+ OperationId,
4
+ OperationParamsMap,
5
+ OperationRequestArgs,
6
+ OperationResponseMap
7
+ } from "./types.js";
8
+
9
+ export type CrawloraParams = Record<string, unknown>;
10
+ export type CrawloraLogEvent = { event: string; [key: string]: unknown };
11
+ export interface CrawloraRequestContext { operationId: string; method: string; url: string; headers: Record<string, string> }
12
+ export type CrawloraBeforeRequest = (ctx: CrawloraRequestContext) => void | Promise<void>;
13
+ export type CrawloraAfterResponse = (operationId: string, status: number, headers: Record<string, string>, body: unknown) => unknown;
14
+
15
+ export interface CrawloraClientOptions {
16
+ apiKey?: string;
17
+ jwtToken?: string;
18
+ baseUrl?: string;
19
+ timeout?: number;
20
+ retries?: number;
21
+ retryDelay?: number;
22
+ maxRetryDelay?: number;
23
+ retryStatuses?: Iterable<number>;
24
+ isRetryable?: (status: number, error: CrawloraError) => boolean;
25
+ onRetry?: (attempt: number, error: CrawloraError, delay: number) => void;
26
+ requestId?: boolean;
27
+ idempotencyKeys?: boolean;
28
+ rateLimit?: number;
29
+ maxConcurrency?: number;
30
+ logger?: (event: CrawloraLogEvent) => void;
31
+ beforeRequest?: CrawloraBeforeRequest | Iterable<CrawloraBeforeRequest>;
32
+ afterResponse?: CrawloraAfterResponse | Iterable<CrawloraAfterResponse>;
33
+ headers?: Record<string, string>;
34
+ userAgent?: string | false;
35
+ fetch?: typeof globalThis.fetch;
36
+ }
37
+
38
+ export interface CrawloraRequestOptions {
39
+ headers?: Record<string, string>;
40
+ responseType?: "auto" | "json" | "text" | "stream";
41
+ timeout?: number;
42
+ signal?: AbortSignal;
43
+ retries?: number;
44
+ isRetryable?: (status: number, error: CrawloraError) => boolean;
45
+ }
46
+
47
+ export interface OperationDefinition {
48
+ id: string; method: string; path: string; pathParams: string[];
49
+ queryParams: Array<{ name: string; in?: "query"; collectionFormat?: string; type?: string; required?: boolean; enum?: string[] }>;
50
+ formParams: Array<{ name: string; in?: "formData"; type?: string; required?: boolean; enum?: string[] }>;
51
+ bodyParam?: string; bodyRequired?: boolean; consumes: string[]; produces: string[]; security: string[];
52
+ paginatable?: boolean; cursorParams?: string[];
53
+ }
54
+
55
+ export class CrawloraError extends Error {
56
+ status: number; code?: number; body: unknown; headers: Record<string, string>;
57
+ response?: Response; cause?: unknown; retryable?: boolean; requestId?: string;
58
+ }
59
+ export class CrawloraClientError extends CrawloraError {}
60
+ export class CrawloraServerError extends CrawloraError {}
61
+ export class CrawloraNetworkError extends CrawloraError {}
62
+
63
+ export interface CrawloraPaginateOptions extends CrawloraRequestOptions {
64
+ pageParam?: string; cursorParam?: string; nextCursor?: (page: unknown) => unknown;
65
+ start?: unknown; step?: number; maxPages?: number;
66
+ }
67
+ export interface CrawloraPaginateItemsOptions extends CrawloraPaginateOptions {
68
+ items?: (page: unknown) => Iterable<unknown>;
69
+ }
70
+
71
+ export class CrawloraClient {
72
+ constructor(options?: CrawloraClientOptions);
73
+ request<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
74
+ request<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
75
+ request<I extends OperationId>(operationId: I, ...args: OperationRequestArgs<I>): Promise<OperationResponseMap[I]>;
76
+ operation<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
77
+ operation<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
78
+ operation<I extends OperationId>(operationId: I, ...args: OperationRequestArgs<I>): Promise<OperationResponseMap[I]>;
79
+ paginate<I extends OperationId>(operationId: I, params?: OperationParamsMap[I], options?: CrawloraPaginateOptions): AsyncGenerator<OperationResponseMap[I], void, unknown>;
80
+ paginateItems<I extends OperationId>(operationId: I, params?: OperationParamsMap[I], options?: CrawloraPaginateItemsOptions): AsyncGenerator<unknown, void, unknown>;
81
+ [group: string]: unknown;
82
+ }
83
+ export interface CrawloraClient extends CrawloraGeneratedGroups {}
84
+
85
+ export class FlashscoreClient extends CrawloraClient {
86
+ request<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
87
+ operation<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
88
+ calendar(params: OperationParamsMap["flashscore-calendar"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
89
+ calendarCategories(params?: OperationParamsMap["flashscore-calendar-categories"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
90
+ competitions(params: OperationParamsMap["flashscore-competitions"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
91
+ matchH2h(params: OperationParamsMap["flashscore-match-h2h"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
92
+ matchHighlights(params: OperationParamsMap["flashscore-match-highlights"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
93
+ matchInfo(params: OperationParamsMap["flashscore-match-info"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
94
+ matchLineups(params: OperationParamsMap["flashscore-match-lineups"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
95
+ matchNews(params: OperationParamsMap["flashscore-match-news"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
96
+ matchStandings(params: OperationParamsMap["flashscore-match-standings"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
97
+ matchStats(params: OperationParamsMap["flashscore-match-stats"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
98
+ navigation(params?: OperationParamsMap["flashscore-navigation"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
99
+ news(params?: OperationParamsMap["flashscore-news"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
100
+ newsArticle(params: OperationParamsMap["flashscore-news-article"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
101
+ newsCategories(params?: OperationParamsMap["flashscore-news-categories"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
102
+ rankingCategories(params?: OperationParamsMap["flashscore-ranking-categories"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
103
+ rankings(params: OperationParamsMap["flashscore-rankings"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
104
+ scores(params: OperationParamsMap["flashscore-scores"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
105
+ search(params: OperationParamsMap["flashscore-search"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
106
+ sports(params?: OperationParamsMap["flashscore-sports"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
107
+ topSearch(params?: OperationParamsMap["flashscore-top-search"], options?: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
108
+ tournamentEvents(params: OperationParamsMap["flashscore-tournament-events"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
109
+ tournamentSeasons(params: OperationParamsMap["flashscore-tournament-seasons"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
110
+ tournamentStandings(params: OperationParamsMap["flashscore-tournament-standings"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
111
+ tournamentStandingsViews(params: OperationParamsMap["flashscore-tournament-standings-views"], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
112
+ request<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
113
+ operation<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
114
+ calendar(params: OperationParamsMap["flashscore-calendar"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
115
+ calendarCategories(params?: OperationParamsMap["flashscore-calendar-categories"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
116
+ competitions(params: OperationParamsMap["flashscore-competitions"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
117
+ matchH2h(params: OperationParamsMap["flashscore-match-h2h"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
118
+ matchHighlights(params: OperationParamsMap["flashscore-match-highlights"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
119
+ matchInfo(params: OperationParamsMap["flashscore-match-info"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
120
+ matchLineups(params: OperationParamsMap["flashscore-match-lineups"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
121
+ matchNews(params: OperationParamsMap["flashscore-match-news"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
122
+ matchStandings(params: OperationParamsMap["flashscore-match-standings"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
123
+ matchStats(params: OperationParamsMap["flashscore-match-stats"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
124
+ navigation(params?: OperationParamsMap["flashscore-navigation"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
125
+ news(params?: OperationParamsMap["flashscore-news"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
126
+ newsArticle(params: OperationParamsMap["flashscore-news-article"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
127
+ newsCategories(params?: OperationParamsMap["flashscore-news-categories"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
128
+ rankingCategories(params?: OperationParamsMap["flashscore-ranking-categories"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
129
+ rankings(params: OperationParamsMap["flashscore-rankings"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
130
+ scores(params: OperationParamsMap["flashscore-scores"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
131
+ search(params: OperationParamsMap["flashscore-search"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
132
+ sports(params?: OperationParamsMap["flashscore-sports"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
133
+ topSearch(params?: OperationParamsMap["flashscore-top-search"], options?: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
134
+ tournamentEvents(params: OperationParamsMap["flashscore-tournament-events"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
135
+ tournamentSeasons(params: OperationParamsMap["flashscore-tournament-seasons"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
136
+ tournamentStandings(params: OperationParamsMap["flashscore-tournament-standings"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
137
+ tournamentStandingsViews(params: OperationParamsMap["flashscore-tournament-standings-views"], options: CrawloraRequestOptions & { responseType: "text" }): Promise<string>;
138
+
139
+ request<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
140
+ request<I extends OperationId>(operationId: I, ...args: OperationRequestArgs<I>): Promise<OperationResponseMap[I]>;
141
+ operation<I extends OperationId>(operationId: I, params: OperationParamsMap[I], options: CrawloraRequestOptions & { responseType: "stream" }): Promise<Response>;
142
+ operation<I extends OperationId>(operationId: I, ...args: OperationRequestArgs<I>): Promise<OperationResponseMap[I]>;
143
+ calendar(...args: OperationRequestArgs<"flashscore-calendar">): Promise<OperationResponseMap["flashscore-calendar"]>;
144
+ calendarCategories(...args: OperationRequestArgs<"flashscore-calendar-categories">): Promise<OperationResponseMap["flashscore-calendar-categories"]>;
145
+ competitions(...args: OperationRequestArgs<"flashscore-competitions">): Promise<OperationResponseMap["flashscore-competitions"]>;
146
+ matchH2h(...args: OperationRequestArgs<"flashscore-match-h2h">): Promise<OperationResponseMap["flashscore-match-h2h"]>;
147
+ matchHighlights(...args: OperationRequestArgs<"flashscore-match-highlights">): Promise<OperationResponseMap["flashscore-match-highlights"]>;
148
+ matchInfo(...args: OperationRequestArgs<"flashscore-match-info">): Promise<OperationResponseMap["flashscore-match-info"]>;
149
+ matchLineups(...args: OperationRequestArgs<"flashscore-match-lineups">): Promise<OperationResponseMap["flashscore-match-lineups"]>;
150
+ matchNews(...args: OperationRequestArgs<"flashscore-match-news">): Promise<OperationResponseMap["flashscore-match-news"]>;
151
+ matchStandings(...args: OperationRequestArgs<"flashscore-match-standings">): Promise<OperationResponseMap["flashscore-match-standings"]>;
152
+ matchStats(...args: OperationRequestArgs<"flashscore-match-stats">): Promise<OperationResponseMap["flashscore-match-stats"]>;
153
+ navigation(...args: OperationRequestArgs<"flashscore-navigation">): Promise<OperationResponseMap["flashscore-navigation"]>;
154
+ news(...args: OperationRequestArgs<"flashscore-news">): Promise<OperationResponseMap["flashscore-news"]>;
155
+ newsArticle(...args: OperationRequestArgs<"flashscore-news-article">): Promise<OperationResponseMap["flashscore-news-article"]>;
156
+ newsCategories(...args: OperationRequestArgs<"flashscore-news-categories">): Promise<OperationResponseMap["flashscore-news-categories"]>;
157
+ rankingCategories(...args: OperationRequestArgs<"flashscore-ranking-categories">): Promise<OperationResponseMap["flashscore-ranking-categories"]>;
158
+ rankings(...args: OperationRequestArgs<"flashscore-rankings">): Promise<OperationResponseMap["flashscore-rankings"]>;
159
+ scores(...args: OperationRequestArgs<"flashscore-scores">): Promise<OperationResponseMap["flashscore-scores"]>;
160
+ search(...args: OperationRequestArgs<"flashscore-search">): Promise<OperationResponseMap["flashscore-search"]>;
161
+ sports(...args: OperationRequestArgs<"flashscore-sports">): Promise<OperationResponseMap["flashscore-sports"]>;
162
+ topSearch(...args: OperationRequestArgs<"flashscore-top-search">): Promise<OperationResponseMap["flashscore-top-search"]>;
163
+ tournamentEvents(...args: OperationRequestArgs<"flashscore-tournament-events">): Promise<OperationResponseMap["flashscore-tournament-events"]>;
164
+ tournamentSeasons(...args: OperationRequestArgs<"flashscore-tournament-seasons">): Promise<OperationResponseMap["flashscore-tournament-seasons"]>;
165
+ tournamentStandings(...args: OperationRequestArgs<"flashscore-tournament-standings">): Promise<OperationResponseMap["flashscore-tournament-standings"]>;
166
+ tournamentStandingsViews(...args: OperationRequestArgs<"flashscore-tournament-standings-views">): Promise<OperationResponseMap["flashscore-tournament-standings-views"]>;
167
+ }
168
+ export { FlashscoreClient as Client };
169
+ export const operations: Record<string, OperationDefinition>;
170
+ export const groups: Record<string, Record<string, string>>;
171
+ export const operationCount: number;
172
+ export const OperationIds: Readonly<Record<string, OperationId>>;
173
+ export const VERSION: string;
174
+ export * from "./types.js";
175
+ export default FlashscoreClient;
package/src/index.js ADDED
@@ -0,0 +1,50 @@
1
+ import { groups } from "./operations.js";
2
+ import {
3
+ CrawloraClient,
4
+ CrawloraClientError,
5
+ CrawloraError,
6
+ CrawloraNetworkError,
7
+ CrawloraServerError
8
+ } from "./client.js";
9
+
10
+ export class FlashscoreClient extends CrawloraClient {
11
+ constructor(options = {}) {
12
+ super({ ...options, userAgent: options.userAgent ?? "crawlora-flashscore-js/0.1.0" });
13
+ this["calendar"] = (...args) => this.request("flashscore-calendar", ...args);
14
+ this["calendarCategories"] = (...args) => this.request("flashscore-calendar-categories", ...args);
15
+ this["competitions"] = (...args) => this.request("flashscore-competitions", ...args);
16
+ this["matchH2h"] = (...args) => this.request("flashscore-match-h2h", ...args);
17
+ this["matchHighlights"] = (...args) => this.request("flashscore-match-highlights", ...args);
18
+ this["matchInfo"] = (...args) => this.request("flashscore-match-info", ...args);
19
+ this["matchLineups"] = (...args) => this.request("flashscore-match-lineups", ...args);
20
+ this["matchNews"] = (...args) => this.request("flashscore-match-news", ...args);
21
+ this["matchStandings"] = (...args) => this.request("flashscore-match-standings", ...args);
22
+ this["matchStats"] = (...args) => this.request("flashscore-match-stats", ...args);
23
+ this["navigation"] = (...args) => this.request("flashscore-navigation", ...args);
24
+ this["news"] = (...args) => this.request("flashscore-news", ...args);
25
+ this["newsArticle"] = (...args) => this.request("flashscore-news-article", ...args);
26
+ this["newsCategories"] = (...args) => this.request("flashscore-news-categories", ...args);
27
+ this["rankingCategories"] = (...args) => this.request("flashscore-ranking-categories", ...args);
28
+ this["rankings"] = (...args) => this.request("flashscore-rankings", ...args);
29
+ this["scores"] = (...args) => this.request("flashscore-scores", ...args);
30
+ this["search"] = (...args) => this.request("flashscore-search", ...args);
31
+ this["sports"] = (...args) => this.request("flashscore-sports", ...args);
32
+ this["topSearch"] = (...args) => this.request("flashscore-top-search", ...args);
33
+ this["tournamentEvents"] = (...args) => this.request("flashscore-tournament-events", ...args);
34
+ this["tournamentSeasons"] = (...args) => this.request("flashscore-tournament-seasons", ...args);
35
+ this["tournamentStandings"] = (...args) => this.request("flashscore-tournament-standings", ...args);
36
+ this["tournamentStandingsViews"] = (...args) => this.request("flashscore-tournament-standings-views", ...args);
37
+ }
38
+ }
39
+
40
+ export { FlashscoreClient as Client };
41
+ export {
42
+ CrawloraClient,
43
+ CrawloraClientError,
44
+ CrawloraError,
45
+ CrawloraNetworkError,
46
+ CrawloraServerError
47
+ };
48
+ export { groups, operations, operationCount, OperationIds } from "./operations.js";
49
+ export const VERSION = "0.1.0";
50
+ export default FlashscoreClient;