@kingstinct/react-native-healthkit 5.1.2 → 5.2.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.
Files changed (65) hide show
  1. package/README.md +28 -23
  2. package/android/.project +18 -1
  3. package/android/.settings/org.eclipse.buildship.core.prefs +4 -4
  4. package/ios/ReactNativeHealthkit.m +9 -0
  5. package/ios/ReactNativeHealthkit.swift +23 -7
  6. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
  7. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +57 -0
  8. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +1 -0
  9. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +12 -19
  10. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +1 -1
  11. package/lib/commonjs/index.ios.js +1 -0
  12. package/lib/commonjs/index.ios.js.map +1 -1
  13. package/lib/commonjs/index.js +3 -1
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/jest.setup.js +29 -2
  16. package/lib/commonjs/jest.setup.js.map +1 -1
  17. package/lib/commonjs/native-types.js +27 -27
  18. package/lib/commonjs/native-types.js.map +1 -1
  19. package/lib/commonjs/test-utils.js +21 -0
  20. package/lib/commonjs/test-utils.js.map +1 -0
  21. package/lib/commonjs/utils/getPreferredUnit.js.map +1 -1
  22. package/lib/commonjs/utils/subscribeToChanges.js +4 -4
  23. package/lib/commonjs/utils/subscribeToChanges.js.map +1 -1
  24. package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
  25. package/lib/module/hooks/useHealthkitAuthorization.test.js +45 -0
  26. package/lib/module/hooks/useHealthkitAuthorization.test.js.map +1 -0
  27. package/lib/module/hooks/useIsHealthDataAvailable.test.js +8 -16
  28. package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +1 -1
  29. package/lib/module/index.ios.js +1 -0
  30. package/lib/module/index.ios.js.map +1 -1
  31. package/lib/module/index.js +3 -1
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/jest.setup.js +29 -2
  34. package/lib/module/jest.setup.js.map +1 -1
  35. package/lib/module/native-types.js +27 -27
  36. package/lib/module/native-types.js.map +1 -1
  37. package/lib/module/test-utils.js +13 -0
  38. package/lib/module/test-utils.js.map +1 -0
  39. package/lib/module/utils/getPreferredUnit.js.map +1 -1
  40. package/lib/module/utils/subscribeToChanges.js +1 -2
  41. package/lib/module/utils/subscribeToChanges.js.map +1 -1
  42. package/lib/{src/types.js → typescript/src/hooks/useHealthkitAuthorization.test.d.ts} +0 -0
  43. package/lib/typescript/src/index.ios.d.ts +1 -0
  44. package/lib/typescript/src/native-types.d.ts +48 -46
  45. package/lib/typescript/src/test-utils.d.ts +2 -0
  46. package/lib/typescript/src/utils/getPreferredUnit.d.ts +1 -1
  47. package/package.json +8 -4
  48. package/src/hooks/useHealthkitAuthorization.test.ts +54 -0
  49. package/src/hooks/useHealthkitAuthorization.ts +1 -0
  50. package/src/hooks/useIsHealthDataAvailable.test.ts +9 -14
  51. package/src/index.ios.tsx +3 -1
  52. package/src/index.tsx +2 -0
  53. package/src/jest.setup.ts +32 -2
  54. package/src/native-types.ts +349 -159
  55. package/src/test-utils.ts +10 -0
  56. package/src/utils/getPreferredUnit.ts +2 -2
  57. package/src/utils/subscribeToChanges.ts +1 -2
  58. package/lib/example/App.js +0 -197
  59. package/lib/index.ios.js +0 -310
  60. package/lib/index.js +0 -44
  61. package/lib/native-types.js +0 -447
  62. package/lib/src/index.ios.js +0 -314
  63. package/lib/src/index.js +0 -45
  64. package/lib/src/native-types.js +0 -453
  65. package/lib/types.js +0 -1
@@ -1,9 +1,6 @@
1
- import {
2
- NativeEventEmitter,
3
- NativeModules,
4
- } from 'react-native'
1
+ import { NativeEventEmitter, NativeModules } from 'react-native'
5
2
 
6
- import type { EmitterSubscription } from 'react-native'
3
+ import type { EmitterSubscription, NativeModule } from 'react-native'
7
4
 
8
5
  export const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier' as const
9
6
  export const HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier' as const
@@ -124,8 +121,8 @@ export enum HKQuantityTypeIdentifier {
124
121
  numberOfAlcoholicBeverages = 'HKQuantityTypeIdentifierNumberOfAlcoholicBeverages', // Scalar(Count), Cumulative
125
122
  }
126
123
 
