@kingstinct/react-native-healthkit 4.4.4 → 5.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.
Files changed (235) hide show
  1. package/README.md +1 -1
  2. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  3. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  4. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  6. package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
  7. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
  8. package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
  9. package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
  10. package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
  11. package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
  12. package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
  13. package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
  14. package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
  15. package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
  16. package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
  17. package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
  18. package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
  19. package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
  20. package/lib/commonjs/index.ios.js +66 -394
  21. package/lib/commonjs/index.ios.js.map +1 -1
  22. package/lib/commonjs/index.js +9 -17
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/native-types.js +249 -78
  25. package/lib/commonjs/native-types.js.map +1 -1
  26. package/lib/commonjs/types.js +13 -0
  27. package/lib/commonjs/types.js.map +1 -1
  28. package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
  29. package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
  30. package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
  31. package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
  32. package/lib/commonjs/utils/deserializeSample.js +17 -0
  33. package/lib/commonjs/utils/deserializeSample.js.map +1 -0
  34. package/lib/commonjs/utils/deserializeWorkout.js +17 -0
  35. package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
  36. package/lib/commonjs/utils/ensureMetadata.js +14 -0
  37. package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
  38. package/lib/commonjs/utils/ensureUnit.js +23 -0
  39. package/lib/commonjs/utils/ensureUnit.js.map +1 -0
  40. package/lib/commonjs/utils/getDateOfBirth.js +19 -0
  41. package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
  42. package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
  43. package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
  44. package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
  45. package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
  46. package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
  47. package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
  48. package/lib/commonjs/utils/getPreferredUnit.js +19 -0
  49. package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
  50. package/lib/commonjs/utils/getPreferredUnits.js +19 -0
  51. package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
  52. package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
  53. package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
  54. package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
  55. package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
  56. package/lib/commonjs/utils/prepareOptions.js +27 -0
  57. package/lib/commonjs/utils/prepareOptions.js.map +1 -0
  58. package/lib/commonjs/utils/queryCategorySamples.js +24 -0
  59. package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
  60. package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
  61. package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
  62. package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
  63. package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
  64. package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
  65. package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
  66. package/lib/commonjs/utils/queryWorkouts.js +30 -0
  67. package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
  68. package/lib/commonjs/utils/requestAuthorization.js +25 -0
  69. package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
  70. package/lib/commonjs/utils/saveCategorySample.js +21 -0
  71. package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
  72. package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
  73. package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
  74. package/lib/commonjs/utils/saveQuantitySample.js +21 -0
  75. package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
  76. package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
  77. package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
  78. package/lib/commonjs/utils/serializeDate.js +12 -0
  79. package/lib/commonjs/utils/serializeDate.js.map +1 -0
  80. package/lib/commonjs/utils/subscribeToChanges.js +37 -0
  81. package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
  82. package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
  83. package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
  84. package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
  85. package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
  86. package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
  87. package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
  88. package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
  89. package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
  90. package/lib/module/hooks/useMostRecentWorkout.js +47 -0
  91. package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
  92. package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
  93. package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
  94. package/lib/module/hooks/useSubscribeToChanges.js +26 -0
  95. package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
  96. package/lib/module/index.ios.js +32 -370
  97. package/lib/module/index.ios.js.map +1 -1
  98. package/lib/module/index.js +10 -7
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/native-types.js +232 -74
  101. package/lib/module/native-types.js.map +1 -1
  102. package/lib/module/types.js +15 -0
  103. package/lib/module/types.js.map +1 -1
  104. package/lib/module/utils/deserializeCategorySample.js +7 -0
  105. package/lib/module/utils/deserializeCategorySample.js.map +1 -0
  106. package/lib/module/utils/deserializeCorrelation.js +21 -0
  107. package/lib/module/utils/deserializeCorrelation.js.map +1 -0
  108. package/lib/module/utils/deserializeSample.js +9 -0
  109. package/lib/module/utils/deserializeSample.js.map +1 -0
  110. package/lib/module/utils/deserializeWorkout.js +9 -0
  111. package/lib/module/utils/deserializeWorkout.js.map +1 -0
  112. package/lib/module/utils/ensureMetadata.js +6 -0
  113. package/lib/module/utils/ensureMetadata.js.map +1 -0
  114. package/lib/module/utils/ensureUnit.js +13 -0
  115. package/lib/module/utils/ensureUnit.js.map +1 -0
  116. package/lib/module/utils/getDateOfBirth.js +9 -0
  117. package/lib/module/utils/getDateOfBirth.js.map +1 -0
  118. package/lib/module/utils/getMostRecentCategorySample.js +12 -0
  119. package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
  120. package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
  121. package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
  122. package/lib/module/utils/getMostRecentWorkout.js +14 -0
  123. package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
  124. package/lib/module/utils/getPreferredUnit.js +9 -0
  125. package/lib/module/utils/getPreferredUnit.js.map +1 -0
  126. package/lib/module/utils/getPreferredUnits.js +9 -0
  127. package/lib/module/utils/getPreferredUnits.js.map +1 -0
  128. package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
  129. package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
  130. package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
  131. package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
  132. package/lib/module/utils/prepareOptions.js +17 -0
  133. package/lib/module/utils/prepareOptions.js.map +1 -0
  134. package/lib/module/utils/queryCategorySamples.js +12 -0
  135. package/lib/module/utils/queryCategorySamples.js.map +1 -0
  136. package/lib/module/utils/queryCorrelationSamples.js +12 -0
  137. package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
  138. package/lib/module/utils/queryQuantitySamples.js +14 -0
  139. package/lib/module/utils/queryQuantitySamples.js.map +1 -0
  140. package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
  141. package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
  142. package/lib/module/utils/queryWorkouts.js +17 -0
  143. package/lib/module/utils/queryWorkouts.js.map +1 -0
  144. package/lib/module/utils/requestAuthorization.js +15 -0
  145. package/lib/module/utils/requestAuthorization.js.map +1 -0
  146. package/lib/module/utils/saveCategorySample.js +11 -0
  147. package/lib/module/utils/saveCategorySample.js.map +1 -0
  148. package/lib/module/utils/saveCorrelationSample.js +13 -0
  149. package/lib/module/utils/saveCorrelationSample.js.map +1 -0
  150. package/lib/module/utils/saveQuantitySample.js +11 -0
  151. package/lib/module/utils/saveQuantitySample.js.map +1 -0
  152. package/lib/module/utils/saveWorkoutSample.js +14 -0
  153. package/lib/module/utils/saveWorkoutSample.js.map +1 -0
  154. package/lib/module/utils/serializeDate.js +4 -0
  155. package/lib/module/utils/serializeDate.js.map +1 -0
  156. package/lib/module/utils/subscribeToChanges.js +25 -0
  157. package/lib/module/utils/subscribeToChanges.js.map +1 -0
  158. package/lib/typescript/example-expo/App.d.ts +2 -0
  159. package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
  160. package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
  161. package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
  162. package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
  163. package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
  164. package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
  165. package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
  166. package/lib/typescript/src/index.d.ts +2 -3
  167. package/lib/typescript/src/index.ios.d.ts +48 -3
  168. package/lib/typescript/src/native-types.d.ts +235 -70
  169. package/lib/typescript/src/types.d.ts +14 -90
  170. package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
  171. package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
  172. package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
  173. package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
  174. package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
  175. package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
  176. package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
  177. package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
  178. package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
  179. package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
  180. package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
  181. package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
  182. package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
  183. package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
  184. package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
  185. package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
  186. package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
  187. package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
  188. package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
  189. package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
  190. package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
  191. package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
  192. package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
  193. package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
  194. package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
  195. package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
  196. package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
  197. package/package.json +17 -6
  198. package/src/hooks/useHealthkitAuthorization.ts +39 -0
  199. package/src/hooks/useIsHealthDataAvailable.ts +17 -0
  200. package/src/hooks/useMostRecentCategorySample.ts +24 -0
  201. package/src/hooks/useMostRecentQuantitySample.ts +39 -0
  202. package/src/hooks/useMostRecentWorkout.ts +60 -0
  203. package/src/hooks/useStatisticsForQuantity.ts +42 -0
  204. package/src/hooks/useSubscribeToChanges.ts +31 -0
  205. package/src/index.ios.tsx +36 -569
  206. package/src/index.tsx +12 -9
  207. package/src/native-types.ts +323 -93
  208. package/src/types.ts +41 -152
  209. package/src/utils/deserializeCategorySample.ts +12 -0
  210. package/src/utils/deserializeCorrelation.ts +28 -0
  211. package/src/utils/deserializeSample.ts +17 -0
  212. package/src/utils/deserializeWorkout.ts +14 -0
  213. package/src/utils/ensureMetadata.ts +5 -0
  214. package/src/utils/ensureUnit.ts +19 -0
  215. package/src/utils/getDateOfBirth.ts +8 -0
  216. package/src/utils/getMostRecentCategorySample.ts +18 -0
  217. package/src/utils/getMostRecentQuantitySample.ts +19 -0
  218. package/src/utils/getMostRecentWorkout.ts +27 -0
  219. package/src/utils/getPreferredUnit.ts +14 -0
  220. package/src/utils/getPreferredUnits.ts +14 -0
  221. package/src/utils/getPreferredUnitsTyped.ts +38 -0
  222. package/src/utils/getRequestStatusForAuthorization.ts +21 -0
  223. package/src/utils/prepareOptions.ts +15 -0
  224. package/src/utils/queryCategorySamples.ts +29 -0
  225. package/src/utils/queryCorrelationSamples.ts +29 -0
  226. package/src/utils/queryQuantitySamples.ts +36 -0
  227. package/src/utils/queryStatisticsForQuantity.ts +38 -0
  228. package/src/utils/queryWorkouts.ts +28 -0
  229. package/src/utils/requestAuthorization.ts +18 -0
  230. package/src/utils/saveCategorySample.ts +27 -0
  231. package/src/utils/saveCorrelationSample.ts +34 -0
  232. package/src/utils/saveQuantitySample.ts +29 -0
  233. package/src/utils/saveWorkoutSample.ts +28 -0
  234. package/src/utils/serializeDate.ts +3 -0
  235. package/src/utils/subscribeToChanges.ts +32 -0
