@kingstinct/react-native-healthkit 6.1.0 → 7.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 (268) hide show
  1. package/README.md +7 -5
  2. package/app.plugin.js +69 -0
  3. package/ios/Constants.swift +28 -0
  4. package/ios/Helpers.swift +152 -0
  5. package/ios/ReactNativeHealthkit.m +24 -0
  6. package/ios/ReactNativeHealthkit.swift +534 -728
  7. package/ios/Serializers.swift +206 -0
  8. package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -6
  9. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
  10. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +2 -9
  11. package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +1 -1
  12. package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -6
  13. package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -1
  14. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +1 -6
  15. package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +1 -1
  16. package/lib/commonjs/hooks/useMostRecentCategorySample.js +1 -7
  17. package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -1
  18. package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -10
  19. package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -1
  20. package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -10
  21. package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -1
  22. package/lib/commonjs/hooks/useSources.js +0 -5
  23. package/lib/commonjs/hooks/useSources.js.map +1 -1
  24. package/lib/commonjs/hooks/useStatisticsForQuantity.js +1 -7
  25. package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -1
  26. package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -8
  27. package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -1
  28. package/lib/commonjs/index.ios.js +6 -33
  29. package/lib/commonjs/index.ios.js.map +1 -1
  30. package/lib/commonjs/index.js +7 -11
  31. package/lib/commonjs/index.js.map +1 -1
  32. package/lib/commonjs/jest.setup.js +3 -1
  33. package/lib/commonjs/jest.setup.js.map +1 -1
  34. package/lib/commonjs/native-types.js +166 -250
  35. package/lib/commonjs/native-types.js.map +1 -1
  36. package/lib/commonjs/test-utils.js +1 -3
  37. package/lib/commonjs/test-utils.js.map +1 -1
  38. package/lib/commonjs/types.js +0 -2
  39. package/lib/commonjs/types.js.map +1 -1
  40. package/lib/commonjs/utils/deleteQuantitySample.js +0 -4
  41. package/lib/commonjs/utils/deleteQuantitySample.js.map +1 -1
  42. package/lib/commonjs/utils/deleteSamples.js +0 -4
  43. package/lib/commonjs/utils/deleteSamples.js.map +1 -1
  44. package/lib/commonjs/utils/deserializeCategorySample.js +2 -3
  45. package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -1
  46. package/lib/commonjs/utils/deserializeCategorySample.test.js +3 -5
  47. package/lib/commonjs/utils/deserializeCategorySample.test.js.map +1 -1
  48. package/lib/commonjs/utils/deserializeCorrelation.js +2 -7
  49. package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -1
  50. package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +2 -3
  51. package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
  52. package/lib/commonjs/utils/deserializeSample.js +2 -3
  53. package/lib/commonjs/utils/deserializeSample.js.map +1 -1
  54. package/lib/commonjs/utils/deserializeWorkout.js +2 -3
  55. package/lib/commonjs/utils/deserializeWorkout.js.map +1 -1
  56. package/lib/commonjs/utils/ensureMetadata.js +0 -2
  57. package/lib/commonjs/utils/ensureMetadata.js.map +1 -1
  58. package/lib/commonjs/utils/ensureUnit.js +0 -5
  59. package/lib/commonjs/utils/ensureUnit.js.map +1 -1
  60. package/lib/commonjs/utils/getDateOfBirth.js +0 -4
  61. package/lib/commonjs/utils/getDateOfBirth.js.map +1 -1
  62. package/lib/commonjs/utils/getMostRecentCategorySample.js +1 -5
  63. package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
  64. package/lib/commonjs/utils/getMostRecentQuantitySample.js +1 -5
  65. package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
  66. package/lib/commonjs/utils/getMostRecentWorkout.js +0 -4
  67. package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -1
  68. package/lib/commonjs/utils/getPreferredUnit.js +0 -4
  69. package/lib/commonjs/utils/getPreferredUnit.js.map +1 -1
  70. package/lib/commonjs/utils/getPreferredUnits.js +0 -4
  71. package/lib/commonjs/utils/getPreferredUnits.js.map +1 -1
  72. package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -11
  73. package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -1
  74. package/lib/commonjs/utils/getRequestStatusForAuthorization.js +4 -6
  75. package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -1
  76. package/lib/commonjs/utils/prepareOptions.js +0 -4
  77. package/lib/commonjs/utils/prepareOptions.js.map +1 -1
  78. package/lib/commonjs/utils/queryCategorySamples.js +3 -14
  79. package/lib/commonjs/utils/queryCategorySamples.js.map +1 -1
  80. package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +22 -0
  81. package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +1 -0
  82. package/lib/commonjs/utils/queryCorrelationSamples.js +1 -7
  83. package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -1
  84. package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +3 -13
  85. package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +1 -1
  86. package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +22 -0
  87. package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -0
  88. package/lib/commonjs/utils/queryQuantitySamples.js +3 -15
  89. package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -1
  90. package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +24 -0
  91. package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +1 -0
  92. package/lib/commonjs/utils/querySources.js +0 -4
  93. package/lib/commonjs/utils/querySources.js.map +1 -1
  94. package/lib/commonjs/utils/queryStatisticsForQuantity.js +3 -7
  95. package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -1
  96. package/lib/commonjs/utils/queryWorkouts.js +1 -8
  97. package/lib/commonjs/utils/queryWorkouts.js.map +1 -1
  98. package/lib/commonjs/utils/requestAuthorization.js +4 -6
  99. package/lib/commonjs/utils/requestAuthorization.js.map +1 -1
  100. package/lib/commonjs/utils/saveCategorySample.js +0 -4
  101. package/lib/commonjs/utils/saveCategorySample.js.map +1 -1
  102. package/lib/commonjs/utils/saveCorrelationSample.js +3 -7
  103. package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -1
  104. package/lib/commonjs/utils/saveQuantitySample.js +0 -4
  105. package/lib/commonjs/utils/saveQuantitySample.js.map +1 -1
  106. package/lib/commonjs/utils/saveWorkoutSample.js +3 -8
  107. package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
  108. package/lib/commonjs/utils/serializeDate.js +0 -2
  109. package/lib/commonjs/utils/serializeDate.js.map +1 -1
  110. package/lib/commonjs/utils/serializeDate.test.js +0 -2
  111. package/lib/commonjs/utils/serializeDate.test.js.map +1 -1
  112. package/lib/commonjs/utils/subscribeToChanges.js +0 -7
  113. package/lib/commonjs/utils/subscribeToChanges.js.map +1 -1
  114. package/lib/module/hooks/useHealthkitAuthorization.js +0 -2
  115. package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
  116. package/lib/module/hooks/useHealthkitAuthorization.test.js +1 -1
  117. package/lib/module/hooks/useHealthkitAuthorization.test.js.map +1 -1
  118. package/lib/module/hooks/useIsHealthDataAvailable.js +0 -3
  119. package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -1
  120. package/lib/module/hooks/useIsHealthDataAvailable.test.js +1 -1
  121. package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +1 -1
  122. package/lib/module/hooks/useMostRecentCategorySample.js +1 -3
  123. package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -1
  124. package/lib/module/hooks/useMostRecentQuantitySample.js +0 -5
  125. package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -1
  126. package/lib/module/hooks/useMostRecentWorkout.js +0 -5
  127. package/lib/module/hooks/useMostRecentWorkout.js.map +1 -1
  128. package/lib/module/hooks/useSources.js +0 -2
  129. package/lib/module/hooks/useSources.js.map +1 -1
  130. package/lib/module/hooks/useStatisticsForQuantity.js +1 -3
  131. package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -1
  132. package/lib/module/hooks/useSubscribeToChanges.js +0 -5
  133. package/lib/module/hooks/useSubscribeToChanges.js.map +1 -1
  134. package/lib/module/index.ios.js +6 -0
  135. package/lib/module/index.ios.js.map +1 -1
  136. package/lib/module/index.js +8 -8
  137. package/lib/module/index.js.map +1 -1
  138. package/lib/module/jest.setup.js +3 -0
  139. package/lib/module/jest.setup.js.map +1 -1
  140. package/lib/module/native-types.js +134 -201
  141. package/lib/module/native-types.js.map +1 -1
  142. package/lib/module/test-utils.js +0 -2
  143. package/lib/module/test-utils.js.map +1 -1
  144. package/lib/module/types.js.map +1 -1
  145. package/lib/module/utils/deleteQuantitySample.js +0 -2
  146. package/lib/module/utils/deleteQuantitySample.js.map +1 -1
  147. package/lib/module/utils/deleteSamples.js +0 -2
  148. package/lib/module/utils/deleteSamples.js.map +1 -1
  149. package/lib/module/utils/deserializeCategorySample.js +2 -2
  150. package/lib/module/utils/deserializeCategorySample.js.map +1 -1
  151. package/lib/module/utils/deserializeCategorySample.test.js +3 -2
  152. package/lib/module/utils/deserializeCategorySample.test.js.map +1 -1
  153. package/lib/module/utils/deserializeCorrelation.js +2 -4
  154. package/lib/module/utils/deserializeCorrelation.js.map +1 -1
  155. package/lib/module/utils/deserializeHeartbeatSeriesSample.js +2 -2
  156. package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
  157. package/lib/module/utils/deserializeSample.js +2 -2
  158. package/lib/module/utils/deserializeSample.js.map +1 -1
  159. package/lib/module/utils/deserializeWorkout.js +2 -2
  160. package/lib/module/utils/deserializeWorkout.js.map +1 -1
  161. package/lib/module/utils/ensureMetadata.js +0 -1
  162. package/lib/module/utils/ensureMetadata.js.map +1 -1
  163. package/lib/module/utils/ensureUnit.js +0 -3
  164. package/lib/module/utils/ensureUnit.js.map +1 -1
  165. package/lib/module/utils/getDateOfBirth.js +0 -2
  166. package/lib/module/utils/getDateOfBirth.js.map +1 -1
  167. package/lib/module/utils/getMostRecentCategorySample.js +1 -3
  168. package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
  169. package/lib/module/utils/getMostRecentQuantitySample.js +1 -3
  170. package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
  171. package/lib/module/utils/getMostRecentWorkout.js +0 -2
  172. package/lib/module/utils/getMostRecentWorkout.js.map +1 -1
  173. package/lib/module/utils/getPreferredUnit.js +0 -2
  174. package/lib/module/utils/getPreferredUnit.js.map +1 -1
  175. package/lib/module/utils/getPreferredUnits.js +0 -2
  176. package/lib/module/utils/getPreferredUnits.js.map +1 -1
  177. package/lib/module/utils/getPreferredUnitsTyped.js +0 -8
  178. package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -1
  179. package/lib/module/utils/getRequestStatusForAuthorization.js +4 -4
  180. package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -1
  181. package/lib/module/utils/prepareOptions.js +0 -2
  182. package/lib/module/utils/prepareOptions.js.map +1 -1
  183. package/lib/module/utils/queryCategorySamples.js +3 -10
  184. package/lib/module/utils/queryCategorySamples.js.map +1 -1
  185. package/lib/module/utils/queryCategorySamplesWithAnchor.js +14 -0
  186. package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +1 -0
  187. package/lib/module/utils/queryCorrelationSamples.js +1 -3
  188. package/lib/module/utils/queryCorrelationSamples.js.map +1 -1
  189. package/lib/module/utils/queryHeartbeatSeriesSamples.js +3 -9
  190. package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +1 -1
  191. package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +14 -0
  192. package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -0
  193. package/lib/module/utils/queryQuantitySamples.js +3 -10
  194. package/lib/module/utils/queryQuantitySamples.js.map +1 -1
  195. package/lib/module/utils/queryQuantitySamplesWithAnchor.js +16 -0
  196. package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +1 -0
  197. package/lib/module/utils/querySources.js +0 -2
  198. package/lib/module/utils/querySources.js.map +1 -1
  199. package/lib/module/utils/queryStatisticsForQuantity.js +3 -4
  200. package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -1
  201. package/lib/module/utils/queryWorkouts.js +1 -3
  202. package/lib/module/utils/queryWorkouts.js.map +1 -1
  203. package/lib/module/utils/requestAuthorization.js +4 -4
  204. package/lib/module/utils/requestAuthorization.js.map +1 -1
  205. package/lib/module/utils/saveCategorySample.js +0 -2
  206. package/lib/module/utils/saveCategorySample.js.map +1 -1
  207. package/lib/module/utils/saveCorrelationSample.js +3 -4
  208. package/lib/module/utils/saveCorrelationSample.js.map +1 -1
  209. package/lib/module/utils/saveQuantitySample.js +0 -2
  210. package/lib/module/utils/saveQuantitySample.js.map +1 -1
  211. package/lib/module/utils/saveWorkoutSample.js +3 -5
  212. package/lib/module/utils/saveWorkoutSample.js.map +1 -1
  213. package/lib/module/utils/serializeDate.js +0 -1
  214. package/lib/module/utils/serializeDate.js.map +1 -1
  215. package/lib/module/utils/serializeDate.test.js.map +1 -1
  216. package/lib/module/utils/subscribeToChanges.js +0 -3
  217. package/lib/module/utils/subscribeToChanges.js.map +1 -1
  218. package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +2 -3
  219. package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +2 -3
  220. package/lib/typescript/src/index.ios.d.ts +4 -1
  221. package/lib/typescript/src/native-types.d.ts +66 -63
  222. package/lib/typescript/src/types.d.ts +3 -3
  223. package/lib/typescript/src/utils/deleteQuantitySample.d.ts +1 -1
  224. package/lib/typescript/src/utils/deleteSamples.d.ts +1 -1
  225. package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +1 -1
  226. package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +1 -1
  227. package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +1 -1
  228. package/lib/typescript/src/utils/getPreferredUnit.d.ts +1 -1
  229. package/lib/typescript/src/utils/getPreferredUnits.d.ts +1 -1
  230. package/lib/typescript/src/utils/queryCategorySamples.d.ts +3 -8
  231. package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +10 -0
  232. package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +1 -1
  233. package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +2 -2
  234. package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +10 -0
  235. package/lib/typescript/src/utils/queryQuantitySamples.d.ts +4 -9
  236. package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +12 -0
  237. package/lib/typescript/src/utils/querySources.d.ts +1 -1
  238. package/package.json +20 -18
  239. package/src/hooks/useHealthkitAuthorization.test.ts +1 -1
  240. package/src/hooks/useIsHealthDataAvailable.test.ts +1 -1
  241. package/src/hooks/useMostRecentCategorySample.ts +3 -4
  242. package/src/hooks/useMostRecentQuantitySample.ts +2 -3
  243. package/src/hooks/useStatisticsForQuantity.ts +1 -1
  244. package/src/index.ios.tsx +6 -0
  245. package/src/index.tsx +10 -5
  246. package/src/jest.setup.ts +3 -0
  247. package/src/native-types.ts +28 -7
  248. package/src/utils/deserializeCategorySample.test.ts +1 -1
  249. package/src/utils/getMostRecentCategorySample.ts +1 -1
  250. package/src/utils/getMostRecentQuantitySample.ts +1 -1
  251. package/src/utils/queryCategorySamples.ts +6 -18
  252. package/src/utils/queryCategorySamplesWithAnchor.ts +39 -0
  253. package/src/utils/queryCorrelationSamples.ts +2 -2
  254. package/src/utils/queryHeartbeatSeriesSamples.ts +3 -8
  255. package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +33 -0
  256. package/src/utils/queryQuantitySamples.ts +8 -18
  257. package/src/utils/queryQuantitySamplesWithAnchor.ts +46 -0
  258. package/src/utils/queryStatisticsForQuantity.ts +1 -1
  259. package/src/utils/queryWorkouts.ts +1 -1
  260. package/src/utils/saveCorrelationSample.ts +1 -1
  261. package/src/utils/saveWorkoutSample.ts +1 -1
  262. package/android/.project +0 -34
  263. package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
  264. package/android/build.gradle +0 -130
  265. package/android/gradle.properties +0 -4
  266. package/android/src/main/AndroidManifest.xml +0 -4
  267. package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitModule.kt +0 -24
  268. package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitPackage.kt +0 -20
