@time2win/t2w 2.0.5 → 2.1.1
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/CHANGELOG.md +8 -0
- package/index.d.ts +3 -2
- package/index.js +41 -0
- package/models.d.ts +32 -32
- package/package.json +1 -1
- package/test.js +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 2.1.1 - 2025-09-18
|
|
9
|
+
### Added
|
|
10
|
+
T2WResultBasic interface to abstract common properties of T2WIndividualResult and T2WTeamResult
|
|
11
|
+
|
|
12
|
+
## 2.1.0 - 2025-08-28
|
|
13
|
+
### Added
|
|
14
|
+
getIndividualResult() to get a single individual result by signupId
|
|
15
|
+
|
|
8
16
|
## 2.0.5 - 2025-08-26
|
|
9
17
|
### Added
|
|
10
18
|
page size option to participantInfo and individualResults methods
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventDataOptions, IndividualResultsOptions, ParticipantInfoOptions, T2WEvent, T2WEventResponse, T2WIndividualResultResponse, T2WParticipantResponse, T2WTeamResponse, T2WTeamResultsResponse, TeamResultOptions, TeamsWithMembersOptions } from './models';
|
|
1
|
+
import { EventDataOptions, IndividualResultOptions, IndividualResultsOptions, ParticipantInfoOptions, T2WEvent, T2WEventResponse, T2WIndividualResultResponse, T2WIndividualResultsResponse, T2WParticipantResponse, T2WTeamResponse, T2WTeamResultsResponse, TeamResultOptions, TeamsWithMembersOptions } from './models';
|
|
2
2
|
export default class Time2WinAPI {
|
|
3
3
|
private readonly apiUrl;
|
|
4
4
|
private readonly _apiKey;
|
|
@@ -9,7 +9,8 @@ export default class Time2WinAPI {
|
|
|
9
9
|
getEventDataWithCache(eventId: number, options?: EventDataOptions, maxAge?: number): Promise<T2WEvent>;
|
|
10
10
|
getTeamResult(eventId: number, raceId: number, options?: TeamResultOptions, page?: number): Promise<T2WTeamResultsResponse>;
|
|
11
11
|
getTeamsWithMembers(eventId: number, options?: TeamsWithMembersOptions, page?: number): Promise<T2WTeamResponse>;
|
|
12
|
-
getIndividualResults(eventId: number, raceId: number, options?: IndividualResultsOptions, page?: number): Promise<
|
|
12
|
+
getIndividualResults(eventId: number, raceId: number, options?: IndividualResultsOptions, page?: number): Promise<T2WIndividualResultsResponse>;
|
|
13
|
+
getIndividualResult(eventId: number, raceId: number, signupId: number, options?: IndividualResultOptions): Promise<T2WIndividualResultResponse>;
|
|
13
14
|
getParticipantInfos(eventId: number, options?: ParticipantInfoOptions, page?: number): Promise<T2WParticipantResponse>;
|
|
14
15
|
/**
|
|
15
16
|
* if no params are given, the events in the next seven days are returned
|
package/index.js
CHANGED
|
@@ -259,6 +259,47 @@ var Time2WinAPI = /** @class */ (function () {
|
|
|
259
259
|
});
|
|
260
260
|
});
|
|
261
261
|
};
|
|
262
|
+
Time2WinAPI.prototype.getIndividualResult = function (eventId, raceId, signupId, options) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
var _this = this;
|
|
265
|
+
return __generator(this, function (_a) {
|
|
266
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
267
|
+
var _a;
|
|
268
|
+
var queryParams = {
|
|
269
|
+
'race_id': raceId,
|
|
270
|
+
id: signupId,
|
|
271
|
+
'data_extra': ((_a = options === null || options === void 0 ? void 0 : options.dataExtra) === null || _a === void 0 ? void 0 : _a.join(',')) || ''
|
|
272
|
+
};
|
|
273
|
+
fetch(_this.getUrl(_this.apiUrl, "results/".concat(eventId, "/individual"), queryParams))
|
|
274
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
275
|
+
var body, event;
|
|
276
|
+
var _this = this;
|
|
277
|
+
var _a;
|
|
278
|
+
return __generator(this, function (_b) {
|
|
279
|
+
switch (_b.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, response.json()];
|
|
281
|
+
case 1:
|
|
282
|
+
body = _b.sent();
|
|
283
|
+
if (response.status === 403) {
|
|
284
|
+
reject(body);
|
|
285
|
+
return [2 /*return*/];
|
|
286
|
+
}
|
|
287
|
+
return [4 /*yield*/, this.getEventDataWithCache(eventId, { dataExtra: ['splits'] }, options === null || options === void 0 ? void 0 : options.maxEventAge)];
|
|
288
|
+
case 2:
|
|
289
|
+
event = _b.sent();
|
|
290
|
+
body.results = ((_a = body.results) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
291
|
+
return __assign(__assign({}, p), { birthdate: p.birthdate ? new Date(p.birthdate) : null, racenumNumeric: _this.getNumericBib(p.racenum), speedNetto: _this.calculateSpeed(p, event, 'speed', 'netto') + ' km/h', speedBrutto: _this.calculateSpeed(p, event, 'speed', 'brutto') + ' km/h', paceNetto: _this.calculateSpeed(p, event, 'pace', 'netto') + ' min/km', paceBrutto: _this.calculateSpeed(p, event, 'pace', 'brutto') + ' min/km' });
|
|
292
|
+
})) || [];
|
|
293
|
+
resolve(body);
|
|
294
|
+
return [2 /*return*/];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}); })
|
|
298
|
+
.catch(function (reason) { return reject(reason); });
|
|
299
|
+
})];
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
262
303
|
Time2WinAPI.prototype.getParticipantInfos = function (eventId, options, page) {
|
|
263
304
|
if (page === void 0) { page = 1; }
|
|
264
305
|
return __awaiter(this, void 0, void 0, function () {
|
package/models.d.ts
CHANGED
|
@@ -95,28 +95,8 @@ export interface T2WTeamResultSplit {
|
|
|
95
95
|
split_index: number;
|
|
96
96
|
split_accumulatedtime: boolean;
|
|
97
97
|
}
|
|
98
|
-
export interface T2WTeamResult {
|
|
99
|
-
id: number;
|
|
98
|
+
export interface T2WTeamResult extends T2WResultBasic {
|
|
100
99
|
team_type: gender;
|
|
101
|
-
gender: gender;
|
|
102
|
-
name_team: string;
|
|
103
|
-
organization: string | null;
|
|
104
|
-
race_id: number;
|
|
105
|
-
race_name: string;
|
|
106
|
-
wave_id: number | null;
|
|
107
|
-
wave_name: string | null;
|
|
108
|
-
racenum: string | null;
|
|
109
|
-
racenumNumeric: number | null;
|
|
110
|
-
status_id: number;
|
|
111
|
-
status_text: string;
|
|
112
|
-
splits: T2WTeamResultSplit[] | null;
|
|
113
|
-
laps: T2WLap[] | null;
|
|
114
|
-
start_tod: string;
|
|
115
|
-
finishtime_fromgun: string | null;
|
|
116
|
-
finishtime_fromgun_ms: number | null;
|
|
117
|
-
finishtime_fromchip: string | null;
|
|
118
|
-
finishtime_fromchip_ms: number | null;
|
|
119
|
-
laps_count: number;
|
|
120
100
|
}
|
|
121
101
|
export interface T2WTeamResponse {
|
|
122
102
|
list: T2WTeam[];
|
|
@@ -152,26 +132,21 @@ export interface T2WTeam {
|
|
|
152
132
|
attr_2: string | null;
|
|
153
133
|
members: T2WTeamMember[];
|
|
154
134
|
}
|
|
155
|
-
export interface
|
|
135
|
+
export interface T2WIndividualResultsResponse {
|
|
156
136
|
page_size: number;
|
|
157
137
|
page: number;
|
|
158
138
|
page_total: number;
|
|
159
139
|
count_total: number;
|
|
160
140
|
list: T2WIndividualResult[];
|
|
161
141
|
}
|
|
162
|
-
export interface
|
|
142
|
+
export interface T2WIndividualResultResponse {
|
|
143
|
+
results: T2WIndividualResult[];
|
|
144
|
+
}
|
|
145
|
+
export interface T2WIndividualResult extends T2WParticipantBasic, T2WResultBasic {
|
|
163
146
|
pos_overall: number;
|
|
164
147
|
pos_gender: number;
|
|
165
148
|
pos_category: number;
|
|
166
149
|
name_full: string;
|
|
167
|
-
splits: T2WIndividualResultSplit[] | null;
|
|
168
|
-
laps: T2WLap[] | null;
|
|
169
|
-
start_tod: string;
|
|
170
|
-
finishtime_fromgun: string | null;
|
|
171
|
-
finishtime_fromgun_ms: number | null;
|
|
172
|
-
finishtime_fromchip: string | null;
|
|
173
|
-
finishtime_fromchip_ms: number | null;
|
|
174
|
-
laps_count: number;
|
|
175
150
|
paceNetto: string;
|
|
176
151
|
paceBrutto: string;
|
|
177
152
|
speedNetto: string;
|
|
@@ -235,7 +210,6 @@ interface T2WParticipantBasic {
|
|
|
235
210
|
category_id: number | null;
|
|
236
211
|
category_name: string | null;
|
|
237
212
|
team_id: number | null;
|
|
238
|
-
team_name: string | null;
|
|
239
213
|
status_id: number;
|
|
240
214
|
status_text: string;
|
|
241
215
|
checkin_status_id: number;
|
|
@@ -254,6 +228,28 @@ interface T2WParticipantBasic {
|
|
|
254
228
|
attr_3: string | null;
|
|
255
229
|
attr_4: string | null;
|
|
256
230
|
}
|
|
231
|
+
export interface T2WResultBasic {
|
|
232
|
+
id: number;
|
|
233
|
+
gender: gender;
|
|
234
|
+
organization: string | null;
|
|
235
|
+
race_id: number;
|
|
236
|
+
race_name: string;
|
|
237
|
+
wave_id: number | null;
|
|
238
|
+
team_name: string;
|
|
239
|
+
wave_name: string | null;
|
|
240
|
+
racenum: string | null;
|
|
241
|
+
racenumNumeric: number | null;
|
|
242
|
+
status_id: number;
|
|
243
|
+
status_text: string;
|
|
244
|
+
splits: T2WTeamResultSplit[] | null;
|
|
245
|
+
laps: T2WLap[] | null;
|
|
246
|
+
start_tod: string;
|
|
247
|
+
finishtime_fromgun: string | null;
|
|
248
|
+
finishtime_fromgun_ms: number | null;
|
|
249
|
+
finishtime_fromchip: string | null;
|
|
250
|
+
finishtime_fromchip_ms: number | null;
|
|
251
|
+
laps_count: number;
|
|
252
|
+
}
|
|
257
253
|
export declare enum RaceStatus {
|
|
258
254
|
FINISHED = 1,
|
|
259
255
|
FINISHED_PENDING_VERIFICATION = 2,
|
|
@@ -284,6 +280,10 @@ export interface IndividualResultsOptions {
|
|
|
284
280
|
maxEventAge?: number;
|
|
285
281
|
pageSize?: number;
|
|
286
282
|
}
|
|
283
|
+
export interface IndividualResultOptions {
|
|
284
|
+
dataExtra?: ('splits' | 'laps' | 'positions' | 'attributes')[];
|
|
285
|
+
maxEventAge?: number;
|
|
286
|
+
}
|
|
287
287
|
export interface EventDataOptions {
|
|
288
288
|
dataExtra?: ('prices' | 'splits' | 'categories' | 'attributes')[];
|
|
289
289
|
}
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var index_1 = __importDefault(require("./index"));
|
|
7
7
|
var api = new index_1.default('09f006ca-23ee-44da-bec5-4372580f4113');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
api.getEventDataWithCache(664, { dataExtra: ['splits'] }, 5).then(
|
|
12
|
-
|
|
13
|
-
}).catch(console.log);
|
|
8
|
+
api.getTeamResult(440, 2495).then(function (res) {
|
|
9
|
+
console.log(res.list);
|
|
10
|
+
});
|
|
11
|
+
// api.getEventDataWithCache(664, { dataExtra: [ 'splits'] }, 5).then(res => {
|
|
12
|
+
// console.log(res);
|
|
13
|
+
// }).catch(console.log);
|