@kingstinct/react-native-healthkit 4.4.4 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/README.md +1 -1
  2. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  3. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  4. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  5. package/ios/ReactNativeHealthkit.xcodeproj/xcuserdata/robertherber.xcuserdatad/xcschemes/xcschememanagement.plist +14 -0
  6. package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
  7. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
  8. package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
  9. package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
  10. package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
  11. package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
  12. package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
  13. package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
  14. package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
  15. package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
  16. package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
  17. package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
  18. package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
  19. package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
  20. package/lib/commonjs/index.ios.js +66 -394
  21. package/lib/commonjs/index.ios.js.map +1 -1
  22. package/lib/commonjs/index.js +9 -17
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/native-types.js +249 -78
  25. package/lib/commonjs/native-types.js.map +1 -1
  26. package/lib/commonjs/types.js +13 -0
  27. package/lib/commonjs/types.js.map +1 -1
  28. package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
  29. package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
  30. package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
  31. package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
  32. package/lib/commonjs/utils/deserializeSample.js +17 -0
  33. package/lib/commonjs/utils/deserializeSample.js.map +1 -0
  34. package/lib/commonjs/utils/deserializeWorkout.js +17 -0
  35. package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
  36. package/lib/commonjs/utils/ensureMetadata.js +14 -0
  37. package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
  38. package/lib/commonjs/utils/ensureUnit.js +23 -0
  39. package/lib/commonjs/utils/ensureUnit.js.map +1 -0
  40. package/lib/commonjs/utils/getDateOfBirth.js +19 -0
  41. package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
  42. package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
  43. package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
  44. package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
  45. package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
  46. package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
  47. package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
  48. package/lib/commonjs/utils/getPreferredUnit.js +19 -0
  49. package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
  50. package/lib/commonjs/utils/getPreferredUnits.js +19 -0
  51. package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
  52. package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
  53. package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
  54. package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
  55. package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
  56. package/lib/commonjs/utils/prepareOptions.js +27 -0
  57. package/lib/commonjs/utils/prepareOptions.js.map +1 -0
  58. package/lib/commonjs/utils/queryCategorySamples.js +24 -0
  59. package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
  60. package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
  61. package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
  62. package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
  63. package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
  64. package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
  65. package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
  66. package/lib/commonjs/utils/queryWorkouts.js +30 -0
  67. package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
  68. package/lib/commonjs/utils/requestAuthorization.js +25 -0
  69. package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
  70. package/lib/commonjs/utils/saveCategorySample.js +21 -0
  71. package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
  72. package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
  73. package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
  74. package/lib/commonjs/utils/saveQuantitySample.js +21 -0
  75. package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
  76. package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
  77. package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
  78. package/lib/commonjs/utils/serializeDate.js +12 -0
  79. package/lib/commonjs/utils/serializeDate.js.map +1 -0
  80. package/lib/commonjs/utils/subscribeToChanges.js +37 -0
  81. package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
  82. package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
  83. package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
  84. package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
  85. package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
  86. package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
  87. package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
  88. package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
  89. package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
  90. package/lib/module/hooks/useMostRecentWorkout.js +47 -0
  91. package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
  92. package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
  93. package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
  94. package/lib/module/hooks/useSubscribeToChanges.js +26 -0
  95. package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
  96. package/lib/module/index.ios.js +32 -370
  97. package/lib/module/index.ios.js.map +1 -1
  98. package/lib/module/index.js +10 -7
  99. package/lib/module/index.js.map +1 -1
  100. package/lib/module/native-types.js +232 -74
  101. package/lib/module/native-types.js.map +1 -1
  102. package/lib/module/types.js +15 -0
  103. package/lib/module/types.js.map +1 -1
  104. package/lib/module/utils/deserializeCategorySample.js +7 -0
  105. package/lib/module/utils/deserializeCategorySample.js.map +1 -0
  106. package/lib/module/utils/deserializeCorrelation.js +21 -0
  107. package/lib/module/utils/deserializeCorrelation.js.map +1 -0
  108. package/lib/module/utils/deserializeSample.js +9 -0
  109. package/lib/module/utils/deserializeSample.js.map +1 -0
  110. package/lib/module/utils/deserializeWorkout.js +9 -0
  111. package/lib/module/utils/deserializeWorkout.js.map +1 -0
  112. package/lib/module/utils/ensureMetadata.js +6 -0
  113. package/lib/module/utils/ensureMetadata.js.map +1 -0
  114. package/lib/module/utils/ensureUnit.js +13 -0
  115. package/lib/module/utils/ensureUnit.js.map +1 -0
  116. package/lib/module/utils/getDateOfBirth.js +9 -0
  117. package/lib/module/utils/getDateOfBirth.js.map +1 -0
  118. package/lib/module/utils/getMostRecentCategorySample.js +12 -0
  119. package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
  120. package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
  121. package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
  122. package/lib/module/utils/getMostRecentWorkout.js +14 -0
  123. package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
  124. package/lib/module/utils/getPreferredUnit.js +9 -0
  125. package/lib/module/utils/getPreferredUnit.js.map +1 -0
  126. package/lib/module/utils/getPreferredUnits.js +9 -0
  127. package/lib/module/utils/getPreferredUnits.js.map +1 -0
  128. package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
  129. package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
  130. package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
  131. package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
  132. package/lib/module/utils/prepareOptions.js +17 -0
  133. package/lib/module/utils/prepareOptions.js.map +1 -0
  134. package/lib/module/utils/queryCategorySamples.js +12 -0
  135. package/lib/module/utils/queryCategorySamples.js.map +1 -0
  136. package/lib/module/utils/queryCorrelationSamples.js +12 -0
  137. package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
  138. package/lib/module/utils/queryQuantitySamples.js +14 -0
  139. package/lib/module/utils/queryQuantitySamples.js.map +1 -0
  140. package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
  141. package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
  142. package/lib/module/utils/queryWorkouts.js +17 -0
  143. package/lib/module/utils/queryWorkouts.js.map +1 -0
  144. package/lib/module/utils/requestAuthorization.js +15 -0
  145. package/lib/module/utils/requestAuthorization.js.map +1 -0
  146. package/lib/module/utils/saveCategorySample.js +11 -0
  147. package/lib/module/utils/saveCategorySample.js.map +1 -0
  148. package/lib/module/utils/saveCorrelationSample.js +13 -0
  149. package/lib/module/utils/saveCorrelationSample.js.map +1 -0
  150. package/lib/module/utils/saveQuantitySample.js +11 -0
  151. package/lib/module/utils/saveQuantitySample.js.map +1 -0
  152. package/lib/module/utils/saveWorkoutSample.js +14 -0
  153. package/lib/module/utils/saveWorkoutSample.js.map +1 -0
  154. package/lib/module/utils/serializeDate.js +4 -0
  155. package/lib/module/utils/serializeDate.js.map +1 -0
  156. package/lib/module/utils/subscribeToChanges.js +25 -0
  157. package/lib/module/utils/subscribeToChanges.js.map +1 -0
  158. package/lib/typescript/example-expo/App.d.ts +2 -0
  159. package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
  160. package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
  161. package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
  162. package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
  163. package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
  164. package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
  165. package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
  166. package/lib/typescript/src/index.d.ts +2 -3
  167. package/lib/typescript/src/index.ios.d.ts +48 -3
  168. package/lib/typescript/src/native-types.d.ts +235 -70
  169. package/lib/typescript/src/types.d.ts +14 -90
  170. package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
  171. package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
  172. package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
  173. package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
  174. package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
  175. package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
  176. package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
  177. package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
  178. package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
  179. package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
  180. package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
  181. package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
  182. package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
  183. package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
  184. package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
  185. package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
  186. package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
  187. package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
  188. package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
  189. package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
  190. package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
  191. package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
  192. package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
  193. package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
  194. package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
  195. package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
  196. package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
  197. package/package.json +17 -6
  198. package/src/hooks/useHealthkitAuthorization.ts +39 -0
  199. package/src/hooks/useIsHealthDataAvailable.ts +17 -0
  200. package/src/hooks/useMostRecentCategorySample.ts +24 -0
  201. package/src/hooks/useMostRecentQuantitySample.ts +39 -0
  202. package/src/hooks/useMostRecentWorkout.ts +60 -0
  203. package/src/hooks/useStatisticsForQuantity.ts +42 -0
  204. package/src/hooks/useSubscribeToChanges.ts +31 -0
  205. package/src/index.ios.tsx +36 -569
  206. package/src/index.tsx +12 -9
  207. package/src/native-types.ts +323 -93
  208. package/src/types.ts +41 -152
  209. package/src/utils/deserializeCategorySample.ts +12 -0
  210. package/src/utils/deserializeCorrelation.ts +28 -0
  211. package/src/utils/deserializeSample.ts +17 -0
  212. package/src/utils/deserializeWorkout.ts +14 -0
  213. package/src/utils/ensureMetadata.ts +5 -0
  214. package/src/utils/ensureUnit.ts +19 -0
  215. package/src/utils/getDateOfBirth.ts +8 -0
  216. package/src/utils/getMostRecentCategorySample.ts +18 -0
  217. package/src/utils/getMostRecentQuantitySample.ts +19 -0
  218. package/src/utils/getMostRecentWorkout.ts +27 -0
  219. package/src/utils/getPreferredUnit.ts +14 -0
  220. package/src/utils/getPreferredUnits.ts +14 -0
  221. package/src/utils/getPreferredUnitsTyped.ts +38 -0
  222. package/src/utils/getRequestStatusForAuthorization.ts +21 -0
  223. package/src/utils/prepareOptions.ts +15 -0
  224. package/src/utils/queryCategorySamples.ts +29 -0
  225. package/src/utils/queryCorrelationSamples.ts +29 -0
  226. package/src/utils/queryQuantitySamples.ts +36 -0
  227. package/src/utils/queryStatisticsForQuantity.ts +38 -0
  228. package/src/utils/queryWorkouts.ts +28 -0
  229. package/src/utils/requestAuthorization.ts +18 -0
  230. package/src/utils/saveCategorySample.ts +27 -0
  231. package/src/utils/saveCorrelationSample.ts +34 -0
  232. package/src/utils/saveQuantitySample.ts +29 -0
  233. package/src/utils/saveWorkoutSample.ts +28 -0
  234. package/src/utils/serializeDate.ts +3 -0
  235. package/src/utils/subscribeToChanges.ts +32 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["serializeDate","prepareOptions","options","limit","Infinity","ascending","from","to"],"sources":["prepareOptions.ts"],"sourcesContent":["import serializeDate from './serializeDate'\n\nimport type { GenericQueryOptions } from '../types'\n\nconst prepareOptions = (options: GenericQueryOptions) => {\n const limit = !options.limit || options.limit === Infinity ? 0 : options.limit\n const ascending = options.ascending ?? limit === 0\n const from = serializeDate(options.from)\n const to = serializeDate(options.to)\n return {\n limit, ascending, from, to,\n }\n}\n\nexport default prepareOptions\n"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;;AAIA,MAAMC,cAAc,GAAIC,OAAD,IAAkC;EACvD,MAAMC,KAAK,GAAG,CAACD,OAAO,CAACC,KAAT,IAAkBD,OAAO,CAACC,KAAR,KAAkBC,QAApC,GAA+C,CAA/C,GAAmDF,OAAO,CAACC,KAAzE;EACA,MAAME,SAAS,GAAGH,OAAO,CAACG,SAAR,IAAqBF,KAAK,KAAK,CAAjD;EACA,MAAMG,IAAI,GAAGN,aAAa,CAACE,OAAO,CAACI,IAAT,CAA1B;EACA,MAAMC,EAAE,GAAGP,aAAa,CAACE,OAAO,CAACK,EAAT,CAAxB;EACA,OAAO;IACLJ,KADK;IACEE,SADF;IACaC,IADb;IACmBC;EADnB,CAAP;AAGD,CARD;;AAUA,eAAeN,cAAf"}
@@ -0,0 +1,12 @@
1
+ import Native from '../native-types';
2
+ import deserializCategorySample from './deserializeCategorySample';
3
+ import prepareOptions from './prepareOptions';
4
+
5
+ const queryCategorySamples = async (identifier, options) => {
6
+ const opts = prepareOptions(options);
7
+ const results = await Native.queryCategorySamples(identifier, opts.from, opts.to, opts.limit, opts.ascending);
8
+ return results.map(deserializCategorySample);
9
+ };
10
+
11
+ export default queryCategorySamples;
12
+ //# sourceMappingURL=queryCategorySamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","deserializCategorySample","prepareOptions","queryCategorySamples","identifier","options","opts","results","from","to","limit","ascending","map"],"sources":["queryCategorySamples.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializCategorySample from './deserializeCategorySample'\nimport prepareOptions from './prepareOptions'\n\nimport type { HKCategoryTypeIdentifier } from '../native-types'\nimport type { GenericQueryOptions, HKCategorySample } from '../types'\n\nexport type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(\n identifier: T,\n options: GenericQueryOptions\n) => Promise<readonly HKCategorySample<T>[]>;\n\nconst queryCategorySamples: QueryCategorySamplesFn = async (\n identifier,\n options,\n) => {\n const opts = prepareOptions(options)\n const results = await Native.queryCategorySamples(\n identifier,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return results.map(deserializCategorySample)\n}\n\nexport default queryCategorySamples\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,wBAAP,MAAqC,6BAArC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAUA,MAAMC,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAGJ,cAAc,CAACG,OAAD,CAA3B;EACA,MAAME,OAAO,GAAG,MAAMP,MAAM,CAACG,oBAAP,CACpBC,UADoB,EAEpBE,IAAI,CAACE,IAFe,EAGpBF,IAAI,CAACG,EAHe,EAIpBH,IAAI,CAACI,KAJe,EAKpBJ,IAAI,CAACK,SALe,CAAtB;EAQA,OAAOJ,OAAO,CAACK,GAAR,CAAYX,wBAAZ,CAAP;AACD,CAdD;;AAgBA,eAAeE,oBAAf"}
@@ -0,0 +1,12 @@
1
+ import Native from '../native-types';
2
+ import deserializeCorrelation from './deserializeCorrelation';
3
+ import prepareOptions from './prepareOptions';
4
+
5
+ const queryCorrelationSamples = async (typeIdentifier, options) => {
6
+ const opts = prepareOptions(options);
7
+ const correlations = await Native.queryCorrelationSamples(typeIdentifier, opts.from, opts.to);
8
+ return correlations.map(deserializeCorrelation);
9
+ };
10
+
11
+ export default queryCorrelationSamples;
12
+ //# sourceMappingURL=queryCorrelationSamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","deserializeCorrelation","prepareOptions","queryCorrelationSamples","typeIdentifier","options","opts","correlations","from","to","map"],"sources":["queryCorrelationSamples.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializeCorrelation from './deserializeCorrelation'\nimport prepareOptions from './prepareOptions'\n\nimport type { HKCorrelationTypeIdentifier } from '../native-types'\nimport type { GenericQueryOptions, HKCorrelation } from '../types'\n\nexport type QueryCorrelationSamplesFn = <\n TIdentifier extends HKCorrelationTypeIdentifier\n>(\n typeIdentifier: TIdentifier,\n options: Omit<GenericQueryOptions, 'ascending' | 'limit'>\n) => Promise<readonly HKCorrelation<TIdentifier>[]>;\n\nconst queryCorrelationSamples: QueryCorrelationSamplesFn = async (\n typeIdentifier,\n options,\n) => {\n const opts = prepareOptions(options)\n const correlations = await Native.queryCorrelationSamples(\n typeIdentifier,\n opts.from,\n opts.to,\n )\n\n return correlations.map(deserializeCorrelation)\n}\n\nexport default queryCorrelationSamples\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAYA,MAAMC,uBAAkD,GAAG,OACzDC,cADyD,EAEzDC,OAFyD,KAGtD;EACH,MAAMC,IAAI,GAAGJ,cAAc,CAACG,OAAD,CAA3B;EACA,MAAME,YAAY,GAAG,MAAMP,MAAM,CAACG,uBAAP,CACzBC,cADyB,EAEzBE,IAAI,CAACE,IAFoB,EAGzBF,IAAI,CAACG,EAHoB,CAA3B;EAMA,OAAOF,YAAY,CAACG,GAAb,CAAiBT,sBAAjB,CAAP;AACD,CAZD;;AAcA,eAAeE,uBAAf"}
@@ -0,0 +1,14 @@
1
+ import Native from '../native-types';
2
+ import deserializeSample from './deserializeSample';
3
+ import ensureUnit from './ensureUnit';
4
+ import prepareOptions from './prepareOptions';
5
+
6
+ const queryQuantitySamples = async (identifier, options) => {
7
+ const unit = await ensureUnit(identifier, options.unit);
8
+ const opts = prepareOptions(options);
9
+ const quantitySamples = await Native.queryQuantitySamples(identifier, unit, opts.from, opts.to, opts.limit, opts.ascending);
10
+ return quantitySamples.map(deserializeSample);
11
+ };
12
+
13
+ export default queryQuantitySamples;
14
+ //# sourceMappingURL=queryQuantitySamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","deserializeSample","ensureUnit","prepareOptions","queryQuantitySamples","identifier","options","unit","opts","quantitySamples","from","to","limit","ascending","map"],"sources":["queryQuantitySamples.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializeSample from './deserializeSample'\nimport ensureUnit from './ensureUnit'\nimport prepareOptions from './prepareOptions'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\nimport type { GenericQueryOptions, HKQuantitySample } from '../types'\n\nexport type QueryQuantitySamplesFn = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n options: GenericQueryOptions & { readonly unit?: TUnit }\n) => Promise<readonly HKQuantitySample<TIdentifier>[]>;\n\nconst queryQuantitySamples: QueryQuantitySamplesFn = async (\n identifier,\n options,\n) => {\n const unit = await ensureUnit(identifier, options.unit)\n const opts = prepareOptions(options)\n\n const quantitySamples = await Native.queryQuantitySamples(\n identifier,\n unit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return quantitySamples.map(deserializeSample)\n}\n\nexport default queryQuantitySamples\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAaA,MAAMC,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAG,MAAML,UAAU,CAACG,UAAD,EAAaC,OAAO,CAACC,IAArB,CAA7B;EACA,MAAMC,IAAI,GAAGL,cAAc,CAACG,OAAD,CAA3B;EAEA,MAAMG,eAAe,GAAG,MAAMT,MAAM,CAACI,oBAAP,CAC5BC,UAD4B,EAE5BE,IAF4B,EAG5BC,IAAI,CAACE,IAHuB,EAI5BF,IAAI,CAACG,EAJuB,EAK5BH,IAAI,CAACI,KALuB,EAM5BJ,IAAI,CAACK,SANuB,CAA9B;EASA,OAAOJ,eAAe,CAACK,GAAhB,CAAoBb,iBAApB,CAAP;AACD,CAjBD;;AAmBA,eAAeG,oBAAf"}
@@ -0,0 +1,23 @@
1
+ import Native from '../native-types';
2
+ import ensureUnit from './ensureUnit';
3
+
4
+ async function queryStatisticsForQuantity(identifier, options, from, to, unit) {
5
+ const actualUnit = await ensureUnit(identifier, unit);
6
+ const toDate = to || new Date();
7
+ const {
8
+ mostRecentQuantityDateInterval,
9
+ ...rawResponse
10
+ } = await Native.queryStatisticsForQuantity(identifier, actualUnit, from.toISOString(), toDate.toISOString(), options);
11
+ const response = { ...rawResponse,
12
+ ...(mostRecentQuantityDateInterval ? {
13
+ mostRecentQuantityDateInterval: {
14
+ from: new Date(mostRecentQuantityDateInterval.from),
15
+ to: new Date(mostRecentQuantityDateInterval.to)
16
+ }
17
+ } : {})
18
+ };
19
+ return response;
20
+ }
21
+
22
+ export default queryStatisticsForQuantity;
23
+ //# sourceMappingURL=queryStatisticsForQuantity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","ensureUnit","queryStatisticsForQuantity","identifier","options","from","to","unit","actualUnit","toDate","Date","mostRecentQuantityDateInterval","rawResponse","toISOString","response"],"sources":["queryStatisticsForQuantity.ts"],"sourcesContent":["import Native from '../native-types'\nimport ensureUnit from './ensureUnit'\n\nimport type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types'\n\nasync function queryStatisticsForQuantity<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>(\n identifier: TIdentifier,\n options: readonly HKStatisticsOptions[],\n from: Date,\n to?: Date,\n unit?: TUnit,\n) {\n const actualUnit = await ensureUnit(identifier, unit)\n const toDate = to || new Date()\n const { mostRecentQuantityDateInterval, ...rawResponse } = await Native.queryStatisticsForQuantity(\n identifier,\n actualUnit,\n from.toISOString(),\n toDate.toISOString(),\n options,\n )\n\n const response = {\n ...rawResponse,\n ...(mostRecentQuantityDateInterval\n ? {\n mostRecentQuantityDateInterval: {\n from: new Date(mostRecentQuantityDateInterval.from),\n to: new Date(mostRecentQuantityDateInterval.to),\n },\n }\n : {}),\n }\n\n return response\n}\n\nexport default queryStatisticsForQuantity\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,UAAP,MAAuB,cAAvB;;AAIA,eAAeC,0BAAf,CACEC,UADF,EAEEC,OAFF,EAGEC,IAHF,EAIEC,EAJF,EAKEC,IALF,EAME;EACA,MAAMC,UAAU,GAAG,MAAMP,UAAU,CAACE,UAAD,EAAaI,IAAb,CAAnC;EACA,MAAME,MAAM,GAAGH,EAAE,IAAI,IAAII,IAAJ,EAArB;EACA,MAAM;IAAEC,8BAAF;IAAkC,GAAGC;EAArC,IAAqD,MAAMZ,MAAM,CAACE,0BAAP,CAC/DC,UAD+D,EAE/DK,UAF+D,EAG/DH,IAAI,CAACQ,WAAL,EAH+D,EAI/DJ,MAAM,CAACI,WAAP,EAJ+D,EAK/DT,OAL+D,CAAjE;EAQA,MAAMU,QAAQ,GAAG,EACf,GAAGF,WADY;IAEf,IAAID,8BAA8B,GAC9B;MACAA,8BAA8B,EAAE;QAC9BN,IAAI,EAAE,IAAIK,IAAJ,CAASC,8BAA8B,CAACN,IAAxC,CADwB;QAE9BC,EAAE,EAAE,IAAII,IAAJ,CAASC,8BAA8B,CAACL,EAAxC;MAF0B;IADhC,CAD8B,GAO9B,EAPJ;EAFe,CAAjB;EAYA,OAAOQ,QAAP;AACD;;AAED,eAAeZ,0BAAf"}
@@ -0,0 +1,17 @@
1
+ import Native from '../native-types';
2
+ import deserializeWorkout from './deserializeWorkout';
3
+ import getPreferredUnitsTyped from './getPreferredUnitsTyped';
4
+ import prepareOptions from './prepareOptions';
5
+
6
+ async function queryWorkouts(options) {
7
+ const {
8
+ energyUnit,
9
+ distanceUnit
10
+ } = await getPreferredUnitsTyped(options);
11
+ const opts = prepareOptions(options);
12
+ const workouts = await Native.queryWorkoutSamples(energyUnit, distanceUnit, opts.from, opts.to, opts.limit, opts.ascending);
13
+ return workouts.map(deserializeWorkout);
14
+ }
15
+
16
+ export default queryWorkouts;
17
+ //# sourceMappingURL=queryWorkouts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","deserializeWorkout","getPreferredUnitsTyped","prepareOptions","queryWorkouts","options","energyUnit","distanceUnit","opts","workouts","queryWorkoutSamples","from","to","limit","ascending","map"],"sources":["queryWorkouts.ts"],"sourcesContent":["import Native from '../native-types'\nimport deserializeWorkout from './deserializeWorkout'\nimport getPreferredUnitsTyped from './getPreferredUnitsTyped'\nimport prepareOptions from './prepareOptions'\n\nimport type { EnergyUnit, LengthUnit } from '../native-types'\nimport type { QueryWorkoutsOptions } from '../types'\n\nasync function queryWorkouts<\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(options: QueryWorkoutsOptions<TEnergy, TDistance>) {\n const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)\n const opts = prepareOptions(options)\n\n const workouts = await Native.queryWorkoutSamples(\n energyUnit,\n distanceUnit,\n opts.from,\n opts.to,\n opts.limit,\n opts.ascending,\n )\n\n return workouts.map(deserializeWorkout)\n}\n\nexport default queryWorkouts\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,kBAAP,MAA+B,sBAA/B;AACA,OAAOC,sBAAP,MAAmC,0BAAnC;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAKA,eAAeC,aAAf,CAGEC,OAHF,EAGqD;EACnD,MAAM;IAAEC,UAAF;IAAcC;EAAd,IAA+B,MAAML,sBAAsB,CAACG,OAAD,CAAjE;EACA,MAAMG,IAAI,GAAGL,cAAc,CAACE,OAAD,CAA3B;EAEA,MAAMI,QAAQ,GAAG,MAAMT,MAAM,CAACU,mBAAP,CACrBJ,UADqB,EAErBC,YAFqB,EAGrBC,IAAI,CAACG,IAHgB,EAIrBH,IAAI,CAACI,EAJgB,EAKrBJ,IAAI,CAACK,KALgB,EAMrBL,IAAI,CAACM,SANgB,CAAvB;EASA,OAAOL,QAAQ,CAACM,GAAT,CAAad,kBAAb,CAAP;AACD;;AAED,eAAeG,aAAf"}
@@ -0,0 +1,15 @@
1
+ import Native from '../native-types';
2
+
3
+ const requestAuthorization = async function (read) {
4
+ let write = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
5
+ const readPermissions = read.reduce((obj, cur) => ({ ...obj,
6
+ [cur]: true
7
+ }), {});
8
+ const writePermissions = write.reduce((obj, cur) => ({ ...obj,
9
+ [cur]: true
10
+ }), {});
11
+ return Native.requestAuthorization(writePermissions, readPermissions);
12
+ };
13
+
14
+ export default requestAuthorization;
15
+ //# sourceMappingURL=requestAuthorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","requestAuthorization","read","write","readPermissions","reduce","obj","cur","writePermissions"],"sources":["requestAuthorization.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type {\n HealthkitReadAuthorization, HealthkitWriteAuthorization, ReadPermissions, WritePermissions,\n} from '../native-types'\n\nconst requestAuthorization = async (\n read: readonly HealthkitReadAuthorization[],\n write: readonly HealthkitWriteAuthorization[] = [],\n): Promise<boolean> => {\n const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)\n\n const writePermissions = write.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as WritePermissions)\n\n return Native.requestAuthorization(writePermissions, readPermissions)\n}\n\nexport default requestAuthorization\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;;AAMA,MAAMC,oBAAoB,GAAG,gBAC3BC,IAD2B,EAGN;EAAA,IADrBC,KACqB,uEAD2B,EAC3B;EACrB,MAAMC,eAAe,GAAGF,IAAI,CAACG,MAAL,CAAY,CAACC,GAAD,EAAMC,GAAN,MAAe,EAAE,GAAGD,GAAL;IAAU,CAACC,GAAD,GAAO;EAAjB,CAAf,CAAZ,EAAqD,EAArD,CAAxB;EAEA,MAAMC,gBAAgB,GAAGL,KAAK,CAACE,MAAN,CAAa,CAACC,GAAD,EAAMC,GAAN,MAAe,EAAE,GAAGD,GAAL;IAAU,CAACC,GAAD,GAAO;EAAjB,CAAf,CAAb,EAAsD,EAAtD,CAAzB;EAEA,OAAOP,MAAM,CAACC,oBAAP,CAA4BO,gBAA5B,EAA8CJ,eAA9C,CAAP;AACD,CATD;;AAWA,eAAeH,oBAAf"}
@@ -0,0 +1,11 @@
1
+ import Native from '../native-types';
2
+
3
+ async function saveCategorySample(identifier, value, options) {
4
+ const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
5
+ const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
6
+ const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
7
+ return Native.saveCategorySample(identifier, value, start.toISOString(), end.toISOString(), metadata || {});
8
+ }
9
+
10
+ export default saveCategorySample;
11
+ //# sourceMappingURL=saveCategorySample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","saveCategorySample","identifier","value","options","start","end","Date","metadata","toISOString"],"sources":["saveCategorySample.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, MetadataMapperForCategoryIdentifier } from '../native-types'\n\nasync function saveCategorySample<T extends HKCategoryTypeIdentifier>(\n identifier: T,\n value: HKCategoryValueForIdentifier<T>,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCategoryIdentifier<T>;\n },\n) {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveCategorySample(\n identifier,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata || {},\n )\n}\n\nexport default saveCategorySample\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;;AAIA,eAAeC,kBAAf,CACEC,UADF,EAEEC,KAFF,EAGEC,OAHF,EAQE;EACA,MAAMC,KAAK,GAAG,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,KAAT,MAAkBD,OAAlB,aAAkBA,OAAlB,uBAAkBA,OAAO,CAAEE,GAA3B,KAAkC,IAAIC,IAAJ,EAAhD;EACA,MAAMD,GAAG,GAAG,CAAAF,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,GAAT,MAAgBF,OAAhB,aAAgBA,OAAhB,uBAAgBA,OAAO,CAAEC,KAAzB,KAAkC,IAAIE,IAAJ,EAA9C;EACA,MAAMC,QAAQ,GAAG,CAAAJ,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEI,QAAT,KAAqB,EAAtC;EAEA,OAAOR,MAAM,CAACC,kBAAP,CACLC,UADK,EAELC,KAFK,EAGLE,KAAK,CAACI,WAAN,EAHK,EAILH,GAAG,CAACG,WAAJ,EAJK,EAKLD,QAAQ,IAAI,EALP,CAAP;AAOD;;AAED,eAAeP,kBAAf"}
@@ -0,0 +1,13 @@
1
+ import Native from '../native-types';
2
+ import ensureMetadata from './ensureMetadata';
3
+
4
+ async function saveCorrelationSample(typeIdentifier, samples, options) {
5
+ const start = ((options === null || options === void 0 ? void 0 : options.start) || new Date()).toISOString();
6
+ const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
7
+ return Native.saveCorrelationSample(typeIdentifier, samples.map(s => ({ ...s,
8
+ metadata: ensureMetadata(s.metadata)
9
+ })), start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
10
+ }
11
+
12
+ export default saveCorrelationSample;
13
+ //# sourceMappingURL=saveCorrelationSample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","ensureMetadata","saveCorrelationSample","typeIdentifier","samples","options","start","Date","toISOString","end","map","s","metadata"],"sources":["saveCorrelationSample.ts"],"sourcesContent":["import Native from '../native-types'\nimport ensureMetadata from './ensureMetadata'\n\nimport type { MetadataMapperForCorrelationIdentifier, HKCorrelationTypeIdentifier } from '../native-types'\nimport type { HKCategorySampleForSaving, HKQuantitySampleForSaving } from '../types'\n\nasync function saveCorrelationSample<\n TIdentifier extends HKCorrelationTypeIdentifier,\n TSamples extends readonly(\n | HKCategorySampleForSaving\n | HKQuantitySampleForSaving\n )[]\n>(\n typeIdentifier: TIdentifier,\n samples: TSamples,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;\n },\n) {\n const start = (options?.start || new Date()).toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveCorrelationSample(\n typeIdentifier,\n samples.map((s) => ({ ...s, metadata: ensureMetadata(s.metadata) })),\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveCorrelationSample\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAKA,eAAeC,qBAAf,CAOEC,cAPF,EAQEC,OARF,EASEC,OATF,EAcE;EACA,MAAMC,KAAK,GAAG,CAAC,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,KAAT,KAAkB,IAAIC,IAAJ,EAAnB,EAA+BC,WAA/B,EAAd;EACA,MAAMC,GAAG,GAAG,CAAC,CAAAJ,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEI,GAAT,KAAgB,IAAIF,IAAJ,EAAjB,EAA6BC,WAA7B,EAAZ;EAEA,OAAOR,MAAM,CAACE,qBAAP,CACLC,cADK,EAELC,OAAO,CAACM,GAAR,CAAaC,CAAD,KAAQ,EAAE,GAAGA,CAAL;IAAQC,QAAQ,EAAEX,cAAc,CAACU,CAAC,CAACC,QAAH;EAAhC,CAAR,CAAZ,CAFK,EAGLN,KAHK,EAILG,GAJK,EAKLR,cAAc,CAACI,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEO,QAAV,CALT,CAAP;AAOD;;AAED,eAAeV,qBAAf"}
@@ -0,0 +1,11 @@
1
+ import Native from '../native-types';
2
+
3
+ async function saveQuantitySample(identifier, unit, value, options) {
4
+ const start = (options === null || options === void 0 ? void 0 : options.start) || (options === null || options === void 0 ? void 0 : options.end) || new Date();
5
+ const end = (options === null || options === void 0 ? void 0 : options.end) || (options === null || options === void 0 ? void 0 : options.start) || new Date();
6
+ const metadata = (options === null || options === void 0 ? void 0 : options.metadata) || {};
7
+ return Native.saveQuantitySample(identifier, unit, value, start.toISOString(), end.toISOString(), metadata);
8
+ }
9
+
10
+ export default saveQuantitySample;
11
+ //# sourceMappingURL=saveQuantitySample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","saveQuantitySample","identifier","unit","value","options","start","end","Date","metadata","toISOString"],"sources":["saveQuantitySample.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { MetadataMapperForQuantityIdentifier, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nasync function saveQuantitySample<TType extends HKQuantityTypeIdentifier>(\n identifier: TType,\n unit: UnitForIdentifier<TType>,\n value: number,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForQuantityIdentifier<TType>;\n },\n) {\n const start = options?.start || options?.end || new Date()\n const end = options?.end || options?.start || new Date()\n const metadata = options?.metadata || {}\n\n return Native.saveQuantitySample(\n identifier,\n unit,\n value,\n start.toISOString(),\n end.toISOString(),\n metadata,\n )\n}\n\nexport default saveQuantitySample\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;;AAIA,eAAeC,kBAAf,CACEC,UADF,EAEEC,IAFF,EAGEC,KAHF,EAIEC,OAJF,EASE;EACA,MAAMC,KAAK,GAAG,CAAAD,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEC,KAAT,MAAkBD,OAAlB,aAAkBA,OAAlB,uBAAkBA,OAAO,CAAEE,GAA3B,KAAkC,IAAIC,IAAJ,EAAhD;EACA,MAAMD,GAAG,GAAG,CAAAF,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEE,GAAT,MAAgBF,OAAhB,aAAgBA,OAAhB,uBAAgBA,OAAO,CAAEC,KAAzB,KAAkC,IAAIE,IAAJ,EAA9C;EACA,MAAMC,QAAQ,GAAG,CAAAJ,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEI,QAAT,KAAqB,EAAtC;EAEA,OAAOT,MAAM,CAACC,kBAAP,CACLC,UADK,EAELC,IAFK,EAGLC,KAHK,EAILE,KAAK,CAACI,WAAN,EAJK,EAKLH,GAAG,CAACG,WAAJ,EALK,EAMLD,QANK,CAAP;AAQD;;AAED,eAAeR,kBAAf"}
@@ -0,0 +1,14 @@
1
+ import Native from '../native-types';
2
+ import ensureMetadata from './ensureMetadata';
3
+
4
+ async function saveWorkoutSample(typeIdentifier, quantities, _start, options) {
5
+ const start = _start.toISOString();
6
+
7
+ const end = ((options === null || options === void 0 ? void 0 : options.end) || new Date()).toISOString();
8
+ return Native.saveWorkoutSample(typeIdentifier, quantities.map(s => ({ ...s,
9
+ metadata: ensureMetadata(s.metadata)
10
+ })), start, end, ensureMetadata(options === null || options === void 0 ? void 0 : options.metadata));
11
+ }
12
+
13
+ export default saveWorkoutSample;
14
+ //# sourceMappingURL=saveWorkoutSample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Native","ensureMetadata","saveWorkoutSample","typeIdentifier","quantities","_start","options","start","toISOString","end","Date","map","s","metadata"],"sources":["saveWorkoutSample.ts"],"sourcesContent":["import Native from '../native-types'\nimport ensureMetadata from './ensureMetadata'\n\nimport type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'\nimport type { HKQuantitySampleForSaving } from '../types'\n\nasync function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(\n typeIdentifier: TIdentifier,\n quantities: readonly HKQuantitySampleForSaving[],\n _start: Date,\n options?: {\n readonly end?: Date;\n readonly metadata?: HKWorkoutMetadata;\n },\n) {\n const start = _start.toISOString()\n const end = (options?.end || new Date()).toISOString()\n\n return Native.saveWorkoutSample(\n typeIdentifier,\n quantities.map(((s) => ({ ...s, metadata: ensureMetadata(s.metadata) }))),\n start,\n end,\n ensureMetadata(options?.metadata),\n )\n}\n\nexport default saveWorkoutSample\n"],"mappings":"AAAA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,cAAP,MAA2B,kBAA3B;;AAKA,eAAeC,iBAAf,CACEC,cADF,EAEEC,UAFF,EAGEC,MAHF,EAIEC,OAJF,EAQE;EACA,MAAMC,KAAK,GAAGF,MAAM,CAACG,WAAP,EAAd;;EACA,MAAMC,GAAG,GAAG,CAAC,CAAAH,OAAO,SAAP,IAAAA,OAAO,WAAP,YAAAA,OAAO,CAAEG,GAAT,KAAgB,IAAIC,IAAJ,EAAjB,EAA6BF,WAA7B,EAAZ;EAEA,OAAOR,MAAM,CAACE,iBAAP,CACLC,cADK,EAELC,UAAU,CAACO,GAAX,CAAiBC,CAAD,KAAQ,EAAE,GAAGA,CAAL;IAAQC,QAAQ,EAAEZ,cAAc,CAACW,CAAC,CAACC,QAAH;EAAhC,CAAR,CAAhB,CAFK,EAGLN,KAHK,EAILE,GAJK,EAKLR,cAAc,CAACK,OAAD,aAACA,OAAD,uBAACA,OAAO,CAAEO,QAAV,CALT,CAAP;AAOD;;AAED,eAAeX,iBAAf"}
@@ -0,0 +1,4 @@
1
+ const serializeDate = date => date ? date.toISOString() : new Date(0).toISOString();
2
+
3
+ export default serializeDate;
4
+ //# sourceMappingURL=serializeDate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["serializeDate","date","toISOString","Date"],"sources":["serializeDate.ts"],"sourcesContent":["const serializeDate = (date?: Date | null): string => (date ? date.toISOString() : new Date(0).toISOString())\n\nexport default serializeDate\n"],"mappings":"AAAA,MAAMA,aAAa,GAAIC,IAAD,IAAiCA,IAAI,GAAGA,IAAI,CAACC,WAAL,EAAH,GAAwB,IAAIC,IAAJ,CAAS,CAAT,EAAYD,WAAZ,EAAnF;;AAEA,eAAeF,aAAf"}
@@ -0,0 +1,25 @@
1
+ import { EventEmitter } from '..';
2
+ import Native from '../native-types';
3
+
4
+ const subscribeToChanges = async (identifier, callback) => {
5
+ const subscription = EventEmitter.addListener('onChange', _ref => {
6
+ let {
7
+ typeIdentifier
8
+ } = _ref;
9
+
10
+ if (typeIdentifier === identifier) {
11
+ callback();
12
+ }
13
+ });
14
+ const queryId = await Native.subscribeToObserverQuery(identifier).catch(async error => {
15
+ subscription.remove();
16
+ return Promise.reject(error);
17
+ });
18
+ return async () => {
19
+ subscription.remove();
20
+ return Native.unsubscribeQuery(queryId);
21
+ };
22
+ };
23
+
24
+ export default subscribeToChanges;
25
+ //# sourceMappingURL=subscribeToChanges.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["EventEmitter","Native","subscribeToChanges","identifier","callback","subscription","addListener","typeIdentifier","queryId","subscribeToObserverQuery","catch","error","remove","Promise","reject","unsubscribeQuery"],"sources":["subscribeToChanges.ts"],"sourcesContent":["import { EventEmitter } from '..'\nimport Native from '../native-types'\n\nimport type { HKSampleTypeIdentifier } from '..'\n\nconst subscribeToChanges = async (\n identifier: HKSampleTypeIdentifier,\n callback: () => void,\n) => {\n const subscription = EventEmitter.addListener(\n 'onChange',\n ({ typeIdentifier }) => {\n if (typeIdentifier === identifier) {\n callback()\n }\n },\n )\n\n const queryId = await Native.subscribeToObserverQuery(identifier).catch(\n async (error) => {\n subscription.remove()\n return Promise.reject(error)\n },\n )\n\n return async () => {\n subscription.remove()\n return Native.unsubscribeQuery(queryId)\n }\n}\n\nexport default subscribeToChanges\n"],"mappings":"AAAA,SAASA,YAAT,QAA6B,IAA7B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;;AAIA,MAAMC,kBAAkB,GAAG,OACzBC,UADyB,EAEzBC,QAFyB,KAGtB;EACH,MAAMC,YAAY,GAAGL,YAAY,CAACM,WAAb,CACnB,UADmB,EAEnB,QAAwB;IAAA,IAAvB;MAAEC;IAAF,CAAuB;;IACtB,IAAIA,cAAc,KAAKJ,UAAvB,EAAmC;MACjCC,QAAQ;IACT;EACF,CANkB,CAArB;EASA,MAAMI,OAAO,GAAG,MAAMP,MAAM,CAACQ,wBAAP,CAAgCN,UAAhC,EAA4CO,KAA5C,CACpB,MAAOC,KAAP,IAAiB;IACfN,YAAY,CAACO,MAAb;IACA,OAAOC,OAAO,CAACC,MAAR,CAAeH,KAAf,CAAP;EACD,CAJmB,CAAtB;EAOA,OAAO,YAAY;IACjBN,YAAY,CAACO,MAAb;IACA,OAAOX,MAAM,CAACc,gBAAP,CAAwBP,OAAxB,CAAP;EACD,CAHD;AAID,CAxBD;;AA0BA,eAAeN,kBAAf"}
@@ -0,0 +1,2 @@
1
+ import App from '../example/src/App';
2
+ export default App;
@@ -0,0 +1,3 @@
1
+ import type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus } from '../native-types';
2
+ declare const useHealthkitAuthorization: (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => readonly [HKAuthorizationRequestStatus | null, () => Promise<HKAuthorizationRequestStatus>];
3
+ export default useHealthkitAuthorization;
@@ -0,0 +1,2 @@
1
+ declare const useIsHealthDataAvailable: () => boolean | null;
2
+ export default useIsHealthDataAvailable;
@@ -0,0 +1,4 @@
1
+ import type { HKCategoryTypeIdentifier } from '../native-types';
2
+ import type { HKCategorySample } from '../types';
3
+ declare function useMostRecentCategorySample<TCategory extends HKCategoryTypeIdentifier>(identifier: TCategory): HKCategorySample<TCategory> | null;
4
+ export default useMostRecentCategorySample;
@@ -0,0 +1,4 @@
1
+ import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
2
+ import type { HKQuantitySample } from '../types';
3
+ declare function useMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit?: TUnit): HKQuantitySample<TIdentifier, UnitForIdentifier<TIdentifier>> | null;
4
+ export default useMostRecentQuantitySample;
@@ -0,0 +1,7 @@
1
+ import type { EnergyUnit, LengthUnit } from '../native-types';
2
+ import type { HKWorkout } from '../types';
3
+ declare function useMostRecentWorkout<TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options?: {
4
+ readonly energyUnit?: TEnergy;
5
+ readonly distanceUnit?: TDistance;
6
+ }): HKWorkout<TEnergy, TDistance> | null;
7
+ export default useMostRecentWorkout;
@@ -0,0 +1,4 @@
1
+ import type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types';
2
+ import type { QueryStatisticsResponse } from '../types';
3
+ declare function useStatisticsForQuantity<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: readonly HKStatisticsOptions[], from: Date, to?: Date, unit?: TUnit): QueryStatisticsResponse<TIdentifier, TUnit> | null;
4
+ export default useStatisticsForQuantity;
@@ -0,0 +1,3 @@
1
+ import type { HKSampleTypeIdentifier } from '..';
2
+ declare function useSubscribeToChanges<TIdentifier extends HKSampleTypeIdentifier>(identifier: TIdentifier, onChange: () => void): void;
3
+ export default useSubscribeToChanges;
@@ -1,5 +1,4 @@
1
- import type { ReactNativeHealthkit } from './types';
2
- declare const Healthkit: ReactNativeHealthkit;
3
- export * from './native-types';
1
+ import type ReactNativeHealthkit from './index.ios';
2
+ declare const Healthkit: typeof ReactNativeHealthkit;
4
3
  export * from './types';