@@ -117,12 +117,21 @@ export enum HKQuantityTypeIdentifier {
117
117
  stairDescentSpeed = 'HKQuantityTypeIdentifierStairDescentSpeed',
118
118
 
119
119
  uvExposure = 'HKQuantityTypeIdentifierUvExposure', // Scalar (Count), Discrete
120
+
121
+ appleMoveTime = 'HKQuantityTypeIdentifierAppleMoveTime', // Time, Cumulative
122
+ appleWalkingSteadiness = 'HKQuantityTypeIdentifierAppleWalkingSteadiness', // Scalar(Percent, 0.0 - 1.0), Discrete
123
+
124
+ numberOfAlcoholicBeverages = 'HKQuantityTypeIdentifierNumberOfAlcoholicBeverages', // Scalar(Count), Cumulative
120
125
  }
121
126
 
122
127
  export type TypeToUnitMapping = { readonly
123
128
  [key in HKQuantityTypeIdentifier]: HKUnit;
124
129
  };
125
130
 
131
+ export enum HKCategoryValueLowCardioFitnessEvent {
132
+ lowFitness = 1,
133
+ }
134
+
126
135
  export enum HKHeartRateMotionContext {
127
136
  active = 2,
128
137
  notSet = 0,
@@ -148,6 +157,58 @@ export enum HKCategoryTypeIdentifier {
148
157
  irregularHeartRhythmEvent = 'HKCategoryTypeIdentifierIrregularHeartRhythmEvent',
149
158
  audioExposureEvent = 'HKCategoryTypeIdentifierAudioExposureEvent',
150
159
  toothbrushingEvent = 'HKCategoryTypeIdentifierToothbrushingEvent',
160
+ lowCardioFitnessEvent = 'HKCategoryTypeIdentifierLowCardioFitnessEvent',
161
+ contraceptive = 'HKCategoryTypeIdentifierContraceptive',
162
+ lactation = 'HKCategoryTypeIdentifierLactation',
163
+ pregnancy = 'HKCategoryTypeIdentifierPregnancy',
164
+ pregnancyTestResult = 'HKCategoryTypeIdentifierPregnancyTestResult',
165
+ progesteroneTestResult = 'HKCategoryTypeIdentifierProgesteroneTestResult',
166
+ environmentalAudioExposureEvent = 'HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent',
167
+ headphoneAudioExposureEvent = 'HKCategoryTypeIdentifierHeadphoneAudioExposureEvent',
168
+ appleWalkingSteadinessEvent = 'HKCategoryTypeIdentifierAppleWalkingSteadinessEvent',
169
+ handwashingEvent = 'HKCategoryTypeIdentifierHandwashingEvent', // HKCategoryValue
170
+
171
+ // Symptoms
172
+ abdominalCramps = 'HKCategoryTypeIdentifierAbdominalCramps', // HKCategoryValueSeverity
173
+ acne = 'HKCategoryTypeIdentifierAcne', // HKCategoryValueSeverity
174
+ appetiteChanges = 'HKCategoryTypeIdentifierAppetiteChanges', // HKCategoryValueAppetiteChanges
175
+ bladderIncontinence = 'HKCategoryTypeIdentifierBladderIncontinence', // HKCategoryValueSeverity
176
+ bloating = 'HKCategoryTypeIdentifierBloating', // HKCategoryValueSeverity
177
+ breastPain = 'HKCategoryTypeIdentifierBreastPain', // HKCategoryValueSeverity
178
+ chestTightnessOrPain = 'HKCategoryTypeIdentifierChestTightnessOrPain', // HKCategoryValueSeverity
179
+ chills = 'HKCategoryTypeIdentifierChills', // HKCategoryValueSeverity
180
+ constipation = 'HKCategoryTypeIdentifierConstipation', // HKCategoryValueSeverity
181
+ coughing = 'HKCategoryTypeIdentifierCoughing', // HKCategoryValueSeverity
182
+ diarrhea = 'HKCategoryTypeIdentifierDiarrhea', // HKCategoryValueSeverity
183
+ dizziness = 'HKCategoryTypeIdentifierDizziness', // HKCategoryValueSeverity
184
+ drySkin = 'HKCategoryTypeIdentifierDrySkin', // HKCategoryValueSeverity
185
+ fainting = 'HKCategoryTypeIdentifierFainting', // HKCategoryValueSeverity
186
+ fatigue = 'HKCategoryTypeIdentifierFatigue', // HKCategoryValueSeverity
187
+ fever = 'HKCategoryTypeIdentifierFever', // HKCategoryValueSeverity
188
+ generalizedBodyAche = 'HKCategoryTypeIdentifierGeneralizedBodyAche', // HKCategoryValueSeverity
189
+ hairLoss = 'HKCategoryTypeIdentifierHairLoss', // HKCategoryValueSeverity
190
+ headache = 'HKCategoryTypeIdentifierHeadache', // HKCategoryValueSeverity
191
+ heartburn = 'HKCategoryTypeIdentifierHeartburn', // HKCategoryValueSeverity
192
+ hotFlashes = 'HKCategoryTypeIdentifierHotFlashes', // HKCategoryValueSeverity
193
+ lossOfSmell = 'HKCategoryTypeIdentifierLossOfSmell', // HKCategoryValueSeverity
194
+ lossOfTaste = 'HKCategoryTypeIdentifierLossOfTaste', // HKCategoryValueSeverity
195
+ lowerBackPain = 'HKCategoryTypeIdentifierLowerBackPain', // HKCategoryValueSeverity
196
+ memoryLapse = 'HKCategoryTypeIdentifierMemoryLapse', // HKCategoryValueSeverity
197
+ moodChanges = 'HKCategoryTypeIdentifierMoodChanges', // HKCategoryValuePresence
198
+ nausea = 'HKCategoryTypeIdentifierNausea', // HKCategoryValueSeverity
199
+ nightSweats = 'HKCategoryTypeIdentifierNightSweats', // HKCategoryValueSeverity
200
+ pelvicPain = 'HKCategoryTypeIdentifierPelvicPain', // HKCategoryValueSeverity
201
+ rapidPoundingOrFlutteringHeartbeat = 'HKCategoryTypeIdentifierRapidPoundingOrFlutteringHeartbeat', // HKCategoryValueSeverity
202
+ runnyNose = 'HKCategoryTypeIdentifierRunnyNose', // HKCategoryValueSeverity
203
+ shortnessOfBreath = 'HKCategoryTypeIdentifierShortnessOfBreath', // HKCategoryValueSeverity
204
+ sinusCongestion = 'HKCategoryTypeIdentifierSinusCongestion', // HKCategoryValueSeverity
205
+ skippedHeartbeat = 'HKCategoryTypeIdentifierSkippedHeartbeat', // HKCategoryValueSeverity
206
+ sleepChanges = 'HKCategoryTypeIdentifierSleepChanges', // HKCategoryValuePresence
207
+ soreThroat = 'HKCategoryTypeIdentifierSoreThroat', // HKCategoryValueSeverity
208
+ vaginalDryness = 'HKCategoryTypeIdentifierVaginalDryness', // HKCategoryValueSeverity
209
+ vomiting = 'HKCategoryTypeIdentifierVomiting', // HKCategoryValueSeverity
210
+ wheezing = 'HKCategoryTypeIdentifierWheezing', // HKCategoryValueSeverity
211
+
151
212
  }
152
213
 
153
214
  export type HKSampleTypeIdentifier =
@@ -308,10 +369,10 @@ enum HKIndoorWorkout {
308
369
  export interface HKWorkoutMetadata
309
370
  extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
310
371
  readonly HKWeatherCondition?: HKWeatherCondition;
311
- readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
372
+ readonly HKWeatherHumidity?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Percent>;
312
373
  // HKWeatherTemperature: HKQuantity<TTemperatureUnit>
313
- readonly HKAverageMETs?: HKQuantity<HKUnit>,
314
- readonly HKElevationAscended?: HKQuantity<HKUnit.Meters>,
374
+ readonly HKAverageMETs?: HKQuantity<HKQuantityTypeIdentifier, HKUnit>,
375
+ readonly HKElevationAscended?: HKQuantity<HKQuantityTypeIdentifier, LengthUnit>,
315
376
  readonly HKIndoorWorkout?: HKIndoorWorkout,
316
377
  }
317
378
 
@@ -327,8 +388,8 @@ export enum HKAuthorizationStatus {
327
388
  sharingAuthorized = 2,
328
389
  }
329
390
 
330
- export type HKQuantity<T extends HKUnit = HKUnit> = {
331
- readonly unit: T;
391
+ export type HKQuantity<TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>> = {
392
+ readonly unit: TUnit;
332
393
  readonly quantity: number;
333
394
  };
334
395
 
@@ -372,14 +433,14 @@ export enum HKStatisticsOptions {
372
433
  separateBySource = 'separateBySource',
373
434
  }
374
435
 
375
- export type QueryStatisticsResponseRaw<TUnit extends HKUnit = HKUnit> = {
376
- readonly averageQuantity?: HKQuantity<TUnit>;
377
- readonly maximumQuantity?: HKQuantity<TUnit>;
378
- readonly minimumQuantity?: HKQuantity<TUnit>;
379
- readonly sumQuantity?: HKQuantity<TUnit>;
380
- readonly mostRecentQuantity?: HKQuantity<TUnit>;
436
+ export type QueryStatisticsResponseRaw<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>> = {
437
+ readonly averageQuantity?: HKQuantity<TIdentifier, TUnit>;
438
+ readonly maximumQuantity?: HKQuantity<TIdentifier, TUnit>;
439
+ readonly minimumQuantity?: HKQuantity<TIdentifier, TUnit>;
440
+ readonly sumQuantity?: HKQuantity<TIdentifier, TUnit>;
441
+ readonly mostRecentQuantity?: HKQuantity<TIdentifier, TUnit>;
381
442
  readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
382
- readonly duration?: HKQuantity<HKUnit.Seconds>;
443
+ readonly duration?: HKQuantity<HKQuantityTypeIdentifier, TimeUnit>;
383
444
  };
384
445
 
385
446
  export enum HKCategoryValueCervicalMucusQuality {
@@ -436,15 +497,10 @@ export enum HKCategoryValueNotApplicable {
436
497
  }
437
498
 
438
499
  export type HKCategoryValue =
439
- | HKCategoryValueAppetiteChanges
440
- | HKCategoryValueCervicalMucusQuality
441
- | HKCategoryValueMenstrualFlow
442
- | HKCategoryValueOvulationTestResult
443
- | HKCategoryValuePresence
444
- | HKCategoryValuePresence
445
- | HKCategoryValueSeverity
446
- | HKCategoryValueSleepAnalysis
447
- | number;
500
+ HKCategoryValueAppetiteChanges | HKCategoryValueCervicalMucusQuality |
501
+ HKCategoryValueLowCardioFitnessEvent | HKCategoryValueMenstrualFlow |
502
+ HKCategoryValueOvulationTestResult | HKCategoryValuePresence |
503
+ HKCategoryValueSeverity | HKCategoryValueSleepAnalysis | number;
448
504
 
449
505
  export enum HKInsulinDeliveryReason {
450
506
  basal = 1,
@@ -475,6 +531,20 @@ export type MetadataMapperForCorrelationIdentifier<
475
531
  }
476
532
  : HKGenericMetadata;
477
533
 
534
+ export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> = T extends HKQuantityTypeIdentifier.bloodGlucose ? BloodGlucoseUnit
535
+ : T extends HKQuantityTypeIdentifier.appleExerciseTime | HKQuantityTypeIdentifier.appleMoveTime | HKQuantityTypeIdentifier.appleStandTime ? TimeUnit
536
+ : T extends HKQuantityTypeIdentifier.activeEnergyBurned | HKQuantityTypeIdentifier.basalEnergyBurned | HKQuantityTypeIdentifier.dietaryEnergyConsumed ? EnergyUnit
537
+ : T extends HKQuantityTypeIdentifier.distanceCycling | HKQuantityTypeIdentifier.distanceDownhillSnowSports | HKQuantityTypeIdentifier.distanceSwimming | HKQuantityTypeIdentifier.distanceWalkingRunning | HKQuantityTypeIdentifier.distanceWheelchair | HKQuantityTypeIdentifier.sixMinuteWalkTestDistance | HKQuantityTypeIdentifier.waistCircumference ? LengthUnit
538
+ : T extends HKQuantityTypeIdentifier.bodyFatPercentage | HKQuantityTypeIdentifier.oxygenSaturation | HKQuantityTypeIdentifier.walkingAsymmetryPercentage | HKQuantityTypeIdentifier.walkingDoubleSupportPercentage ? HKUnits.Percent
539
+ : T extends HKQuantityTypeIdentifier.basalBodyTemperature | HKQuantityTypeIdentifier.basalBodyTemperature ? TemperatureUnit
540
+ : T extends HKQuantityTypeIdentifier.stairAscentSpeed | HKQuantityTypeIdentifier.stairDescentSpeed | HKQuantityTypeIdentifier.walkingSpeed | HKQuantityTypeIdentifier.walkingSpeed ? SpeedUnit<LengthUnit, TimeUnit>
541
+ : T extends HKQuantityTypeIdentifier.flightsClimbed | HKQuantityTypeIdentifier.numberOfAlcoholicBeverages | HKQuantityTypeIdentifier.numberOfTimesFallen | HKQuantityTypeIdentifier.pushCount | HKQuantityTypeIdentifier.stepCount | HKQuantityTypeIdentifier.swimmingStrokeCount ? HKUnits.Count
542
+ : T extends HKQuantityTypeIdentifier.dietaryBiotin | HKQuantityTypeIdentifier.dietaryCaffeine | HKQuantityTypeIdentifier.dietaryCalcium | HKQuantityTypeIdentifier.dietaryCarbohydrates | HKQuantityTypeIdentifier.dietaryChloride | HKQuantityTypeIdentifier.dietaryCholesterol | HKQuantityTypeIdentifier.dietaryChromium | HKQuantityTypeIdentifier.dietaryCopper | HKQuantityTypeIdentifier.dietaryFatMonounsaturated | HKQuantityTypeIdentifier.dietaryFatPolyunsaturated | HKQuantityTypeIdentifier.dietaryFatSaturated | HKQuantityTypeIdentifier.dietaryFatTotal | HKQuantityTypeIdentifier.dietaryFiber | HKQuantityTypeIdentifier.dietaryFolate | HKQuantityTypeIdentifier.dietaryIodine | HKQuantityTypeIdentifier.dietaryIodine | HKQuantityTypeIdentifier.dietaryIron | HKQuantityTypeIdentifier.dietaryMagnesium | HKQuantityTypeIdentifier.dietaryManganese | HKQuantityTypeIdentifier.dietaryMolybdenum | HKQuantityTypeIdentifier.dietaryNiacin | HKQuantityTypeIdentifier.dietaryPantothenicAcid | HKQuantityTypeIdentifier.dietaryPhosphorus | HKQuantityTypeIdentifier.dietaryPotassium | HKQuantityTypeIdentifier.dietaryProtein | HKQuantityTypeIdentifier.dietaryRiboflavin | HKQuantityTypeIdentifier.dietarySelenium | HKQuantityTypeIdentifier.dietarySodium | HKQuantityTypeIdentifier.dietarySugar | HKQuantityTypeIdentifier.dietaryThiamin | HKQuantityTypeIdentifier.dietaryVitaminA | HKQuantityTypeIdentifier.dietaryVitaminB6 | HKQuantityTypeIdentifier.dietaryVitaminB12 | HKQuantityTypeIdentifier.dietaryVitaminC | HKQuantityTypeIdentifier.dietaryVitaminD | HKQuantityTypeIdentifier.dietaryVitaminE | HKQuantityTypeIdentifier.dietaryVitaminK | HKQuantityTypeIdentifier.dietaryZinc ? MassUnit
543
+ : T extends HKQuantityTypeIdentifier.dietaryWater ? VolumeUnit
544
+ : T extends HKQuantityTypeIdentifier.insulinDelivery ? HKUnits.InternationalUnit | `${HKUnits.InternationalUnit}`
545
+ : T extends HKQuantityTypeIdentifier.heartRate | HKQuantityTypeIdentifier.restingHeartRate | HKQuantityTypeIdentifier.walkingHeartRateAverage ? CountPerTime<TimeUnit>
546
+ : HKUnit
547
+
478
548
  export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
479
549
  T extends HKCategoryTypeIdentifier.cervicalMucusQuality
480
550
  ? HKCategoryValueCervicalMucusQuality
@@ -484,17 +554,51 @@ export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
484
554
  ? HKCategoryValueOvulationTestResult
485
555
  : T extends HKCategoryTypeIdentifier.sleepAnalysis
486
556
  ? HKCategoryValueSleepAnalysis
487
- : T extends HKCategoryTypeIdentifier.mindfulSession
557
+ : T extends (HKCategoryTypeIdentifier.highHeartRateEvent | HKCategoryTypeIdentifier.intermenstrualBleeding
558
+ | HKCategoryTypeIdentifier.mindfulSession | HKCategoryTypeIdentifier.sexualActivity)
488
559
  ? HKCategoryValueNotApplicable
489
- : T extends HKCategoryTypeIdentifier.intermenstrualBleeding
490
- ? HKCategoryValueNotApplicable
491
- : T extends HKCategoryTypeIdentifier.highHeartRateEvent
492
- ? HKCategoryValueNotApplicable
493
- : T extends HKCategoryTypeIdentifier.sexualActivity
494
- ? HKCategoryValueNotApplicable
495
- : T extends HKCategoryTypeIdentifier.appleStandHour
496
- ? HKCategoryValueAppleStandHour
497
- : number;
560
+ : T extends (HKCategoryTypeIdentifier.abdominalCramps
561
+ | HKCategoryTypeIdentifier.abdominalCramps
562
+ | HKCategoryTypeIdentifier.acne
563
+ | HKCategoryTypeIdentifier.bladderIncontinence
564
+ | HKCategoryTypeIdentifier.bloating| HKCategoryTypeIdentifier.breastPain
565
+ | HKCategoryTypeIdentifier.chestTightnessOrPain| HKCategoryTypeIdentifier.chills| HKCategoryTypeIdentifier.constipation
566
+ | HKCategoryTypeIdentifier.coughing| HKCategoryTypeIdentifier.diarrhea| HKCategoryTypeIdentifier.dizziness| HKCategoryTypeIdentifier.drySkin| HKCategoryTypeIdentifier.fainting
567
+ | HKCategoryTypeIdentifier.fatigue| HKCategoryTypeIdentifier.fever| HKCategoryTypeIdentifier.generalizedBodyAche| HKCategoryTypeIdentifier.hairLoss
568
+ | HKCategoryTypeIdentifier.headache| HKCategoryTypeIdentifier.heartburn
569
+ | HKCategoryTypeIdentifier.hotFlashes| HKCategoryTypeIdentifier.lossOfSmell| HKCategoryTypeIdentifier.lossOfTaste
570
+ | HKCategoryTypeIdentifier.lowerBackPain| HKCategoryTypeIdentifier.memoryLapse| HKCategoryTypeIdentifier.moodChanges
571
+ | HKCategoryTypeIdentifier.nausea| HKCategoryTypeIdentifier.nightSweats| HKCategoryTypeIdentifier.pelvicPain
572
+ | HKCategoryTypeIdentifier.rapidPoundingOrFlutteringHeartbeat| HKCategoryTypeIdentifier.runnyNose
573
+ | HKCategoryTypeIdentifier.shortnessOfBreath| HKCategoryTypeIdentifier.sinusCongestion| HKCategoryTypeIdentifier.skippedHeartbeat
574
+ | HKCategoryTypeIdentifier.soreThroat| HKCategoryTypeIdentifier.vaginalDryness
575
+ | HKCategoryTypeIdentifier.vomiting| HKCategoryTypeIdentifier.wheezing)
576
+ ? HKCategoryValueSeverity
577
+ : T extends (HKCategoryTypeIdentifier.appetiteChanges | HKCategoryTypeIdentifier.sleepChanges)
578
+ ? HKCategoryValuePresence
579
+ : T extends HKCategoryTypeIdentifier.lowCardioFitnessEvent ? HKCategoryValueLowCardioFitnessEvent :
580
+ T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult :
581
+ T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult :
582
+ T extends HKCategoryTypeIdentifier.appleStandHour
583
+ ? HKCategoryValueAppleStandHour
584
+ : number;
585
+
586
+ enum HKCategoryValuePregnancyTestResult {
587
+ positive = 2,
588
+ negative = 1,
589
+ indeterminate = 3
590
+ }
591
+ /* needs further mapping
592
+
593
+ contraceptive = 'HKCategoryTypeIdentifierContraceptive',
594
+ lactation = 'HKCategoryTypeIdentifierLactation',
595
+ pregnancy = 'HKCategoryTypeIdentifierPregnancy',
596
+
597
+ progesteroneTestResult = 'HKCategoryTypeIdentifierProgesteroneTestResult',
598
+ environmentalAudioExposureEvent = 'HKCategoryTypeIdentifierEnvironmentalAudioExposureEvent',
599
+ headphoneAudioExposureEvent = 'HKCategoryTypeIdentifierHeadphoneAudioExposureEvent',
600
+ appleWalkingSteadinessEvent = 'HKCategoryTypeIdentifierAppleWalkingSteadinessEvent',
601
+ handwashingEvent = 'HKCategoryTypeIdentifierHandwashingEvent', // HKCategoryValue */
498
602
 
499
603
  export type MetadataMapperForCategoryIdentifier<
500
604
  T extends HKCategoryTypeIdentifier
@@ -516,7 +620,8 @@ export enum HKWheelchairUse {
516
620
  }
517
621
 
518
622
  // Unit types are a straight mapping from here https://developer.apple.com/documentation/healthkit/hkunit/1615733-init
519
- export enum HKUnitSIPrefix {
623
+ export enum HKMetricPrefix {
624
+ None = '',
520
625
  Pico = 'p',
521
626
  Nano = 'n',
522
627
  Micro = 'mc',
@@ -529,64 +634,179 @@ export enum HKUnitSIPrefix {
529
634
  Mega = 'M',
530
635
  Giga = 'G',
531
636
  Tera = 'T',
637
+ Femto = 'f',
532
638
  }
533
639
 
534
- export enum HKUnitSI {
535
- Grams = 'g',
536
- Joules = 'J',
640
+ export enum HKUnitMetric {
641
+ Gram = 'g',
642
+ Joule = 'J',
537
643
  Kelvin = 'K',
538
- Liters = 'l',
539
- Meters = 'm',
540
- Pascals = 'Pa',
541
- Seconds = 's',
542
- Siemens = 'S',
644
+ Liter = 'l',
645
+ Meter = 'm',
646
+ Pascal = 'Pa',
647
+ Second = 's',
648
+ Siemen = 'S',
649
+ Hertz = 'Hz',
650
+ Volt = 'V',
543
651
  }
544
652
 
545
- export enum HKUnit {
546
- Grams = 'g',
547
- Joules = 'J',
548
- Kelvin = 'K',
549
- Liters = 'l',
550
- Meters = 'm',
551
- Pascals = 'Pa',
552
- Seconds = 's',
553
- Siemens = 'S',
653
+ export enum HKUnits {
554
654
 
555
- Atmospheres = 'atm',
556
- CentimetersOfWater = 'cmAq',
557
- Count = 'count',
558
- Days = 'd',
559
655
  DecibelHearingLevel = 'dBHL',
560
656
  DecibelSoundPressureLevel = 'dBASPL',
561
- DegreesCelsius = 'degC',
562
- DegreesFahrenheit = 'degF',
657
+
658
+ Percent = '%',
659
+ Count = 'count',
660
+ InternationalUnit = 'IU',
661
+
662
+ }
663
+
664
+ export type MeterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Meter}`;
665
+ export type LiterUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Liter}`;
666
+ export type GramUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Gram}`;
667
+ export type PascalUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Pascal}`;
668
+ export type SecondUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Second}`;
669
+ export type JouleUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Joule}`;
670
+ export type HertzUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Hertz}`;
671
+ export type VoltUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Volt}`;
672
+ export type SiemenUnit<Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}${HKUnitMetric.Siemen}`;
673
+
674
+ // not 100% sure about these
675
+ export type MoleUnit<MolarMass extends number> =`mol<${MolarMass}>`;
676
+ export type MoleUnitWith<MolarMass extends number, Prefix extends HKMetricPrefix = HKMetricPrefix.None> =`${Prefix}mol<${MolarMass}>`;
677
+
678
+ export type FrequencyUnit = HertzUnit<HKMetricPrefix>
679
+
680
+ /**
681
+ * More SI prefixes also available as literals, just type the string
682
+ * @example 'cm', 'km'
683
+ */
684
+ export enum UnitOfLength {
563
685
  Feet = 'ft',
564
- Hertz = 'Hz',
565
- Hours = 'hr',
686
+ /**
687
+ * More SI prefixes also available as literals, just type the string
688
+ * @example 'cm', 'km'
689
+ */
690
+ Meter = 'm',
691
+ Inches = 'in',
692
+ Yards = 'yd',
693
+ Miles = 'mi',
694
+ }
695
+ export type LengthUnit = MeterUnit<HKMetricPrefix> | UnitOfLength
696
+
697
+ /**
698
+ * More SI prefixes also available as literals, just type the string
699
+ * @example 'ml', 'cl'
700
+ */
701
+ export enum UnitOfVolume {
566
702
  ImperialCup = 'cup_imp',
567
703
  ImperialFluidOunces = 'fl_oz_imp',
568
704
  ImperialPint = 'pt_imp',
569
- Inches = 'in',
570
- InternationalUnit = 'IU',
571
- Kilocalories = 'kcal',
572
- LargeCalories = 'Cal',
573
- Miles = 'mi',
574
- MillimetersOfMercury = 'mmHg',
575
- Minutes = 'min',
576
- Ounces = 'oz',
577
- Percent = '%',
578
- Pounds = 'lb',
579
- SmallCalories = 'cal',
580
- Stones = 'st',
581
705
  USCup = 'cup_us',
582
706
  USFluidOunces = 'fl_oz_us',
583
707
  USPint = 'pt_us',
584
- Yard = 'yd',
708
+ /**
709
+ * More SI prefixes also available as literals, just type the string
710
+ * @example 'ml', 'cl'
711
+ */
712
+ Liter = 'l',
713
+ }
714
+ export type VolumeUnit = LiterUnit<HKMetricPrefix> | UnitOfVolume;
715
+
716
+ /**
717
+ * More SI prefixes also available as literals, just type the string
718
+ * @example 'mg', 'kg'
719
+ */
720
+ export enum UnitOfMass {
721
+ Ounces = 'oz',
722
+ Stones = 'st',
723
+ Pounds = 'lb',
724
+ /**
725
+ * More SI prefixes also available as literals, just type the string
726
+ * @example 'mg', 'kg'
727
+ */
728
+ Gram = 'g'
729
+ }
730
+ /**
731
+ * More SI prefixes also available as literals, just type the string
732
+ * @example 'mg', 'kg'
733
+ */
734
+ export type MassUnit = GramUnit<HKMetricPrefix> | UnitOfMass
735
+
736
+ /**
737
+ * More SI prefixes also available as literals, just type the string
738
+ * @example 'kPa', 'hPa'
739
+ */
740
+ export enum UnitOfPressure {
741
+ Atmospheres = 'atm',
742
+ CentimetersOfWater = 'cmAq',
743
+ MillimetersOfMercury = 'mmHg',
744
+ InchesOfMercury = 'inHg',
745
+ DecibelAWeightedSoundPressureLevel = 'dBASPL',
746
+ /**
747
+ * More SI prefixes also available as literals, just type the string
748
+ * @example 'kPa', 'hPa'
749
+ */
750
+ Pascals = 'Pa',
751
+ }
585
752
 
753
+ /**
754
+ * More SI prefixes also available as literals, just type the string
755
+ * @example 'kPa', 'hPa'
756
+ */
757
+ export type PressureUnit = PascalUnit<HKMetricPrefix> | UnitOfPressure;
758
+
759
+ /**
760
+ * More SI prefixes also available as literals, just type the string
761
+ * @example 'ms'
762
+ */
763
+ export enum UnitOfTime {
764
+ Days = 'd',
765
+ Minutes = 'min',
766
+ Hours = 'hr',
767
+ /**
768
+ * More SI prefixes also available as literals, just type the string
769
+ * @example 'ms'
770
+ */
771
+ Seconds = 's',
772
+ }
773
+ /**
774
+ * More SI prefixes also available as literals, just type the string
775
+ * @example 'ms'
776
+ */
777
+ export type TimeUnit = SecondUnit<HKMetricPrefix> | UnitOfTime
778
+ export enum TemperatureUnit {
779
+ DegreesCelsius = 'degC',
780
+ DegreesFahrenheit = 'degF',
781
+ Kelvin = 'K',
782
+ }
783
+
784
+ /**
785
+ * More SI prefixes also available as literals, just type the string
786
+ * @example 'kJ'
787
+ */
788
+ export enum UnitOfEnergy {
789
+ Kilocalories = 'kcal',
790
+ LargeCalories = 'Cal',
791
+ SmallCalories = 'cal',
792
+ /**
793
+ * More SI prefixes also available as literals, just type the string
794
+ * @example 'kJ'
795
+ */
796
+ Joules = 'J',
797
+ }
798
+ export type EnergyUnit = JouleUnit<HKMetricPrefix> | UnitOfEnergy
799
+ export enum BloodGlucoseUnit {
586
800
  GlucoseMmolPerL = 'mmol<180.15588000005408>/l',
587
801
  GlucoseMgPerDl = 'mg/dL',
588
802
  }
589
803
 
804
+ export type SpeedUnit<TLength extends LengthUnit, TTime extends TimeUnit> =`${TLength}/${TTime}`;
805
+ export type CountPerTime<TTime extends TimeUnit> =`count/${TTime}`;
806
+
807
+ export type HKUnit = BloodGlucoseUnit | CountPerTime<TimeUnit> | EnergyUnit | FrequencyUnit | HKUnits | LengthUnit | MassUnit | PressureUnit | SpeedUnit<LengthUnit, TimeUnit> | TemperatureUnit | TimeUnit | VolumeUnit
808
+ | `${BloodGlucoseUnit}` | `${EnergyUnit}` | `${FrequencyUnit}` | `${HKUnits}` | `${LengthUnit}` | `${MassUnit}` | `${PressureUnit}` | `${TemperatureUnit}` | `${TimeUnit}` | `${VolumeUnit}`;
809
+
590
810
  export type HKDevice = {
591
811
  readonly name: string; // ex: "Apple Watch"
592
812
  readonly firmwareVersion: string | null;
@@ -611,7 +831,7 @@ export type HKSourceRevision = {
611
831
 
612
832
  export type HKQuantitySampleRaw<
613
833
  TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
614
- TUnit extends HKUnit = HKUnit
834
+ TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
615
835
  > = {
616
836
  readonly uuid: string;
617
837
  readonly device?: HKDevice;
@@ -624,15 +844,30 @@ export type HKQuantitySampleRaw<
624
844
  readonly sourceRevision?: HKSourceRevision;
625
845
  };
626
846
 
627
- export type HKWorkoutRaw<TEnergy extends HKUnit, TDistance extends HKUnit> = {
847
+ export type HKQuantitySampleRawForSaving<
848
+ TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
849
+ TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>,
850
+ > = Omit<
851
+ HKQuantitySampleRaw<TQuantityIdentifier, TUnit>,
852
+ 'device' | 'endDate' | 'startDate' | 'uuid'
853
+ >
854
+
855
+ export type HKCategorySampleRawForSaving<
856
+ TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier,
857
+ > = Omit<
858
+ HKCategorySampleRaw<TCategory>,
859
+ 'device' | 'endDate' | 'startDate' | 'uuid'
860
+ >
861
+
862
+ export type HKWorkoutRaw<TEnergy extends EnergyUnit, TDistance extends LengthUnit> = {
628
863
  readonly uuid: string;
629
864
  readonly device?: HKDevice;
630
865
  readonly workoutActivityType: HKWorkoutActivityType;
631
866
  readonly duration: number;
632
- readonly totalDistance?: HKQuantity<TDistance>;
633
- readonly totalEnergyBurned?: HKQuantity<TEnergy>;
634
- readonly totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
635
- readonly totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
867
+ readonly totalDistance?: HKQuantity<HKQuantityTypeIdentifier, TDistance>;
868
+ readonly totalEnergyBurned?: HKQuantity<HKQuantityTypeIdentifier, TEnergy>;
869
+ readonly totalSwimmingStrokeCount?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
870
+ readonly totalFlightsClimbed?: HKQuantity<HKQuantityTypeIdentifier, HKUnits.Count>;
636
871
  readonly startDate: string;
637
872
  readonly endDate: string;
638
873
  readonly metadata?: HKWorkoutMetadata;
@@ -646,6 +881,7 @@ export enum HKCharacteristicTypeIdentifier {
646
881
  bloodType = 'HKCharacteristicTypeIdentifierBloodType',
647
882
  dateOfBirth = 'HKCharacteristicTypeIdentifierDateOfBirth',
648
883
  wheelchairUse = 'HKCharacteristicTypeIdentifierWheelchairUse',
884
+ activityMoveMode = 'HKCharacteristicTypeIdentifierActivityMoveMode', // HKActivityMoveModeObject
649
885
  }
650
886
 
651
887
  export type WritePermissions = {
@@ -721,12 +957,9 @@ type ReactNativeHealthkitTypeNative = {
721
957
  ) => Promise<boolean>;
722
958
  readonly disableAllBackgroundDelivery: () => Promise<boolean>;
723
959
 
724
- readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
960
+ readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier, TSamples extends readonly (HKCategorySampleRawForSaving | HKQuantitySampleRawForSaving)[]>(
725
961
  typeIdentifier: TIdentifier,
726
- samples: readonly Omit<
727
- HKCategorySampleRaw | HKQuantitySampleRaw,
728
- 'device' | 'endDate' | 'startDate' | 'uuid'
729
- >[],
962
+ samples: TSamples,
730
963
  start: string,
731
964
  end: string,
732
965
  metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>
@@ -734,10 +967,7 @@ type ReactNativeHealthkitTypeNative = {
734
967
 
735
968
  readonly saveWorkoutSample: (
736
969
  typeIdentifier: HKWorkoutActivityType,
737
- quantities: readonly Omit<
738
- HKQuantitySampleRaw,
739
- 'device' | 'endDate' | 'startDate' | 'uuid'
740
- >[],
970
+ quantities: readonly HKQuantitySampleRawForSaving[],
741
971
  start: string,
742
972
  end: string,
743
973
  metadata: HKWorkoutMetadata
@@ -764,15 +994,15 @@ type ReactNativeHealthkitTypeNative = {
764
994
  write: WritePermissions,
765
995
  read: ReadPermissions
766
996
  ): Promise<boolean>;
767
- readonly saveQuantitySample: (
768
- identifier: HKQuantityTypeIdentifier,
769
- unit: HKUnit,
997
+ readonly saveQuantitySample: <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType> = UnitForIdentifier<TType>> (
998
+ identifier: TType,
999
+ unit: TUnit,
770
1000
  value: number,
771
1001
  start: string,
772
1002
  end: string,
773
1003
  metadata: unknown
774
1004
  ) => Promise<boolean>;
775
- readonly queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
1005
+ readonly queryWorkoutSamples: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(
776
1006
  energyUnit: TEnergy,
777
1007
  distanceUnit: TDistance,
778
1008
  from: string,
@@ -788,8 +1018,8 @@ type ReactNativeHealthkitTypeNative = {
788
1018
  ascending: boolean
789
1019
  ) => Promise<readonly HKCategorySampleRaw<T>[]>;
790
1020
  readonly queryQuantitySamples: <
791
- TUnit extends HKUnit,
792
- TIdentifier extends HKQuantityTypeIdentifier
1021
+ TIdentifier extends HKQuantityTypeIdentifier,
1022
+ TUnit extends UnitForIdentifier<TIdentifier>,
793
1023
  >(
794
1024
  identifier: TIdentifier,
795
1025
  unit: TUnit,
@@ -805,13 +1035,13 @@ type ReactNativeHealthkitTypeNative = {
805
1035
  end: string,
806
1036
  metadata: unknown
807
1037
  ) => Promise<boolean>;
808
- readonly queryStatisticsForQuantity: <TUnit extends HKUnit>(
1038
+ readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(
809
1039
  identifier: HKQuantityTypeIdentifier,
810
1040
  unit: TUnit,
811
1041
  from: string,
812
1042
  to: string,
813
1043
  options: readonly HKStatisticsOptions[]
814
- ) => Promise<QueryStatisticsResponseRaw<TUnit>>;
1044
+ ) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
815
1045
  readonly getPreferredUnits: (
816
1046
  identifiers: readonly HKQuantityTypeIdentifier[]
817
1047
  ) => Promise<TypeToUnitMapping>;