@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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segments resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { DetailedSegment, ExplorerResponse } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Options for exploring segments
|
|
8
|
+
*/
|
|
9
|
+
export interface ExploreSegmentsOptions {
|
|
10
|
+
/** Bounding box as [south, west, north, east] */
|
|
11
|
+
bounds: [number, number, number, number];
|
|
12
|
+
/** Activity type filter */
|
|
13
|
+
activityType?: "running" | "riding";
|
|
14
|
+
/** Minimum category */
|
|
15
|
+
minCat?: number;
|
|
16
|
+
/** Maximum category */
|
|
17
|
+
maxCat?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resource for interacting with Strava segments
|
|
21
|
+
*/
|
|
22
|
+
export declare class SegmentsResource {
|
|
23
|
+
private client;
|
|
24
|
+
constructor(client: StravaClient);
|
|
25
|
+
/**
|
|
26
|
+
* Get segment by ID
|
|
27
|
+
*/
|
|
28
|
+
getById(id: number): Promise<DetailedSegment>;
|
|
29
|
+
/**
|
|
30
|
+
* Explore segments
|
|
31
|
+
*/
|
|
32
|
+
explore(options: ExploreSegmentsOptions): Promise<ExplorerResponse>;
|
|
33
|
+
/**
|
|
34
|
+
* Star segment
|
|
35
|
+
*/
|
|
36
|
+
star(id: number, starred?: boolean): Promise<DetailedSegment>;
|
|
37
|
+
/**
|
|
38
|
+
* Unstar segment
|
|
39
|
+
*/
|
|
40
|
+
unstar(id: number): Promise<DetailedSegment>;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=segments.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Segments resource
|
|
3
|
+
*/
|
|
4
|
+
import { validatePositiveInteger } from "../utils/validators.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resource for interacting with Strava segments
|
|
7
|
+
*/
|
|
8
|
+
export class SegmentsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
Object.defineProperty(this, "client", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: client
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get segment by ID
|
|
19
|
+
*/
|
|
20
|
+
async getById(id) {
|
|
21
|
+
validatePositiveInteger(id, "id");
|
|
22
|
+
return await this.client.request({
|
|
23
|
+
method: "GET",
|
|
24
|
+
path: `/segments/${id}`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Explore segments
|
|
29
|
+
*/
|
|
30
|
+
async explore(options) {
|
|
31
|
+
const [south, west, north, east] = options.bounds;
|
|
32
|
+
const query = {
|
|
33
|
+
bounds: `${south},${west},${north},${east}`,
|
|
34
|
+
};
|
|
35
|
+
if (options.activityType) {
|
|
36
|
+
query.activity_type = options.activityType;
|
|
37
|
+
}
|
|
38
|
+
if (options.minCat !== undefined) {
|
|
39
|
+
query.min_cat = options.minCat;
|
|
40
|
+
}
|
|
41
|
+
if (options.maxCat !== undefined) {
|
|
42
|
+
query.max_cat = options.maxCat;
|
|
43
|
+
}
|
|
44
|
+
return await this.client.request({
|
|
45
|
+
method: "GET",
|
|
46
|
+
path: "/segments/explore",
|
|
47
|
+
query,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Star segment
|
|
52
|
+
*/
|
|
53
|
+
async star(id, starred = true) {
|
|
54
|
+
validatePositiveInteger(id, "id");
|
|
55
|
+
return await this.client.request({
|
|
56
|
+
method: "PUT",
|
|
57
|
+
path: `/segments/${id}/starred`,
|
|
58
|
+
query: { starred: starred ? "true" : "false" },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Unstar segment
|
|
63
|
+
*/
|
|
64
|
+
async unstar(id) {
|
|
65
|
+
return await this.star(id, false);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streams resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { StreamSet } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Available stream types
|
|
8
|
+
*/
|
|
9
|
+
export type StreamType = "time" | "distance" | "latlng" | "altitude" | "velocity_smooth" | "heartrate" | "cadence" | "watts" | "temp" | "moving" | "grade_smooth";
|
|
10
|
+
/**
|
|
11
|
+
* Options for getting streams
|
|
12
|
+
*/
|
|
13
|
+
export interface GetStreamsOptions {
|
|
14
|
+
/** Stream types to retrieve */
|
|
15
|
+
types?: StreamType[];
|
|
16
|
+
/** Whether to key streams by type */
|
|
17
|
+
keyByType?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Resource for interacting with Strava streams
|
|
21
|
+
*/
|
|
22
|
+
export declare class StreamsResource {
|
|
23
|
+
private client;
|
|
24
|
+
constructor(client: StravaClient);
|
|
25
|
+
/**
|
|
26
|
+
* Get activity streams
|
|
27
|
+
*/
|
|
28
|
+
getForActivity(id: number, options?: GetStreamsOptions): Promise<StreamSet>;
|
|
29
|
+
/**
|
|
30
|
+
* Get segment effort streams
|
|
31
|
+
*/
|
|
32
|
+
getForSegmentEffort(id: number, options?: GetStreamsOptions): Promise<StreamSet>;
|
|
33
|
+
/**
|
|
34
|
+
* Get segment streams
|
|
35
|
+
*/
|
|
36
|
+
getForSegment(id: number, options?: Omit<GetStreamsOptions, "types"> & {
|
|
37
|
+
types?: Array<"distance" | "latlng" | "altitude">;
|
|
38
|
+
}): Promise<StreamSet>;
|
|
39
|
+
/**
|
|
40
|
+
* Get route streams
|
|
41
|
+
*/
|
|
42
|
+
getForRoute(id: number): Promise<StreamSet>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=streams.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streams resource
|
|
3
|
+
*/
|
|
4
|
+
import { validatePositiveInteger } from "../utils/validators.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resource for interacting with Strava streams
|
|
7
|
+
*/
|
|
8
|
+
export class StreamsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
Object.defineProperty(this, "client", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: client
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get activity streams
|
|
19
|
+
*/
|
|
20
|
+
async getForActivity(id, options) {
|
|
21
|
+
validatePositiveInteger(id, "id");
|
|
22
|
+
const types = options?.types || ["time", "distance", "latlng", "altitude", "heartrate"];
|
|
23
|
+
const query = {
|
|
24
|
+
keys: types.join(","),
|
|
25
|
+
key_by_type: options?.keyByType ?? true,
|
|
26
|
+
};
|
|
27
|
+
return await this.client.request({
|
|
28
|
+
method: "GET",
|
|
29
|
+
path: `/activities/${id}/streams`,
|
|
30
|
+
query,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get segment effort streams
|
|
35
|
+
*/
|
|
36
|
+
async getForSegmentEffort(id, options) {
|
|
37
|
+
validatePositiveInteger(id, "id");
|
|
38
|
+
const types = options?.types || ["time", "distance", "latlng", "altitude", "heartrate"];
|
|
39
|
+
const query = {
|
|
40
|
+
keys: types.join(","),
|
|
41
|
+
key_by_type: options?.keyByType ?? true,
|
|
42
|
+
};
|
|
43
|
+
return await this.client.request({
|
|
44
|
+
method: "GET",
|
|
45
|
+
path: `/segment_efforts/${id}/streams`,
|
|
46
|
+
query,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get segment streams
|
|
51
|
+
*/
|
|
52
|
+
async getForSegment(id, options) {
|
|
53
|
+
validatePositiveInteger(id, "id");
|
|
54
|
+
const types = options?.types || ["distance", "latlng", "altitude"];
|
|
55
|
+
const query = {
|
|
56
|
+
keys: types.join(","),
|
|
57
|
+
key_by_type: options?.keyByType ?? true,
|
|
58
|
+
};
|
|
59
|
+
return await this.client.request({
|
|
60
|
+
method: "GET",
|
|
61
|
+
path: `/segments/${id}/streams`,
|
|
62
|
+
query,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Get route streams
|
|
67
|
+
*/
|
|
68
|
+
async getForRoute(id) {
|
|
69
|
+
validatePositiveInteger(id, "id");
|
|
70
|
+
return await this.client.request({
|
|
71
|
+
method: "GET",
|
|
72
|
+
path: `/routes/${id}/streams`,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads resource
|
|
3
|
+
*/
|
|
4
|
+
import type { StravaClient } from "../client.js";
|
|
5
|
+
import type { Upload } from "../types/api.js";
|
|
6
|
+
/**
|
|
7
|
+
* Options for creating an upload
|
|
8
|
+
*/
|
|
9
|
+
export interface CreateUploadOptions {
|
|
10
|
+
/** Activity file (FIT, TCX, or GPX format) */
|
|
11
|
+
file: File | Blob | Uint8Array;
|
|
12
|
+
/** Activity name */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Activity description */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** Whether activity was done on trainer */
|
|
17
|
+
trainer?: boolean;
|
|
18
|
+
/** Whether activity is a commute */
|
|
19
|
+
commute?: boolean;
|
|
20
|
+
/** File data type */
|
|
21
|
+
dataType?: "fit" | "fit.gz" | "tcx" | "tcx.gz" | "gpx" | "gpx.gz";
|
|
22
|
+
/** External ID for the activity */
|
|
23
|
+
externalId?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Resource for uploading activities to Strava
|
|
27
|
+
*/
|
|
28
|
+
export declare class UploadsResource {
|
|
29
|
+
private client;
|
|
30
|
+
constructor(client: StravaClient);
|
|
31
|
+
/**
|
|
32
|
+
* Create upload
|
|
33
|
+
*/
|
|
34
|
+
create(options: CreateUploadOptions): Promise<Upload>;
|
|
35
|
+
/**
|
|
36
|
+
* Get upload by ID
|
|
37
|
+
*/
|
|
38
|
+
getById(id: number): Promise<Upload>;
|
|
39
|
+
private getAccessToken;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=uploads.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Uploads resource
|
|
3
|
+
*/
|
|
4
|
+
import { validatePositiveInteger } from "../utils/validators.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resource for uploading activities to Strava
|
|
7
|
+
*/
|
|
8
|
+
export class UploadsResource {
|
|
9
|
+
constructor(client) {
|
|
10
|
+
Object.defineProperty(this, "client", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: client
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create upload
|
|
19
|
+
*/
|
|
20
|
+
async create(options) {
|
|
21
|
+
const formData = new FormData();
|
|
22
|
+
if (options.file instanceof File) {
|
|
23
|
+
formData.append("file", options.file);
|
|
24
|
+
}
|
|
25
|
+
else if (options.file instanceof Blob) {
|
|
26
|
+
formData.append("file", options.file, "activity.fit");
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// Uint8Array
|
|
30
|
+
const blob = new Blob([options.file], { type: "application/octet-stream" });
|
|
31
|
+
formData.append("file", blob, "activity.fit");
|
|
32
|
+
}
|
|
33
|
+
if (options.name) {
|
|
34
|
+
formData.append("name", options.name);
|
|
35
|
+
}
|
|
36
|
+
if (options.description) {
|
|
37
|
+
formData.append("description", options.description);
|
|
38
|
+
}
|
|
39
|
+
if (options.trainer !== undefined) {
|
|
40
|
+
formData.append("trainer", options.trainer ? "1" : "0");
|
|
41
|
+
}
|
|
42
|
+
if (options.commute !== undefined) {
|
|
43
|
+
formData.append("commute", options.commute ? "1" : "0");
|
|
44
|
+
}
|
|
45
|
+
if (options.dataType) {
|
|
46
|
+
formData.append("data_type", options.dataType);
|
|
47
|
+
}
|
|
48
|
+
if (options.externalId) {
|
|
49
|
+
formData.append("external_id", options.externalId);
|
|
50
|
+
}
|
|
51
|
+
// Use direct fetch for multipart/form-data
|
|
52
|
+
const token = await this.getAccessToken();
|
|
53
|
+
const response = await fetch("https://www.strava.com/api/v3/uploads", {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"Authorization": `Bearer ${token}`,
|
|
57
|
+
},
|
|
58
|
+
body: formData,
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
const error = await response.json().catch(() => ({ message: response.statusText }));
|
|
62
|
+
throw new Error(`Upload failed: ${error.message || response.statusText}`);
|
|
63
|
+
}
|
|
64
|
+
return await response.json();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Get upload by ID
|
|
68
|
+
*/
|
|
69
|
+
async getById(id) {
|
|
70
|
+
validatePositiveInteger(id, "id");
|
|
71
|
+
return await this.client.request({
|
|
72
|
+
method: "GET",
|
|
73
|
+
path: `/uploads/${id}`,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
async getAccessToken() {
|
|
77
|
+
return await this.client.getAccessToken();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API types - Re-exports and type aliases for generated types
|
|
3
|
+
*
|
|
4
|
+
* This file provides convenient access to all generated types from the Swagger specification.
|
|
5
|
+
* Types are automatically generated from https://developers.strava.com/swagger/swagger.json
|
|
6
|
+
*/
|
|
7
|
+
export * from "./generated.js";
|
|
8
|
+
export type { ActivityStats, ActivityTotal, ActivityType, ActivityZone, ClubActivity, ClubAnnouncement, ClubAthlete, Comment, DetailedActivity, DetailedActivity as Activity, DetailedAthlete as Athlete, DetailedClub as Club, DetailedGear as Gear, DetailedSegment as Segment, DetailedSegmentEffort as SegmentEffort, ExplorerResponse, ExplorerSegment, Fault, HeartRateZoneRanges, Lap, LatLng, MetaActivity, MetaAthlete, MetaClub, PhotosSummary, PolylineMap, PowerZoneRanges, Route, Split, SportType, StreamSet, StreamType, SummaryActivity, SummaryAthlete, SummaryClub, SummaryGear, SummaryPRSegmentEffort, SummarySegment, SummarySegmentEffort, UpdatableActivity, Upload, Waypoint, ZoneRange, ZoneRanges, Zones, } from "./generated.js";
|
|
9
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API types - Re-exports and type aliases for generated types
|
|
3
|
+
*
|
|
4
|
+
* This file provides convenient access to all generated types from the Swagger specification.
|
|
5
|
+
* Types are automatically generated from https://developers.strava.com/swagger/swagger.json
|
|
6
|
+
*/
|
|
7
|
+
export * from "./generated.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common types and interfaces for the Strava client
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Retry configuration for failed requests
|
|
6
|
+
*/
|
|
7
|
+
export interface RetryConfig {
|
|
8
|
+
/** Maximum number of retry attempts (default: 3) */
|
|
9
|
+
maxAttempts?: number;
|
|
10
|
+
/** Initial delay in milliseconds (default: 1000) */
|
|
11
|
+
initialDelay?: number;
|
|
12
|
+
/** Maximum delay in milliseconds (default: 10000) */
|
|
13
|
+
maxDelay?: number;
|
|
14
|
+
/** Exponential backoff factor (default: 2) */
|
|
15
|
+
backoffFactor?: number;
|
|
16
|
+
/** HTTP status codes that should trigger retry (default: [429, 500, 502, 503, 504]) */
|
|
17
|
+
retryableStatusCodes?: number[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Rate limit strategy for handling rate limit errors
|
|
21
|
+
* - "queue": Queue requests and process when rate limit resets
|
|
22
|
+
* - "throw": Immediately throw error when rate limit is hit
|
|
23
|
+
* - "wait": Wait until rate limit resets before making request
|
|
24
|
+
*/
|
|
25
|
+
export type RateLimitStrategy = "queue" | "throw" | "wait";
|
|
26
|
+
/**
|
|
27
|
+
* HTTP request configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface RequestConfig {
|
|
30
|
+
/** HTTP method */
|
|
31
|
+
method: string;
|
|
32
|
+
/** API path (without base URL) */
|
|
33
|
+
path: string;
|
|
34
|
+
/** Query parameters */
|
|
35
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
36
|
+
/** Request headers */
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
/** Request body */
|
|
39
|
+
body?: unknown;
|
|
40
|
+
/** Request timeout in milliseconds */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pagination options for list endpoints
|
|
45
|
+
*/
|
|
46
|
+
export interface PaginationOptions {
|
|
47
|
+
/** Page number (default: 1) */
|
|
48
|
+
page?: number;
|
|
49
|
+
/** Number of items per page (default: 30, max: 200) */
|
|
50
|
+
perPage?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Rate limit information from response headers
|
|
54
|
+
*/
|
|
55
|
+
export interface RateLimitInfo {
|
|
56
|
+
/** Short-term rate limit (15-minute window) */
|
|
57
|
+
shortTermLimit?: number;
|
|
58
|
+
/** Short-term usage count */
|
|
59
|
+
shortTermUsage?: number;
|
|
60
|
+
/** Daily rate limit */
|
|
61
|
+
dailyLimit?: number;
|
|
62
|
+
/** Daily usage count */
|
|
63
|
+
dailyUsage?: number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=common.d.ts.map
|