@kingstinct/react-native-healthkit 8.7.2 → 9.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/ReactNativeHealthkit.podspec +36 -0
- package/app.plugin.js +43 -33
- package/ios/Bridge.h +8 -0
- package/ios/CategoryTypeModule.swift +128 -0
- package/ios/CharacteristicTypeModule.swift +78 -0
- package/ios/Constants.swift +2 -0
- package/ios/CoreModule.swift +376 -0
- package/ios/CorrelationTypeModule.swift +153 -0
- package/ios/HeartbeatSeriesModule.swift +189 -0
- package/ios/Helpers.swift +529 -251
- package/ios/QuantityTypeModule.swift +461 -0
- package/ios/Serializers.swift +211 -124
- package/ios/SourceProxy.swift +35 -0
- package/ios/StateOfMindModule.swift +160 -0
- package/ios/WorkoutProxy.swift +405 -0
- package/ios/WorkoutSessionModule.swift +182 -0
- package/ios/WorkoutsModule.swift +357 -0
- package/package.json +43 -127
- package/react-native.config.js +16 -0
- package/src/hooks/useHealthkitAuthorization.test.ts +47 -29
- package/src/hooks/useHealthkitAuthorization.ts +21 -15
- package/src/hooks/useIsHealthDataAvailable.test.ts +17 -7
- package/src/hooks/useIsHealthDataAvailable.ts +7 -7
- package/src/hooks/useMostRecentCategorySample.ts +10 -12
- package/src/hooks/useMostRecentQuantitySample.ts +17 -36
- package/src/hooks/useMostRecentWorkout.ts +16 -38
- package/src/hooks/useSources.ts +8 -12
- package/src/hooks/useStatisticsForQuantity.ts +19 -14
- package/src/hooks/useSubscribeToChanges.ts +9 -13
- package/src/index.ios.ts +232 -0
- package/src/index.ts +444 -0
- package/src/modules.ts +43 -0
- package/src/specs/CategoryTypeModule.nitro.ts +64 -0
- package/src/specs/CharacteristicTypeModule.nitro.ts +22 -0
- package/src/specs/CoreModule.nitro.ts +107 -0
- package/src/specs/CorrelationTypeModule.nitro.ts +23 -0
- package/src/specs/HeartbeatSeriesModule.nitro.ts +19 -0
- package/src/specs/QuantityTypeModule.nitro.ts +60 -0
- package/src/specs/SourceProxy.nitro.ts +13 -0
- package/src/specs/StateOfMindModule.nitro.ts +23 -0
- package/src/specs/WorkoutProxy.nitro.ts +18 -0
- package/src/specs/WorkoutSessionModule.nitro.ts +71 -0
- package/src/specs/WorkoutsModule.nitro.ts +32 -0
- package/src/test-setup.ts +68 -54
- package/src/test-utils.ts +3 -2
- package/src/types/Auth.ts +17 -0
- package/src/types/Background.ts +9 -0
- package/src/types/CategoryType.ts +249 -0
- package/src/types/CategoryTypeIdentifier.ts +99 -0
- package/src/types/Characteristics.ts +53 -0
- package/src/types/Constants.ts +25 -0
- package/src/types/CorrelationType.ts +31 -0
- package/src/types/Device.ts +13 -0
- package/src/types/HeartbeatSeries.ts +29 -0
- package/src/types/InterfaceVerification.ts +164 -0
- package/src/types/InterfaceVerificationExample.ts +89 -0
- package/src/types/QuantitySample.ts +30 -0
- package/src/types/QuantityType.ts +192 -0
- package/src/types/QuantityTypeIdentifier.ts +758 -0
- package/src/types/QueryOptions.ts +69 -0
- package/src/types/README-InterfaceVerification.md +103 -0
- package/src/types/Shared.ts +79 -0
- package/src/types/Source.ts +11 -0
- package/src/types/StateOfMind.ts +110 -0
- package/src/types/Subscriptons.ts +10 -0
- package/src/types/Units.ts +190 -0
- package/src/types/WeatherCondition.ts +31 -0
- package/src/types/WorkoutKit.ts +18 -0
- package/src/types/Workouts.ts +282 -0
- package/src/utils/getMostRecentCategorySample.ts +7 -11
- package/src/utils/getMostRecentQuantitySample.ts +8 -18
- package/src/utils/getMostRecentWorkout.ts +7 -17
- package/src/utils/getPreferredUnit.ts +12 -8
- package/src/utils/subscribeToChanges.ts +9 -26
- package/LICENSE +0 -21
- package/README.md +0 -179
- package/ios/ReactNativeHealthkit-Bridging-Header.h +0 -2
- package/ios/ReactNativeHealthkit.m +0 -271
- package/ios/ReactNativeHealthkit.swift +0 -2333
- package/ios/ReactNativeHealthkit.xcodeproj/project.pbxproj +0 -279
- package/kingstinct-react-native-healthkit.podspec +0 -21
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -39
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +0 -72
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -27
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +0 -41
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +0 -23
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -37
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -48
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/hooks/useSources.js +0 -22
- package/lib/commonjs/hooks/useSources.js.map +0 -1
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +0 -28
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -28
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/commonjs/index.ios.js +0 -531
- package/lib/commonjs/index.ios.js.map +0 -1
- package/lib/commonjs/index.js +0 -22
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/index.native.js +0 -235
- package/lib/commonjs/index.native.js.map +0 -1
- package/lib/commonjs/index.web.js +0 -22
- package/lib/commonjs/index.web.js.map +0 -1
- package/lib/commonjs/native-types.js +0 -1575
- package/lib/commonjs/native-types.js.map +0 -1
- package/lib/commonjs/test-setup.js +0 -57
- package/lib/commonjs/test-setup.js.map +0 -1
- package/lib/commonjs/test-utils.js +0 -18
- package/lib/commonjs/test-utils.js.map +0 -1
- package/lib/commonjs/types.js +0 -17
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/deleteQuantitySample.js +0 -11
- package/lib/commonjs/utils/deleteQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/deleteSamples.js +0 -18
- package/lib/commonjs/utils/deleteSamples.js.map +0 -1
- package/lib/commonjs/utils/deleteWorkoutSample.js +0 -11
- package/lib/commonjs/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +0 -13
- package/lib/commonjs/utils/deserializeCategorySample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.test.js +0 -26
- package/lib/commonjs/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/commonjs/utils/deserializeCorrelation.js +0 -26
- package/lib/commonjs/utils/deserializeCorrelation.js.map +0 -1
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +0 -15
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeSample.js +0 -15
- package/lib/commonjs/utils/deserializeSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeWorkout.js +0 -15
- package/lib/commonjs/utils/deserializeWorkout.js.map +0 -1
- package/lib/commonjs/utils/ensureMetadata.js +0 -11
- package/lib/commonjs/utils/ensureMetadata.js.map +0 -1
- package/lib/commonjs/utils/ensureTotals.js +0 -11
- package/lib/commonjs/utils/ensureTotals.js.map +0 -1
- package/lib/commonjs/utils/ensureUnit.js +0 -17
- package/lib/commonjs/utils/ensureUnit.js.map +0 -1
- package/lib/commonjs/utils/getDateOfBirth.js +0 -14
- package/lib/commonjs/utils/getDateOfBirth.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +0 -17
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +0 -21
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentWorkout.js +0 -19
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnit.js +0 -14
- package/lib/commonjs/utils/getPreferredUnit.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnits.js +0 -14
- package/lib/commonjs/utils/getPreferredUnits.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -33
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +0 -21
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/commonjs/utils/getWorkoutPlanById.js +0 -13
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/commonjs/utils/prepareOptions.js +0 -25
- package/lib/commonjs/utils/prepareOptions.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamples.js +0 -17
- package/lib/commonjs/utils/queryCategorySamples.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryCorrelationSamples.js +0 -17
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +0 -17
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +0 -19
- package/lib/commonjs/utils/queryQuantitySamples.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +0 -23
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/querySources.js +0 -14
- package/lib/commonjs/utils/querySources.js.map +0 -1
- package/lib/commonjs/utils/queryStateOfMindSamples.js +0 -22
- package/lib/commonjs/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js +0 -16
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +0 -29
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js +0 -26
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryWorkouts.js +0 -22
- package/lib/commonjs/utils/queryWorkouts.js.map +0 -1
- package/lib/commonjs/utils/requestAuthorization.js +0 -22
- package/lib/commonjs/utils/requestAuthorization.js.map +0 -1
- package/lib/commonjs/utils/saveCategorySample.js +0 -20
- package/lib/commonjs/utils/saveCategorySample.js.map +0 -1
- package/lib/commonjs/utils/saveCorrelationSample.js +0 -35
- package/lib/commonjs/utils/saveCorrelationSample.js.map +0 -1
- package/lib/commonjs/utils/saveQuantitySample.js +0 -16
- package/lib/commonjs/utils/saveQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/saveStateOfMindSample.js +0 -17
- package/lib/commonjs/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +0 -26
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +0 -36
- package/lib/commonjs/utils/saveWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.js +0 -9
- package/lib/commonjs/utils/serializeDate.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.test.js +0 -17
- package/lib/commonjs/utils/serializeDate.test.js.map +0 -1
- package/lib/commonjs/utils/startWatchApp.js +0 -11
- package/lib/commonjs/utils/startWatchApp.js.map +0 -1
- package/lib/commonjs/utils/subscribeToChanges.js +0 -27
- package/lib/commonjs/utils/subscribeToChanges.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +0 -32
- package/lib/module/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js +0 -68
- package/lib/module/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js +0 -21
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js +0 -37
- package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +0 -16
- package/lib/module/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +0 -30
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentWorkout.js +0 -41
- package/lib/module/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/module/hooks/useSources.js +0 -15
- package/lib/module/hooks/useSources.js.map +0 -1
- package/lib/module/hooks/useStatisticsForQuantity.js +0 -21
- package/lib/module/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/module/hooks/useSubscribeToChanges.js +0 -21
- package/lib/module/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/module/index.ios.js +0 -209
- package/lib/module/index.ios.js.map +0 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.native.js +0 -160
- package/lib/module/index.native.js.map +0 -1
- package/lib/module/index.web.js +0 -4
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/native-types.js +0 -1606
- package/lib/module/native-types.js.map +0 -1
- package/lib/module/test-setup.js +0 -54
- package/lib/module/test-setup.js.map +0 -1
- package/lib/module/test-utils.js +0 -11
- package/lib/module/test-utils.js.map +0 -1
- package/lib/module/types.js +0 -67
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/deleteQuantitySample.js +0 -4
- package/lib/module/utils/deleteQuantitySample.js.map +0 -1
- package/lib/module/utils/deleteSamples.js +0 -11
- package/lib/module/utils/deleteSamples.js.map +0 -1
- package/lib/module/utils/deleteWorkoutSample.js +0 -4
- package/lib/module/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.js +0 -7
- package/lib/module/utils/deserializeCategorySample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.test.js +0 -22
- package/lib/module/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/module/utils/deserializeCorrelation.js +0 -19
- package/lib/module/utils/deserializeCorrelation.js.map +0 -1
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js +0 -9
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/module/utils/deserializeSample.js +0 -9
- package/lib/module/utils/deserializeSample.js.map +0 -1
- package/lib/module/utils/deserializeWorkout.js +0 -9
- package/lib/module/utils/deserializeWorkout.js.map +0 -1
- package/lib/module/utils/ensureMetadata.js +0 -5
- package/lib/module/utils/ensureMetadata.js.map +0 -1
- package/lib/module/utils/ensureTotals.js +0 -5
- package/lib/module/utils/ensureTotals.js.map +0 -1
- package/lib/module/utils/ensureUnit.js +0 -10
- package/lib/module/utils/ensureUnit.js.map +0 -1
- package/lib/module/utils/getDateOfBirth.js +0 -7
- package/lib/module/utils/getDateOfBirth.js.map +0 -1
- package/lib/module/utils/getMostRecentCategorySample.js +0 -10
- package/lib/module/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +0 -14
- package/lib/module/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/module/utils/getMostRecentWorkout.js +0 -12
- package/lib/module/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/module/utils/getPreferredUnit.js +0 -7
- package/lib/module/utils/getPreferredUnit.js.map +0 -1
- package/lib/module/utils/getPreferredUnits.js +0 -7
- package/lib/module/utils/getPreferredUnits.js.map +0 -1
- package/lib/module/utils/getPreferredUnitsTyped.js +0 -26
- package/lib/module/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/module/utils/getRequestStatusForAuthorization.js +0 -14
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/module/utils/getWorkoutPlanById.js +0 -6
- package/lib/module/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/module/utils/prepareOptions.js +0 -18
- package/lib/module/utils/prepareOptions.js.map +0 -1
- package/lib/module/utils/queryCategorySamples.js +0 -10
- package/lib/module/utils/queryCategorySamples.js.map +0 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryCorrelationSamples.js +0 -10
- package/lib/module/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamples.js +0 -10
- package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryQuantitySamples.js +0 -12
- package/lib/module/utils/queryQuantitySamples.js.map +0 -1
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js +0 -16
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/querySources.js +0 -7
- package/lib/module/utils/querySources.js.map +0 -1
- package/lib/module/utils/queryStateOfMindSamples.js +0 -14
- package/lib/module/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js +0 -9
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/module/utils/queryStatisticsForQuantity.js +0 -22
- package/lib/module/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js +0 -19
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryWorkouts.js +0 -15
- package/lib/module/utils/queryWorkouts.js.map +0 -1
- package/lib/module/utils/requestAuthorization.js +0 -15
- package/lib/module/utils/requestAuthorization.js.map +0 -1
- package/lib/module/utils/saveCategorySample.js +0 -13
- package/lib/module/utils/saveCategorySample.js.map +0 -1
- package/lib/module/utils/saveCorrelationSample.js +0 -28
- package/lib/module/utils/saveCorrelationSample.js.map +0 -1
- package/lib/module/utils/saveQuantitySample.js +0 -9
- package/lib/module/utils/saveQuantitySample.js.map +0 -1
- package/lib/module/utils/saveStateOfMindSample.js +0 -10
- package/lib/module/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/module/utils/saveWorkoutRoute.js +0 -19
- package/lib/module/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/module/utils/saveWorkoutSample.js +0 -29
- package/lib/module/utils/saveWorkoutSample.js.map +0 -1
- package/lib/module/utils/serializeDate.js +0 -3
- package/lib/module/utils/serializeDate.js.map +0 -1
- package/lib/module/utils/serializeDate.test.js +0 -14
- package/lib/module/utils/serializeDate.test.js.map +0 -1
- package/lib/module/utils/startWatchApp.js +0 -4
- package/lib/module/utils/startWatchApp.js.map +0 -1
- package/lib/module/utils/subscribeToChanges.js +0 -20
- package/lib/module/utils/subscribeToChanges.js.map +0 -1
- package/lib/typescript/example-expo/App.d.ts +0 -2
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +0 -8
- package/lib/typescript/src/hooks/useHealthkitAuthorization.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +0 -7
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +0 -10
- package/lib/typescript/src/hooks/useSources.d.ts +0 -3
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +0 -4
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +0 -3
- package/lib/typescript/src/index.d.ts +0 -3
- package/lib/typescript/src/index.ios.d.ts +0 -198
- package/lib/typescript/src/index.native.d.ts +0 -41
- package/lib/typescript/src/index.web.d.ts +0 -3
- package/lib/typescript/src/native-types.d.ts +0 -1764
- package/lib/typescript/src/test-setup.d.ts +0 -1
- package/lib/typescript/src/test-utils.d.ts +0 -2
- package/lib/typescript/src/types.d.ts +0 -111
- package/lib/typescript/src/utils/deleteQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/deleteSamples.d.ts +0 -8
- package/lib/typescript/src/utils/deleteWorkoutSample.d.ts +0 -3
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeCategorySample.test.d.ts +0 -1
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeHeartbeatSeriesSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +0 -4
- package/lib/typescript/src/utils/ensureMetadata.d.ts +0 -2
- package/lib/typescript/src/utils/ensureTotals.d.ts +0 -2
- package/lib/typescript/src/utils/ensureUnit.d.ts +0 -3
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +0 -2
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +0 -5
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +0 -9
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +0 -3
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +0 -5
- package/lib/typescript/src/utils/prepareOptions.d.ts +0 -9
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +0 -10
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +0 -12
- package/lib/typescript/src/utils/querySources.d.ts +0 -4
- package/lib/typescript/src/utils/queryStateOfMindSamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryStatisticsCollectionForQuantity.d.ts +0 -3
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +0 -14
- package/lib/typescript/src/utils/queryWorkoutSamplesWithAnchor.d.ts +0 -9
- package/lib/typescript/src/utils/queryWorkouts.d.ts +0 -4
- package/lib/typescript/src/utils/requestAuthorization.d.ts +0 -4
- package/lib/typescript/src/utils/saveCategorySample.d.ts +0 -11
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +0 -8
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +0 -7
- package/lib/typescript/src/utils/saveStateOfMindSample.d.ts +0 -11
- package/lib/typescript/src/utils/saveWorkoutRoute.d.ts +0 -3
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +0 -11
- package/lib/typescript/src/utils/serializeDate.d.ts +0 -2
- package/lib/typescript/src/utils/serializeDate.test.d.ts +0 -1
- package/lib/typescript/src/utils/startWatchApp.d.ts +0 -3
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +0 -3
- package/src/index.ios.tsx +0 -292
- package/src/index.native.tsx +0 -233
- package/src/index.tsx +0 -5
- package/src/index.web.tsx +0 -5
- package/src/native-types.ts +0 -2471
- package/src/types.ts +0 -156
- package/src/utils/deleteQuantitySample.ts +0 -14
- package/src/utils/deleteSamples.ts +0 -23
- package/src/utils/deleteWorkoutSample.ts +0 -7
- package/src/utils/deserializeCategorySample.test.ts +0 -24
- package/src/utils/deserializeCategorySample.ts +0 -12
- package/src/utils/deserializeCorrelation.ts +0 -28
- package/src/utils/deserializeHeartbeatSeriesSample.ts +0 -12
- package/src/utils/deserializeSample.ts +0 -17
- package/src/utils/deserializeWorkout.ts +0 -14
- package/src/utils/ensureMetadata.ts +0 -5
- package/src/utils/ensureTotals.ts +0 -5
- package/src/utils/ensureUnit.ts +0 -19
- package/src/utils/getDateOfBirth.ts +0 -8
- package/src/utils/getPreferredUnits.ts +0 -14
- package/src/utils/getPreferredUnitsTyped.ts +0 -38
- package/src/utils/getRequestStatusForAuthorization.ts +0 -21
- package/src/utils/getWorkoutPlanById.ts +0 -7
- package/src/utils/prepareOptions.ts +0 -19
- package/src/utils/queryCategorySamples.ts +0 -29
- package/src/utils/queryCategorySamplesWithAnchor.ts +0 -39
- package/src/utils/queryCorrelationSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +0 -33
- package/src/utils/queryQuantitySamples.ts +0 -38
- package/src/utils/queryQuantitySamplesWithAnchor.ts +0 -46
- package/src/utils/querySources.ts +0 -21
- package/src/utils/queryStateOfMindSamples.ts +0 -14
- package/src/utils/queryStatisticsCollectionForQuantity.ts +0 -38
- package/src/utils/queryStatisticsForQuantity.ts +0 -38
- package/src/utils/queryWorkoutSamplesWithAnchor.ts +0 -46
- package/src/utils/queryWorkouts.ts +0 -28
- package/src/utils/requestAuthorization.ts +0 -19
- package/src/utils/saveCategorySample.ts +0 -31
- package/src/utils/saveCorrelationSample.ts +0 -43
- package/src/utils/saveQuantitySample.ts +0 -29
- package/src/utils/saveStateOfMindSample.ts +0 -38
- package/src/utils/saveWorkoutRoute.ts +0 -21
- package/src/utils/saveWorkoutSample.ts +0 -42
- package/src/utils/serializeDate.test.ts +0 -16
- package/src/utils/serializeDate.ts +0 -5
- package/src/utils/startWatchApp.ts +0 -7
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
|
+
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro'
|
|
3
|
+
import type { Device } from './Device'
|
|
4
|
+
import type { Quantity } from './QuantityType'
|
|
5
|
+
import type { PredicateForSamples } from './QueryOptions'
|
|
6
|
+
import type { DeletedSample, GenericMetadata } from './Shared'
|
|
7
|
+
import type { SourceRevision } from './Source'
|
|
8
|
+
|
|
9
|
+
export enum WorkoutActivityType {
|
|
10
|
+
americanFootball = 1,
|
|
11
|
+
archery = 2,
|
|
12
|
+
australianFootball = 3,
|
|
13
|
+
badminton = 4,
|
|
14
|
+
baseball = 5,
|
|
15
|
+
basketball = 6,
|
|
16
|
+
bowling = 7,
|
|
17
|
+
boxing = 8, // See also HKWorkoutActivityTypeKickboxing.,
|
|
18
|
+
climbing = 9,
|
|
19
|
+
cricket = 10,
|
|
20
|
+
crossTraining = 11, // Any mix of cardio and/or strength training. See also HKWorkoutActivityTypeCoreTraining and HKWorkoutActivityTypeFlexibility.,
|
|
21
|
+
curling = 12,
|
|
22
|
+
cycling = 13,
|
|
23
|
+
dance = 14,
|
|
24
|
+
danceInspiredTraining = 15, // This enum remains available to access older data.,
|
|
25
|
+
elliptical = 16,
|
|
26
|
+
equestrianSports = 17, // Polo, Horse Racing, Horse Riding, etc.,
|
|
27
|
+
fencing = 18,
|
|
28
|
+
fishing = 19,
|
|
29
|
+
functionalStrengthTraining = 20, // Primarily free weights and/or body weight and/or accessories,
|
|
30
|
+
golf = 21,
|
|
31
|
+
gymnastics = 22,
|
|
32
|
+
handball = 23,
|
|
33
|
+
hiking = 24,
|
|
34
|
+
hockey = 25, // Ice Hockey, Field Hockey, etc.,
|
|
35
|
+
hunting = 26,
|
|
36
|
+
lacrosse = 27,
|
|
37
|
+
martialArts = 28,
|
|
38
|
+
mindAndBody = 29, // Qigong, meditation, etc.,
|
|
39
|
+
mixedMetabolicCardioTraining = 30, // This enum remains available to access older data.,
|
|
40
|
+
paddleSports = 31, // Canoeing, Kayaking, Outrigger, Stand Up Paddle Board, etc.,
|
|
41
|
+
play = 32, // Dodge Ball, Hopscotch, Tetherball, Jungle Gym, etc.,
|
|
42
|
+
preparationAndRecovery = 33, // Foam rolling, stretching, etc.,
|
|
43
|
+
racquetball = 34,
|
|
44
|
+
rowing = 35,
|
|
45
|
+
rugby = 36,
|
|
46
|
+
running = 37,
|
|
47
|
+
sailing = 38,
|
|
48
|
+
skatingSports = 39, // Ice Skating, Speed Skating, Inline Skating, Skateboarding, etc.,
|
|
49
|
+
snowSports = 40, // Sledding, Snowmobiling, Building a Snowman, etc. See also HKWorkoutActivityTypeCrossCountrySkiing, HKWorkoutActivityTypeSnowboarding, and HKWorkoutActivityTypeDownhillSkiing.,
|
|
50
|
+
soccer = 41,
|
|
51
|
+
softball = 42,
|
|
52
|
+
squash = 43,
|
|
53
|
+
stairClimbing = 44, // See also HKWorkoutActivityTypeStairs and HKWorkoutActivityTypeStepTraining.,
|
|
54
|
+
surfingSports = 45, // Traditional Surfing, Kite Surfing, Wind Surfing, etc.,
|
|
55
|
+
swimming = 46,
|
|
56
|
+
tableTennis = 47,
|
|
57
|
+
tennis = 48,
|
|
58
|
+
trackAndField = 49, // Shot Put, Javelin, Pole Vaulting, etc.,
|
|
59
|
+
traditionalStrengthTraining = 50, // Primarily machines and/or free weights,
|
|
60
|
+
volleyball = 51,
|
|
61
|
+
walking = 52,
|
|
62
|
+
waterFitness = 53,
|
|
63
|
+
waterPolo = 54,
|
|
64
|
+
waterSports = 55, // Water Skiing, Wake Boarding, etc.,
|
|
65
|
+
wrestling = 56,
|
|
66
|
+
yoga = 57,
|
|
67
|
+
barre = 58, // HKWorkoutActivityTypeDanceInspiredTraining,
|
|
68
|
+
coreTraining = 59,
|
|
69
|
+
crossCountrySkiing = 60,
|
|
70
|
+
downhillSkiing = 61,
|
|
71
|
+
flexibility = 62,
|
|
72
|
+
highIntensityIntervalTraining = 63,
|
|
73
|
+
jumpRope = 64,
|
|
74
|
+
kickboxing = 65,
|
|
75
|
+
pilates = 66, // HKWorkoutActivityTypeDanceInspiredTraining,
|
|
76
|
+
snowboarding = 67,
|
|
77
|
+
stairs = 68,
|
|
78
|
+
stepTraining = 69,
|
|
79
|
+
wheelchairWalkPace = 70,
|
|
80
|
+
wheelchairRunPace = 71,
|
|
81
|
+
taiChi = 72,
|
|
82
|
+
mixedCardio = 73, // HKWorkoutActivityTypeMixedMetabolicCardioTraining,
|
|
83
|
+
handCycling = 74,
|
|
84
|
+
discSports = 75,
|
|
85
|
+
fitnessGaming = 76,
|
|
86
|
+
cardioDance = 77,
|
|
87
|
+
socialDance = 78,
|
|
88
|
+
pickleball = 79,
|
|
89
|
+
cooldown = 80,
|
|
90
|
+
swimBikeRun = 82,
|
|
91
|
+
transition = 83,
|
|
92
|
+
underwaterDiving = 84,
|
|
93
|
+
other = 3000,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// documented at https://developer.apple.com/documentation/healthkit/hkweathercondition
|
|
97
|
+
export enum WeatherCondition {
|
|
98
|
+
none = 0,
|
|
99
|
+
clear = 1,
|
|
100
|
+
fair = 2,
|
|
101
|
+
partlyCloudy = 3,
|
|
102
|
+
mostlyCloudy = 4,
|
|
103
|
+
cloudy = 5,
|
|
104
|
+
foggy = 6,
|
|
105
|
+
haze = 7,
|
|
106
|
+
windy = 8,
|
|
107
|
+
blustery = 9,
|
|
108
|
+
smoky = 10,
|
|
109
|
+
dust = 11,
|
|
110
|
+
snow = 12,
|
|
111
|
+
hail = 13,
|
|
112
|
+
sleet = 14,
|
|
113
|
+
freezingDrizzle = 15,
|
|
114
|
+
freezingRain = 16,
|
|
115
|
+
mixedRainAndHail = 17,
|
|
116
|
+
mixedRainAndSnow = 18,
|
|
117
|
+
mixedRainAndSleet = 19,
|
|
118
|
+
mixedSnowAndSleet = 20,
|
|
119
|
+
drizzle = 21,
|
|
120
|
+
scatteredShowers = 22,
|
|
121
|
+
showers = 23,
|
|
122
|
+
thunderstorms = 24,
|
|
123
|
+
tropicalStorm = 25,
|
|
124
|
+
hurricane = 26,
|
|
125
|
+
tornado = 27,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface WorkoutMetadata extends GenericMetadata {
|
|
129
|
+
readonly HKWeatherCondition?: WeatherCondition
|
|
130
|
+
readonly HKWeatherHumidity?: Quantity
|
|
131
|
+
readonly HKWeatherTemperature?: Quantity
|
|
132
|
+
readonly HKAverageMETs?: Quantity
|
|
133
|
+
readonly HKElevationAscended?: Quantity
|
|
134
|
+
readonly HKIndoorWorkout?: boolean
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface WorkoutEvent {
|
|
138
|
+
readonly type: WorkoutEventType
|
|
139
|
+
readonly startDate: Date
|
|
140
|
+
readonly endDate: Date
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export enum WorkoutEventType {
|
|
144
|
+
pause = 1,
|
|
145
|
+
resume = 2,
|
|
146
|
+
lap = 3,
|
|
147
|
+
marker = 4,
|
|
148
|
+
motionPaused = 5,
|
|
149
|
+
motionResumed = 6,
|
|
150
|
+
segment = 7,
|
|
151
|
+
pauseOrResumeRequest = 8,
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface WorkoutActivity {
|
|
155
|
+
readonly startDate: Date
|
|
156
|
+
readonly endDate: Date
|
|
157
|
+
readonly uuid: string
|
|
158
|
+
readonly duration: number
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface WorkoutRoute {
|
|
162
|
+
readonly locations: readonly WorkoutRouteLocation[]
|
|
163
|
+
readonly HKMetadataKeySyncIdentifier?: string
|
|
164
|
+
readonly HKMetadataKeySyncVersion?: number
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface QueryWorkoutSamplesWithAnchorResponse {
|
|
168
|
+
readonly workouts: readonly WorkoutProxy[]
|
|
169
|
+
readonly deletedSamples: readonly DeletedSample[]
|
|
170
|
+
readonly newAnchor: string
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type WorkoutActivityTypePredicate = {
|
|
174
|
+
readonly workoutActivityType: WorkoutActivityType
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
enum ComparisonPredicateOperator {
|
|
178
|
+
lessThan = 0,
|
|
179
|
+
lessThanOrEqualTo = 1,
|
|
180
|
+
greaterThan = 2,
|
|
181
|
+
greaterThanOrEqualTo = 3,
|
|
182
|
+
equalTo = 4,
|
|
183
|
+
notEqualTo = 5,
|
|
184
|
+
matches = 6,
|
|
185
|
+
like = 7,
|
|
186
|
+
beginsWith = 8,
|
|
187
|
+
endsWith = 9,
|
|
188
|
+
in = 10,
|
|
189
|
+
customSelector = 11,
|
|
190
|
+
contains = 99,
|
|
191
|
+
between = 100,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type WorkoutDurationPredicate = {
|
|
195
|
+
readonly predicateOperator: ComparisonPredicateOperator
|
|
196
|
+
readonly durationInSeconds: number
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type PredicateForWorkouts =
|
|
200
|
+
| PredicateForSamples
|
|
201
|
+
| WorkoutActivityTypePredicate
|
|
202
|
+
| WorkoutDurationPredicate
|
|
203
|
+
|
|
204
|
+
export type PredicateForWorkoutsOr = {
|
|
205
|
+
readonly OR: readonly PredicateForWorkouts[]
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export type PredicateForWorkoutsAnd = {
|
|
209
|
+
readonly AND: readonly PredicateForWorkouts[]
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type FilterForWorkouts =
|
|
213
|
+
| PredicateForWorkouts
|
|
214
|
+
| PredicateForWorkoutsOr
|
|
215
|
+
| PredicateForWorkoutsAnd
|
|
216
|
+
|
|
217
|
+
export interface WorkoutQueryOptionsWithAnchor {
|
|
218
|
+
energyUnit?: string
|
|
219
|
+
distanceUnit?: string
|
|
220
|
+
filter?: FilterForWorkouts
|
|
221
|
+
limit?: number
|
|
222
|
+
anchor?: string
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface WorkoutQueryOptions {
|
|
226
|
+
energyUnit?: string
|
|
227
|
+
distanceUnit?: string
|
|
228
|
+
filter?: FilterForWorkouts
|
|
229
|
+
limit?: number
|
|
230
|
+
ascending?: boolean
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface WorkoutRouteLocation {
|
|
234
|
+
readonly altitude: number
|
|
235
|
+
readonly course: number
|
|
236
|
+
readonly date: Date
|
|
237
|
+
readonly distance: number | null
|
|
238
|
+
readonly horizontalAccuracy: number
|
|
239
|
+
readonly latitude: number
|
|
240
|
+
readonly longitude: number
|
|
241
|
+
readonly speed: number
|
|
242
|
+
readonly speedAccuracy: number
|
|
243
|
+
readonly verticalAccuracy: number
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface LocationForSaving {
|
|
247
|
+
readonly altitude: number
|
|
248
|
+
readonly course: number
|
|
249
|
+
readonly date: Date // unix timestamp in milliseconds
|
|
250
|
+
readonly horizontalAccuracy: number
|
|
251
|
+
readonly latitude: number
|
|
252
|
+
readonly longitude: number
|
|
253
|
+
readonly speed: number
|
|
254
|
+
readonly verticalAccuracy: number
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface WorkoutPlan {
|
|
258
|
+
readonly id: string
|
|
259
|
+
readonly activityType: WorkoutActivityType
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface WorkoutTotals {
|
|
263
|
+
readonly distance?: number
|
|
264
|
+
readonly energyBurned?: number
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface WorkoutSample {
|
|
268
|
+
readonly uuid: string
|
|
269
|
+
readonly device?: Device
|
|
270
|
+
readonly workoutActivityType: WorkoutActivityType
|
|
271
|
+
readonly duration: Quantity
|
|
272
|
+
readonly totalDistance?: Quantity
|
|
273
|
+
readonly totalEnergyBurned?: Quantity
|
|
274
|
+
readonly totalSwimmingStrokeCount?: Quantity
|
|
275
|
+
readonly totalFlightsClimbed?: Quantity
|
|
276
|
+
readonly startDate: Date
|
|
277
|
+
readonly endDate: Date
|
|
278
|
+
readonly metadata?: AnyMap
|
|
279
|
+
readonly sourceRevision?: SourceRevision
|
|
280
|
+
readonly events?: readonly WorkoutEvent[]
|
|
281
|
+
readonly activities?: readonly WorkoutActivity[]
|
|
282
|
+
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CategoryTypes } from '../modules'
|
|
2
|
+
import type { CategoryTypeIdentifier } from '../types/CategoryTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
T extends HKCategoryTypeIdentifier
|
|
8
|
-
>(
|
|
9
|
-
identifier: T,
|
|
10
|
-
): Promise<HKCategorySample<T> | null> {
|
|
11
|
-
const samples = await queryCategorySamples(identifier, {
|
|
4
|
+
export async function getMostRecentCategorySample<
|
|
5
|
+
T extends CategoryTypeIdentifier,
|
|
6
|
+
>(identifier: T) {
|
|
7
|
+
const samples = await CategoryTypes.queryCategorySamples(identifier, {
|
|
12
8
|
limit: 1,
|
|
13
9
|
ascending: false,
|
|
14
10
|
})
|
|
15
11
|
|
|
16
|
-
return samples[0]
|
|
12
|
+
return samples[0]
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
export default getMostRecentCategorySample
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { QuantityTypes } from '../modules'
|
|
2
|
+
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
9
|
-
>(
|
|
10
|
-
identifier: TIdentifier,
|
|
11
|
-
unit: TUnit,
|
|
12
|
-
): Promise<HKQuantitySample<TIdentifier, TUnit> | null> {
|
|
13
|
-
const samples = await queryQuantitySamples(identifier, {
|
|
4
|
+
async function getMostRecentQuantitySample(
|
|
5
|
+
identifier: QuantityTypeIdentifier,
|
|
6
|
+
unit?: string,
|
|
7
|
+
) {
|
|
8
|
+
const samples = await QuantityTypes.queryQuantitySamples(identifier, {
|
|
14
9
|
limit: 1,
|
|
15
10
|
unit,
|
|
16
11
|
})
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (lastSample) {
|
|
21
|
-
return lastSample as HKQuantitySample<TIdentifier, TUnit>
|
|
22
|
-
}
|
|
23
|
-
return null
|
|
13
|
+
return samples[0]
|
|
24
14
|
}
|
|
25
15
|
|
|
26
16
|
export default getMostRecentQuantitySample
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Workouts } from '../modules'
|
|
2
|
+
import type { WorkoutQueryOptions } from '../types/Workouts'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TEnergy extends EnergyUnit,
|
|
8
|
-
TDistance extends LengthUnit
|
|
9
|
-
>(
|
|
10
|
-
options?: Pick<
|
|
11
|
-
QueryWorkoutsOptions<TEnergy, TDistance>,
|
|
12
|
-
'distanceUnit' | 'energyUnit'
|
|
13
|
-
>
|
|
14
|
-
) => Promise<HKWorkout<TEnergy, TDistance> | null>;
|
|
15
|
-
|
|
16
|
-
const getMostRecentWorkout: GetMostRecentWorkoutFn = async (options) => {
|
|
17
|
-
const workouts = await queryWorkouts({
|
|
4
|
+
const getMostRecentWorkout = async (
|
|
5
|
+
options: Pick<WorkoutQueryOptions, 'distanceUnit' | 'energyUnit'>,
|
|
6
|
+
) => {
|
|
7
|
+
const workouts = await Workouts.queryWorkoutSamples({
|
|
18
8
|
limit: 1,
|
|
19
9
|
ascending: false,
|
|
20
10
|
energyUnit: options?.energyUnit,
|
|
21
11
|
distanceUnit: options?.distanceUnit,
|
|
22
12
|
})
|
|
23
13
|
|
|
24
|
-
return workouts[0]
|
|
14
|
+
return workouts[0]
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
export default getMostRecentWorkout
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Core } from '../modules'
|
|
2
|
+
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const getPreferredUnit = async (
|
|
5
|
+
quantityType: QuantityTypeIdentifier,
|
|
6
|
+
): Promise<string> => {
|
|
7
|
+
const units = await Core.getPreferredUnits([quantityType])
|
|
8
|
+
const unit = units[0]?.unit
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
if (!unit) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
`No preferred unit found for quantity type: ${quantityType}`,
|
|
13
|
+
)
|
|
14
|
+
}
|
|
8
15
|
|
|
9
|
-
const getPreferredUnit: GetPreferredUnitFn = async (type) => {
|
|
10
|
-
const [unit] = await getPreferredUnits([type])
|
|
11
16
|
return unit
|
|
12
17
|
}
|
|
13
|
-
|
|
14
18
|
export default getPreferredUnit
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Core } from '../modules'
|
|
2
|
+
import type { SampleTypeIdentifier } from '../types/Shared'
|
|
3
|
+
import type { OnChangeCallbackArgs } from '../types/Subscriptons'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
identifier: HKSampleTypeIdentifier,
|
|
7
|
-
callback: () => void,
|
|
5
|
+
export const subscribeToChanges = (
|
|
6
|
+
identifier: SampleTypeIdentifier,
|
|
7
|
+
callback: (args: OnChangeCallbackArgs) => void,
|
|
8
8
|
) => {
|
|
9
|
-
const
|
|
10
|
-
'onChange',
|
|
11
|
-
({ typeIdentifier }: { readonly typeIdentifier: HKSampleTypeIdentifier }) => {
|
|
12
|
-
if (typeIdentifier === identifier) {
|
|
13
|
-
callback()
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const queryId = await Native.subscribeToObserverQuery(identifier).catch(
|
|
19
|
-
async (error) => {
|
|
20
|
-
subscription.remove()
|
|
21
|
-
return Promise.reject(error)
|
|
22
|
-
},
|
|
23
|
-
)
|
|
9
|
+
const queryId = Core.subscribeToObserverQuery(identifier, callback)
|
|
24
10
|
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
return Native.unsubscribeQuery(queryId)
|
|
11
|
+
return {
|
|
12
|
+
remove: () => Core.unsubscribeQuery(queryId),
|
|
28
13
|
}
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
export default subscribeToChanges
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Robert Herber
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
# @kingstinct/react-native-healthkit
|
|
2
|
-
|
|
3
|
-
[](https://github.com/Kingstinct/react-native-healthkit/actions/workflows/test.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/@kingstinct/react-native-healthkit)
|
|
5
|
-
[](https://www.npmjs.com/package/@kingstinct/react-native-healthkit)
|
|
6
|
-
[](https://discord.gg/hrgnETpsJA)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
React Native bindings for HealthKit with full TypeScript and Promise support covering about any kind of data. Keeping TypeScript mappings as close as possible to HealthKit - both in regards to naming and serialization. This will make it easier to keep this library up-to-date with HealthKit as well as browsing [the official documentation](https://developer.apple.com/documentation/healthkit) (and if something - metadata properties for example - is not typed it will still be accessible).
|
|
10
|
-
|
|
11
|
-
| Data Types | Query | Save | Subscribe | Examples |
|
|
12
|
-
| ----------------------------|:------|:------|:----------|:---------------------------------------|
|
|
13
|
-
| 100+ Quantity Types | ✅ | ✅ | ✅ | Steps, energy burnt, blood glucose etc.. |
|
|
14
|
-
| 63 Category Types | ✅ | ✅ | ✅ | Sleep analysis, mindful sessions etc.. |
|
|
15
|
-
| 75+ Workout Activity Types | ✅ | ✅ | ✅ | Swimming, running, table tennis etc.. |
|
|
16
|
-
| Correlation Types | ✅ | ✅ | ✅ | Food and blood pressure |
|
|
17
|
-
| Document Types | ✅ | ❌ | ✅ | [CDA documents](https://developer.apple.com/documentation/healthkit/hkcdadocument) exposed as Base64 data |
|
|
18
|
-
| Clinical Records | ⚠️ | ❌ | ⚠️ | Lab results etc in [FHIR JSON format](https://www.hl7.org/fhir/json.html) (see [Clinical Records](https://github.com/kingstinct/react-native-healthkit#clinical-records)) |
|
|
19
|
-
|
|
20
|
-
### Disclaimer
|
|
21
|
-
|
|
22
|
-
This library is provided as-is without any warranty and is not affiliated with Apple in any way. The data might be incomplete or inaccurate.
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
### Expo
|
|
27
|
-
Usage with Expo is possible - just keep in mind it will not work in Expo Go and [you'll need to roll your own Dev Client](https://docs.expo.dev/development/getting-started/).
|
|
28
|
-
|
|
29
|
-
1. `yarn add @kingstinct/react-native-healthkit`
|
|
30
|
-
2. Update your app.json with the config plugin:
|
|
31
|
-
```json
|
|
32
|
-
{
|
|
33
|
-
"expo": {
|
|
34
|
-
"plugins": ["@kingstinct/react-native-healthkit"]
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
this will give you defaults that make the app build without any further configuration. If you want, you can override the defaults:
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"expo": {
|
|
42
|
-
"plugins": [
|
|
43
|
-
["@kingstinct/react-native-healthkit", {
|
|
44
|
-
"NSHealthShareUsageDescription": "Your own custom usage description",
|
|
45
|
-
"NSHealthUpdateUsageDescription": false, // if you have no plans to update data, you could skip adding it to your info.plist
|
|
46
|
-
"background": false // if you have no plans to use it in background mode, you could skip adding it to the entitlements
|
|
47
|
-
}]
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
3. Build a new Dev Client
|
|
53
|
-
|
|
54
|
-
### Native or Expo Bare Workflow
|
|
55
|
-
1. `yarn add @kingstinct/react-native-healthkit`
|
|
56
|
-
2. `npx pod-install`
|
|
57
|
-
3. Set `NSHealthUpdateUsageDescription` and `NSHealthShareUsageDescription` in your `Info.plist`
|
|
58
|
-
4. Enable the HealthKit capability for the project in Xcode.
|
|
59
|
-
5. Since this package is using Swift you might also need to add a bridging header in your project if you haven't already, you can [find more about that in the official React Native docs](https://reactnative.dev/docs/native-modules-ios#exporting-swift)
|
|
60
|
-
|
|
61
|
-
## Usage
|
|
62
|
-
|
|
63
|
-
During runtime check and request permissions with `requestAuthorization`. Failing to request authorization, or requesting a permission you haven't requested yet, will result in the app crashing. This is easy to miss - for example by requesting authorization in the same component where you have a hook trying to fetch data right away.. :)
|
|
64
|
-
|
|
65
|
-
Some hook examples:
|
|
66
|
-
```TypeScript
|
|
67
|
-
import { HKQuantityTypeIdentifier, useHealthkitAuthorization } from '@kingstinct/react-native-healthkit';
|
|
68
|
-
|
|
69
|
-
const [authorizationStatus, requestAuthorization] = useHealthkitAuthorization([HKQuantityTypeIdentifier.bloodGlucose])
|
|
70
|
-
|
|
71
|
-
// make sure that you've requested authorization before requesting data, otherwise your app will crash
|
|
72
|
-
import { useMostRecentQuantitySample, HKQuantityTypeIdentifier, useMostRecentCategorySample } from '@kingstinct/react-native-healthkit';
|
|
73
|
-
|
|
74
|
-
const mostRecentBloodGlucoseSample = useMostRecentQuantitySample(HKQuantityTypeIdentifier.bloodGlucose)
|
|
75
|
-
const lastBodyFatSample = useMostRecentQuantitySample(HKQuantityTypeIdentifier.bodyFatPercentage)
|
|
76
|
-
const lastMindfulSession = useMostRecentCategorySample(HKCategoryTypeIdentifier.mindfulSession)
|
|
77
|
-
const lastWorkout = useMostRecentWorkout()
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Some imperative examples:
|
|
81
|
-
```TypeScript
|
|
82
|
-
import HealthKit, { HKUnit, HKQuantityTypeIdentifier, HKInsulinDeliveryReason, HKCategoryTypeIdentifier } from '@kingstinct/react-native-healthkit';
|
|
83
|
-
|
|
84
|
-
const isAvailable = await HealthKit.isHealthDataAvailable();
|
|
85
|
-
|
|
86
|
-
/* Read latest sample of any data */
|
|
87
|
-
await HealthKit.requestAuthorization([HKQuantityTypeIdentifier.bodyFatPercentage]); // request read permission for bodyFatPercentage
|
|
88
|
-
|
|
89
|
-
const { quantity, unit, startDate, endDate } = await HealthKit.getMostRecentQuantitySample(HKQuantityTypeIdentifier.bodyFatPercentage); // read latest sample
|
|
90
|
-
|
|
91
|
-
console.log(quantity) // 17.5
|
|
92
|
-
console.log(unit) // %
|
|
93
|
-
|
|
94
|
-
await HealthKit.requestAuthorization([HKQuantityTypeIdentifier.heartRate]); // request read permission for heart rate
|
|
95
|
-
|
|
96
|
-
/* Subscribe to data (Make sure to request permissions before subscribing to changes) */
|
|
97
|
-
const [hasRequestedAuthorization, setHasRequestedAuthorization] = useState(false);
|
|
98
|
-
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
HealthKit.requestAuthorization([HKQuantityTypeIdentifier.heartRate]).then(() => {
|
|
101
|
-
setHasRequestedAuthorization(true);
|
|
102
|
-
});
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (hasRequestedAuthorization) {
|
|
107
|
-
const unsubscribe = HealthKit.subscribeToChanges(HKQuantityTypeIdentifier.heartRate, () => {
|
|
108
|
-
// refetch data as needed
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return () => unsubscribe();
|
|
113
|
-
}, [hasRequestedAuthorization]);
|
|
114
|
-
|
|
115
|
-
/* write data */
|
|
116
|
-
await HealthKit.requestAuthorization([], [HKQuantityTypeIdentifier.insulinDelivery]); // request write permission for insulin delivery
|
|
117
|
-
|
|
118
|
-
ReactNativeHealthkit.saveQuantitySample(
|
|
119
|
-
HKQuantityTypeIdentifier.insulinDelivery,
|
|
120
|
-
HKUnit.InternationalUnit,
|
|
121
|
-
5.5,
|
|
122
|
-
{
|
|
123
|
-
metadata: {
|
|
124
|
-
// Metadata keys could be arbirtary string to store app-specific data.
|
|
125
|
-
// To use built-in types from https://developer.apple.com/documentation/healthkit/samples/metadata_keys
|
|
126
|
-
// you need to specify string values instead of variable names (by dropping MetadataKey from the name).
|
|
127
|
-
HKInsulinDeliveryReason: HKInsulinDeliveryReason.basal,
|
|
128
|
-
},
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### HealthKit Anchors (breaking change in 6.0)
|
|
134
|
-
In 6.0 you can use HealthKit anchors to get changes and deleted items which is very useful for syncing. This is a breaking change - but a very easy one to handle that TypeScript should help you with. Most queries now return an object containing samples which is what was returned as only an array before.
|
|
135
|
-
|
|
136
|
-
```newAnchor``` is a base64-encoded string returned from HealthKit that contain sync information. After each successful sync, store the anchor for the next time your anchor query is called to only return the values that have changed.
|
|
137
|
-
|
|
138
|
-
```limit``` will indicate how many records to consider when sycning data, you can set this value to 0 indicate no limit.
|
|
139
|
-
|
|
140
|
-
Example:
|
|
141
|
-
|
|
142
|
-
```TypeScript
|
|
143
|
-
const { newAnchor, samples, deletedSamples } = await queryQuantitySamplesWithAnchor(HKQuantityTypeIdentifier.stepCount, {
|
|
144
|
-
limit: 2,
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
const nextResult = await queryQuantitySamplesWithAnchor(HKQuantityTypeIdentifier.stepCount, {
|
|
148
|
-
limit: 2,
|
|
149
|
-
anchor: newAnchor,
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
// etc..
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
## A note on Apple Documentation
|
|
156
|
-
|
|
157
|
-
We're striving to do as straight a mapping as possible to the Native Libraries. This means that in most cases the Apple Documentation makes sense. However, when it comes to the Healthkit [Metadata Keys](https://developer.apple.com/documentation/healthkit/samples/metadata_keys) the documentation doesn't actually reflect the serialized values. For example HKMetadataKeyExternalUUID in the documentation serializes to HKExternalUUID - which is what we use.
|
|
158
|
-
|
|
159
|
-
## Clinical Records
|
|
160
|
-
|
|
161
|
-
For accessing Clinical Records use old version (3.x) or use specific branch "including-clinical-records". The reason is we cannot refer to this code natively in apps without getting approval from Apple, this could probably be solved by the config plugin but we haven't had time to look into it yet.
|
|
162
|
-
|
|
163
|
-
## Android alternatives
|
|
164
|
-
|
|
165
|
-
For a similar library for Android, check out [react-native-health-connect](https://github.com/matinzd/react-native-health-connect/) that works with the new Health Connect. For Google Fit [react-native-google-fit](https://www.npmjs.com/package/react-native-google-fit) seems to be the most popular option, and and another possible option is to work directly with the Google Fit REST API which I've some experience with.
|
|
166
|
-
|
|
167
|
-
## Contributing
|
|
168
|
-
|
|
169
|
-
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
170
|
-
|
|
171
|
-
## Sponsorship and enterprise-grade support
|
|
172
|
-
|
|
173
|
-
If you're using @kingstinct/react-native-healthkit to build your production app [please consider funding its continued development](https://github.com/sponsors/Kingstinct). It helps us spend more time on keeping this library as good as it can be.
|
|
174
|
-
|
|
175
|
-
At Kingstinct we're also able to provide enterprise-grade support for this package, [find us here](https://kingstinct.com) or [drop an email](mailto:healthkit@kingstinct.com) for more information. Also feel free to join our [Discord community](https://discord.gg/EHScS93v).
|
|
176
|
-
|
|
177
|
-
## License
|
|
178
|
-
|
|
179
|
-
MIT
|