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.
Files changed (88) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +21 -0
  3. package/.github/workflows/ci.yml +15 -0
  4. package/.github/workflows/npm-publish.yml +59 -0
  5. package/.github/workflows/pr-auto-assign.yml +15 -0
  6. package/.prettierrc.js +5 -0
  7. package/README.md +2 -17
  8. package/built/chat.d.ts +23 -25
  9. package/built/coachPlans.d.ts +1 -2
  10. package/built/coachPlans.js +2 -2
  11. package/built/filterExercises.d.ts +3 -19
  12. package/built/filterExercises.js +60 -72
  13. package/built/index.d.ts +304 -1140
  14. package/built/index.js +75 -269
  15. package/built/setIndicatorUtils.d.ts +3 -4
  16. package/built/setIndicatorUtils.js +1 -15
  17. package/built/tests/utils.test.js +0 -748
  18. package/built/tests/workoutVolume.test.js +49 -165
  19. package/built/units.d.ts +7 -14
  20. package/built/units.js +14 -24
  21. package/built/utils.d.ts +5 -192
  22. package/built/utils.js +85 -598
  23. package/built/websocket.d.ts +2 -14
  24. package/built/workoutVolume.d.ts +5 -24
  25. package/built/workoutVolume.js +34 -25
  26. package/jest.config.js +4 -0
  27. package/package.json +10 -32
  28. package/src/chat.ts +130 -0
  29. package/src/coachPlans.ts +57 -0
  30. package/src/constants.ts +14 -0
  31. package/src/filterExercises.ts +222 -0
  32. package/src/index.ts +1576 -0
  33. package/src/setIndicatorUtils.ts +137 -0
  34. package/src/tests/utils.test.ts +156 -0
  35. package/src/tests/workoutVolume.test.ts +93 -0
  36. package/src/units.ts +41 -0
  37. package/src/utils.ts +516 -0
  38. package/src/websocket.ts +36 -0
  39. package/src/workoutVolume.ts +175 -0
  40. package/tsconfig.json +70 -0
  41. package/built/API/APIClient.d.ts +0 -157
  42. package/built/API/APIClient.js +0 -381
  43. package/built/API/index.d.ts +0 -2
  44. package/built/API/index.js +0 -18
  45. package/built/API/types.d.ts +0 -38
  46. package/built/API/types.js +0 -18
  47. package/built/adjustEventTokens.d.ts +0 -16
  48. package/built/adjustEventTokens.js +0 -18
  49. package/built/adminPermissions.d.ts +0 -4
  50. package/built/adminPermissions.js +0 -22
  51. package/built/async.d.ts +0 -50
  52. package/built/async.js +0 -170
  53. package/built/cue.d.ts +0 -12
  54. package/built/cue.js +0 -22
  55. package/built/exerciseLocaleUtils.d.ts +0 -17
  56. package/built/exerciseLocaleUtils.js +0 -62
  57. package/built/hevyTrainer.d.ts +0 -250
  58. package/built/hevyTrainer.js +0 -676
  59. package/built/muscleHeatmaps.d.ts +0 -31
  60. package/built/muscleHeatmaps.js +0 -68
  61. package/built/muscleSplits.d.ts +0 -36
  62. package/built/muscleSplits.js +0 -100
  63. package/built/normalizedWorkoutUtils.d.ts +0 -88
  64. package/built/normalizedWorkoutUtils.js +0 -112
  65. package/built/notifications.d.ts +0 -215
  66. package/built/notifications.js +0 -9
  67. package/built/routineUtils.d.ts +0 -14
  68. package/built/routineUtils.js +0 -186
  69. package/built/schemas.d.ts +0 -6
  70. package/built/schemas.js +0 -12
  71. package/built/tests/async.test.d.ts +0 -1
  72. package/built/tests/async.test.js +0 -49
  73. package/built/tests/hevyTrainer.test.d.ts +0 -1
  74. package/built/tests/hevyTrainer.test.js +0 -1199
  75. package/built/tests/muscleSplit.test.d.ts +0 -1
  76. package/built/tests/muscleSplit.test.js +0 -153
  77. package/built/tests/routineUtils.test.d.ts +0 -1
  78. package/built/tests/routineUtils.test.js +0 -745
  79. package/built/tests/testUtils.d.ts +0 -85
  80. package/built/tests/testUtils.js +0 -319
  81. package/built/translations/index.d.ts +0 -2
  82. package/built/translations/index.js +0 -18
  83. package/built/translations/translationUtils.d.ts +0 -2
  84. package/built/translations/translationUtils.js +0 -61
  85. package/built/translations/types.d.ts +0 -8
  86. package/built/translations/types.js +0 -20
  87. package/built/typeUtils.d.ts +0 -70
  88. package/built/typeUtils.js +0 -55
