@kingstinct/react-native-healthkit 4.4.6 → 5.0.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/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/commonjs/index.ios.js +66 -394
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +2 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +170 -78
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js +13 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
- package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
- package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
- package/lib/commonjs/utils/deserializeSample.js +17 -0
- package/lib/commonjs/utils/deserializeSample.js.map +1 -0
- package/lib/commonjs/utils/deserializeWorkout.js +17 -0
- package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
- package/lib/commonjs/utils/ensureMetadata.js +14 -0
- package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
- package/lib/commonjs/utils/ensureUnit.js +23 -0
- package/lib/commonjs/utils/ensureUnit.js.map +1 -0
- package/lib/commonjs/utils/getDateOfBirth.js +19 -0
- package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnit.js +19 -0
- package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnits.js +19 -0
- package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/commonjs/utils/prepareOptions.js +27 -0
- package/lib/commonjs/utils/prepareOptions.js.map +1 -0
- package/lib/commonjs/utils/queryCategorySamples.js +24 -0
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/utils/queryWorkouts.js +30 -0
- package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
- package/lib/commonjs/utils/requestAuthorization.js +25 -0
- package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
- package/lib/commonjs/utils/saveCategorySample.js +21 -0
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
- package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
- package/lib/commonjs/utils/saveQuantitySample.js +21 -0
- package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
- package/lib/commonjs/utils/serializeDate.js +12 -0
- package/lib/commonjs/utils/serializeDate.js.map +1 -0
- package/lib/commonjs/utils/subscribeToChanges.js +37 -0
- package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
- package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentWorkout.js +47 -0
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
- package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/module/hooks/useSubscribeToChanges.js +26 -0
- package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/module/index.ios.js +32 -370
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +3 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +154 -74
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +15 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.js +7 -0
- package/lib/module/utils/deserializeCategorySample.js.map +1 -0
- package/lib/module/utils/deserializeCorrelation.js +21 -0
- package/lib/module/utils/deserializeCorrelation.js.map +1 -0
- package/lib/module/utils/deserializeSample.js +9 -0
- package/lib/module/utils/deserializeSample.js.map +1 -0
- package/lib/module/utils/deserializeWorkout.js +9 -0
- package/lib/module/utils/deserializeWorkout.js.map +1 -0
- package/lib/module/utils/ensureMetadata.js +6 -0
- package/lib/module/utils/ensureMetadata.js.map +1 -0
- package/lib/module/utils/ensureUnit.js +13 -0
- package/lib/module/utils/ensureUnit.js.map +1 -0
- package/lib/module/utils/getDateOfBirth.js +9 -0
- package/lib/module/utils/getDateOfBirth.js.map +1 -0
- package/lib/module/utils/getMostRecentCategorySample.js +12 -0
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/module/utils/getMostRecentWorkout.js +14 -0
- package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/module/utils/getPreferredUnit.js +9 -0
- package/lib/module/utils/getPreferredUnit.js.map +1 -0
- package/lib/module/utils/getPreferredUnits.js +9 -0
- package/lib/module/utils/getPreferredUnits.js.map +1 -0
- package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
- package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/module/utils/prepareOptions.js +17 -0
- package/lib/module/utils/prepareOptions.js.map +1 -0
- package/lib/module/utils/queryCategorySamples.js +12 -0
- package/lib/module/utils/queryCategorySamples.js.map +1 -0
- package/lib/module/utils/queryCorrelationSamples.js +12 -0
- package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/module/utils/queryQuantitySamples.js +14 -0
- package/lib/module/utils/queryQuantitySamples.js.map +1 -0
- package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
- package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/module/utils/queryWorkouts.js +17 -0
- package/lib/module/utils/queryWorkouts.js.map +1 -0
- package/lib/module/utils/requestAuthorization.js +15 -0
- package/lib/module/utils/requestAuthorization.js.map +1 -0
- package/lib/module/utils/saveCategorySample.js +11 -0
- package/lib/module/utils/saveCategorySample.js.map +1 -0
- package/lib/module/utils/saveCorrelationSample.js +13 -0
- package/lib/module/utils/saveCorrelationSample.js.map +1 -0
- package/lib/module/utils/saveQuantitySample.js +11 -0
- package/lib/module/utils/saveQuantitySample.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +14 -0
- package/lib/module/utils/saveWorkoutSample.js.map +1 -0
- package/lib/module/utils/serializeDate.js +4 -0
- package/lib/module/utils/serializeDate.js.map +1 -0
- package/lib/module/utils/subscribeToChanges.js +25 -0
- package/lib/module/utils/subscribeToChanges.js.map +1 -0
- package/lib/typescript/example-expo/App.d.ts +2 -0
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
- package/lib/typescript/src/index.d.ts +2 -3
- package/lib/typescript/src/index.ios.d.ts +48 -3
- package/lib/typescript/src/native-types.d.ts +169 -65
- package/lib/typescript/src/types.d.ts +14 -90
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
- package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
- package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
- package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
- package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
- package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
- package/package.json +17 -6
- package/src/hooks/useHealthkitAuthorization.ts +39 -0
- package/src/hooks/useIsHealthDataAvailable.ts +17 -0
- package/src/hooks/useMostRecentCategorySample.ts +24 -0
- package/src/hooks/useMostRecentQuantitySample.ts +39 -0
- package/src/hooks/useMostRecentWorkout.ts +60 -0
- package/src/hooks/useStatisticsForQuantity.ts +42 -0
- package/src/hooks/useSubscribeToChanges.ts +31 -0
- package/src/index.ios.tsx +36 -569
- package/src/index.tsx +5 -7
- package/src/native-types.ts +213 -74
- package/src/types.ts +41 -152
- package/src/utils/deserializeCategorySample.ts +12 -0
- package/src/utils/deserializeCorrelation.ts +28 -0
- package/src/utils/deserializeSample.ts +17 -0
- package/src/utils/deserializeWorkout.ts +14 -0
- package/src/utils/ensureMetadata.ts +5 -0
- package/src/utils/ensureUnit.ts +19 -0
- package/src/utils/getDateOfBirth.ts +8 -0
- package/src/utils/getMostRecentCategorySample.ts +18 -0
- package/src/utils/getMostRecentQuantitySample.ts +19 -0
- package/src/utils/getMostRecentWorkout.ts +27 -0
- package/src/utils/getPreferredUnit.ts +14 -0
- package/src/utils/getPreferredUnits.ts +14 -0
- package/src/utils/getPreferredUnitsTyped.ts +38 -0
- package/src/utils/getRequestStatusForAuthorization.ts +21 -0
- package/src/utils/prepareOptions.ts +15 -0
- package/src/utils/queryCategorySamples.ts +29 -0
- package/src/utils/queryCorrelationSamples.ts +29 -0
- package/src/utils/queryQuantitySamples.ts +36 -0
- package/src/utils/queryStatisticsForQuantity.ts +38 -0
- package/src/utils/queryWorkouts.ts +28 -0
- package/src/utils/requestAuthorization.ts +18 -0
- package/src/utils/saveCategorySample.ts +27 -0
- package/src/utils/saveCorrelationSample.ts +34 -0
- package/src/utils/saveQuantitySample.ts +29 -0
- package/src/utils/saveWorkoutSample.ts +28 -0
- package/src/utils/serializeDate.ts +3 -0
- package/src/utils/subscribeToChanges.ts +32 -0
package/src/native-types.ts
CHANGED
|
@@ -369,10 +369,10 @@ enum HKIndoorWorkout {
|
|
|
369
369
|
export interface HKWorkoutMetadata
|
|
370
370
|
extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
|
|
371
371
|
readonly HKWeatherCondition?: HKWeatherCondition;
|
|
372
|
-
readonly HKWeatherHumidity?: HKQuantity<
|
|
372
|
+
readonly HKWeatherHumidity?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Percent>;
|
|
373
373
|
// HKWeatherTemperature: HKQuantity<TTemperatureUnit>
|
|
374
|
-
readonly HKAverageMETs?: HKQuantity<HKUnit>,
|
|
375
|
-
readonly HKElevationAscended?: HKQuantity<
|
|
374
|
+
readonly HKAverageMETs?: HKQuantity<HKQuantityTypeIdentifier, HKUnit>,
|
|
375
|
+
readonly HKElevationAscended?: HKQuantity<HKQuantityTypeIdentifier, LengthUnit>,
|
|
376
376
|
readonly HKIndoorWorkout?: HKIndoorWorkout,
|
|
377
377
|
}
|
|
378
378
|
|
|
@@ -388,8 +388,8 @@ export enum HKAuthorizationStatus {
|
|
|
388
388
|
sharingAuthorized = 2,
|
|
389
389
|
}
|
|
390
390
|
|
|
391
|
-
export type HKQuantity<
|
|
392
|
-
readonly unit:
|
|
391
|
+
export type HKQuantity<TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>> = {
|
|
392
|
+
readonly unit: TUnit;
|
|
393
393
|
readonly quantity: number;
|
|
394
394
|
};
|
|
395
395
|
|
|
@@ -433,14 +433,14 @@ export enum HKStatisticsOptions {
|
|
|
433
433
|
separateBySource = 'separateBySource',
|
|
434
434
|
}
|
|
435
435
|
|
|
436
|
-
export type QueryStatisticsResponseRaw<
|
|
437
|
-
readonly averageQuantity?: HKQuantity<TUnit>;
|
|
438
|
-
readonly maximumQuantity?: HKQuantity<TUnit>;
|
|
439
|
-
readonly minimumQuantity?: HKQuantity<TUnit>;
|
|
440
|
-
readonly sumQuantity?: HKQuantity<TUnit>;
|
|
441
|
-
readonly mostRecentQuantity?: HKQuantity<TUnit>;
|
|
436
|
+
export type QueryStatisticsResponseRaw<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>> = {
|
|
437
|
+
readonly averageQuantity?: HKQuantity<TIdentifier, TUnit>;
|
|
438
|
+
readonly maximumQuantity?: HKQuantity<TIdentifier, TUnit>;
|
|
439
|
+
readonly minimumQuantity?: HKQuantity<TIdentifier, TUnit>;
|
|
440
|
+
readonly sumQuantity?: HKQuantity<TIdentifier, TUnit>;
|
|
441
|
+
readonly mostRecentQuantity?: HKQuantity<TIdentifier, TUnit>;
|
|
442
442
|
readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
|
|
443
|
-
readonly duration?: HKQuantity<
|
|
443
|
+
readonly duration?: HKQuantity<HKQuantityTypeIdentifier, TimeUnit>;
|
|
444
444
|
};
|
|
445
445
|
|
|
446
446
|
export enum HKCategoryValueCervicalMucusQuality {
|
|
@@ -531,6 +531,20 @@ export type MetadataMapperForCorrelationIdentifier<
|
|
|
531
531
|
}
|
|
532
532
|
: HKGenericMetadata;
|
|
533
533
|
|
|
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
|
|
547
|
+
|
|
534
548
|
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
|
|
535
549
|
T extends HKCategoryTypeIdentifier.cervicalMucusQuality
|
|
536
550
|
? HKCategoryValueCervicalMucusQuality
|
|
@@ -606,7 +620,8 @@ export enum HKWheelchairUse {
|
|
|
606
620
|
}
|
|
607
621
|
|
|
608
622
|
// Unit types are a straight mapping from here https://developer.apple.com/documentation/healthkit/hkunit/1615733-init
|
|
609
|
-
export enum
|
|
623
|
+
export enum HKMetricPrefix {
|
|
624
|
+
None = '',
|
|
610
625
|
Pico = 'p',
|
|
611
626
|
Nano = 'n',
|
|
612
627
|
Micro = 'mc',
|
|
@@ -619,64 +634,179 @@ export enum HKUnitSIPrefix {
|
|
|
619
634
|
Mega = 'M',
|
|
620
635
|
Giga = 'G',
|
|
621
636
|
Tera = 'T',
|
|
637
|
+
Femto = 'f',
|
|
622
638
|
}
|
|
623
639
|
|
|
624
|
-
export enum
|
|
625
|
-
|
|
626
|
-
|
|
640
|
+
export enum HKUnitMetric {
|
|
641
|
+
Gram = 'g',
|
|
642
|
+
Joule = 'J',
|
|
627
643
|
Kelvin = 'K',
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
644
|
+
Liter = 'l',
|
|
645
|
+
Meter = 'm',
|
|
646
|
+
Pascal = 'Pa',
|
|
647
|
+
Second = 's',
|
|
648
|
+
Siemen = 'S',
|
|
649
|
+
Hertz = 'Hz',
|
|
650
|
+
Volt = 'V',
|
|
633
651
|
}
|
|
634
652
|
|
|
635
|
-
export enum
|
|
636
|
-
Grams = 'g',
|
|
637
|
-
Joules = 'J',
|
|
638
|
-
Kelvin = 'K',
|
|
639
|
-
Liters = 'l',
|
|
640
|
-
Meters = 'm',
|
|
641
|
-
Pascals = 'Pa',
|
|
642
|
-
Seconds = 's',
|
|
643
|
-
Siemens = 'S',
|
|
653
|
+
export enum HKUnits {
|
|
644
654
|
|
|
645
|
-
Atmospheres = 'atm',
|
|
646
|
-
CentimetersOfWater = 'cmAq',
|
|
647
|
-
Count = 'count',
|
|
648
|
-
Days = 'd',
|
|
649
655
|
DecibelHearingLevel = 'dBHL',
|
|
650
656
|
DecibelSoundPressureLevel = 'dBASPL',
|
|
651
|
-
|
|
652
|
-
|
|
657
|
+
|
|
658
|
+
Percent = '%',
|
|
659
|
+
Count = 'count',
|
|
660
|
+
InternationalUnit = 'IU',
|
|
661
|
+
|
|
662
|
+
}
|
|
663
|
+
|
|
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}`;
|
|
673
|
+
|
|
674
|
+
// 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}>`;
|
|
677
|
+
|
|
678
|
+
export type FrequencyUnit = HertzUnit<HKMetricPrefix>
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* More SI prefixes also available as literals, just type the string
|
|
682
|
+
* @example 'cm', 'km'
|
|
683
|
+
*/
|
|
684
|
+
export enum UnitOfLength {
|
|
653
685
|
Feet = 'ft',
|
|
654
|
-
|
|
655
|
-
|
|
686
|
+
/**
|
|
687
|
+
* More SI prefixes also available as literals, just type the string
|
|
688
|
+
* @example 'cm', 'km'
|
|
689
|
+
*/
|
|
690
|
+
Meter = 'm',
|
|
691
|
+
Inches = 'in',
|
|
692
|
+
Yards = 'yd',
|
|
693
|
+
Miles = 'mi',
|
|
694
|
+
}
|
|
695
|
+
export type LengthUnit = MeterUnit<HKMetricPrefix> | UnitOfLength
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* More SI prefixes also available as literals, just type the string
|
|
699
|
+
* @example 'ml', 'cl'
|
|
700
|
+
*/
|
|
701
|
+
export enum UnitOfVolume {
|
|
656
702
|
ImperialCup = 'cup_imp',
|
|
657
703
|
ImperialFluidOunces = 'fl_oz_imp',
|
|
658
704
|
ImperialPint = 'pt_imp',
|
|
659
|
-
Inches = 'in',
|
|
660
|
-
InternationalUnit = 'IU',
|
|
661
|
-
Kilocalories = 'kcal',
|
|
662
|
-
LargeCalories = 'Cal',
|
|
663
|
-
Miles = 'mi',
|
|
664
|
-
MillimetersOfMercury = 'mmHg',
|
|
665
|
-
Minutes = 'min',
|
|
666
|
-
Ounces = 'oz',
|
|
667
|
-
Percent = '%',
|
|
668
|
-
Pounds = 'lb',
|
|
669
|
-
SmallCalories = 'cal',
|
|
670
|
-
Stones = 'st',
|
|
671
705
|
USCup = 'cup_us',
|
|
672
706
|
USFluidOunces = 'fl_oz_us',
|
|
673
707
|
USPint = 'pt_us',
|
|
674
|
-
|
|
708
|
+
/**
|
|
709
|
+
* More SI prefixes also available as literals, just type the string
|
|
710
|
+
* @example 'ml', 'cl'
|
|
711
|
+
*/
|
|
712
|
+
Liter = 'l',
|
|
713
|
+
}
|
|
714
|
+
export type VolumeUnit = LiterUnit<HKMetricPrefix> | UnitOfVolume;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* More SI prefixes also available as literals, just type the string
|
|
718
|
+
* @example 'mg', 'kg'
|
|
719
|
+
*/
|
|
720
|
+
export enum UnitOfMass {
|
|
721
|
+
Ounces = 'oz',
|
|
722
|
+
Stones = 'st',
|
|
723
|
+
Pounds = 'lb',
|
|
724
|
+
/**
|
|
725
|
+
* More SI prefixes also available as literals, just type the string
|
|
726
|
+
* @example 'mg', 'kg'
|
|
727
|
+
*/
|
|
728
|
+
Gram = 'g'
|
|
729
|
+
}
|
|
730
|
+
/**
|
|
731
|
+
* More SI prefixes also available as literals, just type the string
|
|
732
|
+
* @example 'mg', 'kg'
|
|
733
|
+
*/
|
|
734
|
+
export type MassUnit = GramUnit<HKMetricPrefix> | UnitOfMass
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* More SI prefixes also available as literals, just type the string
|
|
738
|
+
* @example 'kPa', 'hPa'
|
|
739
|
+
*/
|
|
740
|
+
export enum UnitOfPressure {
|
|
741
|
+
Atmospheres = 'atm',
|
|
742
|
+
CentimetersOfWater = 'cmAq',
|
|
743
|
+
MillimetersOfMercury = 'mmHg',
|
|
744
|
+
InchesOfMercury = 'inHg',
|
|
745
|
+
DecibelAWeightedSoundPressureLevel = 'dBASPL',
|
|
746
|
+
/**
|
|
747
|
+
* More SI prefixes also available as literals, just type the string
|
|
748
|
+
* @example 'kPa', 'hPa'
|
|
749
|
+
*/
|
|
750
|
+
Pascals = 'Pa',
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* More SI prefixes also available as literals, just type the string
|
|
755
|
+
* @example 'kPa', 'hPa'
|
|
756
|
+
*/
|
|
757
|
+
export type PressureUnit = PascalUnit<HKMetricPrefix> | UnitOfPressure;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* More SI prefixes also available as literals, just type the string
|
|
761
|
+
* @example 'ms'
|
|
762
|
+
*/
|
|
763
|
+
export enum UnitOfTime {
|
|
764
|
+
Days = 'd',
|
|
765
|
+
Minutes = 'min',
|
|
766
|
+
Hours = 'hr',
|
|
767
|
+
/**
|
|
768
|
+
* More SI prefixes also available as literals, just type the string
|
|
769
|
+
* @example 'ms'
|
|
770
|
+
*/
|
|
771
|
+
Seconds = 's',
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* More SI prefixes also available as literals, just type the string
|
|
775
|
+
* @example 'ms'
|
|
776
|
+
*/
|
|
777
|
+
export type TimeUnit = SecondUnit<HKMetricPrefix> | UnitOfTime
|
|
778
|
+
export enum TemperatureUnit {
|
|
779
|
+
DegreesCelsius = 'degC',
|
|
780
|
+
DegreesFahrenheit = 'degF',
|
|
781
|
+
Kelvin = 'K',
|
|
782
|
+
}
|
|
675
783
|
|
|
784
|
+
/**
|
|
785
|
+
* More SI prefixes also available as literals, just type the string
|
|
786
|
+
* @example 'kJ'
|
|
787
|
+
*/
|
|
788
|
+
export enum UnitOfEnergy {
|
|
789
|
+
Kilocalories = 'kcal',
|
|
790
|
+
LargeCalories = 'Cal',
|
|
791
|
+
SmallCalories = 'cal',
|
|
792
|
+
/**
|
|
793
|
+
* More SI prefixes also available as literals, just type the string
|
|
794
|
+
* @example 'kJ'
|
|
795
|
+
*/
|
|
796
|
+
Joules = 'J',
|
|
797
|
+
}
|
|
798
|
+
export type EnergyUnit = JouleUnit<HKMetricPrefix> | UnitOfEnergy
|
|
799
|
+
export enum BloodGlucoseUnit {
|
|
676
800
|
GlucoseMmolPerL = 'mmol<180.15588000005408>/l',
|
|
677
801
|
GlucoseMgPerDl = 'mg/dL',
|
|
678
802
|
}
|
|
679
803
|
|
|
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 | FrequencyUnit | HKUnits | LengthUnit | MassUnit | PressureUnit | SpeedUnit<LengthUnit, TimeUnit> | TemperatureUnit | TimeUnit | VolumeUnit
|
|
808
|
+
| `${BloodGlucoseUnit}` | `${EnergyUnit}` | `${FrequencyUnit}` | `${HKUnits}` | `${LengthUnit}` | `${MassUnit}` | `${PressureUnit}` | `${TemperatureUnit}` | `${TimeUnit}` | `${VolumeUnit}`;
|
|
809
|
+
|
|
680
810
|
export type HKDevice = {
|
|
681
811
|
readonly name: string; // ex: "Apple Watch"
|
|
682
812
|
readonly firmwareVersion: string | null;
|
|
@@ -701,7 +831,7 @@ export type HKSourceRevision = {
|
|
|
701
831
|
|
|
702
832
|
export type HKQuantitySampleRaw<
|
|
703
833
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
704
|
-
TUnit extends
|
|
834
|
+
TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
|
|
705
835
|
> = {
|
|
706
836
|
readonly uuid: string;
|
|
707
837
|
readonly device?: HKDevice;
|
|
@@ -714,15 +844,30 @@ export type HKQuantitySampleRaw<
|
|
|
714
844
|
readonly sourceRevision?: HKSourceRevision;
|
|
715
845
|
};
|
|
716
846
|
|
|
717
|
-
export type
|
|
847
|
+
export type HKQuantitySampleRawForSaving<
|
|
848
|
+
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
849
|
+
TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
|
|
850
|
+
> = Omit<
|
|
851
|
+
HKQuantitySampleRaw<TQuantityIdentifier, TUnit>,
|
|
852
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
853
|
+
>
|
|
854
|
+
|
|
855
|
+
export type HKCategorySampleRawForSaving<
|
|
856
|
+
TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier,
|
|
857
|
+
> = Omit<
|
|
858
|
+
HKCategorySampleRaw<TCategory>,
|
|
859
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
860
|
+
>
|
|
861
|
+
|
|
862
|
+
export type HKWorkoutRaw<TEnergy extends EnergyUnit, TDistance extends LengthUnit> = {
|
|
718
863
|
readonly uuid: string;
|
|
719
864
|
readonly device?: HKDevice;
|
|
720
865
|
readonly workoutActivityType: HKWorkoutActivityType;
|
|
721
866
|
readonly duration: number;
|
|
722
|
-
readonly totalDistance?: HKQuantity<TDistance>;
|
|
723
|
-
readonly totalEnergyBurned?: HKQuantity<TEnergy>;
|
|
724
|
-
readonly totalSwimmingStrokeCount?: HKQuantity<
|
|
725
|
-
readonly totalFlightsClimbed?: HKQuantity<
|
|
867
|
+
readonly totalDistance?: HKQuantity<HKQuantityTypeIdentifier, TDistance>;
|
|
868
|
+
readonly totalEnergyBurned?: HKQuantity<HKQuantityTypeIdentifier, TEnergy>;
|
|
869
|
+
readonly totalSwimmingStrokeCount?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
|
|
870
|
+
readonly totalFlightsClimbed?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
|
|
726
871
|
readonly startDate: string;
|
|
727
872
|
readonly endDate: string;
|
|
728
873
|
readonly metadata?: HKWorkoutMetadata;
|
|
@@ -812,12 +957,9 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
812
957
|
) => Promise<boolean>;
|
|
813
958
|
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
814
959
|
|
|
815
|
-
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
960
|
+
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier, TSamples extends readonly (HKCategorySampleRawForSaving | HKQuantitySampleRawForSaving)[]>(
|
|
816
961
|
typeIdentifier: TIdentifier,
|
|
817
|
-
samples:
|
|
818
|
-
HKCategorySampleRaw | HKQuantitySampleRaw,
|
|
819
|
-
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
820
|
-
>[],
|
|
962
|
+
samples: TSamples,
|
|
821
963
|
start: string,
|
|
822
964
|
end: string,
|
|
823
965
|
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>
|
|
@@ -825,10 +967,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
825
967
|
|
|
826
968
|
readonly saveWorkoutSample: (
|
|
827
969
|
typeIdentifier: HKWorkoutActivityType,
|
|
828
|
-
quantities: readonly
|
|
829
|
-
HKQuantitySampleRaw,
|
|
830
|
-
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
831
|
-
>[],
|
|
970
|
+
quantities: readonly HKQuantitySampleRawForSaving[],
|
|
832
971
|
start: string,
|
|
833
972
|
end: string,
|
|
834
973
|
metadata: HKWorkoutMetadata
|
|
@@ -855,15 +994,15 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
855
994
|
write: WritePermissions,
|
|
856
995
|
read: ReadPermissions
|
|
857
996
|
): Promise<boolean>;
|
|
858
|
-
readonly saveQuantitySample: (
|
|
859
|
-
identifier:
|
|
860
|
-
unit:
|
|
997
|
+
readonly saveQuantitySample: <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType> = UnitForIdentifier<TType>> (
|
|
998
|
+
identifier: TType,
|
|
999
|
+
unit: TUnit,
|
|
861
1000
|
value: number,
|
|
862
1001
|
start: string,
|
|
863
1002
|
end: string,
|
|
864
1003
|
metadata: unknown
|
|
865
1004
|
) => Promise<boolean>;
|
|
866
|
-
readonly queryWorkoutSamples: <TEnergy extends
|
|
1005
|
+
readonly queryWorkoutSamples: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(
|
|
867
1006
|
energyUnit: TEnergy,
|
|
868
1007
|
distanceUnit: TDistance,
|
|
869
1008
|
from: string,
|
|
@@ -879,8 +1018,8 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
879
1018
|
ascending: boolean
|
|
880
1019
|
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
881
1020
|
readonly queryQuantitySamples: <
|
|
882
|
-
|
|
883
|
-
|
|
1021
|
+
TIdentifier extends HKQuantityTypeIdentifier,
|
|
1022
|
+
TUnit extends UnitForIdentifier<TIdentifier>,
|
|
884
1023
|
>(
|
|
885
1024
|
identifier: TIdentifier,
|
|
886
1025
|
unit: TUnit,
|
|
@@ -896,13 +1035,13 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
896
1035
|
end: string,
|
|
897
1036
|
metadata: unknown
|
|
898
1037
|
) => Promise<boolean>;
|
|
899
|
-
readonly queryStatisticsForQuantity: <TUnit extends
|
|
1038
|
+
readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(
|
|
900
1039
|
identifier: HKQuantityTypeIdentifier,
|
|
901
1040
|
unit: TUnit,
|
|
902
1041
|
from: string,
|
|
903
1042
|
to: string,
|
|
904
1043
|
options: readonly HKStatisticsOptions[]
|
|
905
|
-
) => Promise<QueryStatisticsResponseRaw<TUnit>>;
|
|
1044
|
+
) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
|
|
906
1045
|
readonly getPreferredUnits: (
|
|
907
1046
|
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
908
1047
|
) => Promise<TypeToUnitMapping>;
|