react-native-rook-sdk 2.1.2 → 4.0.0-beta.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 (335) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +35 -3
  3. package/RNRookSdk.podspec +22 -0
  4. package/android/build.gradle +20 -41
  5. package/android/gradle.properties +5 -5
  6. package/android/src/main/AndroidManifest.xml +1 -2
  7. package/android/src/main/java/com/rooksdk/RookSdkModule.kt +11 -222
  8. package/android/src/main/java/com/rooksdk/RookSdkPackage.kt +24 -33
  9. package/ios/DateHelper.swift +55 -0
  10. package/ios/Encodable.swift +25 -0
  11. package/ios/EncodableDataSource.swift +5 -6
  12. package/ios/EncodableDataSourceAuthorizer.swift +3 -4
  13. package/ios/HearRateMapper.swift +42 -0
  14. package/ios/RookBackground.swift +35 -0
  15. package/ios/RookConfiguration.swift +116 -0
  16. package/ios/RookData.swift +170 -0
  17. package/ios/RookEntry.swift +61 -0
  18. package/ios/RookPermissions.swift +78 -0
  19. package/ios/RookSdk-Bridging-Header.h +12 -0
  20. package/ios/RookSdk.h +14 -2
  21. package/ios/RookSdk.mm +549 -81
  22. package/ios/RookSources.swift +74 -116
  23. package/ios/RookSync.swift +126 -34
  24. package/ios/boost-boost_privacy-Bridging-Header.h +4 -0
  25. package/lib/module/NativeRookSdk.js +96 -0
  26. package/lib/module/NativeRookSdk.js.map +1 -0
  27. package/lib/module/context/RookSyncGateContext.js +2 -0
  28. package/lib/module/context/RookSyncGateContext.js.map +1 -1
  29. package/lib/module/context/RookSyncGateProvider.js +16 -15
  30. package/lib/module/context/RookSyncGateProvider.js.map +1 -1
  31. package/lib/module/context/RookSyncGateReducer.js +2 -0
  32. package/lib/module/context/RookSyncGateReducer.js.map +1 -1
  33. package/lib/module/context/RookSyncGateTypes.js +2 -0
  34. package/lib/module/hooks/useRookAPISources.js +66 -0
  35. package/lib/module/hooks/useRookAPISources.js.map +1 -0
  36. package/lib/module/hooks/useRookAndroidBackgroundSteps.js +12 -25
  37. package/lib/module/hooks/useRookAndroidBackgroundSteps.js.map +1 -1
  38. package/lib/module/hooks/useRookAppleHealth.js +11 -23
  39. package/lib/module/hooks/useRookAppleHealth.js.map +1 -1
  40. package/lib/module/hooks/useRookConfiguration.js +10 -109
  41. package/lib/module/hooks/useRookConfiguration.js.map +1 -1
  42. package/lib/module/hooks/useRookData.js +35 -33
  43. package/lib/module/hooks/useRookData.js.map +1 -1
  44. package/lib/module/hooks/useRookHealthConnect.js +9 -10
  45. package/lib/module/hooks/useRookHealthConnect.js.map +1 -1
  46. package/lib/module/hooks/useRookPermissions.js +39 -77
  47. package/lib/module/hooks/useRookPermissions.js.map +1 -1
  48. package/lib/module/hooks/useRookSamsungHealth.js +35 -0
  49. package/lib/module/hooks/useRookSamsungHealth.js.map +1 -0
  50. package/lib/module/hooks/useRookSync.js +23 -31
  51. package/lib/module/hooks/useRookSync.js.map +1 -1
  52. package/lib/module/hooks/useRookVariables.js +24 -18
  53. package/lib/module/hooks/useRookVariables.js.map +1 -1
  54. package/lib/module/index.js +18 -5
  55. package/lib/module/index.js.map +1 -1
  56. package/lib/module/modules/hook/useRookAutoSync.js +22 -36
  57. package/lib/module/modules/hook/useRookAutoSync.js.map +1 -1
  58. package/lib/module/modules/types/sendMessageBroadcast.js +1 -1
  59. package/lib/module/modules/utils/errors.js +2 -0
  60. package/lib/module/modules/utils/errors.js.map +1 -1
  61. package/lib/module/package.json +1 -0
  62. package/lib/module/types/ActivityEvent.js +2 -0
  63. package/lib/module/types/AppleHealthPermissions.js +53 -0
  64. package/lib/module/types/AppleHealthPermissions.js.map +1 -0
  65. package/lib/module/types/AuthorizedSources.js +2 -0
  66. package/lib/module/types/BodySummary.js +2 -0
  67. package/lib/module/types/DataSource.js +10 -0
  68. package/lib/module/types/DataSource.js.map +1 -1
  69. package/lib/module/types/HeartRateEvent.js +2 -0
  70. package/lib/{commonjs/types/DataSource.js.map → module/types/HeartRateEvent.js.map} +1 -1
  71. package/lib/module/types/PermissionsType.js +1 -1
  72. package/lib/module/types/PhysicalSummary.js +2 -0
  73. package/lib/module/types/Rook.js +2 -0
  74. package/lib/{commonjs/types/SyncTypes.js.map → module/types/Rook.js.map} +1 -1
  75. package/lib/module/types/SDKSources.js +2 -0
  76. package/lib/module/types/SDKSources.js.map +1 -1
  77. package/lib/module/types/SamsungHealthPermissions.js +3 -0
  78. package/lib/module/types/SamsungHealthPermissions.js.map +1 -1
  79. package/lib/module/types/SleepSummary.js +2 -0
  80. package/lib/module/types/SummaryTypes.js +1 -1
  81. package/lib/module/types/SyncTypes.js +28 -1
  82. package/lib/module/types/SyncTypes.js.map +1 -1
  83. package/lib/module/utils/isModuleReady.js +2 -0
  84. package/lib/module/utils/isModuleReady.js.map +1 -1
  85. package/lib/module/utils/isRunningOnAndroid.js +2 -0
  86. package/lib/module/utils/isRunningOnAndroid.js.map +1 -1
  87. package/lib/module/utils/isRunningOniOS.js +2 -0
  88. package/lib/module/utils/isRunningOniOS.js.map +1 -1
  89. package/lib/module/utils/isValidDate.js +2 -0
  90. package/lib/module/utils/isValidDate.js.map +1 -1
  91. package/lib/typescript/package.json +1 -0
  92. package/lib/typescript/src/NativeRookSdk.d.ts +190 -0
  93. package/lib/typescript/src/NativeRookSdk.d.ts.map +1 -0
  94. package/lib/typescript/src/context/RookSyncGateContext.d.ts.map +1 -1
  95. package/lib/typescript/src/context/RookSyncGateProvider.d.ts.map +1 -1
  96. package/lib/typescript/src/context/RookSyncGateReducer.d.ts.map +1 -1
  97. package/lib/typescript/src/hooks/useRookAPISources.d.ts +15 -0
  98. package/lib/typescript/src/hooks/useRookAPISources.d.ts.map +1 -0
  99. package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts +0 -1
  100. package/lib/typescript/src/hooks/useRookAndroidBackgroundSteps.d.ts.map +1 -1
  101. package/lib/typescript/src/hooks/useRookAppleHealth.d.ts +1 -2
  102. package/lib/typescript/src/hooks/useRookAppleHealth.d.ts.map +1 -1
  103. package/lib/typescript/src/hooks/useRookConfiguration.d.ts +0 -8
  104. package/lib/typescript/src/hooks/useRookConfiguration.d.ts.map +1 -1
  105. package/lib/typescript/src/hooks/useRookData.d.ts +2 -0
  106. package/lib/typescript/src/hooks/useRookData.d.ts.map +1 -1
  107. package/lib/typescript/src/hooks/useRookHealthConnect.d.ts.map +1 -1
  108. package/lib/typescript/src/hooks/useRookPermissions.d.ts +11 -12
  109. package/lib/typescript/src/hooks/useRookPermissions.d.ts.map +1 -1
  110. package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts +7 -0
  111. package/lib/typescript/src/hooks/useRookSamsungHealth.d.ts.map +1 -0
  112. package/lib/typescript/src/hooks/useRookSync.d.ts.map +1 -1
  113. package/lib/typescript/src/hooks/useRookVariables.d.ts.map +1 -1
  114. package/lib/typescript/src/index.d.ts +19 -4
  115. package/lib/typescript/src/index.d.ts.map +1 -1
  116. package/lib/typescript/src/modules/hook/useRookAutoSync.d.ts.map +1 -1
  117. package/lib/typescript/src/types/AppleHealthPermissions.d.ts +50 -0
  118. package/lib/typescript/src/types/AppleHealthPermissions.d.ts.map +1 -0
  119. package/lib/typescript/src/types/AuthorizedSources.d.ts +3 -3
  120. package/lib/typescript/src/types/AuthorizedSources.d.ts.map +1 -1
  121. package/lib/typescript/src/types/DataSource.d.ts +8 -1
  122. package/lib/typescript/src/types/DataSource.d.ts.map +1 -1
  123. package/lib/typescript/src/types/HeartRateEvent.d.ts +24 -0
  124. package/lib/typescript/src/types/HeartRateEvent.d.ts.map +1 -0
  125. package/lib/typescript/src/types/PermissionsType.d.ts +0 -4
  126. package/lib/typescript/src/types/PermissionsType.d.ts.map +1 -1
  127. package/lib/typescript/src/types/Rook.d.ts +9 -0
  128. package/lib/typescript/src/types/Rook.d.ts.map +1 -0
  129. package/lib/typescript/src/types/SamsungHealthPermissions.d.ts +1 -0
  130. package/lib/typescript/src/types/SamsungHealthPermissions.d.ts.map +1 -1
  131. package/lib/typescript/src/types/SyncTypes.d.ts +28 -5
  132. package/lib/typescript/src/types/SyncTypes.d.ts.map +1 -1
  133. package/lib/typescript/src/utils/isModuleReady.d.ts.map +1 -1
  134. package/lib/typescript/src/utils/isValidDate.d.ts.map +1 -1
  135. package/package.json +94 -98
  136. package/src/NativeRookSdk.ts +282 -0
  137. package/{lib/commonjs/context/RookSyncGateContext.js → src/context/RookSyncGateContext.ts} +10 -13
  138. package/src/context/RookSyncGateProvider.tsx +78 -0
  139. package/{lib/commonjs/context/RookSyncGateReducer.js → src/context/RookSyncGateReducer.ts} +12 -33
  140. package/src/context/RookSyncGateTypes.ts +34 -0
  141. package/src/hooks/useRookAPISources.ts +83 -0
  142. package/src/hooks/useRookAndroidBackgroundSteps.ts +81 -0
  143. package/src/hooks/useRookAppleHealth.ts +55 -0
  144. package/src/hooks/useRookConfiguration.ts +82 -0
  145. package/src/hooks/useRookData.ts +122 -0
  146. package/src/hooks/useRookHealthConnect.ts +59 -0
  147. package/src/hooks/useRookPermissions.ts +224 -0
  148. package/src/hooks/useRookSamsungHealth.ts +37 -0
  149. package/src/hooks/useRookSync.ts +157 -0
  150. package/src/hooks/useRookVariables.ts +77 -0
  151. package/src/index.tsx +28 -0
  152. package/src/modules/hook/useRookAutoSync.ts +305 -0
  153. package/src/modules/types/sendMessageBroadcast.ts +5 -0
  154. package/src/modules/utils/errors.ts +9 -0
  155. package/src/types/ActivityEvent.ts +159 -0
  156. package/src/types/AppleHealthPermissions.ts +49 -0
  157. package/src/types/AuthorizedSources.ts +33 -0
  158. package/src/types/BodySummary.ts +116 -0
  159. package/src/types/DataSource.ts +16 -0
  160. package/src/types/HeartRateEvent.ts +26 -0
  161. package/src/types/PermissionsType.ts +9 -0
  162. package/src/types/PhysicalSummary.ts +84 -0
  163. package/src/types/Rook.ts +8 -0
  164. package/src/types/SDKSources.ts +5 -0
  165. package/src/types/SamsungHealthPermissions.ts +16 -0
  166. package/src/types/SleepSummary.ts +66 -0
  167. package/src/types/SummaryTypes.ts +70 -0
  168. package/src/types/SyncTypes.ts +63 -0
  169. package/{lib/commonjs/utils/isModuleReady.js → src/utils/isModuleReady.ts} +4 -10
  170. package/src/utils/isRunningOnAndroid.ts +10 -0
  171. package/src/utils/isRunningOniOS.ts +10 -0
  172. package/{lib/commonjs/utils/isValidDate.js → src/utils/isValidDate.ts} +5 -10
  173. package/android/src/main/AndroidManifestNew.xml +0 -36
  174. package/android/src/main/java/com/rooksdk/broadcasts/AndroidPermissionsReceiverTransmitter.kt +0 -65
  175. package/android/src/main/java/com/rooksdk/broadcasts/HealthConnectPermissionsReceiverTransmitter.kt +0 -70
  176. package/android/src/main/java/com/rooksdk/broadcasts/SamsungHealthPermissionsReceiverTransmitter.kt +0 -52
  177. package/android/src/main/java/com/rooksdk/modules/RookBackgroundSyncModule.kt +0 -85
  178. package/android/src/main/java/com/rooksdk/modules/RookConfigurationModule.kt +0 -148
  179. package/android/src/main/java/com/rooksdk/modules/RookLocalData.kt +0 -247
  180. package/android/src/main/java/com/rooksdk/modules/RookPermissionsModule.kt +0 -309
  181. package/android/src/main/java/com/rooksdk/modules/RookStepsModule.kt +0 -105
  182. package/android/src/main/java/com/rooksdk/modules/RookSyncModule.kt +0 -496
  183. package/android/src/main/java/com/rooksdk/utils/DatasourcesUtils.kt +0 -63
  184. package/android/src/main/java/com/rooksdk/utils/PermissionConversion.kt +0 -21
  185. package/android/src/main/java/com/rooksdk/utils/ReadableToWritable.kt +0 -64
  186. package/android/src/main/java/com/rooksdk/utils/RookDateTime.kt +0 -20
  187. package/android/src/main/java/com/rooksdk/utils/SamsungAvailability.kt +0 -21
  188. package/android/src/main/java/com/rooksdk/utils/Source.kt +0 -6
  189. package/android/src/main/java/com/rooksdk/utils/StringToSyncType.kt +0 -58
  190. package/android/src/main/java/com/rooksdk/utils/serializers/InstantSerializer.kt +0 -19
  191. package/android/src/main/java/com/rooksdk/utils/serializers/LocalDateSerializer.kt +0 -21
  192. package/android/src/main/res/drawable/ic_health_connect.xml +0 -19
  193. package/android/src/main/res/values/themes.xml +0 -3
  194. package/ios/EncodableRookDataSource.swift +0 -36
  195. package/ios/EncodableStatusDataSources.swift +0 -47
  196. package/ios/RookBackgroundModule.h +0 -5
  197. package/ios/RookBackgroundModule.mm +0 -89
  198. package/ios/RookConfigurationModule.h +0 -5
  199. package/ios/RookConfigurationModule.mm +0 -163
  200. package/ios/RookExternalModule.h +0 -5
  201. package/ios/RookExternalModule.m +0 -27
  202. package/ios/RookLocalData.swift +0 -152
  203. package/ios/RookPermissionsModule.h +0 -5
  204. package/ios/RookPermissionsModule.mm +0 -180
  205. package/ios/RookSourcesModule.h +0 -5
  206. package/ios/RookSourcesModule.mm +0 -67
  207. package/ios/RookSync.h +0 -5
  208. package/ios/RookSync.m +0 -27
  209. package/ios/RookSyncModule.h +0 -5
  210. package/ios/RookSyncModule.mm +0 -476
  211. package/ios/SwiftTest.swift +0 -18
  212. package/ios/react-native-rook-sdk-Bridging-Header.h +0 -12
  213. package/lib/commonjs/context/RookSyncGateContext.js.map +0 -1
  214. package/lib/commonjs/context/RookSyncGateProvider.js +0 -98
  215. package/lib/commonjs/context/RookSyncGateProvider.js.map +0 -1
  216. package/lib/commonjs/context/RookSyncGateReducer.js.map +0 -1
  217. package/lib/commonjs/context/RookSyncGateTypes.js +0 -6
  218. package/lib/commonjs/context/RookSyncGateTypes.js.map +0 -1
  219. package/lib/commonjs/context/index.js +0 -14
  220. package/lib/commonjs/context/index.js.map +0 -1
  221. package/lib/commonjs/hooks/index.js +0 -90
  222. package/lib/commonjs/hooks/index.js.map +0 -1
  223. package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js +0 -100
  224. package/lib/commonjs/hooks/useRookAndroidBackgroundSteps.js.map +0 -1
  225. package/lib/commonjs/hooks/useRookAppleHealth.js +0 -74
  226. package/lib/commonjs/hooks/useRookAppleHealth.js.map +0 -1
  227. package/lib/commonjs/hooks/useRookAppleHealthVariables.js +0 -48
  228. package/lib/commonjs/hooks/useRookAppleHealthVariables.js.map +0 -1
  229. package/lib/commonjs/hooks/useRookConfiguration.js +0 -188
  230. package/lib/commonjs/hooks/useRookConfiguration.js.map +0 -1
  231. package/lib/commonjs/hooks/useRookData.js +0 -100
  232. package/lib/commonjs/hooks/useRookData.js.map +0 -1
  233. package/lib/commonjs/hooks/useRookDataSources.js +0 -118
  234. package/lib/commonjs/hooks/useRookDataSources.js.map +0 -1
  235. package/lib/commonjs/hooks/useRookEvents.js +0 -225
  236. package/lib/commonjs/hooks/useRookEvents.js.map +0 -1
  237. package/lib/commonjs/hooks/useRookHealthConnect.js +0 -70
  238. package/lib/commonjs/hooks/useRookHealthConnect.js.map +0 -1
  239. package/lib/commonjs/hooks/useRookPermissions.js +0 -226
  240. package/lib/commonjs/hooks/useRookPermissions.js.map +0 -1
  241. package/lib/commonjs/hooks/useRookSummaries.js +0 -85
  242. package/lib/commonjs/hooks/useRookSummaries.js.map +0 -1
  243. package/lib/commonjs/hooks/useRookSync.js +0 -147
  244. package/lib/commonjs/hooks/useRookSync.js.map +0 -1
  245. package/lib/commonjs/hooks/useRookVariables.js +0 -69
  246. package/lib/commonjs/hooks/useRookVariables.js.map +0 -1
  247. package/lib/commonjs/index.js +0 -56
  248. package/lib/commonjs/index.js.map +0 -1
  249. package/lib/commonjs/modules/hook/useRookAutoSync.js +0 -262
  250. package/lib/commonjs/modules/hook/useRookAutoSync.js.map +0 -1
  251. package/lib/commonjs/modules/types/sendMessageBroadcast.js +0 -2
  252. package/lib/commonjs/modules/types/sendMessageBroadcast.js.map +0 -1
  253. package/lib/commonjs/modules/utils/errors.js +0 -12
  254. package/lib/commonjs/modules/utils/errors.js.map +0 -1
  255. package/lib/commonjs/types/ActivityEvent.js +0 -6
  256. package/lib/commonjs/types/ActivityEvent.js.map +0 -1
  257. package/lib/commonjs/types/AuthorizedSources.js +0 -2
  258. package/lib/commonjs/types/AuthorizedSources.js.map +0 -1
  259. package/lib/commonjs/types/BodySummary.js +0 -6
  260. package/lib/commonjs/types/BodySummary.js.map +0 -1
  261. package/lib/commonjs/types/DataSource.js +0 -2
  262. package/lib/commonjs/types/PermissionsType.js +0 -2
  263. package/lib/commonjs/types/PermissionsType.js.map +0 -1
  264. package/lib/commonjs/types/PhysicalSummary.js +0 -6
  265. package/lib/commonjs/types/PhysicalSummary.js.map +0 -1
  266. package/lib/commonjs/types/SDKSources.js +0 -13
  267. package/lib/commonjs/types/SDKSources.js.map +0 -1
  268. package/lib/commonjs/types/SamsungHealthPermissions.js +0 -23
  269. package/lib/commonjs/types/SamsungHealthPermissions.js.map +0 -1
  270. package/lib/commonjs/types/SleepSummary.js +0 -6
  271. package/lib/commonjs/types/SleepSummary.js.map +0 -1
  272. package/lib/commonjs/types/SummaryTypes.js +0 -2
  273. package/lib/commonjs/types/SummaryTypes.js.map +0 -1
  274. package/lib/commonjs/types/SyncTypes.js +0 -6
  275. package/lib/commonjs/utils/credentials.js +0 -12
  276. package/lib/commonjs/utils/credentials.js.map +0 -1
  277. package/lib/commonjs/utils/getNativeModule.js +0 -29
  278. package/lib/commonjs/utils/getNativeModule.js.map +0 -1
  279. package/lib/commonjs/utils/getRookModule.js +0 -28
  280. package/lib/commonjs/utils/getRookModule.js.map +0 -1
  281. package/lib/commonjs/utils/isModuleReady.js.map +0 -1
  282. package/lib/commonjs/utils/isRunningOnAndroid.js +0 -15
  283. package/lib/commonjs/utils/isRunningOnAndroid.js.map +0 -1
  284. package/lib/commonjs/utils/isRunningOniOS.js +0 -15
  285. package/lib/commonjs/utils/isRunningOniOS.js.map +0 -1
  286. package/lib/commonjs/utils/isValidDate.js.map +0 -1
  287. package/lib/commonjs/utils/nativeModules.js +0 -28
  288. package/lib/commonjs/utils/nativeModules.js.map +0 -1
  289. package/lib/commonjs/utils/packageInfo.js +0 -13
  290. package/lib/commonjs/utils/packageInfo.js.map +0 -1
  291. package/lib/module/context/index.js +0 -2
  292. package/lib/module/context/index.js.map +0 -1
  293. package/lib/module/hooks/index.js +0 -13
  294. package/lib/module/hooks/index.js.map +0 -1
  295. package/lib/module/hooks/useRookAppleHealthVariables.js +0 -41
  296. package/lib/module/hooks/useRookAppleHealthVariables.js.map +0 -1
  297. package/lib/module/hooks/useRookDataSources.js +0 -110
  298. package/lib/module/hooks/useRookDataSources.js.map +0 -1
  299. package/lib/module/hooks/useRookEvents.js +0 -218
  300. package/lib/module/hooks/useRookEvents.js.map +0 -1
  301. package/lib/module/hooks/useRookSummaries.js +0 -78
  302. package/lib/module/hooks/useRookSummaries.js.map +0 -1
  303. package/lib/module/utils/credentials.js +0 -6
  304. package/lib/module/utils/credentials.js.map +0 -1
  305. package/lib/module/utils/getNativeModule.js +0 -23
  306. package/lib/module/utils/getNativeModule.js.map +0 -1
  307. package/lib/module/utils/getRookModule.js +0 -22
  308. package/lib/module/utils/getRookModule.js.map +0 -1
  309. package/lib/module/utils/nativeModules.js +0 -22
  310. package/lib/module/utils/nativeModules.js.map +0 -1
  311. package/lib/module/utils/packageInfo.js +0 -7
  312. package/lib/module/utils/packageInfo.js.map +0 -1
  313. package/lib/typescript/src/context/index.d.ts +0 -2
  314. package/lib/typescript/src/context/index.d.ts.map +0 -1
  315. package/lib/typescript/src/hooks/index.d.ts +0 -13
  316. package/lib/typescript/src/hooks/index.d.ts.map +0 -1
  317. package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts +0 -15
  318. package/lib/typescript/src/hooks/useRookAppleHealthVariables.d.ts.map +0 -1
  319. package/lib/typescript/src/hooks/useRookDataSources.d.ts +0 -22
  320. package/lib/typescript/src/hooks/useRookDataSources.d.ts.map +0 -1
  321. package/lib/typescript/src/hooks/useRookEvents.d.ts +0 -26
  322. package/lib/typescript/src/hooks/useRookEvents.d.ts.map +0 -1
  323. package/lib/typescript/src/hooks/useRookSummaries.d.ts +0 -14
  324. package/lib/typescript/src/hooks/useRookSummaries.d.ts.map +0 -1
  325. package/lib/typescript/src/utils/credentials.d.ts +0 -5
  326. package/lib/typescript/src/utils/credentials.d.ts.map +0 -1
  327. package/lib/typescript/src/utils/getNativeModule.d.ts +0 -10
  328. package/lib/typescript/src/utils/getNativeModule.d.ts.map +0 -1
  329. package/lib/typescript/src/utils/getRookModule.d.ts +0 -9
  330. package/lib/typescript/src/utils/getRookModule.d.ts.map +0 -1
  331. package/lib/typescript/src/utils/nativeModules.d.ts +0 -23
  332. package/lib/typescript/src/utils/nativeModules.d.ts.map +0 -1
  333. package/lib/typescript/src/utils/packageInfo.d.ts +0 -6
  334. package/lib/typescript/src/utils/packageInfo.d.ts.map +0 -1
  335. package/react-native-rook-sdk.podspec +0 -45
