@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.
Files changed (449) hide show
  1. package/ReactNativeHealthkit.podspec +36 -0
  2. package/app.plugin.js +43 -33
  3. package/ios/Bridge.h +8 -0
  4. package/ios/CategoryTypeModule.swift +128 -0
  5. package/ios/CharacteristicTypeModule.swift +78 -0
  6. package/ios/Constants.swift +2 -0
  7. package/ios/CoreModule.swift +376 -0
  8. package/ios/CorrelationTypeModule.swift +153 -0
  9. package/ios/HeartbeatSeriesModule.swift +189 -0
  10. package/ios/Helpers.swift +529 -251
  11. package/ios/QuantityTypeModule.swift +461 -0
  12. package/ios/Serializers.swift +211 -124
  13. package/ios/SourceProxy.swift +35 -0
  14. package/ios/StateOfMindModule.swift +160 -0
  15. package/ios/WorkoutProxy.swift +405 -0
  16. package/ios/WorkoutSessionModule.swift +182 -0
  17. package/ios/WorkoutsModule.swift +357 -0
  18. package/package.json +43 -127
  19. package/react-native.config.js +16 -0
  20. package/src/hooks/useHealthkitAuthorization.test.ts +47 -29
  21. package/src/hooks/useHealthkitAuthorization.ts +21 -15
  22. package/src/hooks/useIsHealthDataAvailable.test.ts +17 -7
  23. package/src/hooks/useIsHealthDataAvailable.ts +7 -7
  24. package/src/hooks/useMostRecentCategorySample.ts +10 -12
  25. package/src/hooks/useMostRecentQuantitySample.ts +17 -36
  26. package/src/hooks/useMostRecentWorkout.ts +16 -38
  27. package/src/hooks/useSources.ts +8 -12
  28. package/src/hooks/useStatisticsForQuantity.ts +19 -14
  29. package/src/hooks/useSubscribeToChanges.ts +9 -13
  30. package/src/index.ios.ts +232 -0
  31. package/src/index.ts +444 -0
  32. package/src/modules.ts +43 -0
  33. package/src/specs/CategoryTypeModule.nitro.ts +64 -0
  34. package/src/specs/CharacteristicTypeModule.nitro.ts +22 -0
  35. package/src/specs/CoreModule.nitro.ts +107 -0
  36. package/src/specs/CorrelationTypeModule.nitro.ts +23 -0
  37. package/src/specs/HeartbeatSeriesModule.nitro.ts +19 -0
  38. package/src/specs/QuantityTypeModule.nitro.ts +60 -0
  39. package/src/specs/SourceProxy.nitro.ts +13 -0
  40. package/src/specs/StateOfMindModule.nitro.ts +23 -0
  41. package/src/specs/WorkoutProxy.nitro.ts +18 -0
  42. package/src/specs/WorkoutSessionModule.nitro.ts +71 -0
  43. package/src/specs/WorkoutsModule.nitro.ts +32 -0
  44. package/src/test-setup.ts +68 -54
  45. package/src/test-utils.ts +3 -2
  46. package/src/types/Auth.ts +17 -0
  47. package/src/types/Background.ts +9 -0
  48. package/src/types/CategoryType.ts +249 -0
  49. package/src/types/CategoryTypeIdentifier.ts +99 -0
  50. package/src/types/Characteristics.ts +53 -0
  51. package/src/types/Constants.ts +25 -0
  52. package/src/types/CorrelationType.ts +31 -0
  53. package/src/types/Device.ts +13 -0
  54. package/src/types/HeartbeatSeries.ts +29 -0
  55. package/src/types/InterfaceVerification.ts +164 -0
  56. package/src/types/InterfaceVerificationExample.ts +89 -0
  57. package/src/types/QuantitySample.ts +30 -0
  58. package/src/types/QuantityType.ts +192 -0
  59. package/src/types/QuantityTypeIdentifier.ts +758 -0
  60. package/src/types/QueryOptions.ts +69 -0
  61. package/src/types/README-InterfaceVerification.md +103 -0
  62. package/src/types/Shared.ts +79 -0
  63. package/src/types/Source.ts +11 -0
  64. package/src/types/StateOfMind.ts +110 -0
  65. package/src/types/Subscriptons.ts +10 -0
  66. package/src/types/Units.ts +190 -0
  67. package/src/types/WeatherCondition.ts +31 -0
  68. package/src/types/WorkoutKit.ts +18 -0
  69. package/src/types/Workouts.ts +282 -0
  70. package/src/utils/getMostRecentCategorySample.ts +7 -11
  71. package/src/utils/getMostRecentQuantitySample.ts +8 -18
  72. package/src/utils/getMostRecentWorkout.ts +7 -17
  73. package/src/utils/getPreferredUnit.ts +12 -8
  74. package/src/utils/subscribeToChanges.ts +9 -26
  75. package/LICENSE +0 -21
  76. package/README.md +0 -179
  77. package/ios/ReactNativeHealthkit-Bridging-Header.h +0 -2
  78. package/ios/ReactNativeHealthkit.m +0 -271
  79. package/ios/ReactNativeHealthkit.swift +0 -2333
  80. package/ios/ReactNativeHealthkit.xcodeproj/project.pbxproj +0 -279
  81. package/kingstinct-react-native-healthkit.podspec +0 -21
  82. package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -39
  83. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +0 -1
  84. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +0 -72
  85. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +0 -1
  86. package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -27
  87. package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +0 -1
  88. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +0 -41
  89. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +0 -1
  90. package/lib/commonjs/hooks/useMostRecentCategorySample.js +0 -23
  91. package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +0 -1
  92. package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -37
  93. package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +0 -1
  94. package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -48
  95. package/lib/commonjs/hooks/useMostRecentWorkout.js.map +0 -1
  96. package/lib/commonjs/hooks/useSources.js +0 -22
  97. package/lib/commonjs/hooks/useSources.js.map +0 -1
  98. package/lib/commonjs/hooks/useStatisticsForQuantity.js +0 -28
  99. package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +0 -1
  100. package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -28
  101. package/lib/commonjs/hooks/useSubscribeToChanges.js.map +0 -1
  102. package/lib/commonjs/index.ios.js +0 -531
  103. package/lib/commonjs/index.ios.js.map +0 -1
  104. package/lib/commonjs/index.js +0 -22
  105. package/lib/commonjs/index.js.map +0 -1
  106. package/lib/commonjs/index.native.js +0 -235
  107. package/lib/commonjs/index.native.js.map +0 -1
  108. package/lib/commonjs/index.web.js +0 -22
  109. package/lib/commonjs/index.web.js.map +0 -1
  110. package/lib/commonjs/native-types.js +0 -1575
  111. package/lib/commonjs/native-types.js.map +0 -1
  112. package/lib/commonjs/test-setup.js +0 -57
  113. package/lib/commonjs/test-setup.js.map +0 -1
  114. package/lib/commonjs/test-utils.js +0 -18
  115. package/lib/commonjs/test-utils.js.map +0 -1
  116. package/lib/commonjs/types.js +0 -17
  117. package/lib/commonjs/types.js.map +0 -1
  118. package/lib/commonjs/utils/deleteQuantitySample.js +0 -11
  119. package/lib/commonjs/utils/deleteQuantitySample.js.map +0 -1
  120. package/lib/commonjs/utils/deleteSamples.js +0 -18
  121. package/lib/commonjs/utils/deleteSamples.js.map +0 -1
  122. package/lib/commonjs/utils/deleteWorkoutSample.js +0 -11
  123. package/lib/commonjs/utils/deleteWorkoutSample.js.map +0 -1
  124. package/lib/commonjs/utils/deserializeCategorySample.js +0 -13
  125. package/lib/commonjs/utils/deserializeCategorySample.js.map +0 -1
  126. package/lib/commonjs/utils/deserializeCategorySample.test.js +0 -26
  127. package/lib/commonjs/utils/deserializeCategorySample.test.js.map +0 -1
  128. package/lib/commonjs/utils/deserializeCorrelation.js +0 -26
  129. package/lib/commonjs/utils/deserializeCorrelation.js.map +0 -1
  130. package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +0 -15
  131. package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
  132. package/lib/commonjs/utils/deserializeSample.js +0 -15
  133. package/lib/commonjs/utils/deserializeSample.js.map +0 -1
  134. package/lib/commonjs/utils/deserializeWorkout.js +0 -15
  135. package/lib/commonjs/utils/deserializeWorkout.js.map +0 -1
  136. package/lib/commonjs/utils/ensureMetadata.js +0 -11
  137. package/lib/commonjs/utils/ensureMetadata.js.map +0 -1
  138. package/lib/commonjs/utils/ensureTotals.js +0 -11
  139. package/lib/commonjs/utils/ensureTotals.js.map +0 -1
  140. package/lib/commonjs/utils/ensureUnit.js +0 -17
  141. package/lib/commonjs/utils/ensureUnit.js.map +0 -1
  142. package/lib/commonjs/utils/getDateOfBirth.js +0 -14
  143. package/lib/commonjs/utils/getDateOfBirth.js.map +0 -1
  144. package/lib/commonjs/utils/getMostRecentCategorySample.js +0 -17
  145. package/lib/commonjs/utils/getMostRecentCategorySample.js.map +0 -1
  146. package/lib/commonjs/utils/getMostRecentQuantitySample.js +0 -21
  147. package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +0 -1
  148. package/lib/commonjs/utils/getMostRecentWorkout.js +0 -19
  149. package/lib/commonjs/utils/getMostRecentWorkout.js.map +0 -1
  150. package/lib/commonjs/utils/getPreferredUnit.js +0 -14
  151. package/lib/commonjs/utils/getPreferredUnit.js.map +0 -1
  152. package/lib/commonjs/utils/getPreferredUnits.js +0 -14
  153. package/lib/commonjs/utils/getPreferredUnits.js.map +0 -1
  154. package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -33
  155. package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +0 -1
  156. package/lib/commonjs/utils/getRequestStatusForAuthorization.js +0 -21
  157. package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +0 -1
  158. package/lib/commonjs/utils/getWorkoutPlanById.js +0 -13
  159. package/lib/commonjs/utils/getWorkoutPlanById.js.map +0 -1
  160. package/lib/commonjs/utils/prepareOptions.js +0 -25
  161. package/lib/commonjs/utils/prepareOptions.js.map +0 -1
  162. package/lib/commonjs/utils/queryCategorySamples.js +0 -17
  163. package/lib/commonjs/utils/queryCategorySamples.js.map +0 -1
  164. package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +0 -21
  165. package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +0 -1
  166. package/lib/commonjs/utils/queryCorrelationSamples.js +0 -17
  167. package/lib/commonjs/utils/queryCorrelationSamples.js.map +0 -1
  168. package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +0 -17
  169. package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +0 -1
  170. package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -21
  171. package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
  172. package/lib/commonjs/utils/queryQuantitySamples.js +0 -19
  173. package/lib/commonjs/utils/queryQuantitySamples.js.map +0 -1
  174. package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +0 -23
  175. package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
  176. package/lib/commonjs/utils/querySources.js +0 -14
  177. package/lib/commonjs/utils/querySources.js.map +0 -1
  178. package/lib/commonjs/utils/queryStateOfMindSamples.js +0 -22
  179. package/lib/commonjs/utils/queryStateOfMindSamples.js.map +0 -1
  180. package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js +0 -16
  181. package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
  182. package/lib/commonjs/utils/queryStatisticsForQuantity.js +0 -29
  183. package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +0 -1
  184. package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js +0 -26
  185. package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
  186. package/lib/commonjs/utils/queryWorkouts.js +0 -22
  187. package/lib/commonjs/utils/queryWorkouts.js.map +0 -1
  188. package/lib/commonjs/utils/requestAuthorization.js +0 -22
  189. package/lib/commonjs/utils/requestAuthorization.js.map +0 -1
  190. package/lib/commonjs/utils/saveCategorySample.js +0 -20
  191. package/lib/commonjs/utils/saveCategorySample.js.map +0 -1
  192. package/lib/commonjs/utils/saveCorrelationSample.js +0 -35
  193. package/lib/commonjs/utils/saveCorrelationSample.js.map +0 -1
  194. package/lib/commonjs/utils/saveQuantitySample.js +0 -16
  195. package/lib/commonjs/utils/saveQuantitySample.js.map +0 -1
  196. package/lib/commonjs/utils/saveStateOfMindSample.js +0 -17
  197. package/lib/commonjs/utils/saveStateOfMindSample.js.map +0 -1
  198. package/lib/commonjs/utils/saveWorkoutRoute.js +0 -26
  199. package/lib/commonjs/utils/saveWorkoutRoute.js.map +0 -1
  200. package/lib/commonjs/utils/saveWorkoutSample.js +0 -36
  201. package/lib/commonjs/utils/saveWorkoutSample.js.map +0 -1
  202. package/lib/commonjs/utils/serializeDate.js +0 -9
  203. package/lib/commonjs/utils/serializeDate.js.map +0 -1
  204. package/lib/commonjs/utils/serializeDate.test.js +0 -17
  205. package/lib/commonjs/utils/serializeDate.test.js.map +0 -1
  206. package/lib/commonjs/utils/startWatchApp.js +0 -11
  207. package/lib/commonjs/utils/startWatchApp.js.map +0 -1
  208. package/lib/commonjs/utils/subscribeToChanges.js +0 -27
  209. package/lib/commonjs/utils/subscribeToChanges.js.map +0 -1
  210. package/lib/module/hooks/useHealthkitAuthorization.js +0 -32
  211. package/lib/module/hooks/useHealthkitAuthorization.js.map +0 -1
  212. package/lib/module/hooks/useHealthkitAuthorization.test.js +0 -68
  213. package/lib/module/hooks/useHealthkitAuthorization.test.js.map +0 -1
  214. package/lib/module/hooks/useIsHealthDataAvailable.js +0 -21
  215. package/lib/module/hooks/useIsHealthDataAvailable.js.map +0 -1
  216. package/lib/module/hooks/useIsHealthDataAvailable.test.js +0 -37
  217. package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +0 -1
  218. package/lib/module/hooks/useMostRecentCategorySample.js +0 -16
  219. package/lib/module/hooks/useMostRecentCategorySample.js.map +0 -1
  220. package/lib/module/hooks/useMostRecentQuantitySample.js +0 -30
  221. package/lib/module/hooks/useMostRecentQuantitySample.js.map +0 -1
  222. package/lib/module/hooks/useMostRecentWorkout.js +0 -41
  223. package/lib/module/hooks/useMostRecentWorkout.js.map +0 -1
  224. package/lib/module/hooks/useSources.js +0 -15
  225. package/lib/module/hooks/useSources.js.map +0 -1
  226. package/lib/module/hooks/useStatisticsForQuantity.js +0 -21
  227. package/lib/module/hooks/useStatisticsForQuantity.js.map +0 -1
  228. package/lib/module/hooks/useSubscribeToChanges.js +0 -21
  229. package/lib/module/hooks/useSubscribeToChanges.js.map +0 -1
  230. package/lib/module/index.ios.js +0 -209
  231. package/lib/module/index.ios.js.map +0 -1
  232. package/lib/module/index.js +0 -4
  233. package/lib/module/index.js.map +0 -1
  234. package/lib/module/index.native.js +0 -160
  235. package/lib/module/index.native.js.map +0 -1
  236. package/lib/module/index.web.js +0 -4
  237. package/lib/module/index.web.js.map +0 -1
  238. package/lib/module/native-types.js +0 -1606
  239. package/lib/module/native-types.js.map +0 -1
  240. package/lib/module/test-setup.js +0 -54
  241. package/lib/module/test-setup.js.map +0 -1
  242. package/lib/module/test-utils.js +0 -11
  243. package/lib/module/test-utils.js.map +0 -1
  244. package/lib/module/types.js +0 -67
  245. package/lib/module/types.js.map +0 -1
  246. package/lib/module/utils/deleteQuantitySample.js +0 -4
  247. package/lib/module/utils/deleteQuantitySample.js.map +0 -1
  248. package/lib/module/utils/deleteSamples.js +0 -11
  249. package/lib/module/utils/deleteSamples.js.map +0 -1
  250. package/lib/module/utils/deleteWorkoutSample.js +0 -4
  251. package/lib/module/utils/deleteWorkoutSample.js.map +0 -1
  252. package/lib/module/utils/deserializeCategorySample.js +0 -7
  253. package/lib/module/utils/deserializeCategorySample.js.map +0 -1
  254. package/lib/module/utils/deserializeCategorySample.test.js +0 -22
  255. package/lib/module/utils/deserializeCategorySample.test.js.map +0 -1
  256. package/lib/module/utils/deserializeCorrelation.js +0 -19
  257. package/lib/module/utils/deserializeCorrelation.js.map +0 -1
  258. package/lib/module/utils/deserializeHeartbeatSeriesSample.js +0 -9
  259. package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
  260. package/lib/module/utils/deserializeSample.js +0 -9
  261. package/lib/module/utils/deserializeSample.js.map +0 -1
  262. package/lib/module/utils/deserializeWorkout.js +0 -9
  263. package/lib/module/utils/deserializeWorkout.js.map +0 -1
  264. package/lib/module/utils/ensureMetadata.js +0 -5
  265. package/lib/module/utils/ensureMetadata.js.map +0 -1
  266. package/lib/module/utils/ensureTotals.js +0 -5
  267. package/lib/module/utils/ensureTotals.js.map +0 -1
  268. package/lib/module/utils/ensureUnit.js +0 -10
  269. package/lib/module/utils/ensureUnit.js.map +0 -1
  270. package/lib/module/utils/getDateOfBirth.js +0 -7
  271. package/lib/module/utils/getDateOfBirth.js.map +0 -1
  272. package/lib/module/utils/getMostRecentCategorySample.js +0 -10
  273. package/lib/module/utils/getMostRecentCategorySample.js.map +0 -1
  274. package/lib/module/utils/getMostRecentQuantitySample.js +0 -14
  275. package/lib/module/utils/getMostRecentQuantitySample.js.map +0 -1
  276. package/lib/module/utils/getMostRecentWorkout.js +0 -12
  277. package/lib/module/utils/getMostRecentWorkout.js.map +0 -1
  278. package/lib/module/utils/getPreferredUnit.js +0 -7
  279. package/lib/module/utils/getPreferredUnit.js.map +0 -1
  280. package/lib/module/utils/getPreferredUnits.js +0 -7
  281. package/lib/module/utils/getPreferredUnits.js.map +0 -1
  282. package/lib/module/utils/getPreferredUnitsTyped.js +0 -26
  283. package/lib/module/utils/getPreferredUnitsTyped.js.map +0 -1
  284. package/lib/module/utils/getRequestStatusForAuthorization.js +0 -14
  285. package/lib/module/utils/getRequestStatusForAuthorization.js.map +0 -1
  286. package/lib/module/utils/getWorkoutPlanById.js +0 -6
  287. package/lib/module/utils/getWorkoutPlanById.js.map +0 -1
  288. package/lib/module/utils/prepareOptions.js +0 -18
  289. package/lib/module/utils/prepareOptions.js.map +0 -1
  290. package/lib/module/utils/queryCategorySamples.js +0 -10
  291. package/lib/module/utils/queryCategorySamples.js.map +0 -1
  292. package/lib/module/utils/queryCategorySamplesWithAnchor.js +0 -14
  293. package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +0 -1
  294. package/lib/module/utils/queryCorrelationSamples.js +0 -10
  295. package/lib/module/utils/queryCorrelationSamples.js.map +0 -1
  296. package/lib/module/utils/queryHeartbeatSeriesSamples.js +0 -10
  297. package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +0 -1
  298. package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -14
  299. package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
  300. package/lib/module/utils/queryQuantitySamples.js +0 -12
  301. package/lib/module/utils/queryQuantitySamples.js.map +0 -1
  302. package/lib/module/utils/queryQuantitySamplesWithAnchor.js +0 -16
  303. package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
  304. package/lib/module/utils/querySources.js +0 -7
  305. package/lib/module/utils/querySources.js.map +0 -1
  306. package/lib/module/utils/queryStateOfMindSamples.js +0 -14
  307. package/lib/module/utils/queryStateOfMindSamples.js.map +0 -1
  308. package/lib/module/utils/queryStatisticsCollectionForQuantity.js +0 -9
  309. package/lib/module/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
  310. package/lib/module/utils/queryStatisticsForQuantity.js +0 -22
  311. package/lib/module/utils/queryStatisticsForQuantity.js.map +0 -1
  312. package/lib/module/utils/queryWorkoutSamplesWithAnchor.js +0 -19
  313. package/lib/module/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
  314. package/lib/module/utils/queryWorkouts.js +0 -15
  315. package/lib/module/utils/queryWorkouts.js.map +0 -1
  316. package/lib/module/utils/requestAuthorization.js +0 -15
  317. package/lib/module/utils/requestAuthorization.js.map +0 -1
  318. package/lib/module/utils/saveCategorySample.js +0 -13
  319. package/lib/module/utils/saveCategorySample.js.map +0 -1
  320. package/lib/module/utils/saveCorrelationSample.js +0 -28
  321. package/lib/module/utils/saveCorrelationSample.js.map +0 -1
  322. package/lib/module/utils/saveQuantitySample.js +0 -9
  323. package/lib/module/utils/saveQuantitySample.js.map +0 -1
  324. package/lib/module/utils/saveStateOfMindSample.js +0 -10
  325. package/lib/module/utils/saveStateOfMindSample.js.map +0 -1
  326. package/lib/module/utils/saveWorkoutRoute.js +0 -19
  327. package/lib/module/utils/saveWorkoutRoute.js.map +0 -1
  328. package/lib/module/utils/saveWorkoutSample.js +0 -29
  329. package/lib/module/utils/saveWorkoutSample.js.map +0 -1
  330. package/lib/module/utils/serializeDate.js +0 -3
  331. package/lib/module/utils/serializeDate.js.map +0 -1
  332. package/lib/module/utils/serializeDate.test.js +0 -14
  333. package/lib/module/utils/serializeDate.test.js.map +0 -1
  334. package/lib/module/utils/startWatchApp.js +0 -4
  335. package/lib/module/utils/startWatchApp.js.map +0 -1
  336. package/lib/module/utils/subscribeToChanges.js +0 -20
  337. package/lib/module/utils/subscribeToChanges.js.map +0 -1
  338. package/lib/typescript/example-expo/App.d.ts +0 -2
  339. package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +0 -8
  340. package/lib/typescript/src/hooks/useHealthkitAuthorization.test.d.ts +0 -1
  341. package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +0 -7
  342. package/lib/typescript/src/hooks/useIsHealthDataAvailable.test.d.ts +0 -1
  343. package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +0 -7
  344. package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +0 -7
  345. package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +0 -10
  346. package/lib/typescript/src/hooks/useSources.d.ts +0 -3
  347. package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +0 -4
  348. package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +0 -3
  349. package/lib/typescript/src/index.d.ts +0 -3
  350. package/lib/typescript/src/index.ios.d.ts +0 -198
  351. package/lib/typescript/src/index.native.d.ts +0 -41
  352. package/lib/typescript/src/index.web.d.ts +0 -3
  353. package/lib/typescript/src/native-types.d.ts +0 -1764
  354. package/lib/typescript/src/test-setup.d.ts +0 -1
  355. package/lib/typescript/src/test-utils.d.ts +0 -2
  356. package/lib/typescript/src/types.d.ts +0 -111
  357. package/lib/typescript/src/utils/deleteQuantitySample.d.ts +0 -4
  358. package/lib/typescript/src/utils/deleteSamples.d.ts +0 -8
  359. package/lib/typescript/src/utils/deleteWorkoutSample.d.ts +0 -3
  360. package/lib/typescript/src/utils/deserializeCategorySample.d.ts +0 -4
  361. package/lib/typescript/src/utils/deserializeCategorySample.test.d.ts +0 -1
  362. package/lib/typescript/src/utils/deserializeCorrelation.d.ts +0 -4
  363. package/lib/typescript/src/utils/deserializeHeartbeatSeriesSample.d.ts +0 -4
  364. package/lib/typescript/src/utils/deserializeSample.d.ts +0 -4
  365. package/lib/typescript/src/utils/deserializeWorkout.d.ts +0 -4
  366. package/lib/typescript/src/utils/ensureMetadata.d.ts +0 -2
  367. package/lib/typescript/src/utils/ensureTotals.d.ts +0 -2
  368. package/lib/typescript/src/utils/ensureUnit.d.ts +0 -3
  369. package/lib/typescript/src/utils/getDateOfBirth.d.ts +0 -2
  370. package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +0 -4
  371. package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +0 -4
  372. package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +0 -5
  373. package/lib/typescript/src/utils/getPreferredUnit.d.ts +0 -4
  374. package/lib/typescript/src/utils/getPreferredUnits.d.ts +0 -4
  375. package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +0 -9
  376. package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +0 -3
  377. package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +0 -5
  378. package/lib/typescript/src/utils/prepareOptions.d.ts +0 -9
  379. package/lib/typescript/src/utils/queryCategorySamples.d.ts +0 -5
  380. package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +0 -10
  381. package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +0 -5
  382. package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +0 -10
  383. package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +0 -10
  384. package/lib/typescript/src/utils/queryQuantitySamples.d.ts +0 -7
  385. package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +0 -12
  386. package/lib/typescript/src/utils/querySources.d.ts +0 -4
  387. package/lib/typescript/src/utils/queryStateOfMindSamples.d.ts +0 -7
  388. package/lib/typescript/src/utils/queryStatisticsCollectionForQuantity.d.ts +0 -3
  389. package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +0 -14
  390. package/lib/typescript/src/utils/queryWorkoutSamplesWithAnchor.d.ts +0 -9
  391. package/lib/typescript/src/utils/queryWorkouts.d.ts +0 -4
  392. package/lib/typescript/src/utils/requestAuthorization.d.ts +0 -4
  393. package/lib/typescript/src/utils/saveCategorySample.d.ts +0 -11
  394. package/lib/typescript/src/utils/saveCorrelationSample.d.ts +0 -8
  395. package/lib/typescript/src/utils/saveQuantitySample.d.ts +0 -7
  396. package/lib/typescript/src/utils/saveStateOfMindSample.d.ts +0 -11
  397. package/lib/typescript/src/utils/saveWorkoutRoute.d.ts +0 -3
  398. package/lib/typescript/src/utils/saveWorkoutSample.d.ts +0 -11
  399. package/lib/typescript/src/utils/serializeDate.d.ts +0 -2
  400. package/lib/typescript/src/utils/serializeDate.test.d.ts +0 -1
  401. package/lib/typescript/src/utils/startWatchApp.d.ts +0 -3
  402. package/lib/typescript/src/utils/subscribeToChanges.d.ts +0 -3
  403. package/src/index.ios.tsx +0 -292
  404. package/src/index.native.tsx +0 -233
  405. package/src/index.tsx +0 -5
  406. package/src/index.web.tsx +0 -5
  407. package/src/native-types.ts +0 -2471
  408. package/src/types.ts +0 -156
  409. package/src/utils/deleteQuantitySample.ts +0 -14
  410. package/src/utils/deleteSamples.ts +0 -23
  411. package/src/utils/deleteWorkoutSample.ts +0 -7
  412. package/src/utils/deserializeCategorySample.test.ts +0 -24
  413. package/src/utils/deserializeCategorySample.ts +0 -12
  414. package/src/utils/deserializeCorrelation.ts +0 -28
  415. package/src/utils/deserializeHeartbeatSeriesSample.ts +0 -12
  416. package/src/utils/deserializeSample.ts +0 -17
  417. package/src/utils/deserializeWorkout.ts +0 -14
  418. package/src/utils/ensureMetadata.ts +0 -5
  419. package/src/utils/ensureTotals.ts +0 -5
  420. package/src/utils/ensureUnit.ts +0 -19
  421. package/src/utils/getDateOfBirth.ts +0 -8
  422. package/src/utils/getPreferredUnits.ts +0 -14
  423. package/src/utils/getPreferredUnitsTyped.ts +0 -38
  424. package/src/utils/getRequestStatusForAuthorization.ts +0 -21
  425. package/src/utils/getWorkoutPlanById.ts +0 -7
  426. package/src/utils/prepareOptions.ts +0 -19
  427. package/src/utils/queryCategorySamples.ts +0 -29
  428. package/src/utils/queryCategorySamplesWithAnchor.ts +0 -39
  429. package/src/utils/queryCorrelationSamples.ts +0 -29
  430. package/src/utils/queryHeartbeatSeriesSamples.ts +0 -29
  431. package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +0 -33
  432. package/src/utils/queryQuantitySamples.ts +0 -38
  433. package/src/utils/queryQuantitySamplesWithAnchor.ts +0 -46
  434. package/src/utils/querySources.ts +0 -21
  435. package/src/utils/queryStateOfMindSamples.ts +0 -14
  436. package/src/utils/queryStatisticsCollectionForQuantity.ts +0 -38
  437. package/src/utils/queryStatisticsForQuantity.ts +0 -38
  438. package/src/utils/queryWorkoutSamplesWithAnchor.ts +0 -46
  439. package/src/utils/queryWorkouts.ts +0 -28
  440. package/src/utils/requestAuthorization.ts +0 -19
  441. package/src/utils/saveCategorySample.ts +0 -31
  442. package/src/utils/saveCorrelationSample.ts +0 -43
  443. package/src/utils/saveQuantitySample.ts +0 -29
  444. package/src/utils/saveStateOfMindSample.ts +0 -38
  445. package/src/utils/saveWorkoutRoute.ts +0 -21
  446. package/src/utils/saveWorkoutSample.ts +0 -42
  447. package/src/utils/serializeDate.test.ts +0 -16
  448. package/src/utils/serializeDate.ts +0 -5
  449. 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
+ }