hevy-shared 1.0.962 → 1.0.963
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 +17 -2
- package/built/API/APIClient.d.ts +157 -0
- package/built/API/APIClient.js +381 -0
- package/built/API/index.d.ts +2 -0
- package/built/API/index.js +18 -0
- package/built/API/types.d.ts +38 -0
- package/built/API/types.js +18 -0
- package/built/adjustEventTokens.d.ts +16 -0
- package/built/adjustEventTokens.js +18 -0
- package/built/adminPermissions.d.ts +4 -0
- package/built/adminPermissions.js +22 -0
- package/built/async.d.ts +50 -0
- package/built/async.js +170 -0
- package/built/chat.d.ts +25 -23
- package/built/coachPlans.d.ts +2 -1
- package/built/coachPlans.js +2 -2
- package/built/cue.d.ts +12 -0
- package/built/cue.js +22 -0
- package/built/exerciseLocaleUtils.d.ts +17 -0
- package/built/exerciseLocaleUtils.js +62 -0
- package/built/filterExercises.d.ts +19 -3
- package/built/filterExercises.js +72 -60
- package/built/hevyTrainer.d.ts +250 -0
- package/built/hevyTrainer.js +676 -0
- package/built/index.d.ts +1140 -304
- package/built/index.js +269 -75
- package/built/muscleHeatmaps.d.ts +31 -0
- package/built/muscleHeatmaps.js +68 -0
- package/built/muscleSplits.d.ts +36 -0
- package/built/muscleSplits.js +100 -0
- package/built/normalizedWorkoutUtils.d.ts +88 -0
- package/built/normalizedWorkoutUtils.js +112 -0
- package/built/notifications.d.ts +215 -0
- package/built/notifications.js +9 -0
- package/built/routineUtils.d.ts +14 -0
- package/built/routineUtils.js +186 -0
- package/built/schemas.d.ts +14 -0
- package/built/schemas.js +9 -0
- package/built/setIndicatorUtils.d.ts +4 -3
- package/built/setIndicatorUtils.js +15 -1
- package/built/tests/async.test.d.ts +1 -0
- package/built/tests/async.test.js +49 -0
- package/built/tests/hevyTrainer.test.d.ts +1 -0
- package/built/tests/hevyTrainer.test.js +1199 -0
- package/built/tests/muscleSplit.test.d.ts +1 -0
- package/built/tests/muscleSplit.test.js +153 -0
- package/built/tests/routineUtils.test.d.ts +1 -0
- package/built/tests/routineUtils.test.js +745 -0
- package/built/tests/testUtils.d.ts +85 -0
- package/built/tests/testUtils.js +319 -0
- package/built/tests/utils.test.js +748 -0
- package/built/tests/workoutVolume.test.js +165 -49
- package/built/translations/index.d.ts +2 -0
- package/built/translations/index.js +18 -0
- package/built/translations/translationUtils.d.ts +2 -0
- package/built/translations/translationUtils.js +61 -0
- package/built/translations/types.d.ts +8 -0
- package/built/translations/types.js +20 -0
- package/built/typeUtils.d.ts +70 -0
- package/built/typeUtils.js +55 -0
- package/built/units.d.ts +14 -7
- package/built/units.js +24 -14
- package/built/utils.d.ts +192 -5
- package/built/utils.js +598 -85
- package/built/websocket.d.ts +14 -2
- package/built/workoutVolume.d.ts +24 -5
- package/built/workoutVolume.js +25 -34
- package/package.json +32 -10
- package/.eslintignore +0 -2
- package/.eslintrc +0 -21
- package/.github/workflows/ci.yml +0 -15
- package/.github/workflows/npm-publish.yml +0 -59
- package/.github/workflows/pr-auto-assign.yml +0 -15
- package/.prettierrc.js +0 -5
- package/jest.config.js +0 -4
- package/src/chat.ts +0 -130
- package/src/coachPlans.ts +0 -57
- package/src/constants.ts +0 -14
- package/src/filterExercises.ts +0 -222
- package/src/index.ts +0 -1576
- package/src/setIndicatorUtils.ts +0 -137
- package/src/tests/utils.test.ts +0 -156
- package/src/tests/workoutVolume.test.ts +0 -93
- package/src/units.ts +0 -41
- package/src/utils.ts +0 -516
- package/src/websocket.ts +0 -36
- package/src/workoutVolume.ts +0 -175
- package/tsconfig.json +0 -70
package/built/websocket.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Program, BaseRoutine } from '.';
|
|
1
2
|
import { NewMessageChatUpdate, MessageDeletedChatUpdate, NewConversationChatUpdate } from './chat';
|
|
2
3
|
export interface PingChatUpdate {
|
|
3
4
|
type: 'websocket-ping';
|
|
@@ -5,14 +6,25 @@ export interface PingChatUpdate {
|
|
|
5
6
|
export interface PongChatUpdate {
|
|
6
7
|
type: 'websocket-pong';
|
|
7
8
|
}
|
|
8
|
-
export interface
|
|
9
|
+
export interface CoachClientsUpdated {
|
|
9
10
|
type: 'coaches-clients-updated';
|
|
10
11
|
new_client_ids: string[];
|
|
11
12
|
removed_client_ids: string[];
|
|
12
13
|
}
|
|
14
|
+
export interface CoachProgramUpdated {
|
|
15
|
+
type: 'coaches-program-updated';
|
|
16
|
+
updated_program: Program;
|
|
17
|
+
}
|
|
18
|
+
export interface CoachRoutineUpdated {
|
|
19
|
+
type: 'coaches-routine-updated';
|
|
20
|
+
updated_routine: BaseRoutine;
|
|
21
|
+
}
|
|
22
|
+
export interface CoachExerciseLibraryUpdated {
|
|
23
|
+
type: 'coaches-exercise-library-updated';
|
|
24
|
+
}
|
|
13
25
|
export interface WebsocketMessageRequest {
|
|
14
26
|
message: HevyWebsocketMessage;
|
|
15
27
|
recipient_user_ids: string[];
|
|
16
28
|
}
|
|
17
|
-
export type HevyWebsocketMessage = NewMessageChatUpdate | MessageDeletedChatUpdate | NewConversationChatUpdate | PingChatUpdate | PongChatUpdate |
|
|
29
|
+
export type HevyWebsocketMessage = NewMessageChatUpdate | MessageDeletedChatUpdate | NewConversationChatUpdate | PingChatUpdate | PongChatUpdate | CoachClientsUpdated | CoachProgramUpdated | CoachRoutineUpdated | CoachExerciseLibraryUpdated;
|
|
18
30
|
export declare const isHevyWebsocketMessage: (message?: any) => message is HevyWebsocketMessage;
|
package/built/workoutVolume.d.ts
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import { BodyMeasurement, ExerciseType,
|
|
2
|
-
export declare const
|
|
1
|
+
import { BodyMeasurement, ExerciseType, BaseExerciseTemplate, WorkoutExerciseSet } from '.';
|
|
2
|
+
export declare const isVolumeDoublingSupportableForExerciseTemplate: (exerciseTemplate: Pick<BaseExerciseTemplate, "equipment_category" | "exercise_type">) => boolean;
|
|
3
|
+
export interface VolumeCalculableWorkout {
|
|
4
|
+
exercises: {
|
|
5
|
+
exercise_type: ExerciseType;
|
|
6
|
+
exercise_template_id: string;
|
|
7
|
+
volume_doubling_enabled: boolean;
|
|
8
|
+
hundred_percent_bodyweight_exercise: boolean;
|
|
9
|
+
sets: Pick<WorkoutExerciseSet, 'indicator' | 'weight_kg' | 'reps' | 'distance_meters' | 'duration_seconds'>[];
|
|
10
|
+
}[];
|
|
11
|
+
include_warmup_sets: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface TimestampedVolumeCalculableWorkout extends VolumeCalculableWorkout {
|
|
14
|
+
start_time: number;
|
|
15
|
+
}
|
|
3
16
|
interface WorkoutVolumeKgProps {
|
|
4
|
-
workout:
|
|
5
|
-
measurements: BodyMeasurement[];
|
|
17
|
+
workout: TimestampedVolumeCalculableWorkout;
|
|
18
|
+
measurements: Pick<BodyMeasurement, 'date' | 'weight_kg'>[];
|
|
6
19
|
}
|
|
7
20
|
export type BodyWeightMeasurement = BodyMeasurement & Required<Pick<BodyMeasurement, 'weight_kg'>>;
|
|
8
21
|
export declare const workoutVolumeKg: ({ workout, measurements, }: WorkoutVolumeKgProps) => number;
|
|
22
|
+
interface EstimatedWorkoutVolumeKgProps {
|
|
23
|
+
workout: VolumeCalculableWorkout;
|
|
24
|
+
bodyweightKg: number;
|
|
25
|
+
}
|
|
26
|
+
export declare const estimatedWorkoutVolumeKg: ({ workout, bodyweightKg, }: EstimatedWorkoutVolumeKgProps) => number;
|
|
9
27
|
/**
|
|
10
28
|
* Given a date, this will return the nearest bodyweight value
|
|
11
29
|
* that was logged before it.
|
|
@@ -15,13 +33,14 @@ export interface WorkoutVolumeSetsVolumeKgProps {
|
|
|
15
33
|
bodyweightKg: number;
|
|
16
34
|
sets: WorkoutVolumeSet[];
|
|
17
35
|
}
|
|
18
|
-
export declare const workoutVolumeSetsVolumeKg: ({ bodyweightKg, sets, }: WorkoutVolumeSetsVolumeKgProps) => number;
|
|
19
36
|
export interface WorkoutVolumeSet {
|
|
20
37
|
type: ExerciseType;
|
|
21
38
|
exerciseTemplateId: string;
|
|
22
39
|
weightKg: number;
|
|
23
40
|
reps: number;
|
|
24
41
|
distanceMeters: number;
|
|
42
|
+
volumeDoublingEnabled?: boolean;
|
|
43
|
+
hundredPercentBodyweightExercise: boolean;
|
|
25
44
|
}
|
|
26
45
|
export declare const setVolumeKg: (set: WorkoutVolumeSet, bodyweightKg: number) => number;
|
|
27
46
|
export {};
|
package/built/workoutVolume.js
CHANGED
|
@@ -1,35 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setVolumeKg = exports.
|
|
3
|
+
exports.setVolumeKg = exports.getClosestRelevantBodyWeightKgForDate = exports.estimatedWorkoutVolumeKg = exports.workoutVolumeKg = exports.isVolumeDoublingSupportableForExerciseTemplate = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const _1 = require(".");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
'
|
|
9
|
-
'729237D1',
|
|
10
|
-
'2C37EC5E',
|
|
11
|
-
'56808FD2',
|
|
12
|
-
'A91838C0',
|
|
13
|
-
'EE2938D1',
|
|
14
|
-
'7C50F118',
|
|
15
|
-
'C7AE420A',
|
|
16
|
-
'29083183',
|
|
17
|
-
'023943F1',
|
|
18
|
-
'D23C609B',
|
|
19
|
-
'28BB4A95',
|
|
20
|
-
'10347BAC',
|
|
21
|
-
'4B4BF8C2',
|
|
22
|
-
'6FCD7755',
|
|
23
|
-
'29472BE1',
|
|
24
|
-
'E9E4089F',
|
|
25
|
-
'51A0EDAA',
|
|
26
|
-
'9F9C164B',
|
|
27
|
-
'30F03BF0',
|
|
28
|
-
'90B04F96', // Handstand Push Up
|
|
29
|
-
]);
|
|
30
|
-
return exerciseTemplateIds.has(exerciseTemplateId);
|
|
6
|
+
const isVolumeDoublingSupportableForExerciseTemplate = (exerciseTemplate) => {
|
|
7
|
+
return (exerciseTemplate.equipment_category === 'dumbbell' &&
|
|
8
|
+
exerciseTemplate.exercise_type === 'weight_reps');
|
|
31
9
|
};
|
|
32
|
-
exports.
|
|
10
|
+
exports.isVolumeDoublingSupportableForExerciseTemplate = isVolumeDoublingSupportableForExerciseTemplate;
|
|
33
11
|
const workoutVolumeKg = ({ workout, measurements, }) => {
|
|
34
12
|
var _a, _b;
|
|
35
13
|
const workoutDate = new Date(workout.start_time * 1000);
|
|
@@ -45,12 +23,19 @@ const workoutVolumeKg = ({ workout, measurements, }) => {
|
|
|
45
23
|
*/
|
|
46
24
|
const oldestLoggedMeasurement = (_b = (_a = bodyWeightMeasurements[0]) === null || _a === void 0 ? void 0 : _a.weight_kg) !== null && _b !== void 0 ? _b : 0;
|
|
47
25
|
const bodyweightKg = mostRecentMeasurementBeforeWorkout !== null && mostRecentMeasurementBeforeWorkout !== void 0 ? mostRecentMeasurementBeforeWorkout : oldestLoggedMeasurement;
|
|
48
|
-
return
|
|
26
|
+
return workoutVolumeSetsVolumeKg({
|
|
49
27
|
bodyweightKg,
|
|
50
28
|
sets: workoutToWorkoutVolumeSets(workout),
|
|
51
29
|
});
|
|
52
30
|
};
|
|
53
31
|
exports.workoutVolumeKg = workoutVolumeKg;
|
|
32
|
+
const estimatedWorkoutVolumeKg = ({ workout, bodyweightKg, }) => {
|
|
33
|
+
return workoutVolumeSetsVolumeKg({
|
|
34
|
+
bodyweightKg,
|
|
35
|
+
sets: workoutToWorkoutVolumeSets(workout),
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
exports.estimatedWorkoutVolumeKg = estimatedWorkoutVolumeKg;
|
|
54
39
|
/**
|
|
55
40
|
* Given a date, this will return the nearest bodyweight value
|
|
56
41
|
* that was logged before it.
|
|
@@ -65,15 +50,15 @@ const workoutVolumeSetsVolumeKg = ({ bodyweightKg, sets, }) => {
|
|
|
65
50
|
return accu + (0, exports.setVolumeKg)(s, bodyweightKg);
|
|
66
51
|
}, 0);
|
|
67
52
|
};
|
|
68
|
-
exports.workoutVolumeSetsVolumeKg = workoutVolumeSetsVolumeKg;
|
|
69
53
|
const setVolumeKg = (set, bodyweightKg) => {
|
|
70
|
-
const { type,
|
|
54
|
+
const { type, weightKg: originalWeightKg, reps, distanceMeters, volumeDoublingEnabled, } = set;
|
|
55
|
+
const weightKg = originalWeightKg * (volumeDoublingEnabled ? 2 : 1);
|
|
71
56
|
switch (type) {
|
|
72
57
|
case 'weight_reps':
|
|
73
58
|
// eg. Bench Press (Barbell)
|
|
74
59
|
return weightKg * reps;
|
|
75
60
|
case 'reps_only':
|
|
76
|
-
if (
|
|
61
|
+
if (set.hundredPercentBodyweightExercise) {
|
|
77
62
|
// eg. Pull Up
|
|
78
63
|
return bodyweightKg * reps;
|
|
79
64
|
}
|
|
@@ -82,7 +67,7 @@ const setVolumeKg = (set, bodyweightKg) => {
|
|
|
82
67
|
return 0;
|
|
83
68
|
}
|
|
84
69
|
case 'bodyweight_reps':
|
|
85
|
-
if (
|
|
70
|
+
if (set.hundredPercentBodyweightExercise) {
|
|
86
71
|
// eg. Pull Up (Weighted)
|
|
87
72
|
return (weightKg + bodyweightKg) * reps;
|
|
88
73
|
}
|
|
@@ -91,7 +76,7 @@ const setVolumeKg = (set, bodyweightKg) => {
|
|
|
91
76
|
return weightKg * reps;
|
|
92
77
|
}
|
|
93
78
|
case 'bodyweight_assisted_reps':
|
|
94
|
-
if (
|
|
79
|
+
if (set.hundredPercentBodyweightExercise) {
|
|
95
80
|
// eg. Pull Up (Assisted)
|
|
96
81
|
const bodyweightAssistedRepsVolume = (bodyweightKg - weightKg) * reps;
|
|
97
82
|
return Math.max(bodyweightAssistedRepsVolume, 0);
|
|
@@ -103,6 +88,8 @@ const setVolumeKg = (set, bodyweightKg) => {
|
|
|
103
88
|
case 'short_distance_weight':
|
|
104
89
|
// eg. Farmers Walk
|
|
105
90
|
return distanceMeters * weightKg;
|
|
91
|
+
case 'weight_duration':
|
|
92
|
+
return weightKg;
|
|
106
93
|
default:
|
|
107
94
|
// `duration` and `distance_duration` exercises
|
|
108
95
|
return 0;
|
|
@@ -111,7 +98,9 @@ const setVolumeKg = (set, bodyweightKg) => {
|
|
|
111
98
|
exports.setVolumeKg = setVolumeKg;
|
|
112
99
|
const workoutToWorkoutVolumeSets = (workout) => {
|
|
113
100
|
const unflatSets = workout.exercises.map((e) => {
|
|
114
|
-
return e.sets
|
|
101
|
+
return e.sets
|
|
102
|
+
.filter((s) => workout.include_warmup_sets || s.indicator !== 'warmup')
|
|
103
|
+
.map((s) => {
|
|
115
104
|
var _a, _b, _c;
|
|
116
105
|
return {
|
|
117
106
|
type: e.exercise_type || 'weight_reps',
|
|
@@ -119,6 +108,8 @@ const workoutToWorkoutVolumeSets = (workout) => {
|
|
|
119
108
|
weightKg: (_a = s.weight_kg) !== null && _a !== void 0 ? _a : 0,
|
|
120
109
|
reps: (_b = s.reps) !== null && _b !== void 0 ? _b : 0,
|
|
121
110
|
distanceMeters: (_c = s.distance_meters) !== null && _c !== void 0 ? _c : 0,
|
|
111
|
+
volumeDoublingEnabled: e.volume_doubling_enabled,
|
|
112
|
+
hundredPercentBodyweightExercise: e.hundred_percent_bodyweight_exercise,
|
|
122
113
|
};
|
|
123
114
|
});
|
|
124
115
|
});
|
package/package.json
CHANGED
|
@@ -1,35 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hevy-shared",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.963",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "built/index.js",
|
|
6
6
|
"types": "built/index.d.ts",
|
|
7
|
-
"prepare": "tsc",
|
|
8
7
|
"prepublish": "tsc",
|
|
9
8
|
"scripts": {
|
|
10
|
-
"
|
|
9
|
+
"prepare": "tsc --skipLibCheck",
|
|
10
|
+
"build": "tsc --removeComments && tsc --emitDeclarationOnly",
|
|
11
11
|
"types": "tsc --skipLibCheck",
|
|
12
12
|
"p": "npm run test && npm version patch && npm run build && npm publish && git push",
|
|
13
|
+
"ci-build": "./scripts/publish.sh",
|
|
13
14
|
"lint": "eslint . --ext .ts",
|
|
14
15
|
"lint-fix": "eslint . --ext .ts --fix",
|
|
15
16
|
"test": "jest"
|
|
16
17
|
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./built/index.js",
|
|
20
|
+
"./API": "./built/API/index.js",
|
|
21
|
+
"./translations": "./built/translations/index.js"
|
|
22
|
+
},
|
|
23
|
+
"typesVersions": {
|
|
24
|
+
"*": {
|
|
25
|
+
"API": [
|
|
26
|
+
"built/API/index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"translations": [
|
|
29
|
+
"built/translations/index.d.ts"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"built"
|
|
35
|
+
],
|
|
17
36
|
"keywords": [],
|
|
18
37
|
"author": "",
|
|
19
38
|
"license": "ISC",
|
|
20
39
|
"devDependencies": {
|
|
40
|
+
"@types/jest": "^29.5.12",
|
|
21
41
|
"@types/lodash": "^4.14.168",
|
|
22
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
23
|
-
"@typescript-eslint/parser": "^
|
|
24
|
-
"eslint": "^8.
|
|
42
|
+
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
43
|
+
"@typescript-eslint/parser": "^8.26.0",
|
|
44
|
+
"eslint": "^8.57.0",
|
|
25
45
|
"eslint-config-prettier": "^8.5.0",
|
|
26
46
|
"eslint-plugin-prettier": "^4.0.0",
|
|
27
|
-
"jest": "^
|
|
47
|
+
"jest": "^29.7.0",
|
|
28
48
|
"prettier": "^2.6.2",
|
|
29
|
-
"ts-jest": "^
|
|
30
|
-
"typescript": "
|
|
49
|
+
"ts-jest": "^29.1.2",
|
|
50
|
+
"typescript": "5.8.2"
|
|
31
51
|
},
|
|
32
52
|
"dependencies": {
|
|
33
|
-
"
|
|
53
|
+
"dayjs": "^1.11.19",
|
|
54
|
+
"lodash": "^4.17.21",
|
|
55
|
+
"zod": "3.24.3"
|
|
34
56
|
}
|
|
35
57
|
}
|
package/.eslintignore
DELETED
package/.eslintrc
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"parser": "@typescript-eslint/parser",
|
|
4
|
-
"plugins": [
|
|
5
|
-
"@typescript-eslint"
|
|
6
|
-
],
|
|
7
|
-
"extends": [
|
|
8
|
-
"eslint:recommended",
|
|
9
|
-
"plugin:@typescript-eslint/eslint-recommended",
|
|
10
|
-
"plugin:@typescript-eslint/recommended",
|
|
11
|
-
"plugin:prettier/recommended"
|
|
12
|
-
],
|
|
13
|
-
"rules": {
|
|
14
|
-
"@typescript-eslint/no-extra-boolean-cast": "off",
|
|
15
|
-
"@typescript-eslint/no-inferrable-types": "off",
|
|
16
|
-
"no-extra-boolean-cast": "off",
|
|
17
|
-
"@typescript-eslint/ban-types": "off",
|
|
18
|
-
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
-
"@typescript-eslint/no-unused-vars": "error"
|
|
20
|
-
}
|
|
21
|
-
}
|
package/.github/workflows/ci.yml
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on: push
|
|
3
|
-
jobs:
|
|
4
|
-
build:
|
|
5
|
-
runs-on: ubuntu-latest
|
|
6
|
-
steps:
|
|
7
|
-
- uses: actions/checkout@v2
|
|
8
|
-
- name: Install modules
|
|
9
|
-
run: npm install
|
|
10
|
-
- name: Run tests
|
|
11
|
-
run: npm run test
|
|
12
|
-
- name: Run Types
|
|
13
|
-
run: npm run types
|
|
14
|
-
- name: Run Linting
|
|
15
|
-
run: npm run lint
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
-
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
-
|
|
4
|
-
name: Node.js Package
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
push:
|
|
8
|
-
branches: master
|
|
9
|
-
workflow_dispatch:
|
|
10
|
-
inputs:
|
|
11
|
-
version:
|
|
12
|
-
required: false
|
|
13
|
-
type: string
|
|
14
|
-
|
|
15
|
-
jobs:
|
|
16
|
-
publish-npm:
|
|
17
|
-
permissions:
|
|
18
|
-
id-token: write # for publishing to npm via oidc
|
|
19
|
-
contents: write # actions/checkout needs read, git tag needs write
|
|
20
|
-
runs-on: ubuntu-latest
|
|
21
|
-
steps:
|
|
22
|
-
- uses: actions/checkout@v3
|
|
23
|
-
- uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: '20.17.0'
|
|
26
|
-
registry-url: https://registry.npmjs.org/
|
|
27
|
-
- name: Set git user info
|
|
28
|
-
run: |
|
|
29
|
-
git config --global user.email "ci@hevyapp.com"
|
|
30
|
-
git config --global user.name "ci"
|
|
31
|
-
- name: Update npm # needs 11.5.1+ for Trusted Publishing
|
|
32
|
-
run: npm install -g npm@11.5.1
|
|
33
|
-
- run: npm ci
|
|
34
|
-
- run: npm run types
|
|
35
|
-
- run: npm run lint
|
|
36
|
-
- run: npm run test
|
|
37
|
-
- name: Set npm version
|
|
38
|
-
run: |
|
|
39
|
-
npm config set allow-same-version true
|
|
40
|
-
npm config set git-tag-version false
|
|
41
|
-
if [ -z "${{ inputs.version }}" ]; then
|
|
42
|
-
echo 'Latest version currenly on npm:' >&2
|
|
43
|
-
npm version $(npm show hevy-shared version) >&2
|
|
44
|
-
echo 'New version:' >&2
|
|
45
|
-
VERSION="$(npm version patch)"
|
|
46
|
-
echo $VERSION >&2
|
|
47
|
-
echo "NPM_VERSION=$VERSION" >>"$GITHUB_ENV"
|
|
48
|
-
else
|
|
49
|
-
echo 'Override version:' >&2
|
|
50
|
-
VERSION="$(npm version ${{ inputs.version }})"
|
|
51
|
-
echo $VERSION >&2
|
|
52
|
-
echo "NPM_VERSION=$VERSION" >>"$GITHUB_ENV"
|
|
53
|
-
fi
|
|
54
|
-
- name: Tag release
|
|
55
|
-
run: |
|
|
56
|
-
git tag "$NPM_VERSION"
|
|
57
|
-
git push --tags
|
|
58
|
-
- run: npm run build
|
|
59
|
-
- run: npm publish
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
name: PR Auto-Assign
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request_target:
|
|
5
|
-
types: [opened]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
assign:
|
|
9
|
-
name: Auto-assign PR to author
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- env:
|
|
13
|
-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
14
|
-
run: |
|
|
15
|
-
gh pr edit ${{ github.event.number }} --add-assignee ${{ github.event.sender.login }} -R ${{ github.event.repository.full_name }}
|
package/.prettierrc.js
DELETED
package/jest.config.js
DELETED
package/src/chat.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
export interface PostCreateConversationRequest {
|
|
2
|
-
conversation_user_ids: string[];
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export interface PostCreateConversationResponse {
|
|
6
|
-
conversation_id: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface PostMessageRequest {
|
|
10
|
-
conversation_id: string;
|
|
11
|
-
data:
|
|
12
|
-
| CreateTextMessageData
|
|
13
|
-
| CreateNewWorkoutMessageData
|
|
14
|
-
| CreateNewBodyMeasurementMesageData;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface PostMessageResponse {
|
|
18
|
-
message_id: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface CreateTextMessageData {
|
|
22
|
-
type: 'text';
|
|
23
|
-
text: string;
|
|
24
|
-
}
|
|
25
|
-
export interface CreateNewWorkoutMessageData {
|
|
26
|
-
type: 'new-workout';
|
|
27
|
-
workout_id: string;
|
|
28
|
-
}
|
|
29
|
-
export interface CreateNewBodyMeasurementMesageData {
|
|
30
|
-
type: 'new-body-measurement';
|
|
31
|
-
measurement_id: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface GetLatestMessageFromAllClientsResponse {
|
|
35
|
-
conversations: {
|
|
36
|
-
conversation_id: string;
|
|
37
|
-
latest_message: Message;
|
|
38
|
-
last_read_message_id?: string;
|
|
39
|
-
}[];
|
|
40
|
-
}
|
|
41
|
-
export interface PostGetMessagesRequest {
|
|
42
|
-
conversation_id: string;
|
|
43
|
-
less_than_index?: string;
|
|
44
|
-
limit: number;
|
|
45
|
-
}
|
|
46
|
-
export interface PostGetMessagesResponse {
|
|
47
|
-
messages: Message[];
|
|
48
|
-
last_read_message_id?: string;
|
|
49
|
-
has_more: boolean;
|
|
50
|
-
}
|
|
51
|
-
export interface PostSetConversationReadAtRequest {
|
|
52
|
-
conversation_id: string;
|
|
53
|
-
last_read_message_id: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface Conversation {
|
|
57
|
-
conversation_id: string;
|
|
58
|
-
user_ids: string[];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export type MessageType = 'text' | 'new-workout' | 'new-body-measurement';
|
|
62
|
-
|
|
63
|
-
export interface MessageBase {
|
|
64
|
-
id: string;
|
|
65
|
-
sender_user_id: string;
|
|
66
|
-
conversation_id: string;
|
|
67
|
-
type: MessageType;
|
|
68
|
-
created_at: string;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export interface TextMessage extends MessageBase {
|
|
72
|
-
type: 'text';
|
|
73
|
-
text: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface NewWorkoutMessageData {
|
|
77
|
-
workout_id: string;
|
|
78
|
-
}
|
|
79
|
-
export interface NewWorkoutMessage extends MessageBase {
|
|
80
|
-
type: 'new-workout';
|
|
81
|
-
data: NewWorkoutMessageData;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export interface NewBodyMeasurementMessageData {
|
|
85
|
-
measurement_id: number;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export interface NewBodyMeasurementMessage extends MessageBase {
|
|
89
|
-
type: 'new-body-measurement';
|
|
90
|
-
data: NewBodyMeasurementMessageData;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export type Message =
|
|
94
|
-
| TextMessage
|
|
95
|
-
| NewWorkoutMessage
|
|
96
|
-
| NewBodyMeasurementMessage;
|
|
97
|
-
|
|
98
|
-
export const isMessage = (message?: any): message is Message => {
|
|
99
|
-
return (
|
|
100
|
-
!!message &&
|
|
101
|
-
!!message.conversation_id &&
|
|
102
|
-
!!message.sender_user_id &&
|
|
103
|
-
!!message.type
|
|
104
|
-
);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export interface NewMessageChatUpdate {
|
|
108
|
-
type: 'new-message';
|
|
109
|
-
message: Message;
|
|
110
|
-
}
|
|
111
|
-
export interface MessageDeletedChatUpdate {
|
|
112
|
-
type: 'message-deleted';
|
|
113
|
-
message_id: string;
|
|
114
|
-
}
|
|
115
|
-
export interface NewConversationChatUpdate {
|
|
116
|
-
type: 'new-conversation';
|
|
117
|
-
conversation_id: string;
|
|
118
|
-
conversation_users: string[];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export type HevyChatUpdatePush =
|
|
122
|
-
| NewMessageChatUpdate
|
|
123
|
-
| MessageDeletedChatUpdate
|
|
124
|
-
| NewConversationChatUpdate;
|
|
125
|
-
|
|
126
|
-
export const isHevyChatUpdatePush = (
|
|
127
|
-
message?: any,
|
|
128
|
-
): message is HevyChatUpdatePush => {
|
|
129
|
-
return !!message && typeof message.type === 'string';
|
|
130
|
-
};
|
package/src/coachPlans.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export const HevyCoachDefaultPlan: Plan = {
|
|
2
|
-
maximum_clients: 3,
|
|
3
|
-
id: 'hevy_coach_free',
|
|
4
|
-
title: 'Free',
|
|
5
|
-
renewal_period: 'lifetime',
|
|
6
|
-
type: 'default',
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export type PlanType = 'default' | 'paid_paddle' | 'trial' | 'beta';
|
|
10
|
-
|
|
11
|
-
export interface Plan {
|
|
12
|
-
title: string;
|
|
13
|
-
maximum_clients: number;
|
|
14
|
-
id: string;
|
|
15
|
-
paddle_update_payment_url?: string;
|
|
16
|
-
renewal_period: 'monthly' | 'lifetime';
|
|
17
|
-
renewal_price?: string;
|
|
18
|
-
renewal_currency?: string;
|
|
19
|
-
type: PlanType;
|
|
20
|
-
}
|
|
21
|
-
/** https://developer.paddle.com/reference/ZG9jOjI1MzU0MDI2-subscription-status-reference */
|
|
22
|
-
export type CoachPlanStatus =
|
|
23
|
-
| 'active'
|
|
24
|
-
| 'past_due'
|
|
25
|
-
| 'paused'
|
|
26
|
-
| 'will_pause' /** This is one we added that means the subscription will pause at the end of the current billing period */
|
|
27
|
-
| 'deleted';
|
|
28
|
-
|
|
29
|
-
export interface CoachsPlan extends Plan {
|
|
30
|
-
status: CoachPlanStatus;
|
|
31
|
-
renewal_date?: string;
|
|
32
|
-
/** Next bill data from Paddle */
|
|
33
|
-
next_bill?: {
|
|
34
|
-
amount: number;
|
|
35
|
-
currency: string;
|
|
36
|
-
date: string;
|
|
37
|
-
};
|
|
38
|
-
user_previously_started_trial: boolean;
|
|
39
|
-
}
|
|
40
|
-
export interface GetAvailableCoachPlansResponse {
|
|
41
|
-
available_plans: Plan[];
|
|
42
|
-
}
|
|
43
|
-
export interface GetCoachPlanResponse {
|
|
44
|
-
current_plan: CoachsPlan;
|
|
45
|
-
}
|
|
46
|
-
export interface CoachPayment {
|
|
47
|
-
id: number;
|
|
48
|
-
amount: number;
|
|
49
|
-
currency: string;
|
|
50
|
-
is_paid: number;
|
|
51
|
-
is_one_off_charge: boolean;
|
|
52
|
-
receipt_url: string;
|
|
53
|
-
payout_date: string;
|
|
54
|
-
}
|
|
55
|
-
export interface GetCoachPaymentHistoryResponse {
|
|
56
|
-
payments: CoachPayment[];
|
|
57
|
-
}
|
package/src/constants.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const MAX_WORKOUT_TITLE_LENGTH = 100;
|
|
2
|
-
export const MAX_WORKOUT_DESCRIPTION_LENGTH = 2000;
|
|
3
|
-
export const MAX_WORKOUT_EXERCISE_NOTES_LENGTH = 2000;
|
|
4
|
-
|
|
5
|
-
export const MAX_ROUTINE_TITLE_LENGTH = 100;
|
|
6
|
-
export const MAX_ROUTINE_EXERCISE_NOTES_LENGTH = 2000;
|
|
7
|
-
|
|
8
|
-
export const MAX_EXERCISE_TITLE_LENGTH = 100;
|
|
9
|
-
|
|
10
|
-
export const MAX_COMMENT_LENGTH = 250;
|
|
11
|
-
|
|
12
|
-
export const MAX_PROFILE_FULL_NAME_LENGTH = 100;
|
|
13
|
-
export const MAX_PROFILE_DESCRIPTION_LENGTH = 200;
|
|
14
|
-
export const MAX_PROFILE_WEBSITE_LENGTH = 100;
|