@time2win/t2w 2.0.1 → 2.0.3

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,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.0.3 - 2025-07-30
9
+ ### Added
10
+ apiKey get property to retrieve the current api key
11
+
12
+ ## 2.0.2 - 2025-07-28
13
+ ### Changed
14
+ empty array instead of undefined list
15
+
8
16
  ## 2.0.1 - 2025-07-28
9
17
  ### Changed
10
18
  Optional check for all response map calls
package/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { EventDataOptions, IndividualResultsOptions, ParticipantInfoOptions, T2WEvent, T2WEventResponse, T2WIndividualResultResponse, T2WParticipantResponse, T2WTeamResponse, T2WTeamResultsResponse, TeamResultOptions, TeamsWithMembersOptions } from './models';
2
2
  export default class Time2WinAPI {
3
3
  private readonly apiUrl;
4
- private readonly apiKey;
4
+ private readonly _apiKey;
5
5
  private readonly pageSize;
6
6
  constructor(apiKey: string, pageSize?: number);
7
+ get apiKey(): string;
7
8
  getEventData(eventId: number, options?: EventDataOptions): Promise<T2WEvent>;
8
9
  getEventDataWithCache(eventId: number, options?: EventDataOptions, maxAge?: number): Promise<T2WEvent>;
9
10
  getTeamResult(eventId: number, raceId: number, options?: TeamResultOptions, page?: number): Promise<T2WTeamResultsResponse>;
package/index.js CHANGED
@@ -51,9 +51,16 @@ var Time2WinAPI = /** @class */ (function () {
51
51
  function Time2WinAPI(apiKey, pageSize) {
52
52
  if (pageSize === void 0) { pageSize = 250; }
53
53
  this.apiUrl = 'https://time2win.at/api/1.1/{{route}}';
54
- this.apiKey = apiKey;
54
+ this._apiKey = apiKey;
55
55
  this.pageSize = pageSize;
56
56
  }
57
+ Object.defineProperty(Time2WinAPI.prototype, "apiKey", {
58
+ get: function () {
59
+ return this._apiKey;
60
+ },
61
+ enumerable: false,
62
+ configurable: true
63
+ });
57
64
  Time2WinAPI.prototype.getEventData = function (eventId, options) {
58
65
  return __awaiter(this, void 0, void 0, function () {
59
66
  var _this = this;
@@ -170,9 +177,9 @@ var Time2WinAPI = /** @class */ (function () {
170
177
  resolve(body);
171
178
  _f.label = 3;
172
179
  case 3:
173
- body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
180
+ body.list = ((_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
174
181
  return __assign(__assign({}, p), { racenumNumeric: _this.getNumericBib(p.racenum), gender: p.team_type });
175
- });
182
+ })) || [];
176
183
  resolve(body);
177
184
  return [2 /*return*/];
178
185
  }
@@ -222,12 +229,12 @@ var Time2WinAPI = /** @class */ (function () {
222
229
  resolve(body);
223
230
  _f.label = 3;
224
231
  case 3:
225
- body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
232
+ body.list = ((_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
226
233
  var _a;
227
234
  return __assign(__assign({}, p), { racenumNumeric: _this.getNumericBib(p.racenum), gender: p.team_type, members: ((_a = p.members) === null || _a === void 0 ? void 0 : _a.map(function (m) {
228
235
  return __assign(__assign({}, m), { racenumNumeric: _this.getNumericBib(m.racenum) });
229
236
  })) || [] });
230
- });
237
+ })) || [];
231
238
  resolve(body);
232
239
  return [2 /*return*/];
233
240
  }
@@ -352,9 +359,9 @@ var Time2WinAPI = /** @class */ (function () {
352
359
  resolve(body);
353
360
  _f.label = 3;
354
361
  case 3:
355
- body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
362
+ body.list = ((_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
356
363
  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' });
357
- });
364
+ })) || [];
358
365
  resolve(body);
359
366
  return [2 /*return*/];
360
367
  }
@@ -407,10 +414,10 @@ var Time2WinAPI = /** @class */ (function () {
407
414
  resolve(body);
408
415
  _f.label = 3;
409
416
  case 3:
410
- body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
417
+ body.list = ((_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
411
418
  var race = event.races.find(function (r) { return r.race_id === p.race_id; });
412
419
  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) });
413
- });
420
+ })) || [];
414
421
  resolve(body);
415
422
  return [2 /*return*/];
416
423
  }
@@ -428,7 +435,7 @@ var Time2WinAPI = /** @class */ (function () {
428
435
  if (url.endsWith('/')) {
429
436
  url = url.slice(0, -1);
430
437
  }
431
- url += url.includes('?') ? "&apikey=".concat(this.apiKey) : "?apikey=".concat(this.apiKey);
438
+ url += url.includes('?') ? "&apikey=".concat(this._apiKey) : "?apikey=".concat(this._apiKey);
432
439
  if (queryParams) {
433
440
  for (var key in queryParams) {
434
441
  url += "&".concat(key, "=").concat(queryParams[key]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@time2win/t2w",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "providing latest-state models and advanced methods to interact with the T2W API",
5
5
  "keywords": [
6
6
  "time2win",