@@ -1,17 +1,14 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.useRookSyncGateContext = exports.RookSyncGateContext = void 0;
7
- var _react = require("react");
8
1
  // RookSyncGateContext.tsx
2
+ import { createContext, useContext, type Dispatch } from 'react';
3
+ import type { RookSyncGateState, Action } from './RookSyncGateTypes';
9
4
 
10
5
  /* This line of code is creating a context using the `createContext` function provided by React. The
11
6
  context being created is named `RookSyncGateContext` and it is defined to hold an object with two
12
7
  properties: `state` of type `RookSyncGateState` and `dispatch` of type `Dispatch<Action>`. The
13
8
  `Dispatch` type is a generic type that represents a function to dispatch actions. */
14
- const RookSyncGateContext = exports.RookSyncGateContext = /*#__PURE__*/(0, _react.createContext)(undefined);
9
+ export const RookSyncGateContext = createContext<
10
+ { state: RookSyncGateState; dispatch: Dispatch<Action> } | undefined
11
+ >(undefined);
15
12
 
16
13
  /**
17
14
  * The function `useRookSyncGateContext` ensures that it is used within the `RookSyncGateProvider`
@@ -20,12 +17,12 @@ const RookSyncGateContext = exports.RookSyncGateContext = /*#__PURE__*/(0, _reac
20
17
  * `RookSyncGateContext` using the `useContext` hook. If the context is not found, it throws an error
21
18
  * indicating that `useRookSyncGateContext` should be used inside `RookSyncGateProvider`.
22
19
  */
23
- const useRookSyncGateContext = () => {
24
- const context = (0, _react.useContext)(RookSyncGateContext);
20
+ export const useRookSyncGateContext = () => {
21
+ const context = useContext(RookSyncGateContext);
25
22
  if (!context) {
26
- throw new Error('useRookSyncGateContext should be used inside RookSyncGateProvider');
23
+ throw new Error(
24
+ 'useRookSyncGateContext should be used inside RookSyncGateProvider'
25
+ );
27
26
  }
28
27
  return context;
29
28
  };
30
- exports.useRookSyncGateContext = useRookSyncGateContext;
31
- //# sourceMappingURL=RookSyncGateContext.js.map
@@ -0,0 +1,78 @@
1
+ /* eslint-disable react-hooks/exhaustive-deps */
2
+ import { useReducer, type FC, useEffect } from 'react';
3
+ import { rookSyncGateReducer } from './RookSyncGateReducer'; // Importa el reducer
4
+ import type {
5
+ RookSyncGateState,
6
+ RookSyncGateProviderProps,
7
+ } from './RookSyncGateTypes';
8
+ import { RookSyncGateContext } from './RookSyncGateContext';
9
+ import RookSdk from '../NativeRookSdk';
10
+ import { useRookAutoSync } from '../modules/hook/useRookAutoSync';
11
+
12
+ const initialState: RookSyncGateState = {
13
+ clientUUID: '',
14
+ environment: 'sandbox',
15
+ password: '',
16
+ ready: false,
17
+ userID: '',
18
+ permissions: 0,
19
+ enableLogs: false,
20
+ };
21
+
22
+ /*
23
+ * This code snippet is defining a React functional component called `RookSyncGateProvider`.
24
+ * this define the provider for the SDK
25
+ */
26
+ const RookSyncGateProvider: FC<RookSyncGateProviderProps> = ({
27
+ environment,
28
+ clientUUID,
29
+ password,
30
+ children,
31
+ enableLogs = false,
32
+ enableBackgroundSync,
33
+ enableEventsBackgroundSync = true,
34
+ }) => {
35
+ const [state, dispatch] = useReducer(rookSyncGateReducer, initialState);
36
+
37
+ const { startBackgroundServices } = useRookAutoSync({
38
+ state,
39
+ enableBackground: enableBackgroundSync,
40
+ enableLogs,
41
+ });
42
+
43
+ useEffect(() => {
44
+ initModule();
45
+ }, [environment, clientUUID, password]);
46
+
47
+ const initModule = async (): Promise<void> => {
48
+ dispatch({ type: 'SET_ROOK_ENVIRONMENT', environment });
49
+ dispatch({ type: 'SET_CLIENT_UUID', clientUUID });
50
+ dispatch({ type: 'SET_PASSWORD', password });
51
+ dispatch({ type: 'SET_ENABLE_LOGS', enableLogs });
52
+
53
+ try {
54
+ await RookSdk.initRook({
55
+ environment,
56
+ clientUUID,
57
+ password,
58
+ enableLogs,
59
+ enableEventsBackgroundSync,
60
+ enableBackground: enableBackgroundSync,
61
+ });
62
+
63
+ if (enableBackgroundSync) startBackgroundServices();
64
+
65
+ dispatch({ type: 'SET_READY', ready: true });
66
+ } catch (error) {
67
+ console.log(error);
68
+ }
69
+ };
70
+
71
+ return (
72
+ <RookSyncGateContext.Provider value={{ state, dispatch }}>
73
+ {children}
74
+ </RookSyncGateContext.Provider>
75
+ );
76
+ };
77
+
78
+ export default RookSyncGateProvider;
@@ -1,9 +1,5 @@
1
- "use strict";
1
+ import type { RookSyncGateState, Action } from './RookSyncGateTypes';
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.rookSyncGateReducer = void 0;
7
3
  /**
8
4
  * The rookSyncGateReducer function in TypeScript handles various actions to update the state of a
9
5
  * RookSyncGate component.
@@ -19,46 +15,29 @@ exports.rookSyncGateReducer = void 0;
19
15
  * type provided. The state object is updated with the corresponding values based on the action type.
20
16
  * If the action type is not recognized, it returns the current state unchanged.
21
17
  */
22
- const rookSyncGateReducer = (state, action) => {
18
+ export const rookSyncGateReducer = (
19
+ state: RookSyncGateState,
20
+ action: Action
21
+ ): RookSyncGateState => {
23
22
  switch (action.type) {
24
23
  case 'SET_READY':
25
- return {
26
- ...state,
27
- ready: action.ready
28
- };
24
+ return { ...state, ready: action.ready };
29
25
  case 'SET_ROOK_ENVIRONMENT':
30
- return {
31
- ...state,
32
- environment: action.environment
33
- };
26
+ return { ...state, environment: action.environment };
34
27
  case 'SET_CLIENT_UUID':
35
- return {
36
- ...state,
37
- clientUUID: action.clientUUID
38
- };
28
+ return { ...state, clientUUID: action.clientUUID };
39
29
  case 'SET_PASSWORD':
40
- return {
41
- ...state,
42
- password: action.password
43
- };
30
+ return { ...state, password: action.password };
44
31
  case 'SET_USER_ID':
45
- return {
46
- ...state,
47
- userID: action.userID
48
- };
32
+ return { ...state, userID: action.userID };
49
33
  case 'SET_ENABLE_LOGS':
50
- return {
51
- ...state,
52
- enableLogs: action.enableLogs
53
- };
34
+ return { ...state, enableLogs: action.enableLogs };
54
35
  case 'SET_PERMISSIONS':
55
36
  return {
56
37
  ...state,
57
- permissions: state.permissions + 1
38
+ permissions: state.permissions + 1,
58
39
  };
59
40
  default:
60
41
  return state;
61
42
  }
62
43
  };
63
- exports.rookSyncGateReducer = rookSyncGateReducer;
64
- //# sourceMappingURL=RookSyncGateReducer.js.map
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export type Environment = 'sandbox' | 'production';
4
+
5
+ type RookSyncGateState = {
6
+ clientUUID: string;
7
+ environment: Environment;
8
+ password: string;
9
+ ready: boolean;
10
+ userID: string;
11
+ permissions: number;
12
+ enableLogs: boolean;
13
+ };
14
+
15
+ type Action =
16
+ | { type: 'SET_CLIENT_UUID'; clientUUID: string }
17
+ | { type: 'SET_ENABLE_LOGS'; enableLogs: boolean }
18
+ | { type: 'SET_PASSWORD'; password: string }
19
+ | { type: 'SET_PERMISSIONS' }
20
+ | { type: 'SET_READY'; ready: boolean }
21
+ | { type: 'SET_ROOK_ENVIRONMENT'; environment: Environment }
22
+ | { type: 'SET_USER_ID'; userID: string };
23
+
24
+ type RookSyncGateProviderProps = {
25
+ children: ReactNode;
26
+ environment: Environment;
27
+ clientUUID: string;
28
+ password: string;
29
+ enableLogs?: boolean;
30
+ enableBackgroundSync: boolean;
31
+ enableEventsBackgroundSync?: boolean;
32
+ };
33
+
34
+ export type { RookSyncGateState, Action, RookSyncGateProviderProps };
@@ -0,0 +1,83 @@
1
+ import RookSdk from '../NativeRookSdk';
2
+ import { isModuleReady } from '../utils/isModuleReady';
3
+ import { Platform } from 'react-native';
4
+ import { useRookSyncGateContext } from '../context/RookSyncGateContext';
5
+ import type { APIDataSource } from '../types/DataSource';
6
+ import type {
7
+ AuthorizedSource,
8
+ DataSourceAuthorizer,
9
+ DataSourceProps,
10
+ } from '../types/AuthorizedSources';
11
+
12
+ /**
13
+ * The `useRookDataSources` hook provides functionality to interact with data sources in Rook,
14
+ * including retrieving available data sources, presenting a connections page, and revoking user
15
+ * authorization for a specific data source.
16
+ * @returns An object is being returned from the `useRookDataSources` hook to allow the user to access to the sources API
17
+ */
18
+ export const useRookAPISources = () => {
19
+ const {
20
+ state: { ready },
21
+ } = useRookSyncGateContext();
22
+
23
+ /**
24
+ * The function `revokeDataSource` revokes user authorization for the specified data source.
25
+ * @param {DataSourceType} type - The `type` parameter in the `revokeDataSource` function represents
26
+ * the type of data source that you want to revoke access to. It is of type `DataSourceType`.
27
+ * @returns A Promise<boolean> is being returned from the `revokeDataSource` function.
28
+ */
29
+ const revokeDataSource = (
30
+ userid: string,
31
+ type: APIDataSource
32
+ ): Promise<boolean> => {
33
+ isModuleReady(ready);
34
+
35
+ return RookSdk.revokeDataSource(userid, type);
36
+ };
37
+
38
+ /**
39
+ * Retrieves the authorization status for a specific data source linked to a given user.
40
+ * If the user is not authorized, an authorization URL is provided to start the process.
41
+ * If the user is already authorized, the response will indicate "authorized": true and no authorization URL will be
42
+ * returned. The redirect_url parameter can be used to specify where the user should be redirected
43
+ * after completing the authorization.
44
+ * @returns The function `getDataSourceAuthorizer` is returning a `DataSourceAuthorizer` object after
45
+ * parsing the response from `rookSync.current.getDataSourceAuthorizer()` as JSON.
46
+ */
47
+ const getDataSourceAuthorizer = async (
48
+ props: DataSourceProps
49
+ ): Promise<DataSourceAuthorizer> => {
50
+ const response = await RookSdk.getDataSourceAuthorizer(props);
51
+
52
+ if (Platform.OS === 'android')
53
+ return JSON.parse(response as any) as DataSourceAuthorizer;
54
+
55
+ return response;
56
+ };
57
+
58
+ /**
59
+ * The function `getAuthorizedDataSources` returns authorized data sources after checking ROOK services
60
+ * in case of apple health, health connect and android this only determines if the user
61
+ * is connected not if the user granted permissions.
62
+ * @returns The function `getAuthorizedDataSources` is returning a Promise that will resolve to the
63
+ * result of calling `rookSync.current.getAuthorizedDataSources()`.
64
+ */
65
+ const getAuthorizedDataSourcesV2 = async (
66
+ userid: string
67
+ ): Promise<AuthorizedSource[]> => {
68
+ isModuleReady(ready);
69
+
70
+ if (Platform.OS !== 'android')
71
+ return RookSdk.getAuthorizedDataSourcesV2(userid);
72
+
73
+ const response = await RookSdk.getAuthorizedDataSourcesV2(userid);
74
+ return JSON.parse(response as any) as AuthorizedSource[];
75
+ };
76
+
77
+ return {
78
+ ready,
79
+ revokeDataSource,
80
+ getDataSourceAuthorizer,
81
+ getAuthorizedDataSourcesV2,
82
+ };
83
+ };
@@ -0,0 +1,81 @@
1
+ import RookSdk from '../NativeRookSdk';
2
+ import { useRookSyncGateContext } from '../context/RookSyncGateContext';
3
+ import { isModuleReady } from '../utils/isModuleReady';
4
+ import isRunningOnAndroid from '../utils/isRunningOnAndroid';
5
+
6
+ /**
7
+ * The `useRookAndroidBackgroundSteps` function provides various methods for managing and retrieving
8
+ * step count data on Android devices using the Rook module.
9
+ * @returns The `useRookAndroidBackgroundSteps` function returns a hook with the functions that allows the user to
10
+ * control de steps sync
11
+ */
12
+ export const useRookAndroidBackgroundSteps = () => {
13
+ const {
14
+ state: { ready },
15
+ } = useRookSyncGateContext();
16
+
17
+ /**
18
+ * The function `isStepsAvailable` checks if steps data is available.
19
+ * @returns The function `isStepsAvailable` is returning a promise that resolve in a boolean value.
20
+ */
21
+ const isStepsAvailable = async (): Promise<boolean> => {
22
+ isRunningOnAndroid();
23
+ isModuleReady(ready);
24
+
25
+ return RookSdk.isStepsAvailable();
26
+ };
27
+
28
+ /**
29
+ * The function `enableBackgroundAndroidSteps` starts collecting of steps during the day
30
+ * @returns The `enableBackgroundAndroidSteps` function is returning a Promise that resolves to a boolean
31
+ */
32
+ const enableBackgroundAndroidSteps = async (): Promise<boolean> => {
33
+ isRunningOnAndroid();
34
+ isModuleReady(ready);
35
+
36
+ return RookSdk.enableBackgroundAndroidSteps();
37
+ };
38
+
39
+ /**
40
+ * The function `disableBackgroundAndroidSteps` stops a process of collecting steps during the day
41
+ * @returns The function `disableBackgroundAndroidSteps` function is returning a Promise that resolves to a boolean
42
+ */
43
+ const disableBackgroundAndroidSteps = (): Promise<boolean> => {
44
+ isRunningOnAndroid();
45
+ isModuleReady(ready);
46
+
47
+ return RookSdk.disableBackgroundAndroidSteps();
48
+ };
49
+
50
+ /**
51
+ * The function `isBackgroundAndroidStepsActive` checks if steps are active and returns a Promise with a boolean
52
+ * value.
53
+ * @returns The function is returning a Promise that resolves to a boolean
54
+ */
55
+ const isBackgroundAndroidStepsActive = (): Promise<boolean> => {
56
+ isRunningOnAndroid();
57
+ isModuleReady(ready);
58
+
59
+ return RookSdk.isBackgroundAndroidStepsActive();
60
+ };
61
+
62
+ /**
63
+ * The function `getTodayAndroidStepsCount` retrieves the number of steps taken today asynchronously as string.
64
+ * @returns The function `getTodaySteps` is returning the result of calling
65
+ */
66
+ const syncTodayAndroidStepsCount = (): Promise<string> => {
67
+ isRunningOnAndroid();
68
+ isModuleReady(ready);
69
+
70
+ return RookSdk.syncTodayAndroidStepsCount();
71
+ };
72
+
73
+ return {
74
+ ready,
75
+ isStepsAvailable,
76
+ enableBackgroundAndroidSteps,
77
+ disableBackgroundAndroidSteps,
78
+ isBackgroundAndroidStepsActive,
79
+ syncTodayAndroidStepsCount,
80
+ };
81
+ };
@@ -0,0 +1,55 @@
1
+ import RookSdk from '../NativeRookSdk';
2
+
3
+ import { useRookSyncGateContext } from '../context/RookSyncGateContext';
4
+ import { isModuleReady } from '../utils/isModuleReady';
5
+ import { isRunningOniOS } from '../utils/isRunningOniOS';
6
+
7
+ export const useRookAppleHealth = () => {
8
+ const {
9
+ state: { ready },
10
+ } = useRookSyncGateContext();
11
+
12
+ /**
13
+ * The function `enableBackGroundUpdates` enable background updates and returns a promise
14
+ * indicating success.
15
+ * @returns The function `enableBackGroundUpdates` returns a Promise that resolves to a boolean
16
+ * value.
17
+ */
18
+ const enableBackGroundUpdates = (): Promise<boolean> => {
19
+ isRunningOniOS();
20
+ isModuleReady(ready);
21
+
22
+ return RookSdk.enableBackGroundUpdates();
23
+ };
24
+
25
+ /**
26
+ * The function `disableBackGroundUpdates` disables background updates and returns a promise
27
+ * indicating success.
28
+ * @returns The function `disableBackGroundUpdates` returns a Promise that resolves to a boolean
29
+ * value.
30
+ */
31
+ const disableBackGroundUpdates = (): Promise<boolean> => {
32
+ isRunningOniOS();
33
+ isModuleReady(ready);
34
+
35
+ return RookSdk.disableBackGroundUpdates();
36
+ };
37
+
38
+ /**
39
+ * This function checks if background summaries are enabled.
40
+ * @returns The function `isBackGroundForSummariesEnable` is returning a boolean value
41
+ */
42
+ const isBackgroundUpdatesEnabled = async (): Promise<boolean> => {
43
+ isRunningOniOS();
44
+ isModuleReady(ready);
45
+
46
+ return RookSdk.isBackgroundUpdatesEnabled();
47
+ };
48
+
49
+ return {
50
+ ready,
51
+ enableBackGroundUpdates,
52
+ disableBackGroundUpdates,
53
+ isBackgroundUpdatesEnabled,
54
+ };
55
+ };
@@ -0,0 +1,82 @@
1
+ import RookSdk from '../NativeRookSdk';
2
+
3
+ import { useRookSyncGateContext } from '../context/RookSyncGateContext';
4
+ import { isModuleReady } from '../utils/isModuleReady';
5
+ import { type SDKDataSource } from '../types/SDKSources';
6
+
7
+ /**
8
+ * The `useRookConfiguration` hook provides various asynchronous methods for managing the configuration
9
+ * of the ROOK SDK
10
+ * @returns The `useRookConfiguration` function returns an object containing that allow the user to configure
11
+ * the SDK
12
+ */
13
+ export const useRookConfiguration = () => {
14
+ const {
15
+ state: { ready },
16
+ dispatch,
17
+ } = useRookSyncGateContext();
18
+
19
+ /**
20
+ * The `getUserID` function retrieves the user ID
21
+ * @returns The function `getUserID` is returning a Promise that resolves to a string value.
22
+ */
23
+ const getUserID = async (): Promise<string> => {
24
+ isModuleReady(ready);
25
+
26
+ const result = await RookSdk.getUserID();
27
+
28
+ if (result) dispatch({ type: 'SET_USER_ID', userID: result });
29
+
30
+ return result;
31
+ };
32
+
33
+ /**
34
+ * The function `updateUserID` updates the user ID and returns a boolean indicating the success of
35
+ * the update.
36
+ * @param {string} userID - The `userID` parameter is a string that represents the user ID that needs
37
+ * to be updated in the system.
38
+ * @returns The `updateUserID` function returns a Promise that resolves to a boolean value.
39
+ */
40
+ const updateUserID = async (userID: string): Promise<boolean> => {
41
+ isModuleReady(ready);
42
+
43
+ const result: boolean = await RookSdk.updateUserID(userID);
44
+
45
+ dispatch({ type: 'SET_USER_ID', userID });
46
+
47
+ return result;
48
+ };
49
+
50
+ /**
51
+ * This function `syncUserTimeZone` synchronizes the user's time zone using
52
+ * @returns The `syncUserTimeZone` function returns a boolean value, indicating success or failure
53
+ */
54
+ const syncUserTimeZone = async (): Promise<boolean> => {
55
+ isModuleReady(ready);
56
+
57
+ const result: boolean = await RookSdk.syncUserTimeZone();
58
+ return result;
59
+ };
60
+
61
+ /**
62
+ * The function `removeUserFromRook` removes a user from a rook services, If you delete the user from the Rook services you have to create the user again with updateUserID and request permissions.
63
+ * @returns The `removeUserFromRook` function is returning a boolean value.
64
+ */
65
+ const removeUserFromRook = async (
66
+ sources: SDKDataSource[]
67
+ ): Promise<boolean> => {
68
+ isModuleReady(ready);
69
+
70
+ dispatch({ type: 'SET_USER_ID', userID: '' });
71
+
72
+ return RookSdk.removeUserFromRook(sources);
73
+ };
74
+
75
+ return {
76
+ ready,
77
+ getUserID,
78
+ updateUserID,
79
+ removeUserFromRook,
80
+ syncUserTimeZone,
81
+ };
82
+ };
@@ -0,0 +1,122 @@
1
+ import RookSdk from '../NativeRookSdk';
2
+ import { Platform } from 'react-native';
3
+
4
+ import { isModuleReady } from '../utils/isModuleReady';
5
+ import { isValidDate } from '../utils/isValidDate';
6
+ import { useRookSyncGateContext } from '../context/RookSyncGateContext';
7
+ import { SDKDataSource } from '../types/SDKSources';
8
+ import { type SleepSummary } from '../types/SleepSummary';
9
+ import { type PhysicalSummary } from '../types/PhysicalSummary';
10
+ import { type BodySummary } from '../types/BodySummary';
11
+ import { type ActivityEvent } from '../types/ActivityEvent';
12
+ import { type HeartRateData } from '../types/HeartRateEvent';
13
+
14
+ type Params = {
15
+ date: string;
16
+ source: SDKDataSource;
17
+ };
18
+
19
+ export const useRookData = () => {
20
+ const {
21
+ state: { ready },
22
+ } = useRookSyncGateContext();
23
+
24
+ const getSleepSummary = async ({
25
+ date,
26
+ source,
27
+ }: Params): Promise<SleepSummary[]> => {
28
+ isModuleReady(ready);
29
+ isValidDate(date);
30
+
31
+ if (Platform.OS === 'android' && source === SDKDataSource.SAMSUNG_HEALTH) {
32
+ const result = await RookSdk.getSamsungSleepSummary(date);
33
+ return JSON.parse(result);
34
+ }
35
+
36
+ if (Platform.OS === 'android' && source === SDKDataSource.HEALTH_CONNECT) {
37
+ const result = await RookSdk.getHealthConnectSleepSummary(date);
38
+ return JSON.parse(result);
39
+ }
40
+
41
+ return RookSdk.getAppleHealthSleepSummary(date);
42
+ };
43
+
44
+ const getPhysicalSummary = async ({
45
+ date,
46
+ source,
47
+ }: Params): Promise<PhysicalSummary> => {
48
+ isModuleReady(ready);
49
+ isValidDate(date);
50
+
51
+ if (Platform.OS === 'android' && source === SDKDataSource.SAMSUNG_HEALTH) {
52
+ const result = await RookSdk.getSamsungPhysicalSummary(date);
53
+ return JSON.parse(result);
54
+ }
55
+
56
+ if (Platform.OS === 'android' && source === SDKDataSource.HEALTH_CONNECT) {
57
+ const result = await RookSdk.getHealthConnectPhysicalSummary(date);
58
+ return JSON.parse(result);
59
+ }
60
+
61
+ return RookSdk.getAppleHealthPhysicalSummary(date);
62
+ };
63
+
64
+ const getBodySummary = async ({
65
+ date,
66
+ source,
67
+ }: Params): Promise<BodySummary> => {
68
+ isModuleReady(ready);
69
+ isValidDate(date);
70
+
71
+ if (Platform.OS === 'android' && source === SDKDataSource.SAMSUNG_HEALTH) {
72
+ const result = await RookSdk.getSamsungBodySummary(date);
73
+ return JSON.parse(result);
74
+ }
75
+
76
+ if (Platform.OS === 'android' && source === SDKDataSource.HEALTH_CONNECT) {
77
+ const result = await RookSdk.getHealthConnectBodySummary(date);
78
+ return JSON.parse(result);
79
+ }
80
+
81
+ return RookSdk.getAppleHealthBodySummary(date);
82
+ };
83
+
84
+ const getActivityEvents = async ({
85
+ date,
86
+ source,
87
+ }: Params): Promise<ActivityEvent[]> => {
88
+ isModuleReady(ready);
89
+ isValidDate(date);
90
+
91
+ if (Platform.OS === 'android' && source === SDKDataSource.SAMSUNG_HEALTH) {
92
+ const result = await RookSdk.getSamsungActivityEvents(date);
93
+ return JSON.parse(result);
94
+ }
95
+
96
+ if (Platform.OS === 'android' && source === SDKDataSource.HEALTH_CONNECT) {
97
+ const result = await RookSdk.getHealthConnectActivityEvents(date);
98
+ return JSON.parse(result);
99
+ }
100
+
101
+ return RookSdk.getAppleHealthActivityEvents(date);
102
+ };
103
+
104
+ const getTodayHeartRate = async (
105
+ source: SDKDataSource
106
+ ): Promise<HeartRateData> => {
107
+ if (Platform.OS !== 'android' && source === SDKDataSource.APPLE_HEALTH) {
108
+ return RookSdk.getTodayHeartRate() as unknown as HeartRateData;
109
+ }
110
+
111
+ throw new Error('Please check the data source');
112
+ };
113
+
114
+ return {
115
+ ready,
116
+ getSleepSummary,
117
+ getPhysicalSummary,
118
+ getBodySummary,
119
+ getActivityEvents,
120
+ getTodayHeartRate,
121
+ };
122
+ };