@time2win/t2w 2.0.0 → 2.0.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.
Files changed (3) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/index.js +31 -26
  3. package/package.json +1 -1
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
+ ## 2.0.1 - 2025-07-28
9
+ ### Changed
10
+ Optional check for all response map calls
11
+
8
12
  ## 2.0.0 - 2025-06-12
9
13
  ### Changed
10
14
  All method signatures to use options object for optional params
package/index.js CHANGED
@@ -64,17 +64,18 @@ var Time2WinAPI = /** @class */ (function () {
64
64
  fetch(_this.getUrl(_this.apiUrl, "event/".concat(eventId, "/eventdata"), queryParams))
65
65
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
66
66
  var body;
67
- return __generator(this, function (_a) {
68
- switch (_a.label) {
67
+ var _a;
68
+ return __generator(this, function (_b) {
69
+ switch (_b.label) {
69
70
  case 0: return [4 /*yield*/, response.json()];
70
71
  case 1:
71
- body = _a.sent();
72
+ body = _b.sent();
72
73
  if (response.status === 403) {
73
74
  reject(body);
74
75
  return [2 /*return*/];
75
76
  }
76
77
  // Convert strings to dates
77
- body.races = body.races.map(function (r) {
78
+ body.races = (_a = body.races) === null || _a === void 0 ? void 0 : _a.map(function (r) {
78
79
  return __assign(__assign({}, r), { starttime: new Date(r.starttime) });
79
80
  });
80
81
  body.registration_start = new Date("".concat(body.registration_start, "Z"));
@@ -104,17 +105,18 @@ var Time2WinAPI = /** @class */ (function () {
104
105
  fetch(_this.getUrl('https://t2wserver.ddns.net/server/{{route}}', "events/".concat(eventId), queryParams))
105
106
  .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
106
107
  var body;
107
- return __generator(this, function (_a) {
108
- switch (_a.label) {
108
+ var _a;
109
+ return __generator(this, function (_b) {
110
+ switch (_b.label) {
109
111
  case 0: return [4 /*yield*/, response.json()];
110
112
  case 1:
111
- body = _a.sent();
113
+ body = _b.sent();
112
114
  if (response.status === 403) {
113
115
  reject(body);
114
116
  return [2 /*return*/];
115
117
  }
116
118
  // Convert strings to dates
117
- body.races = body.races.map(function (r) {
119
+ body.races = (_a = body.races) === null || _a === void 0 ? void 0 : _a.map(function (r) {
118
120
  return __assign(__assign({}, r), { starttime: new Date(r.starttime) });
119
121
  });
120
122
  body.registration_start = new Date("".concat(body.registration_start, "Z"));
@@ -148,11 +150,12 @@ var Time2WinAPI = /** @class */ (function () {
148
150
  var body, _a, _b, _c;
149
151
  var _d;
150
152
  var _this = this;
151
- return __generator(this, function (_e) {
152
- switch (_e.label) {
153
+ var _e;
154
+ return __generator(this, function (_f) {
155
+ switch (_f.label) {
153
156
  case 0: return [4 /*yield*/, response.json()];
154
157
  case 1:
155
- body = _e.sent();
158
+ body = _f.sent();
156
159
  if (response.status === 403) {
157
160
  reject(body);
158
161
  return [2 /*return*/];
@@ -162,12 +165,12 @@ var Time2WinAPI = /** @class */ (function () {
162
165
  _c = [_d];
163
166
  return [4 /*yield*/, this.getTeamResult(eventId, raceId, options, body.page + 1)];
164
167
  case 2:
165
- _b.apply(_a, _c.concat([(_e.sent()).list]));
168
+ _b.apply(_a, _c.concat([(_f.sent()).list]));
166
169
  body.page = Math.ceil(body.list.length / body.page_size);
167
170
  resolve(body);
168
- _e.label = 3;
171
+ _f.label = 3;
169
172
  case 3:
170
- body.list = body.list.map(function (p) {
173
+ body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
171
174
  return __assign(__assign({}, p), { racenumNumeric: _this.getNumericBib(p.racenum), gender: p.team_type });
172
175
  });
173
176
  resolve(body);
@@ -198,11 +201,12 @@ var Time2WinAPI = /** @class */ (function () {
198
201
  var body, _a, _b, _c;
199
202
  var _d;
200
203
  var _this = this;
201
- return __generator(this, function (_e) {
202
- switch (_e.label) {
204
+ var _e;
205
+ return __generator(this, function (_f) {
206
+ switch (_f.label) {
203
207
  case 0: return [4 /*yield*/, response.json()];
204
208
  case 1:
205
- body = _e.sent();
209
+ body = _f.sent();
206
210
  if (response.status === 403) {
207
211
  reject(body);
208
212
  return [2 /*return*/];
@@ -212,13 +216,13 @@ var Time2WinAPI = /** @class */ (function () {
212
216
  _c = [_d];
213
217
  return [4 /*yield*/, this.getTeamsWithMembers(eventId, options, body.page + 1)];
214
218
  case 2:
215
- _b.apply(_a, _c.concat([(_e.sent()).list]));
219
+ _b.apply(_a, _c.concat([(_f.sent()).list]));
216
220
  body.page_more = false;
217
221
  body.page = Math.ceil(body.list.length / body.page_size);
218
222
  resolve(body);
219
- _e.label = 3;
223
+ _f.label = 3;
220
224
  case 3:
221
- body.list = body.list.map(function (p) {
225
+ body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
222
226
  var _a;
223
227
  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) {
224
228
  return __assign(__assign({}, m), { racenumNumeric: _this.getNumericBib(m.racenum) });
@@ -382,11 +386,12 @@ var Time2WinAPI = /** @class */ (function () {
382
386
  var body, _a, _b, _c;
383
387
  var _d;
384
388
  var _this = this;
385
- return __generator(this, function (_e) {
386
- switch (_e.label) {
389
+ var _e;
390
+ return __generator(this, function (_f) {
391
+ switch (_f.label) {
387
392
  case 0: return [4 /*yield*/, response.json()];
388
393
  case 1:
389
- body = _e.sent();
394
+ body = _f.sent();
390
395
  if (response.status === 403) {
391
396
  reject(body);
392
397
  return [2 /*return*/];
@@ -396,13 +401,13 @@ var Time2WinAPI = /** @class */ (function () {
396
401
  _c = [_d];
397
402
  return [4 /*yield*/, this.fetchParticipantInfos(event, raceId, dataExtra, gender, body.page + 1)];
398
403
  case 2:
399
- _b.apply(_a, _c.concat([(_e.sent()).list]));
404
+ _b.apply(_a, _c.concat([(_f.sent()).list]));
400
405
  body.page_more = false;
401
406
  body.page = Math.ceil(body.list.length / body.page_size);
402
407
  resolve(body);
403
- _e.label = 3;
408
+ _f.label = 3;
404
409
  case 3:
405
- body.list = body.list.map(function (p) {
410
+ body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
406
411
  var race = event.races.find(function (r) { return r.race_id === p.race_id; });
407
412
  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) });
408
413
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@time2win/t2w",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "providing latest-state models and advanced methods to interact with the T2W API",
5
5
  "keywords": [
6
6
  "time2win",