@krampa/common 0.3.2 → 0.4.0

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 CHANGED
@@ -20,20 +20,43 @@ npm install @krampa/common
20
20
  import { GOAL_TYPES, GOAL_TYPE_VALUES, GoalType } from "@krampa/common";
21
21
 
22
22
  // Use constants
23
- const goalType = GOAL_TYPES.FREQUENCY_CARDIO; // "frequency/cardio"
23
+ const goalType = GOAL_TYPES.WORKOUT_STRENGTH; // "workout/strength"
24
24
 
25
25
  // Use in TypeScript types
26
26
  const myGoal: GoalType = "weight/loss";
27
27
 
28
28
  // Use for database enum
29
29
  const dbEnum = GOAL_TYPE_VALUES; // Array of all valid goal types
30
+ ```
31
+
32
+ ### Challenge Status
33
+
34
+ ```typescript
35
+ import { CHALLENGE_STATUSES, CHALLENGE_STATUS_VALUES, ChallengeStatus } from "@krampa/common";
36
+
37
+ // Use constants
38
+ const status = CHALLENGE_STATUSES.ONGOING; // "ONGOING"
39
+
40
+ // Use in TypeScript types
41
+ const challengeStatus: ChallengeStatus = "PENDING";
42
+
43
+ // Use for database enum
44
+ const dbEnum = CHALLENGE_STATUS_VALUES; // Array of all valid challenge statuses
45
+ ```
30
46
 
31
- // Type guards
32
- import { isCardioGoal, isWeightGoal } from "@krampa/common";
47
+ ### Invite Status
33
48
 
34
- if (isCardioGoal(goal.type)) {
35
- // Handle cardio-specific logic
36
- }
49
+ ```typescript
50
+ import { INVITE_STATUSES, INVITE_STATUS_VALUES, InviteStatus } from "@krampa/common";
51
+
52
+ // Use constants
53
+ const status = INVITE_STATUSES.ACCEPTED; // "ACCEPTED"
54
+
55
+ // Use in TypeScript types
56
+ const inviteStatus: InviteStatus = "PENDING";
57
+
58
+ // Use for database enum
59
+ const dbEnum = INVITE_STATUS_VALUES; // Array of all valid invite statuses
37
60
  ```
38
61
 
39
62
  ## Development
@@ -6,7 +6,7 @@ export declare const GOAL_TYPES: {
6
6
  readonly WEIGHT_LOSS: "weight/loss";
7
7
  readonly WEIGHT_GAIN: "weight/gain";
8
8
  readonly WEIGHT_MAINTAIN: "weight/maintain";
9
- readonly WORKOUT_GENERAL: "workout/general";
9
+ readonly WORKOUT_STRENGTH: "workout/strength";
10
10
  readonly WORKOUT_CARDIO: "workout/cardio";
11
11
  readonly WORKOUT_OTHER: "workout/other";
12
12
  readonly ACHIEVEMENT_PR: "achievement/pr";
@@ -14,5 +14,5 @@ export declare const GOAL_TYPES: {
14
14
  readonly MEASUREMENT_BODY: "measurement/body";
15
15
  readonly CUSTOM_OTHER: "custom/other";
16
16
  };
17
- export declare const GOAL_TYPE_VALUES: readonly ["weight/loss", "weight/gain", "weight/maintain", "workout/general", "workout/cardio", "workout/other", "achievement/pr", "steps/daily", "measurement/body", "custom/other"];
17
+ export declare const GOAL_TYPE_VALUES: readonly ["weight/loss", "weight/gain", "weight/maintain", "workout/strength", "workout/cardio", "workout/other", "achievement/pr", "steps/daily", "measurement/body", "custom/other"];
18
18
  export type GoalType = (typeof GOAL_TYPE_VALUES)[number];
@@ -12,7 +12,7 @@ exports.GOAL_TYPES = {
12
12
  WEIGHT_GAIN: "weight/gain",
13
13
  WEIGHT_MAINTAIN: "weight/maintain",
14
14
  // Workout goals (distance/time embedded in cardio)
15
- WORKOUT_GENERAL: "workout/general",
15
+ WORKOUT_STRENGTH: "workout/strength",
16
16
  WORKOUT_CARDIO: "workout/cardio",
17
17
  WORKOUT_OTHER: "workout/other",
18
18
  // Achievement goals
@@ -27,7 +27,7 @@ exports.GOAL_TYPE_VALUES = [
27
27
  exports.GOAL_TYPES.WEIGHT_LOSS,
28
28
  exports.GOAL_TYPES.WEIGHT_GAIN,
29
29
  exports.GOAL_TYPES.WEIGHT_MAINTAIN,
30
- exports.GOAL_TYPES.WORKOUT_GENERAL,
30
+ exports.GOAL_TYPES.WORKOUT_STRENGTH,
31
31
  exports.GOAL_TYPES.WORKOUT_CARDIO,
32
32
  exports.GOAL_TYPES.WORKOUT_OTHER,
33
33
  exports.GOAL_TYPES.ACHIEVEMENT_PR,
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Goal value type definitions
3
+ * Shared between frontend and backend for type safety
4
+ */
5
+ export type WeightChange = {
6
+ startWeight: number;
7
+ targetWeight: number;
8
+ };
9
+ export type WeightMaintain = {
10
+ targetWeight: number;
11
+ };
12
+ export type WorkoutCardioValue = {
13
+ activityName: string;
14
+ weeklyTarget: number;
15
+ weeklyDistance?: number;
16
+ weeklyTime?: number;
17
+ };
18
+ export type WorkoutOtherValue = {
19
+ activityName: string;
20
+ weeklyTarget: number;
21
+ };
22
+ export type WorkoutStrengthValue = {
23
+ weeklyTarget: number;
24
+ workoutTypes: string[];
25
+ };
26
+ export type StepsGoalValue = {
27
+ targetSteps: number;
28
+ };
29
+ type BaseGoal = {};
30
+ export type WeightLossGoal = BaseGoal & {
31
+ type: "weight/loss";
32
+ value: WeightChange;
33
+ };
34
+ export type WeightGainGoal = BaseGoal & {
35
+ type: "weight/gain";
36
+ value: WeightChange;
37
+ };
38
+ export type WeightMaintainGoal = BaseGoal & {
39
+ type: "weight/maintain";
40
+ value: WeightMaintain;
41
+ };
42
+ export type WorkoutStrengthGoal = BaseGoal & {
43
+ type: "workout/strength";
44
+ value: WorkoutStrengthValue;
45
+ };
46
+ export type WorkoutCardioGoal = BaseGoal & {
47
+ type: "workout/cardio";
48
+ value: WorkoutCardioValue;
49
+ };
50
+ export type WorkoutOtherGoal = BaseGoal & {
51
+ type: "workout/other";
52
+ value: WorkoutOtherValue;
53
+ };
54
+ export type StepsGoal = BaseGoal & {
55
+ type: "steps/daily";
56
+ value: StepsGoalValue;
57
+ };
58
+ export type Goal = WeightLossGoal | WeightGainGoal | WeightMaintainGoal | WorkoutStrengthGoal | WorkoutCardioGoal | WorkoutOtherGoal | StepsGoal;
59
+ export {};
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * Goal value type definitions
4
+ * Shared between frontend and backend for type safety
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -3,5 +3,6 @@
3
3
  * Shared types and constants
4
4
  */
5
5
  export * from "./goal-types";
6
+ export * from "./goal-value-types";
6
7
  export * from "./invite-status";
7
8
  export * from "./challenge-status";
package/dist/index.js CHANGED
@@ -19,5 +19,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  __exportStar(require("./goal-types"), exports);
22
+ __exportStar(require("./goal-value-types"), exports);
22
23
  __exportStar(require("./invite-status"), exports);
23
24
  __exportStar(require("./challenge-status"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krampa/common",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Shared types and constants for Krampa fitness challenge app",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",