suunto-api-wrapper 1.2.0 → 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/README.md +16 -2
- package/dist/index.d.mts +282 -61
- package/dist/index.d.ts +282 -61
- package/dist/index.js +164 -0
- package/dist/index.mjs +161 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
# suunto-api-wrapper
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/suunto-api-wrapper)
|
|
4
|
+
[](https://sonarcloud.io/summary/new_code?id=Marius-Ar_suunto-api-wrapper)
|
|
4
5
|
|
|
5
|
-
A small, typed TypeScript client for the **Suunto app API**
|
|
6
|
-
the Sports Tracker
|
|
6
|
+
A small, typed TypeScript client for the **Suunto mobile app API** the same
|
|
7
|
+
backend the Suunto phone app talks to (served by Sports Tracker at
|
|
8
|
+
`api.sports-tracker.com`).
|
|
9
|
+
|
|
10
|
+
**No Suunto apizone / developer account required.** This library does **not**
|
|
11
|
+
use Suunto's official partner API at `apizone.suunto.com`, so there are no
|
|
12
|
+
OAuth client IDs, no app registration, and no developer approval to deal with.
|
|
13
|
+
You authenticate with the same email + password you use in the Suunto app.
|
|
7
14
|
|
|
8
15
|
It handles the annoying parts and exposes the endpoints as
|
|
9
16
|
typed, resource‑grouped methods:
|
|
@@ -83,6 +90,8 @@ payload, typed to the real API response shape (an envelope of
|
|
|
83
90
|
| `suunto.workouts` | `.own(params?)` | your own workouts |
|
|
84
91
|
| | `.public(username, params?)` | a user's public workouts |
|
|
85
92
|
| | `.byKey(username, key, params?)` | a single workout (public, or your own when authed) |
|
|
93
|
+
| | `.stats(username)` | aggregated workout stats per activity |
|
|
94
|
+
| | `.within(box)` | public workouts inside a lat/lng bounding box |
|
|
86
95
|
| `suunto.users` | `.byName(username)` | a user's public profile |
|
|
87
96
|
| | `.search(terms)` | search for users |
|
|
88
97
|
| `suunto.gear` | `.latest(username, params?)` | a user's latest gear |
|
|
@@ -92,6 +101,10 @@ payload, typed to the real API response shape (an envelope of
|
|
|
92
101
|
const own = await suunto.workouts.own({ limit: 20, offset: 0, since: 0 });
|
|
93
102
|
const publicItems = await suunto.workouts.public("someuser", { limit: 40 });
|
|
94
103
|
const single = await suunto.workouts.byKey("someuser", "workoutKey123");
|
|
104
|
+
const stats = await suunto.workouts.stats("someuser");
|
|
105
|
+
const nearby = await suunto.workouts.within({
|
|
106
|
+
lowerLat: 45.70, lowerLng: 4.75, upperLat: 45.85, upperLng: 4.95, limit: 50,
|
|
107
|
+
});
|
|
95
108
|
|
|
96
109
|
// Users
|
|
97
110
|
const profile = await suunto.users.byName("someuser");
|
|
@@ -122,6 +135,7 @@ Some endpoints (like fetching a public profile) don't require login. Use the
|
|
|
122
135
|
```ts
|
|
123
136
|
const guest = SuuntoClient.unauthenticated();
|
|
124
137
|
const profile = await guest.users.byName("someuser");
|
|
138
|
+
const stats = await guest.workouts.stats("someuser");
|
|
125
139
|
```
|
|
126
140
|
|
|
127
141
|
### Escape hatch: the raw HTTP client
|
package/dist/index.d.mts
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,142 @@ 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
|
+
}
|
|
98
296
|
/** Valid values for the `extensions` query param on the single-workout endpoint. */
|
|
99
297
|
declare enum WorkoutExtensionName {
|
|
100
298
|
Dive = "DiveExtension",
|
|
@@ -312,8 +510,7 @@ type WorkoutExtension = FitnessExtension | IntensityExtension | SummaryExtension
|
|
|
312
510
|
interface Workout {
|
|
313
511
|
username: string;
|
|
314
512
|
sharingFlags: number;
|
|
315
|
-
|
|
316
|
-
activityId: number;
|
|
513
|
+
activityId: SuuntoActivityType;
|
|
317
514
|
key: string;
|
|
318
515
|
startTime: number;
|
|
319
516
|
stopTime: number;
|
|
@@ -341,7 +538,8 @@ interface Workout {
|
|
|
341
538
|
tss: TssEntry;
|
|
342
539
|
tssList: TssEntry[];
|
|
343
540
|
suuntoTags: string[];
|
|
344
|
-
|
|
541
|
+
/** Absent on some workouts (e.g. when the user has no achievements yet). */
|
|
542
|
+
clientCalculatedAchievements?: ClientCalculatedAchievements;
|
|
345
543
|
workoutKey: string;
|
|
346
544
|
visibilityFacebook: boolean;
|
|
347
545
|
visibilityTwitter: boolean;
|
|
@@ -370,6 +568,16 @@ interface Workout {
|
|
|
370
568
|
comments?: WorkoutComment[];
|
|
371
569
|
/** Only present when reactionCount > 0. */
|
|
372
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;
|
|
373
581
|
}
|
|
374
582
|
interface WorkoutsResponse {
|
|
375
583
|
error: string | null;
|
|
@@ -384,9 +592,72 @@ interface WorkoutResponse {
|
|
|
384
592
|
payload: Workout;
|
|
385
593
|
metadata: Record<string, unknown>;
|
|
386
594
|
}
|
|
595
|
+
/** Single item from the {@link getWorkoutsWithin} feed: owner + workout. */
|
|
596
|
+
interface WorkoutsWithinItem {
|
|
597
|
+
user: SearchUser;
|
|
598
|
+
workout: Workout;
|
|
599
|
+
}
|
|
600
|
+
interface WorkoutsWithinResponse {
|
|
601
|
+
error: string | null;
|
|
602
|
+
payload: WorkoutsWithinItem[];
|
|
603
|
+
metadata: {
|
|
604
|
+
workoutcount: string;
|
|
605
|
+
};
|
|
606
|
+
}
|
|
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[];
|
|
640
|
+
}
|
|
641
|
+
interface WorkoutStatsResponse {
|
|
642
|
+
error: string | null;
|
|
643
|
+
payload: WorkoutStats;
|
|
644
|
+
metadata: {
|
|
645
|
+
ts: string;
|
|
646
|
+
};
|
|
647
|
+
}
|
|
387
648
|
|
|
388
649
|
declare function getWorkouts(client: HttpClient, username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
|
|
389
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>;
|
|
390
661
|
/** Workout endpoints, bound to an {@link HttpClient}. Accessed via `suunto.workouts`. */
|
|
391
662
|
declare class WorkoutsResource {
|
|
392
663
|
private readonly client;
|
|
@@ -400,63 +671,13 @@ declare class WorkoutsResource {
|
|
|
400
671
|
* and, when the client is authenticated as the owner, for private ones too.
|
|
401
672
|
*/
|
|
402
673
|
byKey(username: string, workoutKey: string, params?: GetWorkoutParams): Promise<WorkoutResponse>;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
realName: string;
|
|
411
|
-
/** ISO 3166-1 alpha-2 country code. */
|
|
412
|
-
country: string;
|
|
413
|
-
gender: string;
|
|
414
|
-
uuid: string;
|
|
415
|
-
blocked: boolean;
|
|
416
|
-
showLocale: boolean;
|
|
417
|
-
followersCount: number;
|
|
418
|
-
followingCount: number;
|
|
419
|
-
currentBlobStorageLocation: string;
|
|
420
|
-
defaultBinaryStorageLocation: string;
|
|
421
|
-
}
|
|
422
|
-
interface UserProfileResponse {
|
|
423
|
-
error: string | null;
|
|
424
|
-
payload: UserProfile;
|
|
425
|
-
metadata: {
|
|
426
|
-
ts: string;
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
/** User shape returned by the search endpoint (differs slightly from {@link UserProfile}). */
|
|
430
|
-
interface SearchUser {
|
|
431
|
-
username: string;
|
|
432
|
-
createdDate: number;
|
|
433
|
-
lastModified: number;
|
|
434
|
-
lastLogin: number;
|
|
435
|
-
realName: string;
|
|
436
|
-
/** ISO 3166-1 country code. Mostly alpha-2, but legacy records may use alpha-3 (e.g. "FRA"). */
|
|
437
|
-
country?: string;
|
|
438
|
-
city?: string;
|
|
439
|
-
gender: string;
|
|
440
|
-
uuid: string;
|
|
441
|
-
imageKey?: string;
|
|
442
|
-
profileImageUrl?: string;
|
|
443
|
-
showLocale: boolean;
|
|
444
|
-
defaultBinaryStorageLocation: string;
|
|
445
|
-
currentBlobStorageLocation: string;
|
|
446
|
-
key: string;
|
|
447
|
-
}
|
|
448
|
-
interface UserSearchResult {
|
|
449
|
-
/** Relationship to the searching user, e.g. "STRANGER". */
|
|
450
|
-
connection: string;
|
|
451
|
-
user: SearchUser;
|
|
452
|
-
workout: unknown | null;
|
|
453
|
-
}
|
|
454
|
-
interface UserSearchResponse {
|
|
455
|
-
error: string | null;
|
|
456
|
-
payload: UserSearchResult[];
|
|
457
|
-
metadata: {
|
|
458
|
-
ts: string;
|
|
459
|
-
};
|
|
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>;
|
|
460
681
|
}
|
|
461
682
|
|
|
462
683
|
/**
|
|
@@ -542,4 +763,4 @@ declare class SuuntoClient {
|
|
|
542
763
|
static unauthenticated(options?: Omit<SuuntoClientOptions, "email" | "sessionKey">): SuuntoClient;
|
|
543
764
|
}
|
|
544
765
|
|
|
545
|
-
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.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,142 @@ 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
|
+
}
|
|
98
296
|
/** Valid values for the `extensions` query param on the single-workout endpoint. */
|
|
99
297
|
declare enum WorkoutExtensionName {
|
|
100
298
|
Dive = "DiveExtension",
|
|
@@ -312,8 +510,7 @@ type WorkoutExtension = FitnessExtension | IntensityExtension | SummaryExtension
|
|
|
312
510
|
interface Workout {
|
|
313
511
|
username: string;
|
|
314
512
|
sharingFlags: number;
|
|
315
|
-
|
|
316
|
-
activityId: number;
|
|
513
|
+
activityId: SuuntoActivityType;
|
|
317
514
|
key: string;
|
|
318
515
|
startTime: number;
|
|
319
516
|
stopTime: number;
|
|
@@ -341,7 +538,8 @@ interface Workout {
|
|
|
341
538
|
tss: TssEntry;
|
|
342
539
|
tssList: TssEntry[];
|
|
343
540
|
suuntoTags: string[];
|
|
344
|
-
|
|
541
|
+
/** Absent on some workouts (e.g. when the user has no achievements yet). */
|
|
542
|
+
clientCalculatedAchievements?: ClientCalculatedAchievements;
|
|
345
543
|
workoutKey: string;
|
|
346
544
|
visibilityFacebook: boolean;
|
|
347
545
|
visibilityTwitter: boolean;
|
|
@@ -370,6 +568,16 @@ interface Workout {
|
|
|
370
568
|
comments?: WorkoutComment[];
|
|
371
569
|
/** Only present when reactionCount > 0. */
|
|
372
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;
|
|
373
581
|
}
|
|
374
582
|
interface WorkoutsResponse {
|
|
375
583
|
error: string | null;
|
|
@@ -384,9 +592,72 @@ interface WorkoutResponse {
|
|
|
384
592
|
payload: Workout;
|
|
385
593
|
metadata: Record<string, unknown>;
|
|
386
594
|
}
|
|
595
|
+
/** Single item from the {@link getWorkoutsWithin} feed: owner + workout. */
|
|
596
|
+
interface WorkoutsWithinItem {
|
|
597
|
+
user: SearchUser;
|
|
598
|
+
workout: Workout;
|
|
599
|
+
}
|
|
600
|
+
interface WorkoutsWithinResponse {
|
|
601
|
+
error: string | null;
|
|
602
|
+
payload: WorkoutsWithinItem[];
|
|
603
|
+
metadata: {
|
|
604
|
+
workoutcount: string;
|
|
605
|
+
};
|
|
606
|
+
}
|
|
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[];
|
|
640
|
+
}
|
|
641
|
+
interface WorkoutStatsResponse {
|
|
642
|
+
error: string | null;
|
|
643
|
+
payload: WorkoutStats;
|
|
644
|
+
metadata: {
|
|
645
|
+
ts: string;
|
|
646
|
+
};
|
|
647
|
+
}
|
|
387
648
|
|
|
388
649
|
declare function getWorkouts(client: HttpClient, username: string, params?: GetWorkoutsParams): Promise<WorkoutsResponse>;
|
|
389
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>;
|
|
390
661
|
/** Workout endpoints, bound to an {@link HttpClient}. Accessed via `suunto.workouts`. */
|
|
391
662
|
declare class WorkoutsResource {
|
|
392
663
|
private readonly client;
|
|
@@ -400,63 +671,13 @@ declare class WorkoutsResource {
|
|
|
400
671
|
* and, when the client is authenticated as the owner, for private ones too.
|
|
401
672
|
*/
|
|
402
673
|
byKey(username: string, workoutKey: string, params?: GetWorkoutParams): Promise<WorkoutResponse>;
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
realName: string;
|
|
411
|
-
/** ISO 3166-1 alpha-2 country code. */
|
|
412
|
-
country: string;
|
|
413
|
-
gender: string;
|
|
414
|
-
uuid: string;
|
|
415
|
-
blocked: boolean;
|
|
416
|
-
showLocale: boolean;
|
|
417
|
-
followersCount: number;
|
|
418
|
-
followingCount: number;
|
|
419
|
-
currentBlobStorageLocation: string;
|
|
420
|
-
defaultBinaryStorageLocation: string;
|
|
421
|
-
}
|
|
422
|
-
interface UserProfileResponse {
|
|
423
|
-
error: string | null;
|
|
424
|
-
payload: UserProfile;
|
|
425
|
-
metadata: {
|
|
426
|
-
ts: string;
|
|
427
|
-
};
|
|
428
|
-
}
|
|
429
|
-
/** User shape returned by the search endpoint (differs slightly from {@link UserProfile}). */
|
|
430
|
-
interface SearchUser {
|
|
431
|
-
username: string;
|
|
432
|
-
createdDate: number;
|
|
433
|
-
lastModified: number;
|
|
434
|
-
lastLogin: number;
|
|
435
|
-
realName: string;
|
|
436
|
-
/** ISO 3166-1 country code. Mostly alpha-2, but legacy records may use alpha-3 (e.g. "FRA"). */
|
|
437
|
-
country?: string;
|
|
438
|
-
city?: string;
|
|
439
|
-
gender: string;
|
|
440
|
-
uuid: string;
|
|
441
|
-
imageKey?: string;
|
|
442
|
-
profileImageUrl?: string;
|
|
443
|
-
showLocale: boolean;
|
|
444
|
-
defaultBinaryStorageLocation: string;
|
|
445
|
-
currentBlobStorageLocation: string;
|
|
446
|
-
key: string;
|
|
447
|
-
}
|
|
448
|
-
interface UserSearchResult {
|
|
449
|
-
/** Relationship to the searching user, e.g. "STRANGER". */
|
|
450
|
-
connection: string;
|
|
451
|
-
user: SearchUser;
|
|
452
|
-
workout: unknown | null;
|
|
453
|
-
}
|
|
454
|
-
interface UserSearchResponse {
|
|
455
|
-
error: string | null;
|
|
456
|
-
payload: UserSearchResult[];
|
|
457
|
-
metadata: {
|
|
458
|
-
ts: string;
|
|
459
|
-
};
|
|
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>;
|
|
460
681
|
}
|
|
461
682
|
|
|
462
683
|
/**
|
|
@@ -542,4 +763,4 @@ declare class SuuntoClient {
|
|
|
542
763
|
static unauthenticated(options?: Omit<SuuntoClientOptions, "email" | "sessionKey">): SuuntoClient;
|
|
543
764
|
}
|
|
544
765
|
|
|
545
|
-
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,6 +293,131 @@ 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
|
|
294
422
|
var DEFAULT_WORKOUT_EXTENSIONS = [
|
|
295
423
|
"SummaryExtension" /* Summary */,
|
|
@@ -337,6 +465,28 @@ async function getWorkout(client, username, workoutKey, params = {}) {
|
|
|
337
465
|
);
|
|
338
466
|
return res.data;
|
|
339
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
|
+
}
|
|
340
490
|
var WorkoutsResource = class {
|
|
341
491
|
constructor(client) {
|
|
342
492
|
this.client = client;
|
|
@@ -356,6 +506,17 @@ var WorkoutsResource = class {
|
|
|
356
506
|
byKey(username, workoutKey, params) {
|
|
357
507
|
return getWorkout(this.client, username, workoutKey, params);
|
|
358
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
|
+
}
|
|
359
520
|
};
|
|
360
521
|
|
|
361
522
|
// src/users/index.ts
|
|
@@ -451,6 +612,7 @@ var SuuntoClient = class _SuuntoClient {
|
|
|
451
612
|
HttpClient,
|
|
452
613
|
HttpError,
|
|
453
614
|
SPORTS_TRACKER_API,
|
|
615
|
+
SuuntoActivityType,
|
|
454
616
|
SuuntoClient,
|
|
455
617
|
UsersResource,
|
|
456
618
|
WorkoutsResource,
|
|
@@ -458,7 +620,9 @@ var SuuntoClient = class _SuuntoClient {
|
|
|
458
620
|
getLatestGear,
|
|
459
621
|
getOwnWorkouts,
|
|
460
622
|
getUserByName,
|
|
623
|
+
getWorkoutStats,
|
|
461
624
|
getWorkouts,
|
|
625
|
+
getWorkoutsWithin,
|
|
462
626
|
login,
|
|
463
627
|
searchUsers,
|
|
464
628
|
secondsUntilRollover,
|
package/dist/index.mjs
CHANGED
|
@@ -248,6 +248,131 @@ function sessionTokenFrom(response) {
|
|
|
248
248
|
return response.sessionkey;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
// src/workouts/types.ts
|
|
252
|
+
var SuuntoActivityType = /* @__PURE__ */ ((SuuntoActivityType2) => {
|
|
253
|
+
SuuntoActivityType2[SuuntoActivityType2["WALKING"] = 0] = "WALKING";
|
|
254
|
+
SuuntoActivityType2[SuuntoActivityType2["RUNNING"] = 1] = "RUNNING";
|
|
255
|
+
SuuntoActivityType2[SuuntoActivityType2["CYCLING"] = 2] = "CYCLING";
|
|
256
|
+
SuuntoActivityType2[SuuntoActivityType2["CROSS_COUNTRY_SKIING"] = 3] = "CROSS_COUNTRY_SKIING";
|
|
257
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_1"] = 4] = "OTHER_1";
|
|
258
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_2"] = 5] = "OTHER_2";
|
|
259
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_3"] = 6] = "OTHER_3";
|
|
260
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_4"] = 7] = "OTHER_4";
|
|
261
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_5"] = 8] = "OTHER_5";
|
|
262
|
+
SuuntoActivityType2[SuuntoActivityType2["OTHER_6"] = 9] = "OTHER_6";
|
|
263
|
+
SuuntoActivityType2[SuuntoActivityType2["MOUNTAIN_BIKING"] = 10] = "MOUNTAIN_BIKING";
|
|
264
|
+
SuuntoActivityType2[SuuntoActivityType2["HIKING"] = 11] = "HIKING";
|
|
265
|
+
SuuntoActivityType2[SuuntoActivityType2["ROLLER_SKATING"] = 12] = "ROLLER_SKATING";
|
|
266
|
+
SuuntoActivityType2[SuuntoActivityType2["DOWNHILL_SKIING"] = 13] = "DOWNHILL_SKIING";
|
|
267
|
+
SuuntoActivityType2[SuuntoActivityType2["PADDLING"] = 14] = "PADDLING";
|
|
268
|
+
SuuntoActivityType2[SuuntoActivityType2["ROWING"] = 15] = "ROWING";
|
|
269
|
+
SuuntoActivityType2[SuuntoActivityType2["GOLF"] = 16] = "GOLF";
|
|
270
|
+
SuuntoActivityType2[SuuntoActivityType2["INDOOR"] = 17] = "INDOOR";
|
|
271
|
+
SuuntoActivityType2[SuuntoActivityType2["PARKOUR"] = 18] = "PARKOUR";
|
|
272
|
+
SuuntoActivityType2[SuuntoActivityType2["BALLGAMES"] = 19] = "BALLGAMES";
|
|
273
|
+
SuuntoActivityType2[SuuntoActivityType2["OUTDOOR_GYM"] = 20] = "OUTDOOR_GYM";
|
|
274
|
+
SuuntoActivityType2[SuuntoActivityType2["SWIMMING"] = 21] = "SWIMMING";
|
|
275
|
+
SuuntoActivityType2[SuuntoActivityType2["TRAIL_RUNNING"] = 22] = "TRAIL_RUNNING";
|
|
276
|
+
SuuntoActivityType2[SuuntoActivityType2["GYM"] = 23] = "GYM";
|
|
277
|
+
SuuntoActivityType2[SuuntoActivityType2["NORDIC_WALKING"] = 24] = "NORDIC_WALKING";
|
|
278
|
+
SuuntoActivityType2[SuuntoActivityType2["HORSEBACK_RIDING"] = 25] = "HORSEBACK_RIDING";
|
|
279
|
+
SuuntoActivityType2[SuuntoActivityType2["MOTOR_SPORTS"] = 26] = "MOTOR_SPORTS";
|
|
280
|
+
SuuntoActivityType2[SuuntoActivityType2["SKATEBOARDING"] = 27] = "SKATEBOARDING";
|
|
281
|
+
SuuntoActivityType2[SuuntoActivityType2["WATER_SPORTS"] = 28] = "WATER_SPORTS";
|
|
282
|
+
SuuntoActivityType2[SuuntoActivityType2["CLIMBING"] = 29] = "CLIMBING";
|
|
283
|
+
SuuntoActivityType2[SuuntoActivityType2["SNOWBOARDING"] = 30] = "SNOWBOARDING";
|
|
284
|
+
SuuntoActivityType2[SuuntoActivityType2["SKI_TOURING"] = 31] = "SKI_TOURING";
|
|
285
|
+
SuuntoActivityType2[SuuntoActivityType2["FITNESS_CLASS"] = 32] = "FITNESS_CLASS";
|
|
286
|
+
SuuntoActivityType2[SuuntoActivityType2["SOCCER"] = 33] = "SOCCER";
|
|
287
|
+
SuuntoActivityType2[SuuntoActivityType2["TENNIS"] = 34] = "TENNIS";
|
|
288
|
+
SuuntoActivityType2[SuuntoActivityType2["BASKETBALL"] = 35] = "BASKETBALL";
|
|
289
|
+
SuuntoActivityType2[SuuntoActivityType2["BADMINTON"] = 36] = "BADMINTON";
|
|
290
|
+
SuuntoActivityType2[SuuntoActivityType2["BASEBALL"] = 37] = "BASEBALL";
|
|
291
|
+
SuuntoActivityType2[SuuntoActivityType2["VOLLEYBALL"] = 38] = "VOLLEYBALL";
|
|
292
|
+
SuuntoActivityType2[SuuntoActivityType2["AMERICAN_FOOTBALL"] = 39] = "AMERICAN_FOOTBALL";
|
|
293
|
+
SuuntoActivityType2[SuuntoActivityType2["TABLE_TENNIS"] = 40] = "TABLE_TENNIS";
|
|
294
|
+
SuuntoActivityType2[SuuntoActivityType2["RACQUETBALL"] = 41] = "RACQUETBALL";
|
|
295
|
+
SuuntoActivityType2[SuuntoActivityType2["SQUASH"] = 42] = "SQUASH";
|
|
296
|
+
SuuntoActivityType2[SuuntoActivityType2["FLOORBALL"] = 43] = "FLOORBALL";
|
|
297
|
+
SuuntoActivityType2[SuuntoActivityType2["HANDBALL"] = 44] = "HANDBALL";
|
|
298
|
+
SuuntoActivityType2[SuuntoActivityType2["SOFTBALL"] = 45] = "SOFTBALL";
|
|
299
|
+
SuuntoActivityType2[SuuntoActivityType2["BOWLING"] = 46] = "BOWLING";
|
|
300
|
+
SuuntoActivityType2[SuuntoActivityType2["CRICKET"] = 47] = "CRICKET";
|
|
301
|
+
SuuntoActivityType2[SuuntoActivityType2["RUGBY"] = 48] = "RUGBY";
|
|
302
|
+
SuuntoActivityType2[SuuntoActivityType2["ICE_SKATING"] = 49] = "ICE_SKATING";
|
|
303
|
+
SuuntoActivityType2[SuuntoActivityType2["ICE_HOCKEY"] = 50] = "ICE_HOCKEY";
|
|
304
|
+
SuuntoActivityType2[SuuntoActivityType2["YOGA"] = 51] = "YOGA";
|
|
305
|
+
SuuntoActivityType2[SuuntoActivityType2["INDOOR_CYCLING"] = 52] = "INDOOR_CYCLING";
|
|
306
|
+
SuuntoActivityType2[SuuntoActivityType2["TREADMILL"] = 53] = "TREADMILL";
|
|
307
|
+
SuuntoActivityType2[SuuntoActivityType2["CROSSFIT"] = 54] = "CROSSFIT";
|
|
308
|
+
SuuntoActivityType2[SuuntoActivityType2["CROSSTRAINER"] = 55] = "CROSSTRAINER";
|
|
309
|
+
SuuntoActivityType2[SuuntoActivityType2["ROLLER_SKIING"] = 56] = "ROLLER_SKIING";
|
|
310
|
+
SuuntoActivityType2[SuuntoActivityType2["INDOOR_ROWING"] = 57] = "INDOOR_ROWING";
|
|
311
|
+
SuuntoActivityType2[SuuntoActivityType2["STRETCHING"] = 58] = "STRETCHING";
|
|
312
|
+
SuuntoActivityType2[SuuntoActivityType2["TRACK_AND_FIELD"] = 59] = "TRACK_AND_FIELD";
|
|
313
|
+
SuuntoActivityType2[SuuntoActivityType2["ORIENTEERING"] = 60] = "ORIENTEERING";
|
|
314
|
+
SuuntoActivityType2[SuuntoActivityType2["SUP"] = 61] = "SUP";
|
|
315
|
+
SuuntoActivityType2[SuuntoActivityType2["COMBAT_SPORTS"] = 62] = "COMBAT_SPORTS";
|
|
316
|
+
SuuntoActivityType2[SuuntoActivityType2["KETTLEBELL"] = 63] = "KETTLEBELL";
|
|
317
|
+
SuuntoActivityType2[SuuntoActivityType2["DANCING"] = 64] = "DANCING";
|
|
318
|
+
SuuntoActivityType2[SuuntoActivityType2["SNOWSHOEING"] = 65] = "SNOWSHOEING";
|
|
319
|
+
SuuntoActivityType2[SuuntoActivityType2["FRISBEE_GOLF"] = 66] = "FRISBEE_GOLF";
|
|
320
|
+
SuuntoActivityType2[SuuntoActivityType2["FUTSAL"] = 67] = "FUTSAL";
|
|
321
|
+
SuuntoActivityType2[SuuntoActivityType2["MULTISPORT"] = 68] = "MULTISPORT";
|
|
322
|
+
SuuntoActivityType2[SuuntoActivityType2["AEROBICS"] = 69] = "AEROBICS";
|
|
323
|
+
SuuntoActivityType2[SuuntoActivityType2["TREKKING"] = 70] = "TREKKING";
|
|
324
|
+
SuuntoActivityType2[SuuntoActivityType2["SAILING"] = 71] = "SAILING";
|
|
325
|
+
SuuntoActivityType2[SuuntoActivityType2["KAYAKING"] = 72] = "KAYAKING";
|
|
326
|
+
SuuntoActivityType2[SuuntoActivityType2["CIRCUIT_TRAINING"] = 73] = "CIRCUIT_TRAINING";
|
|
327
|
+
SuuntoActivityType2[SuuntoActivityType2["TRIATHLON"] = 74] = "TRIATHLON";
|
|
328
|
+
SuuntoActivityType2[SuuntoActivityType2["PADEL"] = 75] = "PADEL";
|
|
329
|
+
SuuntoActivityType2[SuuntoActivityType2["CHEERLEADING"] = 76] = "CHEERLEADING";
|
|
330
|
+
SuuntoActivityType2[SuuntoActivityType2["BOXING"] = 77] = "BOXING";
|
|
331
|
+
SuuntoActivityType2[SuuntoActivityType2["SCUBADIVING"] = 78] = "SCUBADIVING";
|
|
332
|
+
SuuntoActivityType2[SuuntoActivityType2["FREEDIVING"] = 79] = "FREEDIVING";
|
|
333
|
+
SuuntoActivityType2[SuuntoActivityType2["ADVENTURE_RACING"] = 80] = "ADVENTURE_RACING";
|
|
334
|
+
SuuntoActivityType2[SuuntoActivityType2["GYMNASTICS"] = 81] = "GYMNASTICS";
|
|
335
|
+
SuuntoActivityType2[SuuntoActivityType2["CANOEING"] = 82] = "CANOEING";
|
|
336
|
+
SuuntoActivityType2[SuuntoActivityType2["MOUNTAINEERING"] = 83] = "MOUNTAINEERING";
|
|
337
|
+
SuuntoActivityType2[SuuntoActivityType2["TELEMARKSKIING"] = 84] = "TELEMARKSKIING";
|
|
338
|
+
SuuntoActivityType2[SuuntoActivityType2["OPENWATER_SWIMMING"] = 85] = "OPENWATER_SWIMMING";
|
|
339
|
+
SuuntoActivityType2[SuuntoActivityType2["WINDSURFING"] = 86] = "WINDSURFING";
|
|
340
|
+
SuuntoActivityType2[SuuntoActivityType2["KITESURFING_KITING"] = 87] = "KITESURFING_KITING";
|
|
341
|
+
SuuntoActivityType2[SuuntoActivityType2["PARAGLIDING"] = 88] = "PARAGLIDING";
|
|
342
|
+
SuuntoActivityType2[SuuntoActivityType2["SNORKELING"] = 90] = "SNORKELING";
|
|
343
|
+
SuuntoActivityType2[SuuntoActivityType2["SURFING"] = 91] = "SURFING";
|
|
344
|
+
SuuntoActivityType2[SuuntoActivityType2["SWIMRUN"] = 92] = "SWIMRUN";
|
|
345
|
+
SuuntoActivityType2[SuuntoActivityType2["DUATHLON"] = 93] = "DUATHLON";
|
|
346
|
+
SuuntoActivityType2[SuuntoActivityType2["AQUATHLON"] = 94] = "AQUATHLON";
|
|
347
|
+
SuuntoActivityType2[SuuntoActivityType2["OBSTACLE_RACING"] = 95] = "OBSTACLE_RACING";
|
|
348
|
+
SuuntoActivityType2[SuuntoActivityType2["FISHING"] = 96] = "FISHING";
|
|
349
|
+
SuuntoActivityType2[SuuntoActivityType2["HUNTING"] = 97] = "HUNTING";
|
|
350
|
+
SuuntoActivityType2[SuuntoActivityType2["GRAVEL_CYCLING"] = 99] = "GRAVEL_CYCLING";
|
|
351
|
+
SuuntoActivityType2[SuuntoActivityType2["MERMAIDING"] = 100] = "MERMAIDING";
|
|
352
|
+
SuuntoActivityType2[SuuntoActivityType2["SPEARFISHING"] = 101] = "SPEARFISHING";
|
|
353
|
+
SuuntoActivityType2[SuuntoActivityType2["JUMP_ROPE"] = 102] = "JUMP_ROPE";
|
|
354
|
+
SuuntoActivityType2[SuuntoActivityType2["TRACK_RUNNING"] = 103] = "TRACK_RUNNING";
|
|
355
|
+
SuuntoActivityType2[SuuntoActivityType2["CALISTHENICS"] = 104] = "CALISTHENICS";
|
|
356
|
+
SuuntoActivityType2[SuuntoActivityType2["E_BIKING"] = 105] = "E_BIKING";
|
|
357
|
+
SuuntoActivityType2[SuuntoActivityType2["E_MTB"] = 106] = "E_MTB";
|
|
358
|
+
SuuntoActivityType2[SuuntoActivityType2["BACKCOUNTRY_SKIING"] = 107] = "BACKCOUNTRY_SKIING";
|
|
359
|
+
SuuntoActivityType2[SuuntoActivityType2["WHEELCHAIR"] = 108] = "WHEELCHAIR";
|
|
360
|
+
SuuntoActivityType2[SuuntoActivityType2["HAND_CYCLING"] = 109] = "HAND_CYCLING";
|
|
361
|
+
SuuntoActivityType2[SuuntoActivityType2["SPLIT_BOARDING"] = 110] = "SPLIT_BOARDING";
|
|
362
|
+
SuuntoActivityType2[SuuntoActivityType2["BIATHLON"] = 111] = "BIATHLON";
|
|
363
|
+
SuuntoActivityType2[SuuntoActivityType2["MEDITATION"] = 112] = "MEDITATION";
|
|
364
|
+
SuuntoActivityType2[SuuntoActivityType2["FIELD_HOCKEY"] = 113] = "FIELD_HOCKEY";
|
|
365
|
+
SuuntoActivityType2[SuuntoActivityType2["CYCLOCROSS"] = 114] = "CYCLOCROSS";
|
|
366
|
+
SuuntoActivityType2[SuuntoActivityType2["VERTICAL_RUN"] = 115] = "VERTICAL_RUN";
|
|
367
|
+
SuuntoActivityType2[SuuntoActivityType2["SKI_MOUNTAINEERING"] = 116] = "SKI_MOUNTAINEERING";
|
|
368
|
+
SuuntoActivityType2[SuuntoActivityType2["SKATE_SKIING"] = 117] = "SKATE_SKIING";
|
|
369
|
+
SuuntoActivityType2[SuuntoActivityType2["CLASSIC_SKIING"] = 118] = "CLASSIC_SKIING";
|
|
370
|
+
SuuntoActivityType2[SuuntoActivityType2["CHORES"] = 119] = "CHORES";
|
|
371
|
+
SuuntoActivityType2[SuuntoActivityType2["PILATES"] = 120] = "PILATES";
|
|
372
|
+
SuuntoActivityType2[SuuntoActivityType2["NEW_YOGA"] = 121] = "NEW_YOGA";
|
|
373
|
+
return SuuntoActivityType2;
|
|
374
|
+
})(SuuntoActivityType || {});
|
|
375
|
+
|
|
251
376
|
// src/workouts/index.ts
|
|
252
377
|
var DEFAULT_WORKOUT_EXTENSIONS = [
|
|
253
378
|
"SummaryExtension" /* Summary */,
|
|
@@ -295,6 +420,28 @@ async function getWorkout(client, username, workoutKey, params = {}) {
|
|
|
295
420
|
);
|
|
296
421
|
return res.data;
|
|
297
422
|
}
|
|
423
|
+
async function getWorkoutsWithin(client, params) {
|
|
424
|
+
const { lowerLat, lowerLng, upperLat, upperLng, limit = 50 } = params;
|
|
425
|
+
const res = await client.get(
|
|
426
|
+
"/apiserver/v1/workouts/public/within",
|
|
427
|
+
{
|
|
428
|
+
query: {
|
|
429
|
+
lowerlat: lowerLat,
|
|
430
|
+
lowerlng: lowerLng,
|
|
431
|
+
upperlat: upperLat,
|
|
432
|
+
upperlng: upperLng,
|
|
433
|
+
limit
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
);
|
|
437
|
+
return res.data;
|
|
438
|
+
}
|
|
439
|
+
async function getWorkoutStats(client, username) {
|
|
440
|
+
const res = await client.get(
|
|
441
|
+
`/apiserver/v1/workouts/${encodeURIComponent(username)}/stats`
|
|
442
|
+
);
|
|
443
|
+
return res.data;
|
|
444
|
+
}
|
|
298
445
|
var WorkoutsResource = class {
|
|
299
446
|
constructor(client) {
|
|
300
447
|
this.client = client;
|
|
@@ -314,6 +461,17 @@ var WorkoutsResource = class {
|
|
|
314
461
|
byKey(username, workoutKey, params) {
|
|
315
462
|
return getWorkout(this.client, username, workoutKey, params);
|
|
316
463
|
}
|
|
464
|
+
/**
|
|
465
|
+
* Aggregated workout stats per activity for the given user. Works
|
|
466
|
+
* unauthenticated.
|
|
467
|
+
*/
|
|
468
|
+
stats(username) {
|
|
469
|
+
return getWorkoutStats(this.client, username);
|
|
470
|
+
}
|
|
471
|
+
/** Public workouts whose center falls inside a geographic bounding box. */
|
|
472
|
+
within(params) {
|
|
473
|
+
return getWorkoutsWithin(this.client, params);
|
|
474
|
+
}
|
|
317
475
|
};
|
|
318
476
|
|
|
319
477
|
// src/users/index.ts
|
|
@@ -408,6 +566,7 @@ export {
|
|
|
408
566
|
HttpClient,
|
|
409
567
|
HttpError,
|
|
410
568
|
SPORTS_TRACKER_API,
|
|
569
|
+
SuuntoActivityType,
|
|
411
570
|
SuuntoClient,
|
|
412
571
|
UsersResource,
|
|
413
572
|
WorkoutsResource,
|
|
@@ -415,7 +574,9 @@ export {
|
|
|
415
574
|
getLatestGear,
|
|
416
575
|
getOwnWorkouts,
|
|
417
576
|
getUserByName,
|
|
577
|
+
getWorkoutStats,
|
|
418
578
|
getWorkouts,
|
|
579
|
+
getWorkoutsWithin,
|
|
419
580
|
login,
|
|
420
581
|
searchUsers,
|
|
421
582
|
secondsUntilRollover,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suunto-api-wrapper",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Unofficial typed TypeScript client for the Suunto app API (Sports Tracker backend). Not affiliated with or endorsed by Suunto or Sports Tracker.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/Marius-Ar/suunto-api-wrapper"
|