@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,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.queryStateOfMindSamples = exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const queryStateOfMindSamples = async ({
|
|
10
|
-
from,
|
|
11
|
-
to,
|
|
12
|
-
limit,
|
|
13
|
-
ascending
|
|
14
|
-
} = {}) => {
|
|
15
|
-
const fromString = (from || new Date(0)).toISOString();
|
|
16
|
-
const toString = (to || new Date(0)).toISOString();
|
|
17
|
-
const res = await _nativeTypes.default.queryStateOfMindSamples(fromString, toString, limit ?? 0, ascending ?? false);
|
|
18
|
-
return res;
|
|
19
|
-
};
|
|
20
|
-
exports.queryStateOfMindSamples = queryStateOfMindSamples;
|
|
21
|
-
var _default = exports.default = queryStateOfMindSamples;
|
|
22
|
-
//# sourceMappingURL=queryStateOfMindSamples.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","queryStateOfMindSamples","from","to","limit","ascending","fromString","Date","toISOString","toString","res","Native","exports","_default"],"sources":["queryStateOfMindSamples.ts"],"sourcesContent":["import Native from '../native-types'\n\nexport const queryStateOfMindSamples = async ({\n from, to, limit, ascending,\n}: { readonly from?: Date; readonly to?: Date; readonly limit?: number; readonly ascending?: boolean } = {}) => {\n const fromString = (from || new Date(0)).toISOString()\n const toString = (to || new Date(0)).toISOString()\n\n const res = await Native.queryStateOfMindSamples(fromString, toString, limit ?? 0, ascending ?? false)\n\n return res\n}\n\nexport default queryStateOfMindSamples\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE7B,MAAMG,uBAAuB,GAAG,MAAAA,CAAO;EAC5CC,IAAI;EAAEC,EAAE;EAAEC,KAAK;EAAEC;AACkF,CAAC,GAAG,CAAC,CAAC,KAAK;EAC9G,MAAMC,UAAU,GAAG,CAACJ,IAAI,IAAI,IAAIK,IAAI,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EACtD,MAAMC,QAAQ,GAAG,CAACN,EAAE,IAAI,IAAII,IAAI,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EAElD,MAAME,GAAG,GAAG,MAAMC,oBAAM,CAACV,uBAAuB,CAACK,UAAU,EAAEG,QAAQ,EAAEL,KAAK,IAAI,CAAC,EAAEC,SAAS,IAAI,KAAK,CAAC;EAEtG,OAAOK,GAAG;AACZ,CAAC;AAAAE,OAAA,CAAAX,uBAAA,GAAAA,uBAAA;AAAA,IAAAY,QAAA,GAAAD,OAAA,CAAAZ,OAAA,GAEcC,uBAAuB","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _ensureUnit = _interopRequireDefault(require("./ensureUnit"));
|
|
8
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
async function queryStatisticsCollectionForQuantity(identifier, options, anchorDate, intervalComponents, startDate, endDate, unit) {
|
|
11
|
-
const actualUnit = await (0, _ensureUnit.default)(identifier, unit);
|
|
12
|
-
const rawResponse = await _nativeTypes.default.queryStatisticsCollectionForQuantity(identifier, actualUnit, options, anchorDate.toISOString(), intervalComponents, startDate.toISOString(), endDate.toISOString());
|
|
13
|
-
return rawResponse;
|
|
14
|
-
}
|
|
15
|
-
var _default = exports.default = queryStatisticsCollectionForQuantity;
|
|
16
|
-
//# sourceMappingURL=queryStatisticsCollectionForQuantity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_ensureUnit","_interopRequireDefault","require","_nativeTypes","e","__esModule","default","queryStatisticsCollectionForQuantity","identifier","options","anchorDate","intervalComponents","startDate","endDate","unit","actualUnit","ensureUnit","rawResponse","Native","toISOString","_default","exports"],"sources":["queryStatisticsCollectionForQuantity.ts"],"sourcesContent":["import ensureUnit from './ensureUnit'\nimport Native from '../native-types'\n\nimport type {\n HKQuantityTypeIdentifier,\n HKStatisticsOptions,\n UnitForIdentifier,\n IntervalComponents,\n} from '../native-types'\n\nasync function queryStatisticsCollectionForQuantity<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n options: readonly HKStatisticsOptions[],\n anchorDate: Date,\n intervalComponents: IntervalComponents,\n startDate: Date,\n endDate: Date,\n unit?: TUnit,\n) {\n const actualUnit = await ensureUnit(identifier, unit)\n\n const rawResponse = await Native.queryStatisticsCollectionForQuantity(\n identifier,\n actualUnit,\n options,\n anchorDate.toISOString(),\n intervalComponents,\n startDate.toISOString(),\n endDate.toISOString(),\n )\n\n return rawResponse\n}\n\nexport default queryStatisticsCollectionForQuantity\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AASpC,eAAeG,oCAAoCA,CAIjDC,UAAuB,EACvBC,OAAuC,EACvCC,UAAgB,EAChBC,kBAAsC,EACtCC,SAAe,EACfC,OAAa,EACbC,IAAY,EACZ;EACA,MAAMC,UAAU,GAAG,MAAM,IAAAC,mBAAU,EAACR,UAAU,EAAEM,IAAI,CAAC;EAErD,MAAMG,WAAW,GAAG,MAAMC,oBAAM,CAACX,oCAAoC,CACnEC,UAAU,EACVO,UAAU,EACVN,OAAO,EACPC,UAAU,CAACS,WAAW,CAAC,CAAC,EACxBR,kBAAkB,EAClBC,SAAS,CAACO,WAAW,CAAC,CAAC,EACvBN,OAAO,CAACM,WAAW,CAAC,CACtB,CAAC;EAED,OAAOF,WAAW;AACpB;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAf,OAAA,GAEcC,oCAAoC","ignoreList":[]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _ensureUnit = _interopRequireDefault(require("./ensureUnit"));
|
|
8
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
async function queryStatisticsForQuantity(identifier, options, from, to, unit) {
|
|
11
|
-
const actualUnit = await (0, _ensureUnit.default)(identifier, unit);
|
|
12
|
-
const toDate = to || new Date();
|
|
13
|
-
const {
|
|
14
|
-
mostRecentQuantityDateInterval,
|
|
15
|
-
...rawResponse
|
|
16
|
-
} = await _nativeTypes.default.queryStatisticsForQuantity(identifier, actualUnit, from.toISOString(), toDate.toISOString(), options);
|
|
17
|
-
const response = {
|
|
18
|
-
...rawResponse,
|
|
19
|
-
...(mostRecentQuantityDateInterval ? {
|
|
20
|
-
mostRecentQuantityDateInterval: {
|
|
21
|
-
from: new Date(mostRecentQuantityDateInterval.from),
|
|
22
|
-
to: new Date(mostRecentQuantityDateInterval.to)
|
|
23
|
-
}
|
|
24
|
-
} : {})
|
|
25
|
-
};
|
|
26
|
-
return response;
|
|
27
|
-
}
|
|
28
|
-
var _default = exports.default = queryStatisticsForQuantity;
|
|
29
|
-
//# sourceMappingURL=queryStatisticsForQuantity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_ensureUnit","_interopRequireDefault","require","_nativeTypes","e","__esModule","default","queryStatisticsForQuantity","identifier","options","from","to","unit","actualUnit","ensureUnit","toDate","Date","mostRecentQuantityDateInterval","rawResponse","Native","toISOString","response","_default","exports"],"sources":["queryStatisticsForQuantity.ts"],"sourcesContent":["import ensureUnit from './ensureUnit'\nimport Native from '../native-types'\n\nimport type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types'\n\nasync function queryStatisticsForQuantity<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>(\n identifier: TIdentifier,\n options: readonly HKStatisticsOptions[],\n from: Date,\n to?: Date,\n unit?: TUnit,\n) {\n const actualUnit = await ensureUnit(identifier, unit)\n const toDate = to || new Date()\n const { mostRecentQuantityDateInterval, ...rawResponse } = await Native.queryStatisticsForQuantity(\n identifier,\n actualUnit,\n from.toISOString(),\n toDate.toISOString(),\n options,\n )\n\n const response = {\n ...rawResponse,\n ...(mostRecentQuantityDateInterval\n ? {\n mostRecentQuantityDateInterval: {\n from: new Date(mostRecentQuantityDateInterval.from),\n to: new Date(mostRecentQuantityDateInterval.to),\n },\n }\n : {}),\n }\n\n return response\n}\n\nexport default queryStatisticsForQuantity\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC,eAAeG,0BAA0BA,CACvCC,UAAuB,EACvBC,OAAuC,EACvCC,IAAU,EACVC,EAAS,EACTC,IAAY,EACZ;EACA,MAAMC,UAAU,GAAG,MAAM,IAAAC,mBAAU,EAACN,UAAU,EAAEI,IAAI,CAAC;EACrD,MAAMG,MAAM,GAAGJ,EAAE,IAAI,IAAIK,IAAI,CAAC,CAAC;EAC/B,MAAM;IAAEC,8BAA8B;IAAE,GAAGC;EAAY,CAAC,GAAG,MAAMC,oBAAM,CAACZ,0BAA0B,CAChGC,UAAU,EACVK,UAAU,EACVH,IAAI,CAACU,WAAW,CAAC,CAAC,EAClBL,MAAM,CAACK,WAAW,CAAC,CAAC,EACpBX,OACF,CAAC;EAED,MAAMY,QAAQ,GAAG;IACf,GAAGH,WAAW;IACd,IAAID,8BAA8B,GAC9B;MACAA,8BAA8B,EAAE;QAC9BP,IAAI,EAAE,IAAIM,IAAI,CAACC,8BAA8B,CAACP,IAAI,CAAC;QACnDC,EAAE,EAAE,IAAIK,IAAI,CAACC,8BAA8B,CAACN,EAAE;MAChD;IACF,CAAC,GACC,CAAC,CAAC;EACR,CAAC;EAED,OAAOU,QAAQ;AACjB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjB,OAAA,GAEcC,0BAA0B","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _deserializeWorkout = _interopRequireDefault(require("./deserializeWorkout"));
|
|
8
|
-
var _getPreferredUnitsTyped = _interopRequireDefault(require("./getPreferredUnitsTyped"));
|
|
9
|
-
var _prepareOptions = _interopRequireDefault(require("./prepareOptions"));
|
|
10
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
async function queryCategorySamplesWithAnchor(options) {
|
|
13
|
-
const opts = (0, _prepareOptions.default)(options);
|
|
14
|
-
const {
|
|
15
|
-
energyUnit,
|
|
16
|
-
distanceUnit
|
|
17
|
-
} = await (0, _getPreferredUnitsTyped.default)(options);
|
|
18
|
-
const raw = await _nativeTypes.default.queryWorkoutSamplesWithAnchor(energyUnit, distanceUnit, opts.from, opts.to, opts.limit, opts.anchor);
|
|
19
|
-
return {
|
|
20
|
-
samples: raw.samples.map(_deserializeWorkout.default),
|
|
21
|
-
deletedSamples: raw.deletedSamples,
|
|
22
|
-
newAnchor: raw.newAnchor
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = queryCategorySamplesWithAnchor;
|
|
26
|
-
//# sourceMappingURL=queryWorkoutSamplesWithAnchor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_deserializeWorkout","_interopRequireDefault","require","_getPreferredUnitsTyped","_prepareOptions","_nativeTypes","e","__esModule","default","queryCategorySamplesWithAnchor","options","opts","prepareOptions","energyUnit","distanceUnit","getPreferredUnitsTyped","raw","Native","queryWorkoutSamplesWithAnchor","from","to","limit","anchor","samples","map","deserializeWorkout","deletedSamples","newAnchor","_default","exports"],"sources":["queryWorkoutSamplesWithAnchor.ts"],"sourcesContent":["import deserializeWorkout from './deserializeWorkout'\nimport getPreferredUnitsTyped from './getPreferredUnitsTyped'\nimport prepareOptions from './prepareOptions'\nimport Native from '../native-types'\n\nimport type {\n EnergyUnit, LengthUnit,\n} from '../native-types'\nimport type {\n DeletedWorkoutSampleRaw, HKWorkout, QueryWorkoutsOptions,\n} from '../types'\n\nexport type QueryWorkoutSamplesWithAnchorResponse<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n> = {\n readonly samples: readonly HKWorkout<TEnergy, TDistance>[],\n readonly deletedSamples: readonly DeletedWorkoutSampleRaw[],\n readonly newAnchor: string\n}\n\nasync function queryCategorySamplesWithAnchor<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(\n options: Omit<QueryWorkoutsOptions<TEnergy, TDistance>, 'ascending'>,\n): Promise<QueryWorkoutSamplesWithAnchorResponse<TEnergy, TDistance>> {\n const opts = prepareOptions(options)\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)\n const raw = await Native.queryWorkoutSamplesWithAnchor(\n energyUnit,\n distanceUnit,\n opts.from,\n opts.to,\n opts.limit,\n opts.anchor,\n )\n\n return {\n samples: raw.samples.map(deserializeWorkout),\n deletedSamples: raw.deletedSamples,\n newAnchor: raw.newAnchor,\n }\n}\n\nexport default queryCategorySamplesWithAnchor\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAkBpC,eAAeG,8BAA8BA,CAI3CC,OAAoE,EACA;EACpE,MAAMC,IAAI,GAAG,IAAAC,uBAAc,EAACF,OAAO,CAAC;EACpC,MAAM;IAAEG,UAAU;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,+BAAsB,EAACL,OAAO,CAAC;EAC1E,MAAMM,GAAG,GAAG,MAAMC,oBAAM,CAACC,6BAA6B,CACpDL,UAAU,EACVC,YAAY,EACZH,IAAI,CAACQ,IAAI,EACTR,IAAI,CAACS,EAAE,EACPT,IAAI,CAACU,KAAK,EACVV,IAAI,CAACW,MACP,CAAC;EAED,OAAO;IACLC,OAAO,EAAEP,GAAG,CAACO,OAAO,CAACC,GAAG,CAACC,2BAAkB,CAAC;IAC5CC,cAAc,EAAEV,GAAG,CAACU,cAAc;IAClCC,SAAS,EAAEX,GAAG,CAACW;EACjB,CAAC;AACH;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEcC,8BAA8B","ignoreList":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _deserializeWorkout = _interopRequireDefault(require("./deserializeWorkout"));
|
|
8
|
-
var _getPreferredUnitsTyped = _interopRequireDefault(require("./getPreferredUnitsTyped"));
|
|
9
|
-
var _prepareOptions = _interopRequireDefault(require("./prepareOptions"));
|
|
10
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
async function queryWorkouts(options) {
|
|
13
|
-
const {
|
|
14
|
-
energyUnit,
|
|
15
|
-
distanceUnit
|
|
16
|
-
} = await (0, _getPreferredUnitsTyped.default)(options);
|
|
17
|
-
const opts = (0, _prepareOptions.default)(options);
|
|
18
|
-
const workouts = await _nativeTypes.default.queryWorkoutSamples(energyUnit, distanceUnit, opts.from, opts.to, opts.limit, opts.ascending);
|
|
19
|
-
return workouts.map(_deserializeWorkout.default);
|
|
20
|
-
}
|
|
21
|
-
var _default = exports.default = queryWorkouts;
|
|
22
|
-
//# sourceMappingURL=queryWorkouts.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_deserializeWorkout","_interopRequireDefault","require","_getPreferredUnitsTyped","_prepareOptions","_nativeTypes","e","__esModule","default","queryWorkouts","options","energyUnit","distanceUnit","getPreferredUnitsTyped","opts","prepareOptions","workouts","Native","queryWorkoutSamples","from","to","limit","ascending","map","deserializeWorkout","_default","exports"],"sources":["queryWorkouts.ts"],"sourcesContent":["import deserializeWorkout from './deserializeWorkout'\nimport getPreferredUnitsTyped from './getPreferredUnitsTyped'\nimport prepareOptions from './prepareOptions'\nimport Native from '../native-types'\n\nimport type { EnergyUnit, LengthUnit } from '../native-types'\nimport type { QueryWorkoutsOptions } from '../types'\n\nasync function queryWorkouts<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(options: QueryWorkoutsOptions<TEnergy, TDistance>) {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)\n const opts = prepareOptions(options)\n\n const workouts = await Native.queryWorkoutSamples(\n energyUnit,\n distanceUnit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return workouts.map(deserializeWorkout)\n}\n\nexport default queryWorkouts\n"],"mappings":";;;;;;AAAA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,YAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKpC,eAAeG,aAAaA,CAG1BC,OAAiD,EAAE;EACnD,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAG,MAAM,IAAAC,+BAAsB,EAACH,OAAO,CAAC;EAC1E,MAAMI,IAAI,GAAG,IAAAC,uBAAc,EAACL,OAAO,CAAC;EAEpC,MAAMM,QAAQ,GAAG,MAAMC,oBAAM,CAACC,mBAAmB,CAC/CP,UAAU,EACVC,YAAY,EACZE,IAAI,CAACK,IAAI,EACTL,IAAI,CAACM,EAAE,EACPN,IAAI,CAACO,KAAK,EACVP,IAAI,CAACQ,SACP,CAAC;EAED,OAAON,QAAQ,CAACO,GAAG,CAACC,2BAAkB,CAAC;AACzC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAEcC,aAAa","ignoreList":[]}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/** See https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization */
|
|
10
|
-
const requestAuthorization = async (read, write = []) => {
|
|
11
|
-
const readPermissions = read.reduce((obj, cur) => ({
|
|
12
|
-
...obj,
|
|
13
|
-
[cur]: true
|
|
14
|
-
}), {});
|
|
15
|
-
const writePermissions = write.reduce((obj, cur) => ({
|
|
16
|
-
...obj,
|
|
17
|
-
[cur]: true
|
|
18
|
-
}), {});
|
|
19
|
-
return _nativeTypes.default.requestAuthorization(writePermissions, readPermissions);
|
|
20
|
-
};
|
|
21
|
-
var _default = exports.default = requestAuthorization;
|
|
22
|
-
//# sourceMappingURL=requestAuthorization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","requestAuthorization","read","write","readPermissions","reduce","obj","cur","writePermissions","Native","_default","exports"],"sources":["requestAuthorization.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type {\n HealthkitReadAuthorization, HealthkitWriteAuthorization, ReadPermissions, WritePermissions,\n} from '../native-types'\n\n/** See https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization */\nconst requestAuthorization = async (\n read: readonly HealthkitReadAuthorization[],\n write: readonly HealthkitWriteAuthorization[] = [],\n): Promise<boolean> => {\n const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)\n\n const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)\n\n return Native.requestAuthorization(writePermissions, readPermissions)\n}\n\nexport default requestAuthorization\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMpC;AACA,MAAMG,oBAAoB,GAAG,MAAAA,CAC3BC,IAA2C,EAC3CC,KAA6C,GAAG,EAAE,KAC7B;EACrB,MAAMC,eAAe,GAAGF,IAAI,CAACG,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,MAAM;IAAE,GAAGD,GAAG;IAAE,CAACC,GAAG,GAAG;EAAK,CAAC,CAAC,EAAE,CAAC,CAAoB,CAAC;EAEnG,MAAMC,gBAAgB,GAAGL,KAAK,CAACE,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,MAAM;IAAE,GAAGD,GAAG;IAAE,CAACC,GAAG,GAAG;EAAK,CAAC,CAAC,EAAE,CAAC,CAAqB,CAAC;EAEtG,OAAOE,oBAAM,CAACR,oBAAoB,CAACO,gBAAgB,EAAEJ,eAAe,CAAC;AACvE,CAAC;AAAA,IAAAM,QAAA,GAAAC,OAAA,CAAAX,OAAA,GAEcC,oBAAoB","ignoreList":[]}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
11
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
12
|
-
*/
|
|
13
|
-
async function saveCategorySample(identifier, value, options) {
|
|
14
|
-
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
15
|
-
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
16
|
-
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
17
|
-
return _nativeTypes.default.saveCategorySample(identifier, value, start.toISOString(), end.toISOString(), metadata || {});
|
|
18
|
-
}
|
|
19
|
-
var _default = exports.default = saveCategorySample;
|
|
20
|
-
//# sourceMappingURL=saveCategorySample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","saveCategorySample","identifier","value","options","start","end","Date","metadata","Native","toISOString","_default","exports"],"sources":["saveCategorySample.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, MetadataMapperForCategoryIdentifier } from '../native-types'\n\n/**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}\n */\nasync function saveCategorySample<T extends HKCategoryTypeIdentifier>(\n identifier: T,\n value: HKCategoryValueForIdentifier<T>,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCategoryIdentifier<T>;\n },\n) {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveCategorySample(\n identifier,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata || {},\n )\n}\n\nexport default saveCategorySample\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC;AACA;AACA;AACA;AACA,eAAeG,kBAAkBA,CAC/BC,UAAa,EACbC,KAAsC,EACtCC,OAIC,EACD;EACA,MAAMC,KAAK,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,MAAID,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,KAAI,IAAIC,IAAI,CAAC,CAAC;EAC1D,MAAMD,GAAG,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,MAAIF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,KAAI,IAAIE,IAAI,CAAC,CAAC;EACxD,MAAMC,QAAQ,GAAG,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,QAAQ,KAAI,CAAC,CAAC;EAExC,OAAOC,oBAAM,CAACR,kBAAkB,CAC9BC,UAAU,EACVC,KAAK,EACLE,KAAK,CAACK,WAAW,CAAC,CAAC,EACnBJ,GAAG,CAACI,WAAW,CAAC,CAAC,EACjBF,QAAQ,IAAI,CAAC,CACf,CAAC;AACH;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEcC,kBAAkB","ignoreList":[]}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _ensureMetadata = _interopRequireDefault(require("./ensureMetadata"));
|
|
8
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
-
async function saveCorrelationSample(typeIdentifier, samples, options) {
|
|
11
|
-
const start = ((options === null || options === void 0 ? void 0 : options.start) || new Date()).toISOString();
|
|
12
|
-
const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
|
|
13
|
-
return _nativeTypes.default.saveCorrelationSample(typeIdentifier, samples.map(sample => {
|
|
14
|
-
const {
|
|
15
|
-
startDate,
|
|
16
|
-
endDate,
|
|
17
|
-
...rest
|
|
18
|
-
} = sample;
|
|
19
|
-
const updatedSample = {
|
|
20
|
-
...rest,
|
|
21
|
-
...(startDate && {
|
|
22
|
-
startDate: new Date(startDate).toISOString()
|
|
23
|
-
}),
|
|
24
|
-
...(endDate && {
|
|
25
|
-
endDate: new Date(endDate).toISOString()
|
|
26
|
-
})
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
...updatedSample,
|
|
30
|
-
metadata: (0, _ensureMetadata.default)(sample.metadata)
|
|
31
|
-
};
|
|
32
|
-
}), start, end, (0, _ensureMetadata.default)(options === null || options === void 0 ? void 0 : options.metadata));
|
|
33
|
-
}
|
|
34
|
-
var _default = exports.default = saveCorrelationSample;
|
|
35
|
-
//# sourceMappingURL=saveCorrelationSample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_ensureMetadata","_interopRequireDefault","require","_nativeTypes","e","__esModule","default","saveCorrelationSample","typeIdentifier","samples","options","start","Date","toISOString","end","Native","map","sample","startDate","endDate","rest","updatedSample","metadata","ensureMetadata","_default","exports"],"sources":["saveCorrelationSample.ts"],"sourcesContent":["import ensureMetadata from './ensureMetadata'\nimport Native from '../native-types'\n\nimport type { MetadataMapperForCorrelationIdentifier, HKCorrelationTypeIdentifier } from '../native-types'\nimport type { HKCategorySampleForSaving, HKQuantitySampleForSaving } from '../types'\n\nasync function saveCorrelationSample<\n TIdentifier extends HKCorrelationTypeIdentifier,\n TSamples extends readonly(\n | HKCategorySampleForSaving\n | HKQuantitySampleForSaving\n )[]\n>(\n typeIdentifier: TIdentifier,\n samples: TSamples,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;\n },\n) {\n const start = (options?.start || new Date()).toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveCorrelationSample(\n typeIdentifier,\n samples.map((sample) => {\n const { startDate, endDate, ...rest } = sample\n const updatedSample = {\n ...rest,\n ...(startDate && { startDate: new Date(startDate).toISOString() }),\n ...(endDate && { endDate: new Date(endDate).toISOString() }),\n }\n\n return { ...updatedSample, metadata: ensureMetadata(sample.metadata) }\n }),\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveCorrelationSample\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKpC,eAAeG,qBAAqBA,CAOlCC,cAA2B,EAC3BC,OAAiB,EACjBC,OAIC,EACD;EACA,MAAMC,KAAK,GAAG,CAAC,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,KAAI,IAAIC,IAAI,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EAC1D,MAAMC,GAAG,GAAG,CAAC,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,GAAG,KAAI,IAAIF,IAAI,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC;EAEtD,OAAOE,oBAAM,CAACR,qBAAqB,CACjCC,cAAc,EACdC,OAAO,CAACO,GAAG,CAAEC,MAAM,IAAK;IACtB,MAAM;MAAEC,SAAS;MAAEC,OAAO;MAAE,GAAGC;IAAK,CAAC,GAAGH,MAAM;IAC9C,MAAMI,aAAa,GAAG;MACpB,GAAGD,IAAI;MACP,IAAIF,SAAS,IAAI;QAAEA,SAAS,EAAE,IAAIN,IAAI,CAACM,SAAS,CAAC,CAACL,WAAW,CAAC;MAAE,CAAC,CAAC;MAClE,IAAIM,OAAO,IAAI;QAAEA,OAAO,EAAE,IAAIP,IAAI,CAACO,OAAO,CAAC,CAACN,WAAW,CAAC;MAAE,CAAC;IAC7D,CAAC;IAED,OAAO;MAAE,GAAGQ,aAAa;MAAEC,QAAQ,EAAE,IAAAC,uBAAc,EAACN,MAAM,CAACK,QAAQ;IAAE,CAAC;EACxE,CAAC,CAAC,EACFX,KAAK,EACLG,GAAG,EACH,IAAAS,uBAAc,EAACb,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEY,QAAQ,CAClC,CAAC;AACH;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAnB,OAAA,GAEcC,qBAAqB","ignoreList":[]}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
async function saveQuantitySample(identifier, unit, value, options) {
|
|
10
|
-
const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
|
|
11
|
-
const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
|
|
12
|
-
const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
|
|
13
|
-
return _nativeTypes.default.saveQuantitySample(identifier, unit, value, start.toISOString(), end.toISOString(), metadata);
|
|
14
|
-
}
|
|
15
|
-
var _default = exports.default = saveQuantitySample;
|
|
16
|
-
//# sourceMappingURL=saveQuantitySample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","saveQuantitySample","identifier","unit","value","options","start","end","Date","metadata","Native","toISOString","_default","exports"],"sources":["saveQuantitySample.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { MetadataMapperForQuantityIdentifier, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nasync function saveQuantitySample<TType extends HKQuantityTypeIdentifier>(\n identifier: TType,\n unit: UnitForIdentifier<TType>,\n value: number,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForQuantityIdentifier<TType>;\n },\n) {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveQuantitySample(\n identifier,\n unit,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata,\n )\n}\n\nexport default saveQuantitySample\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC,eAAeG,kBAAkBA,CAC/BC,UAAiB,EACjBC,IAA8B,EAC9BC,KAAa,EACbC,OAIC,EACD;EACA,MAAMC,KAAK,GAAG,CAAAD,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,MAAID,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,KAAI,IAAIC,IAAI,CAAC,CAAC;EAC1D,MAAMD,GAAG,GAAG,CAAAF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEE,GAAG,MAAIF,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEC,KAAK,KAAI,IAAIE,IAAI,CAAC,CAAC;EACxD,MAAMC,QAAQ,GAAG,CAAAJ,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEI,QAAQ,KAAI,CAAC,CAAC;EAExC,OAAOC,oBAAM,CAACT,kBAAkB,CAC9BC,UAAU,EACVC,IAAI,EACJC,KAAK,EACLE,KAAK,CAACK,WAAW,CAAC,CAAC,EACnBJ,GAAG,CAACI,WAAW,CAAC,CAAC,EACjBF,QACF,CAAC;AACH;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAb,OAAA,GAEcC,kBAAkB","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
/**
|
|
10
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind Saving state of mind samples (Apple Docs)}
|
|
11
|
-
* @description Saves a state of mind sample to HealthKit, including kind, mood, valence, labels (optional), and associations (optional).
|
|
12
|
-
*/
|
|
13
|
-
async function saveStateOfMindSample(options) {
|
|
14
|
-
return _nativeTypes.default.saveStateOfMindSample(options.date.toISOString(), options.kind, options.valence, options.labels || [], options.associations || [], options.metadata || {});
|
|
15
|
-
}
|
|
16
|
-
var _default = exports.default = saveStateOfMindSample;
|
|
17
|
-
//# sourceMappingURL=saveStateOfMindSample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","saveStateOfMindSample","options","Native","date","toISOString","kind","valence","labels","associations","metadata","_default","exports"],"sources":["saveStateOfMindSample.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKStateOfMindSampleRaw } from '../native-types'\n\n/**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmind Saving state of mind samples (Apple Docs)}\n * @description Saves a state of mind sample to HealthKit, including kind, mood, valence, labels (optional), and associations (optional).\n */\nasync function saveStateOfMindSample(\n options: Omit<\n HKStateOfMindSampleRaw,\n | 'uuid'\n | 'valenceClassification'\n | 'startDate'\n | 'endDate'\n | 'labels'\n | 'associations'\n | 'device'\n | 'sourceRevision'\n > & {\n // allow the user to provide a Date instead of expecting them to provide date.toISOString()\n readonly date: Date\n // omitting then redeclaring these in order to make them optional\n readonly associations?: HKStateOfMindSampleRaw['associations']\n readonly labels?: HKStateOfMindSampleRaw['labels']\n },\n) {\n return Native.saveStateOfMindSample(\n options.date.toISOString(),\n options.kind,\n options.valence,\n options.labels || [],\n options.associations || [],\n options.metadata || {},\n )\n}\n\nexport default saveStateOfMindSample\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC;AACA;AACA;AACA;AACA,eAAeG,qBAAqBA,CAClCC,OAgBC,EACD;EACA,OAAOC,oBAAM,CAACF,qBAAqB,CACjCC,OAAO,CAACE,IAAI,CAACC,WAAW,CAAC,CAAC,EAC1BH,OAAO,CAACI,IAAI,EACZJ,OAAO,CAACK,OAAO,EACfL,OAAO,CAACM,MAAM,IAAI,EAAE,EACpBN,OAAO,CAACO,YAAY,IAAI,EAAE,EAC1BP,OAAO,CAACQ,QAAQ,IAAI,CAAC,CACvB,CAAC;AACH;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEcC,qBAAqB","ignoreList":[]}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
async function saveWorkoutRoute(workoutUUID, locations) {
|
|
10
|
-
return _nativeTypes.default.saveWorkoutRoute(workoutUUID, locations.map(location => {
|
|
11
|
-
const {
|
|
12
|
-
timestamp,
|
|
13
|
-
...rest
|
|
14
|
-
} = location;
|
|
15
|
-
return {
|
|
16
|
-
...rest,
|
|
17
|
-
...(timestamp ? {
|
|
18
|
-
timestamp: new Date(timestamp).toISOString()
|
|
19
|
-
} : {
|
|
20
|
-
timestamp: ''
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
}));
|
|
24
|
-
}
|
|
25
|
-
var _default = exports.default = saveWorkoutRoute;
|
|
26
|
-
//# sourceMappingURL=saveWorkoutRoute.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","saveWorkoutRoute","workoutUUID","locations","Native","map","location","timestamp","rest","Date","toISOString","_default","exports"],"sources":["saveWorkoutRoute.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { CLLocationForSaving } from '../types'\n\nasync function saveWorkoutRoute(\n workoutUUID: string,\n locations: readonly CLLocationForSaving[],\n) {\n return Native.saveWorkoutRoute(\n workoutUUID,\n locations.map((location) => {\n const { timestamp, ...rest } = location\n return {\n ...rest,\n ...(timestamp ? { timestamp: new Date(timestamp).toISOString() } : { timestamp: '' }),\n }\n }),\n )\n}\n\nexport default saveWorkoutRoute\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC,eAAeG,gBAAgBA,CAC7BC,WAAmB,EACnBC,SAAyC,EACzC;EACA,OAAOC,oBAAM,CAACH,gBAAgB,CAC5BC,WAAW,EACXC,SAAS,CAACE,GAAG,CAAEC,QAAQ,IAAK;IAC1B,MAAM;MAAEC,SAAS;MAAE,GAAGC;IAAK,CAAC,GAAGF,QAAQ;IACvC,OAAO;MACL,GAAGE,IAAI;MACP,IAAID,SAAS,GAAG;QAAEA,SAAS,EAAE,IAAIE,IAAI,CAACF,SAAS,CAAC,CAACG,WAAW,CAAC;MAAE,CAAC,GAAG;QAAEH,SAAS,EAAE;MAAG,CAAC;IACtF,CAAC;EACH,CAAC,CACH,CAAC;AACH;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEcC,gBAAgB","ignoreList":[]}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _ensureMetadata = _interopRequireDefault(require("./ensureMetadata"));
|
|
8
|
-
var _ensureTotals = _interopRequireDefault(require("./ensureTotals"));
|
|
9
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
async function saveWorkoutSample(typeIdentifier, quantities, _start, options) {
|
|
12
|
-
const start = _start.toISOString();
|
|
13
|
-
const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
|
|
14
|
-
return _nativeTypes.default.saveWorkoutSample(typeIdentifier, quantities.map(quantity => {
|
|
15
|
-
const {
|
|
16
|
-
startDate,
|
|
17
|
-
endDate,
|
|
18
|
-
...rest
|
|
19
|
-
} = quantity;
|
|
20
|
-
const updatedQuantity = {
|
|
21
|
-
...rest,
|
|
22
|
-
...(startDate && {
|
|
23
|
-
startDate: startDate.toISOString()
|
|
24
|
-
}),
|
|
25
|
-
...(endDate && {
|
|
26
|
-
endDate: endDate.toISOString()
|
|
27
|
-
})
|
|
28
|
-
};
|
|
29
|
-
return {
|
|
30
|
-
...updatedQuantity,
|
|
31
|
-
metadata: (0, _ensureMetadata.default)(quantity.metadata)
|
|
32
|
-
};
|
|
33
|
-
}), start, end, (0, _ensureTotals.default)(options === null || options === void 0 ? void 0 : options.totals), (0, _ensureMetadata.default)(options === null || options === void 0 ? void 0 : options.metadata));
|
|
34
|
-
}
|
|
35
|
-
var _default = exports.default = saveWorkoutSample;
|
|
36
|
-
//# sourceMappingURL=saveWorkoutSample.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_ensureMetadata","_interopRequireDefault","require","_ensureTotals","_nativeTypes","e","__esModule","default","saveWorkoutSample","typeIdentifier","quantities","_start","options","start","toISOString","end","Date","Native","map","quantity","startDate","endDate","rest","updatedQuantity","metadata","ensureMetadata","ensureTotals","totals","_default","exports"],"sources":["saveWorkoutSample.ts"],"sourcesContent":["import ensureMetadata from './ensureMetadata'\nimport ensureTotals from './ensureTotals'\nimport Native from '../native-types'\n\nimport type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'\nimport type { HKQuantitySampleForSaving } from '../types'\n\nasync function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(\n typeIdentifier: TIdentifier,\n quantities: readonly HKQuantitySampleForSaving[],\n _start: Date,\n options?: {\n readonly end?: Date;\n readonly totals?: {\n readonly distance?: number;\n readonly energyBurned?: number;\n }\n readonly metadata?: HKWorkoutMetadata;\n },\n) {\n const start = _start.toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveWorkoutSample(\n typeIdentifier,\n quantities.map((quantity) => {\n const { startDate, endDate, ...rest } = quantity\n const updatedQuantity = {\n ...rest,\n ...(startDate && { startDate: startDate.toISOString() }),\n ...(endDate && { endDate: endDate.toISOString() }),\n }\n return { ...updatedQuantity, metadata: ensureMetadata(quantity.metadata) }\n }),\n start,\n end,\n ensureTotals(options?.totals),\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveWorkoutSample\n"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,YAAA,GAAAH,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKpC,eAAeG,iBAAiBA,CAC9BC,cAA2B,EAC3BC,UAAgD,EAChDC,MAAY,EACZC,OAOC,EACD;EACA,MAAMC,KAAK,GAAGF,MAAM,CAACG,WAAW,CAAC,CAAC;EAClC,MAAMC,GAAG,GAAG,CAAC,CAAAH,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEG,GAAG,KAAI,IAAIC,IAAI,CAAC,CAAC,EAAEF,WAAW,CAAC,CAAC;EAEtD,OAAOG,oBAAM,CAACT,iBAAiB,CAC7BC,cAAc,EACdC,UAAU,CAACQ,GAAG,CAAEC,QAAQ,IAAK;IAC3B,MAAM;MAAEC,SAAS;MAAEC,OAAO;MAAE,GAAGC;IAAK,CAAC,GAAGH,QAAQ;IAChD,MAAMI,eAAe,GAAG;MACtB,GAAGD,IAAI;MACP,IAAIF,SAAS,IAAI;QAAEA,SAAS,EAAEA,SAAS,CAACN,WAAW,CAAC;MAAE,CAAC,CAAC;MACxD,IAAIO,OAAO,IAAI;QAAEA,OAAO,EAAEA,OAAO,CAACP,WAAW,CAAC;MAAE,CAAC;IACnD,CAAC;IACD,OAAO;MAAE,GAAGS,eAAe;MAAEC,QAAQ,EAAE,IAAAC,uBAAc,EAACN,QAAQ,CAACK,QAAQ;IAAE,CAAC;EAC5E,CAAC,CAAC,EACFX,KAAK,EACLE,GAAG,EACH,IAAAW,qBAAY,EAACd,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEe,MAAM,CAAC,EAC7B,IAAAF,uBAAc,EAACb,OAAO,aAAPA,OAAO,uBAAPA,OAAO,CAAEY,QAAQ,CAClC,CAAC;AACH;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAtB,OAAA,GAEcC,iBAAiB","ignoreList":[]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
const serializeDate = date => (date || new Date(-1)).toISOString();
|
|
8
|
-
var _default = exports.default = serializeDate;
|
|
9
|
-
//# sourceMappingURL=serializeDate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["serializeDate","date","Date","toISOString","_default","exports","default"],"sources":["serializeDate.ts"],"sourcesContent":["const serializeDate = (date?: Date | null): string => (\n (date || new Date(-1)).toISOString()\n)\n\nexport default serializeDate\n"],"mappings":";;;;;;AAAA,MAAMA,aAAa,GAAIC,IAAkB,IACvC,CAACA,IAAI,IAAI,IAAIC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAEC,WAAW,CAAC,CACpC;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcN,aAAa","ignoreList":[]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _serializeDate = _interopRequireDefault(require("./serializeDate"));
|
|
4
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
5
|
-
describe('serializeDate', () => {
|
|
6
|
-
it('should serialize zero date', () => {
|
|
7
|
-
expect((0, _serializeDate.default)(new Date(0))).toBe('1970-01-01T00:00:00.000Z');
|
|
8
|
-
});
|
|
9
|
-
it('should serialize date', () => {
|
|
10
|
-
const date = new Date();
|
|
11
|
-
expect((0, _serializeDate.default)(date)).toBe(date.toISOString());
|
|
12
|
-
});
|
|
13
|
-
it('should serialize null date', () => {
|
|
14
|
-
expect((0, _serializeDate.default)(null)).toBe('1969-12-31T23:59:59.999Z');
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=serializeDate.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_serializeDate","_interopRequireDefault","require","e","__esModule","default","describe","it","expect","serializeDate","Date","toBe","date","toISOString"],"sources":["serializeDate.test.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\ndescribe('serializeDate', () => {\n it('should serialize zero date', () => {\n expect(serializeDate(new Date(0))).toBe('1970-01-01T00:00:00.000Z')\n })\n\n it('should serialize date', () => {\n const date = new Date()\n expect(serializeDate(date)).toBe(date.toISOString())\n })\n\n it('should serialize null date', () => {\n expect(serializeDate(null)).toBe('1969-12-31T23:59:59.999Z')\n })\n})\n"],"mappings":";;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA2C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3CG,QAAQ,CAAC,eAAe,EAAE,MAAM;EAC9BC,EAAE,CAAC,4BAA4B,EAAE,MAAM;IACrCC,MAAM,CAAC,IAAAC,sBAAa,EAAC,IAAIC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,0BAA0B,CAAC;EACrE,CAAC,CAAC;EAEFJ,EAAE,CAAC,uBAAuB,EAAE,MAAM;IAChC,MAAMK,IAAI,GAAG,IAAIF,IAAI,CAAC,CAAC;IACvBF,MAAM,CAAC,IAAAC,sBAAa,EAACG,IAAI,CAAC,CAAC,CAACD,IAAI,CAACC,IAAI,CAACC,WAAW,CAAC,CAAC,CAAC;EACtD,CAAC,CAAC;EAEFN,EAAE,CAAC,4BAA4B,EAAE,MAAM;IACrCC,MAAM,CAAC,IAAAC,sBAAa,EAAC,IAAI,CAAC,CAAC,CAACE,IAAI,CAAC,0BAA0B,CAAC;EAC9D,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireDefault(require("../native-types"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const startWatchApp = configuration => async () => _nativeTypes.default.startWatchAppWithWorkoutConfiguration(configuration);
|
|
10
|
-
var _default = exports.default = startWatchApp;
|
|
11
|
-
//# sourceMappingURL=startWatchApp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireDefault","require","e","__esModule","default","startWatchApp","configuration","Native","startWatchAppWithWorkoutConfiguration","_default","exports"],"sources":["startWatchApp.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKWorkoutConfiguration } from '..'\n\nconst startWatchApp = (configuration: HKWorkoutConfiguration) => async () => Native.startWatchAppWithWorkoutConfiguration(configuration)\n\nexport default startWatchApp\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAoC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAIpC,MAAMG,aAAa,GAAIC,aAAqC,IAAK,YAAYC,oBAAM,CAACC,qCAAqC,CAACF,aAAa,CAAC;AAAA,IAAAG,QAAA,GAAAC,OAAA,CAAAN,OAAA,GAEzHC,aAAa","ignoreList":[]}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _nativeTypes = _interopRequireWildcard(require("../native-types"));
|
|
8
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
9
|
-
const subscribeToChanges = async (identifier, callback) => {
|
|
10
|
-
const subscription = _nativeTypes.EventEmitter.addListener('onChange', ({
|
|
11
|
-
typeIdentifier
|
|
12
|
-
}) => {
|
|
13
|
-
if (typeIdentifier === identifier) {
|
|
14
|
-
callback();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
const queryId = await _nativeTypes.default.subscribeToObserverQuery(identifier).catch(async error => {
|
|
18
|
-
subscription.remove();
|
|
19
|
-
return Promise.reject(error);
|
|
20
|
-
});
|
|
21
|
-
return async () => {
|
|
22
|
-
subscription.remove();
|
|
23
|
-
return _nativeTypes.default.unsubscribeQuery(queryId);
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
var _default = exports.default = subscribeToChanges;
|
|
27
|
-
//# sourceMappingURL=subscribeToChanges.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_nativeTypes","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","subscribeToChanges","identifier","callback","subscription","EventEmitter","addListener","typeIdentifier","queryId","Native","subscribeToObserverQuery","catch","error","remove","Promise","reject","unsubscribeQuery","_default","exports"],"sources":["subscribeToChanges.ts"],"sourcesContent":["import Native, { EventEmitter } from '../native-types'\n\nimport type { HKSampleTypeIdentifier } from '..'\n\nconst subscribeToChanges = async (\n identifier: HKSampleTypeIdentifier,\n callback: () => void,\n) => {\n const subscription = EventEmitter.addListener(\n 'onChange',\n ({ typeIdentifier }: { readonly typeIdentifier: HKSampleTypeIdentifier }) => {\n if (typeIdentifier === identifier) {\n callback()\n }\n },\n )\n\n const queryId = await Native.subscribeToObserverQuery(identifier).catch(\n async (error) => {\n subscription.remove()\n return Promise.reject(error)\n },\n )\n\n return async () => {\n subscription.remove()\n return Native.unsubscribeQuery(queryId)\n }\n}\n\nexport default subscribeToChanges\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAsD,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAItD,MAAMkB,kBAAkB,GAAG,MAAAA,CACzBC,UAAkC,EAClCC,QAAoB,KACjB;EACH,MAAMC,YAAY,GAAGC,yBAAY,CAACC,WAAW,CAC3C,UAAU,EACV,CAAC;IAAEC;EAAoE,CAAC,KAAK;IAC3E,IAAIA,cAAc,KAAKL,UAAU,EAAE;MACjCC,QAAQ,CAAC,CAAC;IACZ;EACF,CACF,CAAC;EAED,MAAMK,OAAO,GAAG,MAAMC,oBAAM,CAACC,wBAAwB,CAACR,UAAU,CAAC,CAACS,KAAK,CACrE,MAAOC,KAAK,IAAK;IACfR,YAAY,CAACS,MAAM,CAAC,CAAC;IACrB,OAAOC,OAAO,CAACC,MAAM,CAACH,KAAK,CAAC;EAC9B,CACF,CAAC;EAED,OAAO,YAAY;IACjBR,YAAY,CAACS,MAAM,CAAC,CAAC;IACrB,OAAOJ,oBAAM,CAACO,gBAAgB,CAACR,OAAO,CAAC;EACzC,CAAC;AACH,CAAC;AAAA,IAAAS,QAAA,GAAAC,OAAA,CAAA1B,OAAA,GAEcS,kBAAkB","ignoreList":[]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
-
import getRequestStatusForAuthorization from '../utils/getRequestStatusForAuthorization';
|
|
3
|
-
import requestAuthorization from '../utils/requestAuthorization';
|
|
4
|
-
/**
|
|
5
|
-
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
6
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
7
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
8
|
-
*/
|
|
9
|
-
const useHealthkitAuthorization = (read, write) => {
|
|
10
|
-
const [status, setStatus] = useState(null);
|
|
11
|
-
const readMemo = useRef(read);
|
|
12
|
-
const writeMemo = useRef(write);
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
readMemo.current = read;
|
|
15
|
-
writeMemo.current = write;
|
|
16
|
-
}, [read, write]);
|
|
17
|
-
const refreshAuthStatus = useCallback(async () => {
|
|
18
|
-
const auth = await getRequestStatusForAuthorization(readMemo.current, writeMemo.current);
|
|
19
|
-
setStatus(auth);
|
|
20
|
-
return auth;
|
|
21
|
-
}, []);
|
|
22
|
-
const request = useCallback(async () => {
|
|
23
|
-
await requestAuthorization(readMemo.current, writeMemo.current);
|
|
24
|
-
return refreshAuthStatus();
|
|
25
|
-
}, [refreshAuthStatus]);
|
|
26
|
-
useEffect(() => {
|
|
27
|
-
void refreshAuthStatus();
|
|
28
|
-
}, [refreshAuthStatus]);
|
|
29
|
-
return [status, request];
|
|
30
|
-
};
|
|
31
|
-
export default useHealthkitAuthorization;
|
|
32
|
-
//# sourceMappingURL=useHealthkitAuthorization.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useRef","useState","getRequestStatusForAuthorization","requestAuthorization","useHealthkitAuthorization","read","write","status","setStatus","readMemo","writeMemo","current","refreshAuthStatus","auth","request"],"sources":["useHealthkitAuthorization.ts"],"sourcesContent":["import {\n useCallback, useEffect, useRef, useState,\n} from 'react'\n\nimport getRequestStatusForAuthorization from '../utils/getRequestStatusForAuthorization'\nimport requestAuthorization from '../utils/requestAuthorization'\n\nimport type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus } from '../native-types'\n\n/**\n * @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}\n */\nconst useHealthkitAuthorization = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => {\n const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)\n\n const readMemo = useRef(read)\n const writeMemo = useRef(write)\n\n useEffect(() => {\n readMemo.current = read\n writeMemo.current = write\n }, [read, write])\n\n const refreshAuthStatus = useCallback(async () => {\n const auth = await getRequestStatusForAuthorization(readMemo.current, writeMemo.current)\n\n setStatus(auth)\n return auth\n }, [])\n\n const request = useCallback(async () => {\n await requestAuthorization(readMemo.current, writeMemo.current)\n return refreshAuthStatus()\n }, [refreshAuthStatus])\n\n useEffect(() => {\n void refreshAuthStatus()\n }, [refreshAuthStatus])\n\n return [status, request] as const\n}\n\nexport default useHealthkitAuthorization\n"],"mappings":"AAAA,SACEA,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QACnC,OAAO;AAEd,OAAOC,gCAAgC,MAAM,2CAA2C;AACxF,OAAOC,oBAAoB,MAAM,+BAA+B;AAIhE;AACA;AACA;AACA;AACA;AACA,MAAMC,yBAAyB,GAAGA,CAACC,IAA2C,EAAEC,KAA8C,KAAK;EACjI,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGP,QAAQ,CAAsC,IAAI,CAAC;EAE/E,MAAMQ,QAAQ,GAAGT,MAAM,CAACK,IAAI,CAAC;EAC7B,MAAMK,SAAS,GAAGV,MAAM,CAACM,KAAK,CAAC;EAE/BP,SAAS,CAAC,MAAM;IACdU,QAAQ,CAACE,OAAO,GAAGN,IAAI;IACvBK,SAAS,CAACC,OAAO,GAAGL,KAAK;EAC3B,CAAC,EAAE,CAACD,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEjB,MAAMM,iBAAiB,GAAGd,WAAW,CAAC,YAAY;IAChD,MAAMe,IAAI,GAAG,MAAMX,gCAAgC,CAACO,QAAQ,CAACE,OAAO,EAAED,SAAS,CAACC,OAAO,CAAC;IAExFH,SAAS,CAACK,IAAI,CAAC;IACf,OAAOA,IAAI;EACb,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,OAAO,GAAGhB,WAAW,CAAC,YAAY;IACtC,MAAMK,oBAAoB,CAACM,QAAQ,CAACE,OAAO,EAAED,SAAS,CAACC,OAAO,CAAC;IAC/D,OAAOC,iBAAiB,CAAC,CAAC;EAC5B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvBb,SAAS,CAAC,MAAM;IACd,KAAKa,iBAAiB,CAAC,CAAC;EAC1B,CAAC,EAAE,CAACA,iBAAiB,CAAC,CAAC;EAEvB,OAAO,CAACL,MAAM,EAAEO,OAAO,CAAC;AAC1B,CAAC;AAED,eAAeV,yBAAyB","ignoreList":[]}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { renderHook, act } from '@testing-library/react-native';
|
|
2
|
-
import waitForNextUpdate from '../test-utils';
|
|
3
|
-
describe('useHealthkitAuthorization', () => {
|
|
4
|
-
let NativeTypes;
|
|
5
|
-
let useHealthkitAuthorization;
|
|
6
|
-
beforeAll(async () => {
|
|
7
|
-
NativeTypes = await import('../native-types');
|
|
8
|
-
useHealthkitAuthorization = (await import('./useHealthkitAuthorization')).default;
|
|
9
|
-
});
|
|
10
|
-
test('should return shouldRequest', async () => {
|
|
11
|
-
const {
|
|
12
|
-
HKAuthorizationRequestStatus,
|
|
13
|
-
HKCategoryTypeIdentifier,
|
|
14
|
-
default: Native
|
|
15
|
-
} = NativeTypes;
|
|
16
|
-
jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.shouldRequest));
|
|
17
|
-
const {
|
|
18
|
-
result
|
|
19
|
-
} = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]));
|
|
20
|
-
await waitForNextUpdate();
|
|
21
|
-
expect(result.current[0]).toBe(HKAuthorizationRequestStatus.shouldRequest);
|
|
22
|
-
});
|
|
23
|
-
test('should request permissions', async () => {
|
|
24
|
-
const {
|
|
25
|
-
HKAuthorizationRequestStatus,
|
|
26
|
-
HKCategoryTypeIdentifier,
|
|
27
|
-
default: Native
|
|
28
|
-
} = NativeTypes;
|
|
29
|
-
const spy = jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.shouldRequest));
|
|
30
|
-
jest.spyOn(Native, 'requestAuthorization').mockReturnValue(Promise.resolve(true));
|
|
31
|
-
const {
|
|
32
|
-
result
|
|
33
|
-
} = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]));
|
|
34
|
-
await waitForNextUpdate();
|
|
35
|
-
spy.mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.unnecessary));
|
|
36
|
-
let retVal;
|
|
37
|
-
await act(async () => {
|
|
38
|
-
const r = await result.current[1]();
|
|
39
|
-
retVal = r;
|
|
40
|
-
});
|
|
41
|
-
expect(result.current[0]).toBe(HKAuthorizationRequestStatus.unnecessary);
|
|
42
|
-
expect(retVal).toBe(HKAuthorizationRequestStatus.unnecessary);
|
|
43
|
-
});
|
|
44
|
-
test('should return unnecessary', async () => {
|
|
45
|
-
const {
|
|
46
|
-
HKAuthorizationRequestStatus,
|
|
47
|
-
HKCategoryTypeIdentifier,
|
|
48
|
-
default: Native
|
|
49
|
-
} = NativeTypes;
|
|
50
|
-
jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.unnecessary));
|
|
51
|
-
const {
|
|
52
|
-
result
|
|
53
|
-
} = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]));
|
|
54
|
-
await waitForNextUpdate();
|
|
55
|
-
expect(result.current[0]).toBe(HKAuthorizationRequestStatus.unnecessary);
|
|
56
|
-
});
|
|
57
|
-
test('should return null before initalizing', async () => {
|
|
58
|
-
const {
|
|
59
|
-
HKCategoryTypeIdentifier
|
|
60
|
-
} = NativeTypes;
|
|
61
|
-
const {
|
|
62
|
-
result
|
|
63
|
-
} = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]));
|
|
64
|
-
expect(result.current[0]).toBe(null);
|
|
65
|
-
await waitForNextUpdate();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
//# sourceMappingURL=useHealthkitAuthorization.test.js.map
|