@modelhealth/modelhealth 0.2.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -16,7 +16,7 @@
16
16
  * const sessions = await client.sessionList();
17
17
  * ```
18
18
  */
19
- import type { CheckerboardDetails, Session, Subject, SubjectParameters, Activity, ActivitySort, ActivityTag, VideoVersion, MotionDataType, MotionData, AnalysisDataType, AnalysisData, AnalysisType, Analysis, AnalysisStatus, ActivityStatus, CalibrationStatus } from "./types.js";
19
+ import type { CheckerboardDetails, Session, SessionConfig, Subject, SubjectParameters, Activity, ActivitySort, ActivityTag, VideoVersion, MotionDataType, MotionData, AnalysisDataType, AnalysisData, ActivityType, ActivityConfig, Analysis, AnalysisStatus, ActivityStatus, CalibrationStatus, ImportStatus, Archive, ArchiveStatus } from "./types.js";
20
20
  /**
21
21
  * Configuration options for the Model Health client.
22
22
  */
@@ -27,7 +27,7 @@ export interface ModelHealthConfig {
27
27
  * This is required to use the SDK. Get your API key from the
28
28
  * ModelHealth dashboard.
29
29
  *
30
- * @required
30
+ * Required.
31
31
  */
32
32
  apiKey: string;
33
33
  /**
@@ -147,7 +147,7 @@ export declare class ModelHealthService {
147
147
  * Creates a session.
148
148
  *
149
149
  * A session is the parent container for a movement capture workflow. It links
150
- * related entities such as activities and subjects, and provides the context
150
+ * related entities such as activities and subjects and provides the context
151
151
  * used by subsequent operations.
152
152
  *
153
153
  * @returns A new `Session` with a unique identifier.
@@ -159,6 +159,31 @@ export declare class ModelHealthService {
159
159
  * ```
160
160
  */
161
161
  createSession(): Promise<Session>;
162
+ /**
163
+ * Applies settings to an existing session.
164
+ *
165
+ * Call this after `createSession` and before calibration to override any
166
+ * default settings. If not called, the session retains the defaults applied
167
+ * during creation.
168
+ *
169
+ * All fields in `config` are optional — omit any field to keep its default.
170
+ *
171
+ * @param session The session to configure.
172
+ * @param config The settings to apply. Pass `{}` to keep all defaults.
173
+ * @throws On network failure or authentication error.
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * const session = await client.createSession();
178
+ *
179
+ * // Override frame rate and data sharing only
180
+ * await client.configureSession(session, {
181
+ * framerate: 60,
182
+ * dataSharing: "Share no data"
183
+ * });
184
+ * ```
185
+ */
186
+ configureSession(session: Session, config?: SessionConfig): Promise<void>;
162
187
  /**
163
188
  * Calibrates cameras using a checkerboard pattern.
164
189
  *
@@ -217,7 +242,7 @@ export declare class ModelHealthService {
217
242
  * Retrieves all subjects associated with the API key.
218
243
  *
219
244
  * Subjects represent individuals being monitored or assessed. Each subject may
220
- * contain demographic information, physical measurements, and categorization tags.
245
+ * contain demographic information, physical measurements and categorization tags.
221
246
  *
222
247
  * @returns An array of `Subject` objects, or an empty array if none exist.
223
248
  * @throws If the request fails due to network or authentication issues.
@@ -276,7 +301,7 @@ export declare class ModelHealthService {
276
301
  * ```typescript
277
302
  * // First page
278
303
  * const page1 = await client.activitiesForSubject(
279
- * "subject-123",
304
+ * subject.id,
280
305
  * 0,
281
306
  * 20,
282
307
  * "updated_at"
@@ -284,14 +309,14 @@ export declare class ModelHealthService {
284
309
  *
285
310
  * // Next page
286
311
  * const page2 = await client.activitiesForSubject(
287
- * "subject-123",
312
+ * subject.id,
288
313
  * 20,
289
314
  * 20,
290
315
  * "updated_at"
291
316
  * );
292
317
  * ```
293
318
  */
