suunto-api-wrapper 1.1.2 → 1.2.2

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/dist/index.d.ts CHANGED
@@ -86,6 +86,68 @@ declare const DEFAULT_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15
86
86
  declare function login(options: LoginOptions): Promise<LoginResponse>;
87
87
  declare function sessionTokenFrom(response: LoginResponse): string | undefined;
88
88
 
89
+ interface UserProfile {
90
+ username: string;
91
+ createdDate: number;
92
+ lastModified: number;
93
+ lastLogin: number;
94
+ realName: string;
95
+ /** ISO 3166-1 alpha-2 country code. */
96
+ country: string;
97
+ gender: string;
98
+ uuid: string;
99
+ blocked: boolean;
100
+ showLocale: boolean;
101
+ followersCount: number;
102
+ followingCount: number;
103
+ currentBlobStorageLocation: string;
104
+ defaultBinaryStorageLocation: string;
105
+ }
106
+ interface UserProfileResponse {
107
+ error: string | null;
108
+ payload: UserProfile;
109
+ metadata: {
110
+ ts: string;
111
+ };
112
+ }
113
+ /** User shape returned by the search endpoint (differs slightly from {@link UserProfile}). */
114
+ interface SearchUser {
115
+ username: string;
116
+ createdDate: number;
117
+ lastModified: number;
118
+ lastLogin: number;
119
+ /** Absent on some legacy accounts. */
120
+ realName?: string;
121
+ /** Free-form profile bio. */
122
+ description?: string;
123
+ /** ISO 3166-1 country code. Mostly alpha-2, but legacy records may use alpha-3 (e.g. "FRA"). */
124
+ country?: string;
125
+ city?: string;
126
+ gender: string;
127
+ uuid: string;
128
+ imageKey?: string;
129
+ profileImageUrl?: string;
130
+ coverImageKey?: string;
131
+ coverImageUrl?: string;
132
+ showLocale: boolean;
133
+ defaultBinaryStorageLocation: string;
134
+ currentBlobStorageLocation: string;
135
+ key: string;
136
+ }
137
+ interface UserSearchResult {
138
+ /** Relationship to the searching user, e.g. "STRANGER". */
139
+ connection: string;
140
+ user: SearchUser;
141
+ workout: unknown | null;
142
+ }
143
+ interface UserSearchResponse {
144
+ error: string | null;
145
+ payload: UserSearchResult[];
146
+ metadata: {
147
+ ts: string;
148
+ };
149
+ }
150
+
89
151
  interface GetWorkoutsParams {
90
152
  limit?: number;
91
153
  sortonst?: boolean;
@@ -95,6 +157,166 @@ interface GetOwnWorkoutsParams {
95
157
  offset?: number;
96
158
  limit?: number;
97
159
  }
160
+ /** Bounding-box query for {@link getWorkoutsWithin}. All coords in decimal degrees. */
161
+ interface GetWorkoutsWithinParams {
162
+ /** South latitude of the bounding box. */
163
+ lowerLat: number;
164
+ /** West longitude of the bounding box. */
165
+ lowerLng: number;
166
+ /** North latitude of the bounding box. */
167
+ upperLat: number;
168
+ /** East longitude of the bounding box. */
169
+ upperLng: number;
170
+ /** Max results. Defaults to 50. */
171
+ limit?: number;
172
+ }
173
+ /** Suunto activity type IDs returned by the API as `activityId` / `_id`. */
174
+ declare enum SuuntoActivityType {
175
+ WALKING = 0,
176
+ RUNNING = 1,
177
+ CYCLING = 2,
178
+ CROSS_COUNTRY_SKIING = 3,
179
+ OTHER_1 = 4,
180
+ OTHER_2 = 5,
181
+ OTHER_3 = 6,
182
+ OTHER_4 = 7,
183
+ OTHER_5 = 8,
184
+ OTHER_6 = 9,
185
+ MOUNTAIN_BIKING = 10,
186
+ HIKING = 11,
187
+ ROLLER_SKATING = 12,
188
+ DOWNHILL_SKIING = 13,
189
+ PADDLING = 14,
190
+ ROWING = 15,
191
+ GOLF = 16,
192
+ INDOOR = 17,
193
+ PARKOUR = 18,
194
+ BALLGAMES = 19,
195
+ OUTDOOR_GYM = 20,
196
+ SWIMMING = 21,
197
+ TRAIL_RUNNING = 22,
198
+ GYM = 23,
199
+ NORDIC_WALKING = 24,
200
+ HORSEBACK_RIDING = 25,
201
+ MOTOR_SPORTS = 26,
202
+ SKATEBOARDING = 27,
203
+ WATER_SPORTS = 28,
204
+ CLIMBING = 29,
205
+ SNOWBOARDING = 30,
206
+ SKI_TOURING = 31,
207
+ FITNESS_CLASS = 32,
208
+ SOCCER = 33,
209
+ TENNIS = 34,
210
+ BASKETBALL = 35,
211
+ BADMINTON = 36,
212
+ BASEBALL = 37,
213
+ VOLLEYBALL = 38,
214
+ AMERICAN_FOOTBALL = 39,
215
+ TABLE_TENNIS = 40,
216
+ RACQUETBALL = 41,
217
+ SQUASH = 42,
218
+ FLOORBALL = 43,
219
+ HANDBALL = 44,
220
+ SOFTBALL = 45,
221
+ BOWLING = 46,
222
+ CRICKET = 47,
223
+ RUGBY = 48,
224
+ ICE_SKATING = 49,
225
+ ICE_HOCKEY = 50,
226
+ YOGA = 51,
227
+ INDOOR_CYCLING = 52,
228
+ TREADMILL = 53,
229
+ CROSSFIT = 54,
230
+ CROSSTRAINER = 55,
231
+ ROLLER_SKIING = 56,
232
+ INDOOR_ROWING = 57,
233
+ STRETCHING = 58,
234
+ TRACK_AND_FIELD = 59,
235
+ ORIENTEERING = 60,
236
+ SUP = 61,
237
+ COMBAT_SPORTS = 62,
238
+ KETTLEBELL = 63,
239
+ DANCING = 64,
240
+ SNOWSHOEING = 65,
241
+ FRISBEE_GOLF = 66,
242
+ FUTSAL = 67,
243
+ MULTISPORT = 68,
244
+ AEROBICS = 69,
245
+ TREKKING = 70,
246
+ SAILING = 71,
247
+ KAYAKING = 72,
248
+ CIRCUIT_TRAINING = 73,
249
+ TRIATHLON = 74,
250
+ PADEL = 75,
251
+ CHEERLEADING = 76,
252
+ BOXING = 77,
253
+ SCUBADIVING = 78,
254
+ FREEDIVING = 79,
255
+ ADVENTURE_RACING = 80,
256
+ GYMNASTICS = 81,
257
+ CANOEING = 82,
258
+ MOUNTAINEERING = 83,
259
+ TELEMARKSKIING = 84,
260
+ OPENWATER_SWIMMING = 85,
261
+ WINDSURFING = 86,
262
+ KITESURFING_KITING = 87,
263
+ PARAGLIDING = 88,
264
+ SNORKELING = 90,
265
+ SURFING = 91,
266
+ SWIMRUN = 92,
267
+ DUATHLON = 93,
268
+ AQUATHLON = 94,
269
+ OBSTACLE_RACING = 95,
270
+ FISHING = 96,
271
+ HUNTING = 97,
272
+ GRAVEL_CYCLING = 99,
273
+ MERMAIDING = 100,
274
+ SPEARFISHING = 101,
275
+ JUMP_ROPE = 102,
276
+ TRACK_RUNNING = 103,
277
+ CALISTHENICS = 104,
278
+ E_BIKING = 105,
279
+ E_MTB = 106,
280
+ BACKCOUNTRY_SKIING = 107,
281
+ WHEELCHAIR = 108,
282
+ HAND_CYCLING = 109,
283
+ SPLIT_BOARDING = 110,
284
+ BIATHLON = 111,
285
+ MEDITATION = 112,
286
+ FIELD_HOCKEY = 113,
287
+ CYCLOCROSS = 114,
288
+ VERTICAL_RUN = 115,
289
+ SKI_MOUNTAINEERING = 116,
290
+ SKATE_SKIING = 117,
291
+ CLASSIC_SKIING = 118,
292
+ CHORES = 119,
293
+ PILATES = 120,
294
+ NEW_YOGA = 121
295
+ }
296
+ /** Valid values for the `extensions` query param on the single-workout endpoint. */
297
+ declare enum WorkoutExtensionName {
298
+ Dive = "DiveExtension",
299
+ JumpRope = "JumpRopeExtension",
300
+ Summary = "SummaryExtension",
301
+ Swimming = "SwimmingExtension",
302
+ Weather = "WeatherExtension",
303
+ Workout = "WorkoutExtension",
304
+ CompetitionHeader = "CompetitionHeaderExtension"
305
+ }
306
+ /** Valid values for the `additionalData` query param on the single-workout endpoint. */
307
+ declare enum WorkoutAdditionalData {
308
+ Achievements = "achievements",
309
+ Photos = "photos",
310
+ Videos = "videos",
311
+ Comments = "comments",
312
+ UserReacted = "user_reacted"
313
+ }
314
+ interface GetWorkoutParams {
315
+ /** Extensions to include in the response. Defaults to `[Summary, CompetitionHeader]`. */
316
+ extensions?: WorkoutExtensionName[];
317
+ /** Extra data blocks to include. Defaults to all five values. */
318
+ additionalData?: WorkoutAdditionalData[];
319
+ }
98
320
  /** GPS coordinate: x = longitude, y = latitude. */
99
321
  interface Position {
100
322
  x: number;
@@ -288,8 +510,7 @@ type WorkoutExtension = FitnessExtension | IntensityExtension | SummaryExtension
288
510
  interface Workout {
289
511
  username: string;
290
512
  sharingFlags: number;
291
- /** Suunto activity type ID (e.g. 2 = cycling, 11 = trail running, 21 = pool swim, 36 = gym, 99 = other). */
292
- activityId: number;
513
+ activityId: SuuntoActivityType;
293
514
  key: string;
294
515
  startTime: number;
295
516
  stopTime: number;
@@ -317,7 +538,8 @@ interface Workout {
317
538
  tss: TssEntry;
318
539
  tssList: TssEntry[];
319
540
  suuntoTags: string[];
320
- clientCalculatedAchievements: ClientCalculatedAchievements;
541
+ /** Absent on some workouts (e.g. when the user has no achievements yet). */
542
+ clientCalculatedAchievements?: ClientCalculatedAchievements;
321
543
  workoutKey: string;
322
544
  visibilityFacebook: boolean;
323
545
  visibilityTwitter: boolean;
@@ -346,6 +568,16 @@ interface Workout {
346
568
  comments?: WorkoutComment[];
347
569
  /** Only present when reactionCount > 0. */
348
570
  reactions?: WorkoutReaction[];
571
+ /** Owner's display name. Returned on feed-style endpoints (e.g. `within`). */
572
+ fullname?: string;
573
+ /** Owner's profile picture URL. Returned on feed-style endpoints. */
574
+ userPhoto?: string;
575
+ /** Owner's cover photo URL. Returned on feed-style endpoints. */
576
+ coverPhoto?: string;
577
+ /** Free-text achievement labels (e.g. "Fastest time on this route"). */
578
+ achievements?: string[];
579
+ /** Average power, watts. Mirrors `SummaryExtension.avgPower` on feed responses. */
580
+ avgPower?: number;
349
581
  }
350
582
  interface WorkoutsResponse {
351
583
  error: string | null;
@@ -355,76 +587,99 @@ interface WorkoutsResponse {
355
587
  until: string;
356
588
  };
357
589
  }
358
-
359
- declare function getWorkouts(client: HttpClient, username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
360
- declare function getOwnWorkouts(client: HttpClient, params?: GetOwnWorkoutsParams): Promise<WorkoutsResponse>;
361
- /** Workout endpoints, bound to an {@link HttpClient}. Accessed via `suunto.workouts`. */
362
- declare class WorkoutsResource {
363
- private readonly client;
364
- constructor(client: HttpClient);
365
- /** The authenticated user's own workouts. */
366
- own(params?: GetOwnWorkoutsParams): Promise<WorkoutsResponse>;
367
- /** A given user's public workouts. */
368
- public(username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
590
+ interface WorkoutResponse {
591
+ error: string | null;
592
+ payload: Workout;
593
+ metadata: Record<string, unknown>;
369
594
  }
370
-
371
- interface UserProfile {
372
- username: string;
373
- createdDate: number;
374
- lastModified: number;
375
- lastLogin: number;
376
- realName: string;
377
- /** ISO 3166-1 alpha-2 country code. */
378
- country: string;
379
- gender: string;
380
- uuid: string;
381
- blocked: boolean;
382
- showLocale: boolean;
383
- followersCount: number;
384
- followingCount: number;
385
- currentBlobStorageLocation: string;
386
- defaultBinaryStorageLocation: string;
595
+ /** Single item from the {@link getWorkoutsWithin} feed: owner + workout. */
596
+ interface WorkoutsWithinItem {
597
+ user: SearchUser;
598
+ workout: Workout;
387
599
  }
388
- interface UserProfileResponse {
600
+ interface WorkoutsWithinResponse {
389
601
  error: string | null;
390
- payload: UserProfile;
602
+ payload: WorkoutsWithinItem[];
391
603
  metadata: {
392
- ts: string;
604
+ workoutcount: string;
393
605
  };
394
606
  }
395
- /** User shape returned by the search endpoint (differs slightly from {@link UserProfile}). */
396
- interface SearchUser {
397
- username: string;
398
- createdDate: number;
399
- lastModified: number;
400
- lastLogin: number;
401
- realName: string;
402
- /** ISO 3166-1 country code. Mostly alpha-2, but legacy records may use alpha-3 (e.g. "FRA"). */
403
- country?: string;
404
- city?: string;
405
- gender: string;
406
- uuid: string;
407
- imageKey?: string;
408
- profileImageUrl?: string;
409
- showLocale: boolean;
410
- defaultBinaryStorageLocation: string;
411
- currentBlobStorageLocation: string;
412
- key: string;
413
- }
414
- interface UserSearchResult {
415
- /** Relationship to the searching user, e.g. "STRANGER". */
416
- connection: string;
417
- user: SearchUser;
418
- workout: unknown | null;
607
+ /** Aggregated totals for a single activity type. */
608
+ interface WorkoutStatsEntry {
609
+ /** Suunto activity type ID this entry aggregates. */
610
+ _id: SuuntoActivityType;
611
+ /** Metres. */
612
+ totalDistance: number;
613
+ /** Seconds. */
614
+ totalTime: number;
615
+ /** Kilocalories. */
616
+ energyConsumption: number;
617
+ /** Number of workouts of this activity. */
618
+ numberOfWorkouts: number;
619
+ /** Metres. Only meaningful for dives. */
620
+ maxDepth: number;
621
+ }
622
+ interface WorkoutStats {
623
+ /** Sum of distances across all activities, in metres. */
624
+ totalDistanceSum: number;
625
+ /** Sum of times across all activities, in seconds. */
626
+ totalTimeSum: number;
627
+ /** Sum of energy consumption across all activities, in kilocalories. */
628
+ totalEnergyConsumptionSum: number;
629
+ /** Total workout count across all activities. */
630
+ totalNumberOfWorkoutsSum: number;
631
+ /** Number of distinct days that have at least one workout. */
632
+ totalDays: number;
633
+ /**
634
+ * Per-activity aggregates, restricted to a curated set of activity types
635
+ * (the ones the official UI surfaces as headline cards).
636
+ */
637
+ allStats: WorkoutStatsEntry[];
638
+ /** Per-activity aggregates covering every activity type the user has recorded. */
639
+ allActualStats: WorkoutStatsEntry[];
419
640
  }
420
- interface UserSearchResponse {
641
+ interface WorkoutStatsResponse {
421
642
  error: string | null;
422
- payload: UserSearchResult[];
643
+ payload: WorkoutStats;
423
644
  metadata: {
424
645
  ts: string;
425
646
  };
426
647
  }
427
648
 
649
+ declare function getWorkouts(client: HttpClient, username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
650
+ declare function getOwnWorkouts(client: HttpClient, params?: GetOwnWorkoutsParams): Promise<WorkoutsResponse>;
651
+ /**
652
+ * Public workouts whose center position falls inside the given geographic
653
+ * bounding box. Used by the "explore nearby" map view. Unauthenticated.
654
+ */
655
+ declare function getWorkoutsWithin(client: HttpClient, params: GetWorkoutsWithinParams): Promise<WorkoutsWithinResponse>;
656
+ /**
657
+ * Aggregated workout stats per activity for a user. Unauthenticated — no
658
+ * session required.
659
+ */
660
+ declare function getWorkoutStats(client: HttpClient, username: string): Promise<WorkoutStatsResponse>;
661
+ /** Workout endpoints, bound to an {@link HttpClient}. Accessed via `suunto.workouts`. */
662
+ declare class WorkoutsResource {
663
+ private readonly client;
664
+ constructor(client: HttpClient);
665
+ /** The authenticated user's own workouts. */
666
+ own(params?: GetOwnWorkoutsParams): Promise<WorkoutsResponse>;
667
+ /** A given user's public workouts. */
668
+ public(username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
669
+ /**
670
+ * A single workout by username and workout key. Works for any public workout
671
+ * and, when the client is authenticated as the owner, for private ones too.
672
+ */
673
+ byKey(username: string, workoutKey: string, params?: GetWorkoutParams): Promise<WorkoutResponse>;
674
+ /**
675
+ * Aggregated workout stats per activity for the given user. Works
676
+ * unauthenticated.
677
+ */
678
+ stats(username: string): Promise<WorkoutStatsResponse>;
679
+ /** Public workouts whose center falls inside a geographic bounding box. */
680
+ within(params: GetWorkoutsWithinParams): Promise<WorkoutsWithinResponse>;
681
+ }
682
+
428
683
  /**
429
684
  * Fetch a user's public profile by username. Unauthenticated — no session
430
685
  * required.
@@ -508,4 +763,4 @@ declare class SuuntoClient {
508
763
  static unauthenticated(options?: Omit<SuuntoClientOptions, "email" | "sessionKey">): SuuntoClient;
509
764
  }
510
765
 
511
- export { type ActivityCounts, type Cadence, type ClientCalculatedAchievements, type CumulativeAchievement, DEFAULT_USER_AGENT, type FitnessExtension, type Gear, GearResource, type GearResponse, type GearSummary, type GetLatestGearParams, type GetOwnWorkoutsParams, type GetWorkoutsParams, type HeartRateRecovery, type HrData, HttpClient, type HttpClientOptions, HttpError, type HttpResponse, type IntensityExtension, type IntensityZone, type IntensityZones, type LoginOptions, type LoginResponse, type PersonalBestAchievement, type Position, type Query, type Rankings, type RequestBody, type RequestContext, type RequestOptions, type RouteRanking, SPORTS_TRACKER_API, type SearchUser, type SummaryExtension, SuuntoClient, type SuuntoClientOptions, type SwimmingHeaderExtension, type TssEntry, type UserProfile, type UserProfileResponse, type UserSearchResponse, type UserSearchResult, UsersResource, type WeatherExtension, type Workout, type WorkoutComment, type WorkoutExtension, type WorkoutReaction, WorkoutsResource, type WorkoutsResponse, generateXtotp, getLatestGear, getOwnWorkouts, getUserByName, getWorkouts, login, searchUsers, secondsUntilRollover, sessionTokenFrom };
766
+ export { type ActivityCounts, type Cadence, type ClientCalculatedAchievements, type CumulativeAchievement, DEFAULT_USER_AGENT, type FitnessExtension, type Gear, GearResource, type GearResponse, type GearSummary, type GetLatestGearParams, type GetOwnWorkoutsParams, type GetWorkoutsParams, type GetWorkoutsWithinParams, type HeartRateRecovery, type HrData, HttpClient, type HttpClientOptions, HttpError, type HttpResponse, type IntensityExtension, type IntensityZone, type IntensityZones, type LoginOptions, type LoginResponse, type PersonalBestAchievement, type Position, type Query, type Rankings, type RequestBody, type RequestContext, type RequestOptions, type RouteRanking, SPORTS_TRACKER_API, type SearchUser, type SummaryExtension, SuuntoActivityType, SuuntoClient, type SuuntoClientOptions, type SwimmingHeaderExtension, type TssEntry, type UserProfile, type UserProfileResponse, type UserSearchResponse, type UserSearchResult, UsersResource, type WeatherExtension, type Workout, type WorkoutComment, type WorkoutExtension, type WorkoutReaction, type WorkoutStats, type WorkoutStatsEntry, type WorkoutStatsResponse, WorkoutsResource, type WorkoutsResponse, type WorkoutsWithinItem, type WorkoutsWithinResponse, generateXtotp, getLatestGear, getOwnWorkouts, getUserByName, getWorkoutStats, getWorkouts, getWorkoutsWithin, login, searchUsers, secondsUntilRollover, sessionTokenFrom };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  HttpClient: () => HttpClient,
26
26
  HttpError: () => HttpError,
27
27
  SPORTS_TRACKER_API: () => SPORTS_TRACKER_API,
28
+ SuuntoActivityType: () => SuuntoActivityType,
28
29
  SuuntoClient: () => SuuntoClient,
29
30
  UsersResource: () => UsersResource,
30
31
  WorkoutsResource: () => WorkoutsResource,
@@ -32,7 +33,9 @@ __export(index_exports, {
32
33
  getLatestGear: () => getLatestGear,
33
34
  getOwnWorkouts: () => getOwnWorkouts,
34
35
  getUserByName: () => getUserByName,
36
+ getWorkoutStats: () => getWorkoutStats,
35
37
  getWorkouts: () => getWorkouts,
38
+ getWorkoutsWithin: () => getWorkoutsWithin,
36
39
  login: () => login,
37
40
  searchUsers: () => searchUsers,
38
41
  secondsUntilRollover: () => secondsUntilRollover,
@@ -290,7 +293,143 @@ function sessionTokenFrom(response) {
290
293
  return response.sessionkey;
291
294
  }
292
295
 
296
+ // src/workouts/types.ts
297
+ var SuuntoActivityType = /* @__PURE__ */ ((SuuntoActivityType2) => {
298
+ SuuntoActivityType2[SuuntoActivityType2["WALKING"] = 0] = "WALKING";
299
+ SuuntoActivityType2[SuuntoActivityType2["RUNNING"] = 1] = "RUNNING";
300
+ SuuntoActivityType2[SuuntoActivityType2["CYCLING"] = 2] = "CYCLING";
301
+ SuuntoActivityType2[SuuntoActivityType2["CROSS_COUNTRY_SKIING"] = 3] = "CROSS_COUNTRY_SKIING";
302
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_1"] = 4] = "OTHER_1";
303
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_2"] = 5] = "OTHER_2";
304
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_3"] = 6] = "OTHER_3";
305
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_4"] = 7] = "OTHER_4";
306
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_5"] = 8] = "OTHER_5";
307
+ SuuntoActivityType2[SuuntoActivityType2["OTHER_6"] = 9] = "OTHER_6";
308
+ SuuntoActivityType2[SuuntoActivityType2["MOUNTAIN_BIKING"] = 10] = "MOUNTAIN_BIKING";
309
+ SuuntoActivityType2[SuuntoActivityType2["HIKING"] = 11] = "HIKING";
310
+ SuuntoActivityType2[SuuntoActivityType2["ROLLER_SKATING"] = 12] = "ROLLER_SKATING";
311
+ SuuntoActivityType2[SuuntoActivityType2["DOWNHILL_SKIING"] = 13] = "DOWNHILL_SKIING";
312
+ SuuntoActivityType2[SuuntoActivityType2["PADDLING"] = 14] = "PADDLING";
313
+ SuuntoActivityType2[SuuntoActivityType2["ROWING"] = 15] = "ROWING";
314
+ SuuntoActivityType2[SuuntoActivityType2["GOLF"] = 16] = "GOLF";
315
+ SuuntoActivityType2[SuuntoActivityType2["INDOOR"] = 17] = "INDOOR";
316
+ SuuntoActivityType2[SuuntoActivityType2["PARKOUR"] = 18] = "PARKOUR";
317
+ SuuntoActivityType2[SuuntoActivityType2["BALLGAMES"] = 19] = "BALLGAMES";
318
+ SuuntoActivityType2[SuuntoActivityType2["OUTDOOR_GYM"] = 20] = "OUTDOOR_GYM";
319
+ SuuntoActivityType2[SuuntoActivityType2["SWIMMING"] = 21] = "SWIMMING";
320
+ SuuntoActivityType2[SuuntoActivityType2["TRAIL_RUNNING"] = 22] = "TRAIL_RUNNING";
321
+ SuuntoActivityType2[SuuntoActivityType2["GYM"] = 23] = "GYM";
322
+ SuuntoActivityType2[SuuntoActivityType2["NORDIC_WALKING"] = 24] = "NORDIC_WALKING";
323
+ SuuntoActivityType2[SuuntoActivityType2["HORSEBACK_RIDING"] = 25] = "HORSEBACK_RIDING";
324
+ SuuntoActivityType2[SuuntoActivityType2["MOTOR_SPORTS"] = 26] = "MOTOR_SPORTS";
325
+ SuuntoActivityType2[SuuntoActivityType2["SKATEBOARDING"] = 27] = "SKATEBOARDING";
326
+ SuuntoActivityType2[SuuntoActivityType2["WATER_SPORTS"] = 28] = "WATER_SPORTS";
327
+ SuuntoActivityType2[SuuntoActivityType2["CLIMBING"] = 29] = "CLIMBING";
328
+ SuuntoActivityType2[SuuntoActivityType2["SNOWBOARDING"] = 30] = "SNOWBOARDING";
329
+ SuuntoActivityType2[SuuntoActivityType2["SKI_TOURING"] = 31] = "SKI_TOURING";
330
+ SuuntoActivityType2[SuuntoActivityType2["FITNESS_CLASS"] = 32] = "FITNESS_CLASS";
331
+ SuuntoActivityType2[SuuntoActivityType2["SOCCER"] = 33] = "SOCCER";
332
+ SuuntoActivityType2[SuuntoActivityType2["TENNIS"] = 34] = "TENNIS";
333
+ SuuntoActivityType2[SuuntoActivityType2["BASKETBALL"] = 35] = "BASKETBALL";
334
+ SuuntoActivityType2[SuuntoActivityType2["BADMINTON"] = 36] = "BADMINTON";
335
+ SuuntoActivityType2[SuuntoActivityType2["BASEBALL"] = 37] = "BASEBALL";
336
+ SuuntoActivityType2[SuuntoActivityType2["VOLLEYBALL"] = 38] = "VOLLEYBALL";
337
+ SuuntoActivityType2[SuuntoActivityType2["AMERICAN_FOOTBALL"] = 39] = "AMERICAN_FOOTBALL";
338
+ SuuntoActivityType2[SuuntoActivityType2["TABLE_TENNIS"] = 40] = "TABLE_TENNIS";
339
+ SuuntoActivityType2[SuuntoActivityType2["RACQUETBALL"] = 41] = "RACQUETBALL";
340
+ SuuntoActivityType2[SuuntoActivityType2["SQUASH"] = 42] = "SQUASH";
341
+ SuuntoActivityType2[SuuntoActivityType2["FLOORBALL"] = 43] = "FLOORBALL";
342
+ SuuntoActivityType2[SuuntoActivityType2["HANDBALL"] = 44] = "HANDBALL";
343
+ SuuntoActivityType2[SuuntoActivityType2["SOFTBALL"] = 45] = "SOFTBALL";
344
+ SuuntoActivityType2[SuuntoActivityType2["BOWLING"] = 46] = "BOWLING";
345
+ SuuntoActivityType2[SuuntoActivityType2["CRICKET"] = 47] = "CRICKET";
346
+ SuuntoActivityType2[SuuntoActivityType2["RUGBY"] = 48] = "RUGBY";
347
+ SuuntoActivityType2[SuuntoActivityType2["ICE_SKATING"] = 49] = "ICE_SKATING";
348
+ SuuntoActivityType2[SuuntoActivityType2["ICE_HOCKEY"] = 50] = "ICE_HOCKEY";
349
+ SuuntoActivityType2[SuuntoActivityType2["YOGA"] = 51] = "YOGA";
350
+ SuuntoActivityType2[SuuntoActivityType2["INDOOR_CYCLING"] = 52] = "INDOOR_CYCLING";
351
+ SuuntoActivityType2[SuuntoActivityType2["TREADMILL"] = 53] = "TREADMILL";
352
+ SuuntoActivityType2[SuuntoActivityType2["CROSSFIT"] = 54] = "CROSSFIT";
353
+ SuuntoActivityType2[SuuntoActivityType2["CROSSTRAINER"] = 55] = "CROSSTRAINER";
354
+ SuuntoActivityType2[SuuntoActivityType2["ROLLER_SKIING"] = 56] = "ROLLER_SKIING";
355
+ SuuntoActivityType2[SuuntoActivityType2["INDOOR_ROWING"] = 57] = "INDOOR_ROWING";
356
+ SuuntoActivityType2[SuuntoActivityType2["STRETCHING"] = 58] = "STRETCHING";
357
+ SuuntoActivityType2[SuuntoActivityType2["TRACK_AND_FIELD"] = 59] = "TRACK_AND_FIELD";
358
+ SuuntoActivityType2[SuuntoActivityType2["ORIENTEERING"] = 60] = "ORIENTEERING";
359
+ SuuntoActivityType2[SuuntoActivityType2["SUP"] = 61] = "SUP";
360
+ SuuntoActivityType2[SuuntoActivityType2["COMBAT_SPORTS"] = 62] = "COMBAT_SPORTS";
361
+ SuuntoActivityType2[SuuntoActivityType2["KETTLEBELL"] = 63] = "KETTLEBELL";
362
+ SuuntoActivityType2[SuuntoActivityType2["DANCING"] = 64] = "DANCING";
363
+ SuuntoActivityType2[SuuntoActivityType2["SNOWSHOEING"] = 65] = "SNOWSHOEING";
364
+ SuuntoActivityType2[SuuntoActivityType2["FRISBEE_GOLF"] = 66] = "FRISBEE_GOLF";
365
+ SuuntoActivityType2[SuuntoActivityType2["FUTSAL"] = 67] = "FUTSAL";
366
+ SuuntoActivityType2[SuuntoActivityType2["MULTISPORT"] = 68] = "MULTISPORT";
367
+ SuuntoActivityType2[SuuntoActivityType2["AEROBICS"] = 69] = "AEROBICS";
368
+ SuuntoActivityType2[SuuntoActivityType2["TREKKING"] = 70] = "TREKKING";
369
+ SuuntoActivityType2[SuuntoActivityType2["SAILING"] = 71] = "SAILING";
370
+ SuuntoActivityType2[SuuntoActivityType2["KAYAKING"] = 72] = "KAYAKING";
371
+ SuuntoActivityType2[SuuntoActivityType2["CIRCUIT_TRAINING"] = 73] = "CIRCUIT_TRAINING";
372
+ SuuntoActivityType2[SuuntoActivityType2["TRIATHLON"] = 74] = "TRIATHLON";
373
+ SuuntoActivityType2[SuuntoActivityType2["PADEL"] = 75] = "PADEL";
374
+ SuuntoActivityType2[SuuntoActivityType2["CHEERLEADING"] = 76] = "CHEERLEADING";
375
+ SuuntoActivityType2[SuuntoActivityType2["BOXING"] = 77] = "BOXING";
376
+ SuuntoActivityType2[SuuntoActivityType2["SCUBADIVING"] = 78] = "SCUBADIVING";
377
+ SuuntoActivityType2[SuuntoActivityType2["FREEDIVING"] = 79] = "FREEDIVING";
378
+ SuuntoActivityType2[SuuntoActivityType2["ADVENTURE_RACING"] = 80] = "ADVENTURE_RACING";
379
+ SuuntoActivityType2[SuuntoActivityType2["GYMNASTICS"] = 81] = "GYMNASTICS";
380
+ SuuntoActivityType2[SuuntoActivityType2["CANOEING"] = 82] = "CANOEING";
381
+ SuuntoActivityType2[SuuntoActivityType2["MOUNTAINEERING"] = 83] = "MOUNTAINEERING";
382
+ SuuntoActivityType2[SuuntoActivityType2["TELEMARKSKIING"] = 84] = "TELEMARKSKIING";
383
+ SuuntoActivityType2[SuuntoActivityType2["OPENWATER_SWIMMING"] = 85] = "OPENWATER_SWIMMING";
384
+ SuuntoActivityType2[SuuntoActivityType2["WINDSURFING"] = 86] = "WINDSURFING";
385
+ SuuntoActivityType2[SuuntoActivityType2["KITESURFING_KITING"] = 87] = "KITESURFING_KITING";
386
+ SuuntoActivityType2[SuuntoActivityType2["PARAGLIDING"] = 88] = "PARAGLIDING";
387
+ SuuntoActivityType2[SuuntoActivityType2["SNORKELING"] = 90] = "SNORKELING";
388
+ SuuntoActivityType2[SuuntoActivityType2["SURFING"] = 91] = "SURFING";
389
+ SuuntoActivityType2[SuuntoActivityType2["SWIMRUN"] = 92] = "SWIMRUN";
390
+ SuuntoActivityType2[SuuntoActivityType2["DUATHLON"] = 93] = "DUATHLON";
391
+ SuuntoActivityType2[SuuntoActivityType2["AQUATHLON"] = 94] = "AQUATHLON";
392
+ SuuntoActivityType2[SuuntoActivityType2["OBSTACLE_RACING"] = 95] = "OBSTACLE_RACING";
393
+ SuuntoActivityType2[SuuntoActivityType2["FISHING"] = 96] = "FISHING";
394
+ SuuntoActivityType2[SuuntoActivityType2["HUNTING"] = 97] = "HUNTING";
395
+ SuuntoActivityType2[SuuntoActivityType2["GRAVEL_CYCLING"] = 99] = "GRAVEL_CYCLING";
396
+ SuuntoActivityType2[SuuntoActivityType2["MERMAIDING"] = 100] = "MERMAIDING";
397
+ SuuntoActivityType2[SuuntoActivityType2["SPEARFISHING"] = 101] = "SPEARFISHING";
398
+ SuuntoActivityType2[SuuntoActivityType2["JUMP_ROPE"] = 102] = "JUMP_ROPE";
399
+ SuuntoActivityType2[SuuntoActivityType2["TRACK_RUNNING"] = 103] = "TRACK_RUNNING";
400
+ SuuntoActivityType2[SuuntoActivityType2["CALISTHENICS"] = 104] = "CALISTHENICS";
401
+ SuuntoActivityType2[SuuntoActivityType2["E_BIKING"] = 105] = "E_BIKING";
402
+ SuuntoActivityType2[SuuntoActivityType2["E_MTB"] = 106] = "E_MTB";
403
+ SuuntoActivityType2[SuuntoActivityType2["BACKCOUNTRY_SKIING"] = 107] = "BACKCOUNTRY_SKIING";
404
+ SuuntoActivityType2[SuuntoActivityType2["WHEELCHAIR"] = 108] = "WHEELCHAIR";
405
+ SuuntoActivityType2[SuuntoActivityType2["HAND_CYCLING"] = 109] = "HAND_CYCLING";
406
+ SuuntoActivityType2[SuuntoActivityType2["SPLIT_BOARDING"] = 110] = "SPLIT_BOARDING";
407
+ SuuntoActivityType2[SuuntoActivityType2["BIATHLON"] = 111] = "BIATHLON";
408
+ SuuntoActivityType2[SuuntoActivityType2["MEDITATION"] = 112] = "MEDITATION";
409
+ SuuntoActivityType2[SuuntoActivityType2["FIELD_HOCKEY"] = 113] = "FIELD_HOCKEY";
410
+ SuuntoActivityType2[SuuntoActivityType2["CYCLOCROSS"] = 114] = "CYCLOCROSS";
411
+ SuuntoActivityType2[SuuntoActivityType2["VERTICAL_RUN"] = 115] = "VERTICAL_RUN";
412
+ SuuntoActivityType2[SuuntoActivityType2["SKI_MOUNTAINEERING"] = 116] = "SKI_MOUNTAINEERING";
413
+ SuuntoActivityType2[SuuntoActivityType2["SKATE_SKIING"] = 117] = "SKATE_SKIING";
414
+ SuuntoActivityType2[SuuntoActivityType2["CLASSIC_SKIING"] = 118] = "CLASSIC_SKIING";
415
+ SuuntoActivityType2[SuuntoActivityType2["CHORES"] = 119] = "CHORES";
416
+ SuuntoActivityType2[SuuntoActivityType2["PILATES"] = 120] = "PILATES";
417
+ SuuntoActivityType2[SuuntoActivityType2["NEW_YOGA"] = 121] = "NEW_YOGA";
418
+ return SuuntoActivityType2;
419
+ })(SuuntoActivityType || {});
420
+
293
421
  // src/workouts/index.ts
422
+ var DEFAULT_WORKOUT_EXTENSIONS = [
423
+ "SummaryExtension" /* Summary */,
424
+ "CompetitionHeaderExtension" /* CompetitionHeader */
425
+ ];
426
+ var DEFAULT_WORKOUT_ADDITIONAL_DATA = [
427
+ "achievements" /* Achievements */,
428
+ "photos" /* Photos */,
429
+ "videos" /* Videos */,
430
+ "comments" /* Comments */,
431
+ "user_reacted" /* UserReacted */
432
+ ];
294
433
  async function getWorkouts(client, username, params = {}) {
295
434
  const { limit = 40, sortonst = true } = params;
296
435
  const res = await client.get(
@@ -310,6 +449,44 @@ async function getOwnWorkouts(client, params = {}) {
310
449
  );
311
450
  return res.data;
312
451
  }
452
+ async function getWorkout(client, username, workoutKey, params = {}) {
453
+ const {
454
+ extensions = DEFAULT_WORKOUT_EXTENSIONS,
455
+ additionalData = DEFAULT_WORKOUT_ADDITIONAL_DATA
456
+ } = params;
457
+ const res = await client.get(
458
+ `/apiserver/v2/workouts/${encodeURIComponent(username)}/${encodeURIComponent(workoutKey)}/combined`,
459
+ {
460
+ query: {
461
+ extensions: extensions.join(","),
462
+ additionalData: additionalData.join(",")
463
+ }
464
+ }
465
+ );
466
+ return res.data;
467
+ }
468
+ async function getWorkoutsWithin(client, params) {
469
+ const { lowerLat, lowerLng, upperLat, upperLng, limit = 50 } = params;
470
+ const res = await client.get(
471
+ "/apiserver/v1/workouts/public/within",
472
+ {
473
+ query: {
474
+ lowerlat: lowerLat,
475
+ lowerlng: lowerLng,
476
+ upperlat: upperLat,
477
+ upperlng: upperLng,
478
+ limit
479
+ }
480
+ }
481
+ );
482
+ return res.data;
483
+ }
484
+ async function getWorkoutStats(client, username) {
485
+ const res = await client.get(
486
+ `/apiserver/v1/workouts/${encodeURIComponent(username)}/stats`
487
+ );
488
+ return res.data;
489
+ }
313
490
  var WorkoutsResource = class {
314
491
  constructor(client) {
315
492
  this.client = client;
@@ -322,6 +499,24 @@ var WorkoutsResource = class {
322
499
  public(username, params) {
323
500
  return getWorkouts(this.client, username, params);
324
501
  }
502
+ /**
503
+ * A single workout by username and workout key. Works for any public workout
504
+ * and, when the client is authenticated as the owner, for private ones too.
505
+ */
506
+ byKey(username, workoutKey, params) {
507
+ return getWorkout(this.client, username, workoutKey, params);
508
+ }
509
+ /**
510
+ * Aggregated workout stats per activity for the given user. Works
511
+ * unauthenticated.
512
+ */
513
+ stats(username) {
514
+ return getWorkoutStats(this.client, username);
515
+ }
516
+ /** Public workouts whose center falls inside a geographic bounding box. */
517
+ within(params) {
518
+ return getWorkoutsWithin(this.client, params);
519
+ }
325
520
  };
326
521
 
327
522
  // src/users/index.ts
@@ -417,6 +612,7 @@ var SuuntoClient = class _SuuntoClient {
417
612
  HttpClient,
418
613
  HttpError,
419
614
  SPORTS_TRACKER_API,
615
+ SuuntoActivityType,
420
616
  SuuntoClient,
421
617
  UsersResource,
422
618
  WorkoutsResource,
@@ -424,7 +620,9 @@ var SuuntoClient = class _SuuntoClient {
424
620
  getLatestGear,
425
621
  getOwnWorkouts,
426
622
  getUserByName,
623
+ getWorkoutStats,
427
624
  getWorkouts,
625
+ getWorkoutsWithin,
428
626
  login,
429
627
  searchUsers,
430
628
  secondsUntilRollover,