@@ -8,7 +8,7 @@ export interface HKCategorySample<T extends HKCategoryTypeIdentifier = HKCategor
8
8
  readonly startDate: Date;
9
9
  readonly endDate: Date;
10
10
  }
11
- export declare type GenericQueryOptions = {
11
+ export type GenericQueryOptions = {
12
12
  readonly from?: Date;
13
13
  readonly to?: Date;
14
14
  readonly limit?: number;
@@ -40,8 +40,8 @@ export interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdent
40
40
  readonly to: Date;
41
41
  };
42
42
  }
43
- export declare type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
44
- export declare type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
43
+ export type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
44
+ export type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
45
45
  export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier> extends Omit<HKCorrelationRaw<TIdentifier>, 'endDate' | 'objects' | 'startDate'> {
46
46
  readonly objects: readonly (HKCategorySample | HKQuantitySample)[];
47
47
  readonly startDate: Date;
@@ -1,4 +1,4 @@
1
1
  import type { HKQuantityTypeIdentifier } from '../native-types';
2
- export declare type DeleteQuantitySampleFn = <TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, uuid: string) => Promise<boolean>;
2
+ export type DeleteQuantitySampleFn = <TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, uuid: string) => Promise<boolean>;
3
3
  declare const deleteQuantitySample: DeleteQuantitySampleFn;