127
- export type TypeToUnitMapping = { readonly
128
- [key in HKQuantityTypeIdentifier]: HKUnit;
124
+ export type TypeToUnitMapping = {
125
+ readonly [key in HKQuantityTypeIdentifier]: HKUnit;
129
126
  };
130
127
 
131
128
  export enum HKCategoryValueLowCardioFitnessEvent {
@@ -208,23 +205,26 @@ export enum HKCategoryTypeIdentifier {
208
205
  vaginalDryness = 'HKCategoryTypeIdentifierVaginalDryness', // HKCategoryValueSeverity
209
206
  vomiting = 'HKCategoryTypeIdentifierVomiting', // HKCategoryValueSeverity
210
207
  wheezing = 'HKCategoryTypeIdentifierWheezing', // HKCategoryValueSeverity
211
-
212
208
  }
213
209
 
214
210
  export type HKSampleTypeIdentifier =
215
- HKCategoryTypeIdentifier
216
- | HKCorrelationTypeIdentifier
217
- | HKQuantityTypeIdentifier
218
- | typeof HKAudiogramTypeIdentifier
219
- | typeof HKDataTypeIdentifierHeartbeatSeries
220
- | typeof HKWorkoutRouteTypeIdentifier
221
- | typeof HKWorkoutTypeIdentifier
222
- | `${HKCategoryTypeIdentifier}`
223
- | `${HKCorrelationTypeIdentifier}`
224
- | `${HKQuantityTypeIdentifier}`
225
-
226
- export type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`
227
- export type HealthkitWriteAuthorization = HKSampleTypeIdentifier
211
+ | HKCategoryTypeIdentifier
212
+ | HKCorrelationTypeIdentifier
213
+ | HKQuantityTypeIdentifier
214
+ | typeof HKAudiogramTypeIdentifier
215
+ | typeof HKDataTypeIdentifierHeartbeatSeries
216
+ | typeof HKWorkoutRouteTypeIdentifier
217
+ | typeof HKWorkoutTypeIdentifier
218
+ | `${HKCategoryTypeIdentifier}`
219
+ | `${HKCorrelationTypeIdentifier}`
220
+ | `${HKQuantityTypeIdentifier}`;
221
+
222
+ export type HealthkitReadAuthorization =
223
+ | HKCharacteristicTypeIdentifier
224
+ | HKSampleTypeIdentifier
225
+ | `${HKCharacteristicTypeIdentifier}`
226
+ | `${HKSampleTypeIdentifier}`;
227
+ export type HealthkitWriteAuthorization = HKSampleTypeIdentifier;
228
228
 
229
229
  export enum HKCategoryValueAppleStandHour {
230
230
  stood = 0,
@@ -369,11 +369,17 @@ enum HKIndoorWorkout {
369
369
  export interface HKWorkoutMetadata
370
370
  extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
371
371
  readonly HKWeatherCondition?: HKWeatherCondition;
372
- readonly HKWeatherHumidity?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Percent>;
372
+ readonly HKWeatherHumidity?: HKQuantity<
373
+ HKQuantityTypeIdentifier,
374
+ HKUnits.Percent
375
+ >;
373
376
  // HKWeatherTemperature: HKQuantity<TTemperatureUnit>
374
- readonly HKAverageMETs?: HKQuantity<HKQuantityTypeIdentifier, HKUnit>,
375
- readonly HKElevationAscended?: HKQuantity<HKQuantityTypeIdentifier, LengthUnit>,
376
- readonly HKIndoorWorkout?: HKIndoorWorkout,
377
+ readonly HKAverageMETs?: HKQuantity<HKQuantityTypeIdentifier, HKUnit>;
378
+ readonly HKElevationAscended?: HKQuantity<
379
+ HKQuantityTypeIdentifier,
380
+ LengthUnit
381
+ >;
382
+ readonly HKIndoorWorkout?: HKIndoorWorkout;
377
383
  }
378
384
 
379
385
  export enum HKAuthorizationRequestStatus {
@@ -388,7 +394,10 @@ export enum HKAuthorizationStatus {
388
394
  sharingAuthorized = 2,
389
395
  }
390
396
 
391
- export type HKQuantity<TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>> = {
397
+ export type HKQuantity<
398
+ TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
399
+ TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>
400
+ > = {
392
401
  readonly unit: TUnit;
393
402
  readonly quantity: number;
394
403
  };
@@ -433,13 +442,19 @@ export enum HKStatisticsOptions {
433
442
  separateBySource = 'separateBySource',
434
443
  }
435
444
 
436
- export type QueryStatisticsResponseRaw<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>> = {
445
+ export type QueryStatisticsResponseRaw<
446
+ TIdentifier extends HKQuantityTypeIdentifier,
447
+ TUnit extends UnitForIdentifier<TIdentifier>
448
+ > = {
437
449
  readonly averageQuantity?: HKQuantity<TIdentifier, TUnit>;
438
450
  readonly maximumQuantity?: HKQuantity<TIdentifier, TUnit>;
439
451
  readonly minimumQuantity?: HKQuantity<TIdentifier, TUnit>;
440
452
  readonly sumQuantity?: HKQuantity<TIdentifier, TUnit>;
441
453
  readonly mostRecentQuantity?: HKQuantity<TIdentifier, TUnit>;
442
- readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
454
+ readonly mostRecentQuantityDateInterval?: {
455
+ readonly from: string;
456
+ readonly to: string;
457
+ };
443
458
  readonly duration?: HKQuantity<HKQuantityTypeIdentifier, TimeUnit>;
444
459
  };
445
460
 
@@ -497,10 +512,15 @@ export enum HKCategoryValueNotApplicable {
497
512
  }
498
513
 
499
514
  export type HKCategoryValue =
500
- HKCategoryValueAppetiteChanges | HKCategoryValueCervicalMucusQuality |
501
- HKCategoryValueLowCardioFitnessEvent | HKCategoryValueMenstrualFlow |
502
- HKCategoryValueOvulationTestResult | HKCategoryValuePresence |
503
- HKCategoryValueSeverity | HKCategoryValueSleepAnalysis | number;
515
+ | HKCategoryValueAppetiteChanges
516
+ | HKCategoryValueCervicalMucusQuality
517
+ | HKCategoryValueLowCardioFitnessEvent
518
+ | HKCategoryValueMenstrualFlow
519
+ | HKCategoryValueOvulationTestResult
520
+ | HKCategoryValuePresence
521
+ | HKCategoryValueSeverity
522
+ | HKCategoryValueSleepAnalysis
523
+ | number;
504
524
 
505
525
  export enum HKInsulinDeliveryReason {
506
526
  basal = 1,
@@ -531,19 +551,102 @@ export type MetadataMapperForCorrelationIdentifier<
531
551
  }
532
552
  : HKGenericMetadata;
533
553
 
534
- export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> = T extends HKQuantityTypeIdentifier.bloodGlucose ? BloodGlucoseUnit
535
- : T extends HKQuantityTypeIdentifier.appleExerciseTime | HKQuantityTypeIdentifier.appleMoveTime | HKQuantityTypeIdentifier.appleStandTime ? TimeUnit
536
- : T extends HKQuantityTypeIdentifier.activeEnergyBurned | HKQuantityTypeIdentifier.basalEnergyBurned | HKQuantityTypeIdentifier.dietaryEnergyConsumed ? EnergyUnit
537
- : T extends HKQuantityTypeIdentifier.distanceCycling | HKQuantityTypeIdentifier.distanceDownhillSnowSports | HKQuantityTypeIdentifier.distanceSwimming | HKQuantityTypeIdentifier.distanceWalkingRunning | HKQuantityTypeIdentifier.distanceWheelchair | HKQuantityTypeIdentifier.sixMinuteWalkTestDistance | HKQuantityTypeIdentifier.waistCircumference ? LengthUnit
538
- : T extends HKQuantityTypeIdentifier.bodyFatPercentage | HKQuantityTypeIdentifier.oxygenSaturation | HKQuantityTypeIdentifier.walkingAsymmetryPercentage | HKQuantityTypeIdentifier.walkingDoubleSupportPercentage ? HKUnits.Percent
539
- : T extends HKQuantityTypeIdentifier.basalBodyTemperature | HKQuantityTypeIdentifier.basalBodyTemperature ? TemperatureUnit
540
- : T extends HKQuantityTypeIdentifier.stairAscentSpeed | HKQuantityTypeIdentifier.stairDescentSpeed | HKQuantityTypeIdentifier.walkingSpeed | HKQuantityTypeIdentifier.walkingSpeed ? SpeedUnit<LengthUnit, TimeUnit>
541
- : T extends HKQuantityTypeIdentifier.flightsClimbed | HKQuantityTypeIdentifier.numberOfAlcoholicBeverages | HKQuantityTypeIdentifier.numberOfTimesFallen | HKQuantityTypeIdentifier.pushCount | HKQuantityTypeIdentifier.stepCount | HKQuantityTypeIdentifier.swimmingStrokeCount ? HKUnits.Count
542
- : T extends HKQuantityTypeIdentifier.dietaryBiotin | HKQuantityTypeIdentifier.dietaryCaffeine | HKQuantityTypeIdentifier.dietaryCalcium | HKQuantityTypeIdentifier.dietaryCarbohydrates | HKQuantityTypeIdentifier.dietaryChloride | HKQuantityTypeIdentifier.dietaryCholesterol | HKQuantityTypeIdentifier.dietaryChromium | HKQuantityTypeIdentifier.dietaryCopper | HKQuantityTypeIdentifier.dietaryFatMonounsaturated | HKQuantityTypeIdentifier.dietaryFatPolyunsaturated | HKQuantityTypeIdentifier.dietaryFatSaturated | HKQuantityTypeIdentifier.dietaryFatTotal | HKQuantityTypeIdentifier.dietaryFiber | HKQuantityTypeIdentifier.dietaryFolate | HKQuantityTypeIdentifier.dietaryIodine | HKQuantityTypeIdentifier.dietaryIodine | HKQuantityTypeIdentifier.dietaryIron | HKQuantityTypeIdentifier.dietaryMagnesium | HKQuantityTypeIdentifier.dietaryManganese | HKQuantityTypeIdentifier.dietaryMolybdenum | HKQuantityTypeIdentifier.dietaryNiacin | HKQuantityTypeIdentifier.dietaryPantothenicAcid | HKQuantityTypeIdentifier.dietaryPhosphorus | HKQuantityTypeIdentifier.dietaryPotassium | HKQuantityTypeIdentifier.dietaryProtein | HKQuantityTypeIdentifier.dietaryRiboflavin | HKQuantityTypeIdentifier.dietarySelenium | HKQuantityTypeIdentifier.dietarySodium | HKQuantityTypeIdentifier.dietarySugar | HKQuantityTypeIdentifier.dietaryThiamin | HKQuantityTypeIdentifier.dietaryVitaminA | HKQuantityTypeIdentifier.dietaryVitaminB6 | HKQuantityTypeIdentifier.dietaryVitaminB12 | HKQuantityTypeIdentifier.dietaryVitaminC | HKQuantityTypeIdentifier.dietaryVitaminD | HKQuantityTypeIdentifier.dietaryVitaminE | HKQuantityTypeIdentifier.dietaryVitaminK | HKQuantityTypeIdentifier.dietaryZinc ? MassUnit
543
- : T extends HKQuantityTypeIdentifier.dietaryWater ? VolumeUnit
544
- : T extends HKQuantityTypeIdentifier.insulinDelivery ? HKUnits.InternationalUnit | `${HKUnits.InternationalUnit}`
545
- : T extends HKQuantityTypeIdentifier.heartRate | HKQuantityTypeIdentifier.restingHeartRate | HKQuantityTypeIdentifier.walkingHeartRateAverage ? CountPerTime<TimeUnit>
546
- : HKUnit
554
+ export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> =
555
+ T extends HKQuantityTypeIdentifier.bloodGlucose
556
+ ? BloodGlucoseUnit
557
+ : T extends
558
+ | HKQuantityTypeIdentifier.appleExerciseTime
559
+ | HKQuantityTypeIdentifier.appleMoveTime
560
+ | HKQuantityTypeIdentifier.appleStandTime
561
+ ? TimeUnit
562
+ : T extends
563
+ | HKQuantityTypeIdentifier.activeEnergyBurned
564
+ | HKQuantityTypeIdentifier.basalEnergyBurned
565
+ | HKQuantityTypeIdentifier.dietaryEnergyConsumed
566
+ ? EnergyUnit
567
+ : T extends
568
+ | HKQuantityTypeIdentifier.distanceCycling
569
+ | HKQuantityTypeIdentifier.distanceDownhillSnowSports
570
+ | HKQuantityTypeIdentifier.distanceSwimming
571
+ | HKQuantityTypeIdentifier.distanceWalkingRunning
572
+ | HKQuantityTypeIdentifier.distanceWheelchair
573
+ | HKQuantityTypeIdentifier.sixMinuteWalkTestDistance
574
+ | HKQuantityTypeIdentifier.waistCircumference
575
+ ? LengthUnit
576
+ : T extends
577
+ | HKQuantityTypeIdentifier.bodyFatPercentage
578
+ | HKQuantityTypeIdentifier.oxygenSaturation
579
+ | HKQuantityTypeIdentifier.walkingAsymmetryPercentage
580
+ | HKQuantityTypeIdentifier.walkingDoubleSupportPercentage
581
+ ? HKUnits.Percent
582
+ : T extends
583
+ | HKQuantityTypeIdentifier.basalBodyTemperature
584
+ | HKQuantityTypeIdentifier.basalBodyTemperature
585
+ ? TemperatureUnit
586
+ : T extends
587
+ | HKQuantityTypeIdentifier.stairAscentSpeed
588
+ | HKQuantityTypeIdentifier.stairDescentSpeed
589
+ | HKQuantityTypeIdentifier.walkingSpeed
590
+ | HKQuantityTypeIdentifier.walkingSpeed
591
+ ? SpeedUnit<LengthUnit, TimeUnit>
592
+ : T extends
593
+ | HKQuantityTypeIdentifier.flightsClimbed
594
+ | HKQuantityTypeIdentifier.numberOfAlcoholicBeverages
595
+ | HKQuantityTypeIdentifier.numberOfTimesFallen
596
+ | HKQuantityTypeIdentifier.pushCount
597
+ | HKQuantityTypeIdentifier.stepCount
598
+ | HKQuantityTypeIdentifier.swimmingStrokeCount
599
+ ? HKUnits.Count
600
+ : T extends
601
+ | HKQuantityTypeIdentifier.dietaryBiotin
602
+ | HKQuantityTypeIdentifier.dietaryCaffeine
603
+ | HKQuantityTypeIdentifier.dietaryCalcium
604
+ | HKQuantityTypeIdentifier.dietaryCarbohydrates
605
+ | HKQuantityTypeIdentifier.dietaryChloride
606
+ | HKQuantityTypeIdentifier.dietaryCholesterol
607
+ | HKQuantityTypeIdentifier.dietaryChromium
608
+ | HKQuantityTypeIdentifier.dietaryCopper
609
+ | HKQuantityTypeIdentifier.dietaryFatMonounsaturated
610
+ | HKQuantityTypeIdentifier.dietaryFatPolyunsaturated
611
+ | HKQuantityTypeIdentifier.dietaryFatSaturated
612
+ | HKQuantityTypeIdentifier.dietaryFatTotal
613
+ | HKQuantityTypeIdentifier.dietaryFiber
614
+ | HKQuantityTypeIdentifier.dietaryFolate
615
+ | HKQuantityTypeIdentifier.dietaryIodine
616
+ | HKQuantityTypeIdentifier.dietaryIodine
617
+ | HKQuantityTypeIdentifier.dietaryIron
618
+ | HKQuantityTypeIdentifier.dietaryMagnesium
619
+ | HKQuantityTypeIdentifier.dietaryManganese
620
+ | HKQuantityTypeIdentifier.dietaryMolybdenum
621
+ | HKQuantityTypeIdentifier.dietaryNiacin
622
+ | HKQuantityTypeIdentifier.dietaryPantothenicAcid
623
+ | HKQuantityTypeIdentifier.dietaryPhosphorus
624
+ | HKQuantityTypeIdentifier.dietaryPotassium
625
+ | HKQuantityTypeIdentifier.dietaryProtein
626
+ | HKQuantityTypeIdentifier.dietaryRiboflavin
627
+ | HKQuantityTypeIdentifier.dietarySelenium
628
+ | HKQuantityTypeIdentifier.dietarySodium
629
+ | HKQuantityTypeIdentifier.dietarySugar
630
+ | HKQuantityTypeIdentifier.dietaryThiamin
631
+ | HKQuantityTypeIdentifier.dietaryVitaminA
632
+ | HKQuantityTypeIdentifier.dietaryVitaminB6
633
+ | HKQuantityTypeIdentifier.dietaryVitaminB12
634
+ | HKQuantityTypeIdentifier.dietaryVitaminC
635
+ | HKQuantityTypeIdentifier.dietaryVitaminD
636
+ | HKQuantityTypeIdentifier.dietaryVitaminE
637
+ | HKQuantityTypeIdentifier.dietaryVitaminK
638
+ | HKQuantityTypeIdentifier.dietaryZinc
639
+ ? MassUnit
640
+ : T extends HKQuantityTypeIdentifier.dietaryWater
641
+ ? VolumeUnit
642
+ : T extends HKQuantityTypeIdentifier.insulinDelivery
643
+ ? HKUnits.InternationalUnit | `${HKUnits.InternationalUnit}`
644
+ : T extends
645
+ | HKQuantityTypeIdentifier.heartRate
646
+ | HKQuantityTypeIdentifier.restingHeartRate
647
+ | HKQuantityTypeIdentifier.walkingHeartRateAverage
648
+ ? CountPerTime<TimeUnit>
649
+ : HKUnit;
547
650
 
548
651
  export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
549
652
  T extends HKCategoryTypeIdentifier.cervicalMucusQuality
@@ -554,39 +657,70 @@ export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
554
657
  ? HKCategoryValueOvulationTestResult
555
658
  : T extends HKCategoryTypeIdentifier.sleepAnalysis
556
659
  ? HKCategoryValueSleepAnalysis
557
- : T extends (HKCategoryTypeIdentifier.highHeartRateEvent | HKCategoryTypeIdentifier.intermenstrualBleeding
558
- | HKCategoryTypeIdentifier.mindfulSession | HKCategoryTypeIdentifier.sexualActivity)
660
+ : T extends
661
+ | HKCategoryTypeIdentifier.highHeartRateEvent
662
+ | HKCategoryTypeIdentifier.intermenstrualBleeding
663
+ | HKCategoryTypeIdentifier.mindfulSession
664
+ | HKCategoryTypeIdentifier.sexualActivity
559
665
  ? HKCategoryValueNotApplicable
560
- : T extends (HKCategoryTypeIdentifier.abdominalCramps
666
+ : T extends
667
+ | HKCategoryTypeIdentifier.abdominalCramps
561
668
  | HKCategoryTypeIdentifier.abdominalCramps
562
669
  | HKCategoryTypeIdentifier.acne
563
670
  | HKCategoryTypeIdentifier.bladderIncontinence
564
- | HKCategoryTypeIdentifier.bloating| HKCategoryTypeIdentifier.breastPain
565
- | HKCategoryTypeIdentifier.chestTightnessOrPain| HKCategoryTypeIdentifier.chills| HKCategoryTypeIdentifier.constipation
566
- | HKCategoryTypeIdentifier.coughing| HKCategoryTypeIdentifier.diarrhea| HKCategoryTypeIdentifier.dizziness| HKCategoryTypeIdentifier.drySkin| HKCategoryTypeIdentifier.fainting
567
- | HKCategoryTypeIdentifier.fatigue| HKCategoryTypeIdentifier.fever| HKCategoryTypeIdentifier.generalizedBodyAche| HKCategoryTypeIdentifier.hairLoss
568
- | HKCategoryTypeIdentifier.headache| HKCategoryTypeIdentifier.heartburn
569
- | HKCategoryTypeIdentifier.hotFlashes| HKCategoryTypeIdentifier.lossOfSmell| HKCategoryTypeIdentifier.lossOfTaste
570
- | HKCategoryTypeIdentifier.lowerBackPain| HKCategoryTypeIdentifier.memoryLapse| HKCategoryTypeIdentifier.moodChanges
571
- | HKCategoryTypeIdentifier.nausea| HKCategoryTypeIdentifier.nightSweats| HKCategoryTypeIdentifier.pelvicPain
572
- | HKCategoryTypeIdentifier.rapidPoundingOrFlutteringHeartbeat| HKCategoryTypeIdentifier.runnyNose
573
- | HKCategoryTypeIdentifier.shortnessOfBreath| HKCategoryTypeIdentifier.sinusCongestion| HKCategoryTypeIdentifier.skippedHeartbeat
574
- | HKCategoryTypeIdentifier.soreThroat| HKCategoryTypeIdentifier.vaginalDryness
575
- | HKCategoryTypeIdentifier.vomiting| HKCategoryTypeIdentifier.wheezing)
671
+ | HKCategoryTypeIdentifier.bloating
672
+ | HKCategoryTypeIdentifier.breastPain
673
+ | HKCategoryTypeIdentifier.chestTightnessOrPain
674
+ | HKCategoryTypeIdentifier.chills
675
+ | HKCategoryTypeIdentifier.constipation
676
+ | HKCategoryTypeIdentifier.coughing
677
+ | HKCategoryTypeIdentifier.diarrhea
678
+ | HKCategoryTypeIdentifier.dizziness
679
+ | HKCategoryTypeIdentifier.drySkin
680
+ | HKCategoryTypeIdentifier.fainting
681
+ | HKCategoryTypeIdentifier.fatigue
682
+ | HKCategoryTypeIdentifier.fever
683
+ | HKCategoryTypeIdentifier.generalizedBodyAche
684
+ | HKCategoryTypeIdentifier.hairLoss
685
+ | HKCategoryTypeIdentifier.headache
686
+ | HKCategoryTypeIdentifier.heartburn
687
+ | HKCategoryTypeIdentifier.hotFlashes
688
+ | HKCategoryTypeIdentifier.lossOfSmell
689
+ | HKCategoryTypeIdentifier.lossOfTaste
690
+ | HKCategoryTypeIdentifier.lowerBackPain
691
+ | HKCategoryTypeIdentifier.memoryLapse
692
+ | HKCategoryTypeIdentifier.moodChanges
693
+ | HKCategoryTypeIdentifier.nausea
694
+ | HKCategoryTypeIdentifier.nightSweats
695
+ | HKCategoryTypeIdentifier.pelvicPain
696
+ | HKCategoryTypeIdentifier.rapidPoundingOrFlutteringHeartbeat
697
+ | HKCategoryTypeIdentifier.runnyNose
698
+ | HKCategoryTypeIdentifier.shortnessOfBreath
699
+ | HKCategoryTypeIdentifier.sinusCongestion
700
+ | HKCategoryTypeIdentifier.skippedHeartbeat
701
+ | HKCategoryTypeIdentifier.soreThroat
702
+ | HKCategoryTypeIdentifier.vaginalDryness
703
+ | HKCategoryTypeIdentifier.vomiting
704
+ | HKCategoryTypeIdentifier.wheezing
576
705
  ? HKCategoryValueSeverity
577
- : T extends (HKCategoryTypeIdentifier.appetiteChanges | HKCategoryTypeIdentifier.sleepChanges)
706
+ : T extends
707
+ | HKCategoryTypeIdentifier.appetiteChanges
708
+ | HKCategoryTypeIdentifier.sleepChanges
578
709
  ? HKCategoryValuePresence
579
- : T extends HKCategoryTypeIdentifier.lowCardioFitnessEvent ? HKCategoryValueLowCardioFitnessEvent :
580
- T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult :
581
- T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult :
582
- T extends HKCategoryTypeIdentifier.appleStandHour
710
+ : T extends HKCategoryTypeIdentifier.lowCardioFitnessEvent
711
+ ? HKCategoryValueLowCardioFitnessEvent
712
+ : T extends HKCategoryTypeIdentifier.pregnancyTestResult
713
+ ? HKCategoryValuePregnancyTestResult
714
+ : T extends HKCategoryTypeIdentifier.pregnancyTestResult
715
+ ? HKCategoryValuePregnancyTestResult
716
+ : T extends HKCategoryTypeIdentifier.appleStandHour
583
717
  ? HKCategoryValueAppleStandHour
584
718
  : number;
585
719
 
586
720
  enum HKCategoryValuePregnancyTestResult {
587
721
  positive = 2,
588
722
  negative = 1,
589
- indeterminate = 3
723
+ indeterminate = 3,
590
724
  }
591
725
  /* needs further mapping
592
726
 
@@ -651,53 +785,63 @@ export enum HKUnitMetric {
651
785
  }
652
786
 
653
787
  export enum HKUnits {
654
-
655
788
  DecibelHearingLevel = 'dBHL',
656
789
  DecibelSoundPressureLevel = 'dBASPL',
657
790
 
658
791
  Percent = '%',
659
792
  Count = 'count',
660
793
  InternationalUnit = 'IU',
661
-
662
794
  }
663
795
 
664
- export type MeterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Meter}`;
665
- export type LiterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Liter}`;
666
- export type GramUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Gram}`;
667
- export type PascalUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Pascal}`;
668
- export type SecondUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Second}`;
669
- export type JouleUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Joule}`;
670
- export type HertzUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Hertz}`;
671
- export type VoltUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Volt}`;
672
- export type SiemenUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Siemen}`;
796
+ export type MeterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
797
+ `${Prefix}${HKUnitMetric.Meter}`;
798
+ export type LiterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
799
+ `${Prefix}${HKUnitMetric.Liter}`;
800
+ export type GramUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
801
+ `${Prefix}${HKUnitMetric.Gram}`;
802
+ export type PascalUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
803
+ `${Prefix}${HKUnitMetric.Pascal}`;
804
+ export type SecondUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
805
+ `${Prefix}${HKUnitMetric.Second}`;
806
+ export type JouleUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
807
+ `${Prefix}${HKUnitMetric.Joule}`;
808
+ export type HertzUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
809
+ `${Prefix}${HKUnitMetric.Hertz}`;
810
+ export type VoltUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
811
+ `${Prefix}${HKUnitMetric.Volt}`;
812
+ export type SiemenUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =
813
+ `${Prefix}${HKUnitMetric.Siemen}`;
673
814
 
