@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
|
@@ -1,46 +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 { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types'
|
|
7
|
-
import type { GenericQueryOptions, HKQuantitySample } from '../types'
|
|
8
|
-
|
|
9
|
-
export type QueryQuantitySamplesWithAnchorResponse<T extends HKQuantityTypeIdentifier> = {
|
|
10
|
-
readonly samples: readonly HKQuantitySample<T>[],
|
|
11
|
-
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[],
|
|
12
|
-
readonly newAnchor: string
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type QueryQuantitySamplesWithAnchorFn = <
|
|
16
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
17
|
-
TUnit extends UnitForIdentifier<TIdentifier>
|
|
18
|
-
>(
|
|
19
|
-
identifier: TIdentifier,
|
|
20
|
-
options: Omit<GenericQueryOptions, 'ascending'> & { readonly unit?: TUnit }
|
|
21
|
-
) => Promise<QueryQuantitySamplesWithAnchorResponse<TIdentifier>>;
|
|
22
|
-
|
|
23
|
-
const queryQuantitySamplesWithAnchor: QueryQuantitySamplesWithAnchorFn = async (
|
|
24
|
-
identifier,
|
|
25
|
-
options,
|
|
26
|
-
) => {
|
|
27
|
-
const unit = await ensureUnit(identifier, options.unit)
|
|
28
|
-
const opts = prepareOptions(options)
|
|
29
|
-
|
|
30
|
-
const result = await Native.queryQuantitySamplesWithAnchor(
|
|
31
|
-
identifier,
|
|
32
|
-
unit,
|
|
33
|
-
opts.from,
|
|
34
|
-
opts.to,
|
|
35
|
-
opts.limit,
|
|
36
|
-
opts.anchor,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
deletedSamples: result.deletedSamples,
|
|
41
|
-
newAnchor: result.newAnchor,
|
|
42
|
-
samples: result.samples.map(deserializeQuantitySample),
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default queryQuantitySamplesWithAnchor
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
HKQuantityTypeIdentifier,
|
|
5
|
-
HKSource,
|
|
6
|
-
HKCategoryTypeIdentifier,
|
|
7
|
-
} from '../native-types'
|
|
8
|
-
|
|
9
|
-
export type QuerySourcesFn = <
|
|
10
|
-
TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier
|
|
11
|
-
>(
|
|
12
|
-
identifier: TIdentifier
|
|
13
|
-
) => Promise<readonly HKSource[]>;
|
|
14
|
-
|
|
15
|
-
const querySources: QuerySourcesFn = async (identifier) => {
|
|
16
|
-
const quantitySamples = await Native.querySources(identifier)
|
|
17
|
-
|
|
18
|
-
return quantitySamples
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default querySources
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
export const queryStateOfMindSamples = async ({
|
|
4
|
-
from, to, limit, ascending,
|
|
5
|
-
}: { readonly from?: Date; readonly to?: Date; readonly limit?: number; readonly ascending?: boolean } = {}) => {
|
|
6
|
-
const fromString = (from || new Date(0)).toISOString()
|
|
7
|
-
const toString = (to || new Date(0)).toISOString()
|
|
8
|
-
|
|
9
|
-
const res = await Native.queryStateOfMindSamples(fromString, toString, limit ?? 0, ascending ?? false)
|
|
10
|
-
|
|
11
|
-
return res
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default queryStateOfMindSamples
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import ensureUnit from './ensureUnit'
|
|
2
|
-
import Native from '../native-types'
|
|
3
|
-
|
|
4
|
-
import type {
|
|
5
|
-
HKQuantityTypeIdentifier,
|
|
6
|
-
HKStatisticsOptions,
|
|
7
|
-
UnitForIdentifier,
|
|
8
|
-
IntervalComponents,
|
|
9
|
-
} from '../native-types'
|
|
10
|
-
|
|
11
|
-
async function queryStatisticsCollectionForQuantity<
|
|
12
|
-
TIdentifier extends HKQuantityTypeIdentifier,
|
|
13
|
-
TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>
|
|
14
|
-
>(
|
|
15
|
-
identifier: TIdentifier,
|
|
16
|
-
options: readonly HKStatisticsOptions[],
|
|
17
|
-
anchorDate: Date,
|
|
18
|
-
intervalComponents: IntervalComponents,
|
|
19
|
-
startDate: Date,
|
|
20
|
-
endDate: Date,
|
|
21
|
-
unit?: TUnit,
|
|
22
|
-
) {
|
|
23
|
-
const actualUnit = await ensureUnit(identifier, unit)
|
|
24
|
-
|
|
25
|
-
const rawResponse = await Native.queryStatisticsCollectionForQuantity(
|
|
26
|
-
identifier,
|
|
27
|
-
actualUnit,
|
|
28
|
-
options,
|
|
29
|
-
anchorDate.toISOString(),
|
|
30
|
-
intervalComponents,
|
|
31
|
-
startDate.toISOString(),
|
|
32
|
-
endDate.toISOString(),
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
return rawResponse
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default queryStatisticsCollectionForQuantity
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import ensureUnit from './ensureUnit'
|
|
2
|
-
import Native from '../native-types'
|
|
3
|
-
|
|
4
|
-
import type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types'
|
|
5
|
-
|
|
6
|
-
async function queryStatisticsForQuantity<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>(
|
|
7
|
-
identifier: TIdentifier,
|
|
8
|
-
options: readonly HKStatisticsOptions[],
|
|
9
|
-
from: Date,
|
|
10
|
-
to?: Date,
|
|
11
|
-
unit?: TUnit,
|
|
12
|
-
) {
|
|
13
|
-
const actualUnit = await ensureUnit(identifier, unit)
|
|
14
|
-
const toDate = to || new Date()
|
|
15
|
-
const { mostRecentQuantityDateInterval, ...rawResponse } = await Native.queryStatisticsForQuantity(
|
|
16
|
-
identifier,
|
|
17
|
-
actualUnit,
|
|
18
|
-
from.toISOString(),
|
|
19
|
-
toDate.toISOString(),
|
|
20
|
-
options,
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
const response = {
|
|
24
|
-
...rawResponse,
|
|
25
|
-
...(mostRecentQuantityDateInterval
|
|
26
|
-
? {
|
|
27
|
-
mostRecentQuantityDateInterval: {
|
|
28
|
-
from: new Date(mostRecentQuantityDateInterval.from),
|
|
29
|
-
to: new Date(mostRecentQuantityDateInterval.to),
|
|
30
|
-
},
|
|
31
|
-
}
|
|
32
|
-
: {}),
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return response
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default queryStatisticsForQuantity
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import deserializeWorkout from './deserializeWorkout'
|
|
2
|
-
import getPreferredUnitsTyped from './getPreferredUnitsTyped'
|
|
3
|
-
import prepareOptions from './prepareOptions'
|
|
4
|
-
import Native from '../native-types'
|
|
5
|
-
|
|
6
|
-
import type {
|
|
7
|
-
EnergyUnit, LengthUnit,
|
|
8
|
-
} from '../native-types'
|
|
9
|
-
import type {
|
|
10
|
-
DeletedWorkoutSampleRaw, HKWorkout, QueryWorkoutsOptions,
|
|
11
|
-
} from '../types'
|
|
12
|
-
|
|
13
|
-
export type QueryWorkoutSamplesWithAnchorResponse<
|
|
14
|
-
TEnergy extends EnergyUnit,
|
|
15
|
-
TDistance extends LengthUnit
|
|
16
|
-
> = {
|
|
17
|
-
readonly samples: readonly HKWorkout<TEnergy, TDistance>[],
|
|
18
|
-
readonly deletedSamples: readonly DeletedWorkoutSampleRaw[],
|
|
19
|
-
readonly newAnchor: string
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
async function queryCategorySamplesWithAnchor<
|
|
23
|
-
TEnergy extends EnergyUnit,
|
|
24
|
-
TDistance extends LengthUnit
|
|
25
|
-
>(
|
|
26
|
-
options: Omit<QueryWorkoutsOptions<TEnergy, TDistance>, 'ascending'>,
|
|
27
|
-
): Promise<QueryWorkoutSamplesWithAnchorResponse<TEnergy, TDistance>> {
|
|
28
|
-
const opts = prepareOptions(options)
|
|
29
|
-
const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)
|
|
30
|
-
const raw = await Native.queryWorkoutSamplesWithAnchor(
|
|
31
|
-
energyUnit,
|
|
32
|
-
distanceUnit,
|
|
33
|
-
opts.from,
|
|
34
|
-
opts.to,
|
|
35
|
-
opts.limit,
|
|
36
|
-
opts.anchor,
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
samples: raw.samples.map(deserializeWorkout),
|
|
41
|
-
deletedSamples: raw.deletedSamples,
|
|
42
|
-
newAnchor: raw.newAnchor,
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default queryCategorySamplesWithAnchor
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import deserializeWorkout from './deserializeWorkout'
|
|
2
|
-
import getPreferredUnitsTyped from './getPreferredUnitsTyped'
|
|
3
|
-
import prepareOptions from './prepareOptions'
|
|
4
|
-
import Native from '../native-types'
|
|
5
|
-
|
|
6
|
-
import type { EnergyUnit, LengthUnit } from '../native-types'
|
|
7
|
-
import type { QueryWorkoutsOptions } from '../types'
|
|
8
|
-
|
|
9
|
-
async function queryWorkouts<
|
|
10
|
-
TEnergy extends EnergyUnit,
|
|
11
|
-
TDistance extends LengthUnit
|
|
12
|
-
>(options: QueryWorkoutsOptions<TEnergy, TDistance>) {
|
|
13
|
-
const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)
|
|
14
|
-
const opts = prepareOptions(options)
|
|
15
|
-
|
|
16
|
-
const workouts = await Native.queryWorkoutSamples(
|
|
17
|
-
energyUnit,
|
|
18
|
-
distanceUnit,
|
|
19
|
-
opts.from,
|
|
20
|
-
opts.to,
|
|
21
|
-
opts.limit,
|
|
22
|
-
opts.ascending,
|
|
23
|
-
)
|
|
24
|
-
|
|
25
|
-
return workouts.map(deserializeWorkout)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default queryWorkouts
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
HealthkitReadAuthorization, HealthkitWriteAuthorization, ReadPermissions, WritePermissions,
|
|
5
|
-
} from '../native-types'
|
|
6
|
-
|
|
7
|
-
/** See https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization */
|
|
8
|
-
const requestAuthorization = async (
|
|
9
|
-
read: readonly HealthkitReadAuthorization[],
|
|
10
|
-
write: readonly HealthkitWriteAuthorization[] = [],
|
|
11
|
-
): Promise<boolean> => {
|
|
12
|
-
const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)
|
|
13
|
-
|
|
14
|
-
const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)
|
|
15
|
-
|
|
16
|
-
return Native.requestAuthorization(writePermissions, readPermissions)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default requestAuthorization
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, MetadataMapperForCategoryIdentifier } from '../native-types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
7
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
8
|
-
*/
|
|
9
|
-
async function saveCategorySample<T extends HKCategoryTypeIdentifier>(
|
|
10
|
-
identifier: T,
|
|
11
|
-
value: HKCategoryValueForIdentifier<T>,
|
|
12
|
-
options?: {
|
|
13
|
-
readonly start?: Date;
|
|
14
|
-
readonly end?: Date;
|
|
15
|
-
readonly metadata?: MetadataMapperForCategoryIdentifier<T>;
|
|
16
|
-
},
|
|
17
|
-
) {
|
|
18
|
-
const start = options?.start || options?.end || new Date()
|
|
19
|
-
const end = options?.end || options?.start || new Date()
|
|
20
|
-
const metadata = options?.metadata || {}
|
|
21
|
-
|
|
22
|
-
return Native.saveCategorySample(
|
|
23
|
-
identifier,
|
|
24
|
-
value,
|
|
25
|
-
start.toISOString(),
|
|
26
|
-
end.toISOString(),
|
|
27
|
-
metadata || {},
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export default saveCategorySample
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import ensureMetadata from './ensureMetadata'
|
|
2
|
-
import Native from '../native-types'
|
|
3
|
-
|
|
4
|
-
import type { MetadataMapperForCorrelationIdentifier, HKCorrelationTypeIdentifier } from '../native-types'
|
|
5
|
-
import type { HKCategorySampleForSaving, HKQuantitySampleForSaving } from '../types'
|
|
6
|
-
|
|
7
|
-
async function saveCorrelationSample<
|
|
8
|
-
TIdentifier extends HKCorrelationTypeIdentifier,
|
|
9
|
-
TSamples extends readonly(
|
|
10
|
-
| HKCategorySampleForSaving
|
|
11
|
-
| HKQuantitySampleForSaving
|
|
12
|
-
)[]
|
|
13
|
-
>(
|
|
14
|
-
typeIdentifier: TIdentifier,
|
|
15
|
-
samples: TSamples,
|
|
16
|
-
options?: {
|
|
17
|
-
readonly start?: Date;
|
|
18
|
-
readonly end?: Date;
|
|
19
|
-
readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
20
|
-
},
|
|
21
|
-
) {
|
|
22
|
-
const start = (options?.start || new Date()).toISOString()
|
|
23
|
-
const end = (options?.end || new Date()).toISOString()
|
|
24
|
-
|
|
25
|
-
return Native.saveCorrelationSample(
|
|
26
|
-
typeIdentifier,
|
|
27
|
-
samples.map((sample) => {
|
|
28
|
-
const { startDate, endDate, ...rest } = sample
|
|
29
|
-
const updatedSample = {
|
|
30
|
-
...rest,
|
|
31
|
-
...(startDate && { startDate: new Date(startDate).toISOString() }),
|
|
32
|
-
...(endDate && { endDate: new Date(endDate).toISOString() }),
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return { ...updatedSample, metadata: ensureMetadata(sample.metadata) }
|
|
36
|
-
}),
|
|
37
|
-
start,
|
|
38
|
-
end,
|
|
39
|
-
ensureMetadata(options?.metadata),
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default saveCorrelationSample
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { MetadataMapperForQuantityIdentifier, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
|
|
4
|
-
|
|
5
|
-
async function saveQuantitySample<TType extends HKQuantityTypeIdentifier>(
|
|
6
|
-
identifier: TType,
|
|
7
|
-
unit: UnitForIdentifier<TType>,
|
|
8
|
-
value: number,
|
|
9
|
-
options?: {
|
|
10
|
-
readonly start?: Date;
|
|
11
|
-
readonly end?: Date;
|
|
12
|
-
readonly metadata?: MetadataMapperForQuantityIdentifier<TType>;
|
|
13
|
-
},
|
|
14
|
-
) {
|
|
15
|
-
const start = options?.start || options?.end || new Date()
|
|
16
|
-
const end = options?.end || options?.start || new Date()
|
|
17
|
-
const metadata = options?.metadata || {}
|
|
18
|
-
|
|
19
|
-
return Native.saveQuantitySample(
|
|
20
|
-
identifier,
|
|
21
|
-
unit,
|
|
22
|
-
value,
|
|
23
|
-
start.toISOString(),
|
|
24
|
-
end.toISOString(),
|
|
25
|
-
metadata,
|
|
26
|
-
)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default saveQuantitySample
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { HKStateOfMindSampleRaw } from '../native-types'
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind Saving state of mind samples (Apple Docs)}
|
|
7
|
-
* @description Saves a state of mind sample to HealthKit, including kind, mood, valence, labels (optional), and associations (optional).
|
|
8
|
-
*/
|
|
9
|
-
async function saveStateOfMindSample(
|
|
10
|
-
options: Omit<
|
|
11
|
-
HKStateOfMindSampleRaw,
|
|
12
|
-
| 'uuid'
|
|
13
|
-
| 'valenceClassification'
|
|
14
|
-
| 'startDate'
|
|
15
|
-
| 'endDate'
|
|
16
|
-
| 'labels'
|
|
17
|
-
| 'associations'
|
|
18
|
-
| 'device'
|
|
19
|
-
| 'sourceRevision'
|
|
20
|
-
> & {
|
|
21
|
-
// allow the user to provide a Date instead of expecting them to provide date.toISOString()
|
|
22
|
-
readonly date: Date
|
|
23
|
-
// omitting then redeclaring these in order to make them optional
|
|
24
|
-
readonly associations?: HKStateOfMindSampleRaw['associations']
|
|
25
|
-
readonly labels?: HKStateOfMindSampleRaw['labels']
|
|
26
|
-
},
|
|
27
|
-
) {
|
|
28
|
-
return Native.saveStateOfMindSample(
|
|
29
|
-
options.date.toISOString(),
|
|
30
|
-
options.kind,
|
|
31
|
-
options.valence,
|
|
32
|
-
options.labels || [],
|
|
33
|
-
options.associations || [],
|
|
34
|
-
options.metadata || {},
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export default saveStateOfMindSample
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
|
|
3
|
-
import type { CLLocationForSaving } from '../types'
|
|
4
|
-
|
|
5
|
-
async function saveWorkoutRoute(
|
|
6
|
-
workoutUUID: string,
|
|
7
|
-
locations: readonly CLLocationForSaving[],
|
|
8
|
-
) {
|
|
9
|
-
return Native.saveWorkoutRoute(
|
|
10
|
-
workoutUUID,
|
|
11
|
-
locations.map((location) => {
|
|
12
|
-
const { timestamp, ...rest } = location
|
|
13
|
-
return {
|
|
14
|
-
...rest,
|
|
15
|
-
...(timestamp ? { timestamp: new Date(timestamp).toISOString() } : { timestamp: '' }),
|
|
16
|
-
}
|
|
17
|
-
}),
|
|
18
|
-
)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export default saveWorkoutRoute
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import ensureMetadata from './ensureMetadata'
|
|
2
|
-
import ensureTotals from './ensureTotals'
|
|
3
|
-
import Native from '../native-types'
|
|
4
|
-
|
|
5
|
-
import type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'
|
|
6
|
-
import type { HKQuantitySampleForSaving } from '../types'
|
|
7
|
-
|
|
8
|
-
async function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(
|
|
9
|
-
typeIdentifier: TIdentifier,
|
|
10
|
-
quantities: readonly HKQuantitySampleForSaving[],
|
|
11
|
-
_start: Date,
|
|
12
|
-
options?: {
|
|
13
|
-
readonly end?: Date;
|
|
14
|
-
readonly totals?: {
|
|
15
|
-
readonly distance?: number;
|
|
16
|
-
readonly energyBurned?: number;
|
|
17
|
-
}
|
|
18
|
-
readonly metadata?: HKWorkoutMetadata;
|
|
19
|
-
},
|
|
20
|
-
) {
|
|
21
|
-
const start = _start.toISOString()
|
|
22
|
-
const end = (options?.end || new Date()).toISOString()
|
|
23
|
-
|
|
24
|
-
return Native.saveWorkoutSample(
|
|
25
|
-
typeIdentifier,
|
|
26
|
-
quantities.map((quantity) => {
|
|
27
|
-
const { startDate, endDate, ...rest } = quantity
|
|
28
|
-
const updatedQuantity = {
|
|
29
|
-
...rest,
|
|
30
|
-
...(startDate && { startDate: startDate.toISOString() }),
|
|
31
|
-
...(endDate && { endDate: endDate.toISOString() }),
|
|
32
|
-
}
|
|
33
|
-
return { ...updatedQuantity, metadata: ensureMetadata(quantity.metadata) }
|
|
34
|
-
}),
|
|
35
|
-
start,
|
|
36
|
-
end,
|
|
37
|
-
ensureTotals(options?.totals),
|
|
38
|
-
ensureMetadata(options?.metadata),
|
|
39
|
-
)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default saveWorkoutSample
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import serializeDate from './serializeDate'
|
|
2
|
-
|
|
3
|
-
describe('serializeDate', () => {
|
|
4
|
-
it('should serialize zero date', () => {
|
|
5
|
-
expect(serializeDate(new Date(0))).toBe('1970-01-01T00:00:00.000Z')
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
it('should serialize date', () => {
|
|
9
|
-
const date = new Date()
|
|
10
|
-
expect(serializeDate(date)).toBe(date.toISOString())
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
it('should serialize null date', () => {
|
|
14
|
-
expect(serializeDate(null)).toBe('1969-12-31T23:59:59.999Z')
|
|
15
|
-
})
|
|
16
|
-
})
|