4
4
  export default deleteQuantitySample;
@@ -1,5 +1,5 @@
1
1
  import type { HKQuantityTypeIdentifier } from '../native-types';
2
- export declare type DeleteSamplesFn = <TIdentifier extends HKQuantityTypeIdentifier>(sample: {
2
+ export type DeleteSamplesFn = <TIdentifier extends HKQuantityTypeIdentifier>(sample: {
3
3
  readonly identifier: TIdentifier;
4
4
  readonly startDate?: Date;
5
5
  readonly endDate?: Date;
@@ -1,3 +1,3 @@
1
1
  import type { HKCategoryTypeIdentifier } from '../native-types';
2
- declare function getMostRecentCategorySample<T extends HKCategoryTypeIdentifier>(identifier: T): Promise<import("..").HKCategorySample<T> | null>;
2
+ declare function getMostRecentCategorySample<T extends HKCategoryTypeIdentifier>(identifier: T): Promise<import("../native-types").HKCategorySampleRaw<T> | null>;
3
3
  export default getMostRecentCategorySample;
@@ -1,3 +1,3 @@
1
1
  import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
2
- declare function getMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit): Promise<import("..").HKQuantitySample<TIdentifier, UnitForIdentifier<TIdentifier>> | null>;
2
+ declare function getMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit): Promise<import("../native-types").HKQuantitySampleRaw<TIdentifier, UnitForIdentifier<TIdentifier>> | null>;
3
3
  export default getMostRecentQuantitySample;
@@ -1,5 +1,5 @@
1
1
  import type { EnergyUnit, LengthUnit } from '../native-types';
2
2
  import type { HKWorkout, QueryWorkoutsOptions } from '../types';
3
- export declare type GetMostRecentWorkoutFn = <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => Promise<HKWorkout<TEnergy, TDistance> | null>;
3
+ export type GetMostRecentWorkoutFn = <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => Promise<HKWorkout<TEnergy, TDistance> | null>;
4
4
  declare const getMostRecentWorkout: GetMostRecentWorkoutFn;
5
5
  export default getMostRecentWorkout;
@@ -1,4 +1,4 @@
1
1
  import type { HKQuantityTypeIdentifier, HKUnit } from '../native-types';
2
- export declare type GetPreferredUnitFn = (identifier: HKQuantityTypeIdentifier) => Promise<HKUnit | undefined>;
2
+ export type GetPreferredUnitFn = (identifier: HKQuantityTypeIdentifier) => Promise<HKUnit | undefined>;
3
3
  declare const getPreferredUnit: GetPreferredUnitFn;
4
4
  export default getPreferredUnit;
@@ -1,4 +1,4 @@
1
1
  import type { HKQuantityTypeIdentifier, HKUnit } from '../native-types';
2
- export declare type GetPreferredUnitsFn = (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<readonly HKUnit[]>;
2
+ export type GetPreferredUnitsFn = (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<readonly HKUnit[]>;
3
3
  declare const getPreferredUnits: GetPreferredUnitsFn;
4
4
  export default getPreferredUnits;
@@ -1,10 +1,5 @@
1
- import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types';
2
- import type { GenericQueryOptions, HKCategorySample } from '../types';
3
- export declare type QueryCategorySamplesResponse<T extends HKCategoryTypeIdentifier> = {
4
- readonly samples: readonly HKCategorySample<T>[];
5
- readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
6
- readonly newAnchor: string;
7
- };
8
- export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<QueryCategorySamplesResponse<T>>;
1
+ import type { HKCategoryTypeIdentifier, HKCategorySampleRaw } from '../native-types';
2
+ import type { GenericQueryOptions } from '../types';
3
+ export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKCategorySampleRaw<T>[]>;
9
4
  declare const queryCategorySamples: QueryCategorySamplesFn;
10
5
  export default queryCategorySamples;
@@ -0,0 +1,10 @@
1
+ import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types';
2
+ import type { GenericQueryOptions, HKCategorySample } from '../types';
3
+ export type QueryCategorySamplesWithAnchorResponse<T extends HKCategoryTypeIdentifier> = {
4
+ readonly samples: readonly HKCategorySample<T>[];
5
+ readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
6
+ readonly newAnchor: string;
7
+ };
8
+ export type QueryCategorySamplesWithAnchorFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryCategorySamplesWithAnchorResponse<T>>;
9
+ declare const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn;
10
+ export default queryCategorySamplesWithAnchor;
@@ -1,5 +1,5 @@
1
1
  import type { HKCorrelationTypeIdentifier } from '../native-types';
2
2
  import type { GenericQueryOptions, HKCorrelation } from '../types';
3
- export declare type QueryCorrelationSamplesFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, options: Omit<GenericQueryOptions, 'ascending' | 'limit'>) => Promise<readonly HKCorrelation<TIdentifier>[]>;
3
+ export type QueryCorrelationSamplesFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, options: Omit<GenericQueryOptions, 'anchor' | 'ascending' | 'limit'>) => Promise<readonly HKCorrelation<TIdentifier>[]>;
4
4
  declare const queryCorrelationSamples: QueryCorrelationSamplesFn;
5
5
  export default queryCorrelationSamples;
@@ -1,10 +1,10 @@
1
1
  import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types';
2
2
  import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types';
3
- export declare type QueryHeartbeatSeriesSamplesResponse = {
3
+ export type QueryHeartbeatSeriesSamplesResponse = {
4
4
  readonly samples: readonly HKHeartbeatSeriesSample[];
5
5
  readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
6
6
  readonly newAnchor: string;
7
7
  };
8
- export declare type QueryHeartbeatSeriesSamplesFn = (options: GenericQueryOptions) => Promise<QueryHeartbeatSeriesSamplesResponse>;
8
+ export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKHeartbeatSeriesSample[]>;
9
9
  declare const queryHeartbeatSeriesSamples: QueryHeartbeatSeriesSamplesFn;
10
10
  export default queryHeartbeatSeriesSamples;
@@ -0,0 +1,10 @@
1
+ import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types';
2
+ import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types';
3
+ export type QueryHeartbeatSeriesSamplesResponse = {
4
+ readonly samples: readonly HKHeartbeatSeriesSample[];
5
+ readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
6
+ readonly newAnchor: string;
7
+ };
8
+ export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryHeartbeatSeriesSamplesResponse>;
9
+ declare const queryHeartbeatSeriesSamplesWithAnchor: QueryHeartbeatSeriesSamplesFn;
10
+ export default queryHeartbeatSeriesSamplesWithAnchor;
@@ -1,12 +1,7 @@
1
- import type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types';
2
- import type { GenericQueryOptions, HKQuantitySample } from '../types';
3
- export declare type QueryQuantitySamplesResponse<T extends HKQuantityTypeIdentifier> = {
4
- readonly samples: readonly HKQuantitySample<T>[];
5
- readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
6
- readonly newAnchor: string;
7
- };
8
- export declare type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: GenericQueryOptions & {
1
+ import type { HKQuantityTypeIdentifier, UnitForIdentifier, HKQuantitySampleRaw } from '../native-types';
2
+ import type { GenericQueryOptions } from '../types';
3
+ export type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: Omit<GenericQueryOptions, 'anchor'> & {
9
4
  readonly unit?: TUnit;
10
- }) => Promise<QueryQuantitySamplesResponse<TIdentifier>>;
5
+ }) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
11
6
  declare const queryQuantitySamples: QueryQuantitySamplesFn;
12
7
  export default queryQuantitySamples;
@@ -0,0 +1,12 @@
1
+ import type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types';
2
+ import type { GenericQueryOptions, HKQuantitySample } from '../types';
3
+ export type QueryQuantitySamplesWithAnchorResponse<T extends HKQuantityTypeIdentifier> = {
4
+ readonly samples: readonly HKQuantitySample<T>[];
5
+ readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
6
+ readonly newAnchor: string;
7
+ };
8
+ export type QueryQuantitySamplesWithAnchorFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: Omit<GenericQueryOptions, 'ascending'> & {
9
+ readonly unit?: TUnit;
10
+ }) => Promise<QueryQuantitySamplesWithAnchorResponse<TIdentifier>>;
11
+ declare const queryQuantitySamplesWithAnchor: QueryQuantitySamplesWithAnchorFn;
12
+ export default queryQuantitySamplesWithAnchor;
@@ -1,4 +1,4 @@
1
1
  import type { HKQuantityTypeIdentifier, HKSource, HKCategoryTypeIdentifier } from '../native-types';
