@time2win/t2w 1.4.18 → 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 CHANGED
@@ -5,6 +5,10 @@ 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
+
8
12
  ## 1.4.18 - 2025-02-14
9
13
  ### Added
10
14
  ```agecategories``` and ```attributes``` properties to ```T2WEvent```
package/index.d.ts CHANGED
@@ -9,6 +9,9 @@ export default class Time2WinAPI {
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
- 'race_id': raceId || '',
252
- 'data_extra': (dataExtra === null || dataExtra === void 0 ? void 0 : dataExtra.join(',')) || '',
253
- gender: gender || '',
254
- page: page,
255
- 'page_size': _this.pageSize
256
- };
257
- fetch(_this.getUrl("/participants/".concat(eventId, "/individuals"), queryParams))
258
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
259
- var body, _a, _b, _c;
260
- var _d;
261
- var _this = this;
262
- return __generator(this, function (_e) {
263
- switch (_e.label) {
264
- case 0: return [4 /*yield*/, response.json()];
265
- case 1:
266
- body = _e.sent();
267
- if (response.status === 403) {
268
- reject(body);
269
- return [2 /*return*/];
270
- }
271
- if (!raceId) {
272
- // const race = (await this.getEventData(eventId)).races.find(r => r.race_id === raceId);
273
- }
274
- if (!body.page_more) return [3 /*break*/, 3];
275
- _b = (_a = (_d = body.list).push).apply;
276
- _c = [_d];
277
- return [4 /*yield*/, this.getParticipantInfos(eventId, raceId, dataExtra, gender, body.page + 1)];
278
- case 2:
279
- _b.apply(_a, _c.concat([(_e.sent()).list]));
280
- body.page_more = false;
281
- body.page = Math.ceil(body.list.length / body.page_size);
282
- resolve(body);
283
- _e.label = 3;
284
- case 3:
285
- body.list = body.list.map(function (p) {
286
- return __assign(__assign({}, p), { birthdate: p.birthdate ? new Date(p.birthdate) : null,
287
- // age: p.birthdate && race ? this.calculateAge(new Date(p.birthdate), race.starttime) : null,
288
- 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) });
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
- resolve(body);
291
- return [2 /*return*/];
292
- }
293
- });
294
- }); })
295
- .catch(function (reason) { return reject(reason); });
296
- })];
298
+ }); })
299
+ .catch(function (reason) { return reject(reason); });
300
+ return [2 /*return*/];
301
+ }
302
+ });
303
+ }); })];
297
304
  });
298
305
  });
299
306
  };
300
- /*
301
- * if no params are given, the events in the next seven days are returned
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@time2win/t2w",
3
- "version": "1.4.18",
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": "^2.0.22",
23
+ "nodemon": "^3.1.9",
26
24
  "ts-node": "^10.2.1",
27
25
  "typescript": "^4.4.3"
28
26
  }