hevy-shared 1.0.829 → 1.0.830

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 CHANGED
@@ -321,6 +321,11 @@ export interface BackofficeAccountUpdate {
321
321
  /** `null` means we're unlinking the user's Gympass account */
322
322
  gympass_email?: string | null;
323
323
  gympass_subscription_active?: boolean;
324
+ gympass_account?: {
325
+ id: string;
326
+ email: string;
327
+ country_code?: string;
328
+ };
324
329
  limited_discovery?: boolean;
325
330
  delete_profile_pic?: boolean;
326
331
  delete_link?: boolean;
@@ -321,139 +321,6 @@ describe('utils', () => {
321
321
  expect((0, utils_1.formatDurationInput)('99:99')).toBe('99:99');
322
322
  });
323
323
  });
324
- describe('getEstimatedExercisesDurationSeconds', () => {
325
- const testCases = [
326
- {
327
- exercises: [
328
- {
329
- type: 'duration',
330
- rest_seconds: 10,
331
- sets: [{ duration_seconds: 50, indicator: 'normal' }],
332
- },
333
- ],
334
- expectedDuration: 50 + 10,
335
- },
336
- {
337
- exercises: [
338
- {
339
- type: 'floors_duration',
340
- rest_seconds: 10,
341
- sets: [{ duration_seconds: 0, indicator: 'normal' }],
342
- },
343
- ],
344
- expectedDuration: 10,
345
- },
346
- {
347
- exercises: [
348
- {
349
- type: 'weight_duration',
350
- rest_seconds: null,
351
- sets: [{ duration_seconds: 30, indicator: 'normal' }],
352
- },
353
- ],
354
- expectedDuration: 30 + utils_1.ESTIMATED_REST_TIMER_DURATION,
355
- },
356
- {
357
- exercises: [
358
- {
359
- type: 'distance_duration',
360
- rest_seconds: 120,
361
- sets: [{ duration_seconds: 40, indicator: 'normal' }],
362
- },
363
- ],
364
- expectedDuration: 40 + 120,
365
- },
366
- {
367
- exercises: [
368
- {
369
- type: 'weight_duration',
370
- rest_seconds: 120,
371
- sets: [{ duration_seconds: null, indicator: 'normal' }],
372
- },
373
- ],
374
- expectedDuration: 120 + utils_1.ESTIMATED_SET_DURATION,
375
- },
376
- {
377
- exercises: [
378
- {
379
- type: 'duration',
380
- rest_seconds: 0,
381
- sets: [{ duration_seconds: null, indicator: 'normal' }],
382
- },
383
- ],
384
- expectedDuration: utils_1.ESTIMATED_SET_DURATION,
385
- },
386
- {
387
- exercises: [
388
- {
389
- type: 'reps_only',
390
- rest_seconds: 180,
391
- sets: [{ duration_seconds: null, indicator: 'normal' }],
392
- },
393
- {
394
- type: 'reps_only',
395
- rest_seconds: 180,
396
- sets: [
397
- {
398
- duration_seconds: 0,
399
- indicator: 'normal',
400
- },
401
- {
402
- duration_seconds: 0,
403
- indicator: 'normal',
404
- },
405
- {
406
- duration_seconds: 0,
407
- indicator: 'normal',
408
- },
409
- {
410
- duration_seconds: 0,
411
- indicator: 'normal',
412
- },
413
- ],
414
- },
415
- ],
416
- expectedDuration: (180 + utils_1.ESTIMATED_SET_DURATION) * 5,
417
- },
418
- {
419
- exercises: [
420
- {
421
- type: 'reps_only',
422
- rest_seconds: null,
423
- sets: [{ duration_seconds: null, indicator: 'normal' }],
424
- },
425
- {
426
- type: 'reps_only',
427
- rest_seconds: null,
428
- sets: [
429
- {
430
- duration_seconds: 0,
431
- indicator: 'normal',
432
- },
433
- {
434
- duration_seconds: 0,
435
- indicator: 'dropset',
436
- },
437
- {
438
- duration_seconds: 0,
439
- indicator: 'normal',
440
- },
441
- {
442
- duration_seconds: 0,
443
- indicator: 'dropset',
444
- },
445
- ],
446
- },
447
- ],
448
- expectedDuration: utils_1.ESTIMATED_REST_TIMER_DURATION * 3 + 5 * utils_1.ESTIMATED_SET_DURATION,
449
- },
450
- ];
451
- testCases.forEach((testCase) => {
452
- it(`getEstimatedExercisesDurationSeconds`, () => {
453
- expect((0, utils_1.getEstimatedExercisesDurationSeconds)(testCase)).toBe(testCase.expectedDuration);
454
- });
455
- });
456
- });
457
324
  describe('splitAtUsernamesAndLinks', () => {
458
325
  it('Takes a string and returns an array of FormatAtText', () => {
459
326
  const inputOutputs = [
package/built/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseExerciseTemplate, ExerciseType, FormatAtText, Result, SetType, StrengthLevel, UserExerciseSet, UserFacingSetIndicator } from '.';
1
+ import { BaseExerciseTemplate, FormatAtText, Result, StrengthLevel, UserExerciseSet } from '.';
2
2
  /**
3
3
  * Doesn't matter what you throw in the function it'll
4
4
  * always return a number. Non number values will return
@@ -175,19 +175,14 @@ export interface TotalSetCountWorkout {
175
175
  */
176
176
  export declare const userExerciseSetWeight: (set: UserExerciseSet, exerciseStore: BaseExerciseTemplate[], hundredPercentBodyweightExercise: boolean) => number;
177
177
  export declare const workoutSetCount: (w: TotalSetCountWorkout) => number;
178
- export declare const UserFacingIndicatorToSetIndicator: (indicator: UserFacingSetIndicator) => SetType;
179
178
  interface GetEstimatedExercisesDuration {
180
179
  exercises: {
181
180
  rest_seconds: number | null;
182
- type: ExerciseType;
183
181
  sets: {
184
182
  duration_seconds?: number | null;
185
- indicator: SetType;
186
183
  }[];
187
184
  }[];
188
185
  }
189
- export declare const ESTIMATED_SET_DURATION = 45;
190
- export declare const ESTIMATED_REST_TIMER_DURATION = 90;
191
186
  export declare const getEstimatedExercisesDurationSeconds: ({ exercises, }: GetEstimatedExercisesDuration) => number;
192
187
  export declare const oneRepMaxPercentageMap: {
193
188
  [s: number]: number;
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.generateUserGroupValue = exports.generateUserGroup = exports.isBaseExerciseTemplate = exports.getStrengthLevelFromPercentile = exports.numberToLocaleString = exports.numberWithCommas = exports.setVolume = exports.oneRepMax = exports.oneRepMaxPercentageMap = exports.getEstimatedExercisesDurationSeconds = exports.ESTIMATED_REST_TIMER_DURATION = exports.ESTIMATED_SET_DURATION = exports.UserFacingIndicatorToSetIndicator = 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.secondsToClockParts = 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.getEstimatedExercisesDurationSeconds = 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.secondsToClockParts = 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
@@ -444,42 +444,18 @@ const workoutSetCount = (w) => {
444
444
  }, 0);
445
445
  };
446
446
  exports.workoutSetCount = workoutSetCount;
447
- const UserFacingIndicatorToSetIndicator = (indicator) => {
448
- if (indicator === 'dropset')
449
- return 'dropset';
450
- if (indicator === 'warmup')
451
- return 'warmup';
452
- if (indicator === 'failure')
453
- return 'failure';
454
- return 'normal';
455
- };
456
- exports.UserFacingIndicatorToSetIndicator = UserFacingIndicatorToSetIndicator;
457
- exports.ESTIMATED_SET_DURATION = 45;
458
- exports.ESTIMATED_REST_TIMER_DURATION = 90;
459
- const isDurationExercise = (type) => {
460
- return (type === 'duration' ||
461
- type === 'weight_duration' ||
462
- type === 'distance_duration' ||
463
- type === 'floors_duration' ||
464
- type === 'steps_duration');
465
- };
447
+ const ESTIMATED_SET_DURATION = 45;
448
+ const ESTIMATED_REST_TIMER_DURATION = 90;
466
449
  const getEstimatedExercisesDurationSeconds = ({ exercises, }) => {
467
450
  const totalSeconds = exercises.reduce((exercisesTotal, exercise) => {
468
451
  var _a;
469
- const restPerSet = (_a = exercise.rest_seconds) !== null && _a !== void 0 ? _a : exports.ESTIMATED_REST_TIMER_DURATION;
470
- const setsTotal = exercise.sets.reduce((setTotal, set) => {
452
+ const restPerSet = (_a = exercise.rest_seconds) !== null && _a !== void 0 ? _a : ESTIMATED_REST_TIMER_DURATION;
453
+ const exerciseTotal = exercise.sets.reduce((setTotal, set) => {
471
454
  var _a;
472
- // Sometimes we get 0 values for duration on exercises that aren't duration.
473
- // Added this check to prevent having a estimated duration of 0 for these.
474
- const duration = isDurationExercise(exercise.type)
475
- ? (_a = set.duration_seconds) !== null && _a !== void 0 ? _a : exports.ESTIMATED_SET_DURATION
476
- : exports.ESTIMATED_SET_DURATION;
477
- // if it is a dropset, we don't add the rest time
478
- if (set.indicator === 'dropset')
479
- return setTotal + duration;
455
+ const duration = (_a = set.duration_seconds) !== null && _a !== void 0 ? _a : ESTIMATED_SET_DURATION;
480
456
  return setTotal + duration + restPerSet;
481
457
  }, 0);
482
- return exercisesTotal + setsTotal;
458
+ return exercisesTotal + exerciseTotal;
483
459
  }, 0);
484
460
  return totalSeconds;
485
461
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hevy-shared",
3
- "version": "1.0.829",
3
+ "version": "1.0.830",
4
4
  "description": "",
5
5
  "main": "built/index.js",
6
6
  "types": "built/index.d.ts",