2
- export declare type QuerySourcesFn = <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
2
+ export type QuerySourcesFn = <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
3
3
  declare const querySources: QuerySourcesFn;
4
4
  export default querySources;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -10,26 +10,32 @@
10
10
  "files": [
11
11
  "src",
12
12
  "lib",
13
- "android",
14
13
  "ios",
15
14
  "cpp",
16
15
  "kingstinct-react-native-healthkit.podspec",
17
16
  "!lib/typescript/example",
18
17
  "!**/__tests__",
19
18
  "!**/__fixtures__",
20
- "!**/__mocks__"
19
+ "!**/__mocks__",
20
+ "app.plugin.js"
21
21
  ],
22
22
  "scripts": {
23
23
  "test-only": "jest",
24
24
  "test": "concurrently \"yarn test-only\" \"yarn typecheck\" \"yarn lint\"",
25
25
  "typecheck": "tsc --noEmit",
26
26
  "lint": "eslint \"**/*.{js,ts,tsx}\" --cache",
27
- "prepare": "bob build",
27
+ "prepare": "bob build && husky install",
28
28
  "release": "release-it",
29
29
  "example": "yarn --cwd example",
30
30
  "pods": "cd example && pod-install --quiet",
31
31
  "bootstrap": "yarn example && yarn && yarn pods"
32
32
  },