@@ -2,184 +2,68 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const workoutVolume_1 = require("../workoutVolume");
4
4
  describe('workoutVolume', () => {
5
- describe('estimatedWorkoutVolumeKg', () => {
6
- it('calculates the correct workout volume', () => {
7
- const emptyWorkout = {
8
- exercises: [],
9
- include_warmup_sets: true,
5
+ describe('workoutVolumeSetsVolumeKg', () => {
6
+ it('calculated the correct workout volume', () => {
7
+ const weightRepsSet = {
8
+ type: 'weight_reps',
9
+ exerciseTemplateId: 'asd',
10
+ weightKg: 100,
11
+ reps: 10,
12
+ distanceMeters: 0,
10
13
  };
11
- const weightRepsWorkout = {
12
- exercises: [
13
- {
14
- exercise_type: 'weight_reps',
15
- exercise_template_id: 'asd',
16
- volume_doubling_enabled: false,
17
- hundred_percent_bodyweight_exercise: false,
18
- sets: [
19
- {
20
- indicator: 'normal',
21
- weight_kg: 100,
22
- reps: 10,
23
- distance_meters: 0,
24
- },
25
- ],
26
- },
27
- ],
28
- include_warmup_sets: true,
14
+ const pullUpSet = {
15
+ type: 'reps_only',
16
+ exerciseTemplateId: '1B2B1E7C',
17
+ weightKg: 0,
18
+ reps: 10,
19
+ distanceMeters: 0,
29
20
  };
30
- const pullUpWorkout = {
31
- exercises: [
32
- {
33
- exercise_type: 'reps_only',
34
- exercise_template_id: '1B2B1E7C', // Pull Up
35
- volume_doubling_enabled: false,
36
- hundred_percent_bodyweight_exercise: true,
37
- sets: [
38
- {
39
- indicator: 'normal',
40
- weight_kg: 0,
41
- reps: 10,
42
- distance_meters: 0,
43
- },
44
- ],
45
- },
46
- ],
47
- include_warmup_sets: true,
21
+ const assistedPullUpSet = {
22
+ type: 'bodyweight_assisted_reps',
23
+ exerciseTemplateId: '2C37EC5E',
24
+ weightKg: 10,
25
+ reps: 10,
26
+ distanceMeters: 0,
48
27
  };
49
- const assistedPullUpWorkout = {
50
- exercises: [
51
- {
52
- exercise_type: 'bodyweight_assisted_reps',
53
- exercise_template_id: '2C37EC5E', // Pull Up (Assisted)
54
- volume_doubling_enabled: false,
55
- hundred_percent_bodyweight_exercise: true,
56
- sets: [
57
- {
58
- indicator: 'normal',
59
- weight_kg: 10,
60
- reps: 10,
61
- distance_meters: 0,
62
- },
63
- ],
64
- },
65
- ],
66
- include_warmup_sets: true,
28
+ const weightedPullUpSet = {
29
+ type: 'bodyweight_reps',
30
+ exerciseTemplateId: '729237D1',
31
+ weightKg: 10,
32
+ reps: 10,
33
+ distanceMeters: 0,
67
34
  };
68
- const weightedPullUpWorkout = {
69
- exercises: [
70
- {
71
- exercise_type: 'bodyweight_reps',
72
- exercise_template_id: '729237D1', // Pull Up (Weighted)
73
- volume_doubling_enabled: false,
74
- hundred_percent_bodyweight_exercise: true,
75
- sets: [
76
- {
77
- indicator: 'normal',
78
- weight_kg: 10,
79
- reps: 10,
80
- distance_meters: 0,
81
- },
82
- ],
83
- },
84
- ],
85
- include_warmup_sets: true,
35
+ const shortDistanceWeight = {
36
+ type: 'short_distance_weight',
37
+ exerciseTemplateId: 'asd',
38
+ weightKg: 100,
39
+ reps: 0,
40
+ distanceMeters: 10,
86
41
  };
87
- const shortDistanceWeightWorkout = {
88
- exercises: [
89
- {
90
- exercise_type: 'short_distance_weight',
91
- exercise_template_id: 'asd',
92
- volume_doubling_enabled: false,
93
- hundred_percent_bodyweight_exercise: false,
94
- sets: [
95
- {
96
- indicator: 'normal',
97
- weight_kg: 100,
98
- reps: 0,
99
- distance_meters: 10,
100
- },
101
- ],
102
- },
103
- ],
104
- include_warmup_sets: true,
105
- };
106
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
107
- bodyweightKg: 100,
108
- workout: emptyWorkout,
109
- })).toBe(0);
110
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
111
- bodyweightKg: 100,
112
- workout: weightRepsWorkout,
113
- })).toBe(1000);
114
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
42
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({ bodyweightKg: 100, sets: [] })).toBe(0);
43
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({ bodyweightKg: 100, sets: [weightRepsSet] })).toBe(1000);
44
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({ bodyweightKg: 100, sets: [pullUpSet] })).toBe(1000);
45
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({
115
46
  bodyweightKg: 100,
116
- workout: pullUpWorkout,
117
- })).toBe(1000);
118
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
119
- bodyweightKg: 100,
120
- workout: assistedPullUpWorkout,
47
+ sets: [assistedPullUpSet],
121
48
  })).toBe(900);
122
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
49
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({
123
50
  bodyweightKg: 100,
124
- workout: weightedPullUpWorkout,
51
+ sets: [weightedPullUpSet],
125
52
  })).toBe(1100);
126
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
53
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({
127
54
  bodyweightKg: 100,
128
- workout: shortDistanceWeightWorkout,
55
+ sets: [shortDistanceWeight],
129
56
  })).toBe(1000);