294
- activitiesForSubject(subjectId: string, startIndex: number, count: number, sort: ActivitySort): Promise<Activity[]>;
319
+ activitiesForSubject(subjectId: number, startIndex: number, count: number, sort: ActivitySort): Promise<Activity[]>;
295
320
  /**
296
321
  * Retrieves an activity by its ID.
297
322
  *
@@ -332,7 +357,7 @@ export declare class ModelHealthService {
332
357
  /**
333
358
  * Deletes an activity.
334
359
  *
335
- * Permanently removes the activity and all associated videos, results, and metadata.
360
+ * Permanently removes the activity and all associated videos, results and metadata.
336
361
  *
337
362
  * @param activity The activity to delete.
338
363
  * @throws If the deletion fails or the request fails.
@@ -343,7 +368,7 @@ export declare class ModelHealthService {
343
368
  * await client.deleteActivity(activity);
344
369
  * ```
345
370
  *
346
- * @warning This operation is irreversible.
371
+ * **Warning:** This operation is irreversible.
347
372
  */
348
373
  deleteActivity(activity: Activity): Promise<void>;
349
374
  /**
@@ -409,7 +434,7 @@ export declare class ModelHealthService {
409
434
  * }
410
435
  * ```
411
436
  *
412
- * @note Downloads run concurrently. Individual download failures do not affect other requests.
437
+ * Downloads run concurrently. Individual download failures do not affect other requests.
413
438
  */
414
439
  videosForActivity(activity: Activity, version?: VideoVersion): Promise<Uint8Array[]>;
415
440
  /**
@@ -419,8 +444,8 @@ export declare class ModelHealthService {
419
444
  * such as kinematics, marker data, or an OpenSim model. Downloads run concurrently and
420
445
  * failed downloads are silently excluded from results.
421
446
  *
422
- * @param dataTypes The motion data types to download (for example, `"kinematics_mot"`, `"markers"`, `"animation"`).
423
447
  * @param activity The activity to download data from. Must have completed processing.
448
+ * @param dataTypes The motion data types to download (for example, `"kinematics_mot"`, `"markers"`, `"animation"`).
424
449
  * @returns An array of `MotionData`, one entry per successfully downloaded type. May be empty
425
450
  * if no results are available or all downloads fail.
426
451
  *
@@ -430,7 +455,7 @@ export declare class ModelHealthService {
430
455
  * const results = await client.motionDataForActivity(activity, ["kinematics_mot"]);
431
456
  *
432
457
  * for (const result of results) {
433
- * switch (result.resultDataType) {
458
+ * switch (result.type) {
434
459
  * case "kinematics_mot":
435
460
  * // Use result.data directly as a .mot file
436
461
  * break;
@@ -447,8 +472,8 @@ export declare class ModelHealthService {
447
472
  * a report, or raw data. Downloads run concurrently and failed downloads are silently
448
473
  * excluded from results.
449
474
  *
450
- * @param dataTypes The analysis result data types to download (for example, `"metrics"`, `"report"`, `"data"`).
451
475
  * @param activity The activity to download analysis results from. Must have a completed analysis.
476
+ * @param dataTypes The analysis result data types to download (for example, `"metrics"`, `"report"`, `"data"`).
452
477
  * @returns An array of `AnalysisData`, one entry per successfully downloaded type.
453
478
  * May be empty if no results are available or all downloads fail.
454
479
  *
@@ -460,7 +485,7 @@ export declare class ModelHealthService {
460
485
  * );
461
486
  *
462
487
  * for (const result of results) {
463
- * switch (result.resultDataType) {
488
+ * switch (result.type) {
464
489
  * case "metrics":
465
490
  * const json = JSON.parse(new TextDecoder().decode(result.data));
466
491
  * break;
@@ -484,17 +509,18 @@ export declare class ModelHealthService {
484
509
  *
485
510
  * @param activityName A descriptive name for this activity (e.g., `"cmj"`, `"squat"`).
486
511
  * @param session The session this activity is associated with.
512
+ * @param config Optional recording configuration.
487
513
  * @returns The newly created `Activity`.
488
514
  * @throws If recording cannot start (e.g., missing calibration).
489
515
  *
490
516
  * @example
491
517
  * ```typescript
492
- * const activity = await client.startRecording("cmj", session);
518
+ * const activity = await client.startRecording("cmj", session, { activityType: ActivityType.CounterMovementJump });
493
519
  * // Subject performs movement...
494
520
  * await client.stopRecording(session);
495
521
  * ```
496
522
  */