33
+ "lint-staged": {
34
+ "*.swift": "swiftlint ios --fix",
35
+ "*.ts": "eslint --fix",
36
+ "*.js": "eslint --fix",
37
+ "*.json": "eslint --fix"
38
+ },
33
39
  "keywords": [
34
40
  "react-native",
35
41
  "ios",
@@ -51,15 +57,14 @@
51
57
  "@expo/config-plugins": "^6.0.1",
52
58
  "@graphql-eslint/eslint-plugin": ">=3",
53
59
  "@release-it/conventional-changelog": "2",
54
- "@testing-library/react-native": "^11.0.0",
60
+ "@testing-library/react-native": "12",
55
61
  "@types/jest": ">=26",
56
62
  "@types/node": "^18.7.14",
57
- "@types/react": "17",
58
- "@types/react-native": "0.67",
63
+ "@types/react": "~18.0.27",
59
64
  "@typescript-eslint/eslint-plugin": ">=5",
60
65
  "@typescript-eslint/parser": ">=5",
61
66
  "commitlint": "^17.1.1",
62
- "concurrently": "^7.3.0",
67
+ "concurrently": "8",
63
68
  "eslint": ">=8",
64
69
  "eslint-config-airbnb": ">=19",
65
70
  "eslint-config-airbnb-base": ">=15",
@@ -82,26 +87,23 @@
82
87
  "husky": "8",
83
88
  "jest": ">=26",
84
89
  "jest-environment-jsdom": "^29.0.2",
90
+ "lint-staged": "^13.2.2",
85
91
  "metro-react-native-babel-preset": "^0.70.3",
86
92
  "pod-install": "^0.1.0",
87
- "react": "17",
88
- "react-native": "0.68",
93
+ "react": "18.2.0",
94
+ "react-native": "0.71.8",
89
95
  "react-native-builder-bob": "^0.18.1",
90
- "react-test-renderer": "17",
96
+ "react-test-renderer": "18",
91
97
  "release-it": "14",
98
+ "solidarity": "^3.0.4",
99
+ "solidarity-react-native": "^2.1.2",
92
100
  "ts-node": "^10.9.1",
93
- "typescript": ">=4"
101
+ "typescript": "^4.9.4"
94
102
  },