130
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
57
+ expect((0, workoutVolume_1.workoutVolumeSetsVolumeKg)({
131
58
  bodyweightKg: 100,
132
- workout: {
133
- exercises: [
134
- ...weightRepsWorkout.exercises,
135
- ...pullUpWorkout.exercises,
136
- ...assistedPullUpWorkout.exercises,
137
- ...weightedPullUpWorkout.exercises,
138
- ...shortDistanceWeightWorkout.exercises,
139
- ],
140
- include_warmup_sets: true,
141
- },
142
- })).toBe(5000);
143
- });
144
- it('takes warmup sets into account only if `include_warmup_sets` === `true`', () => {
145
- const workoutWithWarmupSets = {
146
- exercises: [
147
- {
148
- exercise_type: 'weight_reps',
149
- exercise_template_id: 'asd',
150
- volume_doubling_enabled: false,
151
- hundred_percent_bodyweight_exercise: false,
152
- sets: [
153
- {
154
- indicator: 'warmup',
155
- weight_kg: 100,
156
- reps: 10,
157
- distance_meters: 0,
158
- },
159
- {
160
- indicator: 'normal',
161
- weight_kg: 100,
162
- reps: 10,
163
- distance_meters: 0,
164
- },
165
- {
166
- indicator: 'normal',
167
- weight_kg: 100,
168
- reps: 10,
169
- distance_meters: 0,
170
- },
171
- ],
172
- },
59
+ sets: [
60
+ weightRepsSet,
61
+ pullUpSet,
62
+ assistedPullUpSet,
63
+ weightedPullUpSet,
64
+ shortDistanceWeight,
173
65
  ],
174
- };
175
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
176
- bodyweightKg: 100,
177
- workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: false }),
178
- })).toBe(2000);
179
- expect((0, workoutVolume_1.estimatedWorkoutVolumeKg)({
180
- bodyweightKg: 100,
181
- workout: Object.assign(Object.assign({}, workoutWithWarmupSets), { include_warmup_sets: true }),
182
- })).toBe(3000);
66
+ })).toBe(5000);
183
67
  });
184
68
  });
185
69
  });
package/built/units.d.ts CHANGED
@@ -1,23 +1,16 @@
1
1
  export declare const POUNDS_IN_KG = 2.20462;
2
2
  export declare const CM_IN_INCH = 2.54;
3
+ export declare const METERS_IN_YARD = 0.9144;
4
+ export declare const KILOMETERS_IN_MILE = 1.60934;
5
+ export declare const YARDS_IN_A_MILE = 1760;
3
6
  export declare const METERS_IN_MILE = 1609.34;
