@nativesquare/soma 0.16.2 → 0.16.4

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.
Files changed (37) hide show
  1. package/dist/client/healthkit.d.ts +5 -85
  2. package/dist/client/healthkit.d.ts.map +1 -1
  3. package/dist/client/healthkit.js +14 -506
  4. package/dist/client/healthkit.js.map +1 -1
  5. package/dist/component/_generated/api.d.ts +4 -0
  6. package/dist/component/_generated/api.d.ts.map +1 -1
  7. package/dist/component/_generated/api.js.map +1 -1
  8. package/dist/component/_generated/component.d.ts +472 -0
  9. package/dist/component/_generated/component.d.ts.map +1 -1
  10. package/dist/component/healthkit/index.d.ts +1 -0
  11. package/dist/component/healthkit/index.d.ts.map +1 -1
  12. package/dist/component/healthkit/index.js +5 -0
  13. package/dist/component/healthkit/index.js.map +1 -1
  14. package/dist/component/healthkit/public.d.ts +451 -0
  15. package/dist/component/healthkit/public.d.ts.map +1 -0
  16. package/dist/component/healthkit/public.js +386 -0
  17. package/dist/component/healthkit/public.js.map +1 -0
  18. package/dist/component/healthkit/types.d.ts +13 -76
  19. package/dist/component/healthkit/types.d.ts.map +1 -1
  20. package/dist/component/healthkit/types.js +9 -6
  21. package/dist/component/healthkit/types.js.map +1 -1
  22. package/dist/component/healthkit/validators.d.ts +1933 -0
  23. package/dist/component/healthkit/validators.d.ts.map +1 -0
  24. package/dist/component/healthkit/validators.js +199 -0
  25. package/dist/component/healthkit/validators.js.map +1 -0
  26. package/dist/component/strava/types/stravaApi/zod.gen.d.ts +3 -3
  27. package/dist/component/validators/connection.js +1 -1
  28. package/dist/component/validators/connection.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/client/healthkit.ts +44 -625
  31. package/src/component/_generated/api.ts +4 -0
  32. package/src/component/_generated/component.ts +412 -0
  33. package/src/component/healthkit/index.ts +74 -46
  34. package/src/component/healthkit/public.ts +597 -0
  35. package/src/component/healthkit/types.ts +45 -114
  36. package/src/component/healthkit/validators.ts +253 -0
  37. package/src/component/validators/connection.ts +1 -1
@@ -56,6 +56,7 @@ import type * as garmin_types_wellnessApi_index from "../garmin/types/wellnessAp
56
56
  import type * as garmin_utils from "../garmin/utils.js";
57
57
  import type * as garmin_webhooks from "../garmin/webhooks.js";
58
58
  import type * as healthkit_index from "../healthkit/index.js";
59
+ import type * as healthkit_public from "../healthkit/public.js";
59
60
  import type * as healthkit_transform_activity from "../healthkit/transform/activity.js";
60
61
  import type * as healthkit_transform_athlete from "../healthkit/transform/athlete.js";
61
62
  import type * as healthkit_transform_body from "../healthkit/transform/body.js";
@@ -68,6 +69,7 @@ import type * as healthkit_transform_nutrition from "../healthkit/transform/nutr
68
69
  import type * as healthkit_transform_sleep from "../healthkit/transform/sleep.js";
69
70
  import type * as healthkit_transform_utils from "../healthkit/transform/utils.js";
70
71
  import type * as healthkit_types from "../healthkit/types.js";
72
+ import type * as healthkit_validators from "../healthkit/validators.js";
71
73
  import type * as private_ from "../private.js";
72
74
  import type * as public_ from "../public.js";
73
75
  import type * as strava_auth from "../strava/auth.js";
