@kingstinct/react-native-healthkit 8.7.2 → 9.0.1
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/README.md +34 -21
- 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 +525 -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 +412 -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/ios/ReactNativeHealthkit-Bridging-Header.h +0 -2
- package/ios/ReactNativeHealthkit.m +0 -271
- package/ios/ReactNativeHealthkit.swift +0 -2333
- package/ios/ReactNativeHealthkit.xcodeproj/project.pbxproj +0 -279
- package/kingstinct-react-native-healthkit.podspec +0 -21
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -39
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +0 -72
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -27
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +0 -41
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +0 -23
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -37
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -48
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/hooks/useSources.js +0 -22
- package/lib/commonjs/hooks/useSources.js.map +0 -1
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +0 -28
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -28
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/commonjs/index.ios.js +0 -531
- package/lib/commonjs/index.ios.js.map +0 -1
- package/lib/commonjs/index.js +0 -22
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/index.native.js +0 -235
- package/lib/commonjs/index.native.js.map +0 -1
- package/lib/commonjs/index.web.js +0 -22
- package/lib/commonjs/index.web.js.map +0 -1
- package/lib/commonjs/native-types.js +0 -1575
- package/lib/commonjs/native-types.js.map +0 -1
- package/lib/commonjs/test-setup.js +0 -57
- package/lib/commonjs/test-setup.js.map +0 -1
- package/lib/commonjs/test-utils.js +0 -18
- package/lib/commonjs/test-utils.js.map +0 -1
- package/lib/commonjs/types.js +0 -17
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/deleteQuantitySample.js +0 -11
- package/lib/commonjs/utils/deleteQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/deleteSamples.js +0 -18
- package/lib/commonjs/utils/deleteSamples.js.map +0 -1
- package/lib/commonjs/utils/deleteWorkoutSample.js +0 -11
- package/lib/commonjs/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +0 -13
- package/lib/commonjs/utils/deserializeCategorySample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.test.js +0 -26
- package/lib/commonjs/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/commonjs/utils/deserializeCorrelation.js +0 -26
- package/lib/commonjs/utils/deserializeCorrelation.js.map +0 -1
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +0 -15
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeSample.js +0 -15
- package/lib/commonjs/utils/deserializeSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeWorkout.js +0 -15
- package/lib/commonjs/utils/deserializeWorkout.js.map +0 -1
- package/lib/commonjs/utils/ensureMetadata.js +0 -11
- package/lib/commonjs/utils/ensureMetadata.js.map +0 -1
- package/lib/commonjs/utils/ensureTotals.js +0 -11
- package/lib/commonjs/utils/ensureTotals.js.map +0 -1
- package/lib/commonjs/utils/ensureUnit.js +0 -17
- package/lib/commonjs/utils/ensureUnit.js.map +0 -1
- package/lib/commonjs/utils/getDateOfBirth.js +0 -14
- package/lib/commonjs/utils/getDateOfBirth.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +0 -17
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +0 -21
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentWorkout.js +0 -19
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnit.js +0 -14
- package/lib/commonjs/utils/getPreferredUnit.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnits.js +0 -14
- package/lib/commonjs/utils/getPreferredUnits.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -33
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +0 -21
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/commonjs/utils/getWorkoutPlanById.js +0 -13
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/commonjs/utils/prepareOptions.js +0 -25
- package/lib/commonjs/utils/prepareOptions.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamples.js +0 -17
- package/lib/commonjs/utils/queryCategorySamples.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryCorrelationSamples.js +0 -17
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +0 -17
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +0 -19
- package/lib/commonjs/utils/queryQuantitySamples.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +0 -23
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/querySources.js +0 -14
- package/lib/commonjs/utils/querySources.js.map +0 -1
- package/lib/commonjs/utils/queryStateOfMindSamples.js +0 -22
- package/lib/commonjs/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js +0 -16
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +0 -29
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js +0 -26
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryWorkouts.js +0 -22
- package/lib/commonjs/utils/queryWorkouts.js.map +0 -1
- package/lib/commonjs/utils/requestAuthorization.js +0 -22
- package/lib/commonjs/utils/requestAuthorization.js.map +0 -1
- package/lib/commonjs/utils/saveCategorySample.js +0 -20
- package/lib/commonjs/utils/saveCategorySample.js.map +0 -1
- package/lib/commonjs/utils/saveCorrelationSample.js +0 -35
- package/lib/commonjs/utils/saveCorrelationSample.js.map +0 -1
- package/lib/commonjs/utils/saveQuantitySample.js +0 -16
- package/lib/commonjs/utils/saveQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/saveStateOfMindSample.js +0 -17
- package/lib/commonjs/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +0 -26
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +0 -36
- package/lib/commonjs/utils/saveWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.js +0 -9
- package/lib/commonjs/utils/serializeDate.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.test.js +0 -17
- package/lib/commonjs/utils/serializeDate.test.js.map +0 -1
- package/lib/commonjs/utils/startWatchApp.js +0 -11
- package/lib/commonjs/utils/startWatchApp.js.map +0 -1
- package/lib/commonjs/utils/subscribeToChanges.js +0 -27
- package/lib/commonjs/utils/subscribeToChanges.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +0 -32
- package/lib/module/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js +0 -68
- package/lib/module/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js +0 -21
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js +0 -37
- package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +0 -16
- package/lib/module/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +0 -30
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentWorkout.js +0 -41
- package/lib/module/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/module/hooks/useSources.js +0 -15
- package/lib/module/hooks/useSources.js.map +0 -1
- package/lib/module/hooks/useStatisticsForQuantity.js +0 -21
- package/lib/module/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/module/hooks/useSubscribeToChanges.js +0 -21
- package/lib/module/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/module/index.ios.js +0 -209
- package/lib/module/index.ios.js.map +0 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.native.js +0 -160
- package/lib/module/index.native.js.map +0 -1
- package/lib/module/index.web.js +0 -4
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/native-types.js +0 -1606
- package/lib/module/native-types.js.map +0 -1
- package/lib/module/test-setup.js +0 -54
- package/lib/module/test-setup.js.map +0 -1
- package/lib/module/test-utils.js +0 -11
- package/lib/module/test-utils.js.map +0 -1
- package/lib/module/types.js +0 -67
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/deleteQuantitySample.js +0 -4
- package/lib/module/utils/deleteQuantitySample.js.map +0 -1
- package/lib/module/utils/deleteSamples.js +0 -11
- package/lib/module/utils/deleteSamples.js.map +0 -1
- package/lib/module/utils/deleteWorkoutSample.js +0 -4
- package/lib/module/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.js +0 -7
- package/lib/module/utils/deserializeCategorySample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.test.js +0 -22
- package/lib/module/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/module/utils/deserializeCorrelation.js +0 -19
- package/lib/module/utils/deserializeCorrelation.js.map +0 -1
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js +0 -9
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/module/utils/deserializeSample.js +0 -9
- package/lib/module/utils/deserializeSample.js.map +0 -1
- package/lib/module/utils/deserializeWorkout.js +0 -9
- package/lib/module/utils/deserializeWorkout.js.map +0 -1
- package/lib/module/utils/ensureMetadata.js +0 -5
- package/lib/module/utils/ensureMetadata.js.map +0 -1
- package/lib/module/utils/ensureTotals.js +0 -5
- package/lib/module/utils/ensureTotals.js.map +0 -1
- package/lib/module/utils/ensureUnit.js +0 -10
- package/lib/module/utils/ensureUnit.js.map +0 -1
- package/lib/module/utils/getDateOfBirth.js +0 -7
- package/lib/module/utils/getDateOfBirth.js.map +0 -1
- package/lib/module/utils/getMostRecentCategorySample.js +0 -10
- package/lib/module/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +0 -14
- package/lib/module/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/module/utils/getMostRecentWorkout.js +0 -12
- package/lib/module/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/module/utils/getPreferredUnit.js +0 -7
- package/lib/module/utils/getPreferredUnit.js.map +0 -1
- package/lib/module/utils/getPreferredUnits.js +0 -7
- package/lib/module/utils/getPreferredUnits.js.map +0 -1
- package/lib/module/utils/getPreferredUnitsTyped.js +0 -26
- package/lib/module/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/module/utils/getRequestStatusForAuthorization.js +0 -14
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/module/utils/getWorkoutPlanById.js +0 -6
- package/lib/module/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/module/utils/prepareOptions.js +0 -18
- package/lib/module/utils/prepareOptions.js.map +0 -1
- package/lib/module/utils/queryCategorySamples.js +0 -10
- package/lib/module/utils/queryCategorySamples.js.map +0 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryCorrelationSamples.js +0 -10
- package/lib/module/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamples.js +0 -10
- package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryQuantitySamples.js +0 -12
- package/lib/module/utils/queryQuantitySamples.js.map +0 -1
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js +0 -16
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/querySources.js +0 -7
- package/lib/module/utils/querySources.js.map +0 -1
- package/lib/module/utils/queryStateOfMindSamples.js +0 -14
- package/lib/module/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js +0 -9
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/module/utils/queryStatisticsForQuantity.js +0 -22
- package/lib/module/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js +0 -19
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryWorkouts.js +0 -15
- package/lib/module/utils/queryWorkouts.js.map +0 -1
- package/lib/module/utils/requestAuthorization.js +0 -15
- package/lib/module/utils/requestAuthorization.js.map +0 -1
- package/lib/module/utils/saveCategorySample.js +0 -13
- package/lib/module/utils/saveCategorySample.js.map +0 -1
- package/lib/module/utils/saveCorrelationSample.js +0 -28
- package/lib/module/utils/saveCorrelationSample.js.map +0 -1
- package/lib/module/utils/saveQuantitySample.js +0 -9
- package/lib/module/utils/saveQuantitySample.js.map +0 -1
- package/lib/module/utils/saveStateOfMindSample.js +0 -10
- package/lib/module/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/module/utils/saveWorkoutRoute.js +0 -19
- package/lib/module/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/module/utils/saveWorkoutSample.js +0 -29
- package/lib/module/utils/saveWorkoutSample.js.map +0 -1
- package/lib/module/utils/serializeDate.js +0 -3
- package/lib/module/utils/serializeDate.js.map +0 -1
- package/lib/module/utils/serializeDate.test.js +0 -14
- package/lib/module/utils/serializeDate.test.js.map +0 -1
- package/lib/module/utils/startWatchApp.js +0 -4
- package/lib/module/utils/startWatchApp.js.map +0 -1
- package/lib/module/utils/subscribeToChanges.js +0 -20
- package/lib/module/utils/subscribeToChanges.js.map +0 -1
- package/lib/typescript/example-expo/App.d.ts +0 -2
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +0 -8
- package/lib/typescript/src/hooks/useHealthkitAuthorization.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +0 -7
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +0 -10
- package/lib/typescript/src/hooks/useSources.d.ts +0 -3
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +0 -4
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +0 -3
- package/lib/typescript/src/index.d.ts +0 -3
- package/lib/typescript/src/index.ios.d.ts +0 -198
- package/lib/typescript/src/index.native.d.ts +0 -41
- package/lib/typescript/src/index.web.d.ts +0 -3
- package/lib/typescript/src/native-types.d.ts +0 -1764
- package/lib/typescript/src/test-setup.d.ts +0 -1
- package/lib/typescript/src/test-utils.d.ts +0 -2
- package/lib/typescript/src/types.d.ts +0 -111
- package/lib/typescript/src/utils/deleteQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/deleteSamples.d.ts +0 -8
- package/lib/typescript/src/utils/deleteWorkoutSample.d.ts +0 -3
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeCategorySample.test.d.ts +0 -1
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeHeartbeatSeriesSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +0 -4
- package/lib/typescript/src/utils/ensureMetadata.d.ts +0 -2
- package/lib/typescript/src/utils/ensureTotals.d.ts +0 -2
- package/lib/typescript/src/utils/ensureUnit.d.ts +0 -3
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +0 -2
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +0 -5
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +0 -9
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +0 -3
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +0 -5
- package/lib/typescript/src/utils/prepareOptions.d.ts +0 -9
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +0 -10
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +0 -12
- package/lib/typescript/src/utils/querySources.d.ts +0 -4
- package/lib/typescript/src/utils/queryStateOfMindSamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryStatisticsCollectionForQuantity.d.ts +0 -3
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +0 -14
- package/lib/typescript/src/utils/queryWorkoutSamplesWithAnchor.d.ts +0 -9
- package/lib/typescript/src/utils/queryWorkouts.d.ts +0 -4
- package/lib/typescript/src/utils/requestAuthorization.d.ts +0 -4
- package/lib/typescript/src/utils/saveCategorySample.d.ts +0 -11
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +0 -8
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +0 -7
- package/lib/typescript/src/utils/saveStateOfMindSample.d.ts +0 -11
- package/lib/typescript/src/utils/saveWorkoutRoute.d.ts +0 -3
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +0 -11
- package/lib/typescript/src/utils/serializeDate.d.ts +0 -2
- package/lib/typescript/src/utils/serializeDate.test.d.ts +0 -1
- package/lib/typescript/src/utils/startWatchApp.d.ts +0 -3
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +0 -3
- package/src/index.ios.tsx +0 -292
- package/src/index.native.tsx +0 -233
- package/src/index.tsx +0 -5
- package/src/index.web.tsx +0 -5
- package/src/native-types.ts +0 -2471
- package/src/types.ts +0 -156
- package/src/utils/deleteQuantitySample.ts +0 -14
- package/src/utils/deleteSamples.ts +0 -23
- package/src/utils/deleteWorkoutSample.ts +0 -7
- package/src/utils/deserializeCategorySample.test.ts +0 -24
- package/src/utils/deserializeCategorySample.ts +0 -12
- package/src/utils/deserializeCorrelation.ts +0 -28
- package/src/utils/deserializeHeartbeatSeriesSample.ts +0 -12
- package/src/utils/deserializeSample.ts +0 -17
- package/src/utils/deserializeWorkout.ts +0 -14
- package/src/utils/ensureMetadata.ts +0 -5
- package/src/utils/ensureTotals.ts +0 -5
- package/src/utils/ensureUnit.ts +0 -19
- package/src/utils/getDateOfBirth.ts +0 -8
- package/src/utils/getPreferredUnits.ts +0 -14
- package/src/utils/getPreferredUnitsTyped.ts +0 -38
- package/src/utils/getRequestStatusForAuthorization.ts +0 -21
- package/src/utils/getWorkoutPlanById.ts +0 -7
- package/src/utils/prepareOptions.ts +0 -19
- package/src/utils/queryCategorySamples.ts +0 -29
- package/src/utils/queryCategorySamplesWithAnchor.ts +0 -39
- package/src/utils/queryCorrelationSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +0 -33
- package/src/utils/queryQuantitySamples.ts +0 -38
- package/src/utils/queryQuantitySamplesWithAnchor.ts +0 -46
- package/src/utils/querySources.ts +0 -21
- package/src/utils/queryStateOfMindSamples.ts +0 -14
- package/src/utils/queryStatisticsCollectionForQuantity.ts +0 -38
- package/src/utils/queryStatisticsForQuantity.ts +0 -38
- package/src/utils/queryWorkoutSamplesWithAnchor.ts +0 -46
- package/src/utils/queryWorkouts.ts +0 -28
- package/src/utils/requestAuthorization.ts +0 -19
- package/src/utils/saveCategorySample.ts +0 -31
- package/src/utils/saveCorrelationSample.ts +0 -43
- package/src/utils/saveQuantitySample.ts +0 -29
- package/src/utils/saveStateOfMindSample.ts +0 -38
- package/src/utils/saveWorkoutRoute.ts +0 -21
- package/src/utils/saveWorkoutSample.ts +0 -42
- package/src/utils/serializeDate.test.ts +0 -16
- package/src/utils/serializeDate.ts +0 -5
- package/src/utils/startWatchApp.ts +0 -7
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
|
+
import type { WorkoutProxy } from '../specs/WorkoutProxy.nitro'
|
|
3
|
+
import type { Device } from './Device'
|
|
4
|
+
import type { Quantity } from './QuantityType'
|
|
5
|
+
import type { PredicateForSamples } from './QueryOptions'
|
|
6
|
+
import type { DeletedSample, GenericMetadata } from './Shared'
|
|
7
|
+
import type { SourceRevision } from './Source'
|
|
8
|
+
|
|
9
|
+
export enum WorkoutActivityType {
|
|
10
|
+
americanFootball = 1,
|
|
11
|
+
archery = 2,
|
|
12
|
+
australianFootball = 3,
|
|
13
|
+
badminton = 4,
|
|
14
|
+
baseball = 5,
|
|
15
|
+
basketball = 6,
|
|
16
|
+
bowling = 7,
|
|
17
|
+
boxing = 8, // See also HKWorkoutActivityTypeKickboxing.,
|
|
18
|
+
climbing = 9,
|
|
19
|
+
cricket = 10,
|
|
20
|
+
crossTraining = 11, // Any mix of cardio and/or strength training. See also HKWorkoutActivityTypeCoreTraining and HKWorkoutActivityTypeFlexibility.,
|
|
21
|
+
curling = 12,
|
|
22
|
+
cycling = 13,
|
|
23
|
+
dance = 14,
|
|
24
|
+
danceInspiredTraining = 15, // This enum remains available to access older data.,
|
|
25
|
+
elliptical = 16,
|
|
26
|
+
equestrianSports = 17, // Polo, Horse Racing, Horse Riding, etc.,
|
|
27
|
+
fencing = 18,
|
|
28
|
+
fishing = 19,
|
|
29
|
+
functionalStrengthTraining = 20, // Primarily free weights and/or body weight and/or accessories,
|
|
30
|
+
golf = 21,
|
|
31
|
+
gymnastics = 22,
|
|
32
|
+
handball = 23,
|
|
33
|
+
hiking = 24,
|
|
34
|
+
hockey = 25, // Ice Hockey, Field Hockey, etc.,
|
|
35
|
+
hunting = 26,
|
|
36
|
+
lacrosse = 27,
|
|
37
|
+
martialArts = 28,
|
|
38
|
+
mindAndBody = 29, // Qigong, meditation, etc.,
|
|
39
|
+
mixedMetabolicCardioTraining = 30, // This enum remains available to access older data.,
|
|
40
|
+
paddleSports = 31, // Canoeing, Kayaking, Outrigger, Stand Up Paddle Board, etc.,
|
|
41
|
+
play = 32, // Dodge Ball, Hopscotch, Tetherball, Jungle Gym, etc.,
|
|
42
|
+
preparationAndRecovery = 33, // Foam rolling, stretching, etc.,
|
|
43
|
+
racquetball = 34,
|
|
44
|
+
rowing = 35,
|
|
45
|
+
rugby = 36,
|
|
46
|
+
running = 37,
|
|
47
|
+
sailing = 38,
|
|
48
|
+
skatingSports = 39, // Ice Skating, Speed Skating, Inline Skating, Skateboarding, etc.,
|
|
49
|
+
snowSports = 40, // Sledding, Snowmobiling, Building a Snowman, etc. See also HKWorkoutActivityTypeCrossCountrySkiing, HKWorkoutActivityTypeSnowboarding, and HKWorkoutActivityTypeDownhillSkiing.,
|
|
50
|
+
soccer = 41,
|
|
51
|
+
softball = 42,
|
|
52
|
+
squash = 43,
|
|
53
|
+
stairClimbing = 44, // See also HKWorkoutActivityTypeStairs and HKWorkoutActivityTypeStepTraining.,
|
|
54
|
+
surfingSports = 45, // Traditional Surfing, Kite Surfing, Wind Surfing, etc.,
|
|
55
|
+
swimming = 46,
|
|
56
|
+
tableTennis = 47,
|
|
57
|
+
tennis = 48,
|
|
58
|
+
trackAndField = 49, // Shot Put, Javelin, Pole Vaulting, etc.,
|
|
59
|
+
traditionalStrengthTraining = 50, // Primarily machines and/or free weights,
|
|
60
|
+
volleyball = 51,
|
|
61
|
+
walking = 52,
|
|
62
|
+
waterFitness = 53,
|
|
63
|
+
waterPolo = 54,
|
|
64
|
+
waterSports = 55, // Water Skiing, Wake Boarding, etc.,
|
|
65
|
+
wrestling = 56,
|
|
66
|
+
yoga = 57,
|
|
67
|
+
barre = 58, // HKWorkoutActivityTypeDanceInspiredTraining,
|
|
68
|
+
coreTraining = 59,
|
|
69
|
+
crossCountrySkiing = 60,
|
|
70
|
+
downhillSkiing = 61,
|
|
71
|
+
flexibility = 62,
|
|
72
|
+
highIntensityIntervalTraining = 63,
|
|
73
|
+
jumpRope = 64,
|
|
74
|
+
kickboxing = 65,
|
|
75
|
+
pilates = 66, // HKWorkoutActivityTypeDanceInspiredTraining,
|
|
76
|
+
snowboarding = 67,
|
|
77
|
+
stairs = 68,
|
|
78
|
+
stepTraining = 69,
|
|
79
|
+
wheelchairWalkPace = 70,
|
|
80
|
+
wheelchairRunPace = 71,
|
|
81
|
+
taiChi = 72,
|
|
82
|
+
mixedCardio = 73, // HKWorkoutActivityTypeMixedMetabolicCardioTraining,
|
|
83
|
+
handCycling = 74,
|
|
84
|
+
discSports = 75,
|
|
85
|
+
fitnessGaming = 76,
|
|
86
|
+
cardioDance = 77,
|
|
87
|
+
socialDance = 78,
|
|
88
|
+
pickleball = 79,
|
|
89
|
+
cooldown = 80,
|
|
90
|
+
swimBikeRun = 82,
|
|
91
|
+
transition = 83,
|
|
92
|
+
underwaterDiving = 84,
|
|
93
|
+
other = 3000,
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// documented at https://developer.apple.com/documentation/healthkit/hkweathercondition
|
|
97
|
+
export enum WeatherCondition {
|
|
98
|
+
none = 0,
|
|
99
|
+
clear = 1,
|
|
100
|
+
fair = 2,
|
|
101
|
+
partlyCloudy = 3,
|
|
102
|
+
mostlyCloudy = 4,
|
|
103
|
+
cloudy = 5,
|
|
104
|
+
foggy = 6,
|
|
105
|
+
haze = 7,
|
|
106
|
+
windy = 8,
|
|
107
|
+
blustery = 9,
|
|
108
|
+
smoky = 10,
|
|
109
|
+
dust = 11,
|
|
110
|
+
snow = 12,
|
|
111
|
+
hail = 13,
|
|
112
|
+
sleet = 14,
|
|
113
|
+
freezingDrizzle = 15,
|
|
114
|
+
freezingRain = 16,
|
|
115
|
+
mixedRainAndHail = 17,
|
|
116
|
+
mixedRainAndSnow = 18,
|
|
117
|
+
mixedRainAndSleet = 19,
|
|
118
|
+
mixedSnowAndSleet = 20,
|
|
119
|
+
drizzle = 21,
|
|
120
|
+
scatteredShowers = 22,
|
|
121
|
+
showers = 23,
|
|
122
|
+
thunderstorms = 24,
|
|
123
|
+
tropicalStorm = 25,
|
|
124
|
+
hurricane = 26,
|
|
125
|
+
tornado = 27,
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface WorkoutMetadata extends GenericMetadata {
|
|
129
|
+
readonly HKWeatherCondition?: WeatherCondition
|
|
130
|
+
readonly HKWeatherHumidity?: Quantity
|
|
131
|
+
readonly HKWeatherTemperature?: Quantity
|
|
132
|
+
readonly HKAverageMETs?: Quantity
|
|
133
|
+
readonly HKElevationAscended?: Quantity
|
|
134
|
+
readonly HKIndoorWorkout?: boolean
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface WorkoutEvent {
|
|
138
|
+
readonly type: WorkoutEventType
|
|
139
|
+
readonly startDate: Date
|
|
140
|
+
readonly endDate: Date
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export enum WorkoutEventType {
|
|
144
|
+
pause = 1,
|
|
145
|
+
resume = 2,
|
|
146
|
+
lap = 3,
|
|
147
|
+
marker = 4,
|
|
148
|
+
motionPaused = 5,
|
|
149
|
+
motionResumed = 6,
|
|
150
|
+
segment = 7,
|
|
151
|
+
pauseOrResumeRequest = 8,
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface WorkoutActivity {
|
|
155
|
+
readonly startDate: Date
|
|
156
|
+
readonly endDate: Date
|
|
157
|
+
readonly uuid: string
|
|
158
|
+
readonly duration: number
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface WorkoutRoute {
|
|
162
|
+
readonly locations: readonly WorkoutRouteLocation[]
|
|
163
|
+
readonly HKMetadataKeySyncIdentifier?: string
|
|
164
|
+
readonly HKMetadataKeySyncVersion?: number
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface QueryWorkoutSamplesWithAnchorResponse {
|
|
168
|
+
readonly workouts: readonly WorkoutProxy[]
|
|
169
|
+
readonly deletedSamples: readonly DeletedSample[]
|
|
170
|
+
readonly newAnchor: string
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type WorkoutActivityTypePredicate = {
|
|
174
|
+
readonly workoutActivityType: WorkoutActivityType
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
enum ComparisonPredicateOperator {
|
|
178
|
+
lessThan = 0,
|
|
179
|
+
lessThanOrEqualTo = 1,
|
|
180
|
+
greaterThan = 2,
|
|
181
|
+
greaterThanOrEqualTo = 3,
|
|
182
|
+
equalTo = 4,
|
|
183
|
+
notEqualTo = 5,
|
|
184
|
+
matches = 6,
|
|
185
|
+
like = 7,
|
|
186
|
+
beginsWith = 8,
|
|
187
|
+
endsWith = 9,
|
|
188
|
+
in = 10,
|
|
189
|
+
customSelector = 11,
|
|
190
|
+
contains = 99,
|
|
191
|
+
between = 100,
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
type WorkoutDurationPredicate = {
|
|
195
|
+
readonly predicateOperator: ComparisonPredicateOperator
|
|
196
|
+
readonly durationInSeconds: number
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export type PredicateForWorkouts =
|
|
200
|
+
| PredicateForSamples
|
|
201
|
+
| WorkoutActivityTypePredicate
|
|
202
|
+
| WorkoutDurationPredicate
|
|
203
|
+
|
|
204
|
+
export type PredicateForWorkoutsOr = {
|
|
205
|
+
readonly OR: readonly PredicateForWorkouts[]
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export type PredicateForWorkoutsAnd = {
|
|
209
|
+
readonly AND: readonly PredicateForWorkouts[]
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export type FilterForWorkouts =
|
|
213
|
+
| PredicateForWorkouts
|
|
214
|
+
| PredicateForWorkoutsOr
|
|
215
|
+
| PredicateForWorkoutsAnd
|
|
216
|
+
|
|
217
|
+
export interface WorkoutQueryOptionsWithAnchor {
|
|
218
|
+
energyUnit?: string
|
|
219
|
+
distanceUnit?: string
|
|
220
|
+
filter?: FilterForWorkouts
|
|
221
|
+
limit?: number
|
|
222
|
+
anchor?: string
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface WorkoutQueryOptions {
|
|
226
|
+
energyUnit?: string
|
|
227
|
+
distanceUnit?: string
|
|
228
|
+
filter?: FilterForWorkouts
|
|
229
|
+
limit?: number
|
|
230
|
+
ascending?: boolean
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface WorkoutRouteLocation {
|
|
234
|
+
readonly altitude: number
|
|
235
|
+
readonly course: number
|
|
236
|
+
readonly date: Date
|
|
237
|
+
readonly distance: number | null
|
|
238
|
+
readonly horizontalAccuracy: number
|
|
239
|
+
readonly latitude: number
|
|
240
|
+
readonly longitude: number
|
|
241
|
+
readonly speed: number
|
|
242
|
+
readonly speedAccuracy: number
|
|
243
|
+
readonly verticalAccuracy: number
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export interface LocationForSaving {
|
|
247
|
+
readonly altitude: number
|
|
248
|
+
readonly course: number
|
|
249
|
+
readonly date: Date // unix timestamp in milliseconds
|
|
250
|
+
readonly horizontalAccuracy: number
|
|
251
|
+
readonly latitude: number
|
|
252
|
+
readonly longitude: number
|
|
253
|
+
readonly speed: number
|
|
254
|
+
readonly verticalAccuracy: number
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export interface WorkoutPlan {
|
|
258
|
+
readonly id: string
|
|
259
|
+
readonly activityType: WorkoutActivityType
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export interface WorkoutTotals {
|
|
263
|
+
readonly distance?: number
|
|
264
|
+
readonly energyBurned?: number
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface WorkoutSample {
|
|
268
|
+
readonly uuid: string
|
|
269
|
+
readonly device?: Device
|
|
270
|
+
readonly workoutActivityType: WorkoutActivityType
|
|
271
|
+
readonly duration: Quantity
|
|
272
|
+
readonly totalDistance?: Quantity
|
|
273
|
+
readonly totalEnergyBurned?: Quantity
|
|
274
|
+
readonly totalSwimmingStrokeCount?: Quantity
|
|
275
|
+
readonly totalFlightsClimbed?: Quantity
|
|
276
|
+
readonly startDate: Date
|
|
277
|
+
readonly endDate: Date
|
|
278
|
+
readonly metadata?: AnyMap
|
|
279
|
+
readonly sourceRevision?: SourceRevision
|
|
280
|
+
readonly events?: readonly WorkoutEvent[]
|
|
281
|
+
readonly activities?: readonly WorkoutActivity[]
|
|
282
|
+
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { CategoryTypes } from '../modules'
|
|
2
|
+
import type { CategoryTypeIdentifier } from '../types/CategoryTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
T extends HKCategoryTypeIdentifier
|
|
8
|
-
>(
|
|
9
|
-
identifier: T,
|
|
10
|
-
): Promise<HKCategorySample<T> | null> {
|
|
11
|
-
const samples = await queryCategorySamples(identifier, {
|
|
4
|
+
export async function getMostRecentCategorySample<
|
|
5
|
+
T extends CategoryTypeIdentifier,
|
|
6
|
+
>(identifier: T) {
|
|
7
|
+
const samples = await CategoryTypes.queryCategorySamples(identifier, {
|
|
12
8
|
limit: 1,
|
|
13
9
|
ascending: false,
|
|
14
10
|
})
|
|
15
11
|
|
|
16
|
-
return samples[0]
|
|
12
|
+
return samples[0]
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
export default getMostRecentCategorySample
|
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { QuantityTypes } from '../modules'
|
|
2
|
+
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
9
|
-
>(
|
|
10
|
-
identifier: TIdentifier,
|
|
11
|
-
unit: TUnit,
|
|
12
|
-
): Promise<HKQuantitySample<TIdentifier, TUnit> | null> {
|
|
13
|
-
const samples = await queryQuantitySamples(identifier, {
|
|
4
|
+
async function getMostRecentQuantitySample(
|
|
5
|
+
identifier: QuantityTypeIdentifier,
|
|
6
|
+
unit?: string,
|
|
7
|
+
) {
|
|
8
|
+
const samples = await QuantityTypes.queryQuantitySamples(identifier, {
|
|
14
9
|
limit: 1,
|
|
15
10
|
unit,
|
|
16
11
|
})
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (lastSample) {
|
|
21
|
-
return lastSample as HKQuantitySample<TIdentifier, TUnit>
|
|
22
|
-
}
|
|
23
|
-
return null
|
|
13
|
+
return samples[0]
|
|
24
14
|
}
|
|
25
15
|
|
|
26
16
|
export default getMostRecentQuantitySample
|
|
@@ -1,27 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Workouts } from '../modules'
|
|
2
|
+
import type { WorkoutQueryOptions } from '../types/Workouts'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
TEnergy extends EnergyUnit,
|
|
8
|
-
TDistance extends LengthUnit
|
|
9
|
-
>(
|
|
10
|
-
options?: Pick<
|
|
11
|
-
QueryWorkoutsOptions<TEnergy, TDistance>,
|
|
12
|
-
'distanceUnit' | 'energyUnit'
|
|
13
|
-
>
|
|
14
|
-
) => Promise<HKWorkout<TEnergy, TDistance> | null>;
|
|
15
|
-
|
|
16
|
-
const getMostRecentWorkout: GetMostRecentWorkoutFn = async (options) => {
|
|
17
|
-
const workouts = await queryWorkouts({
|
|
4
|
+
const getMostRecentWorkout = async (
|
|
5
|
+
options: Pick<WorkoutQueryOptions, 'distanceUnit' | 'energyUnit'>,
|
|
6
|
+
) => {
|
|
7
|
+
const workouts = await Workouts.queryWorkoutSamples({
|
|
18
8
|
limit: 1,
|
|
19
9
|
ascending: false,
|
|
20
10
|
energyUnit: options?.energyUnit,
|
|
21
11
|
distanceUnit: options?.distanceUnit,
|
|
22
12
|
})
|
|
23
13
|
|
|
24
|
-
return workouts[0]
|
|
14
|
+
return workouts[0]
|
|
25
15
|
}
|
|
26
16
|
|
|
27
17
|
export default getMostRecentWorkout
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Core } from '../modules'
|
|
2
|
+
import type { QuantityTypeIdentifier } from '../types/QuantityTypeIdentifier'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
const getPreferredUnit = async (
|
|
5
|
+
quantityType: QuantityTypeIdentifier,
|
|
6
|
+
): Promise<string> => {
|
|
7
|
+
const units = await Core.getPreferredUnits([quantityType])
|
|
8
|
+
const unit = units[0]?.unit
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
if (!unit) {
|
|
11
|
+
throw new Error(
|
|
12
|
+
`No preferred unit found for quantity type: ${quantityType}`,
|
|
13
|
+
)
|
|
14
|
+
}
|
|
8
15
|
|
|
9
|
-
const getPreferredUnit: GetPreferredUnitFn = async (type) => {
|
|
10
|
-
const [unit] = await getPreferredUnits([type])
|
|
11
16
|
return unit
|
|
12
17
|
}
|
|
13
|
-
|
|
14
18
|
export default getPreferredUnit
|
|
@@ -1,31 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Core } from '../modules'
|
|
2
|
+
import type { SampleTypeIdentifier } from '../types/Shared'
|
|
3
|
+
import type { OnChangeCallbackArgs } from '../types/Subscriptons'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
identifier: HKSampleTypeIdentifier,
|
|
7
|
-
callback: () => void,
|
|
5
|
+
export const subscribeToChanges = (
|
|
6
|
+
identifier: SampleTypeIdentifier,
|
|
7
|
+
callback: (args: OnChangeCallbackArgs) => void,
|
|
8
8
|
) => {
|
|
9
|
-
const
|
|
10
|
-
'onChange',
|
|
11
|
-
({ typeIdentifier }: { readonly typeIdentifier: HKSampleTypeIdentifier }) => {
|
|
12
|
-
if (typeIdentifier === identifier) {
|
|
13
|
-
callback()
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
const queryId = await Native.subscribeToObserverQuery(identifier).catch(
|
|
19
|
-
async (error) => {
|
|
20
|
-
subscription.remove()
|
|
21
|
-
return Promise.reject(error)
|
|
22
|
-
},
|
|
23
|
-
)
|
|
9
|
+
const queryId = Core.subscribeToObserverQuery(identifier, callback)
|
|
24
10
|
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
return Native.unsubscribeQuery(queryId)
|
|
11
|
+
return {
|
|
12
|
+
remove: () => Core.unsubscribeQuery(queryId),
|
|
28
13
|
}
|
|
29
14
|
}
|
|
30
|
-
|
|
31
|
-
export default subscribeToChanges
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Robert Herber
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|