7
+ export declare const roundToTwoDecimal: (value: number) => number;
8
+ export declare const roundToOneDecimal: (value: number) => number;
9
+ export declare const roundToWholeNumber: (value: number) => number;
4
10
  export declare const exactLbsToKg: (value: number) => number;
5
11
  export declare const exactKgtoLbs: (value: number) => number;
6
12
  export declare const exactInchtoCm: (value: number) => number;
7
13
  export declare const exactCmtoInch: (value: number) => number;
14
+ export declare const exactMetersToYards: (value: number) => number;
8
15
  export declare const exactMilesToMeters: (value: number) => number;
9
16
  export declare const exactMetersToMiles: (meters: number) => number;
10
- export interface FtIn {
11
- ft: number;
12
- in: number;
13
- }
14
- export declare const roundedCmToFtIn: (cm: number) => {
15
- ft: number;
16
- in: number;
17
- };
18
- export declare const exactFtInToCm: (ftIn: FtIn) => number;
19
- /**
20
- * Round kilo- to deci- (e.g. kilograms/kg to decigrams/dg). Used for comparing
21
- * weight values in kg which may have originated in lbs.
22
- */
23
- export declare const roundKtoD: (value: number) => number;
package/built/units.js CHANGED
@@ -1,9 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundKtoD = exports.exactFtInToCm = exports.roundedCmToFtIn = exports.exactMetersToMiles = exports.exactMilesToMeters = exports.exactCmtoInch = exports.exactInchtoCm = exports.exactKgtoLbs = exports.exactLbsToKg = exports.METERS_IN_MILE = exports.CM_IN_INCH = exports.POUNDS_IN_KG = void 0;
3
+ exports.exactMetersToMiles = exports.exactMilesToMeters = exports.exactMetersToYards = exports.exactCmtoInch = exports.exactInchtoCm = exports.exactKgtoLbs = exports.exactLbsToKg = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.METERS_IN_MILE = exports.YARDS_IN_A_MILE = exports.KILOMETERS_IN_MILE = exports.METERS_IN_YARD = exports.CM_IN_INCH = exports.POUNDS_IN_KG = void 0;
4
4
  exports.POUNDS_IN_KG = 2.20462;
5
5
  exports.CM_IN_INCH = 2.54;
6
+ exports.METERS_IN_YARD = 0.9144;
7
+ exports.KILOMETERS_IN_MILE = 1.60934;
8
+ exports.YARDS_IN_A_MILE = 1760;
6
9
  exports.METERS_IN_MILE = 1609.34;
10
+ const roundToTwoDecimal = (value) => Math.round(value * 100) / 100;
11
+ exports.roundToTwoDecimal = roundToTwoDecimal;
12
+ const roundToOneDecimal = (value) => Math.round(value * 10) / 10;
13
+ exports.roundToOneDecimal = roundToOneDecimal;
14
+ const roundToWholeNumber = (value) => Math.round(value);
15
+ exports.roundToWholeNumber = roundToWholeNumber;
7
16
  const exactLbsToKg = (value) => {
8
17
  return value / exports.POUNDS_IN_KG;
9
18
  };
@@ -20,6 +29,10 @@ const exactCmtoInch = (value) => {
20
29
  return value / exports.CM_IN_INCH;
21
30
  };
22
31
  exports.exactCmtoInch = exactCmtoInch;
32
+ const exactMetersToYards = (value) => {
33
+ return value / exports.METERS_IN_YARD;
34
+ };
35
+ exports.exactMetersToYards = exactMetersToYards;
23
36
  const exactMilesToMeters = (value) => {
24
37
  return value * exports.METERS_IN_MILE;
25
38
  };
@@ -28,26 +41,3 @@ const exactMetersToMiles = (meters) => {
28
41
  return meters / exports.METERS_IN_MILE;
29
42
  };
30
43
  exports.exactMetersToMiles = exactMetersToMiles;
