hevy-shared 1.0.960 → 1.0.962
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/.eslintignore +2 -0
- package/.eslintrc +21 -0
- package/.github/workflows/ci.yml +15 -0
- package/.github/workflows/npm-publish.yml +59 -0
- package/.github/workflows/pr-auto-assign.yml +15 -0
- package/.prettierrc.js +5 -0
- package/README.md +2 -17
- package/built/chat.d.ts +23 -25
- package/built/coachPlans.d.ts +1 -2
- package/built/coachPlans.js +2 -2
- package/built/filterExercises.d.ts +3 -19
- package/built/filterExercises.js +60 -72
- package/built/index.d.ts +304 -1140
- package/built/index.js +75 -269
- package/built/setIndicatorUtils.d.ts +3 -4
- package/built/setIndicatorUtils.js +1 -15
- package/built/tests/utils.test.js +0 -748
- package/built/tests/workoutVolume.test.js +49 -165
- package/built/units.d.ts +7 -14
- package/built/units.js +14 -24
- package/built/utils.d.ts +5 -192
- package/built/utils.js +85 -598
- package/built/websocket.d.ts +2 -14
- package/built/workoutVolume.d.ts +5 -24
- package/built/workoutVolume.js +34 -25
- package/jest.config.js +4 -0
- package/package.json +10 -32
- package/src/chat.ts +130 -0
- package/src/coachPlans.ts +57 -0
- package/src/constants.ts +14 -0
- package/src/filterExercises.ts +222 -0
- package/src/index.ts +1576 -0
- package/src/setIndicatorUtils.ts +137 -0
- package/src/tests/utils.test.ts +156 -0
- package/src/tests/workoutVolume.test.ts +93 -0
- package/src/units.ts +41 -0
- package/src/utils.ts +516 -0
- package/src/websocket.ts +36 -0
- package/src/workoutVolume.ts +175 -0
- package/tsconfig.json +70 -0
- package/built/API/APIClient.d.ts +0 -157
- package/built/API/APIClient.js +0 -381
- package/built/API/index.d.ts +0 -2
- package/built/API/index.js +0 -18
- package/built/API/types.d.ts +0 -38
- package/built/API/types.js +0 -18
- package/built/adjustEventTokens.d.ts +0 -16
- package/built/adjustEventTokens.js +0 -18
- package/built/adminPermissions.d.ts +0 -4
- package/built/adminPermissions.js +0 -22
- package/built/async.d.ts +0 -50
- package/built/async.js +0 -170
- package/built/cue.d.ts +0 -12
- package/built/cue.js +0 -22
- package/built/exerciseLocaleUtils.d.ts +0 -17
- package/built/exerciseLocaleUtils.js +0 -62
- package/built/hevyTrainer.d.ts +0 -250
- package/built/hevyTrainer.js +0 -676
- package/built/muscleHeatmaps.d.ts +0 -31
- package/built/muscleHeatmaps.js +0 -68
- package/built/muscleSplits.d.ts +0 -36
- package/built/muscleSplits.js +0 -100
- package/built/normalizedWorkoutUtils.d.ts +0 -88
- package/built/normalizedWorkoutUtils.js +0 -112
- package/built/notifications.d.ts +0 -215
- package/built/notifications.js +0 -9
- package/built/routineUtils.d.ts +0 -14
- package/built/routineUtils.js +0 -186
- package/built/schemas.d.ts +0 -6
- package/built/schemas.js +0 -12
- package/built/tests/async.test.d.ts +0 -1
- package/built/tests/async.test.js +0 -49
- package/built/tests/hevyTrainer.test.d.ts +0 -1
- package/built/tests/hevyTrainer.test.js +0 -1199
- package/built/tests/muscleSplit.test.d.ts +0 -1
- package/built/tests/muscleSplit.test.js +0 -153
- package/built/tests/routineUtils.test.d.ts +0 -1
- package/built/tests/routineUtils.test.js +0 -745
- package/built/tests/testUtils.d.ts +0 -85
- package/built/tests/testUtils.js +0 -319
- package/built/translations/index.d.ts +0 -2
- package/built/translations/index.js +0 -18
- package/built/translations/translationUtils.d.ts +0 -2
- package/built/translations/translationUtils.js +0 -61
- package/built/translations/types.d.ts +0 -8
- package/built/translations/types.js +0 -20
- package/built/typeUtils.d.ts +0 -70
- package/built/typeUtils.js +0 -55
package/built/async.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LockError = exports.handleRejection = exports.allToResolveOrReject = void 0;
|
|
13
|
-
exports._synchronized_3 = _synchronized_3;
|
|
14
|
-
exports.synchronized = synchronized;
|
|
15
|
-
/**
|
|
16
|
-
* The difference between this and `Promise.all` is that `Promise.all` rejects
|
|
17
|
-
* when any promise rejects, and this resolves when all promises resolve _or_
|
|
18
|
-
* reject.
|
|
19
|
-
*
|
|
20
|
-
* This function returns an array of results, each of which is either a success
|
|
21
|
-
* result containing the resolved promise, or an error result containing the
|
|
22
|
-
* value that was passed to `reject()`.
|
|
23
|
-
*
|
|
24
|
-
* This function itself never throws or rejects.
|
|
25
|
-
*/
|
|
26
|
-
const allToResolveOrReject = (promises) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
// Attach a dummy rejection handler to each promise as soon as possible, to
|
|
28
|
-
// try to prevent them from rejecting in the background without a handler, as
|
|
29
|
-
// that can cause issues, depending on the runtime environment.
|
|
30
|
-
//
|
|
31
|
-
promises.forEach(exports.handleRejection); // try to comment this out & run the tests
|
|
32
|
-
const results = [];
|
|
33
|
-
for (const promise of promises) {
|
|
34
|
-
try {
|
|
35
|
-
const value = yield promise;
|
|
36
|
-
results.push({ isSuccess: true, value });
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
results.push({ isSuccess: false, error });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return results;
|
|
43
|
-
});
|
|
44
|
-
exports.allToResolveOrReject = allToResolveOrReject;
|
|
45
|
-
/**
|
|
46
|
-
* Attach a dummy rejection handler to a promise and return the original
|
|
47
|
-
* promise. Used to prevent unhandled rejections in the background.
|
|
48
|
-
*
|
|
49
|
-
* To use this, wrap any `async` or `Promise`-returning function with this
|
|
50
|
-
* function and use it as you otherwise would.
|
|
51
|
-
*
|
|
52
|
-
* Calling this multiple times for the same promise should have no ill effect.
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // Before
|
|
56
|
-
* await fetch('https://hevy.com/blabla');
|
|
57
|
-
*
|
|
58
|
-
* // After
|
|
59
|
-
* await handleRejection(fetch('https://hevy.com/blabla'));
|
|
60
|
-
*/
|
|
61
|
-
const handleRejection = (p) => (p.catch(() => { }), p);
|
|
62
|
-
exports.handleRejection = handleRejection;
|
|
63
|
-
/**
|
|
64
|
-
* Do not use this directly. Use the alias provided by the parent project.
|
|
65
|
-
*/
|
|
66
|
-
function _synchronized_3(arg0, arg1) {
|
|
67
|
-
if (typeof arg1 === 'object' &&
|
|
68
|
-
arg1 !== null &&
|
|
69
|
-
'name' in arg1 &&
|
|
70
|
-
'access' in arg1) {
|
|
71
|
-
return synchronizedStage3DecoratorFactory(arg0, arg1, true);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
return function (value, context) {
|
|
75
|
-
return synchronizedStage3DecoratorFactory(value, context, arg0, arg1);
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function synchronized(arg0, arg1, arg2) {
|
|
80
|
-
if (arguments.length === 1) {
|
|
81
|
-
return function (target, propertyKey, descriptor) {
|
|
82
|
-
return synchronizedLegacyDecoratorFactory(target, propertyKey, descriptor, arg0);
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
else if (arguments.length === 2) {
|
|
86
|
-
return function (target, propertyKey, descriptor) {
|
|
87
|
-
return synchronizedLegacyDecoratorFactory(target, propertyKey, descriptor, arg0, arg1);
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
return synchronizedLegacyDecoratorFactory(arg0, arg1, arg2, true);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
const $queue = Symbol();
|
|
95
|
-
class LockError extends Error {
|
|
96
|
-
constructor(...args) {
|
|
97
|
-
super(...args);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.LockError = LockError;
|
|
101
|
-
class $LockError extends LockError {
|
|
102
|
-
constructor({ message: baseMessage, propertyKey, lockId, }) {
|
|
103
|
-
const formattedLockId = lockId !== undefined ? `"${String(lockId)}"` : '(anonymous)';
|
|
104
|
-
const message = `Cannot invoke "${String(propertyKey)}" (locked by ${formattedLockId}): ${baseMessage}`;
|
|
105
|
-
super(message);
|
|
106
|
-
this.name = 'LockError';
|
|
107
|
-
this.message = message;
|
|
108
|
-
this.propertyKey = propertyKey;
|
|
109
|
-
this.lockId = lockId;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function synchronizedStage3DecoratorFactory(origFn, context, wait, id) {
|
|
113
|
-
const lockId = arguments.length === 4 ? id : Symbol();
|
|
114
|
-
const propertyKey = context.name;
|
|
115
|
-
return synchronizedDecoratorFactory({
|
|
116
|
-
id,
|
|
117
|
-
lockId,
|
|
118
|
-
origFn,
|
|
119
|
-
propertyKey,
|
|
120
|
-
wait,
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
function synchronizedLegacyDecoratorFactory(_target, propertyKey, descriptor, wait, id) {
|
|
124
|
-
const origFn = descriptor.value;
|
|
125
|
-
const lockId = arguments.length === 5 ? id : Symbol();
|
|
126
|
-
descriptor.value = synchronizedDecoratorFactory({
|
|
127
|
-
id,
|
|
128
|
-
lockId,
|
|
129
|
-
origFn,
|
|
130
|
-
propertyKey,
|
|
131
|
-
wait,
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
function synchronizedDecoratorFactory({ id, lockId, origFn, propertyKey, wait, }) {
|
|
135
|
-
return function (...args) {
|
|
136
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
-
var _a, _b;
|
|
138
|
-
var _c;
|
|
139
|
-
const queue = ((_b = (_c = ((_a = this[$queue]) !== null && _a !== void 0 ? _a : (this[$queue] = {})))[lockId]) !== null && _b !== void 0 ? _b : (_c[lockId] = []));
|
|
140
|
-
if (queue.length > 0 && !wait) {
|
|
141
|
-
throw new $LockError({
|
|
142
|
-
message: 'Operation is already in progress',
|
|
143
|
-
propertyKey,
|
|
144
|
-
lockId: id,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
let done;
|
|
148
|
-
const thisCall = new Promise((resolve) => {
|
|
149
|
-
done = resolve;
|
|
150
|
-
});
|
|
151
|
-
const waiting = [...queue];
|
|
152
|
-
queue.push(thisCall);
|
|
153
|
-
yield (0, exports.allToResolveOrReject)(waiting);
|
|
154
|
-
try {
|
|
155
|
-
return yield origFn.apply(this, args);
|
|
156
|
-
}
|
|
157
|
-
finally {
|
|
158
|
-
done();
|
|
159
|
-
if (queue.shift() !== thisCall) {
|
|
160
|
-
// eslint-disable-next-line no-unsafe-finally
|
|
161
|
-
throw new $LockError({
|
|
162
|
-
message: 'Assertion failed: @synchronized queue is mangled',
|
|
163
|
-
propertyKey,
|
|
164
|
-
lockId: id,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
});
|
|
169
|
-
};
|
|
170
|
-
}
|
package/built/cue.d.ts
DELETED
package/built/cue.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCueGroup = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* A = control group
|
|
6
|
-
*
|
|
7
|
-
* B = test group
|
|
8
|
-
*/
|
|
9
|
-
const generateCueGroup = (userId) => {
|
|
10
|
-
if (typeof userId !== 'string') {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
const firstCharacter = userId.charAt(0);
|
|
14
|
-
if (['0', '1', '2', '3', '4', '5', '6', '7'].includes(firstCharacter)) {
|
|
15
|
-
return 'a';
|
|
16
|
-
}
|
|
17
|
-
if (['8', '9', 'a', 'b', 'c', 'd', 'e', 'f'].includes(firstCharacter)) {
|
|
18
|
-
return 'b';
|
|
19
|
-
}
|
|
20
|
-
return undefined;
|
|
21
|
-
};
|
|
22
|
-
exports.generateCueGroup = generateCueGroup;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { LibraryExercise, Lookup } from '.';
|
|
2
|
-
import { Language } from './translations';
|
|
3
|
-
/** Keeping exercise instruction/title localization utils here instead of translations
|
|
4
|
-
* so I don't need to import exercise types from here in translations (translations was
|
|
5
|
-
* created so that hevy-web can import utils from shared without importing something from
|
|
6
|
-
* that isn't allowed in Edge Runtime)
|
|
7
|
-
*/
|
|
8
|
-
export declare const supportedInstructionsLanguages: readonly ["en", "it", "de", "es", "fr", "pt"];
|
|
9
|
-
export type InstructionsLanguage = Lookup<typeof supportedInstructionsLanguages>;
|
|
10
|
-
export declare const isSupportedInstructionsLanguage: (lang: string) => lang is InstructionsLanguage;
|
|
11
|
-
type LocalizableExerciseTemplate = Pick<LibraryExercise, 'title' | 'es_title' | 'de_title' | 'fr_title' | 'it_title' | 'ja_title' | 'ko_title' | 'pt_title' | 'ru_title' | 'tr_title' | 'zh_cn_title' | 'zh_tw_title' | 'localised_instructions' | 'is_custom'>;
|
|
12
|
-
export declare const localisedExerciseTitle: (locale: Language, template: LocalizableExerciseTemplate) => string;
|
|
13
|
-
export declare const localisedExerciseInstructions: (locale: Language, exerciseTemplate: LocalizableExerciseTemplate) => string;
|
|
14
|
-
export declare const localeSelect: <T>(locale: Language, options: {
|
|
15
|
-
en: T;
|
|
16
|
-
} & { [language in Exclude<Language, "en">]?: T | null; }) => T;
|
|
17
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.localeSelect = exports.localisedExerciseInstructions = exports.localisedExerciseTitle = exports.isSupportedInstructionsLanguage = exports.supportedInstructionsLanguages = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
/** Keeping exercise instruction/title localization utils here instead of translations
|
|
6
|
-
* so I don't need to import exercise types from here in translations (translations was
|
|
7
|
-
* created so that hevy-web can import utils from shared without importing something from
|
|
8
|
-
* that isn't allowed in Edge Runtime)
|
|
9
|
-
*/
|
|
10
|
-
exports.supportedInstructionsLanguages = [
|
|
11
|
-
'en',
|
|
12
|
-
'it',
|
|
13
|
-
'de',
|
|
14
|
-
'es',
|
|
15
|
-
'fr',
|
|
16
|
-
'pt',
|
|
17
|
-
];
|
|
18
|
-
const isSupportedInstructionsLanguage = (lang) => {
|
|
19
|
-
return (0, _1.isInArray)(lang, exports.supportedInstructionsLanguages);
|
|
20
|
-
};
|
|
21
|
-
exports.isSupportedInstructionsLanguage = isSupportedInstructionsLanguage;
|
|
22
|
-
const localisedExerciseTitle = (locale, template) => {
|
|
23
|
-
var _a;
|
|
24
|
-
if (template.is_custom) {
|
|
25
|
-
return template.title;
|
|
26
|
-
}
|
|
27
|
-
return ((_a = (0, exports.localeSelect)(locale, {
|
|
28
|
-
en: template.title,
|
|
29
|
-
es: template.es_title,
|
|
30
|
-
de: template.de_title,
|
|
31
|
-
fr: template.fr_title,
|
|
32
|
-
it: template.it_title,
|
|
33
|
-
pt: template.pt_title,
|
|
34
|
-
tr: template.tr_title,
|
|
35
|
-
zh_CN: template.zh_cn_title,
|
|
36
|
-
zh_TW: template.zh_tw_title,
|
|
37
|
-
ru: template.ru_title,
|
|
38
|
-
ja: template.ja_title,
|
|
39
|
-
ko: template.ko_title,
|
|
40
|
-
})) !== null && _a !== void 0 ? _a : template.title);
|
|
41
|
-
};
|
|
42
|
-
exports.localisedExerciseTitle = localisedExerciseTitle;
|
|
43
|
-
const localisedExerciseInstructions = (locale, exerciseTemplate) => {
|
|
44
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
45
|
-
if (exerciseTemplate.is_custom) {
|
|
46
|
-
return '';
|
|
47
|
-
}
|
|
48
|
-
return (0, exports.localeSelect)(locale, {
|
|
49
|
-
en: (_b = (_a = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _a === void 0 ? void 0 : _a.en) !== null && _b !== void 0 ? _b : '',
|
|
50
|
-
pt: (_c = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _c === void 0 ? void 0 : _c.pt,
|
|
51
|
-
de: (_d = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _d === void 0 ? void 0 : _d.de,
|
|
52
|
-
es: (_e = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _e === void 0 ? void 0 : _e.es,
|
|
53
|
-
it: (_f = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _f === void 0 ? void 0 : _f.it,
|
|
54
|
-
fr: (_g = exerciseTemplate === null || exerciseTemplate === void 0 ? void 0 : exerciseTemplate.localised_instructions) === null || _g === void 0 ? void 0 : _g.fr,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
exports.localisedExerciseInstructions = localisedExerciseInstructions;
|
|
58
|
-
const localeSelect = (locale, options) => {
|
|
59
|
-
var _a;
|
|
60
|
-
return (_a = options[locale]) !== null && _a !== void 0 ? _a : options.en;
|
|
61
|
-
};
|
|
62
|
-
exports.localeSelect = localeSelect;
|
package/built/hevyTrainer.d.ts
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
import { WeeklyTrainingFrequency, TrainingGoal, TrainingLevel, SimplifiedMuscleGroup, MuscleGroup, LibraryExercise, ExerciseCategory, GranularEquipment, HevyTrainerProgramEquipment, RestTimerLength } from '.';
|
|
2
|
-
export type HevyTrainerExerciseCategory = typeof hevyTrainerExerciseCategories[number];
|
|
3
|
-
export type HevyTrainerRoutineName = typeof routineNames[number];
|
|
4
|
-
export declare const workoutDurationOptions: readonly [40, 60, 80];
|
|
5
|
-
export type WorkoutDurationMinutes = typeof workoutDurationOptions[number];
|
|
6
|
-
export declare const trainerGymTypes: readonly ["home_gym", "garage_gym", "commercial_gym", "full_gym"];
|
|
7
|
-
export type TrainerGymType = typeof trainerGymTypes[number];
|
|
8
|
-
export declare const granularEquipmentDefaults: {
|
|
9
|
-
[key in TrainerGymType]: GranularEquipment[];
|
|
10
|
-
};
|
|
11
|
-
export declare const trainerEquipmentToGranularEquipments: (equipments: HevyTrainerProgramEquipment[]) => GranularEquipment[];
|
|
12
|
-
/**
|
|
13
|
-
* Converts granular equipment values back to the old HevyTrainerProgramEquipment
|
|
14
|
-
* types for backwards compatibility with old mobile clients.
|
|
15
|
-
*/
|
|
16
|
-
export declare const granularEquipmentsToTrainerEquipments: (granularEquipments: GranularEquipment[]) => HevyTrainerProgramEquipment[];
|
|
17
|
-
export declare const hevyTrainerExerciseCategories: readonly ["compound", "isolation"];
|
|
18
|
-
export declare const defaultDurationPerFrequency: Record<WeeklyTrainingFrequency, WorkoutDurationMinutes>;
|
|
19
|
-
export declare const routineNames: readonly ["full_body_1", "full_body_2_a", "full_body_2_b", "full_body_3_a", "full_body_3_b", "full_body_3_c", "upper_1_a", "lower_1_a", "upper_1_b", "lower_1_b", "push_1", "pull_1", "legs_1", "upper_2", "lower_2", "push_2_a", "pull_2_a", "legs_2_a", "push_2_b", "pull_2_b", "legs_2_b"];
|
|
20
|
-
export type exerciseId = string;
|
|
21
|
-
export interface ExerciseSelectionCriteria {
|
|
22
|
-
exerciseCategory: HevyTrainerExerciseCategory | 'all';
|
|
23
|
-
equipments: GranularEquipment[];
|
|
24
|
-
routineBarbellExerciseCount: number;
|
|
25
|
-
level: TrainingLevel;
|
|
26
|
-
goal: TrainingGoal;
|
|
27
|
-
muscleGroup: MuscleGroup;
|
|
28
|
-
frequency: WeeklyTrainingFrequency;
|
|
29
|
-
}
|
|
30
|
-
export interface ExerciseSelectionContext {
|
|
31
|
-
programUsedExerciseIds?: Set<string>;
|
|
32
|
-
routineUsedExerciseIds?: Set<string>;
|
|
33
|
-
excludedExerciseIds?: Set<string>;
|
|
34
|
-
}
|
|
35
|
-
export interface ExerciseSelectionParams<T extends HevyTrainerLibraryExercise> {
|
|
36
|
-
sortedExercises: Record<MuscleGroup, T[]>;
|
|
37
|
-
handPickedExercises?: T[];
|
|
38
|
-
criteria: ExerciseSelectionCriteria;
|
|
39
|
-
context: ExerciseSelectionContext;
|
|
40
|
-
}
|
|
41
|
-
export interface ExerciseSelectionTraceEntry {
|
|
42
|
-
pass: 1 | 2 | 3 | 4 | 5 | 6;
|
|
43
|
-
label: string;
|
|
44
|
-
candidatePoolSize: number;
|
|
45
|
-
selectedExerciseId?: string;
|
|
46
|
-
}
|
|
47
|
-
export interface ExerciseSelectionTrace {
|
|
48
|
-
entries: ExerciseSelectionTraceEntry[];
|
|
49
|
-
selectedPass?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
50
|
-
}
|
|
51
|
-
export interface ProgramGenerationParams<T extends HevyTrainerLibraryExercise> {
|
|
52
|
-
trainerAlgorithmSettings: TrainerAlgorithmSettings;
|
|
53
|
-
frequency: WeeklyTrainingFrequency;
|
|
54
|
-
goal: TrainingGoal;
|
|
55
|
-
level: TrainingLevel;
|
|
56
|
-
equipments: GranularEquipment[];
|
|
57
|
-
workoutDurationMinutes: WorkoutDurationMinutes;
|
|
58
|
-
restTimerLength: RestTimerLength;
|
|
59
|
-
exerciseStore: T[];
|
|
60
|
-
focusMuscle?: SimplifiedMuscleGroup;
|
|
61
|
-
excludedExerciseIds?: Set<string>;
|
|
62
|
-
/**
|
|
63
|
-
* When enabled, includes exercise selection trace breadcrumbs in the result
|
|
64
|
-
* for debugging. Intended for troubleshooting on backoffice; keep off in
|
|
65
|
-
* normal usage on the app.
|
|
66
|
-
*/
|
|
67
|
-
debugExerciseSelectionTrace?: boolean;
|
|
68
|
-
}
|
|
69
|
-
export interface ProgramExerciseSelectionTraceRecord {
|
|
70
|
-
routine: HevyTrainerRoutineName;
|
|
71
|
-
prescriptionIndex: number;
|
|
72
|
-
prescription: ExercisePrescription;
|
|
73
|
-
resolvedMuscleGroup: MuscleGroup;
|
|
74
|
-
criteria: ExerciseSelectionCriteria;
|
|
75
|
-
selectedExerciseId?: string;
|
|
76
|
-
trace: ExerciseSelectionTrace;
|
|
77
|
-
}
|
|
78
|
-
export type TrainerProgramAttemptWithTraces = TrainerProgramAttempt & {
|
|
79
|
-
exerciseSelectionTraces: ProgramExerciseSelectionTraceRecord[];
|
|
80
|
-
};
|
|
81
|
-
export type FrequencyString = 'one_day' | 'two_days' | 'three_days' | 'four_days' | 'five_days' | 'six_days';
|
|
82
|
-
export declare const frequencyMap: Record<WeeklyTrainingFrequency, FrequencyString>;
|
|
83
|
-
export declare const programSplits: Record<WeeklyTrainingFrequency, HevyTrainerRoutineName[]>;
|
|
84
|
-
export type SetsPerGoal = {
|
|
85
|
-
[key in TrainingGoal]: number;
|
|
86
|
-
};
|
|
87
|
-
export type SetsPerFrequency = {
|
|
88
|
-
[key in FrequencyString]: SetsPerGoal;
|
|
89
|
-
};
|
|
90
|
-
export interface RepRange {
|
|
91
|
-
rep_range_start: number;
|
|
92
|
-
rep_range_end: number;
|
|
93
|
-
}
|
|
94
|
-
export type RepRangesPerCategory = {
|
|
95
|
-
[key in HevyTrainerExerciseCategory]: RepRange;
|
|
96
|
-
};
|
|
97
|
-
export type RepRanges = {
|
|
98
|
-
[key in TrainingGoal]: RepRangesPerCategory;
|
|
99
|
-
};
|
|
100
|
-
export type RestTimersPerCategory = {
|
|
101
|
-
[key in HevyTrainerExerciseCategory]: number;
|
|
102
|
-
};
|
|
103
|
-
export type CategoryPerRestTimerLength = {
|
|
104
|
-
[key in RestTimerLength]: RestTimersPerCategory;
|
|
105
|
-
};
|
|
106
|
-
export type RestTimers = {
|
|
107
|
-
[key in TrainingGoal]: CategoryPerRestTimerLength;
|
|
108
|
-
};
|
|
109
|
-
export type ExercisePriorities = {
|
|
110
|
-
[key in MuscleGroup]: exerciseId[];
|
|
111
|
-
};
|
|
112
|
-
export type ExerciseNotes = {
|
|
113
|
-
[key in exerciseId]: string;
|
|
114
|
-
};
|
|
115
|
-
export interface ExercisePrescription {
|
|
116
|
-
muscle_group: MuscleGroup | 'focus_muscle';
|
|
117
|
-
category: HevyTrainerExerciseCategory;
|
|
118
|
-
warmup_set_count?: number;
|
|
119
|
-
min_workout_duration_limit?: WorkoutDurationMinutes;
|
|
120
|
-
}
|
|
121
|
-
export type ExerciseReplacements = {
|
|
122
|
-
[key in exerciseId]: exerciseId[];
|
|
123
|
-
};
|
|
124
|
-
export interface WorkoutTemplate {
|
|
125
|
-
exercises: ExercisePrescription[];
|
|
126
|
-
notes?: string;
|
|
127
|
-
}
|
|
128
|
-
export type Templates = {
|
|
129
|
-
[key in HevyTrainerRoutineName]: WorkoutTemplate;
|
|
130
|
-
};
|
|
131
|
-
export interface BackofficeTrainerPreset {
|
|
132
|
-
id?: number;
|
|
133
|
-
username: string;
|
|
134
|
-
title?: string;
|
|
135
|
-
is_default?: boolean;
|
|
136
|
-
updated_at?: string;
|
|
137
|
-
settings: TrainerAlgorithmSettings;
|
|
138
|
-
}
|
|
139
|
-
export interface TrainerAlgorithmSettings {
|
|
140
|
-
sets: SetsPerFrequency;
|
|
141
|
-
rep_ranges: RepRanges;
|
|
142
|
-
rest_timers: RestTimers;
|
|
143
|
-
templates: Templates;
|
|
144
|
-
exercise_priorities: ExercisePriorities;
|
|
145
|
-
exercise_notes: ExerciseNotes;
|
|
146
|
-
exercise_replacements: ExerciseReplacements;
|
|
147
|
-
}
|
|
148
|
-
export interface TrainerProgramExercise {
|
|
149
|
-
exerciseTemplate: HevyTrainerLibraryExercise;
|
|
150
|
-
muscleGroup: MuscleGroup | 'focus_muscle';
|
|
151
|
-
category: HevyTrainerExerciseCategory;
|
|
152
|
-
sets: number;
|
|
153
|
-
warmupSetCount?: number;
|
|
154
|
-
repRangeStart: number;
|
|
155
|
-
repRangeEnd: number;
|
|
156
|
-
restTimerSeconds: number;
|
|
157
|
-
notes?: string;
|
|
158
|
-
}
|
|
159
|
-
export interface TrainerProgramRoutine {
|
|
160
|
-
name: HevyTrainerRoutineName;
|
|
161
|
-
exercises: TrainerProgramExercise[];
|
|
162
|
-
notes?: string;
|
|
163
|
-
}
|
|
164
|
-
export interface TrainerProgram {
|
|
165
|
-
name: WeeklyTrainingFrequency;
|
|
166
|
-
routines: TrainerProgramRoutine[];
|
|
167
|
-
}
|
|
168
|
-
export declare const getTrainerSetCount: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, frequency: WeeklyTrainingFrequency) => number;
|
|
169
|
-
export declare const getTrainerRepRange: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, exerciseCategory: HevyTrainerExerciseCategory) => RepRange;
|
|
170
|
-
export declare const getTrainerRestTimerSeconds: (trainerAlgorithmSettings: TrainerAlgorithmSettings, goal: TrainingGoal, length: RestTimerLength, exerciseCategory: HevyTrainerExerciseCategory) => number;
|
|
171
|
-
/**
|
|
172
|
-
* Normalizes the exercise category to a HevyTrainerExerciseCategory
|
|
173
|
-
* - Treat custom exercises and exercises with no category as `compound`
|
|
174
|
-
* - Treat `assistance-compound` as `compound`
|
|
175
|
-
* - Treat `isolation` as `isolation`
|
|
176
|
-
* @param exercise - The exercise to normalize the category for
|
|
177
|
-
* @returns The normalized exercise category
|
|
178
|
-
*/
|
|
179
|
-
export declare const normalizeExerciseCategory: (exercise: {
|
|
180
|
-
is_custom: boolean;
|
|
181
|
-
category?: ExerciseCategory;
|
|
182
|
-
}) => HevyTrainerExerciseCategory;
|
|
183
|
-
/**
|
|
184
|
-
* Checks if an exercise is compatible with the user's selected granular equipments
|
|
185
|
-
*
|
|
186
|
-
* - If the exercise has no granular equipments, it is compatible no matter what the user has selected
|
|
187
|
-
* - Otherwise, the exercise is only allowed if the user has all the granular equipments
|
|
188
|
-
*/
|
|
189
|
-
export declare const isEquipmentCompatible: (exercise: HevyTrainerLibraryExercise, userSelectedGranularEquipments: GranularEquipment[]) => boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Sorts exercises by priority for each muscle group based on the provided priorities
|
|
192
|
-
* and adds any remaining exercises from the store that weren't in the priorities.
|
|
193
|
-
*
|
|
194
|
-
* @param exercisePriorities - Object mapping muscle groups to arrays of exercise IDs in priority order
|
|
195
|
-
* @param exerciseStore - Array of all available exercises
|
|
196
|
-
* @returns Object mapping muscle groups to arrays of exercises sorted by priority
|
|
197
|
-
*/
|
|
198
|
-
export declare const getPrioritySortedExercises: <T extends HevyTrainerLibraryExercise>(exercisePriorities: ExercisePriorities, exerciseStore: T[]) => Record<MuscleGroup, T[]>;
|
|
199
|
-
/**
|
|
200
|
-
* Selects the best exercise for a given prescription using a multi-pass strategy
|
|
201
|
-
*/
|
|
202
|
-
type PickExerciseResult<T extends HevyTrainerLibraryExercise> = {
|
|
203
|
-
exercise?: T;
|
|
204
|
-
trace: ExerciseSelectionTrace;
|
|
205
|
-
};
|
|
206
|
-
export declare function pickExerciseForPrescription<T extends HevyTrainerLibraryExercise>(params: ExerciseSelectionParams<T> & {
|
|
207
|
-
withTrace: true;
|
|
208
|
-
}): PickExerciseResult<T>;
|
|
209
|
-
export declare function pickExerciseForPrescription<T extends HevyTrainerLibraryExercise>(params: ExerciseSelectionParams<T>): T | undefined;
|
|
210
|
-
export type HevyTrainerLibraryExercise = Pick<LibraryExercise, 'id' | 'title' | 'priority' | 'muscle_group' | 'other_muscles' | 'exercise_type' | 'equipment_category' | 'category' | 'level' | 'goal' | 'granular_equipments'>;
|
|
211
|
-
export interface ExercisePrescriptionError {
|
|
212
|
-
type: 'exercise_not_found';
|
|
213
|
-
prescription: ExercisePrescription;
|
|
214
|
-
muscleGroup: MuscleGroup;
|
|
215
|
-
context: {
|
|
216
|
-
goal: TrainingGoal;
|
|
217
|
-
level: TrainingLevel;
|
|
218
|
-
equipments: GranularEquipment[];
|
|
219
|
-
focusMuscle?: SimplifiedMuscleGroup;
|
|
220
|
-
};
|
|
221
|
-
}
|
|
222
|
-
export interface TrainerProgramExerciseResult {
|
|
223
|
-
success: true;
|
|
224
|
-
exercise: TrainerProgramExercise;
|
|
225
|
-
}
|
|
226
|
-
export interface TrainerProgramExerciseError {
|
|
227
|
-
success: false;
|
|
228
|
-
error: ExercisePrescriptionError;
|
|
229
|
-
}
|
|
230
|
-
export type TrainerProgramExerciseAttempt = TrainerProgramExerciseResult | TrainerProgramExerciseError;
|
|
231
|
-
export interface TrainerProgramResult {
|
|
232
|
-
success: true;
|
|
233
|
-
program: TrainerProgram;
|
|
234
|
-
}
|
|
235
|
-
export interface TrainerProgramError {
|
|
236
|
-
success: false;
|
|
237
|
-
errors: ExercisePrescriptionError[];
|
|
238
|
-
partialProgram: TrainerProgram;
|
|
239
|
-
}
|
|
240
|
-
export type TrainerProgramAttempt = TrainerProgramResult | TrainerProgramError;
|
|
241
|
-
/**
|
|
242
|
-
* Generates a complete training program based on the provided parameters
|
|
243
|
-
* - debugExerciseSelectionTrace: true -> includes exercise selection trace breadcrumbs in the result for debugging.
|
|
244
|
-
* - debugExerciseSelectionTrace: false -> no exercise selection trace breadcrumbs in the result.
|
|
245
|
-
*/
|
|
246
|
-
export declare function generateProgram<T extends HevyTrainerLibraryExercise>(params: ProgramGenerationParams<T> & {
|
|
247
|
-
debugExerciseSelectionTrace: true;
|
|
248
|
-
}): TrainerProgramAttemptWithTraces;
|
|
249
|
-
export declare function generateProgram<T extends HevyTrainerLibraryExercise>(params: ProgramGenerationParams<T>): TrainerProgramAttempt;
|
|
250
|
-
export {};
|