674
815
  // not 100% sure about these
675
- export type MoleUnit<MolarMass extends number> =`mol<${MolarMass}>`;
676
- export type MoleUnitWith<MolarMass extends number, Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}mol<${MolarMass}>`;
816
+ export type MoleUnit<MolarMass extends number> = `mol<${MolarMass}>`;
817
+ export type MoleUnitWith<
818
+ MolarMass extends number,
819
+ Prefix extends HKMetricPrefix = HKMetricPrefix.None
820
+ > = `${Prefix}mol<${MolarMass}>`;
677
821
 
678
- export type FrequencyUnit = HertzUnit<HKMetricPrefix>
822
+ export type FrequencyUnit = HertzUnit<HKMetricPrefix>;
679
823
 
680
824
  /**
681
- * More SI prefixes also available as literals, just type the string
682
- * @example 'cm', 'km'
683
- */
825
+ * More SI prefixes also available as literals, just type the string
826
+ * @example 'cm', 'km'
827
+ */
684
828
  export enum UnitOfLength {
685
829
  Feet = 'ft',
686
830
  /**
687
- * More SI prefixes also available as literals, just type the string
688
- * @example 'cm', 'km'
689
- */
831
+ * More SI prefixes also available as literals, just type the string
832
+ * @example 'cm', 'km'
833
+ */
690
834
  Meter = 'm',
691
835
  Inches = 'in',
692
836
  Yards = 'yd',
693
837
  Miles = 'mi',
694
838
  }
695
- export type LengthUnit = MeterUnit<HKMetricPrefix> | UnitOfLength
839
+ export type LengthUnit = MeterUnit<HKMetricPrefix> | UnitOfLength;
696
840
 
697
841
  /**
698
- * More SI prefixes also available as literals, just type the string
699
- * @example 'ml', 'cl'
700
- */
842
+ * More SI prefixes also available as literals, just type the string
843
+ * @example 'ml', 'cl'
844
+ */
701
845
  export enum UnitOfVolume {
702
846
  ImperialCup = 'cup_imp',
703
847
  ImperialFluidOunces = 'fl_oz_imp',
@@ -706,37 +850,37 @@ export enum UnitOfVolume {
706
850
  USFluidOunces = 'fl_oz_us',
707
851
  USPint = 'pt_us',
708
852
  /**
709
- * More SI prefixes also available as literals, just type the string
710
- * @example 'ml', 'cl'
711
- */
853
+ * More SI prefixes also available as literals, just type the string
854
+ * @example 'ml', 'cl'
855
+ */
712
856
  Liter = 'l',
713
857
  }
714
858
  export type VolumeUnit = LiterUnit<HKMetricPrefix> | UnitOfVolume;
715
859
 
716
860
  /**
717
- * More SI prefixes also available as literals, just type the string
718
- * @example 'mg', 'kg'
719
- */
861
+ * More SI prefixes also available as literals, just type the string
862
+ * @example 'mg', 'kg'
863
+ */
720
864
  export enum UnitOfMass {
721
865
  Ounces = 'oz',
722
866
  Stones = 'st',
723
867
  Pounds = 'lb',
724
868
  /**
725
- * More SI prefixes also available as literals, just type the string
726
- * @example 'mg', 'kg'
727
- */
728
- Gram = 'g'
869
+ * More SI prefixes also available as literals, just type the string
870
+ * @example 'mg', 'kg'
871
+ */
872
+ Gram = 'g',
729
873
  }
730
874
  /**
731
- * More SI prefixes also available as literals, just type the string
732
- * @example 'mg', 'kg'
733
- */
734
- export type MassUnit = GramUnit<HKMetricPrefix> | UnitOfMass
875
+ * More SI prefixes also available as literals, just type the string
876
+ * @example 'mg', 'kg'
877
+ */
878
+ export type MassUnit = GramUnit<HKMetricPrefix> | UnitOfMass;
735
879
 
736
880
  /**
737
- * More SI prefixes also available as literals, just type the string
738
- * @example 'kPa', 'hPa'
739
- */
881
+ * More SI prefixes also available as literals, just type the string
882
+ * @example 'kPa', 'hPa'
883
+ */
740
884
  export enum UnitOfPressure {
741
885
  Atmospheres = 'atm',
742
886
  CentimetersOfWater = 'cmAq',
@@ -744,37 +888,37 @@ export enum UnitOfPressure {
744
888
  InchesOfMercury = 'inHg',
745
889
  DecibelAWeightedSoundPressureLevel = 'dBASPL',
746
890
  /**
747
- * More SI prefixes also available as literals, just type the string
748
- * @example 'kPa', 'hPa'
749
- */
891
+ * More SI prefixes also available as literals, just type the string
892
+ * @example 'kPa', 'hPa'
893
+ */
750
894
  Pascals = 'Pa',
751
895
  }
752
896
 
753
897
  /**
754
- * More SI prefixes also available as literals, just type the string
755
- * @example 'kPa', 'hPa'
756
- */
898
+ * More SI prefixes also available as literals, just type the string
899
+ * @example 'kPa', 'hPa'
900
+ */
757
901
  export type PressureUnit = PascalUnit<HKMetricPrefix> | UnitOfPressure;
758
902
 
759
903
  /**
760
- * More SI prefixes also available as literals, just type the string
761
- * @example 'ms'
762
- */
904
+ * More SI prefixes also available as literals, just type the string
905
+ * @example 'ms'
906
+ */
763
907
  export enum UnitOfTime {
764
908
  Days = 'd',
765
909
  Minutes = 'min',
766
910
  Hours = 'hr',
767
911
  /**
768
- * More SI prefixes also available as literals, just type the string
769
- * @example 'ms'
770
- */
912
+ * More SI prefixes also available as literals, just type the string
913
+ * @example 'ms'
914
+ */
771
915
  Seconds = 's',
772
916
  }
773
917
  /**
774
- * More SI prefixes also available as literals, just type the string
775
- * @example 'ms'
776
- */
777
- export type TimeUnit = SecondUnit<HKMetricPrefix> | UnitOfTime
918
+ * More SI prefixes also available as literals, just type the string
919
+ * @example 'ms'
920
+ */
921
+ export type TimeUnit = SecondUnit<HKMetricPrefix> | UnitOfTime;
778
922
  export enum TemperatureUnit {
779
923
  DegreesCelsius = 'degC',
780
924
  DegreesFahrenheit = 'degF',
@@ -782,33 +926,54 @@ export enum TemperatureUnit {
782
926
  }
783
927
 
784
928
  /**
785
- * More SI prefixes also available as literals, just type the string
786
- * @example 'kJ'
787
- */
929
+ * More SI prefixes also available as literals, just type the string
930
+ * @example 'kJ'
931
+ */
788
932
  export enum UnitOfEnergy {
789
933
  Kilocalories = 'kcal',
790
934
  LargeCalories = 'Cal',
791
935
  SmallCalories = 'cal',
792
936
  /**
793
- * More SI prefixes also available as literals, just type the string
794
- * @example 'kJ'
795
- */
937
+ * More SI prefixes also available as literals, just type the string
938
+ * @example 'kJ'
939
+ */
796
940
  Joules = 'J',
797
941
  }
798
- export type EnergyUnit = JouleUnit<HKMetricPrefix> | UnitOfEnergy
942
+ export type EnergyUnit = JouleUnit<HKMetricPrefix> | UnitOfEnergy;
799
943
  export enum BloodGlucoseUnit {
800
944
  GlucoseMmolPerL = 'mmol<180.15588000005408>/l',
801
945
  GlucoseMgPerDl = 'mg/dL',
802
946
  }
803
947
 
804
- export type SpeedUnit<TLength extends LengthUnit, TTime extends TimeUnit> =`${TLength}/${TTime}`;
805
- export type CountPerTime<TTime extends TimeUnit> =`count/${TTime}`;
806
-
807
- export type HKUnit = BloodGlucoseUnit | CountPerTime<TimeUnit> | EnergyUnit
808
- | FrequencyUnit | HKUnits | LengthUnit | MassUnit | PressureUnit | SpeedUnit<LengthUnit, TimeUnit>
809
- | TemperatureUnit | TimeUnit | VolumeUnit
810
- | `${BloodGlucoseUnit}` | `${EnergyUnit}` | `${FrequencyUnit}` | `${HKUnits}` | `${LengthUnit}`
811
- | `${MassUnit}` | `${PressureUnit}` | `${TemperatureUnit}` | `${TimeUnit}` | `${VolumeUnit}`;
948
+ export type SpeedUnit<
949
+ TLength extends LengthUnit,
950
+ TTime extends TimeUnit
951
+ > = `${TLength}/${TTime}`;
952
+ export type CountPerTime<TTime extends TimeUnit> = `count/${TTime}`;
953
+
954
+ export type HKUnit =
955
+ | BloodGlucoseUnit
956
+ | CountPerTime<TimeUnit>
957
+ | EnergyUnit
958
+ | FrequencyUnit
959
+ | HKUnits
960
+ | LengthUnit
961
+ | MassUnit
962
+ | PressureUnit
963
+ | SpeedUnit<LengthUnit, TimeUnit>
964
+ | TemperatureUnit
965
+ | TimeUnit
966
+ | VolumeUnit
967
+ | `${BloodGlucoseUnit}`
968
+ | `${EnergyUnit}`
969
+ | `${FrequencyUnit}`
970
+ | `${HKUnits}`
971
+ | `${LengthUnit}`
972
+ | `${MassUnit}`
973
+ | `${PressureUnit}`
974
+ | `${TemperatureUnit}`
975
+ | `${TimeUnit}`
976
+ | `${VolumeUnit}`;
812
977
 
813
978
  export type HKDevice = {
814
979
  readonly name: string; // ex: "Apple Watch"
@@ -834,7 +999,7 @@ export type HKSourceRevision = {
834
999
 
835
1000
  export type HKQuantitySampleRaw<
836
1001
  TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
837
- TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
1002
+ TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>
838
1003
  > = {
839
1004
  readonly uuid: string;
840
1005
  readonly device?: HKDevice;
@@ -849,28 +1014,37 @@ export type HKQuantitySampleRaw<
849
1014
 
850
1015
  export type HKQuantitySampleRawForSaving<
851
1016
  TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
852
- TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
1017
+ TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>
853
1018
  > = Omit<
854
1019
  HKQuantitySampleRaw<TQuantityIdentifier, TUnit>,
855
1020
  'device' | 'endDate' | 'startDate' | 'uuid'
856
- >
1021
+ >;
857
1022
 
858
1023
  export type HKCategorySampleRawForSaving<
859
- TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier,
1024
+ TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
860
1025
  > = Omit<
861
1026
  HKCategorySampleRaw<TCategory>,
862
1027
  'device' | 'endDate' | 'startDate' | 'uuid'
863
- >
1028
+ >;
864
1029
 
865
- export type HKWorkoutRaw<TEnergy extends EnergyUnit, TDistance extends LengthUnit> = {
1030
+ export type HKWorkoutRaw<
1031
+ TEnergy extends EnergyUnit,
1032
+ TDistance extends LengthUnit
1033
+ > = {
866
1034
  readonly uuid: string;
867
1035
  readonly device?: HKDevice;
868
1036
  readonly workoutActivityType: HKWorkoutActivityType;
869
1037
  readonly duration: number;
870
1038
  readonly totalDistance?: HKQuantity<HKQuantityTypeIdentifier, TDistance>;
871
1039
  readonly totalEnergyBurned?: HKQuantity<HKQuantityTypeIdentifier, TEnergy>;
872
- readonly totalSwimmingStrokeCount?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
873
- readonly totalFlightsClimbed?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
1040
+ readonly totalSwimmingStrokeCount?: HKQuantity<
1041
+ HKQuantityTypeIdentifier,
1042
+ HKUnits.Count
1043
+ >;
1044
+ readonly totalFlightsClimbed?: HKQuantity<
1045
+ HKQuantityTypeIdentifier,
1046
+ HKUnits.Count
1047
+ >;
874
1048
  readonly startDate: string;
875
1049
  readonly endDate: string;
876
1050
  readonly metadata?: HKWorkoutMetadata;
@@ -888,11 +1062,17 @@ export enum HKCharacteristicTypeIdentifier {
888
1062
  }
889
1063
 
890
1064
  export type WritePermissions = {
891
- readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
1065
+ readonly [key in
1066
+ | HKCategoryTypeIdentifier
1067
+ | HKCharacteristicTypeIdentifier
1068
+ | HKQuantityTypeIdentifier]: boolean;
892
1069
  };
893
1070
 
894
1071
  export type ReadPermissions = {
895
- readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
1072
+ readonly [key in
1073
+ | HKCategoryTypeIdentifier
1074
+ | HKCharacteristicTypeIdentifier
1075
+ | HKQuantityTypeIdentifier]: boolean;
896
1076
  };
897
1077
 
898
1078
  export type HKCategorySampleRaw<
@@ -935,6 +1115,7 @@ export type WorkoutLocation = {
935
1115
  readonly horizontalAccuracy: number;
936
1116
  readonly speedAccuracy: number;
937
1117
  readonly verticalAccuracy: number;
1118
+ readonly distance: number | null;
938
1119
  };
939
1120
 
940
1121
  export type WorkoutRoute = {
@@ -945,6 +1126,7 @@ export type WorkoutRoute = {
945
1126
 
946
1127
  type ReactNativeHealthkitTypeNative = {
947
1128
  isHealthDataAvailable(): Promise<boolean>;
1129
+ canAccessProtectedData(): Promise<boolean>;
948
1130
  getBloodType(): Promise<HKBloodType>;
949
1131
  getDateOfBirth(): Promise<string>;
950
1132
  getBiologicalSex(): Promise<HKBiologicalSex>;
@@ -956,13 +1138,16 @@ type ReactNativeHealthkitTypeNative = {
956
1138
  updateFrequency: HKUpdateFrequency
957
1139
  ) => Promise<boolean>;
958
1140
  readonly disableBackgroundDelivery: (
959
- typeIdentifier: HKSampleTypeIdentifier,
1141
+ typeIdentifier: HKSampleTypeIdentifier
960
1142
  ) => Promise<boolean>;
961
1143
  readonly disableAllBackgroundDelivery: () => Promise<boolean>;
962
1144
 
963
1145
  readonly saveCorrelationSample: <
964
1146
  TIdentifier extends HKCorrelationTypeIdentifier,
965
- TSamples extends readonly (HKCategorySampleRawForSaving | HKQuantitySampleRawForSaving)[]
1147
+ TSamples extends readonly (
1148
+ | HKCategorySampleRawForSaving
1149
+ | HKQuantitySampleRawForSaving
1150
+ )[]
966
1151
  >(
967
1152
  typeIdentifier: TIdentifier,
968
1153
  samples: TSamples,
@@ -979,7 +1164,9 @@ type ReactNativeHealthkitTypeNative = {
979
1164
  metadata: HKWorkoutMetadata
980
1165
  ) => Promise<boolean>;
981
1166
 
982
- readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
1167
+ readonly queryCorrelationSamples: <
1168
+ TIdentifier extends HKCorrelationTypeIdentifier
1169
+ >(
983
1170
  typeIdentifier: TIdentifier,
984
1171
  from: string,
985
1172
  to: string
@@ -989,9 +1176,7 @@ type ReactNativeHealthkitTypeNative = {
989
1176
  identifier: HKSampleTypeIdentifier
990
1177
  ): Promise<QueryId>;
991
1178
  unsubscribeQuery(queryId: QueryId): Promise<boolean>;
992
- authorizationStatusFor(
993
- type: HealthkitReadAuthorization
994
- ): Promise<boolean>;
1179
+ authorizationStatusFor(type: HealthkitReadAuthorization): Promise<boolean>;
995
1180
  getRequestStatusForAuthorization(
996
1181
  write: WritePermissions,
997
1182
  read: ReadPermissions
@@ -1003,7 +1188,7 @@ type ReactNativeHealthkitTypeNative = {
1003
1188
  readonly saveQuantitySample: <
1004
1189
  TType extends HKQuantityTypeIdentifier,
1005
1190
  TUnit extends UnitForIdentifier<TType> = UnitForIdentifier<TType>
1006
- > (
1191
+ >(
1007
1192
  identifier: TType,
1008
1193
  unit: TUnit,
1009
1194
  value: number,
@@ -1015,7 +1200,10 @@ type ReactNativeHealthkitTypeNative = {
1015
1200
  typeIdentifier: TIdentifier,
1016
1201
  uuid: string
1017
1202
  ) => Promise<boolean>;
1018
- readonly queryWorkoutSamples: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(
1203
+ readonly queryWorkoutSamples: <
1204
+ TEnergy extends EnergyUnit,
1205
+ TDistance extends LengthUnit
1206
+ >(
1019
1207
  energyUnit: TEnergy,
1020
1208
  distanceUnit: TDistance,
1021
1209
  from: string,
@@ -1032,7 +1220,7 @@ type ReactNativeHealthkitTypeNative = {
1032
1220
  ) => Promise<readonly HKCategorySampleRaw<T>[]>;
1033
1221
  readonly queryQuantitySamples: <
1034
1222
  TIdentifier extends HKQuantityTypeIdentifier,
1035
- TUnit extends UnitForIdentifier<TIdentifier>,
1223
+ TUnit extends UnitForIdentifier<TIdentifier>
1036
1224
  >(
1037
1225
  identifier: TIdentifier,
1038
1226
  unit: TUnit,
@@ -1061,7 +1249,9 @@ type ReactNativeHealthkitTypeNative = {
1061
1249
  readonly getPreferredUnits: (
1062
1250
  identifiers: readonly HKQuantityTypeIdentifier[]
1063
1251
  ) => Promise<TypeToUnitMapping>;
1064
- readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
1252
+ readonly getWorkoutRoutes: (
1253
+ workoutUUID: string
1254
+ ) => Promise<readonly WorkoutRoute[]>;
1065
1255
  };
1066
1256
 
1067
1257
  const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
@@ -1080,7 +1270,7 @@ interface HealthkitEventEmitter extends NativeEventEmitter {
1080
1270
  }
1081
1271
 
1082
1272
  export const EventEmitter = new NativeEventEmitter(
1083
- NativeModules.ReactNativeHealthkit,
1273
+ NativeModules.ReactNativeHealthkit as NativeModule,
1084
1274
  ) as HealthkitEventEmitter
1085
1275
 
1086
1276
  export default Native