@kingstinct/react-native-healthkit 4.4.6 → 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 (231) hide show
  1. package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  2. package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
  3. package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
  4. package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
  5. package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
  6. package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
  7. package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
  8. package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
  9. package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
  10. package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
  11. package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
  12. package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
  13. package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
  14. package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
  15. package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
  16. package/lib/commonjs/index.ios.js +66 -394
  17. package/lib/commonjs/index.ios.js.map +1 -1
  18. package/lib/commonjs/index.js +2 -15
  19. package/lib/commonjs/index.js.map +1 -1
  20. package/lib/commonjs/native-types.js +170 -78
  21. package/lib/commonjs/native-types.js.map +1 -1
  22. package/lib/commonjs/types.js +13 -0
  23. package/lib/commonjs/types.js.map +1 -1
  24. package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
  25. package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
  26. package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
  27. package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
  28. package/lib/commonjs/utils/deserializeSample.js +17 -0
  29. package/lib/commonjs/utils/deserializeSample.js.map +1 -0
  30. package/lib/commonjs/utils/deserializeWorkout.js +17 -0
  31. package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
  32. package/lib/commonjs/utils/ensureMetadata.js +14 -0
  33. package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
  34. package/lib/commonjs/utils/ensureUnit.js +23 -0
  35. package/lib/commonjs/utils/ensureUnit.js.map +1 -0
  36. package/lib/commonjs/utils/getDateOfBirth.js +19 -0
  37. package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
  38. package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
  39. package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
  40. package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
  41. package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
  42. package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
  43. package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
  44. package/lib/commonjs/utils/getPreferredUnit.js +19 -0
  45. package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
  46. package/lib/commonjs/utils/getPreferredUnits.js +19 -0
  47. package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
  48. package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
  49. package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
  50. package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
  51. package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
  52. package/lib/commonjs/utils/prepareOptions.js +27 -0
  53. package/lib/commonjs/utils/prepareOptions.js.map +1 -0
  54. package/lib/commonjs/utils/queryCategorySamples.js +24 -0
  55. package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
  56. package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
  57. package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
  58. package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
  59. package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
  60. package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
  61. package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
  62. package/lib/commonjs/utils/queryWorkouts.js +30 -0
  63. package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
  64. package/lib/commonjs/utils/requestAuthorization.js +25 -0
  65. package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
  66. package/lib/commonjs/utils/saveCategorySample.js +21 -0
  67. package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
  68. package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
  69. package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
  70. package/lib/commonjs/utils/saveQuantitySample.js +21 -0
  71. package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
  72. package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
  73. package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
  74. package/lib/commonjs/utils/serializeDate.js +12 -0
  75. package/lib/commonjs/utils/serializeDate.js.map +1 -0
  76. package/lib/commonjs/utils/subscribeToChanges.js +37 -0
  77. package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
  78. package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
  79. package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
  80. package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
  81. package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
  82. package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
  83. package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
  84. package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
  85. package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
  86. package/lib/module/hooks/useMostRecentWorkout.js +47 -0
  87. package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
  88. package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
  89. package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
  90. package/lib/module/hooks/useSubscribeToChanges.js +26 -0
  91. package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
  92. package/lib/module/index.ios.js +32 -370
  93. package/lib/module/index.ios.js.map +1 -1
  94. package/lib/module/index.js +3 -5
  95. package/lib/module/index.js.map +1 -1
  96. package/lib/module/native-types.js +154 -74
  97. package/lib/module/native-types.js.map +1 -1
  98. package/lib/module/types.js +15 -0
  99. package/lib/module/types.js.map +1 -1
  100. package/lib/module/utils/deserializeCategorySample.js +7 -0
  101. package/lib/module/utils/deserializeCategorySample.js.map +1 -0
  102. package/lib/module/utils/deserializeCorrelation.js +21 -0
  103. package/lib/module/utils/deserializeCorrelation.js.map +1 -0
  104. package/lib/module/utils/deserializeSample.js +9 -0
  105. package/lib/module/utils/deserializeSample.js.map +1 -0
  106. package/lib/module/utils/deserializeWorkout.js +9 -0
  107. package/lib/module/utils/deserializeWorkout.js.map +1 -0
  108. package/lib/module/utils/ensureMetadata.js +6 -0
  109. package/lib/module/utils/ensureMetadata.js.map +1 -0
  110. package/lib/module/utils/ensureUnit.js +13 -0
  111. package/lib/module/utils/ensureUnit.js.map +1 -0
  112. package/lib/module/utils/getDateOfBirth.js +9 -0
  113. package/lib/module/utils/getDateOfBirth.js.map +1 -0
  114. package/lib/module/utils/getMostRecentCategorySample.js +12 -0
  115. package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
  116. package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
  117. package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
  118. package/lib/module/utils/getMostRecentWorkout.js +14 -0
  119. package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
  120. package/lib/module/utils/getPreferredUnit.js +9 -0
  121. package/lib/module/utils/getPreferredUnit.js.map +1 -0
  122. package/lib/module/utils/getPreferredUnits.js +9 -0
  123. package/lib/module/utils/getPreferredUnits.js.map +1 -0
  124. package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
  125. package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
  126. package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
  127. package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
  128. package/lib/module/utils/prepareOptions.js +17 -0
  129. package/lib/module/utils/prepareOptions.js.map +1 -0
  130. package/lib/module/utils/queryCategorySamples.js +12 -0
  131. package/lib/module/utils/queryCategorySamples.js.map +1 -0
  132. package/lib/module/utils/queryCorrelationSamples.js +12 -0
  133. package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
  134. package/lib/module/utils/queryQuantitySamples.js +14 -0
  135. package/lib/module/utils/queryQuantitySamples.js.map +1 -0
  136. package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
  137. package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
  138. package/lib/module/utils/queryWorkouts.js +17 -0
  139. package/lib/module/utils/queryWorkouts.js.map +1 -0
  140. package/lib/module/utils/requestAuthorization.js +15 -0
  141. package/lib/module/utils/requestAuthorization.js.map +1 -0
  142. package/lib/module/utils/saveCategorySample.js +11 -0
  143. package/lib/module/utils/saveCategorySample.js.map +1 -0
  144. package/lib/module/utils/saveCorrelationSample.js +13 -0
  145. package/lib/module/utils/saveCorrelationSample.js.map +1 -0
  146. package/lib/module/utils/saveQuantitySample.js +11 -0
  147. package/lib/module/utils/saveQuantitySample.js.map +1 -0
  148. package/lib/module/utils/saveWorkoutSample.js +14 -0
  149. package/lib/module/utils/saveWorkoutSample.js.map +1 -0
  150. package/lib/module/utils/serializeDate.js +4 -0
  151. package/lib/module/utils/serializeDate.js.map +1 -0
  152. package/lib/module/utils/subscribeToChanges.js +25 -0
  153. package/lib/module/utils/subscribeToChanges.js.map +1 -0
  154. package/lib/typescript/example-expo/App.d.ts +2 -0
  155. package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
  156. package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
  157. package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
  158. package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
  159. package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
  160. package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
  161. package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
  162. package/lib/typescript/src/index.d.ts +2 -3
  163. package/lib/typescript/src/index.ios.d.ts +48 -3
  164. package/lib/typescript/src/native-types.d.ts +169 -65
  165. package/lib/typescript/src/types.d.ts +14 -90
  166. package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
  167. package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
  168. package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
  169. package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
  170. package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
  171. package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
  172. package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
  173. package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
  174. package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
  175. package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
  176. package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
  177. package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
  178. package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
  179. package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
  180. package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
  181. package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
  182. package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
  183. package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
  184. package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
  185. package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
  186. package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
  187. package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
  188. package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
  189. package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
  190. package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
  191. package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
  192. package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
  193. package/package.json +17 -6
  194. package/src/hooks/useHealthkitAuthorization.ts +39 -0
  195. package/src/hooks/useIsHealthDataAvailable.ts +17 -0
  196. package/src/hooks/useMostRecentCategorySample.ts +24 -0
  197. package/src/hooks/useMostRecentQuantitySample.ts +39 -0
  198. package/src/hooks/useMostRecentWorkout.ts +60 -0
  199. package/src/hooks/useStatisticsForQuantity.ts +42 -0
  200. package/src/hooks/useSubscribeToChanges.ts +31 -0
  201. package/src/index.ios.tsx +36 -569
  202. package/src/index.tsx +5 -7
  203. package/src/native-types.ts +213 -74
  204. package/src/types.ts +41 -152
  205. package/src/utils/deserializeCategorySample.ts +12 -0
  206. package/src/utils/deserializeCorrelation.ts +28 -0
  207. package/src/utils/deserializeSample.ts +17 -0
  208. package/src/utils/deserializeWorkout.ts +14 -0
  209. package/src/utils/ensureMetadata.ts +5 -0
  210. package/src/utils/ensureUnit.ts +19 -0
  211. package/src/utils/getDateOfBirth.ts +8 -0
  212. package/src/utils/getMostRecentCategorySample.ts +18 -0
  213. package/src/utils/getMostRecentQuantitySample.ts +19 -0
  214. package/src/utils/getMostRecentWorkout.ts +27 -0
  215. package/src/utils/getPreferredUnit.ts +14 -0
  216. package/src/utils/getPreferredUnits.ts +14 -0
  217. package/src/utils/getPreferredUnitsTyped.ts +38 -0
  218. package/src/utils/getRequestStatusForAuthorization.ts +21 -0
  219. package/src/utils/prepareOptions.ts +15 -0
  220. package/src/utils/queryCategorySamples.ts +29 -0
  221. package/src/utils/queryCorrelationSamples.ts +29 -0
  222. package/src/utils/queryQuantitySamples.ts +36 -0
  223. package/src/utils/queryStatisticsForQuantity.ts +38 -0
  224. package/src/utils/queryWorkouts.ts +28 -0
  225. package/src/utils/requestAuthorization.ts +18 -0
  226. package/src/utils/saveCategorySample.ts +27 -0
  227. package/src/utils/saveCorrelationSample.ts +34 -0
  228. package/src/utils/saveQuantitySample.ts +29 -0
  229. package/src/utils/saveWorkoutSample.ts +28 -0
  230. package/src/utils/serializeDate.ts +3 -0
  231. package/src/utils/subscribeToChanges.ts +32 -0
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n HealthkitReadAuthorization,\n HealthkitWriteAuthorization,\n HKAuthorizationRequestStatus,\n HKBiologicalSex,\n HKBloodType,\n HKCategorySampleRaw,\n HKCategoryTypeIdentifier,\n HKCategoryValueForIdentifier,\n HKCorrelationRaw,\n HKCorrelationTypeIdentifier,\n HKFitzpatrickSkinType,\n HKQuantitySampleRaw,\n HKQuantityTypeIdentifier,\n HKSampleTypeIdentifier,\n HKStatisticsOptions,\n HKUnit,\n HKUnitSI,\n HKUnitSIPrefix,\n HKUpdateFrequency,\n HKWheelchairUse,\n HKWorkoutActivityType,\n HKWorkoutMetadata,\n HKWorkoutRaw,\n MetadataMapperForCategoryIdentifier,\n MetadataMapperForCorrelationIdentifier,\n MetadataMapperForQuantityIdentifier,\n QueryStatisticsResponseRaw,\n WorkoutRoute,\n} from './native-types'\n\nexport interface QueryWorkoutsOptions<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n> extends GenericQueryOptions {\n readonly energyUnit?: TEnergy;\n readonly distanceUnit?: TDistance;\n}\n\nexport interface HKCategorySample<\n T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier\n> extends Omit<HKCategorySampleRaw<T>, 'endDate' | 'startDate'> {\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport type GenericQueryOptions = {\n readonly from?: Date;\n readonly to?: Date;\n readonly limit?: number;\n readonly ascending?: boolean;\n};\n\nexport interface HKWorkout<\n TEnergy extends HKUnit = HKUnit,\n TDistance extends HKUnit = HKUnit\n> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport interface HKQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,\n TUnit extends HKUnit = HKUnit\n> extends Omit<\n HKQuantitySampleRaw<TIdentifier, TUnit>,\n 'endDate' | 'startDate'\n > {\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport interface QueryStatisticsResponse<T extends HKUnit = HKUnit>\n extends Omit<\n QueryStatisticsResponseRaw<T>,\n 'mostRecentQuantityDateInterval'\n > {\n readonly mostRecentQuantityDateInterval?: { readonly from: Date; readonly to: Date };\n}\n\ntype UnsubscribeFunction = () => Promise<boolean>;\n\nexport type IsHealthDataAvailableFn = () => Promise<boolean>;\n\nexport type GetBloodTypeFn = () => Promise<HKBloodType>;\n\nexport type GetDateOfBirthFn = () => Promise<Date>;\nexport type GetBiologicalSexFn = () => Promise<HKBiologicalSex>;\nexport type GetWheelchairUseFn = () => Promise<HKWheelchairUse>;\nexport type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;\n\nexport type QueryStatisticsForQuantityFn = <TUnit extends HKUnit>(\n identifier: HKQuantityTypeIdentifier,\n options: readonly HKStatisticsOptions[],\n from: Date,\n to?: Date,\n unit?: TUnit\n) => Promise<QueryStatisticsResponse<TUnit>>;\n\nexport type QueryWorkoutsFn = <\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(\n options: QueryWorkoutsOptions<TEnergy, TDistance>\n) => Promise<readonly HKWorkout<TEnergy, TDistance>[]>;\n\nexport type AuthorizationStatusForFn = (\n type: HealthkitReadAuthorization\n) => Promise<boolean>;\n\nexport type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(\n identifier: T,\n options: GenericQueryOptions\n) => Promise<readonly HKCategorySample<T>[]>;\n\nexport type GetRequestStatusForAuthorizationFn = (\n read: readonly HealthkitReadAuthorization[],\n write?: readonly HealthkitWriteAuthorization[]\n) => Promise<HKAuthorizationRequestStatus>;\n\nexport type RequestAuthorizationFn = (\n read: readonly HealthkitReadAuthorization[],\n write?: readonly HealthkitWriteAuthorization[]\n) => Promise<boolean>;\n\nexport type SaveQuantitySampleFn = <TUnit extends HKQuantityTypeIdentifier>(\n identifier: TUnit,\n unit: HKUnit,\n value: number,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForQuantityIdentifier<TUnit>;\n }\n) => Promise<boolean>;\n\nexport type QueryQuantitySamplesFn = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends HKUnit = HKUnit\n>(\n identifier: TIdentifier,\n options: GenericQueryOptions & { readonly unit?: TUnit }\n) => Promise<readonly HKQuantitySample<TIdentifier, TUnit>[]>;\n\nexport type SubscribeToChangesFn = (\n identifier: HKSampleTypeIdentifier,\n callback: () => void\n) => Promise<UnsubscribeFunction>;\n\nexport type SaveCategorySampleFn = <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) => Promise<boolean>;\n\nexport type GetMostRecentCategorySampleFn = <\n T extends HKCategoryTypeIdentifier\n>(\n identifier: T\n) => Promise<HKCategorySample<T> | null>;\n\nexport type MostRecentCategorySampleHook = <T extends HKCategoryTypeIdentifier>(\n identifier: T\n) => HKCategorySample<T> | null;\n\nexport type MostRecentCorrelationSampleHook = <\n T extends HKCorrelationTypeIdentifier\n>(\n identifer: T\n) => HKCorrelation<T> | null;\n\nexport type GetMostRecentQuantitySampleFn = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends HKUnit\n>(\n identifier: TIdentifier,\n unit?: TUnit\n) => Promise<HKQuantitySample<TIdentifier, TUnit> | null>;\n\nexport type MostRecentQuantitySampleHook = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends HKUnit\n>(\n identifier: TIdentifier,\n unit?: TUnit\n) => HKQuantitySample<TIdentifier, TUnit> | null;\n\nexport type GetMostRecentWorkoutFn = <\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(\n options?: Pick<\n QueryWorkoutsOptions<TEnergy, TDistance>,\n 'distanceUnit' | 'energyUnit'\n >\n) => Promise<HKWorkout<TEnergy, TDistance> | null>;\n\nexport type MostRecentWorkoutHook = <\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(\n options?: Pick<\n QueryWorkoutsOptions<TEnergy, TDistance>,\n 'distanceUnit' | 'energyUnit'\n >\n) => HKWorkout<TEnergy, TDistance> | null;\n\nexport type GetPreferredUnitsFn = (\n identifiers: readonly HKQuantityTypeIdentifier[]\n) => Promise<readonly HKUnit[]>;\n\nexport type GetPreferredUnitFn = (\n identifier: HKQuantityTypeIdentifier\n) => Promise<HKUnit>;\n\nexport type SaveCorrelationSampleFn = <\n TIdentifier extends HKCorrelationTypeIdentifier\n>(\n typeIdentifier: TIdentifier,\n samples: readonly (\n | Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>\n | Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>\n )[],\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;\n }\n) => Promise<boolean>;\n\nexport type SaveWorkoutSampleFn = (\n typeIdentifier: HKWorkoutActivityType,\n quantities: readonly Omit<\n HKQuantitySample,\n 'device' | 'endDate' | 'startDate' | 'uuid'\n >[],\n start: Date,\n options?: {\n readonly end?: Date;\n readonly metadata?: HKWorkoutMetadata;\n }\n) => Promise<boolean>;\n\nexport interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>\n extends Omit<\n HKCorrelationRaw<TIdentifier>,\n 'endDate' | 'objects' | 'startDate'\n > {\n readonly objects: readonly (HKCategorySample | HKQuantitySample)[];\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport type QueryCorrelationSamplesFn = <\n TIdentifier extends HKCorrelationTypeIdentifier\n>(\n typeIdentifier: TIdentifier,\n options: Omit<GenericQueryOptions, 'ascending' | 'limit'>\n) => Promise<readonly HKCorrelation<TIdentifier>[]>;\n\nexport type SubscribeToChangesHook = <\n TIdentifier extends HKSampleTypeIdentifier\n>(\n identifier: TIdentifier,\n onChange: () => void,\n runInitialUpdate?: boolean\n) => void;\n\nexport type GetWorkoutRoutesFn = (\n workoutUUID: string\n) => Promise<readonly WorkoutRoute[]>;\n\nexport type ReactNativeHealthkit = {\n readonly authorizationStatusFor: AuthorizationStatusForFn;\n\n readonly getBiologicalSex: GetBiologicalSexFn;\n readonly getBloodType: GetBloodTypeFn;\n readonly getDateOfBirth: GetDateOfBirthFn;\n readonly getFitzpatrickSkinType: GetFitzpatrickSkinTypeFn;\n readonly getMostRecentQuantitySample: GetMostRecentQuantitySampleFn;\n readonly getMostRecentCategorySample: GetMostRecentCategorySampleFn;\n readonly getMostRecentWorkout: GetMostRecentWorkoutFn;\n readonly getPreferredUnit: GetPreferredUnitFn;\n readonly getPreferredUnits: GetPreferredUnitsFn;\n readonly getRequestStatusForAuthorization: GetRequestStatusForAuthorizationFn;\n readonly getWheelchairUse: GetWheelchairUseFn;\n readonly getWorkoutRoutes: GetWorkoutRoutesFn;\n\n readonly buildUnitWithPrefix: (prefix: HKUnitSIPrefix, unit: HKUnitSI) => HKUnit;\n\n readonly isHealthDataAvailable: IsHealthDataAvailableFn;\n\n readonly queryCategorySamples: QueryCategorySamplesFn;\n readonly queryQuantitySamples: QueryQuantitySamplesFn;\n readonly queryStatisticsForQuantity: QueryStatisticsForQuantityFn;\n readonly queryWorkouts: QueryWorkoutsFn;\n readonly queryCorrelationSamples: QueryCorrelationSamplesFn;\n\n readonly requestAuthorization: RequestAuthorizationFn;\n\n readonly saveCategorySample: SaveCategorySampleFn;\n readonly saveQuantitySample: SaveQuantitySampleFn;\n readonly saveCorrelationSample: SaveCorrelationSampleFn;\n readonly saveWorkoutSample: SaveWorkoutSampleFn;\n readonly enableBackgroundDelivery: (\n typeIdentifier: HKSampleTypeIdentifier,\n updateFrequency: HKUpdateFrequency\n ) => Promise<boolean>;\n readonly disableBackgroundDelivery: (\n typeIdentifier: HKSampleTypeIdentifier\n ) => Promise<boolean>;\n readonly disableAllBackgroundDelivery: () => Promise<boolean>;\n\n readonly subscribeToChanges: SubscribeToChangesFn;\n\n readonly useMostRecentWorkout: MostRecentWorkoutHook;\n readonly useMostRecentCategorySample: MostRecentCategorySampleHook;\n readonly useMostRecentQuantitySample: MostRecentQuantitySampleHook;\n\n readonly useSubscribeToChanges: SubscribeToChangesHook;\n readonly useIsHealthDataAvailable: () => boolean | null;\n readonly useHealthkitAuthorization: (\n read: readonly HealthkitReadAuthorization[],\n write?: readonly HealthkitWriteAuthorization[],\n ) => readonly [authorizationStatus: HKAuthorizationRequestStatus | null, request: () => Promise<HKAuthorizationRequestStatus | null>];\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type {\n EnergyUnit,\n HKCategorySampleRaw,\n HKCategoryTypeIdentifier,\n HKCorrelationRaw,\n HKCorrelationTypeIdentifier,\n HKDevice,\n HKQuantityTypeIdentifier,\n HKSourceRevision,\n HKUnit,\n HKWorkoutRaw,\n LengthUnit,\n MetadataMapperForQuantityIdentifier,\n QueryStatisticsResponseRaw,\n UnitForIdentifier,\n} from './native-types'\n\nexport * from './native-types'\n\nexport interface QueryWorkoutsOptions<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n> extends GenericQueryOptions {\n readonly energyUnit?: TEnergy;\n readonly distanceUnit?: TDistance;\n}\n\nexport interface HKCategorySample<\n T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier\n> extends Omit<HKCategorySampleRaw<T>, 'endDate' | 'startDate'> {\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport type GenericQueryOptions = {\n readonly from?: Date;\n readonly to?: Date;\n readonly limit?: number;\n readonly ascending?: boolean;\n};\n\nexport interface HKWorkout<\n TEnergy extends EnergyUnit = EnergyUnit,\n TDistance extends LengthUnit = LengthUnit\n> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport interface HKQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>\n> {\n readonly uuid: string;\n readonly device?: HKDevice;\n readonly quantityType: TIdentifier;\n readonly quantity: number;\n readonly unit: TUnit;\n readonly metadata?: MetadataMapperForQuantityIdentifier<TIdentifier>;\n readonly sourceRevision?: HKSourceRevision;\n readonly startDate: Date;\n readonly endDate: Date;\n}\n\nexport interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier> = UnitForIdentifier<TIdentifier>>\n extends Omit<\n QueryStatisticsResponseRaw<TIdentifier, TUnit>,\n 'mostRecentQuantityDateInterval'\n > {\n readonly mostRecentQuantityDateInterval?: { readonly from: Date; readonly to: Date };\n}\n/*\nexport type IsHealthDataAvailableFn = () => Promise<boolean>;\n\nexport type GetBloodTypeFn = () => Promise<HKBloodType>;\n\nexport type GetDateOfBirthFn = () => Promise<Date>;\nexport type GetBiologicalSexFn = () => Promise<HKBiologicalSex>;\nexport type GetWheelchairUseFn = () => Promise<HKWheelchairUse>;\nexport type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;\n\nexport type AuthorizationStatusForFn = (\n type: HealthkitReadAuthorization\n) => Promise<boolean>;\n\nexport type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(\n identifier: T,\n options: GenericQueryOptions\n) => Promise<readonly HKCategorySample<T>[]>;\n\nexport type GetRequestStatusForAuthorizationFn = (\n read: readonly HealthkitReadAuthorization[],\n write?: readonly HealthkitWriteAuthorization[]\n) => Promise<HKAuthorizationRequestStatus>;\n\nexport type RequestAuthorizationFn = (\n read: readonly HealthkitReadAuthorization[],\n write?: readonly HealthkitWriteAuthorization[]\n) => Promise<boolean>;\n\nexport type SaveQuantitySampleFn = <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType>>(\n identifier: TType,\n unit: TUnit,\n value: number,\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForQuantityIdentifier<TType>;\n }\n) => Promise<boolean>;\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\nexport type HKCategorySampleForSaving =Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>\n\nexport type HKQuantitySampleForSaving =Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>\n/*\nexport type SaveCategorySampleFn = <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) => Promise<boolean>;\n\nexport type MostRecentCategorySampleHook = <T extends HKCategoryTypeIdentifier>(\n identifier: T\n) => HKCategorySample<T> | null;\n\nexport type MostRecentCorrelationSampleHook = <\n T extends HKCorrelationTypeIdentifier\n>(\n identifer: T\n) => HKCorrelation<T> | null;\n\nexport type MostRecentQuantitySampleHook = <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n unit?: TUnit\n) => HKQuantitySample<TIdentifier> | null;\n\nexport type MostRecentWorkoutHook = <\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(\n options?: Pick<\n QueryWorkoutsOptions<TEnergy, TDistance>,\n 'distanceUnit' | 'energyUnit'\n >\n) => HKWorkout<TEnergy, TDistance> | null;\n\nexport type GetPreferredUnitsFn = (\n identifiers: readonly HKQuantityTypeIdentifier[]\n) => Promise<readonly HKUnit[]>;\n\nexport type GetPreferredUnitFn = (\n identifier: HKQuantityTypeIdentifier\n) => Promise<HKUnit>;\n\nexport type SaveCorrelationSampleFn = <\n TIdentifier extends HKCorrelationTypeIdentifier\n>(\n typeIdentifier: TIdentifier,\n samples: readonly (\n | Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>\n | Omit<HKQuantitySample<HKQuantityTypeIdentifier>, 'device' | 'endDate' | 'startDate' | 'uuid'>\n )[],\n options?: {\n readonly start?: Date;\n readonly end?: Date;\n readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;\n }\n) => Promise<boolean>;\n\nexport type SaveWorkoutSampleFn<TIdentifier extends HKWorkoutActivityType, TQIdentifier extends HKQuantityTypeIdentifier> = (\n typeIdentifier: TIdentifier,\n quantities: readonly Omit<\n HKQuantitySample<TQIdentifier>,\n 'device' | 'endDate' | 'startDate' | 'uuid'\n >[],\n start: Date,\n options?: {\n readonly end?: Date;\n readonly metadata?: HKWorkoutMetadata;\n }\n) => Promise<boolean>;\n*/\nexport interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>\n extends Omit<\n HKCorrelationRaw<TIdentifier>,\n 'endDate' | 'objects' | 'startDate'\n > {\n readonly objects: readonly (HKCategorySample | HKQuantitySample)[];\n readonly startDate: Date;\n readonly endDate: Date;\n}\n/*\nexport type SubscribeToChangesHook = <\n TIdentifier extends HKSampleTypeIdentifier\n>(\n identifier: TIdentifier,\n onChange: () => void,\n runInitialUpdate?: boolean\n) => void;\n\nexport type GetWorkoutRoutesFn = (\n workoutUUID: string\n) => Promise<readonly WorkoutRoute[]>;\n*/\n"],"mappings":";;;;;;AAiBA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ const deserializCategorySample = sample => ({ ...sample,
9
+ startDate: new Date(sample.startDate),
10
+ endDate: new Date(sample.endDate)
11
+ });
12
+
13
+ var _default = deserializCategorySample;
14
+ exports.default = _default;
15
+ //# sourceMappingURL=deserializeCategorySample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deserializCategorySample","sample","startDate","Date","endDate"],"sources":["deserializeCategorySample.ts"],"sourcesContent":["import type { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../native-types'\nimport type { HKCategorySample } from '../types'\n\nconst deserializCategorySample = <T extends HKCategoryTypeIdentifier>(\n sample: HKCategorySampleRaw<T>,\n): HKCategorySample<T> => ({\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n})\n\nexport default deserializCategorySample\n"],"mappings":";;;;;;;AAGA,MAAMA,wBAAwB,GAC5BC,MAD+B,KAEN,EACzB,GAAGA,MADsB;EAEzBC,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFc;EAGzBE,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;AAHgB,CAFM,CAAjC;;eAQeJ,wB"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _deserializeCategorySample = _interopRequireDefault(require("./deserializeCategorySample"));
9
+
10
+ var _deserializeSample = _interopRequireDefault(require("./deserializeSample"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ function deserializeCorrelation(s) {
15
+ return { ...s,
16
+ objects: s.objects.map(o => {
17
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
18
+ // @ts-ignore
19
+ if (o.quantity !== undefined) {
20
+ return (0, _deserializeSample.default)(o);
21
+ }
22
+
23
+ return (0, _deserializeCategorySample.default)(o);
24
+ }),
25
+ endDate: new Date(s.endDate),
26
+ startDate: new Date(s.startDate)
27
+ };
28
+ }
29
+
30
+ var _default = deserializeCorrelation;
31
+ exports.default = _default;
32
+ //# sourceMappingURL=deserializeCorrelation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deserializeCorrelation","s","objects","map","o","quantity","undefined","deserializeSample","deserializCategorySample","endDate","Date","startDate"],"sources":["deserializeCorrelation.ts"],"sourcesContent":["import deserializCategorySample from './deserializeCategorySample'\nimport deserializeSample from './deserializeSample'\n\nimport type {\n HKCategorySampleRaw, HKCorrelationRaw, HKCorrelationTypeIdentifier, HKQuantitySampleRaw, HKQuantityTypeIdentifier,\n} from '../native-types'\nimport type { HKCorrelation } from '../types'\n\nfunction deserializeCorrelation<\n TIdentifier extends HKCorrelationTypeIdentifier\n>(s: HKCorrelationRaw<TIdentifier>): HKCorrelation<TIdentifier> {\n return {\n ...s,\n objects: s.objects.map((o) => {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n if (o.quantity !== undefined) {\n return deserializeSample(o as HKQuantitySampleRaw<HKQuantityTypeIdentifier>)\n }\n\n return deserializCategorySample(o as HKCategorySampleRaw)\n }),\n endDate: new Date(s.endDate),\n startDate: new Date(s.startDate),\n }\n}\n\nexport default deserializeCorrelation\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAOA,SAASA,sBAAT,CAEEC,CAFF,EAEgE;EAC9D,OAAO,EACL,GAAGA,CADE;IAELC,OAAO,EAAED,CAAC,CAACC,OAAF,CAAUC,GAAV,CAAeC,CAAD,IAAO;MAC9B;MACA;MACE,IAAIA,CAAC,CAACC,QAAF,KAAeC,SAAnB,EAA8B;QAC5B,OAAO,IAAAC,0BAAA,EAAkBH,CAAlB,CAAP;MACD;;MAED,OAAO,IAAAI,kCAAA,EAAyBJ,CAAzB,CAAP;IACD,CARQ,CAFJ;IAWLK,OAAO,EAAE,IAAIC,IAAJ,CAAST,CAAC,CAACQ,OAAX,CAXJ;IAYLE,SAAS,EAAE,IAAID,IAAJ,CAAST,CAAC,CAACU,SAAX;EAZN,CAAP;AAcD;;eAEcX,sB"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function deserializeSample(sample) {
9
+ return { ...sample,
10
+ startDate: new Date(sample.startDate),
11
+ endDate: new Date(sample.endDate)
12
+ };
13
+ }
14
+
15
+ var _default = deserializeSample;
16
+ exports.default = _default;
17
+ //# sourceMappingURL=deserializeSample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deserializeSample","sample","startDate","Date","endDate"],"sources":["deserializeSample.ts"],"sourcesContent":["import type { HKQuantitySampleRaw, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\nimport type { HKQuantitySample } from '../types'\n\nfunction deserializeSample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n sample: HKQuantitySampleRaw<TIdentifier, TUnit>,\n): HKQuantitySample<TIdentifier, TUnit> {\n return {\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n }\n}\n\nexport default deserializeSample\n"],"mappings":";;;;;;;AAGA,SAASA,iBAAT,CAIEC,MAJF,EAKwC;EACtC,OAAO,EACL,GAAGA,MADE;IAELC,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFN;IAGLE,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;EAHJ,CAAP;AAKD;;eAEcJ,iB"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function deserializeWorkout(sample) {
9
+ return { ...sample,
10
+ startDate: new Date(sample.startDate),
11
+ endDate: new Date(sample.endDate)
12
+ };
13
+ }
14
+
15
+ var _default = deserializeWorkout;
16
+ exports.default = _default;
17
+ //# sourceMappingURL=deserializeWorkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["deserializeWorkout","sample","startDate","Date","endDate"],"sources":["deserializeWorkout.ts"],"sourcesContent":["import type { EnergyUnit, HKWorkoutRaw, LengthUnit } from '../native-types'\nimport type { HKWorkout } from '../types'\n\nfunction deserializeWorkout<TEnergy extends EnergyUnit, TDistance extends LengthUnit>(\n sample: HKWorkoutRaw<TEnergy, TDistance>,\n): HKWorkout<TEnergy, TDistance> {\n return {\n ...sample,\n startDate: new Date(sample.startDate),\n endDate: new Date(sample.endDate),\n }\n}\n\nexport default deserializeWorkout\n"],"mappings":";;;;;;;AAGA,SAASA,kBAAT,CACEC,MADF,EAEiC;EAC/B,OAAO,EACL,GAAGA,MADE;IAELC,SAAS,EAAE,IAAIC,IAAJ,CAASF,MAAM,CAACC,SAAhB,CAFN;IAGLE,OAAO,EAAE,IAAID,IAAJ,CAASF,MAAM,CAACG,OAAhB;EAHJ,CAAP;AAKD;;eAEcJ,kB"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ function ensureMetadata(metadata) {
9
+ return metadata || {};
10
+ }
11
+
12
+ var _default = ensureMetadata;
13
+ exports.default = _default;
14
+ //# sourceMappingURL=ensureMetadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensureMetadata","metadata"],"sources":["ensureMetadata.ts"],"sourcesContent":["function ensureMetadata<TMetadata>(metadata?: TMetadata) {\n return metadata || ({} as TMetadata)\n}\n\nexport default ensureMetadata\n"],"mappings":";;;;;;;AAAA,SAASA,cAAT,CAAmCC,QAAnC,EAAyD;EACvD,OAAOA,QAAQ,IAAK,EAApB;AACD;;eAEcD,c"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const ensureUnit = async (type, providedUnit) => {
13
+ if (providedUnit) {
14
+ return providedUnit;
15
+ }
16
+
17
+ const unit = await _nativeTypes.default.getPreferredUnits([type]);
18
+ return unit[type];
19
+ };
20
+
21
+ var _default = ensureUnit;
22
+ exports.default = _default;
23
+ //# sourceMappingURL=ensureUnit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ensureUnit","type","providedUnit","unit","Native","getPreferredUnits"],"sources":["ensureUnit.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nconst ensureUnit = async <\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n type: TIdentifier,\n providedUnit?: TUnit,\n) => {\n if (providedUnit) {\n return providedUnit\n }\n const unit = await Native.getPreferredUnits([type])\n return unit[type] as TUnit\n}\n\nexport default ensureUnit\n"],"mappings":";;;;;;;AAAA;;;;AAIA,MAAMA,UAAU,GAAG,OAIjBC,IAJiB,EAKjBC,YALiB,KAMd;EACH,IAAIA,YAAJ,EAAkB;IAChB,OAAOA,YAAP;EACD;;EACD,MAAMC,IAAI,GAAG,MAAMC,oBAAA,CAAOC,iBAAP,CAAyB,CAACJ,IAAD,CAAzB,CAAnB;EACA,OAAOE,IAAI,CAACF,IAAD,CAAX;AACD,CAZD;;eAceD,U"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getDateOfBirth = async () => {
13
+ const dateOfBirth = await _nativeTypes.default.getDateOfBirth();
14
+ return new Date(dateOfBirth);
15
+ };
16
+
17
+ var _default = getDateOfBirth;
18
+ exports.default = _default;
19
+ //# sourceMappingURL=getDateOfBirth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getDateOfBirth","dateOfBirth","Native","Date"],"sources":["getDateOfBirth.ts"],"sourcesContent":["import Native from '../native-types'\n\nconst getDateOfBirth = async () => {\n const dateOfBirth = await Native.getDateOfBirth()\n return new Date(dateOfBirth)\n}\n\nexport default getDateOfBirth\n"],"mappings":";;;;;;;AAAA;;;;AAEA,MAAMA,cAAc,GAAG,YAAY;EACjC,MAAMC,WAAW,GAAG,MAAMC,oBAAA,CAAOF,cAAP,EAA1B;EACA,OAAO,IAAIG,IAAJ,CAASF,WAAT,CAAP;AACD,CAHD;;eAKeD,c"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _queryCategorySamples = _interopRequireDefault(require("./queryCategorySamples"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ async function getMostRecentCategorySample(identifier) {
13
+ const samples = await (0, _queryCategorySamples.default)(identifier, {
14
+ limit: 1,
15
+ ascending: false
16
+ });
17
+ return samples[0] || null;
18
+ }
19
+
20
+ var _default = getMostRecentCategorySample;
21
+ exports.default = _default;
22
+ //# sourceMappingURL=getMostRecentCategorySample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getMostRecentCategorySample","identifier","samples","queryCategorySamples","limit","ascending"],"sources":["getMostRecentCategorySample.ts"],"sourcesContent":["import queryCategorySamples from './queryCategorySamples'\n\nimport type { HKCategoryTypeIdentifier } from '../native-types'\n\nasync function getMostRecentCategorySample<\n T extends HKCategoryTypeIdentifier\n>(\n identifier: T,\n) {\n const samples = await queryCategorySamples(identifier, {\n limit: 1,\n ascending: false,\n })\n\n return samples[0] || null\n}\n\nexport default getMostRecentCategorySample\n"],"mappings":";;;;;;;AAAA;;;;AAIA,eAAeA,2BAAf,CAGEC,UAHF,EAIE;EACA,MAAMC,OAAO,GAAG,MAAM,IAAAC,6BAAA,EAAqBF,UAArB,EAAiC;IACrDG,KAAK,EAAE,CAD8C;IAErDC,SAAS,EAAE;EAF0C,CAAjC,CAAtB;EAKA,OAAOH,OAAO,CAAC,CAAD,CAAP,IAAc,IAArB;AACD;;eAEcF,2B"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _queryQuantitySamples = _interopRequireDefault(require("./queryQuantitySamples"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ async function getMostRecentQuantitySample(identifier, unit) {
13
+ const samples = await (0, _queryQuantitySamples.default)(identifier, {
14
+ limit: 1,
15
+ unit
16
+ });
17
+ return samples[0] || null;
18
+ }
19
+
20
+ var _default = getMostRecentQuantitySample;
21
+ exports.default = _default;
22
+ //# sourceMappingURL=getMostRecentQuantitySample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getMostRecentQuantitySample","identifier","unit","samples","queryQuantitySamples","limit"],"sources":["getMostRecentQuantitySample.ts"],"sourcesContent":["import queryQuantitySamples from './queryQuantitySamples'\n\nimport type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'\n\nasync function getMostRecentQuantitySample<\n TIdentifier extends HKQuantityTypeIdentifier,\n TUnit extends UnitForIdentifier<TIdentifier>\n>(\n identifier: TIdentifier,\n unit: TUnit,\n) {\n const samples = await queryQuantitySamples(identifier, {\n limit: 1,\n unit,\n })\n return samples[0] || null\n}\n\nexport default getMostRecentQuantitySample\n"],"mappings":";;;;;;;AAAA;;;;AAIA,eAAeA,2BAAf,CAIEC,UAJF,EAKEC,IALF,EAME;EACA,MAAMC,OAAO,GAAG,MAAM,IAAAC,6BAAA,EAAqBH,UAArB,EAAiC;IACrDI,KAAK,EAAE,CAD8C;IAErDH;EAFqD,CAAjC,CAAtB;EAIA,OAAOC,OAAO,CAAC,CAAD,CAAP,IAAc,IAArB;AACD;;eAEcH,2B"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _queryWorkouts = _interopRequireDefault(require("./queryWorkouts"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getMostRecentWorkout = async options => {
13
+ const workouts = await (0, _queryWorkouts.default)({
14
+ limit: 1,
15
+ ascending: false,
16
+ energyUnit: options === null || options === void 0 ? void 0 : options.energyUnit,
17
+ distanceUnit: options === null || options === void 0 ? void 0 : options.distanceUnit
18
+ });
19
+ return workouts[0] || null;
20
+ };
21
+
22
+ var _default = getMostRecentWorkout;
23
+ exports.default = _default;
24
+ //# sourceMappingURL=getMostRecentWorkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getMostRecentWorkout","options","workouts","queryWorkouts","limit","ascending","energyUnit","distanceUnit"],"sources":["getMostRecentWorkout.ts"],"sourcesContent":["import queryWorkouts from './queryWorkouts'\n\nimport type { EnergyUnit, LengthUnit } from '../native-types'\nimport type { HKWorkout, QueryWorkoutsOptions } from '../types'\n\nexport type GetMostRecentWorkoutFn = <\n TEnergy extends EnergyUnit,\n TDistance extends LengthUnit\n>(\n options?: Pick<\n QueryWorkoutsOptions<TEnergy, TDistance>,\n 'distanceUnit' | 'energyUnit'\n >\n) => Promise<HKWorkout<TEnergy, TDistance> | null>;\n\nconst getMostRecentWorkout: GetMostRecentWorkoutFn = async (options) => {\n const workouts = await queryWorkouts({\n limit: 1,\n ascending: false,\n energyUnit: options?.energyUnit,\n distanceUnit: options?.distanceUnit,\n })\n\n return workouts[0] || null\n}\n\nexport default getMostRecentWorkout\n"],"mappings":";;;;;;;AAAA;;;;AAeA,MAAMA,oBAA4C,GAAG,MAAOC,OAAP,IAAmB;EACtE,MAAMC,QAAQ,GAAG,MAAM,IAAAC,sBAAA,EAAc;IACnCC,KAAK,EAAE,CAD4B;IAEnCC,SAAS,EAAE,KAFwB;IAGnCC,UAAU,EAAEL,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK,UAHc;IAInCC,YAAY,EAAEN,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEM;EAJY,CAAd,CAAvB;EAOA,OAAOL,QAAQ,CAAC,CAAD,CAAR,IAAe,IAAtB;AACD,CATD;;eAWeF,oB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _getPreferredUnits = _interopRequireDefault(require("./getPreferredUnits"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getPreferredUnit = async type => {
13
+ const [unit] = await (0, _getPreferredUnits.default)([type]);
14
+ return unit;
15
+ };
16
+
17
+ var _default = getPreferredUnit;
18
+ exports.default = _default;
19
+ //# sourceMappingURL=getPreferredUnit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPreferredUnit","type","unit","getPreferredUnits"],"sources":["getPreferredUnit.ts"],"sourcesContent":["import getPreferredUnits from './getPreferredUnits'\n\nimport type { HKQuantityTypeIdentifier, HKUnit } from '../native-types'\n\nexport type GetPreferredUnitFn = (\n identifier: HKQuantityTypeIdentifier\n) => Promise<HKUnit>;\n\nconst getPreferredUnit: GetPreferredUnitFn = async (type) => {\n const [unit] = await getPreferredUnits([type])\n return unit!\n}\n\nexport default getPreferredUnit\n"],"mappings":";;;;;;;AAAA;;;;AAQA,MAAMA,gBAAoC,GAAG,MAAOC,IAAP,IAAgB;EAC3D,MAAM,CAACC,IAAD,IAAS,MAAM,IAAAC,0BAAA,EAAkB,CAACF,IAAD,CAAlB,CAArB;EACA,OAAOC,IAAP;AACD,CAHD;;eAKeF,gB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getPreferredUnits = async identifiers => {
13
+ const units = await _nativeTypes.default.getPreferredUnits(identifiers);
14
+ return identifiers.map(i => units[i]);
15
+ };
16
+
17
+ var _default = getPreferredUnits;
18
+ exports.default = _default;
19
+ //# sourceMappingURL=getPreferredUnits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPreferredUnits","identifiers","units","Native","map","i"],"sources":["getPreferredUnits.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type { HKQuantityTypeIdentifier, HKUnit } from '../native-types'\n\nexport type GetPreferredUnitsFn = (\n identifiers: readonly HKQuantityTypeIdentifier[]\n) => Promise<readonly HKUnit[]>;\n\nconst getPreferredUnits: GetPreferredUnitsFn = async (identifiers) => {\n const units = await Native.getPreferredUnits(identifiers)\n return identifiers.map((i) => units[i])\n}\n\nexport default getPreferredUnits\n"],"mappings":";;;;;;;AAAA;;;;AAQA,MAAMA,iBAAsC,GAAG,MAAOC,WAAP,IAAuB;EACpE,MAAMC,KAAK,GAAG,MAAMC,oBAAA,CAAOH,iBAAP,CAAyBC,WAAzB,CAApB;EACA,OAAOA,WAAW,CAACG,GAAZ,CAAiBC,CAAD,IAAOH,KAAK,CAACG,CAAD,CAA5B,CAAP;AACD,CAHD;;eAKeL,iB"}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireWildcard(require("../native-types"));
9
+
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+
14
+ async function getPreferredUnitsTyped(options) {
15
+ let energyUnit = options === null || options === void 0 ? void 0 : options.energyUnit;
16
+ let distanceUnit = options === null || options === void 0 ? void 0 : options.distanceUnit;
17
+
18
+ if (!energyUnit || !distanceUnit) {
19
+ const units = await _nativeTypes.default.getPreferredUnits([_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning, _nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned]);
20
+
21
+ if (!energyUnit) {
22
+ energyUnit = units[_nativeTypes.HKQuantityTypeIdentifier.activeEnergyBurned];
23
+ }
24
+
25
+ if (!distanceUnit) {
26
+ distanceUnit = units[_nativeTypes.HKQuantityTypeIdentifier.distanceWalkingRunning];
27
+ }
28
+ }
29
+
30
+ if (!energyUnit) {
31
+ energyUnit = _nativeTypes.UnitOfEnergy.Kilocalories;
32
+ }
33
+
34
+ if (!distanceUnit) {
35
+ distanceUnit = _nativeTypes.UnitOfLength.Meter;
36
+ }
37
+
38
+ return {
39
+ energyUnit,
40
+ distanceUnit
41
+ };
42
+ }
43
+
44
+ var _default = getPreferredUnitsTyped;
45
+ exports.default = _default;
46
+ //# sourceMappingURL=getPreferredUnitsTyped.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getPreferredUnitsTyped","options","energyUnit","distanceUnit","units","Native","getPreferredUnits","HKQuantityTypeIdentifier","distanceWalkingRunning","activeEnergyBurned","UnitOfEnergy","Kilocalories","UnitOfLength","Meter"],"sources":["getPreferredUnitsTyped.ts"],"sourcesContent":["import Native, { HKQuantityTypeIdentifier, UnitOfEnergy, UnitOfLength } from '../native-types'\n\nimport type { HKUnit } from '../native-types'\n\nasync function getPreferredUnitsTyped<\n TEnergy extends HKUnit,\n TDistance extends HKUnit\n>(options?: { readonly energyUnit?: TEnergy; readonly distanceUnit?: TDistance }) {\n let energyUnit = options?.energyUnit\n let distanceUnit = options?.distanceUnit\n\n if (!energyUnit || !distanceUnit) {\n const units = await Native.getPreferredUnits([\n HKQuantityTypeIdentifier.distanceWalkingRunning,\n HKQuantityTypeIdentifier.activeEnergyBurned,\n ])\n if (!energyUnit) {\n energyUnit = units[HKQuantityTypeIdentifier.activeEnergyBurned] as\n | TEnergy\n | undefined\n }\n if (!distanceUnit) {\n distanceUnit = units[HKQuantityTypeIdentifier.distanceWalkingRunning] as\n | TDistance\n | undefined\n }\n }\n\n if (!energyUnit) {\n energyUnit = UnitOfEnergy.Kilocalories as TEnergy\n }\n if (!distanceUnit) {\n distanceUnit = UnitOfLength.Meter as TDistance\n }\n return { energyUnit, distanceUnit }\n}\n\nexport default getPreferredUnitsTyped\n"],"mappings":";;;;;;;AAAA;;;;;;AAIA,eAAeA,sBAAf,CAGEC,OAHF,EAGkF;EAChF,IAAIC,UAAU,GAAGD,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEC,UAA1B;EACA,IAAIC,YAAY,GAAGF,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEE,YAA5B;;EAEA,IAAI,CAACD,UAAD,IAAe,CAACC,YAApB,EAAkC;IAChC,MAAMC,KAAK,GAAG,MAAMC,oBAAA,CAAOC,iBAAP,CAAyB,CAC3CC,qCAAA,CAAyBC,sBADkB,EAE3CD,qCAAA,CAAyBE,kBAFkB,CAAzB,CAApB;;IAIA,IAAI,CAACP,UAAL,EAAiB;MACfA,UAAU,GAAGE,KAAK,CAACG,qCAAA,CAAyBE,kBAA1B,CAAlB;IAGD;;IACD,IAAI,CAACN,YAAL,EAAmB;MACjBA,YAAY,GAAGC,KAAK,CAACG,qCAAA,CAAyBC,sBAA1B,CAApB;IAGD;EACF;;EAED,IAAI,CAACN,UAAL,EAAiB;IACfA,UAAU,GAAGQ,yBAAA,CAAaC,YAA1B;EACD;;EACD,IAAI,CAACR,YAAL,EAAmB;IACjBA,YAAY,GAAGS,yBAAA,CAAaC,KAA5B;EACD;;EACD,OAAO;IAAEX,UAAF;IAAcC;EAAd,CAAP;AACD;;eAEcH,sB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const getRequestStatusForAuthorization = async function (read) {
13
+ let write = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
14
+ const readPermissions = read.reduce((obj, cur) => ({ ...obj,
15
+ [cur]: true
16
+ }), {});
17
+ const writePermissions = write.reduce((obj, cur) => ({ ...obj,
18
+ [cur]: true
19
+ }), {});
20
+ return _nativeTypes.default.getRequestStatusForAuthorization(writePermissions, readPermissions);
21
+ };
22
+
23
+ var _default = getRequestStatusForAuthorization;
24
+ exports.default = _default;
25
+ //# sourceMappingURL=getRequestStatusForAuthorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getRequestStatusForAuthorization","read","write","readPermissions","reduce","obj","cur","writePermissions","Native"],"sources":["getRequestStatusForAuthorization.ts"],"sourcesContent":["import Native from '../native-types'\n\nimport type {\n HealthkitReadAuthorization, HealthkitWriteAuthorization, ReadPermissions, WritePermissions,\n} from '../native-types'\n\nconst getRequestStatusForAuthorization = async (\n read: readonly HealthkitReadAuthorization[],\n write: readonly HealthkitWriteAuthorization[] = [],\n) => {\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.getRequestStatusForAuthorization(\n writePermissions,\n readPermissions,\n )\n}\n\nexport default getRequestStatusForAuthorization\n"],"mappings":";;;;;;;AAAA;;;;AAMA,MAAMA,gCAAgC,GAAG,gBACvCC,IADuC,EAGpC;EAAA,IADHC,KACG,uEAD6C,EAC7C;EACH,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,OAAOE,oBAAA,CAAOR,gCAAP,CACLO,gBADK,EAELJ,eAFK,CAAP;AAID,CAZD;;eAceH,gC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _serializeDate = _interopRequireDefault(require("./serializeDate"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const prepareOptions = options => {
13
+ const limit = !options.limit || options.limit === Infinity ? 0 : options.limit;
14
+ const ascending = options.ascending ?? limit === 0;
15
+ const from = (0, _serializeDate.default)(options.from);
16
+ const to = (0, _serializeDate.default)(options.to);
17
+ return {
18
+ limit,
19
+ ascending,
20
+ from,
21
+ to
22
+ };
23
+ };
24
+
25
+ var _default = prepareOptions;
26
+ exports.default = _default;
27
+ //# sourceMappingURL=prepareOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["prepareOptions","options","limit","Infinity","ascending","from","serializeDate","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;;;;AAIA,MAAMA,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,GAAG,IAAAC,sBAAA,EAAcL,OAAO,CAACI,IAAtB,CAAb;EACA,MAAME,EAAE,GAAG,IAAAD,sBAAA,EAAcL,OAAO,CAACM,EAAtB,CAAX;EACA,OAAO;IACLL,KADK;IACEE,SADF;IACaC,IADb;IACmBE;EADnB,CAAP;AAGD,CARD;;eAUeP,c"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ var _deserializeCategorySample = _interopRequireDefault(require("./deserializeCategorySample"));
11
+
12
+ var _prepareOptions = _interopRequireDefault(require("./prepareOptions"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const queryCategorySamples = async (identifier, options) => {
17
+ const opts = (0, _prepareOptions.default)(options);
18
+ const results = await _nativeTypes.default.queryCategorySamples(identifier, opts.from, opts.to, opts.limit, opts.ascending);
19
+ return results.map(_deserializeCategorySample.default);
20
+ };
21
+
22
+ var _default = queryCategorySamples;
23
+ exports.default = _default;
24
+ //# sourceMappingURL=queryCategorySamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["queryCategorySamples","identifier","options","opts","prepareOptions","results","Native","from","to","limit","ascending","map","deserializCategorySample"],"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;;AACA;;AACA;;;;AAUA,MAAMA,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAG,IAAAC,uBAAA,EAAeF,OAAf,CAAb;EACA,MAAMG,OAAO,GAAG,MAAMC,oBAAA,CAAON,oBAAP,CACpBC,UADoB,EAEpBE,IAAI,CAACI,IAFe,EAGpBJ,IAAI,CAACK,EAHe,EAIpBL,IAAI,CAACM,KAJe,EAKpBN,IAAI,CAACO,SALe,CAAtB;EAQA,OAAOL,OAAO,CAACM,GAAR,CAAYC,kCAAZ,CAAP;AACD,CAdD;;eAgBeZ,oB"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ var _deserializeCorrelation = _interopRequireDefault(require("./deserializeCorrelation"));
11
+
12
+ var _prepareOptions = _interopRequireDefault(require("./prepareOptions"));
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+
16
+ const queryCorrelationSamples = async (typeIdentifier, options) => {
17
+ const opts = (0, _prepareOptions.default)(options);
18
+ const correlations = await _nativeTypes.default.queryCorrelationSamples(typeIdentifier, opts.from, opts.to);
19
+ return correlations.map(_deserializeCorrelation.default);
20
+ };
21
+
22
+ var _default = queryCorrelationSamples;
23
+ exports.default = _default;
24
+ //# sourceMappingURL=queryCorrelationSamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["queryCorrelationSamples","typeIdentifier","options","opts","prepareOptions","correlations","Native","from","to","map","deserializeCorrelation"],"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;;AACA;;AACA;;;;AAYA,MAAMA,uBAAkD,GAAG,OACzDC,cADyD,EAEzDC,OAFyD,KAGtD;EACH,MAAMC,IAAI,GAAG,IAAAC,uBAAA,EAAeF,OAAf,CAAb;EACA,MAAMG,YAAY,GAAG,MAAMC,oBAAA,CAAON,uBAAP,CACzBC,cADyB,EAEzBE,IAAI,CAACI,IAFoB,EAGzBJ,IAAI,CAACK,EAHoB,CAA3B;EAMA,OAAOH,YAAY,CAACI,GAAb,CAAiBC,+BAAjB,CAAP;AACD,CAZD;;eAceV,uB"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ var _deserializeSample = _interopRequireDefault(require("./deserializeSample"));
11
+
12
+ var _ensureUnit = _interopRequireDefault(require("./ensureUnit"));
13
+
14
+ var _prepareOptions = _interopRequireDefault(require("./prepareOptions"));
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const queryQuantitySamples = async (identifier, options) => {
19
+ const unit = await (0, _ensureUnit.default)(identifier, options.unit);
20
+ const opts = (0, _prepareOptions.default)(options);
21
+ const quantitySamples = await _nativeTypes.default.queryQuantitySamples(identifier, unit, opts.from, opts.to, opts.limit, opts.ascending);
22
+ return quantitySamples.map(_deserializeSample.default);
23
+ };
24
+
25
+ var _default = queryQuantitySamples;
26
+ exports.default = _default;
27
+ //# sourceMappingURL=queryQuantitySamples.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["queryQuantitySamples","identifier","options","unit","ensureUnit","opts","prepareOptions","quantitySamples","Native","from","to","limit","ascending","map","deserializeSample"],"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;;AACA;;AACA;;AACA;;;;AAaA,MAAMA,oBAA4C,GAAG,OACnDC,UADmD,EAEnDC,OAFmD,KAGhD;EACH,MAAMC,IAAI,GAAG,MAAM,IAAAC,mBAAA,EAAWH,UAAX,EAAuBC,OAAO,CAACC,IAA/B,CAAnB;EACA,MAAME,IAAI,GAAG,IAAAC,uBAAA,EAAeJ,OAAf,CAAb;EAEA,MAAMK,eAAe,GAAG,MAAMC,oBAAA,CAAOR,oBAAP,CAC5BC,UAD4B,EAE5BE,IAF4B,EAG5BE,IAAI,CAACI,IAHuB,EAI5BJ,IAAI,CAACK,EAJuB,EAK5BL,IAAI,CAACM,KALuB,EAM5BN,IAAI,CAACO,SANuB,CAA9B;EASA,OAAOL,eAAe,CAACM,GAAhB,CAAoBC,0BAApB,CAAP;AACD,CAjBD;;eAmBed,oB"}
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _nativeTypes = _interopRequireDefault(require("../native-types"));
9
+
10
+ var _ensureUnit = _interopRequireDefault(require("./ensureUnit"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ async function queryStatisticsForQuantity(identifier, options, from, to, unit) {
15
+ const actualUnit = await (0, _ensureUnit.default)(identifier, unit);
16
+ const toDate = to || new Date();
17
+ const {
18
+ mostRecentQuantityDateInterval,
19
+ ...rawResponse
20
+ } = await _nativeTypes.default.queryStatisticsForQuantity(identifier, actualUnit, from.toISOString(), toDate.toISOString(), options);
21
+ const response = { ...rawResponse,
22
+ ...(mostRecentQuantityDateInterval ? {
23
+ mostRecentQuantityDateInterval: {
24
+ from: new Date(mostRecentQuantityDateInterval.from),
25
+ to: new Date(mostRecentQuantityDateInterval.to)
26
+ }
27
+ } : {})
28
+ };
29
+ return response;
30
+ }
31
+
32
+ var _default = queryStatisticsForQuantity;
33
+ exports.default = _default;
34
+ //# sourceMappingURL=queryStatisticsForQuantity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["queryStatisticsForQuantity","identifier","options","from","to","unit","actualUnit","ensureUnit","toDate","Date","mostRecentQuantityDateInterval","rawResponse","Native","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;;AACA;;;;AAIA,eAAeA,0BAAf,CACEC,UADF,EAEEC,OAFF,EAGEC,IAHF,EAIEC,EAJF,EAKEC,IALF,EAME;EACA,MAAMC,UAAU,GAAG,MAAM,IAAAC,mBAAA,EAAWN,UAAX,EAAuBI,IAAvB,CAAzB;EACA,MAAMG,MAAM,GAAGJ,EAAE,IAAI,IAAIK,IAAJ,EAArB;EACA,MAAM;IAAEC,8BAAF;IAAkC,GAAGC;EAArC,IAAqD,MAAMC,oBAAA,CAAOZ,0BAAP,CAC/DC,UAD+D,EAE/DK,UAF+D,EAG/DH,IAAI,CAACU,WAAL,EAH+D,EAI/DL,MAAM,CAACK,WAAP,EAJ+D,EAK/DX,OAL+D,CAAjE;EAQA,MAAMY,QAAQ,GAAG,EACf,GAAGH,WADY;IAEf,IAAID,8BAA8B,GAC9B;MACAA,8BAA8B,EAAE;QAC9BP,IAAI,EAAE,IAAIM,IAAJ,CAASC,8BAA8B,CAACP,IAAxC,CADwB;QAE9BC,EAAE,EAAE,IAAIK,IAAJ,CAASC,8BAA8B,CAACN,EAAxC;MAF0B;IADhC,CAD8B,GAO9B,EAPJ;EAFe,CAAjB;EAYA,OAAOU,QAAP;AACD;;eAEcd,0B"}