@time2win/t2w 1.4.16 → 1.4.18

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,15 @@ 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.18 - 2025-02-14
9
+ ### Added
10
+ ```agecategories``` and ```attributes``` properties to ```T2WEvent```
11
+
12
+ ## 1.4.17 - 2024-11-12
13
+ ### Changed
14
+ ```Time2WinAPI``` constructor, to add optional parameter ```pageSize```, default value = 250.
15
+ <br> removed currently unused ```getEventData()``` call in ```getParticipantInfos()```
16
+
8
17
  ## 1.4.16 - 2024-10-15
9
18
  ### Changed
10
19
  type of ```organization``` of ```T2WTeamResult``` to ```string | null```
package/index.d.ts CHANGED
@@ -3,8 +3,8 @@ export default class Time2WinAPI {
3
3
  private readonly apiUrl;
4
4
  private readonly apiKey;
5
5
  private readonly pageSize;
6
- constructor(apiKey: string);
7
- getEventData(eventId: number, dataExtra?: ('prices' | 'splits')[]): Promise<T2WEvent>;
6
+ constructor(apiKey: string, pageSize?: number);
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>;
package/index.js CHANGED
@@ -48,10 +48,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
50
  var Time2WinAPI = /** @class */ (function () {
51
- function Time2WinAPI(apiKey) {
51
+ function Time2WinAPI(apiKey, pageSize) {
52
+ if (pageSize === void 0) { pageSize = 250; }
52
53
  this.apiUrl = 'https://time2win.at/api/1.1/{{route}}';
53
54
  this.apiKey = apiKey;
54
- this.pageSize = 250;
55
+ this.pageSize = pageSize;
55
56
  }
56
57
  Time2WinAPI.prototype.getEventData = function (eventId, dataExtra) {
57
58
  return __awaiter(this, void 0, void 0, function () {
@@ -255,7 +256,7 @@ var Time2WinAPI = /** @class */ (function () {
255
256
  };
256
257
  fetch(_this.getUrl("/participants/".concat(eventId, "/individuals"), queryParams))
257
258
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
258
- var body, race_1, race, _a, _b, _c;
259
+ var body, _a, _b, _c;
259
260
  var _d;
260
261
  var _this = this;
261
262
  return __generator(this, function (_e) {
@@ -267,24 +268,20 @@ var Time2WinAPI = /** @class */ (function () {
267
268
  reject(body);
268
269
  return [2 /*return*/];
269
270
  }
270
- if (!!raceId) return [3 /*break*/, 3];
271
- return [4 /*yield*/, this.getEventData(eventId)];
272
- case 2:
273
- race_1 = (_e.sent()).races.find(function (r) { return r.race_id === raceId; });
274
- _e.label = 3;
275
- case 3:
276
- race = null;
277
- if (!body.page_more) return [3 /*break*/, 5];
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];
278
275
  _b = (_a = (_d = body.list).push).apply;
279
276
  _c = [_d];
280
277
  return [4 /*yield*/, this.getParticipantInfos(eventId, raceId, dataExtra, gender, body.page + 1)];
281
- case 4:
278
+ case 2:
282
279
  _b.apply(_a, _c.concat([(_e.sent()).list]));
283
280
  body.page_more = false;
284
281
  body.page = Math.ceil(body.list.length / body.page_size);
285
282
  resolve(body);
286
- _e.label = 5;
287
- case 5:
283
+ _e.label = 3;
284
+ case 3:
288
285
  body.list = body.list.map(function (p) {
289
286
  return __assign(__assign({}, p), { birthdate: p.birthdate ? new Date(p.birthdate) : null,
290
287
  // age: p.birthdate && race ? this.calculateAge(new Date(p.birthdate), race.starttime) : null,
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: 'M' | 'F' | 'U';
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: 'M' | 'F' | 'U';
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: 'M' | 'F' | 'U';
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"; // custom status, does not exist in api
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.16",
3
+ "version": "1.4.18",
4
4
  "description": "providing latest-state models and advanced methods to interact with the T2W API",
5
5
  "keywords": [
6
6
  "time2win",
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.getIndividualResults(681, 4237).then(function (res) {
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
  });