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/.eslintignore
ADDED
package/.eslintrc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"root": true,
|
|
3
|
+
"parser": "@typescript-eslint/parser",
|
|
4
|
+
"plugins": [
|
|
5
|
+
"@typescript-eslint"
|
|
6
|
+
],
|
|
7
|
+
"extends": [
|
|
8
|
+
"eslint:recommended",
|
|
9
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
10
|
+
"plugin:@typescript-eslint/recommended",
|
|
11
|
+
"plugin:prettier/recommended"
|
|
12
|
+
],
|
|
13
|
+
"rules": {
|
|
14
|
+
"@typescript-eslint/no-extra-boolean-cast": "off",
|
|
15
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
16
|
+
"no-extra-boolean-cast": "off",
|
|
17
|
+
"@typescript-eslint/ban-types": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
19
|
+
"@typescript-eslint/no-unused-vars": "error"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on: push
|
|
3
|
+
jobs:
|
|
4
|
+
build:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
steps:
|
|
7
|
+
- uses: actions/checkout@v2
|
|
8
|
+
- name: Install modules
|
|
9
|
+
run: npm install
|
|
10
|
+
- name: Run tests
|
|
11
|
+
run: npm run test
|
|
12
|
+
- name: Run Types
|
|
13
|
+
run: npm run types
|
|
14
|
+
- name: Run Linting
|
|
15
|
+
run: npm run lint
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
|
|
3
|
+
|
|
4
|
+
name: Node.js Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: master
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
inputs:
|
|
11
|
+
version:
|
|
12
|
+
required: false
|
|
13
|
+
type: string
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
publish-npm:
|
|
17
|
+
permissions:
|
|
18
|
+
id-token: write # for publishing to npm via oidc
|
|
19
|
+
contents: write # actions/checkout needs read, git tag needs write
|
|
20
|
+
runs-on: ubuntu-latest
|
|
21
|
+
steps:
|
|
22
|
+
- uses: actions/checkout@v3
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '20.17.0'
|
|
26
|
+
registry-url: https://registry.npmjs.org/
|
|
27
|
+
- name: Set git user info
|
|
28
|
+
run: |
|
|
29
|
+
git config --global user.email "ci@hevyapp.com"
|
|
30
|
+
git config --global user.name "ci"
|
|
31
|
+
- name: Update npm # needs 11.5.1+ for Trusted Publishing
|
|
32
|
+
run: npm install -g npm@11.5.1
|
|
33
|
+
- run: npm ci
|
|
34
|
+
- run: npm run types
|
|
35
|
+
- run: npm run lint
|
|
36
|
+
- run: npm run test
|
|
37
|
+
- name: Set npm version
|
|
38
|
+
run: |
|
|
39
|
+
npm config set allow-same-version true
|
|
40
|
+
npm config set git-tag-version false
|
|
41
|
+
if [ -z "${{ inputs.version }}" ]; then
|
|
42
|
+
echo 'Latest version currenly on npm:' >&2
|
|
43
|
+
npm version $(npm show hevy-shared version) >&2
|
|
44
|
+
echo 'New version:' >&2
|
|
45
|
+
VERSION="$(npm version patch)"
|
|
46
|
+
echo $VERSION >&2
|
|
47
|
+
echo "NPM_VERSION=$VERSION" >>"$GITHUB_ENV"
|
|
48
|
+
else
|
|
49
|
+
echo 'Override version:' >&2
|
|
50
|
+
VERSION="$(npm version ${{ inputs.version }})"
|
|
51
|
+
echo $VERSION >&2
|
|
52
|
+
echo "NPM_VERSION=$VERSION" >>"$GITHUB_ENV"
|
|
53
|
+
fi
|
|
54
|
+
- name: Tag release
|
|
55
|
+
run: |
|
|
56
|
+
git tag "$NPM_VERSION"
|
|
57
|
+
git push --tags
|
|
58
|
+
- run: npm run build
|
|
59
|
+
- run: npm publish
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: PR Auto-Assign
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request_target:
|
|
5
|
+
types: [opened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
assign:
|
|
9
|
+
name: Auto-assign PR to author
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- env:
|
|
13
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
14
|
+
run: |
|
|
15
|
+
gh pr edit ${{ github.event.number }} --add-assignee ${{ github.event.sender.login }} -R ${{ github.event.repository.full_name }}
|
package/.prettierrc.js
ADDED
package/README.md
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
# hevy-shared
|
|
2
2
|
Common code shared by the other repos.
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
There are two ways of publishing a new version of `hevy-shared` to npm.
|
|
7
|
-
|
|
8
|
-
### Automatically
|
|
9
|
-
|
|
10
|
-
Merging PRs to `master` will automatically trigger the publishing of a new patch version to npm using Github Actions (see .github/workflows). Go to https://www.npmjs.com/package/hevy-shared for more information.
|
|
11
|
-
|
|
12
|
-
**Important note:** Please do **NOT** merge your `hevy-shared` PRs into `master` until _all_ the other repos (regardless of whether they use npm or Git submodules) which depend on your `hevy-shared` PR have their respective PRs merged into their respective main branches.
|
|
13
|
-
Doing so should help avoid type errors and conflicts more than doing it the other way around, even though they can still happen.
|
|
14
|
-
|
|
15
|
-
### Manually
|
|
16
|
-
|
|
17
|
-
To publish manually, run `npm run ci-build` _on the branch of your choice_. This is useful if you need to get your changes into a repo which doesn't use Git submodules.
|
|
18
|
-
|
|
19
|
-
Running the command will print the next unused version number, which should be the version of the newly published package. You will just have to wait until it's actually published before you can install it.
|
|
20
|
-
You can run `npm view hevy-shared version` to check the current `latest` version that's available on npm at any given moment.
|
|
4
|
+
## Deploying
|
|
5
|
+
Merging PRs to `master` will automatically trigger the deployment of a new patch version to npm using github actions (see ./github/workflows). Go to https://www.npmjs.com/package/hevy-shared for more information
|
package/built/chat.d.ts
CHANGED
|
@@ -6,15 +6,7 @@ export interface PostCreateConversationResponse {
|
|
|
6
6
|
}
|
|
7
7
|
export interface PostMessageRequest {
|
|
8
8
|
conversation_id: string;
|
|
9
|
-
data: CreateTextMessageData |
|
|
10
|
-
}
|
|
11
|
-
export interface PostGetDeletedMessagesRequest {
|
|
12
|
-
messages_deleted_since_time?: string;
|
|
13
|
-
conversation_id: string;
|
|
14
|
-
}
|
|
15
|
-
export interface PostDeletedMessagesResponse {
|
|
16
|
-
deleted_message_ids: string[];
|
|
17
|
-
checked_at_time: string;
|
|
9
|
+
data: CreateTextMessageData | CreateNewWorkoutMessageData | CreateNewBodyMeasurementMesageData;
|
|
18
10
|
}
|
|
19
11
|
export interface PostMessageResponse {
|
|
20
12
|
message_id: string;
|
|
@@ -23,13 +15,13 @@ export interface CreateTextMessageData {
|
|
|
23
15
|
type: 'text';
|
|
24
16
|
text: string;
|
|
25
17
|
}
|
|
26
|
-
export interface
|
|
27
|
-
type: '
|
|
28
|
-
|
|
18
|
+
export interface CreateNewWorkoutMessageData {
|
|
19
|
+
type: 'new-workout';
|
|
20
|
+
workout_id: string;
|
|
29
21
|
}
|
|
30
|
-
export interface
|
|
31
|
-
type: '
|
|
32
|
-
|
|
22
|
+
export interface CreateNewBodyMeasurementMesageData {
|
|
23
|
+
type: 'new-body-measurement';
|
|
24
|
+
measurement_id: number;
|
|
33
25
|
}
|
|
34
26
|
export interface GetLatestMessageFromAllClientsResponse {
|
|
35
27
|
conversations: {
|
|
@@ -56,7 +48,7 @@ export interface Conversation {
|
|
|
56
48
|
conversation_id: string;
|
|
57
49
|
user_ids: string[];
|
|
58
50
|
}
|
|
59
|
-
export type MessageType = 'text' | '
|
|
51
|
+
export type MessageType = 'text' | 'new-workout' | 'new-body-measurement';
|
|
60
52
|
export interface MessageBase {
|
|
61
53
|
id: string;
|
|
62
54
|
sender_user_id: string;
|
|
@@ -68,15 +60,21 @@ export interface TextMessage extends MessageBase {
|
|
|
68
60
|
type: 'text';
|
|
69
61
|
text: string;
|
|
70
62
|
}
|
|
71
|
-
export interface
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
export interface NewWorkoutMessageData {
|
|
64
|
+
workout_id: string;
|
|
65
|
+
}
|
|
66
|
+
export interface NewWorkoutMessage extends MessageBase {
|
|
67
|
+
type: 'new-workout';
|
|
68
|
+
data: NewWorkoutMessageData;
|
|
69
|
+
}
|
|
70
|
+
export interface NewBodyMeasurementMessageData {
|
|
71
|
+
measurement_id: number;
|
|
74
72
|
}
|
|
75
|
-
export interface
|
|
76
|
-
type: '
|
|
77
|
-
|
|
73
|
+
export interface NewBodyMeasurementMessage extends MessageBase {
|
|
74
|
+
type: 'new-body-measurement';
|
|
75
|
+
data: NewBodyMeasurementMessageData;
|
|
78
76
|
}
|
|
79
|
-
export type Message = TextMessage |
|
|
77
|
+
export type Message = TextMessage | NewWorkoutMessage | NewBodyMeasurementMessage;
|
|
80
78
|
export declare const isMessage: (message?: any) => message is Message;
|
|
81
79
|
export interface NewMessageChatUpdate {
|
|
82
80
|
type: 'new-message';
|
|
@@ -91,5 +89,5 @@ export interface NewConversationChatUpdate {
|
|
|
91
89
|
conversation_id: string;
|
|
92
90
|
conversation_users: string[];
|
|
93
91
|
}
|
|
94
|
-
export type
|
|
95
|
-
export declare const isHevyChatUpdatePush: (message?: any) => message is
|
|
92
|
+
export type HevyChatUpdatePush = NewMessageChatUpdate | MessageDeletedChatUpdate | NewConversationChatUpdate;
|
|
93
|
+
export declare const isHevyChatUpdatePush: (message?: any) => message is HevyChatUpdatePush;
|
package/built/coachPlans.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export declare const HevyCoachDefaultPlan: Plan;
|
|
2
|
-
export type PlanType = '
|
|
2
|
+
export type PlanType = 'default' | 'paid_paddle' | 'trial' | 'beta';
|
|
3
3
|
export interface Plan {
|
|
4
4
|
title: string;
|
|
5
5
|
maximum_clients: number;
|
|
6
6
|
id: string;
|
|
7
7
|
paddle_update_payment_url?: string;
|
|
8
|
-
paddle_subscription_id?: number;
|
|
9
8
|
renewal_period: 'monthly' | 'lifetime';
|
|
10
9
|
renewal_price?: string;
|
|
11
10
|
renewal_currency?: string;
|
package/built/coachPlans.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HevyCoachDefaultPlan = void 0;
|
|
4
4
|
exports.HevyCoachDefaultPlan = {
|
|
5
|
-
maximum_clients:
|
|
5
|
+
maximum_clients: 3,
|
|
6
6
|
id: 'hevy_coach_free',
|
|
7
7
|
title: 'Free',
|
|
8
8
|
renewal_period: 'lifetime',
|
|
9
|
-
type: '
|
|
9
|
+
type: 'default',
|
|
10
10
|
};
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { EquipmentFilter,
|
|
2
|
-
|
|
3
|
-
export interface SearchableLibraryExercise extends LibraryExercise {
|
|
1
|
+
import { EquipmentFilter, ExerciseTemplate, Language, MuscleGroupFilter } from './index';
|
|
2
|
+
export interface SearchableExerciseTemplate extends ExerciseTemplate {
|
|
4
3
|
localized_muscle_group_name: string;
|
|
5
4
|
}
|
|
6
|
-
export interface SearchableCustomExercise extends CustomExercise {
|
|
7
|
-
localized_muscle_group_name: string;
|
|
8
|
-
}
|
|
9
|
-
export type SearchableExerciseTemplate = SearchableLibraryExercise | SearchableCustomExercise;
|
|
10
|
-
export interface SearchableLibraryExerciseWithStringScore<T = number> extends SearchableLibraryExercise {
|
|
11
|
-
searchStringScore?: T;
|
|
12
|
-
}
|
|
13
|
-
export interface SearchableCustomExerciseWithStringScore<T = number> extends SearchableCustomExercise {
|
|
14
|
-
searchStringScore?: T;
|
|
15
|
-
}
|
|
16
|
-
export type SearchableExerciseTemplateWithStringScore<T = number> = SearchableLibraryExerciseWithStringScore<T> | SearchableCustomExerciseWithStringScore<T>;
|
|
17
5
|
interface FilterExercisesProps {
|
|
18
6
|
exercises: SearchableExerciseTemplate[];
|
|
19
7
|
muscleGroupFilter: MuscleGroupFilter;
|
|
@@ -21,11 +9,7 @@ interface FilterExercisesProps {
|
|
|
21
9
|
searchText: string;
|
|
22
10
|
language: Language;
|
|
23
11
|
}
|
|
24
|
-
export declare const
|
|
25
|
-
export type ExerciseSearchMatch<T> = {
|
|
26
|
-
exercise: T;
|
|
27
|
-
matchType: 'title' | 'muscle_group' | 'other' | 'custom';
|
|
28
|
-
};
|
|
12
|
+
export declare const filterExercises: ({ exercises, muscleGroupFilter, equipmentType, searchText, language, }: FilterExercisesProps) => ExerciseTemplate[];
|
|
29
13
|
/**
|
|
30
14
|
* Exercise templates that are shown at the top of the Exercise Library to
|
|
31
15
|
* users who don't have any workouts logged.
|
package/built/filterExercises.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.popularExerciseTemplateIds = exports.
|
|
4
|
-
const utils_1 = require("./utils");
|
|
3
|
+
exports.popularExerciseTemplateIds = exports.filterExercises = void 0;
|
|
5
4
|
const lodash_1 = require("lodash");
|
|
6
|
-
const
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
const filterExercises = ({ exercises, muscleGroupFilter, equipmentType, searchText, language, }) => {
|
|
7
7
|
let result = exercises;
|
|
8
8
|
result = filterExercisesWithMuscleGroup(muscleGroupFilter, result);
|
|
9
9
|
result = filterExercisesWithEquipment(equipmentType, result);
|
|
10
10
|
const normalizedSearchText = normalizeSearchText(searchText, language);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return
|
|
11
|
+
result = filterExercisesWithSearchText(normalizedSearchText, result, language);
|
|
12
|
+
result = orderExercisesWithSearchText(normalizedSearchText, result);
|
|
13
|
+
return result;
|
|
14
14
|
};
|
|
15
|
-
exports.
|
|
15
|
+
exports.filterExercises = filterExercises;
|
|
16
16
|
const filterExercisesWithMuscleGroup = (muscleGroup, exercises) => {
|
|
17
17
|
if (muscleGroup === 'all_muscles') {
|
|
18
18
|
return exercises;
|
|
@@ -25,52 +25,41 @@ const filterExercisesWithEquipment = (equipmentType, exercises) => {
|
|
|
25
25
|
}
|
|
26
26
|
return exercises.filter((rd) => rd.equipment_category === equipmentType);
|
|
27
27
|
};
|
|
28
|
-
// Old filter exercise functionality, will be removed when new feature goes live
|
|
29
28
|
const filterExercisesWithSearchText = (searchText, exercises, language) => {
|
|
30
29
|
if (searchText.length === 0) {
|
|
31
|
-
return exercises
|
|
30
|
+
return exercises;
|
|
32
31
|
}
|
|
33
|
-
|
|
34
|
-
for (const e of exercises) {
|
|
32
|
+
return exercises.filter((e) => {
|
|
35
33
|
const searchableSearchText = searchable(searchText);
|
|
36
34
|
const searchableEnglishTitle = searchable(e.title);
|
|
37
|
-
const searchableLocalizedTitleMap =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
: {
|
|
53
|
-
en: searchable(e.title),
|
|
54
|
-
};
|
|
35
|
+
const searchableLocalizedTitleMap = {
|
|
36
|
+
en: searchable(e.title),
|
|
37
|
+
es: e.es_title ? searchable(e.es_title) : undefined,
|
|
38
|
+
de: e.de_title ? searchable(e.de_title) : undefined,
|
|
39
|
+
fr: e.fr_title ? searchable(e.fr_title) : undefined,
|
|
40
|
+
it: e.it_title ? searchable(e.it_title) : undefined,
|
|
41
|
+
pt: e.pt_title ? searchable(e.pt_title) : undefined,
|
|
42
|
+
tr: e.tr_title ? searchable(e.tr_title) : undefined,
|
|
43
|
+
zh_CN: e.zh_cn_title ? searchable(e.zh_cn_title) : undefined,
|
|
44
|
+
zh_TW: e.zh_tw_title ? searchable(e.zh_tw_title) : undefined,
|
|
45
|
+
ru: e.ru_title ? searchable(e.ru_title) : undefined,
|
|
46
|
+
ja: e.ja_title ? searchable(e.ja_title) : undefined,
|
|
47
|
+
ko: e.ko_title ? searchable(e.ko_title) : undefined,
|
|
48
|
+
};
|
|
55
49
|
const searchableLocalizedTitle = searchableLocalizedTitleMap[language] || searchableLocalizedTitleMap.en;
|
|
56
50
|
const searchableLocalizedMuscleGroupName = searchable(e.localized_muscle_group_name);
|
|
57
51
|
const searchableMuscleGroup = searchable(e.muscle_group);
|
|
58
52
|
const searchableMisspelledDumbbellEquipment = e.equipment_category === 'dumbbell' ? 'dumbell' : '';
|
|
59
|
-
const searchableTags =
|
|
60
|
-
const searchableAka =
|
|
53
|
+
const searchableTags = e.manual_tag ? searchable(e.manual_tag) : '';
|
|
54
|
+
const searchableAka = e.aka ? searchable(e.aka) : '';
|
|
61
55
|
if (searchableLocalizedTitle.includes(searchableSearchText) ||
|
|
62
|
-
searchableEnglishTitle.includes(searchableSearchText)
|
|
63
|
-
|
|
64
|
-
continue;
|
|
65
|
-
}
|
|
66
|
-
else if (searchableLocalizedMuscleGroupName.includes(searchableSearchText) ||
|
|
56
|
+
searchableEnglishTitle.includes(searchableSearchText) ||
|
|
57
|
+
searchableLocalizedMuscleGroupName.includes(searchableSearchText) ||
|
|
67
58
|
searchableMuscleGroup.includes(searchableSearchText)) {
|
|
68
|
-
|
|
69
|
-
continue;
|
|
59
|
+
return true;
|
|
70
60
|
}
|
|
71
61
|
if (e.is_custom && 'custom'.includes(searchableSearchText)) {
|
|
72
|
-
|
|
73
|
-
continue;
|
|
62
|
+
return true;
|
|
74
63
|
}
|
|
75
64
|
const splitSearch = searchableSearchText.split(' ');
|
|
76
65
|
const splitTitle = [
|
|
@@ -86,29 +75,28 @@ const filterExercisesWithSearchText = (searchText, exercises, language) => {
|
|
|
86
75
|
// title ['arnold', 'press', '(barbell)']
|
|
87
76
|
// search ['press', 'bar']
|
|
88
77
|
if ((0, lodash_1.intersectionWith)(splitSearch, splitTitle, (search, title) => title.includes(search)).length === splitSearch.length) {
|
|
89
|
-
|
|
90
|
-
continue;
|
|
78
|
+
return true;
|
|
91
79
|
}
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
return false;
|
|
81
|
+
});
|
|
94
82
|
};
|
|
95
|
-
const orderExercisesWithSearchText = (searchText,
|
|
83
|
+
const orderExercisesWithSearchText = (searchText, exercises) => {
|
|
96
84
|
if (searchText.length === 0) {
|
|
97
|
-
return
|
|
85
|
+
return exercises;
|
|
98
86
|
}
|
|
99
|
-
return
|
|
100
|
-
.reduce((accu,
|
|
101
|
-
const lowercaseTitle =
|
|
87
|
+
return exercises
|
|
88
|
+
.reduce((accu, currentExercise) => {
|
|
89
|
+
const lowercaseTitle = currentExercise.title.toLowerCase();
|
|
102
90
|
if (lowercaseTitle.startsWith(searchText)) {
|
|
103
91
|
accu.push({
|
|
104
|
-
exercise:
|
|
105
|
-
weight:
|
|
92
|
+
exercise: currentExercise,
|
|
93
|
+
weight: currentExercise.priority * 2,
|
|
106
94
|
});
|
|
107
95
|
return accu;
|
|
108
96
|
}
|
|
109
97
|
accu.push({
|
|
110
|
-
exercise:
|
|
111
|
-
weight:
|
|
98
|
+
exercise: currentExercise,
|
|
99
|
+
weight: currentExercise.priority,
|
|
112
100
|
});
|
|
113
101
|
return accu;
|
|
114
102
|
}, [])
|
|
@@ -138,24 +126,24 @@ const searchable = (str) => {
|
|
|
138
126
|
* users who don't have any workouts logged.
|
|
139
127
|
*/
|
|
140
128
|
exports.popularExerciseTemplateIds = [
|
|
141
|
-
'B8127AD1',
|
|
142
|
-
'11A123F3',
|
|
143
|
-
'D04AC939',
|
|
144
|
-
'75A4F6C4',
|
|
145
|
-
'422B08F1',
|
|
146
|
-
'C7973E0E',
|
|
147
|
-
'07B38369',
|
|
148
|
-
'3601968B',
|
|
149
|
-
'6A6C31A5',
|
|
150
|
-
'0393F233',
|
|
151
|
-
'37FCC2BB',
|
|
152
|
-
'55E6546F',
|
|
153
|
-
'94B7239B',
|
|
154
|
-
'C6272009',
|
|
155
|
-
'878CD1D0',
|
|
156
|
-
'651F844C',
|
|
157
|
-
'79D0BB3A',
|
|
158
|
-
'93A552C6',
|
|
159
|
-
'7E3BC8B6',
|
|
129
|
+
'B8127AD1',
|
|
130
|
+
'11A123F3',
|
|
131
|
+
'D04AC939',
|
|
132
|
+
'75A4F6C4',
|
|
133
|
+
'422B08F1',
|
|
134
|
+
'C7973E0E',
|
|
135
|
+
'07B38369',
|
|
136
|
+
'3601968B',
|
|
137
|
+
'6A6C31A5',
|
|
138
|
+
'0393F233',
|
|
139
|
+
'37FCC2BB',
|
|
140
|
+
'55E6546F',
|
|
141
|
+
'94B7239B',
|
|
142
|
+
'C6272009',
|
|
143
|
+
'878CD1D0',
|
|
144
|
+
'651F844C',
|
|
145
|
+
'79D0BB3A',
|
|
146
|
+
'93A552C6',
|
|
147
|
+
'7E3BC8B6',
|
|
160
148
|
'BE640BA0', // Face Pull
|
|
161
149
|
];
|