@dgpholdings/greatoak-shared 1.2.29 → 1.2.31
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/README.md +105 -80
- package/dist/types/TApiExercise.d.ts +1 -0
- package/dist/types/commonTypes.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,93 +1,118 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dgpholdings/greatoak-shared
|
|
2
2
|
|
|
3
|
+
The shared library for the Fitfrix ecosystem. Contains all types, utilities, and the scoring engine used across:
|
|
3
4
|
|
|
5
|
+
- `v2/fitfrix` — the mobile app (React Native / Expo)
|
|
6
|
+
- `backend/api-service` — the NestJS backend
|
|
7
|
+
- `fitfrix.com` — the web/landing (Vite + React)
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
Any type, constant, or utility that is used by more than one package lives here. If you're about to define a type locally in a consuming app — check here first.
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
---
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
## Install / Import
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
```ts
|
|
16
|
+
// Types
|
|
17
|
+
import type { TExercise, TRecord, TUserMetric } from '@dgpholdings/greatoak-shared';
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
cd existing_repo
|
|
18
|
-
git remote add origin https://gitlab.com/greatoak/shared.git
|
|
19
|
-
git branch -M main
|
|
20
|
-
git push -uf origin main
|
|
19
|
+
// Utils
|
|
20
|
+
import { calculateExerciseScoreV2, calculateTotalVolume, isDefined, toError } from '@dgpholdings/greatoak-shared';
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## What's Inside
|
|
26
|
+
|
|
27
|
+
| Category | Location | Doc |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| **Types** | `src/types/` | [docs/types.md](docs/types.md) |
|
|
30
|
+
| **Utils** | `src/utils/` | [docs/utils.md](docs/utils.md) |
|
|
31
|
+
| **Scoring Engine** | `src/utils/scoring/` | [docs/scoring.md](docs/scoring.md) |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Types — Quick Reference
|
|
36
|
+
|
|
37
|
+
| File | What it defines |
|
|
38
|
+
|---|---|
|
|
39
|
+
| `commonTypes.ts` | `TRecord`, `TExerciseConfig`, `TTemplateExercise`, `TGdprData`, `TDayKey` |
|
|
40
|
+
| `TApiExercise.ts` | `TExercise`, `TBodyPart`, `EBodyParts`, `TTrainingType`, `TTimingGuardrails` |
|
|
41
|
+
| `TApiUser.ts` | `TUserMetric`, `TFitnessGoal`, `TUserType`, `TSubscriptionStatus`, `TGender` |
|
|
42
|
+
| `TApiAuth.ts` | `TOnboardingData`, signup/signin request & response types |
|
|
43
|
+
| `TApiExerciseRecord.ts` | Record save/fetch request & response types |
|
|
44
|
+
| `TApiTemplateData.ts` | `TTemplate`, `TTemplateDb`, `TTemplateData`, `TExerciseLatestRecord` |
|
|
45
|
+
| `TApiProPlan.ts` | `TProPlan`, pro plan CRUD request & response types |
|
|
46
|
+
| `TApiTemplateShop.ts` | `TTemplateShopDb`, shop CRUD & shared plan types |
|
|
47
|
+
| `TApiBillingPlan.ts` | `TBillingPlan`, `TBillingCountries`, billing API types |
|
|
48
|
+
| `TApiRevenueCat.ts` | `TApiRevenueCatWebhookReq`, RevenueCat event types |
|
|
49
|
+
| `TApiClientProgress.ts` | `TClientWorkoutHistory`, trainer dashboard types |
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Utils — Quick Reference
|
|
54
|
+
|
|
55
|
+
| Export | What it does |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `calculateExerciseScoreV2` | Full exercise scoring → `{ score, muscleScores }` |
|
|
58
|
+
| `calculateTotalVolume` | Total workout volume for charts |
|
|
59
|
+
| `isDefined` / `isDefinedNumber` | Null/undefined type guards |
|
|
60
|
+
| `toError` | Converts unknown catch values to `Error` |
|
|
61
|
+
| `toNumber` | Safe string/number → `number \| undefined` |
|
|
62
|
+
| `mmssToSecs` | `"MM:SS"` → seconds |
|
|
63
|
+
| `getDaysAndHoursDifference` | Date diff → `{ days, hours }` |
|
|
64
|
+
| `isUserAllowedToUpdate` | Profile update rate-limit guard |
|
|
65
|
+
| `countryToCurrencyCode` | Country code → ISO currency string |
|
|
66
|
+
| `slugifyText` | Text → URL-safe slug |
|
|
67
|
+
| `generatePlanCode` | Generates a unique 9-char Crockford Base32 plan code |
|
|
68
|
+
| `maskEmail` / `isEmail` / `isAnonymousEmail` | Email utilities |
|
|
69
|
+
| `NOOP` | Empty function `() => {}` |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Source Structure
|
|
54
74
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
```
|
|
76
|
+
shared/
|
|
77
|
+
├── src/
|
|
78
|
+
│ ├── types/
|
|
79
|
+
│ │ ├── index.ts # Re-exports all types
|
|
80
|
+
│ │ ├── commonTypes.ts # TRecord, TExerciseConfig, TTemplateExercise, TGdprData, TDayKey
|
|
81
|
+
│ │ ├── TApiExercise.ts # TExercise and related
|
|
82
|
+
│ │ ├── TApiUser.ts # TUserMetric and related
|
|
83
|
+
│ │ ├── TApiAuth.ts # Auth flows
|
|
84
|
+
│ │ ├── TApiExerciseRecord.ts # Workout record save/fetch
|
|
85
|
+
│ │ ├── TApiTemplateData.ts # User workout templates
|
|
86
|
+
│ │ ├── TApiProPlan.ts # Pro/trainer plans
|
|
87
|
+
│ │ ├── TApiTemplateShop.ts # Template shop (legacy, see TApiProPlan)
|
|
88
|
+
│ │ ├── TApiBillingPlan.ts # Billing plans
|
|
89
|
+
│ │ ├── TApiRevenueCat.ts # In-app purchase webhooks
|
|
90
|
+
│ │ └── TApiClientProgress.ts # Trainer client tracking
|
|
91
|
+
│ └── utils/
|
|
92
|
+
│ ├── index.ts # Re-exports all utils
|
|
93
|
+
│ ├── billing.utils.ts
|
|
94
|
+
│ ├── email.utils.ts
|
|
95
|
+
│ ├── isDefined.utils.ts
|
|
96
|
+
│ ├── noop.utils.ts
|
|
97
|
+
│ ├── number.util.ts
|
|
98
|
+
│ ├── planCode.util.ts
|
|
99
|
+
│ ├── slugify.util.ts
|
|
100
|
+
│ ├── time.util.ts
|
|
101
|
+
│ ├── toError.util.ts
|
|
102
|
+
│ └── scoring/ # Exercise scoring engine
|
|
103
|
+
│ └── README.md # Full scoring documentation
|
|
104
|
+
├── docs/
|
|
105
|
+
│ ├── types.md # All types documented in detail
|
|
106
|
+
│ ├── utils.md # All utils documented with examples
|
|
107
|
+
│ └── scoring.md # Scoring system overview
|
|
108
|
+
└── README.md # This file
|
|
109
|
+
```
|
|
85
110
|
|
|
86
|
-
|
|
87
|
-
Show your appreciation to those who have contributed to the project.
|
|
111
|
+
---
|
|
88
112
|
|
|
89
|
-
##
|
|
90
|
-
For open source projects, say how it is licensed.
|
|
113
|
+
## Key Design Rules
|
|
91
114
|
|
|
92
|
-
|
|
93
|
-
|
|
115
|
+
- **No local duplication** — if a type or utility is needed by ≥2 packages, it belongs here
|
|
116
|
+
- **No framework code** — this package must stay framework-agnostic (no React, no NestJS decorators)
|
|
117
|
+
- **Strict types** — no `any`. Use generics, discriminated unions, or `unknown`
|
|
118
|
+
- **Scoring is the business core** — the scoring engine drives the muscle fatigue diagram and progress charts. Read [docs/scoring.md](docs/scoring.md) before touching it
|
|
@@ -122,6 +122,7 @@ export type TExercise = {
|
|
|
122
122
|
popularityIndex: number;
|
|
123
123
|
isFavorite?: boolean;
|
|
124
124
|
scoringSpecialHandling?: "plyometric" | "stretch-mobility" | "continuous-duration" | "loaded-carry";
|
|
125
|
+
isFlaggedCorrection?: boolean;
|
|
125
126
|
};
|
|
126
127
|
export type TBodyPartExercises = Record<TBodyPart, TExercise[]>;
|
|
127
128
|
export type TApiCreateOrUpdateExerciseReq = {
|