31
- const roundedCmToFtIn = (cm) => {
32
- const totalInches = (0, exports.exactCmtoInch)(cm);
33
- const feet = Math.floor(totalInches / 12);
34
- const inches = Math.round(totalInches % 12);
35
- if (inches === 12) {
36
- return { ft: feet + 1, in: 0 };
37
- }
38
- else {
39
- return { ft: feet, in: inches };
40
- }
41
- };
42
- exports.roundedCmToFtIn = roundedCmToFtIn;
43
- const exactFtInToCm = (ftIn) => {
44
- const totalInches = ftIn.ft * 12 + ftIn.in;
45
- return Math.round((0, exports.exactInchtoCm)(totalInches));
46
- };
47
- exports.exactFtInToCm = exactFtInToCm;
48
- /**
49
- * Round kilo- to deci- (e.g. kilograms/kg to decigrams/dg). Used for comparing
50
- * weight values in kg which may have originated in lbs.
51
- */
52
- const roundKtoD = (value) => Math.round(value * 10000);
53
- exports.roundKtoD = roundKtoD;
package/built/utils.d.ts CHANGED
@@ -1,25 +1,12 @@
1
- import { Dayjs } from 'dayjs';
2
- import { BaseExerciseTemplate, DistanceUnit, ExerciseInstructionsStep, ExerciseType, FormatAtText, Result, SetType, StrengthLevel, UserExerciseSet, UserFacingSetIndicator, Weekday, WeightUnit } from '.';
1
+ import { CustomExercise, ExerciseTemplate } from '.';
3
2
  /**
4
3
  * Doesn't matter what you throw in the function it'll
5
4
  * always return a number. Non number values will return
6
5
  * 0.
7
6
  */
8
7
  export declare const num: (value?: any) => number;
9
- export declare const clampNumber: (value: number, limits: {
10
- min?: number;
11
- max?: number;
12
- }) => number;
13
8
  export declare const divide: (numerator: number, denominator: number) => number;
14
- export declare const roundToTwoDecimal: (value: number) => number;
15
- export declare const roundToOneDecimal: (value: number) => number;
16
- export declare const roundToWholeNumber: (value: number) => number;
17
9
  export declare const isValidUsername: (username: string) => boolean;
18
- export declare const secondsToClockParts: (totalSeconds: number) => {
19
- hours: number;
20
- minutes: number;
21
- seconds: number;
22
- };
23
10
  /**
24
11
  * 01:25
25
12
  * 02:25:36
@@ -34,19 +21,9 @@ export declare const secondsToWordFormat: (seconds: number) => string;
34
21
  /**
35
22
  * 14min
36
23
  * 2h 4min
37
- * 2h 0min
38
24
  */
39
25
  export declare const secondsToWordFormatMinutes: (seconds: number) => string;
40
26
  export declare const isValidEmail: (email: string) => boolean;
41
- /**
42
- * Matches strings with a base format of `domain.tld`.
43
- * - `domain` may contain letters, digits and dashes, but it can't begin or
44
- * end with a dash
45
- * - `domain` may be prefixed once or multiple times with another `domain.`
46
- * - `tld` may be followed by `/path-to-page`
47
- * - the entire string may be prefixed by `https://` or `http://`
48
- */
49
- export declare const URL_REGEX: RegExp;
50
27
  export declare const isValidWebUrl: (url: string) => boolean;
51
28
  /**
52
29
  * Check if a string is a valid phone number. A valid phone number is a string
@@ -64,13 +41,7 @@ export declare const isValidWebUrl: (url: string) => boolean;
64
41
  * +1234567890123456
65
42
  */
66
43
  export declare const isValidPhoneNumber: (phoneNumber: string) => boolean;
67
- /**
68
- * Matches all UUID types, case-insensitive (matches both uppercase and
69
- * lowercase hexadecimal digits).
70
- */
71
- export declare const isValidUuid: (uuid: string) => boolean;
72
- export declare const isNumber: (x: any) => x is number;
73
- export declare const isWholeNumber: (value: number) => boolean;
44
+ export declare const customExerciseTemplateToExerciseTemplate: (cet: CustomExercise) => ExerciseTemplate;
74
45
  /**
75
46
  * Return true is value is of format: NN:NN or NN:NN:NN
76
47
  */
@@ -84,63 +55,7 @@ export declare const forceStringToNumber: (value?: string) => number;
84
55
  * Returns a number or undefined
85
56
  */
86
57
  export declare const stringToNumber: (value?: string) => number | undefined;
