@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/README.md ADDED
@@ -0,0 +1,214 @@
1
+ # Model Health SDK for TypeScript
2
+
3
+ TypeScript/JavaScript SDK for the Model Health biomechanics platform.
4
+
5
+ ## Features
6
+
7
+ - 📦 **Type-safe**: Full TypeScript type definitions
8
+ - 🌐 **Cross-platform**: Works in browsers, Node.js, React, Vue, Svelte, etc.
9
+ - 🔒 **API key authentication**: Use your Model Health API key
10
+ - ⚡ **Fast**: WASM performance with JavaScript ergonomics
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @modelhealth/modelhealth
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```typescript
21
+ import { ModelHealthService } from '@modelhealth/modelhealth';
22
+
23
+ const client = new ModelHealthService({
24
+ apiKey: 'your-api-key-here',
25
+ });
26
+ await client.init();
27
+
28
+ const sessions = await client.sessionList();
29
+ console.log(sessions);
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ ### Optional: Disable auto-init
35
+
36
+ ```typescript
37
+ const client = new ModelHealthService({
38
+ apiKey: 'your-api-key',
39
+ autoInit: false, // Call init() manually when ready
40
+ });
41
+ ```
42
+
43
+ ## API Reference
44
+
45
+ ### Sessions
46
+
47
+ ```typescript
48
+ // Get all sessions
49
+ const sessions = await client.sessionList();
50
+
51
+ // Get specific session with trials
52
+ const session = await client.getSession('session-id');
53
+
54
+ // Create new session
55
+ const newSession = await client.createSession();
56
+ ```
57
+
58
+ ### Subjects
59
+
60
+ ```typescript
61
+ // Get all subjects
62
+ const subjects = await client.subjectList();
63
+ ```
64
+
65
+ ### Trials
66
+
67
+ ```typescript
68
+ // Get trials for a session
69
+ const trials = await client.trialList('session-id');
70
+
71
+ // Download trial videos
72
+ const videos = await client.downloadTrialVideos(
73
+ trial,
74
+ 'raw' // or 'synced'
75
+ );
76
+
77
+ // Download result data
78
+ const results = await client.downloadTrialResultData(
79
+ trial,
80
+ ['motData', 'csvData']
81
+ );
82
+ ```
83
+
84
+ ### Utilities
85
+
86
+ ```typescript
87
+ // Convert MOT to CSV
88
+ const motData = new Uint8Array([...]); // MOT file data
89
+ const csv = ModelHealthService.motToCsv(motData);
90
+ ```
91
+
92
+ ## React Example
93
+
94
+ ```tsx
95
+ import { useState, useEffect } from 'react';
96
+ import { ModelHealthService, Session } from '@modelhealth/modelhealth';
97
+
98
+ function App() {
99
+ const [client] = useState(
100
+ () => new ModelHealthService({ apiKey: 'your-api-key' })
101
+ );
102
+ const [sessions, setSessions] = useState<Session[]>([]);
103
+ const [loading, setLoading] = useState(true);
104
+
105
+ useEffect(() => {
106
+ async function init() {
107
+ await client.init();
108
+ const data = await client.sessionList();
109
+ setSessions(data);
110
+ setLoading(false);
111
+ }
112
+
113
+ init();
114
+ }, [client]);
115
+
116
+ if (loading)
117
+ return <div>Loading...</div>;
118
+
119
+ return (
120
+ <div>
121
+ <h1>Sessions</h1>
122
+ {sessions.map(session => (
123
+ <div key={session.id}>{session.name}</div>
124
+ ))}
125
+ </div>
126
+ );
127
+ }
128
+ ```
129
+
130
+ ## Vite Configuration
131
+
132
+ If using Vite, add WASM support:
133
+
134
+ ```typescript
135
+ // vite.config.ts
136
+ import { defineConfig } from 'vite';
137
+ import wasm from 'vite-plugin-wasm';
138
+ import topLevelAwait from 'vite-plugin-top-level-await';
139
+
140
+ export default defineConfig({
141
+ plugins: [
142
+ wasm(),
143
+ topLevelAwait(),
144
+ ],
145
+ });
146
+ ```
147
+
148
+ Install plugins:
149
+ ```bash
150
+ npm install -D vite-plugin-wasm vite-plugin-top-level-await
151
+ ```
152
+
153
+ ## TypeScript Types
154
+
155
+ All types are fully documented with JSDoc comments. Import types as needed:
156
+
157
+ ```typescript
158
+ import type {
159
+ Session,
160
+ Subject,
161
+ Trial,
162
+ CheckerboardDetails,
163
+ // ... etc
164
+ } from '@modelhealth/modelhealth';
165
+ ```
166
+
167
+ ## Building from Source
168
+
169
+ ```bash
170
+ # Install dependencies
171
+ npm install
172
+
173
+ # Build WASM and TypeScript
174
+ npm run build
175
+
176
+ # Development build with watch mode
177
+ npm run dev
178
+ ```
179
+
180
+ ### Requirements
181
+
182
+ - Node.js 18+
183
+ - Rust 1.70+
184
+ - wasm-pack (`cargo install wasm-pack`)
185
+
186
+ ## Platform Support
187
+
188
+ - ✅ Modern browsers (Chrome, Firefox, Safari, Edge)
189
+ - ✅ Node.js 18+ (with WASM support)
190
+ - ✅ React, Vue, Svelte, Angular
191
+ - ✅ React Native (with WASM bridge)
192
+ - ✅ Electron
193
+
194
+ ## Error Handling
195
+
196
+ All async methods can throw errors. Always use try-catch:
197
+
198
+ ```typescript
199
+ try {
200
+ const sessions = await client.sessionList();
201
+ } catch (error) {
202
+ console.error('Request failed:', error);
203
+ }
204
+ ```
205
+
206
+ ## License
207
+
208
+ Apache-2.0 © Model Health
209
+
210
+ ## Support
211
+
212
+ - Documentation: https://docs.modelhealth.io
213
+ - Issues: https://github.com/model-health/model-health/issues
214
+ - Email: support@modelhealth.io