5
4
  export default Healthkit;
@@ -1,5 +1,50 @@
1
- import type { ReactNativeHealthkit } from './types';
2
- declare const Healthkit: ReactNativeHealthkit;
3
- export * from './native-types';
1
+ import useMostRecentCategorySample from './hooks/useMostRecentCategorySample';
2
+ import useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample';
3
+ import useMostRecentWorkout from './hooks/useMostRecentWorkout';
4
+ import useSubscribeToChanges from './hooks/useSubscribeToChanges';
5
+ import getMostRecentCategorySample from './utils/getMostRecentCategorySample';
6
+ import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample';
7
+ import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
8
+ import queryWorkouts from './utils/queryWorkouts';
9
+ import saveCategorySample from './utils/saveCategorySample';
10
+ import saveCorrelationSample from './utils/saveCorrelationSample';
11
+ import saveQuantitySample from './utils/saveQuantitySample';
12
+ import saveWorkoutSample from './utils/saveWorkoutSample';
13
+ declare const Healthkit: {
14
+ authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<boolean>;
15
+ isHealthDataAvailable: () => Promise<boolean>;
16
+ disableAllBackgroundDelivery: () => Promise<boolean>;
17
+ disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
18
+ enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
19
+ getBiologicalSex: () => Promise<import("./native-types").HKBiologicalSex>;
20
+ getFitzpatrickSkinType: () => Promise<import("./native-types").HKFitzpatrickSkinType>;
21
+ getWheelchairUse: () => Promise<import("./native-types").HKWheelchairUse>;
22
+ getBloodType: () => Promise<import("./native-types").HKBloodType>;
23
+ getWorkoutRoutes: (workoutUUID: string) => Promise<readonly import("./native-types").WorkoutRoute[]>;
24
+ getDateOfBirth: () => Promise<Date>;
25
+ getMostRecentQuantitySample: typeof getMostRecentQuantitySample;
26
+ getMostRecentCategorySample: typeof getMostRecentCategorySample;
27
+ getMostRecentWorkout: import("./utils/getMostRecentWorkout").GetMostRecentWorkoutFn;
28
+ getPreferredUnit: import("./utils/getPreferredUnit").GetPreferredUnitFn;
29
+ getPreferredUnits: import("./utils/getPreferredUnits").GetPreferredUnitsFn;
30
+ getRequestStatusForAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<import("./native-types").HKAuthorizationRequestStatus>;
31
+ queryCategorySamples: import("./utils/queryCategorySamples").QueryCategorySamplesFn;
32
+ queryCorrelationSamples: import("./utils/queryCorrelationSamples").QueryCorrelationSamplesFn;
33
+ queryQuantitySamples: import("./utils/queryQuantitySamples").QueryQuantitySamplesFn;
34
+ queryStatisticsForQuantity: typeof queryStatisticsForQuantity;
35
+ queryWorkouts: typeof queryWorkouts;
36
+ requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
37
+ saveCategorySample: typeof saveCategorySample;
38
+ saveCorrelationSample: typeof saveCorrelationSample;
39
+ saveQuantitySample: typeof saveQuantitySample;
40
+ saveWorkoutSample: typeof saveWorkoutSample;
41
+ subscribeToChanges: (identifier: import("./native-types").HKSampleTypeIdentifier, callback: () => void) => Promise<() => Promise<boolean>>;
42
+ useMostRecentCategorySample: typeof useMostRecentCategorySample;
43
+ useMostRecentQuantitySample: typeof useMostRecentQuantitySample;
44
+ useMostRecentWorkout: typeof useMostRecentWorkout;
45
+ useSubscribeToChanges: typeof useSubscribeToChanges;
46
+ useIsHealthDataAvailable: () => boolean | null;
47
+ useHealthkitAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[] | undefined) => readonly [import("./native-types").HKAuthorizationRequestStatus | null, () => Promise<import("./native-types").HKAuthorizationRequestStatus>];
48
+ };
4
49
  export * from './types';
5
50
  export default Healthkit;