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.
Files changed (88) hide show
  1. package/README.md +17 -2
  2. package/built/API/APIClient.d.ts +157 -0
  3. package/built/API/APIClient.js +381 -0
  4. package/built/API/index.d.ts +2 -0
  5. package/built/API/index.js +18 -0
  6. package/built/API/types.d.ts +38 -0
  7. package/built/API/types.js +18 -0
  8. package/built/adjustEventTokens.d.ts +16 -0
  9. package/built/adjustEventTokens.js +18 -0
  10. package/built/adminPermissions.d.ts +4 -0
  11. package/built/adminPermissions.js +22 -0
  12. package/built/async.d.ts +50 -0
  13. package/built/async.js +170 -0
  14. package/built/chat.d.ts +25 -23
  15. package/built/coachPlans.d.ts +2 -1
  16. package/built/coachPlans.js +2 -2
  17. package/built/cue.d.ts +12 -0
  18. package/built/cue.js +22 -0
  19. package/built/exerciseLocaleUtils.d.ts +17 -0
  20. package/built/exerciseLocaleUtils.js +62 -0
  21. package/built/filterExercises.d.ts +19 -3
  22. package/built/filterExercises.js +72 -60
  23. package/built/hevyTrainer.d.ts +250 -0
  24. package/built/hevyTrainer.js +676 -0
  25. package/built/index.d.ts +1140 -304
  26. package/built/index.js +269 -75
  27. package/built/muscleHeatmaps.d.ts +31 -0
  28. package/built/muscleHeatmaps.js +68 -0
  29. package/built/muscleSplits.d.ts +36 -0
  30. package/built/muscleSplits.js +100 -0
  31. package/built/normalizedWorkoutUtils.d.ts +88 -0
  32. package/built/normalizedWorkoutUtils.js +112 -0
  33. package/built/notifications.d.ts +215 -0
  34. package/built/notifications.js +9 -0
  35. package/built/routineUtils.d.ts +14 -0
  36. package/built/routineUtils.js +186 -0
  37. package/built/schemas.d.ts +14 -0
  38. package/built/schemas.js +9 -0
  39. package/built/setIndicatorUtils.d.ts +4 -3
  40. package/built/setIndicatorUtils.js +15 -1
  41. package/built/tests/async.test.d.ts +1 -0
  42. package/built/tests/async.test.js +49 -0
  43. package/built/tests/hevyTrainer.test.d.ts +1 -0
  44. package/built/tests/hevyTrainer.test.js +1199 -0
  45. package/built/tests/muscleSplit.test.d.ts +1 -0
  46. package/built/tests/muscleSplit.test.js +153 -0
  47. package/built/tests/routineUtils.test.d.ts +1 -0
  48. package/built/tests/routineUtils.test.js +745 -0
  49. package/built/tests/testUtils.d.ts +85 -0
  50. package/built/tests/testUtils.js +319 -0
  51. package/built/tests/utils.test.js +748 -0
  52. package/built/tests/workoutVolume.test.js +165 -49
  53. package/built/translations/index.d.ts +2 -0
  54. package/built/translations/index.js +18 -0
  55. package/built/translations/translationUtils.d.ts +2 -0
  56. package/built/translations/translationUtils.js +61 -0
  57. package/built/translations/types.d.ts +8 -0
  58. package/built/translations/types.js +20 -0
  59. package/built/typeUtils.d.ts +70 -0
  60. package/built/typeUtils.js +55 -0
  61. package/built/units.d.ts +14 -7
  62. package/built/units.js +24 -14
  63. package/built/utils.d.ts +192 -5
  64. package/built/utils.js +598 -85
  65. package/built/websocket.d.ts +14 -2
  66. package/built/workoutVolume.d.ts +24 -5
  67. package/built/workoutVolume.js +25 -34
  68. package/package.json +32 -10
  69. package/.eslintignore +0 -2
  70. package/.eslintrc +0 -21
  71. package/.github/workflows/ci.yml +0 -15
  72. package/.github/workflows/npm-publish.yml +0 -59
  73. package/.github/workflows/pr-auto-assign.yml +0 -15
  74. package/.prettierrc.js +0 -5
  75. package/jest.config.js +0 -4
  76. package/src/chat.ts +0 -130
  77. package/src/coachPlans.ts +0 -57
  78. package/src/constants.ts +0 -14
  79. package/src/filterExercises.ts +0 -222
  80. package/src/index.ts +0 -1576
  81. package/src/setIndicatorUtils.ts +0 -137
  82. package/src/tests/utils.test.ts +0 -156
  83. package/src/tests/workoutVolume.test.ts +0 -93
  84. package/src/units.ts +0 -41
  85. package/src/utils.ts +0 -516
  86. package/src/websocket.ts +0 -36
  87. package/src/workoutVolume.ts +0 -175
  88. package/tsconfig.json +0 -70
@@ -1,5 +1,5 @@
1
1
  interface SetIndicatored {
2
- indicator: 'warmup' | 'dropset' | 'failure' | 'normal' | any;
2
+ indicator: 'warmup' | 'dropset' | 'failure' | 'normal' | number;
3
3
  }
