@time2win/t2w 1.4.17 → 1.4.19
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 -1
- package/index.d.ts +4 -1
- package/index.js +57 -50
- package/models.d.ts +20 -3
- package/models.js +1 -1
- package/package.json +2 -4
- package/test.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,12 +5,19 @@ 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
|
+
## 1.4.19 - 2025-02-25
|
|
9
|
+
### Added
|
|
10
|
+
```age``` property for participant info
|
|
11
|
+
|
|
12
|
+
## 1.4.18 - 2025-02-14
|
|
13
|
+
### Added
|
|
14
|
+
```agecategories``` and ```attributes``` properties to ```T2WEvent```
|
|
15
|
+
|
|
8
16
|
## 1.4.17 - 2024-11-12
|
|
9
17
|
### Changed
|
|
10
18
|
```Time2WinAPI``` constructor, to add optional parameter ```pageSize```, default value = 250.
|
|
11
19
|
<br> removed currently unused ```getEventData()``` call in ```getParticipantInfos()```
|
|
12
20
|
|
|
13
|
-
|
|
14
21
|
## 1.4.16 - 2024-10-15
|
|
15
22
|
### Changed
|
|
16
23
|
type of ```organization``` of ```T2WTeamResult``` to ```string | null```
|
package/index.d.ts
CHANGED
|
@@ -4,11 +4,14 @@ export default class Time2WinAPI {
|
|
|
4
4
|
private readonly apiKey;
|
|
5
5
|
private readonly pageSize;
|
|
6
6
|
constructor(apiKey: string, pageSize?: number);
|
|
7
|
-
getEventData(eventId: number, dataExtra?: ('prices' | 'splits')[]): Promise<T2WEvent>;
|
|
7
|
+
getEventData(eventId: number, dataExtra?: ('prices' | 'splits' | 'categories' | 'attributes')[]): Promise<T2WEvent>;
|
|
8
8
|
getTeamResult(eventId: number, raceId: number, dataExtra?: ('splits' | 'attributes' | 'laps')[], teamType?: 'M' | 'F' | 'U', page?: number): Promise<T2WTeamResultsResponse>;
|
|
9
9
|
getTeamsWithMembers(eventId: number, raceId?: number, dataExtra?: ('teammembers' | 'attributes')[], page?: number): Promise<T2WTeamResponse>;
|
|
10
10
|
getIndividualResults(eventId: number, raceId: number, dataExtra?: ('splits' | 'laps' | 'positions' | 'attributes')[], gender?: 'M' | 'F' | 'U', page?: number): Promise<T2WIndividualResultResponse>;
|
|
11
11
|
getParticipantInfos(eventId: number, raceId?: number, dataExtra?: ('order' | 'attributes' | 'categories' | 'uci_id' | 'chip_code' | 'externalticket' | 'contactinfo')[], gender?: 'M' | 'F' | 'U', page?: number): Promise<T2WParticipantResponse>;
|
|
12
|
+
/**
|
|
13
|
+
* if no params are given, the events in the next seven days are returned
|
|
14
|
+
* */
|
|
12
15
|
getUpcomingEvents(from?: Date, to?: Date, page?: number): Promise<T2WEventResponse>;
|
|
13
16
|
private getUrl;
|
|
14
17
|
private calculateAge;
|
package/index.js
CHANGED
|
@@ -246,60 +246,67 @@ var Time2WinAPI = /** @class */ (function () {
|
|
|
246
246
|
return __awaiter(this, void 0, void 0, function () {
|
|
247
247
|
var _this = this;
|
|
248
248
|
return __generator(this, function (_a) {
|
|
249
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
250
|
-
var queryParams
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
249
|
+
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
250
|
+
var queryParams, races;
|
|
251
|
+
var _this = this;
|
|
252
|
+
return __generator(this, function (_a) {
|
|
253
|
+
switch (_a.label) {
|
|
254
|
+
case 0:
|
|
255
|
+
queryParams = {
|
|
256
|
+
'race_id': raceId || '',
|
|
257
|
+
'data_extra': (dataExtra === null || dataExtra === void 0 ? void 0 : dataExtra.join(',')) || '',
|
|
258
|
+
gender: gender || '',
|
|
259
|
+
page: page,
|
|
260
|
+
'page_size': this.pageSize
|
|
261
|
+
};
|
|
262
|
+
return [4 /*yield*/, this.getEventData(eventId)];
|
|
263
|
+
case 1:
|
|
264
|
+
races = (_a.sent()).races;
|
|
265
|
+
fetch(this.getUrl("/participants/".concat(eventId, "/individuals"), queryParams))
|
|
266
|
+
.then(function (response) { return __awaiter(_this, void 0, void 0, function () {
|
|
267
|
+
var body, _a, _b, _c;
|
|
268
|
+
var _d;
|
|
269
|
+
var _this = this;
|
|
270
|
+
return __generator(this, function (_e) {
|
|
271
|
+
switch (_e.label) {
|
|
272
|
+
case 0: return [4 /*yield*/, response.json()];
|
|
273
|
+
case 1:
|
|
274
|
+
body = _e.sent();
|
|
275
|
+
if (response.status === 403) {
|
|
276
|
+
reject(body);
|
|
277
|
+
return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
if (!body.page_more) return [3 /*break*/, 3];
|
|
280
|
+
_b = (_a = (_d = body.list).push).apply;
|
|
281
|
+
_c = [_d];
|
|
282
|
+
return [4 /*yield*/, this.getParticipantInfos(eventId, raceId, dataExtra, gender, body.page + 1)];
|
|
283
|
+
case 2:
|
|
284
|
+
_b.apply(_a, _c.concat([(_e.sent()).list]));
|
|
285
|
+
body.page_more = false;
|
|
286
|
+
body.page = Math.ceil(body.list.length / body.page_size);
|
|
287
|
+
resolve(body);
|
|
288
|
+
_e.label = 3;
|
|
289
|
+
case 3:
|
|
290
|
+
body.list = body.list.map(function (p) {
|
|
291
|
+
var race = races.find(function (r) { return r.race_id === p.race_id; });
|
|
292
|
+
return __assign(__assign({}, p), { birthdate: p.birthdate ? new Date(p.birthdate) : null, age: p.birthdate && race ? _this.calculateAge(new Date(p.birthdate), race.starttime) : null, year: p.birthdate ? new Date(p.birthdate).getFullYear() : null, order_date: p.order_date ? new Date(p.order_date) : null, racenumNumeric: _this.getNumericBib(p.racenum) });
|
|
293
|
+
});
|
|
294
|
+
resolve(body);
|
|
295
|
+
return [2 /*return*/];
|
|
296
|
+
}
|
|
289
297
|
});
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
})];
|
|
298
|
+
}); })
|
|
299
|
+
.catch(function (reason) { return reject(reason); });
|
|
300
|
+
return [2 /*return*/];
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}); })];
|
|
297
304
|
});
|
|
298
305
|
});
|
|
299
306
|
};
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
307
|
+
/**
|
|
308
|
+
* if no params are given, the events in the next seven days are returned
|
|
309
|
+
* */
|
|
303
310
|
Time2WinAPI.prototype.getUpcomingEvents = function (from, to, page) {
|
|
304
311
|
if (from === void 0) { from = new Date(); }
|
|
305
312
|
if (page === void 0) { page = 1; }
|
package/models.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
declare type gender = 'M' | 'F' | 'U';
|
|
1
2
|
export interface T2WEventResponse {
|
|
2
3
|
events: T2WEvent[];
|
|
3
4
|
page: number;
|
|
@@ -6,6 +7,7 @@ export interface T2WEventResponse {
|
|
|
6
7
|
}
|
|
7
8
|
export interface T2WEvent {
|
|
8
9
|
event_id: number;
|
|
10
|
+
event_id_previous: number | null;
|
|
9
11
|
event_name: string;
|
|
10
12
|
event_start: string;
|
|
11
13
|
event_end: string;
|
|
@@ -23,6 +25,8 @@ export interface T2WEvent {
|
|
|
23
25
|
banner_url: string;
|
|
24
26
|
locations: T2WEventLocations[];
|
|
25
27
|
races: T2WEventRace[];
|
|
28
|
+
attributes: T2WEventAttributes[] | null;
|
|
29
|
+
agecategories: T2WEventCategories[] | null;
|
|
26
30
|
}
|
|
27
31
|
export interface T2WEventRace {
|
|
28
32
|
race_id: number;
|
|
@@ -56,6 +60,19 @@ export interface T2WEventLocations {
|
|
|
56
60
|
latitude: number;
|
|
57
61
|
longitude: number;
|
|
58
62
|
}
|
|
63
|
+
export interface T2WEventAttributes {
|
|
64
|
+
attribute: number;
|
|
65
|
+
name: string;
|
|
66
|
+
}
|
|
67
|
+
export interface T2WEventCategories {
|
|
68
|
+
id: number;
|
|
69
|
+
name: string;
|
|
70
|
+
interval_from: number;
|
|
71
|
+
interval_to: number;
|
|
72
|
+
gender: gender | null;
|
|
73
|
+
ordering: number;
|
|
74
|
+
races: number[];
|
|
75
|
+
}
|
|
59
76
|
export interface T2WTeamResultsResponse {
|
|
60
77
|
page_size: number;
|
|
61
78
|
page: number;
|
|
@@ -80,7 +97,7 @@ export interface T2WTeamResultSplit {
|
|
|
80
97
|
}
|
|
81
98
|
export interface T2WTeamResult {
|
|
82
99
|
id: number;
|
|
83
|
-
team_type:
|
|
100
|
+
team_type: gender;
|
|
84
101
|
name_team: string;
|
|
85
102
|
organization: string | null;
|
|
86
103
|
race_id: number;
|
|
@@ -128,7 +145,7 @@ export interface T2WTeam {
|
|
|
128
145
|
status_text: string;
|
|
129
146
|
name_team: string;
|
|
130
147
|
organization: string | null;
|
|
131
|
-
team_type:
|
|
148
|
+
team_type: gender;
|
|
132
149
|
attr_1: string | null;
|
|
133
150
|
attr_2: string | null;
|
|
134
151
|
members: T2WTeamMember[];
|
|
@@ -221,7 +238,7 @@ interface T2WParticipantBasic {
|
|
|
221
238
|
name_last: string;
|
|
222
239
|
organization: string | null;
|
|
223
240
|
birthdate: Date | null;
|
|
224
|
-
gender:
|
|
241
|
+
gender: gender;
|
|
225
242
|
country_code: string;
|
|
226
243
|
attr_extra: string | null;
|
|
227
244
|
attr_commentary: string | null;
|
package/models.js
CHANGED
|
@@ -17,5 +17,5 @@ var RaceStatus;
|
|
|
17
17
|
RaceStatus[RaceStatus["UNKNOWN_OTHER"] = 40] = "UNKNOWN_OTHER";
|
|
18
18
|
RaceStatus[RaceStatus["NOT_STARTED"] = 45] = "NOT_STARTED";
|
|
19
19
|
RaceStatus[RaceStatus["CHECKED_IN"] = 50] = "CHECKED_IN";
|
|
20
|
-
RaceStatus[RaceStatus["PENALTY"] = 60] = "PENALTY";
|
|
20
|
+
RaceStatus[RaceStatus["PENALTY"] = 60] = "PENALTY";
|
|
21
21
|
})(RaceStatus = exports.RaceStatus || (exports.RaceStatus = {}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@time2win/t2w",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.19",
|
|
4
4
|
"description": "providing latest-state models and advanced methods to interact with the T2W API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"time2win",
|
|
@@ -18,11 +18,9 @@
|
|
|
18
18
|
},
|
|
19
19
|
"author": "Jonas Dorfinger",
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
},
|
|
23
21
|
"devDependencies": {
|
|
24
22
|
"@types/node": "^16.10.1",
|
|
25
|
-
"nodemon": "^
|
|
23
|
+
"nodemon": "^3.1.9",
|
|
26
24
|
"ts-node": "^10.2.1",
|
|
27
25
|
"typescript": "^4.4.3"
|
|
28
26
|
}
|
package/test.js
CHANGED
|
@@ -5,8 +5,8 @@ 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
|
-
api.
|
|
9
|
-
console.log('SUCCESS', res);
|
|
8
|
+
api.getEventData(550, ['prices', 'splits', 'categories', 'attributes']).then(function (res) {
|
|
9
|
+
// console.log('SUCCESS', res);
|
|
10
10
|
}).catch(function (err) {
|
|
11
11
|
console.log('ERROR', err);
|
|
12
12
|
});
|