@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import { Platform } from 'react-native'
|
|
2
|
+
|
|
3
|
+
// Import types for default values and function signatures.
|
|
4
|
+
// These types are expected to be available via the './types' export.
|
|
5
|
+
// You might need to adjust the import path or ensure these types are correctly exported from './types'
|
|
6
|
+
|
|
7
|
+
// This import is crucial for deriving the type of the default export `HealthkitModule`
|
|
8
|
+
// It assumes that index.ios.ts exports a default object matching the Healthkit native module structure.
|
|
9
|
+
import type * as ReactNativeHealthkit from './index.ios'
|
|
10
|
+
import type { SourceProxy } from './specs/SourceProxy.nitro'
|
|
11
|
+
import type { WorkoutProxy } from './specs/WorkoutProxy.nitro'
|
|
12
|
+
import { AuthorizationRequestStatus, AuthorizationStatus } from './types/Auth'
|
|
13
|
+
import type {
|
|
14
|
+
CategorySampleTyped,
|
|
15
|
+
CategorySamplesWithAnchorResponseTyped,
|
|
16
|
+
} from './types/CategoryType'
|
|
17
|
+
import type { CategoryTypeIdentifier } from './types/CategoryTypeIdentifier'
|
|
18
|
+
import {
|
|
19
|
+
BiologicalSex,
|
|
20
|
+
BloodType,
|
|
21
|
+
FitzpatrickSkinType,
|
|
22
|
+
WheelchairUse,
|
|
23
|
+
} from './types/Characteristics'
|
|
24
|
+
import type { CorrelationSample } from './types/CorrelationType'
|
|
25
|
+
import type {
|
|
26
|
+
HeartbeatSeriesSample,
|
|
27
|
+
HeartbeatSeriesSamplesWithAnchorResponse,
|
|
28
|
+
} from './types/HeartbeatSeries'
|
|
29
|
+
import type { QuantitySample } from './types/QuantitySample'
|
|
30
|
+
import type {
|
|
31
|
+
QuantitySamplesWithAnchorResponse,
|
|
32
|
+
QueryStatisticsResponse,
|
|
33
|
+
} from './types/QuantityType'
|
|
34
|
+
import type { StateOfMindSample } from './types/StateOfMind'
|
|
35
|
+
import type { IdentifierWithUnit } from './types/Units'
|
|
36
|
+
import type { QueryWorkoutSamplesWithAnchorResponse } from './types/Workouts'
|
|
37
|
+
|
|
38
|
+
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${Platform.OS}" not supported. HealthKit is only available on iOS.`
|
|
39
|
+
|
|
40
|
+
let hasWarned = false
|
|
41
|
+
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
44
|
+
function UnavailableFnNew<T extends Function>(defaultValue: ReturnType<T>): T {
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
return () => {
|
|
47
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
48
|
+
console.warn(notAvailableError)
|
|
49
|
+
hasWarned = true
|
|
50
|
+
}
|
|
51
|
+
return defaultValue
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
function UnavailableFnFromModule<
|
|
57
|
+
TKey extends keyof typeof ReactNativeHealthkit,
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
// biome-ignore lint/complexity/noBannedTypes: <explanation>
|
|
60
|
+
T extends Function = (typeof ReactNativeHealthkit)[TKey],
|
|
61
|
+
// @ts-ignore
|
|
62
|
+
>(fn: TKey, defaultValue: ReturnType<T>): T {
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return () => {
|
|
65
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
66
|
+
console.warn(notAvailableError)
|
|
67
|
+
hasWarned = true
|
|
68
|
+
}
|
|
69
|
+
return defaultValue
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// --- Mock Implementations for exported functions ---
|
|
74
|
+
|
|
75
|
+
// CoreModule functions
|
|
76
|
+
export const authorizationStatusFor = UnavailableFnFromModule(
|
|
77
|
+
'authorizationStatusFor',
|
|
78
|
+
AuthorizationStatus.notDetermined,
|
|
79
|
+
)
|
|
80
|
+
export const disableAllBackgroundDelivery = UnavailableFnFromModule(
|
|
81
|
+
'disableAllBackgroundDelivery',
|
|
82
|
+
Promise.resolve(false),
|
|
83
|
+
)
|
|
84
|
+
export const disableBackgroundDelivery = UnavailableFnFromModule(
|
|
85
|
+
'disableBackgroundDelivery',
|
|
86
|
+
Promise.resolve(false),
|
|
87
|
+
)
|
|
88
|
+
export const enableBackgroundDelivery = UnavailableFnFromModule(
|
|
89
|
+
'enableBackgroundDelivery',
|
|
90
|
+
Promise.resolve(false),
|
|
91
|
+
)
|
|
92
|
+
export const getPreferredUnits = UnavailableFnFromModule(
|
|
93
|
+
'getPreferredUnits',
|
|
94
|
+
Promise.resolve([]),
|
|
95
|
+
)
|
|
96
|
+
export const getRequestStatusForAuthorization = UnavailableFnFromModule(
|
|
97
|
+
'getRequestStatusForAuthorization',
|
|
98
|
+
Promise.resolve(AuthorizationRequestStatus.unknown),
|
|
99
|
+
)
|
|
100
|
+
export const isHealthDataAvailable = UnavailableFnFromModule(
|
|
101
|
+
'isHealthDataAvailable',
|
|
102
|
+
false,
|
|
103
|
+
) // Original was synchronous
|
|
104
|
+
export const isHealthDataAvailableAsync = UnavailableFnFromModule(
|
|
105
|
+
'isHealthDataAvailableAsync',
|
|
106
|
+
Promise.resolve(false),
|
|
107
|
+
) // Added for consistency if needed
|
|
108
|
+
export const querySources = UnavailableFnFromModule(
|
|
109
|
+
'querySources',
|
|
110
|
+
Promise.resolve([]),
|
|
111
|
+
)
|
|
112
|
+
export const requestAuthorization = UnavailableFnFromModule(
|
|
113
|
+
'requestAuthorization',
|
|
114
|
+
Promise.resolve(false),
|
|
115
|
+
)
|
|
116
|
+
export const deleteObjects = UnavailableFnFromModule(
|
|
117
|
+
'deleteObjects',
|
|
118
|
+
Promise.resolve(0),
|
|
119
|
+
)
|
|
120
|
+
export const subscribeToChanges = UnavailableFnFromModule(
|
|
121
|
+
'subscribeToChanges',
|
|
122
|
+
'dummy-query-uuid',
|
|
123
|
+
) // Mocking the observer query UUID
|
|
124
|
+
export const isProtectedDataAvailable = UnavailableFnFromModule(
|
|
125
|
+
'isProtectedDataAvailable',
|
|
126
|
+
false,
|
|
127
|
+
)
|
|
128
|
+
export const isObjectTypeAvailable = UnavailableFnFromModule(
|
|
129
|
+
'isObjectTypeAvailable',
|
|
130
|
+
false,
|
|
131
|
+
)
|
|
132
|
+
export const isObjectTypeAvailableAsync = UnavailableFnFromModule(
|
|
133
|
+
'isObjectTypeAvailableAsync',
|
|
134
|
+
Promise.resolve(false),
|
|
135
|
+
)
|
|
136
|
+
export const areObjectTypesAvailable = UnavailableFnFromModule(
|
|
137
|
+
'areObjectTypesAvailable',
|
|
138
|
+
{},
|
|
139
|
+
)
|
|
140
|
+
export const areObjectTypesAvailableAsync = UnavailableFnFromModule(
|
|
141
|
+
'areObjectTypesAvailableAsync',
|
|
142
|
+
Promise.resolve({}),
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
// CharacteristicTypeModule functions
|
|
146
|
+
export const getBiologicalSex = UnavailableFnFromModule(
|
|
147
|
+
'getBiologicalSex',
|
|
148
|
+
BiologicalSex.notSet,
|
|
149
|
+
)
|
|
150
|
+
export const getBloodType = UnavailableFnFromModule(
|
|
151
|
+
'getBloodType',
|
|
152
|
+
BloodType.notSet,
|
|
153
|
+
)
|
|
154
|
+
export const getDateOfBirth = UnavailableFnFromModule(
|
|
155
|
+
'getDateOfBirth',
|
|
156
|
+
new Date(0),
|
|
157
|
+
) // Assuming string for date
|
|
158
|
+
export const getFitzpatrickSkinType = UnavailableFnFromModule(
|
|
159
|
+
'getFitzpatrickSkinType',
|
|
160
|
+
FitzpatrickSkinType.notSet,
|
|
161
|
+
)
|
|
162
|
+
export const getWheelchairUse = UnavailableFnFromModule(
|
|
163
|
+
'getWheelchairUse',
|
|
164
|
+
WheelchairUse.notSet,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
// QuantityTypeModule functions
|
|
168
|
+
export const queryQuantitySamples = UnavailableFnFromModule(
|
|
169
|
+
'queryQuantitySamples',
|
|
170
|
+
Promise.resolve([]),
|
|
171
|
+
)
|
|
172
|
+
export const queryQuantitySamplesWithAnchor = UnavailableFnFromModule(
|
|
173
|
+
'queryQuantitySamplesWithAnchor',
|
|
174
|
+
Promise.resolve({
|
|
175
|
+
samples: [],
|
|
176
|
+
deletedSamples: [],
|
|
177
|
+
newAnchor: '',
|
|
178
|
+
}),
|
|
179
|
+
)
|
|
180
|
+
export const queryStatisticsForQuantity = UnavailableFnFromModule(
|
|
181
|
+
'queryStatisticsForQuantity',
|
|
182
|
+
Promise.resolve({}),
|
|
183
|
+
)
|
|
184
|
+
export const queryStatisticsCollectionForQuantity = UnavailableFnFromModule(
|
|
185
|
+
'queryStatisticsCollectionForQuantity',
|
|
186
|
+
Promise.resolve([]),
|
|
187
|
+
)
|
|
188
|
+
export const saveQuantitySample = UnavailableFnFromModule(
|
|
189
|
+
'saveQuantitySample',
|
|
190
|
+
Promise.resolve(false),
|
|
191
|
+
)
|
|
192
|
+
export const isQuantityCompatibleWithUnit = UnavailableFnFromModule(
|
|
193
|
+
'isQuantityCompatibleWithUnit',
|
|
194
|
+
false,
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
// CategoryTypeModule functions
|
|
198
|
+
export function queryCategorySamples<T extends CategoryTypeIdentifier>(
|
|
199
|
+
categoryTypeIdentifier: T,
|
|
200
|
+
): Promise<CategorySampleTyped<T>[]> {
|
|
201
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
202
|
+
console.warn(notAvailableError)
|
|
203
|
+
hasWarned = true
|
|
204
|
+
}
|
|
205
|
+
return Promise.resolve([])
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function queryCategorySamplesWithAnchor<
|
|
209
|
+
T extends CategoryTypeIdentifier,
|
|
210
|
+
>(
|
|
211
|
+
categoryTypeIdentifier: T,
|
|
212
|
+
): Promise<CategorySamplesWithAnchorResponseTyped<T>> {
|
|
213
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
214
|
+
console.warn(notAvailableError)
|
|
215
|
+
hasWarned = true
|
|
216
|
+
}
|
|
217
|
+
return Promise.resolve({
|
|
218
|
+
samples: [],
|
|
219
|
+
deletedSamples: [],
|
|
220
|
+
newAnchor: '',
|
|
221
|
+
})
|
|
222
|
+
}
|
|
223
|
+
export const saveCategorySample = UnavailableFnFromModule(
|
|
224
|
+
'saveCategorySample',
|
|
225
|
+
Promise.resolve(false),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
// CorrelationTypeModule functions
|
|
229
|
+
export const queryCorrelationSamples = UnavailableFnFromModule(
|
|
230
|
+
'queryCorrelationSamples',
|
|
231
|
+
Promise.resolve([]),
|
|
232
|
+
)
|
|
233
|
+
export const saveCorrelationSample = UnavailableFnFromModule(
|
|
234
|
+
'saveCorrelationSample',
|
|
235
|
+
Promise.resolve(false),
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
// HeartbeatSeriesModule functions
|
|
239
|
+
export const queryHeartbeatSeriesSamples = UnavailableFnFromModule(
|
|
240
|
+
'queryHeartbeatSeriesSamples',
|
|
241
|
+
Promise.resolve([]),
|
|
242
|
+
)
|
|
243
|
+
export const queryHeartbeatSeriesSamplesWithAnchor = UnavailableFnFromModule(
|
|
244
|
+
'queryHeartbeatSeriesSamplesWithAnchor',
|
|
245
|
+
Promise.resolve({
|
|
246
|
+
samples: [],
|
|
247
|
+
deletedSamples: [],
|
|
248
|
+
newAnchor: '',
|
|
249
|
+
}),
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
// WorkoutsModule functions
|
|
253
|
+
export const queryWorkoutSamples = UnavailableFnFromModule(
|
|
254
|
+
'queryWorkoutSamples',
|
|
255
|
+
Promise.resolve([]),
|
|
256
|
+
)
|
|
257
|
+
export const queryWorkoutSamplesWithAnchor = UnavailableFnFromModule(
|
|
258
|
+
'queryWorkoutSamplesWithAnchor',
|
|
259
|
+
Promise.resolve({
|
|
260
|
+
workouts: [],
|
|
261
|
+
deletedSamples: [],
|
|
262
|
+
newAnchor: '',
|
|
263
|
+
}),
|
|
264
|
+
)
|
|
265
|
+
export const saveWorkoutSample = UnavailableFnFromModule(
|
|
266
|
+
'saveWorkoutSample',
|
|
267
|
+
Promise.resolve(''),
|
|
268
|
+
)
|
|
269
|
+
export const startWatchApp = UnavailableFnFromModule(
|
|
270
|
+
'startWatchApp',
|
|
271
|
+
Promise.resolve(false),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
// StateOfMindModule functions
|
|
275
|
+
export const queryStateOfMindSamples = UnavailableFnFromModule(
|
|
276
|
+
'queryStateOfMindSamples',
|
|
277
|
+
Promise.resolve([]),
|
|
278
|
+
)
|
|
279
|
+
export const saveStateOfMindSample = UnavailableFnFromModule(
|
|
280
|
+
'saveStateOfMindSample',
|
|
281
|
+
Promise.resolve(false),
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
// Utility functions (from original export list)
|
|
285
|
+
export function getMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
286
|
+
identifier: T,
|
|
287
|
+
): Promise<CategorySampleTyped<T> | undefined> {
|
|
288
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
289
|
+
console.warn(notAvailableError)
|
|
290
|
+
hasWarned = true
|
|
291
|
+
}
|
|
292
|
+
return Promise.resolve(undefined)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export const getMostRecentQuantitySample = UnavailableFnFromModule(
|
|
296
|
+
'getMostRecentQuantitySample',
|
|
297
|
+
Promise.resolve(undefined),
|
|
298
|
+
)
|
|
299
|
+
export const getMostRecentWorkout = UnavailableFnFromModule(
|
|
300
|
+
'getMostRecentWorkout',
|
|
301
|
+
Promise.resolve(undefined),
|
|
302
|
+
)
|
|
303
|
+
export const getPreferredUnit = UnavailableFnFromModule(
|
|
304
|
+
'getPreferredUnit',
|
|
305
|
+
Promise.resolve('count'),
|
|
306
|
+
) // Defaulting to 'count'
|
|
307
|
+
|
|
308
|
+
// Hooks (from original export list)
|
|
309
|
+
export function useMostRecentCategorySample<T extends CategoryTypeIdentifier>(
|
|
310
|
+
categoryTypeIdentifier: T,
|
|
311
|
+
): CategorySampleTyped<T> | undefined {
|
|
312
|
+
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
313
|
+
console.warn(notAvailableError)
|
|
314
|
+
hasWarned = true
|
|
315
|
+
}
|
|
316
|
+
return undefined
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export const useMostRecentQuantitySample = UnavailableFnFromModule(
|
|
320
|
+
'useMostRecentQuantitySample',
|
|
321
|
+
undefined,
|
|
322
|
+
)
|
|
323
|
+
export const useMostRecentWorkout = UnavailableFnFromModule(
|
|
324
|
+
'useMostRecentWorkout',
|
|
325
|
+
undefined,
|
|
326
|
+
)
|
|
327
|
+
export const useSubscribeToChanges = UnavailableFnFromModule(
|
|
328
|
+
'useSubscribeToChanges',
|
|
329
|
+
undefined,
|
|
330
|
+
) // Mocking callback structure
|
|
331
|
+
export const useHealthkitAuthorization = UnavailableFnFromModule(
|
|
332
|
+
'useHealthkitAuthorization',
|
|
333
|
+
[
|
|
334
|
+
AuthorizationRequestStatus.unknown,
|
|
335
|
+
() => Promise.resolve(AuthorizationRequestStatus.unknown),
|
|
336
|
+
] as const,
|
|
337
|
+
)
|
|
338
|
+
export const useIsHealthDataAvailable = UnavailableFnFromModule(
|
|
339
|
+
'useIsHealthDataAvailable',
|
|
340
|
+
false,
|
|
341
|
+
)
|
|
342
|
+
export const useSources = UnavailableFnFromModule('useSources', null)
|
|
343
|
+
export const useStatisticsForQuantity = UnavailableFnFromModule(
|
|
344
|
+
'useStatisticsForQuantity',
|
|
345
|
+
null,
|
|
346
|
+
)
|
|
347
|
+
|
|
348
|
+
export const getBiologicalSexAsync = UnavailableFnFromModule(
|
|
349
|
+
'getBiologicalSexAsync',
|
|
350
|
+
Promise.resolve(BiologicalSex.notSet),
|
|
351
|
+
)
|
|
352
|
+
export const getBloodTypeAsync = UnavailableFnFromModule(
|
|
353
|
+
'getBloodTypeAsync',
|
|
354
|
+
Promise.resolve(BloodType.notSet),
|
|
355
|
+
)
|
|
356
|
+
export const getDateOfBirthAsync = UnavailableFnFromModule(
|
|
357
|
+
'getDateOfBirthAsync',
|
|
358
|
+
Promise.resolve(new Date(0)),
|
|
359
|
+
) // Assuming string for date
|
|
360
|
+
export const getFitzpatrickSkinTypeAsync = UnavailableFnFromModule(
|
|
361
|
+
'getFitzpatrickSkinTypeAsync',
|
|
362
|
+
Promise.resolve(FitzpatrickSkinType.notSet),
|
|
363
|
+
)
|
|
364
|
+
export const getWheelchairUseAsync = UnavailableFnFromModule(
|
|
365
|
+
'getWheelchairUseAsync',
|
|
366
|
+
Promise.resolve(WheelchairUse.notSet),
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
export const unsubscribeQueries = UnavailableFnFromModule(
|
|
370
|
+
'unsubscribeQueries',
|
|
371
|
+
0,
|
|
372
|
+
)
|
|
373
|
+
|
|
374
|
+
// --- Default Export ---
|
|
375
|
+
// This attempts to match the structure of the default export from index.ios.ts
|
|
376
|
+
const HealthkitModule = {
|
|
377
|
+
// All named exports are also part of the default export object
|
|
378
|
+
authorizationStatusFor,
|
|
379
|
+
isObjectTypeAvailable,
|
|
380
|
+
unsubscribeQueries,
|
|
381
|
+
isObjectTypeAvailableAsync,
|
|
382
|
+
areObjectTypesAvailable,
|
|
383
|
+
areObjectTypesAvailableAsync,
|
|
384
|
+
isQuantityCompatibleWithUnit,
|
|
385
|
+
disableAllBackgroundDelivery,
|
|
386
|
+
disableBackgroundDelivery,
|
|
387
|
+
enableBackgroundDelivery,
|
|
388
|
+
getBiologicalSex,
|
|
389
|
+
getBloodType,
|
|
390
|
+
getDateOfBirth,
|
|
391
|
+
getFitzpatrickSkinType,
|
|
392
|
+
getMostRecentCategorySample,
|
|
393
|
+
getMostRecentQuantitySample,
|
|
394
|
+
getMostRecentWorkout,
|
|
395
|
+
getPreferredUnits,
|
|
396
|
+
getPreferredUnit,
|
|
397
|
+
getRequestStatusForAuthorization,
|
|
398
|
+
getWheelchairUse,
|
|
399
|
+
isHealthDataAvailable,
|
|
400
|
+
isHealthDataAvailableAsync,
|
|
401
|
+
queryCategorySamples,
|
|
402
|
+
queryCategorySamplesWithAnchor,
|
|
403
|
+
queryCorrelationSamples,
|
|
404
|
+
queryHeartbeatSeriesSamples,
|
|
405
|
+
queryHeartbeatSeriesSamplesWithAnchor,
|
|
406
|
+
queryQuantitySamples,
|
|
407
|
+
queryQuantitySamplesWithAnchor,
|
|
408
|
+
queryStatisticsForQuantity,
|
|
409
|
+
queryStatisticsCollectionForQuantity,
|
|
410
|
+
queryWorkoutSamples,
|
|
411
|
+
queryWorkoutSamplesWithAnchor,
|
|
412
|
+
querySources,
|
|
413
|
+
requestAuthorization,
|
|
414
|
+
deleteObjects,
|
|
415
|
+
saveCategorySample,
|
|
416
|
+
saveCorrelationSample,
|
|
417
|
+
saveQuantitySample,
|
|
418
|
+
saveWorkoutSample,
|
|
419
|
+
subscribeToChanges,
|
|
420
|
+
startWatchApp,
|
|
421
|
+
isProtectedDataAvailable,
|
|
422
|
+
queryStateOfMindSamples,
|
|
423
|
+
saveStateOfMindSample,
|
|
424
|
+
|
|
425
|
+
// Hooks
|
|
426
|
+
useMostRecentCategorySample,
|
|
427
|
+
useMostRecentQuantitySample,
|
|
428
|
+
useMostRecentWorkout,
|
|
429
|
+
useSubscribeToChanges,
|
|
430
|
+
useHealthkitAuthorization,
|
|
431
|
+
useIsHealthDataAvailable,
|
|
432
|
+
useSources,
|
|
433
|
+
useStatisticsForQuantity,
|
|
434
|
+
getBiologicalSexAsync,
|
|
435
|
+
getBloodTypeAsync,
|
|
436
|
+
getDateOfBirthAsync,
|
|
437
|
+
getFitzpatrickSkinTypeAsync,
|
|
438
|
+
getWheelchairUseAsync,
|
|
439
|
+
} as Omit<typeof ReactNativeHealthkit, 'default'>
|
|
440
|
+
|
|
441
|
+
export default {
|
|
442
|
+
...HealthkitModule,
|
|
443
|
+
default: HealthkitModule,
|
|
444
|
+
} as typeof ReactNativeHealthkit
|
package/src/modules.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules'
|
|
2
|
+
import type {
|
|
3
|
+
CategoryTypeModule,
|
|
4
|
+
CategoryTypeModuleTyped,
|
|
5
|
+
} from './specs/CategoryTypeModule.nitro'
|
|
6
|
+
import type { CharacteristicTypeModule } from './specs/CharacteristicTypeModule.nitro'
|
|
7
|
+
import type { CoreModule } from './specs/CoreModule.nitro'
|
|
8
|
+
import type { CorrelationTypeModule } from './specs/CorrelationTypeModule.nitro'
|
|
9
|
+
import type { HeartbeatSeriesModule } from './specs/HeartbeatSeriesModule.nitro'
|
|
10
|
+
import type { QuantityTypeModule } from './specs/QuantityTypeModule.nitro'
|
|
11
|
+
import type { StateOfMindModule } from './specs/StateOfMindModule.nitro'
|
|
12
|
+
import type { WorkoutsModule } from './specs/WorkoutsModule.nitro'
|
|
13
|
+
|
|
14
|
+
export const Core = NitroModules.createHybridObject<CoreModule>('CoreModule')
|
|
15
|
+
|
|
16
|
+
export const Workouts =
|
|
17
|
+
NitroModules.createHybridObject<WorkoutsModule>('WorkoutsModule')
|
|
18
|
+
|
|
19
|
+
export const Characteristics =
|
|
20
|
+
NitroModules.createHybridObject<CharacteristicTypeModule>(
|
|
21
|
+
'CharacteristicTypeModule',
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export const QuantityTypes =
|
|
25
|
+
NitroModules.createHybridObject<QuantityTypeModule>('QuantityTypeModule')
|
|
26
|
+
|
|
27
|
+
export const CategoryTypes =
|
|
28
|
+
NitroModules.createHybridObject<CategoryTypeModule>(
|
|
29
|
+
'CategoryTypeModule',
|
|
30
|
+
) as CategoryTypeModuleTyped
|
|
31
|
+
|
|
32
|
+
export const CorrelationTypes =
|
|
33
|
+
NitroModules.createHybridObject<CorrelationTypeModule>(
|
|
34
|
+
'CorrelationTypeModule',
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export const HeartbeatSeries =
|
|
38
|
+
NitroModules.createHybridObject<HeartbeatSeriesModule>(
|
|
39
|
+
'HeartbeatSeriesModule',
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
export const StateOfMind =
|
|
43
|
+
NitroModules.createHybridObject<StateOfMindModule>('StateOfMindModule')
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AnyMap, HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CategorySample,
|
|
5
|
+
CategorySampleTyped,
|
|
6
|
+
CategorySamplesWithAnchorResponse,
|
|
7
|
+
CategorySamplesWithAnchorResponseTyped,
|
|
8
|
+
CategoryValueForIdentifier,
|
|
9
|
+
MetadataForCategoryIdentifier,
|
|
10
|
+
} from '../types/CategoryType'
|
|
11
|
+
import type { CategoryTypeIdentifier } from '../types/CategoryTypeIdentifier'
|
|
12
|
+
import type { InterfaceAssertion } from '../types/InterfaceVerification'
|
|
13
|
+
import type {
|
|
14
|
+
QueryOptionsWithAnchor,
|
|
15
|
+
QueryOptionsWithSortOrder,
|
|
16
|
+
} from '../types/QueryOptions'
|
|
17
|
+
|
|
18
|
+
export interface CategoryTypeModule extends HybridObject<{ ios: 'swift' }> {
|
|
19
|
+
saveCategorySample(
|
|
20
|
+
identifier: CategoryTypeIdentifier,
|
|
21
|
+
value: CategoryValueForIdentifier,
|
|
22
|
+
startDate: Date,
|
|
23
|
+
endDate: Date,
|
|
24
|
+
metadata: AnyMap,
|
|
25
|
+
): Promise<boolean>
|
|
26
|
+
|
|
27
|
+
queryCategorySamples(
|
|
28
|
+
identifier: CategoryTypeIdentifier,
|
|
29
|
+
options?: QueryOptionsWithSortOrder,
|
|
30
|
+
): Promise<readonly CategorySample[]>
|
|
31
|
+
|
|
32
|
+
queryCategorySamplesWithAnchor(
|
|
33
|
+
identifier: CategoryTypeIdentifier,
|
|
34
|
+
options: QueryOptionsWithAnchor,
|
|
35
|
+
): Promise<CategorySamplesWithAnchorResponse>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Interface verification to ensure CategoryTypeModule and CategoryTypeModuleTyped stay in sync
|
|
39
|
+
// This will cause a TypeScript compilation error if the interfaces have different method names or parameter counts
|
|
40
|
+
const _interfaceVerification: InterfaceAssertion<
|
|
41
|
+
CategoryTypeModule,
|
|
42
|
+
CategoryTypeModuleTyped,
|
|
43
|
+
keyof HybridObject
|
|
44
|
+
> = true
|
|
45
|
+
|
|
46
|
+
export interface CategoryTypeModuleTyped {
|
|
47
|
+
saveCategorySample<T extends CategoryTypeIdentifier>(
|
|
48
|
+
identifier: T,
|
|
49
|
+
value: CategoryValueForIdentifier,
|
|
50
|
+
startDate: Date,
|
|
51
|
+
endDate: Date,
|
|
52
|
+
metadata: MetadataForCategoryIdentifier<T>,
|
|
53
|
+
): Promise<boolean>
|
|
54
|
+
|
|
55
|
+
queryCategorySamples<T extends CategoryTypeIdentifier>(
|
|
56
|
+
identifier: T,
|
|
57
|
+
options?: QueryOptionsWithSortOrder,
|
|
58
|
+
): Promise<readonly CategorySampleTyped<T>[]>
|
|
59
|
+
|
|
60
|
+
queryCategorySamplesWithAnchor<T extends CategoryTypeIdentifier>(
|
|
61
|
+
identifier: T,
|
|
62
|
+
options: QueryOptionsWithAnchor,
|
|
63
|
+
): Promise<CategorySamplesWithAnchorResponseTyped<T>>
|
|
64
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
import type {
|
|
3
|
+
BiologicalSex,
|
|
4
|
+
BloodType,
|
|
5
|
+
FitzpatrickSkinType,
|
|
6
|
+
WheelchairUse,
|
|
7
|
+
} from '../types/Characteristics'
|
|
8
|
+
|
|
9
|
+
export interface CharacteristicTypeModule
|
|
10
|
+
extends HybridObject<{ ios: 'swift' }> {
|
|
11
|
+
getBloodType(): BloodType
|
|
12
|
+
getDateOfBirth(): Date
|
|
13
|
+
getBiologicalSex(): BiologicalSex
|
|
14
|
+
getFitzpatrickSkinType(): FitzpatrickSkinType
|
|
15
|
+
getWheelchairUse(): WheelchairUse
|
|
16
|
+
|
|
17
|
+
getBloodTypeAsync(): Promise<BloodType>
|
|
18
|
+
getDateOfBirthAsync(): Promise<Date>
|
|
19
|
+
getBiologicalSexAsync(): Promise<BiologicalSex>
|
|
20
|
+
getFitzpatrickSkinTypeAsync(): Promise<FitzpatrickSkinType>
|
|
21
|
+
getWheelchairUseAsync(): Promise<WheelchairUse>
|
|
22
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
import type {
|
|
3
|
+
AuthorizationRequestStatus,
|
|
4
|
+
AuthorizationStatus,
|
|
5
|
+
} from '../types/Auth'
|
|
6
|
+
import type { UpdateFrequency } from '../types/Background'
|
|
7
|
+
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
8
|
+
import type { FilterForSamples } from '../types/QueryOptions'
|
|
9
|
+
import type {
|
|
10
|
+
ObjectTypeIdentifier,
|
|
11
|
+
SampleTypeIdentifier,
|
|
12
|
+
SampleTypeIdentifierWriteable,
|
|
13
|
+
} from '../types/Shared'
|
|
14
|
+
import type { OnChangeCallbackArgs } from '../types/Subscriptons'
|
|
15
|
+
import type { IdentifierWithUnit } from '../types/Units'
|
|
16
|
+
import type { SourceProxy } from './SourceProxy.nitro'
|
|
17
|
+
|
|
18
|
+
export interface CoreModule extends HybridObject<{ ios: 'swift' }> {
|
|
19
|
+
/**
|
|
20
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
|
|
21
|
+
*/
|
|
22
|
+
enableBackgroundDelivery(
|
|
23
|
+
typeIdentifier: ObjectTypeIdentifier,
|
|
24
|
+
updateFrequency: UpdateFrequency,
|
|
25
|
+
): Promise<boolean>
|
|
26
|
+
/**
|
|
27
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery Apple Docs }
|
|
28
|
+
*/
|
|
29
|
+
disableBackgroundDelivery(
|
|
30
|
+
typeIdentifier: ObjectTypeIdentifier,
|
|
31
|
+
): Promise<boolean>
|
|
32
|
+
/**
|
|
33
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
|
|
34
|
+
*/
|
|
35
|
+
disableAllBackgroundDelivery(): Promise<boolean>
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
|
|
39
|
+
*/
|
|
40
|
+
isHealthDataAvailable(): boolean
|
|
41
|
+
isHealthDataAvailableAsync(): Promise<boolean>
|
|
42
|
+
|
|
43
|
+
isProtectedDataAvailable(): boolean
|
|
44
|
+
isProtectedDataAvailableAsync(): Promise<boolean>
|
|
45
|
+
|
|
46
|
+
getPreferredUnits(
|
|
47
|
+
identifiers: readonly QuantityTypeIdentifier[],
|
|
48
|
+
forceUpdate?: boolean,
|
|
49
|
+
): Promise<IdentifierWithUnit[]>
|
|
50
|
+
|
|
51
|
+
querySources(
|
|
52
|
+
identifier: SampleTypeIdentifier,
|
|
53
|
+
): Promise<readonly SourceProxy[]>
|
|
54
|
+
|
|
55
|
+
/** @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-requestauthorizationtoaccess Apple Docs }
|
|
56
|
+
* @param {SampleTypeIdentifier} typeIdentifier - The type identifier of the sample to request authorization for.
|
|
57
|
+
* @param {(args: OnChangeCallbackArgs) => void} callback - An array of type identifiers that the app wants to write.
|
|
58
|
+
* @returns A promise that resolves to a boolean indicating whether the authorization was successful.*/
|
|
59
|
+
subscribeToObserverQuery(
|
|
60
|
+
typeIdentifier: SampleTypeIdentifier,
|
|
61
|
+
callback: (args: OnChangeCallbackArgs) => void,
|
|
62
|
+
): string
|
|
63
|
+
|
|
64
|
+
unsubscribeQuery(queryId: string): boolean
|
|
65
|
+
unsubscribeQueryAsync(queryId: string): Promise<boolean>
|
|
66
|
+
|
|
67
|
+
unsubscribeQueries(queryIds: string[]): number
|
|
68
|
+
unsubscribeQueriesAsync(queryIds: string[]): Promise<number>
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
|
|
72
|
+
*/
|
|
73
|
+
authorizationStatusFor(type: ObjectTypeIdentifier): AuthorizationStatus
|
|
74
|
+
/**
|
|
75
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
76
|
+
*/
|
|
77
|
+
getRequestStatusForAuthorization(
|
|
78
|
+
toShare: SampleTypeIdentifierWriteable[],
|
|
79
|
+
toRead: ObjectTypeIdentifier[],
|
|
80
|
+
): Promise<AuthorizationRequestStatus>
|
|
81
|
+
/**
|
|
82
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
83
|
+
*/
|
|
84
|
+
requestAuthorization(
|
|
85
|
+
toShare: SampleTypeIdentifierWriteable[],
|
|
86
|
+
toRead: ObjectTypeIdentifier[],
|
|
87
|
+
): Promise<boolean>
|
|
88
|
+
|
|
89
|
+
deleteObjects(
|
|
90
|
+
objectTypeIdentifier: ObjectTypeIdentifier,
|
|
91
|
+
filter: FilterForSamples,
|
|
92
|
+
): Promise<number>
|
|
93
|
+
|
|
94
|
+
isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean
|
|
95
|
+
|
|
96
|
+
areObjectTypesAvailable(
|
|
97
|
+
objectTypeIdentifiers: ObjectTypeIdentifier[],
|
|
98
|
+
): Record<string, boolean>
|
|
99
|
+
|
|
100
|
+
areObjectTypesAvailableAsync(
|
|
101
|
+
objectTypeIdentifiers: ObjectTypeIdentifier[],
|
|
102
|
+
): Promise<Record<string, boolean>>
|
|
103
|
+
|
|
104
|
+
isObjectTypeAvailableAsync(
|
|
105
|
+
objectTypeIdentifier: ObjectTypeIdentifier,
|
|
106
|
+
): Promise<boolean>
|
|
107
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AnyMap, HybridObject } from 'react-native-nitro-modules'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CorrelationSample,
|
|
5
|
+
CorrelationTypeIdentifier,
|
|
6
|
+
SampleForSaving,
|
|
7
|
+
} from '../types/CorrelationType'
|
|
8
|
+
|
|
9
|
+
export interface CorrelationTypeModule extends HybridObject<{ ios: 'swift' }> {
|
|
10
|
+
saveCorrelationSample(
|
|
11
|
+
typeIdentifier: CorrelationTypeIdentifier,
|
|
12
|
+
samples: SampleForSaving[],
|
|
13
|
+
start: Date,
|
|
14
|
+
end: Date,
|
|
15
|
+
metadata: AnyMap,
|
|
16
|
+
): Promise<boolean>
|
|
17
|
+
|
|
18
|
+
queryCorrelationSamples(
|
|
19
|
+
typeIdentifier: CorrelationTypeIdentifier,
|
|
20
|
+
from: Date,
|
|
21
|
+
to: Date,
|
|
22
|
+
): Promise<readonly CorrelationSample[]>
|
|
23
|
+
}
|