@krampa/common 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 dabbe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @dabbe/krampa-common
2
+
3
+ Shared types and constants for the Krampa fitness challenge app.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @dabbe/krampa-common
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Goal Types
14
+
15
+ ```typescript
16
+ import { GOAL_TYPES, GOAL_TYPE_VALUES, GoalType } from "@dabbe/krampa-common";
17
+
18
+ // Use constants
19
+ const goalType = GOAL_TYPES.FREQUENCY_CARDIO; // "frequency/cardio"
20
+
21
+ // Use in TypeScript types
22
+ const myGoal: GoalType = "weight/loss";
23
+
24
+ // Use for database enum
25
+ const dbEnum = GOAL_TYPE_VALUES; // Array of all valid goal types
26
+
27
+ // Type guards
28
+ import { isCardioGoal, isWeightGoal } from "@dabbe/krampa-common";
29
+
30
+ if (isCardioGoal(goal.type)) {
31
+ // Handle cardio-specific logic
32
+ }
33
+ ```
34
+
35
+ ## Development
36
+
37
+ ```bash
38
+ # Build the package
39
+ npm run build
40
+
41
+ # Publish to npm (requires npm login)
42
+ npm publish --access public
43
+ ```
44
+
45
+ ## License
46
+
47
+ MIT
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Goal type constants for Krampa fitness challenge app
3
+ * These types follow a category/subtype pattern (e.g., "weight/loss", "frequency/cardio")
4
+ */
5
+ export declare const GOAL_TYPES: {
6
+ readonly WEIGHT_LOSS: "weight/loss";
7
+ readonly WEIGHT_GAIN: "weight/gain";
8
+ readonly WEIGHT_MAINTAIN: "weight/maintain";
9
+ readonly FREQUENCY_GENERAL: "frequency/general";
10
+ readonly FREQUENCY_CARDIO: "frequency/cardio";
11
+ readonly FREQUENCY_OTHER: "frequency/other";
12
+ readonly ACHIEVEMENT_PR: "achievement/pr";
13
+ readonly ACHIEVEMENT_STEPS: "achievement/steps";
14
+ readonly MEASUREMENT_BODY: "measurement/body";
15
+ readonly CUSTOM_OTHER: "custom/other";
16
+ };
17
+ export declare const GOAL_TYPE_VALUES: readonly ["weight/loss", "weight/gain", "weight/maintain", "frequency/general", "frequency/cardio", "frequency/other", "achievement/pr", "achievement/steps", "measurement/body", "custom/other"];
18
+ export type GoalType = (typeof GOAL_TYPE_VALUES)[number];
19
+ export declare const isWeightGoal: (type: string) => boolean;
20
+ export declare const isFrequencyGoal: (type: string) => boolean;
21
+ export declare const isAchievementGoal: (type: string) => boolean;
22
+ export declare const isCardioGoal: (type: string) => boolean;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /**
3
+ * Goal type constants for Krampa fitness challenge app
4
+ * These types follow a category/subtype pattern (e.g., "weight/loss", "frequency/cardio")
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.isCardioGoal = exports.isAchievementGoal = exports.isFrequencyGoal = exports.isWeightGoal = exports.GOAL_TYPE_VALUES = exports.GOAL_TYPES = void 0;
8
+ // Goal type enum values (matches database enum)
9
+ exports.GOAL_TYPES = {
10
+ // Weight goals
11
+ WEIGHT_LOSS: "weight/loss",
12
+ WEIGHT_GAIN: "weight/gain",
13
+ WEIGHT_MAINTAIN: "weight/maintain",
14
+ // Frequency goals (distance/time embedded in cardio)
15
+ FREQUENCY_GENERAL: "frequency/general",
16
+ FREQUENCY_CARDIO: "frequency/cardio",
17
+ FREQUENCY_OTHER: "frequency/other",
18
+ // Achievement goals
19
+ ACHIEVEMENT_PR: "achievement/pr",
20
+ ACHIEVEMENT_STEPS: "achievement/steps",
21
+ // Other
22
+ MEASUREMENT_BODY: "measurement/body",
23
+ CUSTOM_OTHER: "custom/other",
24
+ };
25
+ // Array of all goal type values (for database enum)
26
+ exports.GOAL_TYPE_VALUES = [
27
+ exports.GOAL_TYPES.WEIGHT_LOSS,
28
+ exports.GOAL_TYPES.WEIGHT_GAIN,
29
+ exports.GOAL_TYPES.WEIGHT_MAINTAIN,
30
+ exports.GOAL_TYPES.FREQUENCY_GENERAL,
31
+ exports.GOAL_TYPES.FREQUENCY_CARDIO,
32
+ exports.GOAL_TYPES.FREQUENCY_OTHER,
33
+ exports.GOAL_TYPES.ACHIEVEMENT_PR,
34
+ exports.GOAL_TYPES.ACHIEVEMENT_STEPS,
35
+ exports.GOAL_TYPES.MEASUREMENT_BODY,
36
+ exports.GOAL_TYPES.CUSTOM_OTHER,
37
+ ];
38
+ // Helper type guards
39
+ const isWeightGoal = (type) => type.startsWith("weight/");
40
+ exports.isWeightGoal = isWeightGoal;
41
+ const isFrequencyGoal = (type) => type.startsWith("frequency/");
42
+ exports.isFrequencyGoal = isFrequencyGoal;
43
+ const isAchievementGoal = (type) => type.startsWith("achievement/");
44
+ exports.isAchievementGoal = isAchievementGoal;
45
+ const isCardioGoal = (type) => type === exports.GOAL_TYPES.FREQUENCY_CARDIO;
46
+ exports.isCardioGoal = isCardioGoal;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @dabbe/krampa-common
3
+ * Shared types and constants for Krampa fitness challenge app
4
+ */
5
+ export * from "./goal-types";
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /**
3
+ * @dabbe/krampa-common
4
+ * Shared types and constants for Krampa fitness challenge app
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ __exportStar(require("./goal-types"), exports);
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "@krampa/common",
3
+ "version": "0.1.0",
4
+ "description": "Shared types and constants for Krampa fitness challenge app",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "krampa",
16
+ "types",
17
+ "typescript"
18
+ ],
19
+ "author": "Daniel",
20
+ "license": "MIT",
21
+ "devDependencies": {
22
+ "typescript": "^5.3.3"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/dabbe/krampa-common.git"
27
+ }
28
+ }