@@ -151,6 +153,7 @@ const fullApi: ApiFromModules<{
151
153
  "garmin/utils": typeof garmin_utils;
152
154
  "garmin/webhooks": typeof garmin_webhooks;
153
155
  "healthkit/index": typeof healthkit_index;
156
+ "healthkit/public": typeof healthkit_public;
154
157
  "healthkit/transform/activity": typeof healthkit_transform_activity;
155
158
  "healthkit/transform/athlete": typeof healthkit_transform_athlete;
156
159
  "healthkit/transform/body": typeof healthkit_transform_body;
@@ -163,6 +166,7 @@ const fullApi: ApiFromModules<{
163
166
  "healthkit/transform/sleep": typeof healthkit_transform_sleep;
164
167
  "healthkit/transform/utils": typeof healthkit_transform_utils;
165
168
  "healthkit/types": typeof healthkit_types;
169
+ "healthkit/validators": typeof healthkit_validators;
166
170
  private: typeof private_;
167
171
  public: typeof public_;
168
172
  "strava/auth": typeof strava_auth;
@@ -407,6 +407,418 @@ export type ComponentApi<Name extends string | undefined = string | undefined> =
407
407
  >;
408
408
  };
409
409
  };
410
+ healthkit: {
411
+ public: {
412
+ connect: FunctionReference<
413
+ "mutation",
414
+ "internal",
415
+ { userId: string },
416
+ string,
417
+ Name
418
+ >;
419
+ disconnect: FunctionReference<
420
+ "mutation",
421
+ "internal",
422
+ { userId: string },
423
+ null,
424
+ Name
425
+ >;
426
+ syncActivities: FunctionReference<
427
+ "mutation",
428
+ "internal",
429
+ {
430
+ userId: string;
431
+ workouts: Array<{
432
+ device?: {
433
+ hardwareVersion?: string;
434
+ manufacturer?: string;
435
+ model?: string;
436
+ name?: string;
437
+ softwareVersion?: string;
438
+ };
439
+ duration: number;
440
+ endDate: string;
441
+ heartRateSamples?: Array<{
442
+ device?: {
443
+ hardwareVersion?: string;
444
+ manufacturer?: string;
445
+ model?: string;
446
+ name?: string;
447
+ softwareVersion?: string;
448
+ };
449
+ endDate: string;
450
+ sampleType: string;
451
+ source?: { bundleIdentifier: string; name: string };
452
+ startDate: string;
453
+ unit: string;
454
+ uuid: string;
455
+ value: number;
456
+ }>;
457
+ routeData?: Array<{
458
+ locations: Array<{
459
+ altitude?: number;
460
+ latitude: number;
461
+ longitude: number;
462
+ timestamp: string;
463
+ }>;
464
+ }>;
465
+ source?: { bundleIdentifier: string; name: string };
466
+ startDate: string;
467
+ totalDistance?: number;
468
+ totalEnergyBurned?: number;
469
+ totalFlightsClimbed?: number;
470
+ totalSwimmingStrokeCount?: number;
471
+ uuid: string;
472
+ workoutActivityType: number;
473
+ }>;
474
+ },
475
+ {
476
+ data: { activities: number };
477
+ errors: Array<{ id: string; message: string; type: string }>;
478
+ },
479
+ Name
480
+ >;
481
+ syncAll: FunctionReference<
482
+ "mutation",
483
+ "internal",
484
+ {
485
+ bodySamples?: Array<{
486
+ device?: {
487
+ hardwareVersion?: string;
488
+ manufacturer?: string;
489
+ model?: string;
490
+ name?: string;
491
+ softwareVersion?: string;
492
+ };
493
+ endDate: string;
494
+ sampleType: string;
495
+ source?: { bundleIdentifier: string; name: string };
496
+ startDate: string;
497
+ unit: string;
498
+ uuid: string;
499
+ value: number;
500
+ }>;
501
+ bodyTimeRange?: { end_time: string; start_time: string };
502
+ characteristics?: {
503
+ biologicalSex?: "female" | "male" | "other" | "notSet";
504
+ bloodType?: string;
505
+ dateOfBirth?: string;
506
+ fitzpatrickSkinType?: number;
507
+ wheelchairUse?: boolean;
508
+ };
509
+ dailySamples?: Array<{
510
+ device?: {
511
+ hardwareVersion?: string;
512
+ manufacturer?: string;
513
+ model?: string;
514
+ name?: string;
515
+ softwareVersion?: string;
516
+ };
517
+ endDate: string;
518
+ sampleType: string;
519
+ source?: { bundleIdentifier: string; name: string };
520
+ startDate: string;
521
+ unit: string;
522
+ uuid: string;
523
+ value: number;
524
+ }>;
525
+ dailySummaries?: Array<{
526
+ activeEnergyBurned: number;
527
+ activeEnergyBurnedGoal: number;
528
+ appleExerciseTime: number;
529
+ appleExerciseTimeGoal: number;
530
+ appleStandHours: number;
531
+ appleStandHoursGoal: number;
532
+ dateComponents: { day: number; month: number; year: number };
533
+ }>;
534
+ dailyTimeRange?: { end_time: string; start_time: string };
535
+ menstruationSamples?: Array<{
536
+ device?: {
537
+ hardwareVersion?: string;
538
+ manufacturer?: string;
539
+ model?: string;
540
+ name?: string;
541
+ softwareVersion?: string;
542
+ };
543
+ endDate: string;
544
+ sampleType: string;
545
+ source?: { bundleIdentifier: string; name: string };
546
+ startDate: string;
547
+ uuid: string;
548
+ value: number;
549
+ }>;
550
+ menstruationTimeRange?: { end_time: string; start_time: string };
551
+ nutritionSamples?: Array<{
552
+ device?: {
553
+ hardwareVersion?: string;
554
+ manufacturer?: string;
555
+ model?: string;
556
+ name?: string;
557
+ softwareVersion?: string;
558
+ };
559
+ endDate: string;
560
+ sampleType: string;
561
+ source?: { bundleIdentifier: string; name: string };
562
+ startDate: string;
563
+ unit: string;
564
+ uuid: string;
565
+ value: number;
566
+ }>;
567
+ nutritionTimeRange?: { end_time: string; start_time: string };
568
+ sleepSessions?: Array<
569
+ Array<{
570
+ device?: {
571
+ hardwareVersion?: string;
572
+ manufacturer?: string;
573
+ model?: string;
574
+ name?: string;
575
+ softwareVersion?: string;
576
+ };
577
+ endDate: string;
578
+ sampleType: string;
579
+ source?: { bundleIdentifier: string; name: string };
580
+ startDate: string;
581
+ uuid: string;
582
+ value: number;
583
+ }>
584
+ >;
585
+ userId: string;
586
+ workouts?: Array<{
587
+ device?: {
588
+ hardwareVersion?: string;
589
+ manufacturer?: string;
590
+ model?: string;
591
+ name?: string;
592
+ softwareVersion?: string;
593
+ };
594
+ duration: number;
595
+ endDate: string;
596
+ heartRateSamples?: Array<{
597
+ device?: {
598
+ hardwareVersion?: string;
599
+ manufacturer?: string;
600
+ model?: string;
601
+ name?: string;
602
+ softwareVersion?: string;
603
+ };
604
+ endDate: string;
605
+ sampleType: string;
606
+ source?: { bundleIdentifier: string; name: string };
607
+ startDate: string;
608
+ unit: string;
609
+ uuid: string;
610
+ value: number;
611
+ }>;
612
+ routeData?: Array<{
613
+ locations: Array<{
614
+ altitude?: number;
615
+ latitude: number;
616
+ longitude: number;
617
+ timestamp: string;
618
+ }>;
619
+ }>;
620
+ source?: { bundleIdentifier: string; name: string };
621
+ startDate: string;
622
+ totalDistance?: number;
623
+ totalEnergyBurned?: number;
624
+ totalFlightsClimbed?: number;
625
+ totalSwimmingStrokeCount?: number;
626
+ uuid: string;
627
+ workoutActivityType: number;
628
+ }>;
629
+ },
630
+ {
631
+ data: Record<string, number>;
632
+ errors: Array<{ id: string; message: string; type: string }>;
633
+ },
634
+ Name
635
+ >;
636
+ syncAthlete: FunctionReference<
637
+ "mutation",
638
+ "internal",
639
+ {
640
+ characteristics: {
641
+ biologicalSex?: "female" | "male" | "other" | "notSet";
642
+ bloodType?: string;
643
+ dateOfBirth?: string;
644
+ fitzpatrickSkinType?: number;
645
+ wheelchairUse?: boolean;
646
+ };
647
+ userId: string;
648
+ },
649
+ {
650
+ data: { athletes: number };
651
+ errors: Array<{ id: string; message: string; type: string }>;
652
+ },
653
+ Name
654
+ >;
655
+ syncBody: FunctionReference<
656
+ "mutation",
657
+ "internal",
658
+ {
659
+ samples: Array<{
660
+ device?: {
661
+ hardwareVersion?: string;
662
+ manufacturer?: string;
663
+ model?: string;
664
+ name?: string;
665
+ softwareVersion?: string;
666
+ };
667
+ endDate: string;
668
+ sampleType: string;
669
+ source?: { bundleIdentifier: string; name: string };
670
+ startDate: string;
671
+ unit: string;
672
+ uuid: string;
673
+ value: number;
674
+ }>;
675
+ timeRange?: { end_time: string; start_time: string };
676
+ userId: string;
677
+ },
678
+ {
679
+ data: { body: number };
680
+ errors: Array<{ id: string; message: string; type: string }>;
681
+ },
682
+ Name
683
+ >;
684
+ syncDaily: FunctionReference<
685
+ "mutation",
686
+ "internal",
687
+ {
688
+ samples: Array<{
689
+ device?: {
690
+ hardwareVersion?: string;
691
+ manufacturer?: string;
692
+ model?: string;
693
+ name?: string;
694
+ softwareVersion?: string;
695
+ };
696
+ endDate: string;
697
+ sampleType: string;
698
+ source?: { bundleIdentifier: string; name: string };
699
+ startDate: string;
700
+ unit: string;
701
+ uuid: string;
702
+ value: number;
703
+ }>;
704
+ timeRange?: { end_time: string; start_time: string };
705
+ userId: string;
706
+ },
707
+ {
708
+ data: { daily: number };
709
+ errors: Array<{ id: string; message: string; type: string }>;
710
+ },
711
+ Name
712
+ >;
713
+ syncDailyFromSummary: FunctionReference<
714
+ "mutation",
715
+ "internal",
716
+ {
717
+ summaries: Array<{
718
+ activeEnergyBurned: number;
719
+ activeEnergyBurnedGoal: number;
720
+ appleExerciseTime: number;
721
+ appleExerciseTimeGoal: number;
722
+ appleStandHours: number;
723
+ appleStandHoursGoal: number;
724
+ dateComponents: { day: number; month: number; year: number };
725
+ }>;
726
+ userId: string;
727
+ },
728
+ {
729
+ data: { daily: number };
730
+ errors: Array<{ id: string; message: string; type: string }>;
731
+ },
732
+ Name
733
+ >;
734
+ syncMenstruation: FunctionReference<
735
+ "mutation",
736
+ "internal",
737
+ {
738
+ samples: Array<{
739
+ device?: {
740
+ hardwareVersion?: string;
741
+ manufacturer?: string;
742
+ model?: string;
743
+ name?: string;
744
+ softwareVersion?: string;
745
+ };
746
+ endDate: string;
747
+ sampleType: string;
748
+ source?: { bundleIdentifier: string; name: string };
749
+ startDate: string;
750
+ uuid: string;
751
+ value: number;
752
+ }>;
753
+ timeRange?: { end_time: string; start_time: string };
754
+ userId: string;
755
+ },
756
+ {
757
+ data: { menstruation: number };
758
+ errors: Array<{ id: string; message: string; type: string }>;
759
+ },
760
+ Name
761
+ >;
762
+ syncNutrition: FunctionReference<
763
+ "mutation",
764
+ "internal",
765
+ {
766
+ samples: Array<{
767
+ device?: {
768
+ hardwareVersion?: string;
769
+ manufacturer?: string;
770
+ model?: string;
771
+ name?: string;
772
+ softwareVersion?: string;
773
+ };
774
+ endDate: string;
775
+ sampleType: string;
776
+ source?: { bundleIdentifier: string; name: string };
777
+ startDate: string;
778
+ unit: string;
779
+ uuid: string;
780
+ value: number;
781
+ }>;
782
+ timeRange?: { end_time: string; start_time: string };
783
+ userId: string;
784
+ },
785
+ {
786
+ data: { nutrition: number };
787
+ errors: Array<{ id: string; message: string; type: string }>;
788
+ },
789
+ Name
790
+ >;
791
+ syncSleep: FunctionReference<
792
+ "mutation",
793
+ "internal",
794
+ {
795
+ sessions: Array<
796
+ Array<{
797
+ device?: {
798
+ hardwareVersion?: string;
799
+ manufacturer?: string;
800
+ model?: string;
801
+ name?: string;
802
+ softwareVersion?: string;
803
+ };
804
+ endDate: string;
805
+ sampleType: string;
806
+ source?: { bundleIdentifier: string; name: string };
807
+ startDate: string;
808
+ uuid: string;
809
+ value: number;
810
+ }>
811
+ >;
812
+ userId: string;
813
+ },
814
+ {
815
+ data: { sleep: number };
816
+ errors: Array<{ id: string; message: string; type: string }>;
817
+ },
818
+ Name
819
+ >;
820
+ };
821
+ };
410
822
  public: {
411
823
  connect: FunctionReference<
412
824
  "mutation",
@@ -1,46 +1,74 @@
1
- // ─── @nativesquare/soma/healthkit ─────────────────────────────────────────────
2
- // Apple HealthKit → Soma schema transformers.
3
- //
4
- // Pure TypeScript functions with zero runtime dependencies.
5
- // Compatible with any HealthKit library (react-native-health, expo-health, etc.)
6
-
7
- // ── Transformers ─────────────────────────────────────────────────────────────
8
- export { transformWorkout } from "./transform/activity.js";
9
- export { transformSleep } from "./transform/sleep.js";
10
- export { transformBody } from "./transform/body.js";
11
- export { transformDaily, transformDailyFromSummary } from "./transform/daily.js";
12
- export { transformNutrition } from "./transform/nutrition.js";
13
- export { transformMenstruation } from "./transform/menstruation.js";
14
- export { transformAthlete } from "./transform/athlete.js";
15
-
16
- // ── Enum Maps ────────────────────────────────────────────────────────────────
17
- export { mapActivityType } from "./transform/maps/activityType.js";
18
- export { mapSleepLevel, isAsleepCategory } from "./transform/maps/sleepLevel.js";
19
- export { mapMenstruationFlow } from "./transform/maps/menstruationFlow.js";
20
-
21
- // ── Types ────────────────────────────────────────────────────────────────────
22
- export type {
23
- HKQuantitySample,
24
- HKCategorySample,
25
- HKWorkout,
26
- HKWorkoutRoute,
27
- HKActivitySummary,
28
- HKDevice,
29
- HKSource,
30
- HKCharacteristics,
31
- HKBiologicalSex,
32
- HKQuantityTypeIdentifier,
33
- HKCategoryTypeIdentifier,
34
- HKSleepCategoryValue,
35
- HKMenstrualFlowCategoryValue,
36
- } from "./types.js";
37
-
38
- export { HKSleepCategory, HKMenstrualFlowCategory } from "./types.js";
39
-
40
- // ── Utilities ────────────────────────────────────────────────────────────────
41
- export {
42
- diffSeconds,
43
- dayRange,
44
- sampleTimeRange,
45
- buildDeviceData,
46
- } from "./transform/utils.js";
1
+ // ─── @nativesquare/soma/healthkit ─────────────────────────────────────────────
2
+ // Apple HealthKit → Soma schema transformers.
3
+ //
4
+ // Pure TypeScript functions with zero runtime dependencies.
5
+ // Compatible with any HealthKit library (react-native-health, expo-health, etc.)
6
+
7
+ // ── Transformers ─────────────────────────────────────────────────────────────
8
+ export { transformWorkout } from "./transform/activity.js";
9
+ export { transformSleep } from "./transform/sleep.js";
10
+ export { transformBody } from "./transform/body.js";
11
+ export { transformDaily, transformDailyFromSummary } from "./transform/daily.js";
12
+ export { transformNutrition } from "./transform/nutrition.js";
13
+ export { transformMenstruation } from "./transform/menstruation.js";
14
+ export { transformAthlete } from "./transform/athlete.js";
15
+
16
+ // ── Enum Maps ────────────────────────────────────────────────────────────────
17
+ export { mapActivityType } from "./transform/maps/activityType.js";
18
+ export { mapSleepLevel, isAsleepCategory } from "./transform/maps/sleepLevel.js";
19
+ export { mapMenstruationFlow } from "./transform/maps/menstruationFlow.js";
20
+
21
+ // ── Types ────────────────────────────────────────────────────────────────────
22
+ export type {
23
+ HKQuantitySample,
24
+ HKCategorySample,
25
+ HKWorkout,
26
+ HKWorkoutRoute,
27
+ HKActivitySummary,
28
+ HKDevice,
29
+ HKSource,
30
+ HKCharacteristics,
31
+ HKBiologicalSex,
32
+ HKQuantityTypeIdentifier,
33
+ HKCategoryTypeIdentifier,
34
+ HKSleepCategoryValue,
35
+ HKMenstrualFlowCategoryValue,
36
+ } from "./types.js";
37
+
38
+ export { HKSleepCategory, HKMenstrualFlowCategory } from "./types.js";
39
+
40
+ // ── Utilities ────────────────────────────────────────────────────────────────
41
+ export {
42
+ diffSeconds,
43
+ dayRange,
44
+ sampleTimeRange,
45
+ buildDeviceData,
46
+ } from "./transform/utils.js";
47
+
48
+ // ── Validators ───────────────────────────────────────────────────────────────
49
+ // Convex validators for HealthKit input shapes. Use as `args:` on your own
50
+ // public mutations to get type-safe validation of HK data flowing from the
51
+ // React Native client into Soma.
52
+ export {
53
+ hkDeviceValidator,
54
+ hkSourceValidator,
55
+ hkQuantitySampleValidator,
56
+ hkCategorySampleValidator,
57
+ hkWorkoutRouteValidator,
58
+ hkWorkoutValidator,
59
+ hkActivitySummaryValidator,
60
+ hkCharacteristicsValidator,
61
+ hkBiologicalSexValidator,
62
+ hkSleepCategoryValueValidator,
63
+ hkMenstrualFlowCategoryValueValidator,
64
+ timeRangeValidator,
65
+ syncActivitiesArgs,
66
+ syncSleepArgs,
67
+ syncBodyArgs,
68
+ syncDailyArgs,
69
+ syncDailyFromSummaryArgs,
70
+ syncNutritionArgs,
71
+ syncMenstruationArgs,
72
+ syncAthleteArgs,
73
+ syncAllHealthKitArgs,
74
+ } from "./validators.js";