497
- startRecording(activityName: string, session: Session): Promise<Activity>;
523
+ startRecording(activityName: string, session: Session, config?: ActivityConfig): Promise<Activity>;
498
524
  /**
499
525
  * Stops the active recording for a movement trial.
500
526
  *
@@ -547,7 +573,7 @@ export declare class ModelHealthService {
547
573
  * Call this after `activityStatus` returns `ready`. Use the
548
574
  * returned `Analysis` with `analysisStatus` to poll progress.
549
575
  *
550
- * @param analysisType The type of analysis to run (for example, `"gait"`, `"counter_movement_jump"`).
576
+ * @param activityType The type of analysis to run (for example, `"gait"`, `"counter_movement_jump"`).
551
577
  * @param activity The activity to analyze.
552
578
  * @param session The session context containing the activity.
553
579
  * @returns An `Analysis` for tracking analysis progress.
@@ -559,7 +585,7 @@ export declare class ModelHealthService {
559
585
  * const status = await client.analysisStatus(task);
560
586
  * ```
561
587
  */
562
- startAnalysis(analysisType: AnalysisType, activity: Activity, session: Session): Promise<Analysis>;
588
+ startAnalysis(activityType: ActivityType, activity: Activity, session: Session): Promise<Analysis>;
563
589
  /**
564
590
  * Retrieves the current status of an analysis task.
565
591
  *
@@ -588,6 +614,116 @@ export declare class ModelHealthService {
588
614
  * ```
589
615
  */
590
616
  analysisStatus(task: Analysis): Promise<AnalysisStatus>;