87
- /**
88
- * Returns the first non-undefined value produced by transform function being
89
- * applied to elements of the array in iteration order, or `undefined` if no
90
- * such value was produced. Equivalent to `firstNotNullOfOrNull` in Kotlin.
91
- */
92
- export declare const findMapped: <T, R>(array: T[], transform: (element: T) => R) => R | undefined;
93
- /**
94
- * converts any array into an array of JSON chunks with a maximum given length
95
- * @param data an array of objects or primitives to be split into chunks
96
- * @param maxLength maximum length of any single returned JSON string
97
- * @returns an array of JSON strings, each one no longer than `maxLength`
98
- * @throws an error if fragmentation is impossible due to input data structure
99
- */
100
- export declare const toFragmentedJSON: <T>(data: T[], maxLength: number, options?: {
101
- lengthIn: "utf8bytes" | "characters";
102
- }) => string[];
103
- /**
104
- * Finds the closest data point that occurs before or at the target date using binary search.
105
- * Assumes input array is sorted by date in ascending order.
106
- *
107
- * @param data - Array of items containing dates in ascending order
108
- * @param dateExtractor - Function to extract Date from each item
109
- * @param targetDate - Target date to search for
110
- * @returns The closest item before or at the target date, or undefined if not found
111
- *
112
- * @example
113
- * const data = [
114
- * { id: 1, date: dayjs('2023-01-01').toDate() },
115
- * { id: 2, date: dayjs('2023-04-01').toDate() }
116
- * ];
117
- * const result = getClosestDataPointBeforeTargetDate(
118
- * data,
119
- * item => item.date,
120
- * dayjs('2023-03-15').toDate(),
121
- * ); // Returns { id: 1, date: Date('2023-01-01') }
122
- */
123
58
  export declare const getClosestDataPointBeforeTargetDate: <T>(data: T[], dateExtractor: (item: T) => Date, targetDate: Date) => T | undefined;
124
- /**
125
- * Finds the closest data point to the target date.
126
- *
127
- * @param data - Array of items containing dates
128
- * @param dateExtractor - Function to extract Date from each item
129
- * @param targetDate - Target date to search for
130
- * @returns The closest item to the target date, or undefined if array is empty
131
- *
132
- * @example
133
- * const data = [
134
- * { id: 1, date: dayjs('2023-01-01').toDate() },
135
- * { id: 2, date: dayjs('2023-04-01').toDate() }
136
- * ];
137
- * const result = getClosestDataPoint(
138
- * data,
139
- * item => item.date,
140
- * dayjs('2023-03-15').toDate(),
141
- * ); // Returns { id: 2, date: Date('2023-04-01') }
142
- */
143
- export declare const getClosestDataPointAroundTargetDate: <T>(data: T[], dateExtractor: (item: T) => Date, targetDate: Date) => T | undefined;
144
59
  export declare const removeAccents: (str: string) => string;
145
60
  /**
146
61
  * Calculate the total duration of a workout in seconds
@@ -180,115 +95,13 @@ export interface TotalSetCountWorkout {
180
95
  sets: Array<any>;
181
96
  }>;
182
97
  }
183
- /**
184
- * Calculate the set weight for a given user exercise set
185
- * to be used in the exercise stats calculations on the web and coach app
186
- */
187
- export declare const userExerciseSetWeight: (set: UserExerciseSet, exerciseStore: BaseExerciseTemplate[], hundredPercentBodyweightExercise: boolean) => number;
188
98
  export declare const workoutSetCount: (w: TotalSetCountWorkout) => number;
189
- export declare const UserFacingIndicatorToSetIndicator: (indicator: UserFacingSetIndicator) => SetType;
190
- interface GetEstimatedExercisesDuration {
191
- exercises: {
192
- rest_seconds: number | null;
193
- exercise_type: ExerciseType;
194
- sets: {
195
- duration_seconds?: number | null;
196
- indicator: SetType;
197
- }[];
198
- }[];
199
- }
200
- export declare const ESTIMATED_SET_DURATION = 45;
201
- export declare const ESTIMATED_REST_TIMER_DURATION = 90;
202
- export declare const getEstimatedExercisesDurationSeconds: ({ exercises, }: GetEstimatedExercisesDuration) => number;
203
99
  export declare const oneRepMaxPercentageMap: {
204
100
  [s: number]: number;
205
101
  };
206
102
  export declare const oneRepMax: (weight: number, reps: number) => number;
207
103
  export declare const setVolume: (weight: number, reps: number) => number;
208
- /** @deprecated use `numberToLocaleString` */
209
104
  export declare const numberWithCommas: (x: number) => string;