95
103
  "peerDependencies": {
96
104
  "react": "*",
97
105
  "react-native": "*"
98
106
  },
99
- "husky": {
100
- "hooks": {
101
- "commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
102
- "pre-commit": "yarn lint && yarn typescript"
103
- }
104
- },
105
107
  "commitlint": {
106
108
  "extends": [
107
109
  "@commitlint/config-conventional"
@@ -1,8 +1,8 @@
1
1
  import { renderHook, act } from '@testing-library/react-native'
2
2
 
3
+ import useHealthkitAuthorization from './useHealthkitAuthorization'
3
4
  import Native, { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier } from '../native-types'
4
5
  import waitForNextUpdate from '../test-utils'
5
- import useHealthkitAuthorization from './useHealthkitAuthorization'
6
6
 
7
7
  describe('useHealthkitAuthorization', () => {
8
8
  test('should return shouldRequest', async () => {
@@ -1,8 +1,8 @@
1
1
  import { renderHook } from '@testing-library/react-native'
2
2
 
3
+ import useIsHealthDataAvailable from './useIsHealthDataAvailable'
3
4
  import Native from '../native-types'
4
5
  import waitForNextUpdate from '../test-utils'
5
- import useIsHealthDataAvailable from './useIsHealthDataAvailable'
6
6
 
7
7
  describe('useIsHealthDataAvailable', () => {
8
8
  test('should return false', async () => {
@@ -1,15 +1,14 @@
1
1
  import { useCallback, useState } from 'react'
2
2
 
3
- import getMostRecentCategorySample from '../utils/getMostRecentCategorySample'
4
3
  import useSubscribeToChanges from './useSubscribeToChanges'
4
+ import getMostRecentCategorySample from '../utils/getMostRecentCategorySample'
5
5
 
6
- import type { HKCategoryTypeIdentifier } from '../native-types'
7
- import type { HKCategorySample } from '../types'
6
+ import type { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../native-types'
8
7
 
9
8
  function useMostRecentCategorySample<
10
9
  TCategory extends HKCategoryTypeIdentifier
11
10
  >(identifier: TCategory) {
12
- const [category, setCategory] = useState<HKCategorySample<TCategory> | null>(
11
+ const [category, setCategory] = useState<HKCategorySampleRaw<TCategory> | null>(
13
12
  null,
14
13
  )
15
14
  const updater = useCallback(() => {
@@ -4,14 +4,13 @@ import ensureUnit from '../utils/ensureUnit'
4
4
  import getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample'
5
5
  import subscribeToChanges from '../utils/subscribeToChanges'
6
6
 
7
- import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
8
- import type { HKQuantitySample } from '../types'
7
+ import type { HKQuantitySampleRaw, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
9
8
 
10
9
  function useMostRecentQuantitySample<
11
10
  TIdentifier extends HKQuantityTypeIdentifier,
12
11
  TUnit extends UnitForIdentifier<TIdentifier>
13
12
  >(identifier: TIdentifier, unit?: TUnit) {
14
- const [lastSample, setLastSample] = useState<HKQuantitySample<
13
+ const [lastSample, setLastSample] = useState<HKQuantitySampleRaw<
15
14
  TIdentifier
16
15
  > | null>(null)
17
16
 
@@ -2,8 +2,8 @@ import {
2
2
  useState, useEffect, useCallback, useRef,
3
3
  } from 'react'
4
4
 
5
- import queryStatisticsForQuantity from '../utils/queryStatisticsForQuantity'
6
5
  import useSubscribeToChanges from './useSubscribeToChanges'
6
+ import queryStatisticsForQuantity from '../utils/queryStatisticsForQuantity'
7
7
 
8
8
  import type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types'
9
9
  import type { QueryStatisticsResponse } from '../types'
package/src/index.ios.tsx CHANGED
@@ -15,9 +15,12 @@ import getPreferredUnit from './utils/getPreferredUnit'
15
15
  import getPreferredUnits from './utils/getPreferredUnits'
16
16
  import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'
17
17
  import queryCategorySamples from './utils/queryCategorySamples'
18
+ import queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'
18
19
  import queryCorrelationSamples from './utils/queryCorrelationSamples'
19
20
  import queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples'
21
+ import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor'
20
22
  import queryQuantitySamples from './utils/queryQuantitySamples'
23
+ import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'
21
24
  import querySources from './utils/querySources'
22
25
  import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'
23
26
  import queryWorkouts from './utils/queryWorkouts'
@@ -59,9 +62,12 @@ const Healthkit = {
59
62
 
60
63
  // query methods
61
64
  queryCategorySamples,
65
+ queryCategorySamplesWithAnchor,
62
66
  queryCorrelationSamples,
63
67
  queryHeartbeatSeriesSamples,
68
+ queryHeartbeatSeriesSamplesWithAnchor,
64
69
  queryQuantitySamples,
70
+ queryQuantitySamplesWithAnchor,
65
71
  queryStatisticsForQuantity,
66
72
  queryWorkouts,
67
73
  querySources,
package/src/index.tsx CHANGED
@@ -1,10 +1,12 @@
1
1
  import { Platform } from 'react-native'
2
2
 
3
3
  import {
4
- HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKQuantityTypeIdentifier, HKUnits, HKWheelchairUse, QueryQuantitySamplesResponseRaw,
4
+ HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse, QueryQuantitySamplesResponseRaw,
5
5
  } from './native-types'
6
6
 
7
7
  import type ReactNativeHealthkit from './index.ios'
8
+ import type { QueryCategorySamplesFn } from './utils/queryCategorySamples'
9
+ import type { QueryQuantitySamplesFn } from './utils/queryQuantitySamples'
8
10
 
9
11
  const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${
10
12
  Platform.OS
@@ -24,7 +26,7 @@ function UnavailableFn<T = unknown>(retVal: T) {
24
26
  }
25
27
 
26
28
  const Healthkit: typeof ReactNativeHealthkit = {
27
- authorizationStatusFor: UnavailableFn(Promise.resolve(false)),
29
+ authorizationStatusFor: UnavailableFn(Promise.resolve(HKAuthorizationStatus.notDetermined)),
28
30
  disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
29
31
  disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
30
32
  enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
@@ -41,18 +43,21 @@ const Healthkit: typeof ReactNativeHealthkit = {
41
43
  getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
42
44
  getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
43
45
  isHealthDataAvailable: async () => Promise.resolve(false),
44
- queryCategorySamples: UnavailableFn(Promise.resolve({
46
+ queryCategorySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryCategorySamplesFn,
47
+ queryCategorySamplesWithAnchor: UnavailableFn(Promise.resolve({
45
48
  samples: [],
46
49
  deletedSamples: [],
47
50
  newAnchor: '',
48
51
  })),
49
52
  queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
50
- queryHeartbeatSeriesSamples: UnavailableFn(Promise.resolve({
53
+ queryHeartbeatSeriesSamples: UnavailableFn(Promise.resolve([])),
54
+ queryHeartbeatSeriesSamplesWithAnchor: UnavailableFn(Promise.resolve({
51
55
  samples: [],
52
56
  deletedSamples: [],
53
57
  newAnchor: '',
54
58
  })),
55
- queryQuantitySamples: UnavailableFn(Promise.resolve({
59
+ queryQuantitySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryQuantitySamplesFn,
60
+ queryQuantitySamplesWithAnchor: UnavailableFn(Promise.resolve({
56
61
  samples: [],
57
62
  deletedSamples: [],
58
63
  newAnchor: '',
package/src/jest.setup.ts CHANGED
@@ -14,6 +14,8 @@ const mockModule: (NativeModule & typeof Native) = {
14
14
  disableAllBackgroundDelivery: jest.fn(),
15
15
  disableBackgroundDelivery: jest.fn(),
16
16
  enableBackgroundDelivery: jest.fn(),
17
+ queryCategorySamplesWithAnchor: jest.fn(),
18
+ queryQuantitySamplesWithAnchor: jest.fn(),
17
19
  getBiologicalSex: jest.fn(),
18
20
  getBloodType: jest.fn(),
19
21
  getDateOfBirth: jest.fn(),
@@ -25,6 +27,7 @@ const mockModule: (NativeModule & typeof Native) = {
25
27
  queryCategorySamples: jest.fn(),
26
28
  queryCorrelationSamples: jest.fn(),
27
29
  queryHeartbeatSeriesSamples: jest.fn(),
30
+ queryHeartbeatSeriesSamplesWithAnchor: jest.fn(),
28
31
  queryQuantitySamples: jest.fn(),
29
32
  querySources: jest.fn(),
30
33
  queryStatisticsForQuantity: jest.fn(),
@@ -1240,7 +1240,7 @@ type ReactNativeHealthkitTypeNative = {
1240
1240
  identifier: HKSampleTypeIdentifier
1241
1241
  ): Promise<QueryId>;
1242
1242
  unsubscribeQuery(queryId: QueryId): Promise<boolean>;
1243
- authorizationStatusFor(type: HealthkitReadAuthorization): Promise<boolean>;
1243
+ authorizationStatusFor(type: HealthkitReadAuthorization): Promise<HKAuthorizationStatus>;
1244
1244
  getRequestStatusForAuthorization(
1245
1245
  write: WritePermissions,
1246
1246
  read: ReadPermissions
@@ -1286,16 +1286,26 @@ type ReactNativeHealthkitTypeNative = {
1286
1286
  to: string,
1287
1287
  limit: number,
1288
1288
  ascending: boolean,
1289
- anchor: string
1290
- ) => Promise<QueryCategorySamplesResponseRaw<T>>;
1291
- readonly queryHeartbeatSeriesSamples: (
1289
+ ) => Promise<readonly HKCategorySampleRaw<T>[]>;
1290
+ readonly queryQuantitySamples: <
1291
+ TIdentifier extends HKQuantityTypeIdentifier,
1292
+ TUnit extends UnitForIdentifier<TIdentifier>
1293
+ >(
1294
+ identifier: TIdentifier,
1295
+ unit: TUnit,
1292
1296
  from: string,
1293
1297
  to: string,
1294
1298
  limit: number,
1295
1299
  ascending: boolean,
1300
+ ) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
1301
+ readonly queryCategorySamplesWithAnchor: <T extends HKCategoryTypeIdentifier>(
1302
+ identifier: T,
1303
+ from: string,
1304
+ to: string,
1305
+ limit: number,
1296
1306
  anchor: string
1297
- ) => Promise<QueryHeartbeatSeriesSamplesResponseRaw>;
1298
- readonly queryQuantitySamples: <
1307
+ ) => Promise<QueryCategorySamplesResponseRaw<T>>;
1308
+ readonly queryQuantitySamplesWithAnchor: <
1299
1309
  TIdentifier extends HKQuantityTypeIdentifier,
1300
1310
  TUnit extends UnitForIdentifier<TIdentifier>
1301
1311
  >(
@@ -1304,9 +1314,20 @@ type ReactNativeHealthkitTypeNative = {
1304
1314
  from: string,
1305
1315
  to: string,
1306
1316
  limit: number,
1307
- ascending: boolean,
1308
1317
  anchor: string
1309
1318
  ) => Promise<QueryQuantitySamplesResponseRaw<TIdentifier>>;
1319
+ readonly queryHeartbeatSeriesSamples: (
1320
+ from: string,
1321
+ to: string,
1322
+ limit: number,
1323
+ ascending: boolean,
1324
+ ) => Promise<readonly HKHeartbeatSeriesSampleRaw[]>;
1325
+ readonly queryHeartbeatSeriesSamplesWithAnchor: (
1326
+ from: string,
1327
+ to: string,
1328
+ limit: number,
1329
+ anchor: string
1330
+ ) => Promise<QueryHeartbeatSeriesSamplesResponseRaw>;
1310
1331
  readonly querySources: <
1311
1332
  TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier
1312
1333
  >(
@@ -1,5 +1,5 @@
1
- import { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../types'
2
1
  import deserializeCategorySample from './deserializeCategorySample'
2
+ import { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../types'
3
3
 
4
4
  describe('deserializeCategorySample', () => {
5
5
  it('should deserialize category sample', () => {
@@ -12,7 +12,7 @@ async function getMostRecentCategorySample<
12
12
  ascending: false,
13
13
  })
14
14
 
15
- return samples.samples[0] || null
15
+ return samples[0] || null
16
16
  }
17
17
 
18
18
  export default getMostRecentCategorySample
@@ -13,7 +13,7 @@ async function getMostRecentQuantitySample<
13
13
  limit: 1,
14
14
  unit,
15
15
  })
16
- return samples.samples[0] || null
16
+ return samples[0] || null
17
17
  }
18
18
 
19
19
  export default getMostRecentQuantitySample
@@ -1,20 +1,13 @@
1
- import Native from '../native-types'
2
- import deserializCategorySample from './deserializeCategorySample'
3
1
  import prepareOptions from './prepareOptions'
2
+ import Native from '../native-types'
4
3
 
5
- import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types'
6
- import type { GenericQueryOptions, HKCategorySample } from '../types'
7
-
8
- export type QueryCategorySamplesResponse<T extends HKCategoryTypeIdentifier> = {
9
- readonly samples: readonly HKCategorySample<T>[],
10
- readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
11
- readonly newAnchor: string
12
- }
4
+ import type { HKCategoryTypeIdentifier, HKCategorySampleRaw } from '../native-types'
5
+ import type { GenericQueryOptions } from '../types'
13
6
 
14
7
  export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(
15
8
  identifier: T,
16
- options: GenericQueryOptions
17
- ) => Promise<QueryCategorySamplesResponse<T>>;
9
+ options: Omit<GenericQueryOptions, 'anchor'>
10
+ ) => Promise<readonly HKCategorySampleRaw<T>[]>;
18
11
 
19
12
  const queryCategorySamples: QueryCategorySamplesFn = async (
20
13
  identifier,
@@ -27,14 +20,9 @@ const queryCategorySamples: QueryCategorySamplesFn = async (
27
20
  opts.to,
28
21
  opts.limit,
29
22
  opts.ascending,
30
- opts.anchor,
31
23
  )
32
24
 
33
- return {
34
- samples: raw.samples.map(deserializCategorySample),
35
- deletedSamples: raw.deletedSamples,
36
- newAnchor: raw.newAnchor,
37
- }
25
+ return raw
38
26
  }
39
27
 
40
28
  export default queryCategorySamples
@@ -0,0 +1,39 @@
1
+ import deserializCategorySample from './deserializeCategorySample'
2
+ import prepareOptions from './prepareOptions'
3
+ import Native from '../native-types'
4
+
5
+ import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types'
6
+ import type { GenericQueryOptions, HKCategorySample } from '../types'
7
+
8
+ export type QueryCategorySamplesWithAnchorResponse<T extends HKCategoryTypeIdentifier> = {
9
+ readonly samples: readonly HKCategorySample<T>[],
10
+ readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
11
+ readonly newAnchor: string
12
+ }
13
+
14
+ export type QueryCategorySamplesWithAnchorFn = <T extends HKCategoryTypeIdentifier>(
15
+ identifier: T,
16
+ options: Omit<GenericQueryOptions, 'ascending'>
17
+ ) => Promise<QueryCategorySamplesWithAnchorResponse<T>>;
18
+
19
+ const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn = async (
20
+ identifier,
21
+ options,
22
+ ) => {
23
+ const opts = prepareOptions(options)
24
+ const raw = await Native.queryCategorySamplesWithAnchor(
25
+ identifier,
26
+ opts.from,
27
+ opts.to,
28
+ opts.limit,
29
+ opts.anchor,
30
+ )
31
+
32
+ return {
33
+ samples: raw.samples.map(deserializCategorySample),
34
+ deletedSamples: raw.deletedSamples,
35
+ newAnchor: raw.newAnchor,
36
+ }
37
+ }
38
+
39
+ export default queryCategorySamplesWithAnchor
@@ -1,6 +1,6 @@
1
- import Native from '../native-types'
2
1
  import deserializeCorrelation from './deserializeCorrelation'
3
2
  import prepareOptions from './prepareOptions'
3
+ import Native from '../native-types'
4
4
 
5
5
  import type { HKCorrelationTypeIdentifier } from '../native-types'
6
6
  import type { GenericQueryOptions, HKCorrelation } from '../types'
@@ -9,7 +9,7 @@ export type QueryCorrelationSamplesFn = <
9
9
  TIdentifier extends HKCorrelationTypeIdentifier
10
10
  >(
11
11
  typeIdentifier: TIdentifier,
12
- options: Omit<GenericQueryOptions, 'ascending' | 'limit'>
12
+ options: Omit<GenericQueryOptions, 'anchor' | 'ascending' | 'limit'>
13
13
  ) => Promise<readonly HKCorrelation<TIdentifier>[]>;
14
14
 
15
15
  const queryCorrelationSamples: QueryCorrelationSamplesFn = async (