hevy-shared 1.0.604 → 1.0.605
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/built/index.d.ts +1 -10
- package/built/index.js +1 -8
- package/built/tests/utils.test.js +12 -0
- package/built/utils.d.ts +8 -0
- package/built/utils.js +31 -5
- package/package.json +1 -1
package/built/index.d.ts
CHANGED
|
@@ -579,12 +579,6 @@ export declare const isExerciseType: (x: any) => x is ExerciseType;
|
|
|
579
579
|
export type CustomExerciseType = Exclude<ExerciseType, 'floors_duration' | 'steps_duration'>;
|
|
580
580
|
export declare const customExericseTypes: CustomExerciseType[];
|
|
581
581
|
export declare const isCustomExerciseType: (x: any) => x is CustomExerciseType;
|
|
582
|
-
export declare const trainingGoals: readonly ["strength", "build_muscle", "fat_loss"];
|
|
583
|
-
export declare const trainingLevels: readonly ["beginner", "intermediate", "advanced"];
|
|
584
|
-
export declare const exerciseCategories: readonly ["isolation", "compound", "assistance-compound"];
|
|
585
|
-
export type TrainingGoal = Lookup<typeof trainingGoals>;
|
|
586
|
-
export type TrainingLevel = Lookup<typeof trainingLevels>;
|
|
587
|
-
export type ExerciseCategory = Lookup<typeof exerciseCategories>;
|
|
588
582
|
/**
|
|
589
583
|
* Base properties that all exercise templates must have
|
|
590
584
|
*/
|
|
@@ -631,9 +625,6 @@ export interface LibraryExercise extends BaseExerciseTemplate {
|
|
|
631
625
|
localised_instructions?: {
|
|
632
626
|
[language in InstructionsLanguage]?: string;
|
|
633
627
|
};
|
|
634
|
-
goal: TrainingGoal[] | undefined;
|
|
635
|
-
level: TrainingLevel[] | undefined;
|
|
636
|
-
category: ExerciseCategory | undefined;
|
|
637
628
|
}
|
|
638
629
|
/**
|
|
639
630
|
* Custom exercises are user-created templates with minimal properties
|
|
@@ -1598,7 +1589,7 @@ export interface CancelSubscriptionFeedback extends BaseFeedback {
|
|
|
1598
1589
|
};
|
|
1599
1590
|
}
|
|
1600
1591
|
export type Feedback = GeneralFeedback | FeatureRequestFeedback | BugReportFeedback | GetHelpFeedback | ReportCommentFeedback | ReportWorkoutFeedback | ReportProfileFeedback | RatingPromptFeedback | CancelSubscriptionFeedback;
|
|
1601
|
-
export type SuggestedUserSource = 'popular' | 'local' | 'contact' | 'mutual_follows' | 'follows_you' | 'featured';
|
|
1592
|
+
export type SuggestedUserSource = 'popular' | 'local' | 'contact' | 'mutual_follows' | 'follows_you' | 'featured' | 'hyper_local';
|
|
1602
1593
|
export type SuggestedUserLabel = 'contact' | 'mutual_friends' | 'follows_you' | 'featured';
|
|
1603
1594
|
export interface SuggestedUser {
|
|
1604
1595
|
id: string;
|
package/built/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isWorkoutBiometrics = exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.
|
|
17
|
+
exports.isValidUserWorkoutMetricsType = exports.isBodyMeasurementKey = exports.measurementsList = exports.isWorkoutBiometrics = exports.isHeartRateSamples = exports.isPublicWorkout = exports.isSetType = exports.isRPE = exports.validRpeValues = exports.isSetPersonalRecordType = exports.supportedInstructionsLanguages = exports.isCustomExerciseType = exports.customExericseTypes = exports.isExerciseType = exports.exerciseTypes = exports.isExerciseRepType = exports.exerciseRepTypes = exports.isEquipmentFilter = exports.equipmentFilters = exports.isEquipment = exports.equipments = exports.isMuscleGroupFilter = exports.muscleGroupFilters = exports.isMuscleGroup = exports.muscleGroups = exports.DefaultClientConfiguration = exports.isCoachRole = exports.isErrorResponse = exports.isLivePRVolumeOption = exports.isTimerVolumeOption = exports.isWeekday = exports.orderedWeekdays = exports.isBodyMeasurementUnit = exports.isDistanceUnitShort = exports.isDistanceUnit = exports.isWeightUnit = exports.isLanguage = exports.supportedLanguages = void 0;
|
|
18
18
|
const typeUtils_1 = require("./typeUtils");
|
|
19
19
|
__exportStar(require("./constants"), exports);
|
|
20
20
|
__exportStar(require("./utils"), exports);
|
|
@@ -185,13 +185,6 @@ exports.isExerciseType = isExerciseType;
|
|
|
185
185
|
exports.customExericseTypes = exports.exerciseTypes.filter((type) => type !== 'floors_duration' && type !== 'steps_duration');
|
|
186
186
|
const isCustomExerciseType = (x) => (0, typeUtils_1.isInArray)(x, exports.customExericseTypes);
|
|
187
187
|
exports.isCustomExerciseType = isCustomExerciseType;
|
|
188
|
-
exports.trainingGoals = ['strength', 'build_muscle', 'fat_loss'];
|
|
189
|
-
exports.trainingLevels = ['beginner', 'intermediate', 'advanced'];
|
|
190
|
-
exports.exerciseCategories = [
|
|
191
|
-
'isolation',
|
|
192
|
-
'compound',
|
|
193
|
-
'assistance-compound',
|
|
194
|
-
];
|
|
195
188
|
exports.supportedInstructionsLanguages = [
|
|
196
189
|
'en',
|
|
197
190
|
'it',
|
|
@@ -392,6 +392,18 @@ describe('utils', () => {
|
|
|
392
392
|
{ format: 'link', text: 'https://example.com' },
|
|
393
393
|
],
|
|
394
394
|
],
|
|
395
|
+
[
|
|
396
|
+
'hey Test - https://www.tiktok.com/@tylerpath/video/7471271437467405614 @test',
|
|
397
|
+
[
|
|
398
|
+
{ format: 'none', text: 'hey Test - ' },
|
|
399
|
+
{
|
|
400
|
+
format: 'link',
|
|
401
|
+
text: 'https://www.tiktok.com/@tylerpath/video/7471271437467405614',
|
|
402
|
+
},
|
|
403
|
+
{ format: 'none', text: ' ' },
|
|
404
|
+
{ format: '@', text: '@test' },
|
|
405
|
+
],
|
|
406
|
+
],
|
|
395
407
|
];
|
|
396
408
|
inputOutputs.forEach((i) => {
|
|
397
409
|
expect((0, utils_1.splitAtUsernamesAndLinks)(i[0])).toEqual(i[1]);
|
package/built/utils.d.ts
CHANGED
|
@@ -199,6 +199,14 @@ type GenerateUserGroupError = 'invalid-number-of-groups' | 'invalid-uuid' | 'uui
|
|
|
199
199
|
* `(userId, numGroups)` pair, or an error, inside a Result<T> object
|
|
200
200
|
*/
|
|
201
201
|
export declare const generateUserGroup: (userId: string, numGroups: number) => Result<number, GenerateUserGroupError>;
|
|
202
|
+
/**
|
|
203
|
+
* Get the user group value for a given user id and number of groups.
|
|
204
|
+
* @param userId a v4 UUID; _must_ be v4 to ensure random distribution
|
|
205
|
+
* @param numGroups number of possible groups, from 2 to 2^32
|
|
206
|
+
* @returns User group value (A, B, C, etc.), or undefined if the user id is not a v4 UUID
|
|
207
|
+
* or if an error occurs.
|
|
208
|
+
*/
|
|
209
|
+
export declare const generateUserGroupValue: (userId: string, numGroups: 2 | 3) => "A" | "B" | "C" | undefined;
|
|
202
210
|
/**
|
|
203
211
|
* @example
|
|
204
212
|
* isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2') // true
|
package/built/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
3
|
+
exports.getYoutubeVideoId = exports.validateYoutubeUrl = exports.splitAtUsernamesAndLinks = exports.isVersionAGreaterOrEqualToVersionB = exports.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.workoutSetCount = exports.userExerciseSetWeight = exports.workoutDistanceMeters = exports.workoutReps = exports.workoutDurationSeconds = exports.removeAccents = exports.getClosestDataPointAroundTargetDate = exports.getClosestDataPointBeforeTargetDate = exports.findMapped = exports.stringToNumber = exports.forceStringToNumber = exports.formatDurationInput = exports.isValidFormattedTime = exports.isWholeNumber = exports.isNumber = exports.isValidUuid = exports.isValidPhoneNumber = exports.isValidWebUrl = exports.URL_REGEX = exports.isValidEmail = exports.secondsToWordFormatMinutes = exports.secondsToWordFormat = exports.secondsToClockFormat = exports.isValidUsername = exports.roundToWholeNumber = exports.roundToOneDecimal = exports.roundToTwoDecimal = exports.divide = exports.clampNumber = exports.num = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Doesn't matter what you throw in the function it'll
|
|
6
6
|
* always return a number. Non number values will return
|
|
@@ -542,6 +542,32 @@ const generateUserGroup = (userId, numGroups) => {
|
|
|
542
542
|
};
|
|
543
543
|
};
|
|
544
544
|
exports.generateUserGroup = generateUserGroup;
|
|
545
|
+
/**
|
|
546
|
+
* Get the user group value for a given user id and number of groups.
|
|
547
|
+
* @param userId a v4 UUID; _must_ be v4 to ensure random distribution
|
|
548
|
+
* @param numGroups number of possible groups, from 2 to 2^32
|
|
549
|
+
* @returns User group value (A, B, C, etc.), or undefined if the user id is not a v4 UUID
|
|
550
|
+
* or if an error occurs.
|
|
551
|
+
*/
|
|
552
|
+
const generateUserGroupValue = (userId, numGroups) => {
|
|
553
|
+
const group = (0, exports.generateUserGroup)(userId, numGroups);
|
|
554
|
+
if (group.isSuccess) {
|
|
555
|
+
switch (group.value) {
|
|
556
|
+
case 0:
|
|
557
|
+
return 'A';
|
|
558
|
+
case 1:
|
|
559
|
+
return 'B';
|
|
560
|
+
case 2:
|
|
561
|
+
return 'C';
|
|
562
|
+
default:
|
|
563
|
+
return undefined;
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
};
|
|
570
|
+
exports.generateUserGroupValue = generateUserGroupValue;
|
|
545
571
|
/**
|
|
546
572
|
* @example
|
|
547
573
|
* isVersionAGreaterOrEqualToVersionB('1.2.3', '1.2') // true
|
|
@@ -586,12 +612,12 @@ const splitAtUsernamesAndLinks = (text) => {
|
|
|
586
612
|
if (index > lastIndex) {
|
|
587
613
|
format.push({ format: 'none', text: text.substring(lastIndex, index) });
|
|
588
614
|
}
|
|
589
|
-
if (match.match(
|
|
590
|
-
format.push({ format: '@', text: match });
|
|
591
|
-
}
|
|
592
|
-
else if (match.match(linksRegex)) {
|
|
615
|
+
if (match.match(linksRegex)) {
|
|
593
616
|
format.push({ format: 'link', text: match });
|
|
594
617
|
}
|
|
618
|
+
else if (match.match(mentionsRegex)) {
|
|
619
|
+
format.push({ format: '@', text: match });
|
|
620
|
+
}
|
|
595
621
|
lastIndex = index + match.length;
|
|
596
622
|
});
|
|
597
623
|
if (lastIndex < text.length) {
|