210
- /**
211
- * Formats a number into a string, accounting for the system locale.
212
- *
213
- * @example
214
- * numberToLocaleString(1234.567) === '1,234.567' // English (UK / US)
215
- * numberToLocaleString(1234.567) === '1.234,567' // German (Germany)
216
- * numberToLocaleString(1234.567) === '1 234,567' // French (France)
217
- */
218
- export declare const numberToLocaleString: (value: number, options?: {
219
- maximumFractionDigits?: number;
220
- }) => string;
221
- export declare const getStrengthLevelFromPercentile: (percentile: number) => StrengthLevel;
222
- export declare const isBaseExerciseTemplate: (x: any) => x is BaseExerciseTemplate;
223
- type GenerateUserGroupError = 'invalid-number-of-groups' | 'invalid-uuid' | 'uuid-not-v4' | 'invalid-variant';
224
- /**
225
- * Generates a subsample or test group given a user id. Technically, it just
226
- * calculates a trivial checksum of the last (random) part of a v4 UUID.
227
- * @param userId a v4 UUID; _must_ be v4 to ensure random distribution
228
- * @param numGroups number of possible groups, from 2 to 2^32
229
- * @returns a number in the `[0, numGroups)` range, always equal for a given
230
- * `(userId, numGroups)` pair, or an error, inside a Result<T> object
231
- */
232
- export declare const generateUserGroup: (userId: string, numGroups: number) => Result<number, GenerateUserGroupError>;
233
- /**
234
- * Get the user group value for a given user id and number of groups.
235
- * @param userId a v4 UUID; _must_ be v4 to ensure random distribution
236
- * @param numGroups number of possible groups, from 2 to 2^32
237
- * @returns User group value (A, B, C, etc.), or undefined if the user id is not a v4 UUID
238
- * or if an error occurs.
239
- */
240
- export declare const generateUserGroupValue: (userId: string, numGroups: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10) => "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | undefined;
241
- /**
242
- * @example
243
- * isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2') // true
244
- * isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2.2') // true
245
- * isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2.3') // true
246
- *
247
- * isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2.4') // false
248
- * isVersionAGreaterOrEqualToVersionB('1.2.3', '1.3') // false
249
- */
250
- export declare const isVersionAGreaterOrEqualToVersionB: (versionA: string, versionB: string) => boolean;
251
- export declare const splitAtUsernamesAndLinks: (text: string) => FormatAtText[];
252
- export declare const validateYoutubeUrl: (url: string) => boolean;
253
- export declare const getYoutubeVideoId: (url: string) => string | undefined;
254
- /**@param workouts must be sorted descending by start_time */
255
- export declare const calculateCurrentWeekStreak: (workouts: {
256
- start_time: number;
257
- }[], firstWeekday: Weekday, untilUnix?: number) => number;
258
- export declare const startOfWeek: (d: Dayjs, firstDayOfWeek: Weekday) => Dayjs;
259
- export declare const weekdayNumberMap: {
260
- [key in Weekday]: number;
261
- };
262
- export declare const distance: (value: number, distanceUnit: DistanceUnit) => number;
263
- export declare const exerciseWeight: (value: number, weightUnit: WeightUnit) => number;
264
- interface getSetValueParams {
265
- exerciseType: ExerciseType;
266
- set: {
267
- weight_kg: number | null;
268
- reps: number | null;
269
- duration_seconds: number | null;
270
- distance_meters: number | null;
271
- custom_metric: number | null;
272
- };
273
- units: {
274
- weight: WeightUnit;
275
- distance: DistanceUnit;
276
- };
277
- lokalizedLabels: {
278
- kg: string;
279
- lbs: string;
280
- km: string;
281
- mi: string;
282
- m: string;
283
- yd: string;
284
- steps: string;
285
- floors: string;
286
- };
287
- }
288
- export declare const formatSetValue: ({ exerciseType, set, units, lokalizedLabels, }: getSetValueParams) => string;
289
- export declare const rawInstructionsToIndexedSteps: (rawInstructions: string) => ExerciseInstructionsStep[];
290
- export declare const roundToKnownValue: (value: number, knownValues: number[]) => number | undefined;
291
- export declare const indexByNearestValue: <T>(value: number, map: {
292
- [key: number]: T;
293
- }) => T | undefined;
294
- export {};
105
+ export declare const comparableExerciseTemplateIds: Set<string>;
106
+ export declare const isCompareExerciseSupported: (temlpateId: string) => boolean;
107
+ export declare const isExerciseTemplate: (x: any) => x is ExerciseTemplate;