@pinta365/strava 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +390 -0
- package/esm/_dnt.shims.d.ts +2 -0
- package/esm/_dnt.shims.js +57 -0
- package/esm/deps/jsr.io/@cross/runtime/1.2.1/mod.d.ts +126 -0
- package/esm/deps/jsr.io/@cross/runtime/1.2.1/mod.js +480 -0
- package/esm/mod.d.ts +27 -0
- package/esm/mod.js +27 -0
- package/esm/package.json +3 -0
- package/esm/src/auth/oauth.d.ts +68 -0
- package/esm/src/auth/oauth.js +203 -0
- package/esm/src/auth/scopes.d.ts +52 -0
- package/esm/src/auth/scopes.js +71 -0
- package/esm/src/auth/token-store.d.ts +57 -0
- package/esm/src/auth/token-store.js +142 -0
- package/esm/src/client.d.ts +98 -0
- package/esm/src/client.js +235 -0
- package/esm/src/errors.d.ts +52 -0
- package/esm/src/errors.js +102 -0
- package/esm/src/http/deduplication.d.ts +33 -0
- package/esm/src/http/deduplication.js +96 -0
- package/esm/src/http/rate-limiter.d.ts +47 -0
- package/esm/src/http/rate-limiter.js +168 -0
- package/esm/src/http/request.d.ts +24 -0
- package/esm/src/http/request.js +158 -0
- package/esm/src/http/retry.d.ts +9 -0
- package/esm/src/http/retry.js +61 -0
- package/esm/src/resources/activities.d.ts +149 -0
- package/esm/src/resources/activities.js +189 -0
- package/esm/src/resources/athletes.d.ts +37 -0
- package/esm/src/resources/athletes.js +85 -0
- package/esm/src/resources/clubs.d.ts +45 -0
- package/esm/src/resources/clubs.js +71 -0
- package/esm/src/resources/gears.d.ts +17 -0
- package/esm/src/resources/gears.js +27 -0
- package/esm/src/resources/routes.d.ts +33 -0
- package/esm/src/resources/routes.js +71 -0
- package/esm/src/resources/segment-efforts.d.ts +38 -0
- package/esm/src/resources/segment-efforts.js +53 -0
- package/esm/src/resources/segments.d.ts +42 -0
- package/esm/src/resources/segments.js +67 -0
- package/esm/src/resources/streams.d.ts +44 -0
- package/esm/src/resources/streams.js +75 -0
- package/esm/src/resources/uploads.d.ts +41 -0
- package/esm/src/resources/uploads.js +79 -0
- package/esm/src/types/api.d.ts +9 -0
- package/esm/src/types/api.js +7 -0
- package/esm/src/types/common.d.ts +65 -0
- package/esm/src/types/common.js +4 -0
- package/esm/src/types/generated.d.ts +731 -0
- package/esm/src/types/generated.js +7 -0
- package/esm/src/utils/pagination.d.ts +45 -0
- package/esm/src/utils/pagination.js +112 -0
- package/esm/src/utils/transformers.d.ts +30 -0
- package/esm/src/utils/transformers.js +189 -0
- package/esm/src/utils/validators.d.ts +53 -0
- package/esm/src/utils/validators.js +84 -0
- package/package.json +40 -0
- package/script/_dnt.shims.d.ts +2 -0
- package/script/_dnt.shims.js +60 -0
- package/script/deps/jsr.io/@cross/runtime/1.2.1/mod.d.ts +126 -0
- package/script/deps/jsr.io/@cross/runtime/1.2.1/mod.js +526 -0
- package/script/mod.d.ts +27 -0
- package/script/mod.js +73 -0
- package/script/package.json +3 -0
- package/script/src/auth/oauth.d.ts +68 -0
- package/script/src/auth/oauth.js +211 -0
- package/script/src/auth/scopes.d.ts +52 -0
- package/script/src/auth/scopes.js +79 -0
- package/script/src/auth/token-store.d.ts +57 -0
- package/script/src/auth/token-store.js +182 -0
- package/script/src/client.d.ts +98 -0
- package/script/src/client.js +239 -0
- package/script/src/errors.d.ts +52 -0
- package/script/src/errors.js +111 -0
- package/script/src/http/deduplication.d.ts +33 -0
- package/script/src/http/deduplication.js +100 -0
- package/script/src/http/rate-limiter.d.ts +47 -0
- package/script/src/http/rate-limiter.js +172 -0
- package/script/src/http/request.d.ts +24 -0
- package/script/src/http/request.js +161 -0
- package/script/src/http/retry.d.ts +9 -0
- package/script/src/http/retry.js +64 -0
- package/script/src/resources/activities.d.ts +149 -0
- package/script/src/resources/activities.js +193 -0
- package/script/src/resources/athletes.d.ts +37 -0
- package/script/src/resources/athletes.js +89 -0
- package/script/src/resources/clubs.d.ts +45 -0
- package/script/src/resources/clubs.js +75 -0
- package/script/src/resources/gears.d.ts +17 -0
- package/script/src/resources/gears.js +31 -0
- package/script/src/resources/routes.d.ts +33 -0
- package/script/src/resources/routes.js +75 -0
- package/script/src/resources/segment-efforts.d.ts +38 -0
- package/script/src/resources/segment-efforts.js +57 -0
- package/script/src/resources/segments.d.ts +42 -0
- package/script/src/resources/segments.js +71 -0
- package/script/src/resources/streams.d.ts +44 -0
- package/script/src/resources/streams.js +79 -0
- package/script/src/resources/uploads.d.ts +41 -0
- package/script/src/resources/uploads.js +83 -0
- package/script/src/types/api.d.ts +9 -0
- package/script/src/types/api.js +23 -0
- package/script/src/types/common.d.ts +65 -0
- package/script/src/types/common.js +5 -0
- package/script/src/types/generated.d.ts +731 -0
- package/script/src/types/generated.js +8 -0
- package/script/src/utils/pagination.d.ts +45 -0
- package/script/src/utils/pagination.js +118 -0
- package/script/src/utils/transformers.d.ts +30 -0
- package/script/src/utils/transformers.js +196 -0
- package/script/src/utils/validators.d.ts +53 -0
- package/script/src/utils/validators.js +92 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Activities resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { ActivityZone, Comment, DetailedActivity, DetailedSegmentEffort, Lap, StreamSet, SummaryActivity, SummaryAthlete } from "../types/api.js";
|
|
6
|
+
import type { StreamType } from "./streams.js";
|
|
7
|
+
/**
|
|
8
|
+
* Options for listing activities
|
|
9
|
+
*/
|
|
10
|
+
export interface ListActivitiesOptions {
|
|
11
|
+
/** Unix timestamp for activities before this time */
|
|
12
|
+
before?: number;
|
|
13
|
+
/** Unix timestamp for activities after this time */
|
|
14
|
+
after?: number;
|
|
15
|
+
/** Page number (default: 1) */
|
|
16
|
+
page?: number;
|
|
17
|
+
/** Number of items per page (default: 30, max: 200) */
|
|
18
|
+
perPage?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Data for creating a new activity
|
|
22
|
+
*/
|
|
23
|
+
export interface CreateActivityData {
|
|
24
|
+
/** Activity name */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Activity type (e.g., "Run", "Ride") */
|
|
27
|
+
type: string;
|
|
28
|
+
/** Start date in ISO 8601 format */
|
|
29
|
+
startDateLocal: string;
|
|
30
|
+
/** Elapsed time in seconds */
|
|
31
|
+
elapsedTime: number;
|
|
32
|
+
/** Activity description */
|
|
33
|
+
description?: string;
|
|
34
|
+
/** Distance in meters */
|
|
35
|
+
distance?: number;
|
|
36
|
+
/** Whether activity was done on trainer */
|
|
37
|
+
trainer?: boolean;
|
|
38
|
+
/** Whether activity is a commute */
|
|
39
|
+
commute?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Data for updating an existing activity
|
|
43
|
+
*/
|
|
44
|
+
export interface UpdateActivityData {
|
|
45
|
+
/** Activity name */
|
|
46
|
+
name?: string;
|
|
47
|
+
/** Activity type (e.g., "Run", "Ride") */
|
|
48
|
+
type?: string;
|
|
49
|
+
/** Sport type */
|
|
50
|
+
sportType?: string;
|
|
51
|
+
/** Start date in ISO 8601 format */
|
|
52
|
+
startDateLocal?: string;
|
|
53
|
+
/** Elapsed time in seconds */
|
|
54
|
+
elapsedTime?: number;
|
|
55
|
+
/** Activity description */
|
|
56
|
+
description?: string;
|
|
57
|
+
/** Distance in meters */
|
|
58
|
+
distance?: number;
|
|
59
|
+
/** Whether activity was done on trainer */
|
|
60
|
+
trainer?: boolean;
|
|
61
|
+
/** Whether activity is a commute */
|
|
62
|
+
commute?: boolean;
|
|
63
|
+
/** Gear ID */
|
|
64
|
+
gearId?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resource for interacting with Strava activities
|
|
68
|
+
*/
|
|
69
|
+
export declare class ActivitiesResource {
|
|
70
|
+
private client;
|
|
71
|
+
constructor(client: StravaClient);
|
|
72
|
+
/**
|
|
73
|
+
* Get activity by ID
|
|
74
|
+
*/
|
|
75
|
+
getById(id: number): Promise<DetailedActivity>;
|
|
76
|
+
/**
|
|
77
|
+
* List athlete activities
|
|
78
|
+
*/
|
|
79
|
+
list(options?: ListActivitiesOptions): Promise<SummaryActivity[]>;
|
|
80
|
+
/**
|
|
81
|
+
* List all activities (auto-pagination)
|
|
82
|
+
*/
|
|
83
|
+
listAll(options?: Omit<ListActivitiesOptions, "page">): AsyncGenerator<SummaryActivity, void, unknown>;
|
|
84
|
+
/**
|
|
85
|
+
* Create activity
|
|
86
|
+
*/
|
|
87
|
+
create(data: CreateActivityData): Promise<DetailedActivity>;
|
|
88
|
+
/**
|
|
89
|
+
* Update activity
|
|
90
|
+
*/
|
|
91
|
+
update(id: number, data: UpdateActivityData): Promise<DetailedActivity>;
|
|
92
|
+
/**
|
|
93
|
+
* Delete activity
|
|
94
|
+
*/
|
|
95
|
+
delete(id: number): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Get activity with details (combines activity + laps + zones + comments + kudoers)
|
|
98
|
+
*/
|
|
99
|
+
getWithDetails(id: number): Promise<DetailedActivity & {
|
|
100
|
+
laps: Lap[];
|
|
101
|
+
zones: ActivityZone[];
|
|
102
|
+
comments: Comment[];
|
|
103
|
+
kudoers: SummaryAthlete[];
|
|
104
|
+
}>;
|
|
105
|
+
/**
|
|
106
|
+
* Get activity laps
|
|
107
|
+
*/
|
|
108
|
+
getLaps(id: number): Promise<Lap[]>;
|
|
109
|
+
/**
|
|
110
|
+
* Get activity zones
|
|
111
|
+
*/
|
|
112
|
+
getZones(id: number): Promise<ActivityZone[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Get activity comments
|
|
115
|
+
*/
|
|
116
|
+
getComments(id: number, options?: {
|
|
117
|
+
page?: number;
|
|
118
|
+
perPage?: number;
|
|
119
|
+
}): Promise<Comment[]>;
|
|
120
|
+
/**
|
|
121
|
+
* Get activity kudoers
|
|
122
|
+
*/
|
|
123
|
+
getKudoers(id: number, options?: {
|
|
124
|
+
page?: number;
|
|
125
|
+
perPage?: number;
|
|
126
|
+
}): Promise<SummaryAthlete[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Analyze activity with comprehensive data
|
|
129
|
+
* Combines activity, zones, laps, best efforts (segments), and optionally streams
|
|
130
|
+
*/
|
|
131
|
+
analyze(id: number, options?: {
|
|
132
|
+
includeStreams?: boolean;
|
|
133
|
+
streamTypes?: StreamType[];
|
|
134
|
+
}): Promise<DetailedActivity & {
|
|
135
|
+
zones: ActivityZone[];
|
|
136
|
+
laps: Lap[];
|
|
137
|
+
bestEfforts: DetailedSegmentEffort[];
|
|
138
|
+
streams?: StreamSet;
|
|
139
|
+
analysis: {
|
|
140
|
+
hasPowerData: boolean;
|
|
141
|
+
hasHeartRateData: boolean;
|
|
142
|
+
totalLaps: number;
|
|
143
|
+
bestEffortCount: number;
|
|
144
|
+
averageLapTime?: number;
|
|
145
|
+
averageLapDistance?: number;
|
|
146
|
+
};
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=activities.d.ts.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Activities resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ActivitiesResource = void 0;
|
|
7
|
+
const pagination_js_1 = require("../utils/pagination.js");
|
|
8
|
+
const validators_js_1 = require("../utils/validators.js");
|
|
9
|
+
const pagination_js_2 = require("../utils/pagination.js");
|
|
10
|
+
/**
|
|
11
|
+
* Resource for interacting with Strava activities
|
|
12
|
+
*/
|
|
13
|
+
class ActivitiesResource {
|
|
14
|
+
constructor(client) {
|
|
15
|
+
Object.defineProperty(this, "client", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: client
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get activity by ID
|
|
24
|
+
*/
|
|
25
|
+
async getById(id) {
|
|
26
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
27
|
+
return await this.client.request({
|
|
28
|
+
method: "GET",
|
|
29
|
+
path: `/activities/${id}`,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* List athlete activities
|
|
34
|
+
*/
|
|
35
|
+
async list(options) {
|
|
36
|
+
const query = {
|
|
37
|
+
...(0, pagination_js_1.buildPaginationQuery)(options),
|
|
38
|
+
};
|
|
39
|
+
if (options?.before) {
|
|
40
|
+
query.before = options.before;
|
|
41
|
+
}
|
|
42
|
+
if (options?.after) {
|
|
43
|
+
query.after = options.after;
|
|
44
|
+
}
|
|
45
|
+
return await this.client.request({
|
|
46
|
+
method: "GET",
|
|
47
|
+
path: "/athlete/activities",
|
|
48
|
+
query,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* List all activities (auto-pagination)
|
|
53
|
+
*/
|
|
54
|
+
async *listAll(options) {
|
|
55
|
+
yield* (0, pagination_js_2.listAll)((page, perPage) => {
|
|
56
|
+
return this.list({ ...options, page, perPage });
|
|
57
|
+
}, options?.perPage || 30);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Create activity
|
|
61
|
+
*/
|
|
62
|
+
async create(data) {
|
|
63
|
+
return await this.client.request({
|
|
64
|
+
method: "POST",
|
|
65
|
+
path: "/activities",
|
|
66
|
+
body: data,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Update activity
|
|
71
|
+
*/
|
|
72
|
+
async update(id, data) {
|
|
73
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
74
|
+
return await this.client.request({
|
|
75
|
+
method: "PUT",
|
|
76
|
+
path: `/activities/${id}`,
|
|
77
|
+
body: data,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Delete activity
|
|
82
|
+
*/
|
|
83
|
+
async delete(id) {
|
|
84
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
85
|
+
await this.client.request({
|
|
86
|
+
method: "DELETE",
|
|
87
|
+
path: `/activities/${id}`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get activity with details (combines activity + laps + zones + comments + kudoers)
|
|
92
|
+
*/
|
|
93
|
+
async getWithDetails(id) {
|
|
94
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
95
|
+
const [activity, laps, zones, comments, kudoers] = await Promise.all([
|
|
96
|
+
this.getById(id),
|
|
97
|
+
this.getLaps(id),
|
|
98
|
+
this.getZones(id),
|
|
99
|
+
this.getComments(id),
|
|
100
|
+
this.getKudoers(id),
|
|
101
|
+
]);
|
|
102
|
+
return {
|
|
103
|
+
...activity,
|
|
104
|
+
laps,
|
|
105
|
+
zones,
|
|
106
|
+
comments,
|
|
107
|
+
kudoers,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get activity laps
|
|
112
|
+
*/
|
|
113
|
+
async getLaps(id) {
|
|
114
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
115
|
+
return await this.client.request({
|
|
116
|
+
method: "GET",
|
|
117
|
+
path: `/activities/${id}/laps`,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Get activity zones
|
|
122
|
+
*/
|
|
123
|
+
async getZones(id) {
|
|
124
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
125
|
+
return await this.client.request({
|
|
126
|
+
method: "GET",
|
|
127
|
+
path: `/activities/${id}/zones`,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Get activity comments
|
|
132
|
+
*/
|
|
133
|
+
async getComments(id, options) {
|
|
134
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
135
|
+
return await this.client.request({
|
|
136
|
+
method: "GET",
|
|
137
|
+
path: `/activities/${id}/comments`,
|
|
138
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get activity kudoers
|
|
143
|
+
*/
|
|
144
|
+
async getKudoers(id, options) {
|
|
145
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
146
|
+
return await this.client.request({
|
|
147
|
+
method: "GET",
|
|
148
|
+
path: `/activities/${id}/kudoers`,
|
|
149
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Analyze activity with comprehensive data
|
|
154
|
+
* Combines activity, zones, laps, best efforts (segments), and optionally streams
|
|
155
|
+
*/
|
|
156
|
+
async analyze(id, options) {
|
|
157
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
158
|
+
const [activity, zones, laps] = await Promise.all([
|
|
159
|
+
this.getById(id),
|
|
160
|
+
this.getZones(id).catch(() => []),
|
|
161
|
+
this.getLaps(id).catch(() => []),
|
|
162
|
+
]);
|
|
163
|
+
const bestEfforts = activity.bestEfforts || [];
|
|
164
|
+
const analysis = {
|
|
165
|
+
hasPowerData: zones.some((z) => z.type === "power"),
|
|
166
|
+
hasHeartRateData: zones.some((z) => z.type === "heartrate"),
|
|
167
|
+
totalLaps: laps.length,
|
|
168
|
+
bestEffortCount: bestEfforts.length,
|
|
169
|
+
averageLapTime: laps.length > 0 ? laps.reduce((sum, lap) => sum + (lap.movingTime || 0), 0) / laps.length : undefined,
|
|
170
|
+
averageLapDistance: laps.length > 0 ? laps.reduce((sum, lap) => sum + (lap.distance || 0), 0) / laps.length : undefined,
|
|
171
|
+
};
|
|
172
|
+
const result = {
|
|
173
|
+
...activity,
|
|
174
|
+
zones,
|
|
175
|
+
laps,
|
|
176
|
+
bestEfforts,
|
|
177
|
+
analysis,
|
|
178
|
+
};
|
|
179
|
+
if (options?.includeStreams) {
|
|
180
|
+
try {
|
|
181
|
+
const streams = await this.client.streams.getForActivity(id, {
|
|
182
|
+
types: options.streamTypes,
|
|
183
|
+
});
|
|
184
|
+
result.streams = streams;
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
// Streams may not be available for all activities
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return result;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
exports.ActivitiesResource = ActivitiesResource;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Athletes resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { ActivityStats, DetailedAthlete, DetailedGear, SummaryActivity } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resource for interacting with Strava athletes
|
|
8
|
+
*/
|
|
9
|
+
export declare class AthletesResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: StravaClient);
|
|
12
|
+
/**
|
|
13
|
+
* Get authenticated athlete
|
|
14
|
+
*/
|
|
15
|
+
get(): Promise<DetailedAthlete>;
|
|
16
|
+
/**
|
|
17
|
+
* Get athlete stats
|
|
18
|
+
*/
|
|
19
|
+
getStats(id: number): Promise<ActivityStats>;
|
|
20
|
+
/**
|
|
21
|
+
* Update authenticated athlete
|
|
22
|
+
*/
|
|
23
|
+
update(weight: number): Promise<DetailedAthlete>;
|
|
24
|
+
/**
|
|
25
|
+
* Get athlete stats with recent activities and gear
|
|
26
|
+
* Combines stats, recent activities, and gear information
|
|
27
|
+
*/
|
|
28
|
+
getStatsWithActivities(id: number, options?: {
|
|
29
|
+
recentActivitiesLimit?: number;
|
|
30
|
+
includeGear?: boolean;
|
|
31
|
+
}): Promise<DetailedAthlete & {
|
|
32
|
+
stats: ActivityStats;
|
|
33
|
+
recentActivities: SummaryActivity[];
|
|
34
|
+
gear?: DetailedGear[];
|
|
35
|
+
}>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=athletes.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Athletes resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AthletesResource = void 0;
|
|
7
|
+
const validators_js_1 = require("../utils/validators.js");
|
|
8
|
+
/**
|
|
9
|
+
* Resource for interacting with Strava athletes
|
|
10
|
+
*/
|
|
11
|
+
class AthletesResource {
|
|
12
|
+
constructor(client) {
|
|
13
|
+
Object.defineProperty(this, "client", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: client
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get authenticated athlete
|
|
22
|
+
*/
|
|
23
|
+
async get() {
|
|
24
|
+
return await this.client.request({
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: "/athlete",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Get athlete stats
|
|
31
|
+
*/
|
|
32
|
+
async getStats(id) {
|
|
33
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
34
|
+
return await this.client.request({
|
|
35
|
+
method: "GET",
|
|
36
|
+
path: `/athletes/${id}/stats`,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Update authenticated athlete
|
|
41
|
+
*/
|
|
42
|
+
async update(weight) {
|
|
43
|
+
return await this.client.request({
|
|
44
|
+
method: "PUT",
|
|
45
|
+
path: "/athlete",
|
|
46
|
+
query: { weight },
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get athlete stats with recent activities and gear
|
|
51
|
+
* Combines stats, recent activities, and gear information
|
|
52
|
+
*/
|
|
53
|
+
async getStatsWithActivities(id, options) {
|
|
54
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
55
|
+
const [athlete, stats, recentActivities] = await Promise.all([
|
|
56
|
+
this.get(),
|
|
57
|
+
this.getStats(id),
|
|
58
|
+
this.client.activities.list({
|
|
59
|
+
perPage: options?.recentActivitiesLimit || 10,
|
|
60
|
+
}),
|
|
61
|
+
]);
|
|
62
|
+
const result = {
|
|
63
|
+
...athlete,
|
|
64
|
+
stats,
|
|
65
|
+
recentActivities,
|
|
66
|
+
};
|
|
67
|
+
if (options?.includeGear !== false) {
|
|
68
|
+
const gearIds = [];
|
|
69
|
+
if (athlete.bikes) {
|
|
70
|
+
gearIds.push(...athlete.bikes.map((bike) => bike.id).filter((id) => id !== undefined));
|
|
71
|
+
}
|
|
72
|
+
if (athlete.shoes) {
|
|
73
|
+
gearIds.push(...athlete.shoes.map((shoe) => shoe.id).filter((id) => id !== undefined));
|
|
74
|
+
}
|
|
75
|
+
if (gearIds.length > 0) {
|
|
76
|
+
try {
|
|
77
|
+
const gearPromises = gearIds.map((id) => this.client.gears.getById(id).catch(() => null));
|
|
78
|
+
const gearResults = await Promise.all(gearPromises);
|
|
79
|
+
result.gear = gearResults.filter((g) => g !== null);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Gear may not be accessible
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.AthletesResource = AthletesResource;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clubs resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { ClubActivity, DetailedClub, SummaryAthlete, SummaryClub } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resource for interacting with Strava clubs
|
|
8
|
+
*/
|
|
9
|
+
export declare class ClubsResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: StravaClient);
|
|
12
|
+
/**
|
|
13
|
+
* Get club by ID
|
|
14
|
+
*/
|
|
15
|
+
getById(id: number): Promise<DetailedClub>;
|
|
16
|
+
/**
|
|
17
|
+
* List athlete clubs
|
|
18
|
+
*/
|
|
19
|
+
list(options?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
perPage?: number;
|
|
22
|
+
}): Promise<SummaryClub[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get club members
|
|
25
|
+
*/
|
|
26
|
+
getMembers(id: number, options?: {
|
|
27
|
+
page?: number;
|
|
28
|
+
perPage?: number;
|
|
29
|
+
}): Promise<SummaryAthlete[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Get club activities
|
|
32
|
+
*/
|
|
33
|
+
getActivities(id: number, options?: {
|
|
34
|
+
page?: number;
|
|
35
|
+
perPage?: number;
|
|
36
|
+
}): Promise<ClubActivity[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Get club admins
|
|
39
|
+
*/
|
|
40
|
+
getAdmins(id: number, options?: {
|
|
41
|
+
page?: number;
|
|
42
|
+
perPage?: number;
|
|
43
|
+
}): Promise<SummaryAthlete[]>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=clubs.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Clubs resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ClubsResource = void 0;
|
|
7
|
+
const validators_js_1 = require("../utils/validators.js");
|
|
8
|
+
const pagination_js_1 = require("../utils/pagination.js");
|
|
9
|
+
/**
|
|
10
|
+
* Resource for interacting with Strava clubs
|
|
11
|
+
*/
|
|
12
|
+
class ClubsResource {
|
|
13
|
+
constructor(client) {
|
|
14
|
+
Object.defineProperty(this, "client", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
configurable: true,
|
|
17
|
+
writable: true,
|
|
18
|
+
value: client
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get club by ID
|
|
23
|
+
*/
|
|
24
|
+
async getById(id) {
|
|
25
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
26
|
+
return await this.client.request({
|
|
27
|
+
method: "GET",
|
|
28
|
+
path: `/clubs/${id}`,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* List athlete clubs
|
|
33
|
+
*/
|
|
34
|
+
async list(options) {
|
|
35
|
+
return await this.client.request({
|
|
36
|
+
method: "GET",
|
|
37
|
+
path: "/athlete/clubs",
|
|
38
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get club members
|
|
43
|
+
*/
|
|
44
|
+
async getMembers(id, options) {
|
|
45
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
46
|
+
return await this.client.request({
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: `/clubs/${id}/members`,
|
|
49
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Get club activities
|
|
54
|
+
*/
|
|
55
|
+
async getActivities(id, options) {
|
|
56
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
57
|
+
return await this.client.request({
|
|
58
|
+
method: "GET",
|
|
59
|
+
path: `/clubs/${id}/activities`,
|
|
60
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get club admins
|
|
65
|
+
*/
|
|
66
|
+
async getAdmins(id, options) {
|
|
67
|
+
(0, validators_js_1.validatePositiveInteger)(id, "id");
|
|
68
|
+
return await this.client.request({
|
|
69
|
+
method: "GET",
|
|
70
|
+
path: `/clubs/${id}/admins`,
|
|
71
|
+
query: (0, pagination_js_1.buildPaginationQuery)(options),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ClubsResource = ClubsResource;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gears resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { DetailedGear } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resource for interacting with Strava gear
|
|
8
|
+
*/
|
|
9
|
+
export declare class GearsResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: StravaClient);
|
|
12
|
+
/**
|
|
13
|
+
* Get gear by ID
|
|
14
|
+
*/
|
|
15
|
+
getById(id: string): Promise<DetailedGear>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=gears.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Gears resource
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GearsResource = void 0;
|
|
7
|
+
const validators_js_1 = require("../utils/validators.js");
|
|
8
|
+
/**
|
|
9
|
+
* Resource for interacting with Strava gear
|
|
10
|
+
*/
|
|
11
|
+
class GearsResource {
|
|
12
|
+
constructor(client) {
|
|
13
|
+
Object.defineProperty(this, "client", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: client
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get gear by ID
|
|
22
|
+
*/
|
|
23
|
+
async getById(id) {
|
|
24
|
+
(0, validators_js_1.validateNonEmptyString)(id, "id");
|
|
25
|
+
return await this.client.request({
|
|
26
|
+
method: "GET",
|
|
27
|
+
path: `/gear/${id}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.GearsResource = GearsResource;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routes resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { Route } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resource for interacting with Strava routes
|
|
8
|
+
*/
|
|
9
|
+
export declare class RoutesResource {
|
|
10
|
+
private client;
|
|
11
|
+
constructor(client: StravaClient);
|
|
12
|
+
/**
|
|
13
|
+
* Get route by ID
|
|
14
|
+
*/
|
|
15
|
+
getById(id: number): Promise<Route>;
|
|
16
|
+
/**
|
|
17
|
+
* List athlete routes
|
|
18
|
+
*/
|
|
19
|
+
list(options?: {
|
|
20
|
+
page?: number;
|
|
21
|
+
perPage?: number;
|
|
22
|
+
}): Promise<Route[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Download route as GPX
|
|
25
|
+
*/
|
|
26
|
+
downloadAsGPX(id: number): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Download route as TCX
|
|
29
|
+
*/
|
|
30
|
+
downloadAsTCX(id: number): Promise<string>;
|
|
31
|
+
private getAccessToken;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=routes.d.ts.map
|