617
+ /**
618
+ * Imports a set of trials into a new session.
619
+ *
620
+ * Performs the full import workflow: session creation, configuration,
621
+ * subject association, trial creation, video download and upload, processing
622
+ * trigger and polling until complete for each trial.
623
+ *
624
+ * Progress is reported via `statusCallback` with `ImportStatus` values.
625
+ *
626
+ * @param activitiesJson A JSON array of trial objects to import.
627
+ * @param subject The subject to associate with the session.
628
+ * @param config Session configuration. Pass `{}` for defaults.
629
+ * @param statusCallback Callback called with progress updates. Defaults to no-op.
630
+ * @returns The `Session` containing all imported trials.
631
+ * @throws If any step of the import fails.
632
+ *
633
+ * @example
634
+ * ```typescript
635
+ * const session = await client.importSession(
636
+ * activitiesJson,
637
+ * subject,
638
+ * null,
639
+ * { framerate: 60 },
640
+ * (status) => {
641
+ * switch (status.type) {
642
+ * case "creating_session":
643
+ * console.log("Creating session...");
644
+ * break;
645
+ * case "uploading_video":
646
+ * console.log(`[${status.trial}] ${status.uploaded}/${status.total}`);
647
+ * break;
648
+ * case "processing":
649
+ * console.log("Processing...");
650
+ * break;
651
+ * }
652
+ * }
653
+ * );
654
+ * ```
655
+ */
656
+ importSession(activitiesJson: string, subject: Subject, config?: SessionConfig, statusCallback?: (status: ImportStatus) => void): Promise<Session>;
657
+ /**
658
+ * Begins preparing a session archive.
659
+ *
660
+ * Kicks off a server-side task that packages the session data into a ZIP file.
661
+ * Poll `archiveStatus` until the status is `ready`, then download the archive
662
+ * with `archiveData`.
663
+ *
664
+ * @param session The session to archive.
665
+ * @param withVideos Whether to include raw videos in the archive. Defaults to `false`.
666
+ * @returns An `Archive` for tracking archive preparation progress.
667
+ * @throws If the request fails.
668
+ *
669
+ * @example
670
+ * ```typescript
671
+ * const archive = await client.prepareArchive(session);
672
+ *
673
+ * let status: ArchiveStatus;
674
+ * do {
675
+ * status = await client.archiveStatus(archive);
676
+ * } while (status.type === "processing");
677
+ *
678
+ * const zipData = await client.archiveData(archive);
679
+ * ```
680
+ */
681
+ prepareArchive(session: Session, withVideos?: boolean): Promise<Archive>;
682
+ /**
683
+ * Retrieves the current status of an archive preparation task.
684
+ *
685
+ * Poll this method after `prepareArchive` until the status is `ready`,
686
+ * then download the archive with `archiveData`.
687
+ *
688
+ * @param archive The archive returned from `prepareArchive`.
689
+ * @returns The current `ArchiveStatus`.
690
+ * @throws If the request fails.
691
+ *
692
+ * @example
693
+ * ```typescript
694
+ * const status = await client.archiveStatus(archive);
695
+ *
696
+ * switch (status.type) {
697
+ * case "processing":
698
+ * console.log("Archive being prepared...");
699
+ * break;
700
+ * case "ready":
701
+ * console.log("Archive ready to download");
702
+ * break;
703
+ * case "failed":
704
+ * console.log("Archive preparation failed");
705
+ * break;
706
+ * }
707
+ * ```
708
+ */
709
+ archiveStatus(archive: Archive): Promise<ArchiveStatus>;
710
+ /**
711
+ * Downloads the prepared archive as raw ZIP data.
712
+ *
713
+ * Call this after `archiveStatus` returns `ready`. The download URL is
714
+ * managed internally and cached for the lifetime of the WASM instance.
715
+ *
716
+ * @param archive The archive returned from `prepareArchive`.
717
+ * @returns The raw ZIP file bytes as a `Uint8Array`.
718
+ * @throws If the archive is not yet ready or the download fails.
719
+ *
720
+ * @example
721
+ * ```typescript
722
+ * const zipData = await client.archiveData(archive);
723
+ * // Write zipData to a file or process it in memory
724
+ * ```
725
+ */
726
+ archiveData(archive: Archive): Promise<Uint8Array>;
591
727
  /**
592
728
  * Parse a WASM response and normalise object keys to camelCase.
593
729
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR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AMxG;;;;;;;;;;;;;OAaG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,cAAc,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC;IAMjE;;;;;;;;;;;;;;;;;OAiBG;IACG,aAAa,CACjB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,GACf,OAAO,CAAC,QAAQ,CAAC;IAYpB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACG,aAAa,CACjB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,OAAO,EAChB,MAAM,GAAE,aAAkB,EAC1B,cAAc,GAAE,CAAC,MAAM,EAAE,YAAY,KAAK,IAAe,GACxD,OAAO,CAAC,OAAO,CAAC;IAuCnB;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,cAAc,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,UAAQ,GAAG,OAAO,CAAC,OAAO,CAAC;IAM5E;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACG,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAM7D;;;;;;;;;;;;;;;OAeG;IACG,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAQxD;;;;;;;;;;OAUG;IACH,OAAO,CAAC,aAAa;CAItB;AAID,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -236,7 +236,7 @@ export class ModelHealthService {
236
236
  * Creates a session.
237
237
  *
238
238
  * A session is the parent container for a movement capture workflow. It links
239
- * related entities such as activities and subjects, and provides the context
239
+ * related entities such as activities and subjects and provides the context
240
240
  * used by subsequent operations.
241
241
  *
242
242
  * @returns A new `Session` with a unique identifier.
@@ -252,6 +252,34 @@ export class ModelHealthService {
252
252
  const result = await this.wasmClient.createSession();
253
253
  return this.parseResponse(result);
254
254
  }
255
+ /**
256
+ * Applies settings to an existing session.
257
+ *
258
+ * Call this after `createSession` and before calibration to override any
259
+ * default settings. If not called, the session retains the defaults applied
260
+ * during creation.
261
+ *
262
+ * All fields in `config` are optional — omit any field to keep its default.
263
+ *
264
+ * @param session The session to configure.
265
+ * @param config The settings to apply. Pass `{}` to keep all defaults.
266
+ * @throws On network failure or authentication error.
267
+ *
268
+ * @example
269
+ * ```typescript
270
+ * const session = await client.createSession();
271
+ *
272
+ * // Override frame rate and data sharing only
273
+ * await client.configureSession(session, {
274
+ * framerate: 60,
275
+ * dataSharing: "Share no data"
276
+ * });
277
+ * ```
278
+ */
279
+ async configureSession(session, config = {}) {
280
+ this.ensureInitialized();
281
+ await this.wasmClient.configureSession(decamelizeKeys(session), decamelizeKeys(config));
282
+ }
255
283
  /**
256
284
  * Calibrates cameras using a checkerboard pattern.
257
285
  *
@@ -323,7 +351,7 @@ export class ModelHealthService {
323
351
  * Retrieves all subjects associated with the API key.
324
352
  *
325
353
  * Subjects represent individuals being monitored or assessed. Each subject may
326
- * contain demographic information, physical measurements, and categorization tags.
354
+ * contain demographic information, physical measurements and categorization tags.
327
355
  *
328
356
  * @returns An array of `Subject` objects, or an empty array if none exist.
329
357
  * @throws If the request fails due to network or authentication issues.
@@ -391,7 +419,7 @@ export class ModelHealthService {
391
419
  * ```typescript
392
420
  * // First page
393
421
  * const page1 = await client.activitiesForSubject(
394
- * "subject-123",
422
+ * subject.id,
395
423
  * 0,
396
424
  * 20,
397
425
  * "updated_at"
@@ -399,7 +427,7 @@ export class ModelHealthService {
399
427
  *
400
428
  * // Next page
401
429
  * const page2 = await client.activitiesForSubject(
402
- * "subject-123",
430
+ * subject.id,
403
431
  * 20,
404
432
  * 20,
405
433
  * "updated_at"
@@ -459,7 +487,7 @@ export class ModelHealthService {
459
487
  /**
460
488
  * Deletes an activity.
461
489
  *
462
- * Permanently removes the activity and all associated videos, results, and metadata.
490
+ * Permanently removes the activity and all associated videos, results and metadata.
463
491
  *
464
492
  * @param activity The activity to delete.
465
493
  * @throws If the deletion fails or the request fails.
@@ -470,7 +498,7 @@ export class ModelHealthService {
470
498
  * await client.deleteActivity(activity);
471
499
  * ```
472
500
  *
473
- * @warning This operation is irreversible.
501
+ * **Warning:** This operation is irreversible.
474
502
  */
