@dlwiest/ts-tonal-client 0.0.1 → 0.1.0
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 +404 -38
- package/dist/examples/create-workout.d.ts +1 -0
- package/dist/examples/debug-daily-lifts.d.ts +1 -0
- package/dist/examples/delete-workout.d.ts +1 -0
- package/dist/examples/edit-workout.d.ts +1 -0
- package/dist/examples/estimate-workout.d.ts +1 -0
- package/dist/examples/get-achievement-stats.d.ts +2 -0
- package/dist/examples/get-achievements.d.ts +2 -0
- package/dist/examples/get-activity-summaries.d.ts +2 -0
- package/dist/examples/get-current-streak.d.ts +1 -0
- package/dist/examples/get-daily-lifts.d.ts +1 -0
- package/dist/examples/get-daily-metrics.d.ts +1 -0
- package/dist/examples/get-goal-metrics.d.ts +1 -0
- package/dist/examples/get-goals.d.ts +1 -0
- package/dist/examples/get-home-calendar.d.ts +2 -0
- package/dist/examples/get-metric-scores.d.ts +1 -0
- package/dist/examples/get-movements.d.ts +1 -0
- package/dist/examples/get-muscle-readiness.d.ts +1 -0
- package/dist/examples/get-program-by-id.d.ts +1 -0
- package/dist/examples/get-target-scores.d.ts +1 -0
- package/dist/examples/get-training-effect-goals.d.ts +1 -0
- package/dist/examples/get-training-types.d.ts +1 -0
- package/dist/examples/get-user-info.d.ts +1 -0
- package/dist/examples/get-user-settings.d.ts +1 -0
- package/dist/examples/get-user-statistics.d.ts +2 -0
- package/dist/examples/get-user-workouts.d.ts +1 -0
- package/dist/examples/get-workout-by-id.d.ts +1 -0
- package/dist/examples/get-workout-by-share-url.d.ts +1 -0
- package/dist/examples/raw-daily-lifts-test.d.ts +1 -0
- package/dist/index.d.ts +573 -29
- package/dist/index.esm.js +447 -119
- package/dist/index.js +451 -119
- package/dist/src/auth/auth-manager.d.ts +12 -0
- package/dist/src/client.d.ts +39 -0
- package/dist/src/http/http-client.d.ts +12 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/services/movement-service.d.ts +7 -0
- package/dist/src/services/user-service.d.ts +51 -0
- package/dist/src/services/workout-service.d.ts +14 -0
- package/dist/src/types/auth.d.ts +18 -0
- package/dist/src/types/common.d.ts +1 -0
- package/dist/src/types/index.d.ts +6 -0
- package/dist/src/types/movements.d.ts +30 -0
- package/dist/src/types/programs.d.ts +46 -0
- package/dist/src/types/users.d.ts +418 -0
- package/dist/src/types/workouts.d.ts +120 -0
- package/dist/src/types.d.ts +125 -0
- package/package.json +43 -4
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { MuscleGroup } from './common';
|
|
2
|
+
export type WorkoutPublishState = 'published' | 'archived' | string;
|
|
3
|
+
export interface WorkoutSet {
|
|
4
|
+
id: string;
|
|
5
|
+
workoutId: string;
|
|
6
|
+
blockStart: boolean;
|
|
7
|
+
movementId: string;
|
|
8
|
+
prescribedReps: number;
|
|
9
|
+
repetition: number;
|
|
10
|
+
repetitionTotal: number;
|
|
11
|
+
blockNumber: number;
|
|
12
|
+
burnout: boolean;
|
|
13
|
+
spotter: boolean;
|
|
14
|
+
eccentric: boolean;
|
|
15
|
+
chains: boolean;
|
|
16
|
+
skipSetup: boolean;
|
|
17
|
+
skipDemo: boolean;
|
|
18
|
+
finalSet: boolean;
|
|
19
|
+
calibration: boolean;
|
|
20
|
+
practice: boolean;
|
|
21
|
+
flex: boolean;
|
|
22
|
+
progressive: boolean;
|
|
23
|
+
weightPercentage: number;
|
|
24
|
+
warmUp: boolean;
|
|
25
|
+
durationBasedRepGoal: number;
|
|
26
|
+
setGroup: number;
|
|
27
|
+
round: number;
|
|
28
|
+
description: string;
|
|
29
|
+
dropSet: boolean;
|
|
30
|
+
omitempty?: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface TonalWorkout {
|
|
33
|
+
id: string;
|
|
34
|
+
createdAt: string;
|
|
35
|
+
title: string;
|
|
36
|
+
shortDescription: string;
|
|
37
|
+
description: string;
|
|
38
|
+
productionCode: string;
|
|
39
|
+
assetId: string;
|
|
40
|
+
coachId: string;
|
|
41
|
+
sets: WorkoutSet[];
|
|
42
|
+
duration: number;
|
|
43
|
+
publishState: WorkoutPublishState;
|
|
44
|
+
programId: string | null;
|
|
45
|
+
level: string;
|
|
46
|
+
groupIds: string[];
|
|
47
|
+
targetArea: string;
|
|
48
|
+
tags: string[] | null;
|
|
49
|
+
bodyRegions: MuscleGroup[];
|
|
50
|
+
goalIds: string[] | null;
|
|
51
|
+
trainingEffectGoals: string[];
|
|
52
|
+
disableModification: boolean;
|
|
53
|
+
publishedAt: string;
|
|
54
|
+
localPublishedAt: string;
|
|
55
|
+
type: string;
|
|
56
|
+
userId: string;
|
|
57
|
+
style: string;
|
|
58
|
+
trainingType: string;
|
|
59
|
+
trainingTypeIds: string[] | null;
|
|
60
|
+
mobileFriendly: boolean;
|
|
61
|
+
live: boolean;
|
|
62
|
+
recoveryWeight: boolean;
|
|
63
|
+
supportedDevices: string[] | null;
|
|
64
|
+
featureGroupIds: string[] | null;
|
|
65
|
+
movementIds: string[];
|
|
66
|
+
accessories?: string[];
|
|
67
|
+
muscleGroupsForExclusion: MuscleGroup[] | null;
|
|
68
|
+
playbackType: string;
|
|
69
|
+
isImported: boolean;
|
|
70
|
+
createdSource?: unknown | null;
|
|
71
|
+
}
|
|
72
|
+
export interface TonalSharedWorkout {
|
|
73
|
+
id: string;
|
|
74
|
+
sharerUserId: string;
|
|
75
|
+
parentWorkoutId: string;
|
|
76
|
+
workoutSnapshotId: string;
|
|
77
|
+
workoutSnapshotHash: string;
|
|
78
|
+
deepLinkUrl: string;
|
|
79
|
+
workoutSnapshot: TonalWorkout;
|
|
80
|
+
}
|
|
81
|
+
export interface TonalWorkoutEstimateSet {
|
|
82
|
+
blockStart: boolean;
|
|
83
|
+
movementId: string;
|
|
84
|
+
prescribedReps?: number;
|
|
85
|
+
prescribedDuration?: number;
|
|
86
|
+
dropSet: boolean;
|
|
87
|
+
repetition: number;
|
|
88
|
+
repetitionTotal: number;
|
|
89
|
+
blockNumber: number;
|
|
90
|
+
burnout: boolean;
|
|
91
|
+
spotter: boolean;
|
|
92
|
+
eccentric: boolean;
|
|
93
|
+
chains: boolean;
|
|
94
|
+
flex: boolean;
|
|
95
|
+
warmUp: boolean;
|
|
96
|
+
weightPercentage: number;
|
|
97
|
+
setGroup: number;
|
|
98
|
+
round: number;
|
|
99
|
+
description: string;
|
|
100
|
+
}
|
|
101
|
+
export interface TonalWorkoutEstimateResponse {
|
|
102
|
+
duration: number;
|
|
103
|
+
}
|
|
104
|
+
export interface TonalWorkoutCreateRequest {
|
|
105
|
+
title: string;
|
|
106
|
+
sets: TonalWorkoutEstimateSet[];
|
|
107
|
+
createdSource?: 'WorkoutBuilder' | 'FreeLift' | 'SharedWorkout' | 'DailyLift' | 'TonalWorkout' | 'WorkoutGenerator' | 'ActivityFeed';
|
|
108
|
+
shortDescription?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface TonalWorkoutUpdateRequest {
|
|
112
|
+
id: string;
|
|
113
|
+
title: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
coachId: string;
|
|
116
|
+
sets: TonalWorkoutEstimateSet[];
|
|
117
|
+
level?: string;
|
|
118
|
+
assetId: string;
|
|
119
|
+
createdSource?: 'WorkoutBuilder' | 'FreeLift' | 'SharedWorkout' | 'DailyLift' | 'TonalWorkout' | 'WorkoutGenerator' | 'ActivityFeed';
|
|
120
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export interface TonalApiError {
|
|
2
|
+
error: string;
|
|
3
|
+
error_description?: string;
|
|
4
|
+
statusCode?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class TonalClientError extends Error {
|
|
7
|
+
readonly statusCode?: number;
|
|
8
|
+
readonly originalError?: unknown;
|
|
9
|
+
constructor(message: string, statusCode?: number, originalError?: unknown);
|
|
10
|
+
}
|
|
11
|
+
export interface OAuthTokenResponse {
|
|
12
|
+
access_token: string;
|
|
13
|
+
id_token: string;
|
|
14
|
+
refresh_token: string;
|
|
15
|
+
scope: string;
|
|
16
|
+
token_type: string;
|
|
17
|
+
expires_in: number;
|
|
18
|
+
}
|
|
19
|
+
export type MuscleGroup = 'Obliques' | 'Abs' | 'Shoulders' | 'Glutes' | 'Back' | 'Biceps' | 'Quads' | 'Triceps' | 'Chest' | 'Hamstrings' | 'Calves' | 'Forearms';
|
|
20
|
+
export interface TonalMovement {
|
|
21
|
+
id: string;
|
|
22
|
+
createdAt: string;
|
|
23
|
+
updatedAt: string;
|
|
24
|
+
name: string;
|
|
25
|
+
shortName: string;
|
|
26
|
+
muscleGroups: MuscleGroup[];
|
|
27
|
+
bodyRegion: string;
|
|
28
|
+
bodyRegionDisplay: string;
|
|
29
|
+
baseOfSupport: string;
|
|
30
|
+
pushPull: string;
|
|
31
|
+
family: string;
|
|
32
|
+
familyDisplay: string;
|
|
33
|
+
inFreeLift: boolean;
|
|
34
|
+
onMachine: boolean;
|
|
35
|
+
countReps: boolean;
|
|
36
|
+
isTwoSided: boolean;
|
|
37
|
+
isBilateral: boolean;
|
|
38
|
+
isAlternating: boolean;
|
|
39
|
+
offMachineAccessory: string;
|
|
40
|
+
descriptionHow: string;
|
|
41
|
+
descriptionWhy: string;
|
|
42
|
+
sortOrder: number;
|
|
43
|
+
imageAssetId: string;
|
|
44
|
+
skillLevel: number;
|
|
45
|
+
active: boolean;
|
|
46
|
+
featureGroupIds: null | string[];
|
|
47
|
+
isGeneric: boolean;
|
|
48
|
+
}
|
|
49
|
+
export interface TonalWorkout {
|
|
50
|
+
id: string;
|
|
51
|
+
createdAt: string;
|
|
52
|
+
title: string;
|
|
53
|
+
shortDescription: string;
|
|
54
|
+
description: string;
|
|
55
|
+
productionCode: string;
|
|
56
|
+
assetId: string;
|
|
57
|
+
coachId: string;
|
|
58
|
+
sets: WorkoutSet[];
|
|
59
|
+
duration: number;
|
|
60
|
+
publishState: string;
|
|
61
|
+
programId: string | null;
|
|
62
|
+
level: string;
|
|
63
|
+
groupIds: string[];
|
|
64
|
+
targetArea: string;
|
|
65
|
+
tags: string[] | null;
|
|
66
|
+
bodyRegions: MuscleGroup[];
|
|
67
|
+
goalIds: string[] | null;
|
|
68
|
+
trainingEffectGoals: string[];
|
|
69
|
+
disableModification: boolean;
|
|
70
|
+
publishedAt: string;
|
|
71
|
+
localPublishedAt: string;
|
|
72
|
+
type: string;
|
|
73
|
+
userId: string;
|
|
74
|
+
style: string;
|
|
75
|
+
trainingType: string;
|
|
76
|
+
trainingTypeIds: string[] | null;
|
|
77
|
+
mobileFriendly: boolean;
|
|
78
|
+
live: boolean;
|
|
79
|
+
recoveryWeight: boolean;
|
|
80
|
+
supportedDevices: string[] | null;
|
|
81
|
+
featureGroupIds: string[] | null;
|
|
82
|
+
movementIds: string[];
|
|
83
|
+
muscleGroupsForExclusion: MuscleGroup[] | null;
|
|
84
|
+
playbackType: string;
|
|
85
|
+
isImported: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface WorkoutSet {
|
|
88
|
+
id: string;
|
|
89
|
+
workoutId: string;
|
|
90
|
+
blockStart: boolean;
|
|
91
|
+
movementId: string;
|
|
92
|
+
prescribedReps: number;
|
|
93
|
+
repetition: number;
|
|
94
|
+
repetitionTotal: number;
|
|
95
|
+
blockNumber: number;
|
|
96
|
+
burnout: boolean;
|
|
97
|
+
spotter: boolean;
|
|
98
|
+
eccentric: boolean;
|
|
99
|
+
chains: boolean;
|
|
100
|
+
skipSetup: boolean;
|
|
101
|
+
skipDemo: boolean;
|
|
102
|
+
finalSet: boolean;
|
|
103
|
+
calibration: boolean;
|
|
104
|
+
practice: boolean;
|
|
105
|
+
flex: boolean;
|
|
106
|
+
progressive: boolean;
|
|
107
|
+
weightPercentage: number;
|
|
108
|
+
warmUp: boolean;
|
|
109
|
+
durationBasedRepGoal: number;
|
|
110
|
+
setGroup: number;
|
|
111
|
+
round: number;
|
|
112
|
+
description: string;
|
|
113
|
+
dropSet: boolean;
|
|
114
|
+
omitempty?: unknown;
|
|
115
|
+
}
|
|
116
|
+
export interface TonalSharedWorkout {
|
|
117
|
+
id: string;
|
|
118
|
+
sharerUserId: string;
|
|
119
|
+
parentWorkoutId: string;
|
|
120
|
+
workoutSnapshotId: string;
|
|
121
|
+
workoutSnapshotHash: string;
|
|
122
|
+
deepLinkUrl: string;
|
|
123
|
+
workoutSnapshot: TonalWorkout;
|
|
124
|
+
}
|
|
125
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,23 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dlwiest/ts-tonal-client",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "TypeScript client for Tonal API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.esm.js",
|
|
13
|
+
"require": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
9
16
|
"files": [
|
|
10
17
|
"dist"
|
|
11
18
|
],
|
|
12
19
|
"scripts": {
|
|
13
|
-
"build": "rollup -c --bundleConfigAsCjs"
|
|
20
|
+
"build": "rollup -c --bundleConfigAsCjs",
|
|
21
|
+
"typecheck": "tsc --noEmit",
|
|
22
|
+
"dev": "tsc --watch --noEmit",
|
|
23
|
+
"prepublishOnly": "npm run typecheck && npm run build",
|
|
24
|
+
"example:movements": "tsx examples/get-movements.ts",
|
|
25
|
+
"example:movements:save": "tsx examples/get-movements.ts --save",
|
|
26
|
+
"example:workout:id": "tsx examples/get-workout-by-id.ts",
|
|
27
|
+
"example:workout:share": "tsx examples/get-workout-by-share-url.ts",
|
|
28
|
+
"example:user": "tsx examples/get-user-info.ts",
|
|
29
|
+
"example:goals": "tsx examples/get-goals.ts",
|
|
30
|
+
"example:user-workouts": "tsx examples/get-user-workouts.ts",
|
|
31
|
+
"example:estimate": "tsx examples/estimate-workout.ts",
|
|
32
|
+
"example:create-workout": "tsx examples/create-workout.ts",
|
|
33
|
+
"example:edit-workout": "tsx examples/edit-workout.ts",
|
|
34
|
+
"example:delete-workout": "tsx examples/delete-workout.ts",
|
|
35
|
+
"example:daily-lifts": "tsx examples/get-daily-lifts.ts",
|
|
36
|
+
"example:training-effect-goals": "tsx examples/get-training-effect-goals.ts",
|
|
37
|
+
"example:training-types": "tsx examples/get-training-types.ts",
|
|
38
|
+
"example:goal-metrics": "tsx examples/get-goal-metrics.ts",
|
|
39
|
+
"example:user-settings": "tsx examples/get-user-settings.ts",
|
|
40
|
+
"example:daily-metrics": "tsx examples/get-daily-metrics.ts",
|
|
41
|
+
"example:current-streak": "tsx examples/get-current-streak.ts",
|
|
42
|
+
"example:activity-summaries": "tsx examples/get-activity-summaries.ts",
|
|
43
|
+
"example:user-statistics": "tsx examples/get-user-statistics.ts",
|
|
44
|
+
"example:achievement-stats": "tsx examples/get-achievement-stats.ts",
|
|
45
|
+
"example:achievements": "tsx examples/get-achievements.ts",
|
|
46
|
+
"example:home-calendar": "tsx examples/get-home-calendar.ts",
|
|
47
|
+
"example:muscle-readiness": "tsx examples/get-muscle-readiness.ts",
|
|
48
|
+
"example:program-by-id": "tsx examples/get-program-by-id.ts",
|
|
49
|
+
"example:target-scores": "tsx examples/get-target-scores.ts",
|
|
50
|
+
"example:metric-scores": "tsx examples/get-metric-scores.ts"
|
|
14
51
|
},
|
|
15
52
|
"repository": {
|
|
16
53
|
"type": "git",
|
|
17
54
|
"url": "git+https://github.com/dlwiest/ts-tonal-client.git"
|
|
18
55
|
},
|
|
19
|
-
"keywords": [],
|
|
20
|
-
"author": "",
|
|
56
|
+
"keywords": ["tonal", "tonal-api", "typescript", "client"],
|
|
57
|
+
"author": "dlwiest",
|
|
21
58
|
"license": "ISC",
|
|
22
59
|
"bugs": {
|
|
23
60
|
"url": "https://github.com/dlwiest/ts-tonal-client/issues"
|
|
@@ -26,10 +63,12 @@
|
|
|
26
63
|
"devDependencies": {
|
|
27
64
|
"@rollup/plugin-typescript": "^11.1.0",
|
|
28
65
|
"@types/node": "^20.14.8",
|
|
66
|
+
"dotenv": "^16.4.5",
|
|
29
67
|
"rollup": "^3.20.2",
|
|
30
68
|
"rollup-plugin-dts": "^5.3.1",
|
|
31
69
|
"ts-node": "^10.9.2",
|
|
32
70
|
"tslib": "^2.7.0",
|
|
71
|
+
"tsx": "^4.20.6",
|
|
33
72
|
"typescript": "^5.5.4"
|
|
34
73
|
}
|
|
35
74
|
}
|