@modelhealth/modelhealth 0.1.17

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/dist/types.js ADDED
@@ -0,0 +1,237 @@
1
+ /**
2
+ * Model Health SDK TypeScript Types
3
+ *
4
+ * Complete type definitions for the Model Health biomechanics SDK.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ // MARK: - Analysis
9
+ /**
10
+ * Represents available analysis functions for motion capture data.
11
+ *
12
+ * Each analysis type processes activity data to extract specific biomechanical metrics
13
+ * and insights. Analysis can only be performed on activities that have completed processing.
14
+ */
15
+ export const AnalysisType = {
16
+ /** Counter Movement Jump */
17
+ CounterMovementJump: "counter_movement_jump",
18
+ /** Overground Walking */
19
+ Gait: "gait",
20
+ /** Treadmill Running */
21
+ TreadmillRunning: "treadmill_running",
22
+ /** Sit-to-Stand Transfer */
23
+ SitToStand: "sit_to_stand",
24
+ /** Squat Exercise */
25
+ Squats: "squats",
26
+ /** Range of Motion (ROM) */
27
+ RangeOfMotion: "range_of_motion",
28
+ /** Overground Running */
29
+ OvergroundRunning: "overground_running",
30
+ /** Drop Vertical Jump */
31
+ DropJump: "drop_jump",
32
+ /** Hop Test */
33
+ Hop: "hop",
34
+ /** Treadmill Walking */
35
+ TreadmillGait: "treadmill_gait",
36
+ /** 5-0-5 Test */
37
+ ChangeOfDirection: "change_of_direction",
38
+ /** Cutting Maneuver */
39
+ Cut: "cut",
40
+ };
41
+ /**
42
+ * In-memory token storage implementation.
43
+ *
44
+ * **Warning**: Not secure - tokens are lost on page refresh.
45
+ * Only use for development and testing.
46
+ *
47
+ * For production, use:
48
+ * - Encrypted IndexedDB
49
+ * - HttpOnly cookies with CSRF protection
50
+ * - Platform-specific secure storage
51
+ */
52
+ export class MemoryTokenStorage {
53
+ constructor() {
54
+ this.token = null;
55
+ }
56
+ async getToken() {
57
+ return this.token;
58
+ }
59
+ async setToken(token) {
60
+ this.token = token;
61
+ }
62
+ async removeToken() {
63
+ this.token = null;
64
+ }
65
+ }
66
+ /**
67
+ * LocalStorage-based token storage implementation.
68
+ *
69
+ * **Warning**: LocalStorage is not encrypted. Use secure
70
+ * HTTP-only cookies or encrypted storage for production.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * const storage = new LocalStorageTokenStorage("my_app_token");
75
+ * const client = new ModelHealthService({ storage });
76
+ * ```
77
+ */
78
+ export class LocalStorageTokenStorage {
79
+ /**
80
+ * Create a LocalStorage token storage.
81
+ *
82
+ * @param key Storage key name (default: "modelhealth_token")
83
+ */
84
+ constructor(key = "modelhealth_token") {
85
+ this.key = key;
86
+ }
87
+ async getToken() {
88
+ if (typeof localStorage === "undefined") {
89
+ return null;
90
+ }
91
+ return localStorage.getItem(this.key);
92
+ }
93
+ async setToken(token) {
94
+ if (typeof localStorage === "undefined") {
95
+ throw new Error("localStorage is not available");
96
+ }
97
+ localStorage.setItem(this.key, token);
98
+ }
99
+ async removeToken() {
100
+ if (typeof localStorage === "undefined") {
101
+ return;
102
+ }
103
+ localStorage.removeItem(this.key);
104
+ }
105
+ }
106
+ // MARK: - Helper Functions for Analysis Results
107
+ /**
108
+ * Extract jump height from CMJ analysis results.
109
+ *
110
+ * @param result Analysis result from counter-movement jump
111
+ * @returns Jump height in centimeters, or null if not available
112
+ */
113
+ export function getJumpHeight(result) {
114
+ const metric = result.metrics["00_jump_height_COM"];
115
+ return metric?.value.type === "single" ? metric.value.value : null;
116
+ }
117
+ /**
118
+ * Extract jump time from CMJ analysis results.
119
+ *
120
+ * @param result Analysis result from counter-movement jump
121
+ * @returns Jump time in seconds, or null if not available
122
+ */
123
+ export function getJumpTime(result) {
124
+ const metric = result.metrics["01_jump_time"];
125
+ return metric?.value.type === "single" ? metric.value.value : null;
126
+ }
127
+ /**
128
+ * Extract concentric/eccentric time ratio from CMJ analysis results.
129
+ *
130
+ * @param result Analysis result from counter-movement jump
131
+ * @returns Time ratio, or null if not available
132
+ */
133
+ export function getConcentricEccentricTimeRatio(result) {
134
+ const metric = result.metrics["02_ratio_concentric_eccentric_time"];
135
+ return metric?.value.type === "single" ? metric.value.value : null;
136
+ }
137
+ /**
138
+ * Extract reactive strength index from CMJ analysis results.
139
+ *
140
+ * @param result Analysis result from counter-movement jump
141
+ * @returns Reactive strength index, or null if not available
142
+ */
143
+ export function getReactiveStrengthIndex(result) {
144
+ const metric = result.metrics["03_reactive_strength_index_COM"];
145
+ return metric?.value.type === "single" ? metric.value.value : null;
146
+ }
147
+ /**
148
+ * Extract peak vertical velocity from CMJ analysis results.
149
+ *
150
+ * @param result Analysis result from counter-movement jump
151
+ * @returns Peak velocity in m/s, or null if not available
152
+ */
153
+ export function getPeakVerticalVelocity(result) {
154
+ const metric = result.metrics["04_peak_vertical_COM_speed_during_takeoff"];
155
+ return metric?.value.type === "single" ? metric.value.value : null;
156
+ }
157
+ /**
158
+ * Extract peak knee extension speed during takeoff from CMJ analysis results.
159
+ *
160
+ * @param result Analysis result from counter-movement jump
161
+ * @returns Object with left and right values in deg/s, or null if not available
162
+ */
163
+ export function getPeakKneeExtensionSpeed(result) {
164
+ const metric = result.metrics["05_peak_knee_extension_speed_during_takeoff"];
165
+ return metric?.value.type === "bilateral"
166
+ ? { left: metric.value.left, right: metric.value.right }
167
+ : null;
168
+ }
169
+ /**
170
+ * Extract peak hip extension speed during takeoff from CMJ analysis results.
171
+ *
172
+ * @param result Analysis result from counter-movement jump
173
+ * @returns Object with left and right values in deg/s, or null if not available
174
+ */
175
+ export function getPeakHipExtensionSpeed(result) {
176
+ const metric = result.metrics["06_peak_hip_extension_speed_during_takeoff"];
177
+ return metric?.value.type === "bilateral"
178
+ ? { left: metric.value.left, right: metric.value.right }
179
+ : null;
180
+ }
181
+ /**
182
+ * Extract peak knee flexion angle during landing from CMJ analysis results.
183
+ *
184
+ * @param result Analysis result from counter-movement jump
185
+ * @returns Object with left and right values in degrees, or null if not available
186
+ */
187
+ export function getPeakKneeFlexionLanding(result) {
188
+ const metric = result.metrics["07_peak_knee_flexion_angle_during_landing"];
189
+ return metric?.value.type === "bilateral"
190
+ ? { left: metric.value.left, right: metric.value.right }
191
+ : null;
192
+ }
193
+ /**
194
+ * Extract peak knee valgus angle during landing from CMJ analysis results.
195
+ *
196
+ * @param result Analysis result from counter-movement jump
197
+ * @returns Object with left and right values in degrees, or null if not available
198
+ */
199
+ export function getPeakKneeValgusLanding(result) {
200
+ const metric = result.metrics["08_peak_dynamic_knee_valgus_angle_during_landing"];
201
+ return metric?.value.type === "bilateral"
202
+ ? { left: metric.value.left, right: metric.value.right }
203
+ : null;
204
+ }
205
+ /**
206
+ * Extract peak hip flexion angle during landing from CMJ analysis results.
207
+ *
208
+ * @param result Analysis result from counter-movement jump
209
+ * @returns Object with left and right values in degrees, or null if not available
210
+ */
211
+ export function getPeakHipFlexionLanding(result) {
212
+ const metric = result.metrics["09_peak_hip_flexion_angle_during_landing"];
213
+ return metric?.value.type === "bilateral"
214
+ ? { left: metric.value.left, right: metric.value.right }
215
+ : null;
216
+ }
217
+ /**
218
+ * Extract peak trunk flexion during landing from CMJ analysis results.
219
+ *
220
+ * @param result Analysis result from counter-movement jump
221
+ * @returns Trunk flexion angle in degrees, or null if not available
222
+ */
223
+ export function getPeakTrunkFlexionLanding(result) {
224
+ const metric = result.metrics["10_peak_trunk_flexion_relative_to_ground_during_landing"];
225
+ return metric?.value.type === "single" ? metric.value.value : null;
226
+ }
227
+ /**
228
+ * Extract peak trunk lean during landing from CMJ analysis results.
229
+ *
230
+ * @param result Analysis result from counter-movement jump
231
+ * @returns Trunk lean angle in degrees, or null if not available
232
+ */
233
+ export function getPeakTrunkLeanLanding(result) {
234
+ const metric = result.metrics["11_peak_trunk_lean_relative_to_ground_during_landing"];
235
+ return metric?.value.type === "single" ? metric.value.value : null;
236
+ }
237
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2QH,mBAAmB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C,CAAC,IAAI,CAAC;AACrE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAC,MAAsB;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,sDAAsD,CAAC,CAAC;IACtF,OAAO,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AACrE,CAAC"}
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@modelhealth/modelhealth",
3
+ "version": "0.1.17",
4
+ "description": "Model Health SDK for TypeScript/JavaScript",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist",
10
+ "wasm",
11
+ "model_health_wasm.js",
12
+ "model_health_wasm.d.ts",
13
+ "model_health_wasm_bg.wasm",
14
+ "model_health_wasm_bg.wasm.d.ts"
15
+ ],
16
+ "scripts": {
17
+ "build:wasm": "wasm-pack build ../model-health-wasm --target web --out-dir ../../model-health-ts/wasm --scope modelhealth",
18
+ "build:ts": "tsc",
19
+ "build": "npm run build:wasm && npm run build:ts",
20
+ "dev": "npm run build:wasm -- --dev && tsc --watch",
21
+ "clean": "rm -rf dist wasm node_modules"
22
+ },
23
+ "keywords": [
24
+ "modelhealth",
25
+ "biomechanics",
26
+ "motion-analysis",
27
+ "sdk"
28
+ ],
29
+ "author": "Model Health",
30
+ "license": "Apache-2.0",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/model-health/model-health"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^20.10.0",
37
+ "typedoc": "^0.28.15",
38
+ "typescript": "^5.3.0"
39
+ }
40
+ }