@dgpholdings/greatoak-shared 1.1.15 → 1.1.16

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.
@@ -81,12 +81,12 @@ export type TUser = {
81
81
  recoveryIssuedTimeStamp: number;
82
82
  recoveryVerifyToken: string;
83
83
  authMethod: TAuthType;
84
- gender?: "male" | "female";
85
- age?: number;
84
+ gender?: "male" | "female" | "unmentioned";
85
+ dob?: Date;
86
86
  weightKg?: number;
87
87
  heightCm?: number;
88
88
  };
89
- export type TUserSignInData = Pick<TUser, "email" | "isVerified" | "languageCountryCode" | "billingPlanType" | "billingPlanVersion" | "paymentMethod" | "authMethod">;
89
+ export type TUserSignInData = Pick<TUser, "email" | "isVerified" | "languageCountryCode" | "billingPlanType" | "billingPlanVersion" | "paymentMethod" | "authMethod" | "dob" | "weightKg">;
90
90
  export type TApiForgotPasswordReq = {
91
91
  email: string;
92
92
  captchaToken: string;
@@ -1,4 +1,3 @@
1
- import { TTemplateData } from "./TApiTemplateData";
2
1
  export type TRecord = {
3
2
  isDone: boolean;
4
3
  rpe?: string;
@@ -38,6 +37,7 @@ export type TRecordConfig = {
38
37
  };
39
38
  export type TApiExerciseRecordUpdateReq = {
40
39
  templateId: string;
40
+ startTime: Date;
41
41
  records: {
42
42
  exerciseId: string;
43
43
  config: TRecordConfig;
@@ -47,7 +47,6 @@ export type TApiExerciseRecordUpdateReq = {
47
47
  };
48
48
  export type TApiExerciseRecordUpdateRes = {
49
49
  status: 201;
50
- updatedTemplate: TTemplateData;
51
50
  } | {
52
51
  status: 400;
53
52
  };
@@ -0,0 +1,8 @@
1
+ export type TApiUserUpdateReq = {
2
+ dob: Date;
3
+ weightKg?: number;
4
+ appLanguage: string;
5
+ emailAddress?: string;
6
+ gender: "male" | "female" | "unmentioned";
7
+ };
8
+ export type TApiUserUpdateRes = TApiUserUpdateReq;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,16 @@
1
+ export type TRecordType = "weight-reps" | "duration" | "body-weight";
2
+ export interface TUserProfile {
3
+ age?: number;
4
+ gender?: "male" | "female" | "non-binary" | "unspecified";
5
+ weightKg?: number;
6
+ }
7
+ export interface TRecordInput {
8
+ isDone: boolean;
9
+ kg?: number;
10
+ reps?: number;
11
+ durationSecs?: string;
12
+ rpe?: number;
13
+ rir?: number;
14
+ auxWeightKg?: number;
15
+ }
16
+ export declare function computeScoreFromRecord(record: TRecordInput, recordType: TRecordType, userProfile?: TUserProfile): number;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeScoreFromRecord = computeScoreFromRecord;
4
+ const time_util_1 = require("./time.util");
5
+ function computeScoreFromRecord(record, recordType, userProfile) {
6
+ var _a, _b, _c, _d, _e, _f, _g, _h;
7
+ if (!record.isDone)
8
+ return 0;
9
+ // Determine load and effortFactor from record based on type
10
+ let load = 0;
11
+ let effortFactor = 0;
12
+ const rpe = (_a = record.rpe) !== null && _a !== void 0 ? _a : undefined;
13
+ const rir = (_b = record.rir) !== null && _b !== void 0 ? _b : undefined;
14
+ // Step 1: Determine effort factor
15
+ if (typeof rpe === "number") {
16
+ effortFactor = rpe;
17
+ }
18
+ else if (typeof rir === "number") {
19
+ effortFactor = 10 - rir; // lower RIR means more effort
20
+ }
21
+ // Step 2: Determine load
22
+ switch (recordType) {
23
+ case "weight-reps": {
24
+ const kg = (_c = record.kg) !== null && _c !== void 0 ? _c : 0;
25
+ const reps = (_d = record.reps) !== null && _d !== void 0 ? _d : 0;
26
+ load = kg * reps;
27
+ break;
28
+ }
29
+ case "duration": {
30
+ const durationSecs = (0, time_util_1.mmssToSecs)((_e = record.durationSecs) !== null && _e !== void 0 ? _e : "00:00");
31
+ const auxWeight = (_f = record.auxWeightKg) !== null && _f !== void 0 ? _f : 0;
32
+ load = auxWeight > 0 ? auxWeight * durationSecs : durationSecs;
33
+ break;
34
+ }
35
+ case "body-weight": {
36
+ const reps = (_g = record.reps) !== null && _g !== void 0 ? _g : 0;
37
+ const auxWeight = (_h = record.auxWeightKg) !== null && _h !== void 0 ? _h : 0;
38
+ load = auxWeight > 0 ? auxWeight * reps : reps;
39
+ break;
40
+ }
41
+ default:
42
+ return 0;
43
+ }
44
+ return computeFinalScore(load, effortFactor, userProfile);
45
+ }
46
+ function computeFinalScore(load, effortFactor, userProfile) {
47
+ const base = Math.log10(1 + Math.max(0, load));
48
+ const effortBoost = 1 + Math.min(effortFactor, 10) * 0.05;
49
+ // Optional scaling
50
+ let adjustment = 1;
51
+ if ((userProfile === null || userProfile === void 0 ? void 0 : userProfile.gender) === "female")
52
+ adjustment *= 1.1;
53
+ if ((userProfile === null || userProfile === void 0 ? void 0 : userProfile.age) && userProfile.age > 50)
54
+ adjustment *= 1.15;
55
+ if ((userProfile === null || userProfile === void 0 ? void 0 : userProfile.weightKg) && userProfile.weightKg > 0) {
56
+ const normalizedWeight = 70;
57
+ adjustment *= normalizedWeight / userProfile.weightKg;
58
+ }
59
+ return base * effortBoost * adjustment;
60
+ }
@@ -1 +1 @@
1
- export declare const mmssToSecs: (mmss: string) => number | undefined;
1
+ export declare const mmssToSecs: (mmss: string) => number;
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mmssToSecs = void 0;
4
- const number_util_1 = require("./number.util");
5
4
  const mmssToSecs = (mmss) => {
6
- const [mm, ss] = mmss.split(":");
7
- return (0, number_util_1.toNumber)(`${mm}${ss}`);
5
+ const [min, sec] = mmss.split(":").map(Number);
6
+ return (min || 0) * 60 + (sec || 0);
8
7
  };
9
8
  exports.mmssToSecs = mmssToSecs;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dgpholdings/greatoak-shared",
3
- "version": "1.1.15",
3
+ "version": "1.1.16",
4
4
  "description": "Shared TypeScript types and utilities for @dgpholdings projects",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",