475
503
  async deleteActivity(activity) {
476
504
  this.ensureInitialized();
@@ -548,7 +576,7 @@ export class ModelHealthService {
548
576
  * }
549
577
  * ```
550
578
  *
551
- * @note Downloads run concurrently. Individual download failures do not affect other requests.
579
+ * Downloads run concurrently. Individual download failures do not affect other requests.
552
580
  */
553
581
  async videosForActivity(activity, version = "synced") {
554
582
  this.ensureInitialized();
@@ -566,8 +594,8 @@ export class ModelHealthService {
566
594
  * such as kinematics, marker data, or an OpenSim model. Downloads run concurrently and
567
595
  * failed downloads are silently excluded from results.
568
596
  *
569
- * @param dataTypes The motion data types to download (for example, `"kinematics_mot"`, `"markers"`, `"animation"`).
570
597
  * @param activity The activity to download data from. Must have completed processing.
598
+ * @param dataTypes The motion data types to download (for example, `"kinematics_mot"`, `"markers"`, `"animation"`).
571
599
  * @returns An array of `MotionData`, one entry per successfully downloaded type. May be empty
572
600
  * if no results are available or all downloads fail.
573
601
  *
@@ -577,7 +605,7 @@ export class ModelHealthService {
577
605
  * const results = await client.motionDataForActivity(activity, ["kinematics_mot"]);
578
606
  *
579
607
  * for (const result of results) {
580
- * switch (result.resultDataType) {
608
+ * switch (result.type) {
581
609
  * case "kinematics_mot":
582
610
  * // Use result.data directly as a .mot file
583
611
  * break;
@@ -598,8 +626,8 @@ export class ModelHealthService {
598
626
  * a report, or raw data. Downloads run concurrently and failed downloads are silently
599
627
  * excluded from results.
600
628
  *
601
- * @param dataTypes The analysis result data types to download (for example, `"metrics"`, `"report"`, `"data"`).
602
629
  * @param activity The activity to download analysis results from. Must have a completed analysis.
630
+ * @param dataTypes The analysis result data types to download (for example, `"metrics"`, `"report"`, `"data"`).
603
631
  * @returns An array of `AnalysisData`, one entry per successfully downloaded type.
604
632
  * May be empty if no results are available or all downloads fail.
605
633
  *
@@ -611,7 +639,7 @@ export class ModelHealthService {
611
639
  * );
612
640
  *
613
641
  * for (const result of results) {
614
- * switch (result.resultDataType) {
642
+ * switch (result.type) {
615
643
  * case "metrics":
616
644
  * const json = JSON.parse(new TextDecoder().decode(result.data));
617
645
  * break;
@@ -640,19 +668,20 @@ export class ModelHealthService {
640
668
  *
641
669
  * @param activityName A descriptive name for this activity (e.g., `"cmj"`, `"squat"`).
642
670
  * @param session The session this activity is associated with.
671
+ * @param config Optional recording configuration.
643
672
  * @returns The newly created `Activity`.
644
673
  * @throws If recording cannot start (e.g., missing calibration).
645
674
  *
646
675
  * @example
647
676
  * ```typescript
648
- * const activity = await client.startRecording("cmj", session);
677
+ * const activity = await client.startRecording("cmj", session, { activityType: ActivityType.CounterMovementJump });
649
678
  * // Subject performs movement...
650
679
  * await client.stopRecording(session);
651
680
  * ```
652
681
  */
653
- async startRecording(activityName, session) {
682
+ async startRecording(activityName, session, config) {
654
683
  this.ensureInitialized();
655
- const result = await this.wasmClient.startRecording(activityName, decamelizeKeys(session));
684
+ const result = await this.wasmClient.startRecording(activityName, decamelizeKeys(session), config?.activityType ?? null);
656
685
  return this.parseResponse(result);
657
686
  }
658
687
  /**
@@ -714,7 +743,7 @@ export class ModelHealthService {
714
743
  * Call this after `activityStatus` returns `ready`. Use the
715
744
  * returned `Analysis` with `analysisStatus` to poll progress.
716
745
  *
717
- * @param analysisType The type of analysis to run (for example, `"gait"`, `"counter_movement_jump"`).
746
+ * @param activityType The type of analysis to run (for example, `"gait"`, `"counter_movement_jump"`).
718
747
  * @param activity The activity to analyze.
719
748
  * @param session The session context containing the activity.
720
749
  * @returns An `Analysis` for tracking analysis progress.
@@ -726,9 +755,9 @@ export class ModelHealthService {
726
755
  * const status = await client.analysisStatus(task);
727
756
  * ```
728
757
  */
729
- async startAnalysis(analysisType, activity, session) {
758
+ async startAnalysis(activityType, activity, session) {
730
759
  this.ensureInitialized();
731
- const result = await this.wasmClient.startAnalysis(analysisType, decamelizeKeys(activity), decamelizeKeys(session));
760
+ const result = await this.wasmClient.startAnalysis(activityType, decamelizeKeys(activity), decamelizeKeys(session));
732
761
  return this.parseResponse(result);
733
762
  }
734
763
  /**
@@ -763,6 +792,159 @@ export class ModelHealthService {
763
792
  const result = await this.wasmClient.analysisStatus(decamelizeKeys(task));
764
793
  return this.parseResponse(result);
765
794
  }
795
+ // MARK: - Import
796
+ /**
797
+ * Imports a set of trials into a new session.
798
+ *
799
+ * Performs the full import workflow: session creation, configuration,
800
+ * subject association, trial creation, video download and upload, processing
801
+ * trigger and polling until complete for each trial.
802
+ *
803
+ * Progress is reported via `statusCallback` with `ImportStatus` values.
804
+ *
805
+ * @param activitiesJson A JSON array of trial objects to import.
806
+ * @param subject The subject to associate with the session.
807
+ * @param config Session configuration. Pass `{}` for defaults.
808
+ * @param statusCallback Callback called with progress updates. Defaults to no-op.
809
+ * @returns The `Session` containing all imported trials.
810
+ * @throws If any step of the import fails.
811
+ *
812
+ * @example
813
+ * ```typescript
814
+ * const session = await client.importSession(
815
+ * activitiesJson,
816
+ * subject,
817
+ * null,
818
+ * { framerate: 60 },
819
+ * (status) => {
820
+ * switch (status.type) {
821
+ * case "creating_session":
822
+ * console.log("Creating session...");
823
+ * break;
824
+ * case "uploading_video":
825
+ * console.log(`[${status.trial}] ${status.uploaded}/${status.total}`);
826
+ * break;
827
+ * case "processing":
828
+ * console.log("Processing...");
829
+ * break;
830
+ * }
831
+ * }
832
+ * );
833
+ * ```
834
+ */
835
+ async importSession(activitiesJson, subject, config = {}, statusCallback = () => { }) {
836
+ this.ensureInitialized();
837
+ const jsCallback = (statusJson) => {
838
+ let status;
839
+ if (typeof statusJson === "string") {
840
+ // Unit variants serialise as plain strings via serde external tagging
841
+ status = { type: statusJson };
842
+ }
843
+ else if (statusJson !== null && typeof statusJson === "object") {
844
+ const obj = statusJson;
845
+ if ("created_session" in obj) {
846
+ const payload = obj["created_session"];
847
+ status = { type: "created_session", session_id: payload.session_id };
848
+ }
849
+ else if ("uploading_video" in obj) {
850
+ const payload = obj["uploading_video"];
851
+ status = { type: "uploading_video", trial: payload.trial, uploaded: payload.uploaded, total: payload.total };
852
+ }
853
+ else {
854
+ return;
855
+ }
856
+ }
857
+ else {
858
+ return;
859
+ }
860
+ statusCallback(status);
861
+ };
862
+ const result = await this.wasmClient.importSession(activitiesJson, decamelizeKeys(subject), decamelizeKeys(config), jsCallback);
863
+ return this.parseResponse(result);
864
+ }
865
+ // MARK: - Archive
866
+ /**
867
+ * Begins preparing a session archive.
868
+ *
869
+ * Kicks off a server-side task that packages the session data into a ZIP file.
870
+ * Poll `archiveStatus` until the status is `ready`, then download the archive
871
+ * with `archiveData`.
872
+ *
873
+ * @param session The session to archive.
874
+ * @param withVideos Whether to include raw videos in the archive. Defaults to `false`.
875
+ * @returns An `Archive` for tracking archive preparation progress.
876
+ * @throws If the request fails.
877
+ *
878
+ * @example
879
+ * ```typescript
880
+ * const archive = await client.prepareArchive(session);
881
+ *
882
+ * let status: ArchiveStatus;
883
+ * do {
884
+ * status = await client.archiveStatus(archive);
885
+ * } while (status.type === "processing");
886
+ *
887
+ * const zipData = await client.archiveData(archive);
888
+ * ```
889
+ */
890
+ async prepareArchive(session, withVideos = false) {
891
+ this.ensureInitialized();
892
+ const result = await this.wasmClient.prepareArchive(decamelizeKeys(session), withVideos);
893
+ return this.parseResponse(result);
894
+ }
895
+ /**
896
+ * Retrieves the current status of an archive preparation task.
897
+ *
898
+ * Poll this method after `prepareArchive` until the status is `ready`,
899
+ * then download the archive with `archiveData`.
900
+ *
901
+ * @param archive The archive returned from `prepareArchive`.
902
+ * @returns The current `ArchiveStatus`.
903
+ * @throws If the request fails.
904
+ *
905
+ * @example
906
+ * ```typescript
907
+ * const status = await client.archiveStatus(archive);
908
+ *
909
+ * switch (status.type) {
910
+ * case "processing":
911
+ * console.log("Archive being prepared...");
912
+ * break;
913
+ * case "ready":
914
+ * console.log("Archive ready to download");
915
+ * break;
916
+ * case "failed":
917
+ * console.log("Archive preparation failed");
918
+ * break;
919
+ * }
920
+ * ```
921
+ */
922
+ async archiveStatus(archive) {
923
+ this.ensureInitialized();
924
+ const result = await this.wasmClient.archiveStatus(decamelizeKeys(archive));
925
+ return this.parseResponse(result);
926
+ }
927
+ /**
928
+ * Downloads the prepared archive as raw ZIP data.
929
+ *
930
+ * Call this after `archiveStatus` returns `ready`. The download URL is
931
+ * managed internally and cached for the lifetime of the WASM instance.
932
+ *
933
+ * @param archive The archive returned from `prepareArchive`.
934
+ * @returns The raw ZIP file bytes as a `Uint8Array`.
935
+ * @throws If the archive is not yet ready or the download fails.
936
+ *
937
+ * @example
938
+ * ```typescript
939
+ * const zipData = await client.archiveData(archive);
940
+ * // Write zipData to a file or process it in memory
941
+ * ```
942
+ */
943
+ async archiveData(archive) {
944
+ this.ensureInitialized();
945
+ const result = await this.wasmClient.archiveData(decamelizeKeys(archive));
946
+ return new Uint8Array(result);
947
+ }
766
948
  // MARK: - Utilities
767
949
  /**
768
950
  * Parse a WASM response and normalise object keys to camelCase.