4
4
  interface Indexed {
5
5
  index: number;
@@ -30,7 +30,7 @@ interface Indexed {
30
30
  * ]
31
31
  * ```
32
32
  */
33
- export declare const indexSetObjectsForUI: <T>(indexedSet: SetIndicatored[]) => (SetIndicatored & Indexed & T)[];
33
+ export declare const indexSetObjectsForUI: <T>(indexedSet: SetIndicatored[]) => Array<SetIndicatored & Indexed & T>;
34
34
  /**
35
35
  * This function is almost the exact same as `indexSetObjectsForUI`
36
36
  * but this function will change failure sets to normal. Because when
@@ -63,7 +63,8 @@ export declare const indexSetObjectsForUI: <T>(indexedSet: SetIndicatored[]) =>
63
63
  * ]
64
64
  * ```
65
65
  */
66
- export declare const indexSetObjectsForType: <T>(indexedSet: SetIndicatored[]) => (SetIndicatored & Indexed & T)[];
66
+ export declare const indexSetObjectsForType: <T>(indexedSet: SetIndicatored[]) => Array<SetIndicatored & Indexed & T>;
67
67
  export type UserFacingSetIndicator = 'dropset' | 'warmup' | 'failure' | number;
68
68
  export declare const setObjectToUIFacingSetIndicator: (set: SetIndicatored & Indexed) => UserFacingSetIndicator;
69
+ export declare const compareUserFacingSetIndicator: (indicatorA: UserFacingSetIndicator, indicatorB: UserFacingSetIndicator) => boolean;
69
70
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setObjectToUIFacingSetIndicator = exports.indexSetObjectsForType = exports.indexSetObjectsForUI = void 0;
3
+ exports.compareUserFacingSetIndicator = exports.setObjectToUIFacingSetIndicator = exports.indexSetObjectsForType = exports.indexSetObjectsForUI = void 0;
4
4
  /**
5
5
  * Accepts any data structure like this:
6
6
  * [
@@ -110,3 +110,17 @@ const setObjectToUIFacingSetIndicator = (set) => {
110
110
  return set.index + 1;
111
111
  };
112
112
  exports.setObjectToUIFacingSetIndicator = setObjectToUIFacingSetIndicator;
113
+ const compareUserFacingSetIndicator = (indicatorA, indicatorB) => {
114
+ const normalizedA = indicatorA === 'warmup'
115
+ ? 'warmup'
116
+ : indicatorA === 'dropset'
117
+ ? 'dropset'
118
+ : 'normal';
119
+ const normalizedB = indicatorB === 'warmup'
120
+ ? 'warmup'
121
+ : indicatorB === 'dropset'
122
+ ? 'dropset'
123
+ : 'normal';
124
+ return normalizedA === normalizedB;
125
+ };
126
+ exports.compareUserFacingSetIndicator = compareUserFacingSetIndicator;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,49 @@
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
+ const async_1 = require("../async");
13
+ const resolveAfterMs = (waitMs, value) => __awaiter(void 0, void 0, void 0, function* () {
14
+ return new Promise((resolve) => {
15
+ setTimeout(() => resolve(value), waitMs);
16
+ });
17
+ });
18
+ const rejectAfterMs = (waitMs, value) => __awaiter(void 0, void 0, void 0, function* () {
19
+ return new Promise((_, reject) => {
20
+ setTimeout(() => reject(value), waitMs);
21
+ });
22
+ });
23
+ describe('async', () => {
24
+ describe('allToResolveOrReject', () => {
25
+ it('resolves when all the arguments have resolved or rejected', () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const startMs = new Date().valueOf();
27
+ yield expect((0, async_1.allToResolveOrReject)([
28
+ resolveAfterMs(100, 'OK after 100 ms'),
29
+ resolveAfterMs(500, 'OK after 500 ms'),
30
+ rejectAfterMs(400, 'Error after 400 ms'),
31
+ resolveAfterMs(200, 'OK after 200 ms'),
32
+ rejectAfterMs(300, 'Error after 300 ms'),
33
+ ])).resolves.toEqual([
34
+ { isSuccess: true, value: 'OK after 100 ms' },
35
+ { isSuccess: true, value: 'OK after 500 ms' },
36
+ { isSuccess: false, error: 'Error after 400 ms' },
37
+ { isSuccess: true, value: 'OK after 200 ms' },
38
+ { isSuccess: false, error: 'Error after 300 ms' },
39
+ ]);
40
+ const endMs = new Date().valueOf();
41
+ // should be 500 ms + (0~10 ms), i.e. the time it takes for the last
42
+ // promise to resolve/reject
43
+ //
44
+ // give 50 ms of leeway in case there's a system hiccup
45
+ //
46
+ expect(endMs - startMs).toBeLessThan(550);
47
+ }), 1000);
48
+ });
49
+ });
@@ -0,0 +1 @@
1
+ export {};