@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/types.ts
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
CLLocationRawForSaving,
|
|
3
|
-
EnergyUnit,
|
|
4
|
-
HKCategorySampleRaw,
|
|
5
|
-
HKCategoryTypeIdentifier,
|
|
6
|
-
HKCorrelationRaw,
|
|
7
|
-
HKCorrelationTypeIdentifier,
|
|
8
|
-
HKDevice,
|
|
9
|
-
HKHeartbeatSeriesSampleRaw,
|
|
10
|
-
HKQuantityTypeIdentifier,
|
|
11
|
-
HKSourceRevision,
|
|
12
|
-
HKUnit,
|
|
13
|
-
HKWorkoutRaw,
|
|
14
|
-
LengthUnit,
|
|
15
|
-
MetadataMapperForQuantityIdentifier,
|
|
16
|
-
QueryStatisticsResponseRaw,
|
|
17
|
-
UnitForIdentifier,
|
|
18
|
-
} from './native-types'
|
|
19
|
-
|
|
20
|
-
export * from './native-types'
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Options for querying workouts.
|
|
24
|
-
* @template TEnergy The energy unit type.
|
|
25
|
-
* @template TDistance The distance unit type.
|
|
26
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkout Apple Docs HKWorkout}
|
|
27
|
-
*/
|
|
28
|
-
export interface QueryWorkoutsOptions<
|
|
29
|
-
TEnergy extends HKUnit,
|
|
30
|
-
TDistance extends HKUnit
|
|
31
|
-
> extends GenericQueryOptions {
|
|
32
|
-
readonly energyUnit?: TEnergy;
|
|
33
|
-
readonly distanceUnit?: TDistance;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Represents a category sample.
|
|
38
|
-
* @template T The category type identifier.
|
|
39
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorysample Apple Docs HKCategorySample}
|
|
40
|
-
*/
|
|
41
|
-
export interface HKCategorySample<
|
|
42
|
-
T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
43
|
-
> extends Omit<HKCategorySampleRaw<T>, 'endDate' | 'startDate'> {
|
|
44
|
-
readonly startDate: Date;
|
|
45
|
-
readonly endDate: Date;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Generic options for querying.
|
|
50
|
-
*/
|
|
51
|
-
export type GenericQueryOptions = {
|
|
52
|
-
readonly from?: Date;
|
|
53
|
-
readonly to?: Date;
|
|
54
|
-
readonly limit?: number;
|
|
55
|
-
readonly ascending?: boolean;
|
|
56
|
-
readonly anchor?: string
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Represents a workout.
|
|
61
|
-
* @template TEnergy The energy unit type.
|
|
62
|
-
* @template TDistance The distance unit type.
|
|
63
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkout Apple Docs HKWorkout}
|
|
64
|
-
*/
|
|
65
|
-
export interface HKWorkout<
|
|
66
|
-
TEnergy extends EnergyUnit = EnergyUnit,
|
|
67
|
-
TDistance extends LengthUnit = LengthUnit
|
|
68
|
-
> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {
|
|
69
|
-
readonly startDate: Date;
|
|
70
|
-
readonly endDate: Date;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Represents a heartbeat series sample.
|
|
75
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkheartbeatseriessample Apple Docs HKHeartbeatSeriesSample}
|
|
76
|
-
*/
|
|
77
|
-
export interface HKHeartbeatSeriesSample extends Omit<HKHeartbeatSeriesSampleRaw, 'endDate' | 'startDate'> {
|
|
78
|
-
readonly startDate: Date;
|
|
79
|
-
readonly endDate: Date;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Represents a quantity sample.
|
|
84
|
-
* @template TIdentifier The quantity type identifier.
|
|
85
|
-
* @template TUnit The unit for the identifier.
|
|
86
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitysample Apple Docs HKQuantitySample}
|
|
87
|
-
*/
|
|
88
|
-
export interface HKQuantitySample<
|
|
89
|
-
TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
90
|
-
TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>
|
|
91
|
-
> {
|
|
92
|
-
readonly uuid: string;
|
|
93
|
-
readonly device?: HKDevice;
|
|
94
|
-
readonly quantityType: TIdentifier;
|
|
95
|
-
readonly quantity: number;
|
|
96
|
-
readonly unit: TUnit;
|
|
97
|
-
readonly metadata?: MetadataMapperForQuantityIdentifier<TIdentifier>;
|
|
98
|
-
readonly sourceRevision?: HKSourceRevision;
|
|
99
|
-
readonly startDate: Date;
|
|
100
|
-
readonly endDate: Date;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Represents a response from a statistics query.
|
|
105
|
-
* @template TIdentifier The quantity type identifier.
|
|
106
|
-
* @template TUnit The unit for the identifier.
|
|
107
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkstatisticsquery Apple Docs HKStatisticsQuery}
|
|
108
|
-
*/
|
|
109
|
-
export interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>
|
|
110
|
-
extends Omit<
|
|
111
|
-
QueryStatisticsResponseRaw<TIdentifier, TUnit>,
|
|
112
|
-
'mostRecentQuantityDateInterval'
|
|
113
|
-
> {
|
|
114
|
-
readonly mostRecentQuantityDateInterval?: { readonly from: Date; readonly to: Date };
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Represents a category sample for saving.
|
|
119
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorysample Apple Docs HKCategorySample}
|
|
120
|
-
*/
|
|
121
|
-
export type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'> & {
|
|
122
|
-
readonly startDate?: Date;
|
|
123
|
-
readonly endDate?: Date;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Represents a quantity sample for saving.
|
|
128
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitysample Apple Docs HKQuantitySample}
|
|
129
|
-
*/
|
|
130
|
-
export type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'> & {
|
|
131
|
-
readonly startDate?: Date;
|
|
132
|
-
readonly endDate?: Date;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Represents a correlation.
|
|
137
|
-
* @template TIdentifier The correlation type identifier.
|
|
138
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkcorrelation Apple Docs HKCorrelation}
|
|
139
|
-
*/
|
|
140
|
-
export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>
|
|
141
|
-
extends Omit<
|
|
142
|
-
HKCorrelationRaw<TIdentifier>,
|
|
143
|
-
'endDate' | 'objects' | 'startDate'
|
|
144
|
-
> {
|
|
145
|
-
readonly objects: readonly (HKCategorySample | HKQuantitySample)[];
|
|
146
|
-
readonly startDate: Date;
|
|
147
|
-
readonly endDate: Date;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Represents a location sample for saving.
|
|
152
|
-
* @see {@link https://developer.apple.com/documentation/corelocation/cllocation Apple Docs CLLocation}
|
|
153
|
-
*/
|
|
154
|
-
export type CLLocationForSaving = Omit<CLLocationRawForSaving, 'timestamp'> & {
|
|
155
|
-
readonly timestamp: number;
|
|
156
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKQuantityTypeIdentifier } from '../native-types'
|
|
4
|
-
|
|
5
|
-
export type DeleteQuantitySampleFn = <
|
|
6
|
-
TIdentifier extends HKQuantityTypeIdentifier
|
|
7
|
-
>(
|
|
8
|
-
identifier: TIdentifier,
|
|
9
|
-
uuid: string
|
|
10
|
-
) => Promise<boolean>
|
|
11
|
-
|
|
12
|
-
const deleteQuantitySample: DeleteQuantitySampleFn = async (identifier, uuid) => Native.deleteQuantitySample(identifier, uuid)
|
|
13
|
-
|
|
14
|
-
export default deleteQuantitySample
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKQuantityTypeIdentifier } from '../native-types'
|
|
4
|
-
|
|
5
|
-
export type DeleteSamplesFn = <
|
|
6
|
-
TIdentifier extends HKQuantityTypeIdentifier
|
|
7
|
-
>(
|
|
8
|
-
sample: {
|
|
9
|
-
readonly identifier: TIdentifier,
|
|
10
|
-
readonly startDate?: Date;
|
|
11
|
-
readonly endDate?: Date;
|
|
12
|
-
}
|
|
13
|
-
) => Promise<boolean>
|
|
14
|
-
|
|
15
|
-
const deleteSamples: DeleteSamplesFn = async (sample) => {
|
|
16
|
-
const start = sample.startDate || new Date()
|
|
17
|
-
const end = sample.endDate || new Date()
|
|
18
|
-
const { identifier } = sample
|
|
19
|
-
|
|
20
|
-
return Native.deleteSamples(identifier, start.toISOString(), end.toISOString())
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default deleteSamples
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import deserializeCategorySample from './deserializeCategorySample'
|
|
2
|
-
|
|
3
|
-
import type { HKCategorySampleRaw } from '../types'
|
|
4
|
-
|
|
5
|
-
describe('deserializeCategorySample', () => {
|
|
6
|
-
it('should deserialize category sample', async () => {
|
|
7
|
-
const { HKCategoryTypeIdentifier } = await import('../native-types')
|
|
8
|
-
|
|
9
|
-
const sample: HKCategorySampleRaw = {
|
|
10
|
-
startDate: '2020-01-01T00:00:00.000Z',
|
|
11
|
-
endDate: '2020-01-01T00:00:00.000Z',
|
|
12
|
-
value: 1,
|
|
13
|
-
categoryType: HKCategoryTypeIdentifier.sexualActivity,
|
|
14
|
-
metadata: {},
|
|
15
|
-
uuid: 'uuid',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
expect(deserializeCategorySample(sample)).toEqual({
|
|
19
|
-
...sample,
|
|
20
|
-
startDate: new Date('2020-01-01T00:00:00.000Z'),
|
|
21
|
-
endDate: new Date('2020-01-01T00:00:00.000Z'),
|
|
22
|
-
})
|
|
23
|
-
})
|
|
24
|
-
})
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../native-types'
|
|
2
|
-
import type { HKCategorySample } from '../types'
|
|
3
|
-
|
|
4
|
-
const deserializeCategorySample = <T extends HKCategoryTypeIdentifier>(
|
|
5
|
-
sample: HKCategorySampleRaw<T>,
|
|
6
|
-
): HKCategorySample<T> => ({
|
|
7
|
-
...sample,
|
|
8
|
-
startDate: new Date(sample.startDate),
|
|
9
|
-
endDate: new Date(sample.endDate),
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
export default deserializeCategorySample
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import deserializCategorySample from './deserializeCategorySample'
|
|
2
|
-
import deserializeQuantitySample from './deserializeSample'
|
|
3
|
-
|
|
4
|
-
import type {
|
|
5
|
-
HKCategorySampleRaw, HKCorrelationRaw, HKCorrelationTypeIdentifier, HKQuantitySampleRaw, HKQuantityTypeIdentifier,
|
|
6
|
-
} from '../native-types'
|
|
7
|
-
import type { HKCorrelation } from '../types'
|
|
8
|
-
|
|
9
|
-
function deserializeCorrelation<
|
|
10
|
-
TIdentifier extends HKCorrelationTypeIdentifier
|
|
11
|
-
>(s: HKCorrelationRaw<TIdentifier>): HKCorrelation<TIdentifier> {
|
|
12
|
-
return {
|
|
13
|
-
...s,
|
|
14
|
-
objects: s.objects.map((o) => {
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
if (o.quantity !== undefined) {
|
|
18
|
-
return deserializeQuantitySample(o as HKQuantitySampleRaw<HKQuantityTypeIdentifier>)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return deserializCategorySample(o as HKCategorySampleRaw)
|
|
22
|
-
}),
|
|
23
|
-
endDate: new Date(s.endDate),
|
|
24
|
-
startDate: new Date(s.startDate),
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default deserializeCorrelation
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { HKHeartbeatSeriesSampleRaw } from '../native-types'
|
|
2
|
-
import type { HKHeartbeatSeriesSample } from '../types'
|
|
3
|
-
|
|
4
|
-
function deserializeHeartbeatSeriesSample(sample: HKHeartbeatSeriesSampleRaw): HKHeartbeatSeriesSample {
|
|
5
|
-
return {
|
|
6
|
-
...sample,
|
|
7
|
-
startDate: new Date(sample.startDate),
|
|
8
|
-
endDate: new Date(sample.endDate),
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default deserializeHeartbeatSeriesSample
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { HKQuantitySampleRaw, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
|
|
2
|
-
import type { HKQuantitySample } from '../types'
|
|
3
|
-
|
|
4
|
-
function deserializeQuantitySample<
|
|
5
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
6
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
7
|
-
>(
|
|
8
|
-
sample: HKQuantitySampleRaw<TIdentifier, TUnit>,
|
|
9
|
-
): HKQuantitySample<TIdentifier, TUnit> {
|
|
10
|
-
return {
|
|
11
|
-
...sample,
|
|
12
|
-
startDate: new Date(sample.startDate),
|
|
13
|
-
endDate: new Date(sample.endDate),
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default deserializeQuantitySample
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { EnergyUnit, HKWorkoutRaw, LengthUnit } from '../native-types'
|
|
2
|
-
import type { HKWorkout } from '../types'
|
|
3
|
-
|
|
4
|
-
function deserializeWorkout<TEnergy extends EnergyUnit, TDistance extends LengthUnit>(
|
|
5
|
-
sample: HKWorkoutRaw<TEnergy, TDistance>,
|
|
6
|
-
): HKWorkout<TEnergy, TDistance> {
|
|
7
|
-
return {
|
|
8
|
-
...sample,
|
|
9
|
-
startDate: new Date(sample.startDate),
|
|
10
|
-
endDate: new Date(sample.endDate),
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default deserializeWorkout
|
package/src/utils/ensureUnit.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
|
|
4
|
-
|
|
5
|
-
const ensureUnit = async <
|
|
6
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
7
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
8
|
-
>(
|
|
9
|
-
type: TIdentifier,
|
|
10
|
-
providedUnit?: TUnit,
|
|
11
|
-
) => {
|
|
12
|
-
if (providedUnit) {
|
|
13
|
-
return providedUnit
|
|
14
|
-
}
|
|
15
|
-
const unit = await Native.getPreferredUnits([type])
|
|
16
|
-
return unit[type] as TUnit
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default ensureUnit
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKQuantityTypeIdentifier, HKUnit } from '../native-types'
|
|
4
|
-
|
|
5
|
-
export type GetPreferredUnitsFn = (
|
|
6
|
-
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
7
|
-
) => Promise<readonly HKUnit[]>;
|
|
8
|
-
|
|
9
|
-
const getPreferredUnits: GetPreferredUnitsFn = async (identifiers) => {
|
|
10
|
-
const units = await Native.getPreferredUnits(identifiers)
|
|
11
|
-
return identifiers.map((i) => units[i])
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default getPreferredUnits
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import Native, { HKQuantityTypeIdentifier, UnitOfEnergy, UnitOfLength } from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKUnit } from '../native-types'
|
|
4
|
-
|
|
5
|
-
async function getPreferredUnitsTyped<
|
|
6
|
-
TEnergy extends HKUnit,
|
|
7
|
-
TDistance extends HKUnit
|
|
8
|
-
>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {
|
|
9
|
-
let energyUnit = options?.energyUnit
|
|
10
|
-
let distanceUnit = options?.distanceUnit
|
|
11
|
-
|
|
12
|
-
if (!energyUnit || !distanceUnit) {
|
|
13
|
-
const units = await Native.getPreferredUnits([
|
|
14
|
-
HKQuantityTypeIdentifier.distanceWalkingRunning,
|
|
15
|
-
HKQuantityTypeIdentifier.activeEnergyBurned,
|
|
16
|
-
])
|
|
17
|
-
if (!energyUnit) {
|
|
18
|
-
energyUnit = units[HKQuantityTypeIdentifier.activeEnergyBurned] as
|
|
19
|
-
| TEnergy
|
|
20
|
-
| undefined
|
|
21
|
-
}
|
|
22
|
-
if (!distanceUnit) {
|
|
23
|
-
distanceUnit = units[HKQuantityTypeIdentifier.distanceWalkingRunning] as
|
|
24
|
-
| TDistance
|
|
25
|
-
| undefined
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (!energyUnit) {
|
|
30
|
-
energyUnit = UnitOfEnergy.Kilocalories as TEnergy
|
|
31
|
-
}
|
|
32
|
-
if (!distanceUnit) {
|
|
33
|
-
distanceUnit = UnitOfLength.Meter as TDistance
|
|
34
|
-
}
|
|
35
|
-
return { energyUnit, distanceUnit }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default getPreferredUnitsTyped
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
HealthkitReadAuthorization, HealthkitWriteAuthorization, ReadPermissions, WritePermissions,
|
|
5
|
-
} from '../native-types'
|
|
6
|
-
|
|
7
|
-
const getRequestStatusForAuthorization = async (
|
|
8
|
-
read: readonly HealthkitReadAuthorization[],
|
|
9
|
-
write: readonly HealthkitWriteAuthorization[] = [],
|
|
10
|
-
) => {
|
|
11
|
-
const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)
|
|
12
|
-
|
|
13
|
-
const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)
|
|
14
|
-
|
|
15
|
-
return Native.getRequestStatusForAuthorization(
|
|
16
|
-
writePermissions,
|
|
17
|
-
readPermissions,
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default getRequestStatusForAuthorization
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import serializeDate from './serializeDate'
|
|
2
|
-
|
|
3
|
-
import type { GenericQueryOptions } from '../types'
|
|
4
|
-
|
|
5
|
-
const prepareOptions = (options: GenericQueryOptions) => {
|
|
6
|
-
const limit = !options.limit || options.limit === Infinity
|
|
7
|
-
? 0
|
|
8
|
-
: options.limit
|
|
9
|
-
const ascending = options.ascending ?? limit === 0
|
|
10
|
-
// eslint-disable-next-line no-nested-ternary
|
|
11
|
-
const from = serializeDate(options.from ? options.from : (limit > 0 ? new Date(0) : undefined))
|
|
12
|
-
const to = serializeDate(options.to)
|
|
13
|
-
const anchor = options.anchor ?? ''
|
|
14
|
-
return {
|
|
15
|
-
limit, ascending, from, to, anchor,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default prepareOptions
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import deserializeCategorySample from './deserializeCategorySample'
|
|
2
|
-
import prepareOptions from './prepareOptions'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { HKCategoryTypeIdentifier } from '../native-types'
|
|
6
|
-
import type { GenericQueryOptions, HKCategorySample } from '../types'
|
|
7
|
-
|
|
8
|
-
export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(
|
|
9
|
-
identifier: T,
|
|
10
|
-
options: Omit<GenericQueryOptions, 'anchor'>
|
|
11
|
-
) => Promise<readonly HKCategorySample<T>[]>;
|
|
12
|
-
|
|
13
|
-
const queryCategorySamples: QueryCategorySamplesFn = async (
|
|
14
|
-
identifier,
|
|
15
|
-
options,
|
|
16
|
-
) => {
|
|
17
|
-
const opts = prepareOptions(options)
|
|
18
|
-
const raw = await Native.queryCategorySamples(
|
|
19
|
-
identifier,
|
|
20
|
-
opts.from,
|
|
21
|
-
opts.to,
|
|
22
|
-
opts.limit,
|
|
23
|
-
opts.ascending,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return raw.map(deserializeCategorySample)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default queryCategorySamples
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import deserializeCategorySample from './deserializeCategorySample'
|
|
2
|
-
import prepareOptions from './prepareOptions'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types'
|
|
6
|
-
import type { GenericQueryOptions, HKCategorySample } from '../types'
|
|
7
|
-
|
|
8
|
-
export type QueryCategorySamplesWithAnchorResponse<T extends HKCategoryTypeIdentifier> = {
|
|
9
|
-
readonly samples: readonly HKCategorySample<T>[],
|
|
10
|
-
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
|
|
11
|
-
readonly newAnchor: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type QueryCategorySamplesWithAnchorFn = <T extends HKCategoryTypeIdentifier>(
|
|
15
|
-
identifier: T,
|
|
16
|
-
options: Omit<GenericQueryOptions, 'ascending'>
|
|
17
|
-
) => Promise<QueryCategorySamplesWithAnchorResponse<T>>;
|
|
18
|
-
|
|
19
|
-
const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn = async (
|
|
20
|
-
identifier,
|
|
21
|
-
options,
|
|
22
|
-
) => {
|
|
23
|
-
const opts = prepareOptions(options)
|
|
24
|
-
const raw = await Native.queryCategorySamplesWithAnchor(
|
|
25
|
-
identifier,
|
|
26
|
-
opts.from,
|
|
27
|
-
opts.to,
|
|
28
|
-
opts.limit,
|
|
29
|
-
opts.anchor,
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
samples: raw.samples.map(deserializeCategorySample),
|
|
34
|
-
deletedSamples: raw.deletedSamples,
|
|
35
|
-
newAnchor: raw.newAnchor,
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default queryCategorySamplesWithAnchor
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import deserializeCorrelation from './deserializeCorrelation'
|
|
2
|
-
import prepareOptions from './prepareOptions'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { HKCorrelationTypeIdentifier } from '../native-types'
|
|
6
|
-
import type { GenericQueryOptions, HKCorrelation } from '../types'
|
|
7
|
-
|
|
8
|
-
export type QueryCorrelationSamplesFn = <
|
|
9
|
-
TIdentifier extends HKCorrelationTypeIdentifier
|
|
10
|
-
>(
|
|
11
|
-
typeIdentifier: TIdentifier,
|
|
12
|
-
options: Omit<GenericQueryOptions, 'anchor' | 'ascending' | 'limit'>
|
|
13
|
-
) => Promise<readonly HKCorrelation<TIdentifier>[]>;
|
|
14
|
-
|
|
15
|
-
const queryCorrelationSamples: QueryCorrelationSamplesFn = async (
|
|
16
|
-
typeIdentifier,
|
|
17
|
-
options,
|
|
18
|
-
) => {
|
|
19
|
-
const opts = prepareOptions(options)
|
|
20
|
-
const correlations = await Native.queryCorrelationSamples(
|
|
21
|
-
typeIdentifier,
|
|
22
|
-
opts.from,
|
|
23
|
-
opts.to,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return correlations.map(deserializeCorrelation)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default queryCorrelationSamples
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import deserializeHeartbeatSeriesSample from './deserializeHeartbeatSeriesSample'
|
|
2
|
-
import prepareOptions from './prepareOptions'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types'
|
|
6
|
-
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types'
|
|
7
|
-
|
|
8
|
-
export type QueryHeartbeatSeriesSamplesResponse = {
|
|
9
|
-
readonly samples: readonly HKHeartbeatSeriesSample[],
|
|
10
|
-
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[],
|
|
11
|
-
readonly newAnchor: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKHeartbeatSeriesSample[]>;
|
|
15
|
-
|
|
16
|
-
const queryHeartbeatSeriesSamples: QueryHeartbeatSeriesSamplesFn = async (options) => {
|
|
17
|
-
const opts = prepareOptions(options)
|
|
18
|
-
|
|
19
|
-
const result = await Native.queryHeartbeatSeriesSamples(
|
|
20
|
-
opts.from,
|
|
21
|
-
opts.to,
|
|
22
|
-
opts.limit,
|
|
23
|
-
opts.ascending,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return result.map(deserializeHeartbeatSeriesSample)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default queryHeartbeatSeriesSamples
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import deserializeHeartbeatSeriesSample from './deserializeHeartbeatSeriesSample'
|
|
2
|
-
import prepareOptions from './prepareOptions'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types'
|
|
6
|
-
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types'
|
|
7
|
-
|
|
8
|
-
export type QueryHeartbeatSeriesSamplesResponse = {
|
|
9
|
-
readonly samples: readonly HKHeartbeatSeriesSample[],
|
|
10
|
-
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[],
|
|
11
|
-
readonly newAnchor: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryHeartbeatSeriesSamplesResponse>;
|
|
15
|
-
|
|
16
|
-
const queryHeartbeatSeriesSamplesWithAnchor: QueryHeartbeatSeriesSamplesFn = async (options) => {
|
|
17
|
-
const opts = prepareOptions(options)
|
|
18
|
-
|
|
19
|
-
const result = await Native.queryHeartbeatSeriesSamplesWithAnchor(
|
|
20
|
-
opts.from,
|
|
21
|
-
opts.to,
|
|
22
|
-
opts.limit,
|
|
23
|
-
opts.anchor,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
deletedSamples: result.deletedSamples,
|
|
28
|
-
newAnchor: result.newAnchor,
|
|
29
|
-
samples: result.samples.map(deserializeHeartbeatSeriesSample),
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default queryHeartbeatSeriesSamplesWithAnchor
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import deserializeQuantitySample from './deserializeSample'
|
|
2
|
-
import ensureUnit from './ensureUnit'
|
|
3
|
-
import prepareOptions from './prepareOptions'
|
|
4
|
-
import Native from '../native-types'
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
HKQuantityTypeIdentifier, UnitForIdentifier,
|
|
8
|
-
} from '../native-types'
|
|
9
|
-
import type { GenericQueryOptions, HKQuantitySample } from '../types'
|
|
10
|
-
|
|
11
|
-
export type QueryQuantitySamplesFn = <
|
|
12
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
13
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
14
|
-
>(
|
|
15
|
-
identifier: TIdentifier,
|
|
16
|
-
options: Omit<GenericQueryOptions, 'anchor'> & { readonly unit?: TUnit }
|
|
17
|
-
) => Promise<readonly HKQuantitySample<TIdentifier>[]>;
|
|
18
|
-
|
|
19
|
-
const queryQuantitySamples: QueryQuantitySamplesFn = async (
|
|
20
|
-
identifier,
|
|
21
|
-
options,
|
|
22
|
-
) => {
|
|
23
|
-
const unit = await ensureUnit(identifier, options.unit)
|
|
24
|
-
const opts = prepareOptions(options)
|
|
25
|
-
|
|
26
|
-
const result = await Native.queryQuantitySamples(
|
|
27
|
-
identifier,
|
|
28
|
-
unit,
|
|
29
|
-
opts.from,
|
|
30
|
-
opts.to,
|
|
31
|
-
opts.limit,
|
|
32
|
-
opts.ascending,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return result.map(deserializeQuantitySample)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default queryQuantitySamples
|