@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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type CategoryTypeIdentifierReadOnly =
|
|
2
|
+
| 'HKCategoryTypeIdentifierAppleStandHour'
|
|
3
|
+
| 'HKCategoryTypeIdentifierHighHeartRateEvent'
|
|
4
|
+
| 'HKCategoryTypeIdentifierLowHeartRateEvent'
|
|
5
|
+
| 'HKCategoryTypeIdentifierHeadphoneAudioExposureEvent'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifier Apple Docs }
|
|
9
|
+
*/
|
|
10
|
+
export type CategoryTypeIdentifierWriteable =
|
|
11
|
+
| 'HKCategoryTypeIdentifierSleepAnalysis'
|
|
12
|
+
| 'HKCategoryTypeIdentifierCervicalMucusQuality'
|
|
13
|
+
| 'HKCategoryTypeIdentifierOvulationTestResult'
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated In iOS 18 beta
|
|
16
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifiermenstrualflow Apple Docs }
|
|
17
|
+
*/
|
|
18
|
+
| 'HKCategoryTypeIdentifierMenstrualFlow'
|
|
19
|
+
| 'HKCategoryTypeIdentifierIntermenstrualBleeding'
|
|
20
|
+
| 'HKCategoryTypeIdentifierSexualActivity'
|
|
21
|
+
| 'HKCategoryTypeIdentifierMindfulSession'
|
|
22
|
+
| 'HKCategoryTypeIdentifierIrregularHeartRhythmEvent'
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated Use environmentalAudioExposureEvent instead.
|
|
25
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifier/audioexposureevent Apple Docs }
|
|
26
|
+
*/
|
|
27
|
+
| 'HKCategoryTypeIdentifierAudioExposureEvent'
|
|
28
|
+
| 'HKCategoryTypeIdentifierToothbrushingEvent'
|
|
29
|
+
| 'HKCategoryTypeIdentifierLowCardioFitnessEvent'
|
|
30
|
+
| 'HKCategoryTypeIdentifierContraceptive'
|
|
31
|
+
| 'HKCategoryTypeIdentifierLactation'
|
|
32
|
+
| 'HKCategoryTypeIdentifierPregnancy'
|
|
33
|
+
| 'HKCategoryTypeIdentifierPregnancyTestResult'
|
|
34
|
+
| 'HKCategoryTypeIdentifierProgesteroneTestResult'
|
|
35
|
+
| 'HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent'
|
|
36
|
+
| 'HKCategoryTypeIdentifierAppleWalkingSteadinessEvent'
|
|
37
|
+
| 'HKCategoryTypeIdentifierHandwashingEvent'
|
|
38
|
+
|
|
39
|
+
// Symptoms
|
|
40
|
+
| 'HKCategoryTypeIdentifierAbdominalCramps'
|
|
41
|
+
| 'HKCategoryTypeIdentifierAcne'
|
|
42
|
+
| 'HKCategoryTypeIdentifierAppetiteChanges'
|
|
43
|
+
| 'HKCategoryTypeIdentifierBladderIncontinence'
|
|
44
|
+
| 'HKCategoryTypeIdentifierBloating'
|
|
45
|
+
| 'HKCategoryTypeIdentifierBreastPain'
|
|
46
|
+
| 'HKCategoryTypeIdentifierChestTightnessOrPain'
|
|
47
|
+
| 'HKCategoryTypeIdentifierChills'
|
|
48
|
+
| 'HKCategoryTypeIdentifierConstipation'
|
|
49
|
+
| 'HKCategoryTypeIdentifierCoughing'
|
|
50
|
+
| 'HKCategoryTypeIdentifierDiarrhea'
|
|
51
|
+
| 'HKCategoryTypeIdentifierDizziness'
|
|
52
|
+
| 'HKCategoryTypeIdentifierDrySkin'
|
|
53
|
+
| 'HKCategoryTypeIdentifierFainting'
|
|
54
|
+
| 'HKCategoryTypeIdentifierFatigue'
|
|
55
|
+
| 'HKCategoryTypeIdentifierFever'
|
|
56
|
+
| 'HKCategoryTypeIdentifierGeneralizedBodyAche'
|
|
57
|
+
| 'HKCategoryTypeIdentifierHairLoss'
|
|
58
|
+
| 'HKCategoryTypeIdentifierHeadache'
|
|
59
|
+
| 'HKCategoryTypeIdentifierHeartburn'
|
|
60
|
+
| 'HKCategoryTypeIdentifierHotFlashes'
|
|
61
|
+
| 'HKCategoryTypeIdentifierLossOfSmell'
|
|
62
|
+
| 'HKCategoryTypeIdentifierLossOfTaste'
|
|
63
|
+
| 'HKCategoryTypeIdentifierLowerBackPain'
|
|
64
|
+
| 'HKCategoryTypeIdentifierMemoryLapse'
|
|
65
|
+
| 'HKCategoryTypeIdentifierMoodChanges'
|
|
66
|
+
| 'HKCategoryTypeIdentifierNausea'
|
|
67
|
+
| 'HKCategoryTypeIdentifierNightSweats'
|
|
68
|
+
| 'HKCategoryTypeIdentifierPelvicPain'
|
|
69
|
+
| 'HKCategoryTypeIdentifierRapidPoundingOrFlutteringHeartbeat'
|
|
70
|
+
| 'HKCategoryTypeIdentifierRunnyNose'
|
|
71
|
+
| 'HKCategoryTypeIdentifierShortnessOfBreath'
|
|
72
|
+
| 'HKCategoryTypeIdentifierSinusCongestion'
|
|
73
|
+
| 'HKCategoryTypeIdentifierSkippedHeartbeat'
|
|
74
|
+
| 'HKCategoryTypeIdentifierSleepChanges'
|
|
75
|
+
| 'HKCategoryTypeIdentifierSoreThroat'
|
|
76
|
+
| 'HKCategoryTypeIdentifierVaginalDryness'
|
|
77
|
+
| 'HKCategoryTypeIdentifierVomiting'
|
|
78
|
+
| 'HKCategoryTypeIdentifierWheezing'
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Bleeding After Pregnancy
|
|
82
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierbleedingafterpregnancy Apple Docs }
|
|
83
|
+
* @since iOS 18
|
|
84
|
+
*/
|
|
85
|
+
| 'HKCategoryTypeIdentifierBleedingAfterPregnancy'
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Bleeding During Pregnancy
|
|
89
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierbleedingduringpregnancy Apple Docs }
|
|
90
|
+
* @since iOS 18
|
|
91
|
+
*/
|
|
92
|
+
| 'HKCategoryTypeIdentifierBleedingDuringPregnancy'
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifier Apple Docs }
|
|
96
|
+
*/
|
|
97
|
+
export type CategoryTypeIdentifier =
|
|
98
|
+
| CategoryTypeIdentifierReadOnly
|
|
99
|
+
| CategoryTypeIdentifierWriteable
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkcharacteristictypeidentifier
|
|
2
|
+
export type CharacteristicTypeIdentifier =
|
|
3
|
+
| 'HKCharacteristicTypeIdentifierFitzpatrickSkinType'
|
|
4
|
+
| 'HKCharacteristicTypeIdentifierBiologicalSex'
|
|
5
|
+
| 'HKCharacteristicTypeIdentifierBloodType'
|
|
6
|
+
| 'HKCharacteristicTypeIdentifierDateOfBirth'
|
|
7
|
+
| 'HKCharacteristicTypeIdentifierWheelchairUse'
|
|
8
|
+
| 'HKCharacteristicTypeIdentifierActivityMoveMode'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkbloodtype Apple Docs }
|
|
12
|
+
*/
|
|
13
|
+
export enum BloodType {
|
|
14
|
+
notSet = 0,
|
|
15
|
+
aPositive = 1,
|
|
16
|
+
aNegative = 2,
|
|
17
|
+
bPositive = 3,
|
|
18
|
+
bNegative = 4,
|
|
19
|
+
abPositive = 5,
|
|
20
|
+
abNegative = 6,
|
|
21
|
+
oPositive = 7,
|
|
22
|
+
oNegative = 8,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkbiologicalsex Apple Docs }
|
|
27
|
+
*/
|
|
28
|
+
export enum BiologicalSex {
|
|
29
|
+
notSet = 0,
|
|
30
|
+
female = 1,
|
|
31
|
+
male = 2,
|
|
32
|
+
other = 3,
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkfitzpatrickskintype Apple Docs }
|
|
37
|
+
*/
|
|
38
|
+
export enum FitzpatrickSkinType {
|
|
39
|
+
notSet = 0,
|
|
40
|
+
I = 1,
|
|
41
|
+
II = 2,
|
|
42
|
+
III = 3,
|
|
43
|
+
IV = 4,
|
|
44
|
+
V = 5,
|
|
45
|
+
VI = 6,
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Maps directly to https://developer.apple.com/documentation/healthkit/hkwheelchairuse
|
|
49
|
+
export enum WheelchairUse {
|
|
50
|
+
notSet = 0,
|
|
51
|
+
notUsingWheelchair = 1,
|
|
52
|
+
usingWheelchair = 2,
|
|
53
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a workout type identifier.
|
|
3
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkouttypeidentifier Apple Docs HKWorkoutTypeIdentifier}
|
|
4
|
+
*/
|
|
5
|
+
export const WorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier' as const
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Represents a workout route type identifier.
|
|
9
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKWorkoutRouteTypeIdentifier Apple Docs WorkoutRouteTypeIdentifier}
|
|
10
|
+
*/
|
|
11
|
+
export const WorkoutRouteTypeIdentifier =
|
|
12
|
+
'HKWorkoutRouteTypeIdentifier' as const
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Represents a state of mind type identifier.
|
|
16
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkstateofmindtype Apple Docs HKStateOfMindType}
|
|
17
|
+
*/
|
|
18
|
+
export const StateOfMindTypeIdentifier = 'HKStateOfMindTypeIdentifier' as const
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Represents a series sample containing heartbeat data..
|
|
22
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKDataTypeIdentifierHeartbeatSeries Apple Docs DataTypeIdentifierHeartbeatSeries}
|
|
23
|
+
*/
|
|
24
|
+
export const HeartbeatSeriesTypeIdentifier =
|
|
25
|
+
'HKDataTypeIdentifierHeartbeatSeries' as const
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
|
+
import type { CategorySample, CategorySampleForSaving } from './CategoryType'
|
|
3
|
+
import type { QuantitySample, QuantitySampleForSaving } from './QuantitySample'
|
|
4
|
+
import type { GenericMetadata } from './Shared'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcorrelationtypeidentifier Apple Docs }
|
|
8
|
+
*/
|
|
9
|
+
export type CorrelationTypeIdentifier =
|
|
10
|
+
| 'HKCorrelationTypeIdentifierBloodPressure'
|
|
11
|
+
| 'HKCorrelationTypeIdentifierFood'
|
|
12
|
+
|
|
13
|
+
type CorrelationObject = CategorySample | QuantitySample
|
|
14
|
+
|
|
15
|
+
export interface CorrelationSample {
|
|
16
|
+
readonly correlationType: CorrelationTypeIdentifier
|
|
17
|
+
readonly objects: readonly CorrelationObject[]
|
|
18
|
+
readonly metadata: AnyMap
|
|
19
|
+
readonly startDate: Date
|
|
20
|
+
readonly endDate: Date
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type MetadataMapperForCorrelationIdentifier<
|
|
24
|
+
TCorrelationTypeIdentifier = CorrelationTypeIdentifier,
|
|
25
|
+
> = TCorrelationTypeIdentifier extends 'CorrelationTypeIdentifierFood'
|
|
26
|
+
? GenericMetadata & {
|
|
27
|
+
readonly HKFoodType?: string
|
|
28
|
+
}
|
|
29
|
+
: GenericMetadata
|
|
30
|
+
|
|
31
|
+
export type SampleForSaving = CategorySampleForSaving | QuantitySampleForSaving
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkdevice Apple Docs }
|
|
3
|
+
*/
|
|
4
|
+
export interface Device {
|
|
5
|
+
readonly name: string | null // ex: "Apple Watch"
|
|
6
|
+
readonly firmwareVersion: string | null
|
|
7
|
+
readonly hardwareVersion: string | null // ex: "Watch6,2",
|
|
8
|
+
readonly localIdentifier: string | null
|
|
9
|
+
readonly manufacturer: string | null // ex: "Apple Inc."
|
|
10
|
+
readonly model: string | null // ex: "Watch"
|
|
11
|
+
readonly softwareVersion: string | null // ex: "9.0"
|
|
12
|
+
readonly udiDeviceIdentifier: string | null
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
|
+
import type { Device } from './Device'
|
|
3
|
+
import type { DeletedSample, GenericMetadata } from './Shared'
|
|
4
|
+
import type { SourceRevision } from './Source'
|
|
5
|
+
|
|
6
|
+
export interface HeartbeatSeriesSampleMetadata extends GenericMetadata {
|
|
7
|
+
readonly HKMetadataKeyAlgorithmVersion: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Heartbeat {
|
|
11
|
+
readonly timeSinceSeriesStart: number
|
|
12
|
+
readonly precededByGap: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface HeartbeatSeriesSample {
|
|
16
|
+
readonly uuid: string
|
|
17
|
+
readonly device?: Device
|
|
18
|
+
readonly startDate: Date
|
|
19
|
+
readonly endDate: Date
|
|
20
|
+
readonly heartbeats: readonly Heartbeat[]
|
|
21
|
+
readonly metadata?: AnyMap
|
|
22
|
+
readonly sourceRevision?: SourceRevision
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface HeartbeatSeriesSamplesWithAnchorResponse {
|
|
26
|
+
readonly samples: readonly HeartbeatSeriesSample[]
|
|
27
|
+
readonly deletedSamples: readonly DeletedSample[]
|
|
28
|
+
readonly newAnchor: string
|
|
29
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript utility types for verifying that two interfaces have matching method signatures.
|
|
3
|
+
*
|
|
4
|
+
* This is particularly useful for ensuring that typed and untyped versions of interfaces
|
|
5
|
+
* stay in sync when one has generics and the other doesn't.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import type { InterfaceAssertion } from "./InterfaceVerification";
|
|
10
|
+
*
|
|
11
|
+
* interface BaseModule extends HybridObject<{ ios: "swift" }> {
|
|
12
|
+
* getData(id: string): Promise<string>;
|
|
13
|
+
* }
|
|
14
|
+
*
|
|
15
|
+
* interface BaseModuleTyped {
|
|
16
|
+
* getData<T extends string>(id: T): Promise<string>;
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // This will cause a TypeScript error if the interfaces don't match
|
|
20
|
+
* const _verification: InterfaceAssertion<BaseModule, BaseModuleTyped, keyof HybridObject> = true;
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Extracts method names from an interface, excluding specified keys
|
|
26
|
+
*/
|
|
27
|
+
export type ExtractMethodNames<
|
|
28
|
+
T,
|
|
29
|
+
ExcludeKeys extends keyof T = never,
|
|
30
|
+
> = Exclude<keyof T, ExcludeKeys>
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the parameter count of a function type
|
|
34
|
+
*/
|
|
35
|
+
export type GetParameterCount<T> = T extends (...args: infer P) => unknown
|
|
36
|
+
? P['length']
|
|
37
|
+
: never
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Checks if two interfaces have the same method names
|
|
41
|
+
*/
|
|
42
|
+
export type CheckMethodNames<
|
|
43
|
+
BaseInterface,
|
|
44
|
+
TypedInterface,
|
|
45
|
+
ExcludeFromBase extends keyof BaseInterface = never,
|
|
46
|
+
> = {
|
|
47
|
+
BaseMethodNames: ExtractMethodNames<BaseInterface, ExcludeFromBase>
|
|
48
|
+
TypedMethodNames: ExtractMethodNames<TypedInterface>
|
|
49
|
+
MissingInBase: Exclude<
|
|
50
|
+
ExtractMethodNames<TypedInterface>,
|
|
51
|
+
ExtractMethodNames<BaseInterface, ExcludeFromBase>
|
|
52
|
+
>
|
|
53
|
+
MissingInTyped: Exclude<
|
|
54
|
+
ExtractMethodNames<BaseInterface, ExcludeFromBase>,
|
|
55
|
+
ExtractMethodNames<TypedInterface>
|
|
56
|
+
>
|
|
57
|
+
InterfaceMismatch:
|
|
58
|
+
| Exclude<
|
|
59
|
+
ExtractMethodNames<TypedInterface>,
|
|
60
|
+
ExtractMethodNames<BaseInterface, ExcludeFromBase>
|
|
61
|
+
>
|
|
62
|
+
| Exclude<
|
|
63
|
+
ExtractMethodNames<BaseInterface, ExcludeFromBase>,
|
|
64
|
+
ExtractMethodNames<TypedInterface>
|
|
65
|
+
>
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Checks parameter counts for shared methods between two interfaces
|
|
70
|
+
*/
|
|
71
|
+
export type CheckParameterCounts<
|
|
72
|
+
BaseInterface,
|
|
73
|
+
TypedInterface,
|
|
74
|
+
ExcludeFromBase extends keyof BaseInterface = never,
|
|
75
|
+
> = {
|
|
76
|
+
SharedMethodNames: ExtractMethodNames<BaseInterface, ExcludeFromBase> &
|
|
77
|
+
ExtractMethodNames<TypedInterface>
|
|
78
|
+
ParameterCountMismatches: {
|
|
79
|
+
[K in ExtractMethodNames<BaseInterface, ExcludeFromBase> &
|
|
80
|
+
ExtractMethodNames<TypedInterface>]: GetParameterCount<
|
|
81
|
+
BaseInterface[K]
|
|
82
|
+
> extends GetParameterCount<TypedInterface[K]>
|
|
83
|
+
? GetParameterCount<TypedInterface[K]> extends GetParameterCount<
|
|
84
|
+
BaseInterface[K]
|
|
85
|
+
>
|
|
86
|
+
? never
|
|
87
|
+
: K
|
|
88
|
+
: K
|
|
89
|
+
}[ExtractMethodNames<BaseInterface, ExcludeFromBase> &
|
|
90
|
+
ExtractMethodNames<TypedInterface>]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Complete interface verification that checks both method names and parameter counts
|
|
95
|
+
*/
|
|
96
|
+
export type VerifyInterfaceSync<
|
|
97
|
+
BaseInterface,
|
|
98
|
+
TypedInterface,
|
|
99
|
+
ExcludeFromBase extends keyof BaseInterface = never,
|
|
100
|
+
> = {
|
|
101
|
+
MethodCheck: CheckMethodNames<BaseInterface, TypedInterface, ExcludeFromBase>
|
|
102
|
+
ParameterCheck: CheckParameterCounts<
|
|
103
|
+
BaseInterface,
|
|
104
|
+
TypedInterface,
|
|
105
|
+
ExcludeFromBase
|
|
106
|
+
>
|
|
107
|
+
|
|
108
|
+
// Final verification result
|
|
109
|
+
Result: CheckMethodNames<
|
|
110
|
+
BaseInterface,
|
|
111
|
+
TypedInterface,
|
|
112
|
+
ExcludeFromBase
|
|
113
|
+
>['InterfaceMismatch'] extends never
|
|
114
|
+
? CheckParameterCounts<
|
|
115
|
+
BaseInterface,
|
|
116
|
+
TypedInterface,
|
|
117
|
+
ExcludeFromBase
|
|
118
|
+
>['ParameterCountMismatches'] extends never
|
|
119
|
+
? true
|
|
120
|
+
: {
|
|
121
|
+
ERROR: 'Parameter count mismatch detected'
|
|
122
|
+
MethodsWithParameterCountMismatch: CheckParameterCounts<
|
|
123
|
+
BaseInterface,
|
|
124
|
+
TypedInterface,
|
|
125
|
+
ExcludeFromBase
|
|
126
|
+
>['ParameterCountMismatches']
|
|
127
|
+
}
|
|
128
|
+
: {
|
|
129
|
+
ERROR: 'Interface mismatch detected'
|
|
130
|
+
MissingInBase: CheckMethodNames<
|
|
131
|
+
BaseInterface,
|
|
132
|
+
TypedInterface,
|
|
133
|
+
ExcludeFromBase
|
|
134
|
+
>['MissingInBase']
|
|
135
|
+
MissingInTyped: CheckMethodNames<
|
|
136
|
+
BaseInterface,
|
|
137
|
+
TypedInterface,
|
|
138
|
+
ExcludeFromBase
|
|
139
|
+
>['MissingInTyped']
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Simplified interface verification for common use cases
|
|
145
|
+
*/
|
|
146
|
+
export type AssertInterfacesMatch<
|
|
147
|
+
BaseInterface,
|
|
148
|
+
TypedInterface,
|
|
149
|
+
ExcludeFromBase extends keyof BaseInterface = never,
|
|
150
|
+
> = VerifyInterfaceSync<
|
|
151
|
+
BaseInterface,
|
|
152
|
+
TypedInterface,
|
|
153
|
+
ExcludeFromBase
|
|
154
|
+
>['Result']
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Creates a compile-time assertion that two interfaces match
|
|
158
|
+
* Usage: const _check: InterfaceAssertion<BaseInterface, TypedInterface> = true;
|
|
159
|
+
*/
|
|
160
|
+
export type InterfaceAssertion<
|
|
161
|
+
BaseInterface,
|
|
162
|
+
TypedInterface,
|
|
163
|
+
ExcludeFromBase extends keyof BaseInterface = never,
|
|
164
|
+
> = AssertInterfacesMatch<BaseInterface, TypedInterface, ExcludeFromBase>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example usage of the InterfaceVerification utility
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to use the reusable interface verification utility
|
|
5
|
+
* to ensure that typed and untyped versions of interfaces stay in sync.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { HybridObject } from 'react-native-nitro-modules'
|
|
9
|
+
import type { InterfaceAssertion } from './InterfaceVerification'
|
|
10
|
+
|
|
11
|
+
// Example: Basic interface without generics
|
|
12
|
+
export interface ExampleModule extends HybridObject<{ ios: 'swift' }> {
|
|
13
|
+
getData(id: string): Promise<string>
|
|
14
|
+
saveData(id: string, data: string): Promise<boolean>
|
|
15
|
+
deleteData(id: string): Promise<void>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Example: Typed version with generics
|
|
19
|
+
export interface ExampleModuleTyped {
|
|
20
|
+
getData<T extends string>(id: T): Promise<string>
|
|
21
|
+
saveData<T extends string>(id: T, data: string): Promise<boolean>
|
|
22
|
+
deleteData<T extends string>(id: T): Promise<void>
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Verification: This will cause a TypeScript error if the interfaces don't match
|
|
26
|
+
const _exampleVerification: InterfaceAssertion<
|
|
27
|
+
ExampleModule,
|
|
28
|
+
ExampleModuleTyped,
|
|
29
|
+
keyof HybridObject
|
|
30
|
+
> = true
|
|
31
|
+
|
|
32
|
+
// Example: Interface with optional parameters
|
|
33
|
+
export interface ConfigModule extends HybridObject<{ ios: 'swift' }> {
|
|
34
|
+
getConfig(key: string, defaultValue?: string): Promise<string>
|
|
35
|
+
setConfig(key: string, value: string, persistent?: boolean): Promise<void>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ConfigModuleTyped {
|
|
39
|
+
getConfig<T extends string>(key: T, defaultValue?: string): Promise<string>
|
|
40
|
+
setConfig<T extends string>(
|
|
41
|
+
key: T,
|
|
42
|
+
value: string,
|
|
43
|
+
persistent?: boolean,
|
|
44
|
+
): Promise<void>
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Verification for optional parameters
|
|
48
|
+
const _configVerification: InterfaceAssertion<
|
|
49
|
+
ConfigModule,
|
|
50
|
+
ConfigModuleTyped,
|
|
51
|
+
keyof HybridObject
|
|
52
|
+
> = true
|
|
53
|
+
|
|
54
|
+
// Example: What happens when there's a mismatch
|
|
55
|
+
export interface BadModule extends HybridObject<{ ios: 'swift' }> {
|
|
56
|
+
method1(): void
|
|
57
|
+
method2(param: string): void
|
|
58
|
+
// This method exists in BadModule but not in BadModuleTyped
|
|
59
|
+
extraMethod(): void
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface BadModuleTyped {
|
|
63
|
+
method1(): void
|
|
64
|
+
method2(param: string): void
|
|
65
|
+
// Missing extraMethod - this will cause a TypeScript error
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// This will show a TypeScript error indicating the mismatch
|
|
69
|
+
// Uncomment to see the error:
|
|
70
|
+
// const _badVerification: InterfaceAssertion<BadModule, BadModuleTyped, keyof HybridObject> = true;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Usage Instructions:
|
|
74
|
+
*
|
|
75
|
+
* 1. Import the InterfaceAssertion type from InterfaceVerification
|
|
76
|
+
* 2. Create your base interface (extending HybridObject)
|
|
77
|
+
* 3. Create your typed interface (with generics)
|
|
78
|
+
* 4. Add a verification line:
|
|
79
|
+
* const _verification: InterfaceAssertion<BaseInterface, TypedInterface, keyof HybridObject> = true;
|
|
80
|
+
*
|
|
81
|
+
* The verification will:
|
|
82
|
+
* - Check that both interfaces have the same method names
|
|
83
|
+
* - Check that corresponding methods have the same number of parameters
|
|
84
|
+
* - Show descriptive TypeScript errors if there are mismatches
|
|
85
|
+
*
|
|
86
|
+
* Error Types:
|
|
87
|
+
* - "Interface mismatch detected" - method names don't match
|
|
88
|
+
* - "Parameter count mismatch detected" - parameter counts don't match
|
|
89
|
+
*/
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnyMap } from 'react-native-nitro-modules'
|
|
2
|
+
|
|
3
|
+
import type { Device } from './Device'
|
|
4
|
+
import type { QuantityTypeIdentifier } from './QuantityTypeIdentifier'
|
|
5
|
+
import type { SourceRevision } from './Source'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitysample Apple Docs }
|
|
9
|
+
*/
|
|
10
|
+
export interface QuantitySample {
|
|
11
|
+
readonly uuid: string
|
|
12
|
+
readonly device?: Device
|
|
13
|
+
readonly quantityType: QuantityTypeIdentifier
|
|
14
|
+
readonly startDate: Date
|
|
15
|
+
readonly endDate: Date
|
|
16
|
+
readonly quantity: number
|
|
17
|
+
readonly unit: string
|
|
18
|
+
readonly metadata: AnyMap
|
|
19
|
+
readonly sourceRevision?: SourceRevision
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface QuantitySampleForSaving {
|
|
23
|
+
readonly startDate: Date
|
|
24
|
+
readonly endDate: Date
|
|
25
|
+
readonly quantityType: QuantityTypeIdentifier
|
|
26
|
+
readonly quantity: number
|
|
27
|
+
readonly unit: string
|
|
28
|
+
readonly metadata: AnyMap
|
|
29
|
+
readonly sourceRevision?: SourceRevision
|
|
30
|
+
}
|