@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.
- package/ios/ReactNativeHealthkit.xcodeproj/project.xcworkspace/xcuserdata/robertherber.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +41 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +29 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +27 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +43 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js +60 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +35 -0
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js +37 -0
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/commonjs/index.ios.js +66 -394
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +2 -15
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +170 -78
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js +13 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +15 -0
- package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -0
- package/lib/commonjs/utils/deserializeCorrelation.js +32 -0
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -0
- package/lib/commonjs/utils/deserializeSample.js +17 -0
- package/lib/commonjs/utils/deserializeSample.js.map +1 -0
- package/lib/commonjs/utils/deserializeWorkout.js +17 -0
- package/lib/commonjs/utils/deserializeWorkout.js.map +1 -0
- package/lib/commonjs/utils/ensureMetadata.js +14 -0
- package/lib/commonjs/utils/ensureMetadata.js.map +1 -0
- package/lib/commonjs/utils/ensureUnit.js +23 -0
- package/lib/commonjs/utils/ensureUnit.js.map +1 -0
- package/lib/commonjs/utils/getDateOfBirth.js +19 -0
- package/lib/commonjs/utils/getDateOfBirth.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +22 -0
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js +24 -0
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnit.js +19 -0
- package/lib/commonjs/utils/getPreferredUnit.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnits.js +19 -0
- package/lib/commonjs/utils/getPreferredUnits.js.map +1 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +46 -0
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +25 -0
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/commonjs/utils/prepareOptions.js +27 -0
- package/lib/commonjs/utils/prepareOptions.js.map +1 -0
- package/lib/commonjs/utils/queryCategorySamples.js +24 -0
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js +24 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/commonjs/utils/queryQuantitySamples.js +27 -0
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +34 -0
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/commonjs/utils/queryWorkouts.js +30 -0
- package/lib/commonjs/utils/queryWorkouts.js.map +1 -0
- package/lib/commonjs/utils/requestAuthorization.js +25 -0
- package/lib/commonjs/utils/requestAuthorization.js.map +1 -0
- package/lib/commonjs/utils/saveCategorySample.js +21 -0
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -0
- package/lib/commonjs/utils/saveCorrelationSample.js +24 -0
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -0
- package/lib/commonjs/utils/saveQuantitySample.js +21 -0
- package/lib/commonjs/utils/saveQuantitySample.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +25 -0
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -0
- package/lib/commonjs/utils/serializeDate.js +12 -0
- package/lib/commonjs/utils/serializeDate.js.map +1 -0
- package/lib/commonjs/utils/subscribeToChanges.js +37 -0
- package/lib/commonjs/utils/subscribeToChanges.js.map +1 -0
- package/lib/module/hooks/useHealthkitAuthorization.js +29 -0
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js +18 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -0
- package/lib/module/hooks/useMostRecentCategorySample.js +15 -0
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js +30 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -0
- package/lib/module/hooks/useMostRecentWorkout.js +47 -0
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -0
- package/lib/module/hooks/useStatisticsForQuantity.js +23 -0
- package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -0
- package/lib/module/hooks/useSubscribeToChanges.js +26 -0
- package/lib/module/hooks/useSubscribeToChanges.js.map +1 -0
- package/lib/module/index.ios.js +32 -370
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +3 -5
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +154 -74
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +15 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.js +7 -0
- package/lib/module/utils/deserializeCategorySample.js.map +1 -0
- package/lib/module/utils/deserializeCorrelation.js +21 -0
- package/lib/module/utils/deserializeCorrelation.js.map +1 -0
- package/lib/module/utils/deserializeSample.js +9 -0
- package/lib/module/utils/deserializeSample.js.map +1 -0
- package/lib/module/utils/deserializeWorkout.js +9 -0
- package/lib/module/utils/deserializeWorkout.js.map +1 -0
- package/lib/module/utils/ensureMetadata.js +6 -0
- package/lib/module/utils/ensureMetadata.js.map +1 -0
- package/lib/module/utils/ensureUnit.js +13 -0
- package/lib/module/utils/ensureUnit.js.map +1 -0
- package/lib/module/utils/getDateOfBirth.js +9 -0
- package/lib/module/utils/getDateOfBirth.js.map +1 -0
- package/lib/module/utils/getMostRecentCategorySample.js +12 -0
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -0
- package/lib/module/utils/getMostRecentQuantitySample.js +12 -0
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -0
- package/lib/module/utils/getMostRecentWorkout.js +14 -0
- package/lib/module/utils/getMostRecentWorkout.js.map +1 -0
- package/lib/module/utils/getPreferredUnit.js +9 -0
- package/lib/module/utils/getPreferredUnit.js.map +1 -0
- package/lib/module/utils/getPreferredUnits.js +9 -0
- package/lib/module/utils/getPreferredUnits.js.map +1 -0
- package/lib/module/utils/getPreferredUnitsTyped.js +34 -0
- package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js +15 -0
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -0
- package/lib/module/utils/prepareOptions.js +17 -0
- package/lib/module/utils/prepareOptions.js.map +1 -0
- package/lib/module/utils/queryCategorySamples.js +12 -0
- package/lib/module/utils/queryCategorySamples.js.map +1 -0
- package/lib/module/utils/queryCorrelationSamples.js +12 -0
- package/lib/module/utils/queryCorrelationSamples.js.map +1 -0
- package/lib/module/utils/queryQuantitySamples.js +14 -0
- package/lib/module/utils/queryQuantitySamples.js.map +1 -0
- package/lib/module/utils/queryStatisticsForQuantity.js +23 -0
- package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -0
- package/lib/module/utils/queryWorkouts.js +17 -0
- package/lib/module/utils/queryWorkouts.js.map +1 -0
- package/lib/module/utils/requestAuthorization.js +15 -0
- package/lib/module/utils/requestAuthorization.js.map +1 -0
- package/lib/module/utils/saveCategorySample.js +11 -0
- package/lib/module/utils/saveCategorySample.js.map +1 -0
- package/lib/module/utils/saveCorrelationSample.js +13 -0
- package/lib/module/utils/saveCorrelationSample.js.map +1 -0
- package/lib/module/utils/saveQuantitySample.js +11 -0
- package/lib/module/utils/saveQuantitySample.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +14 -0
- package/lib/module/utils/saveWorkoutSample.js.map +1 -0
- package/lib/module/utils/serializeDate.js +4 -0
- package/lib/module/utils/serializeDate.js.map +1 -0
- package/lib/module/utils/subscribeToChanges.js +25 -0
- package/lib/module/utils/subscribeToChanges.js.map +1 -0
- package/lib/typescript/example-expo/App.d.ts +2 -0
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +3 -0
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +2 -0
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +4 -0
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +7 -0
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +4 -0
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +3 -0
- package/lib/typescript/src/index.d.ts +2 -3
- package/lib/typescript/src/index.ios.d.ts +48 -3
- package/lib/typescript/src/native-types.d.ts +169 -65
- package/lib/typescript/src/types.d.ts +14 -90
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeSample.d.ts +4 -0
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +4 -0
- package/lib/typescript/src/utils/ensureMetadata.d.ts +2 -0
- package/lib/typescript/src/utils/ensureUnit.d.ts +3 -0
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +2 -0
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +3 -0
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +5 -0
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +4 -0
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +9 -0
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/prepareOptions.d.ts +8 -0
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +5 -0
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +7 -0
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +14 -0
- package/lib/typescript/src/utils/queryWorkouts.d.ts +4 -0
- package/lib/typescript/src/utils/requestAuthorization.d.ts +3 -0
- package/lib/typescript/src/utils/saveCategorySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +8 -0
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +7 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +7 -0
- package/lib/typescript/src/utils/serializeDate.d.ts +2 -0
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +3 -0
- package/package.json +17 -6
- package/src/hooks/useHealthkitAuthorization.ts +39 -0
- package/src/hooks/useIsHealthDataAvailable.ts +17 -0
- package/src/hooks/useMostRecentCategorySample.ts +24 -0
- package/src/hooks/useMostRecentQuantitySample.ts +39 -0
- package/src/hooks/useMostRecentWorkout.ts +60 -0
- package/src/hooks/useStatisticsForQuantity.ts +42 -0
- package/src/hooks/useSubscribeToChanges.ts +31 -0
- package/src/index.ios.tsx +36 -569
- package/src/index.tsx +5 -7
- package/src/native-types.ts +213 -74
- package/src/types.ts +41 -152
- package/src/utils/deserializeCategorySample.ts +12 -0
- package/src/utils/deserializeCorrelation.ts +28 -0
- package/src/utils/deserializeSample.ts +17 -0
- package/src/utils/deserializeWorkout.ts +14 -0
- package/src/utils/ensureMetadata.ts +5 -0
- package/src/utils/ensureUnit.ts +19 -0
- package/src/utils/getDateOfBirth.ts +8 -0
- package/src/utils/getMostRecentCategorySample.ts +18 -0
- package/src/utils/getMostRecentQuantitySample.ts +19 -0
- package/src/utils/getMostRecentWorkout.ts +27 -0
- package/src/utils/getPreferredUnit.ts +14 -0
- package/src/utils/getPreferredUnits.ts +14 -0
- package/src/utils/getPreferredUnitsTyped.ts +38 -0
- package/src/utils/getRequestStatusForAuthorization.ts +21 -0
- package/src/utils/prepareOptions.ts +15 -0
- package/src/utils/queryCategorySamples.ts +29 -0
- package/src/utils/queryCorrelationSamples.ts +29 -0
- package/src/utils/queryQuantitySamples.ts +36 -0
- package/src/utils/queryStatisticsForQuantity.ts +38 -0
- package/src/utils/queryWorkouts.ts +28 -0
- package/src/utils/requestAuthorization.ts +18 -0
- package/src/utils/saveCategorySample.ts +27 -0
- package/src/utils/saveCorrelationSample.ts +34 -0
- package/src/utils/saveQuantitySample.ts +29 -0
- package/src/utils/saveWorkoutSample.ts +28 -0
- package/src/utils/serializeDate.ts +3 -0
- package/src/utils/subscribeToChanges.ts +32 -0
|
@@ -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;;AAED,eAAeJ,iBAAf"}
|
|
@@ -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;;AAED,eAAeJ,kBAAf"}
|
|
@@ -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;;AAED,eAAeD,cAAf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Native from '../native-types';
|
|
2
|
+
|
|
3
|
+
const ensureUnit = async (type, providedUnit) => {
|
|
4
|
+
if (providedUnit) {
|
|
5
|
+
return providedUnit;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const unit = await Native.getPreferredUnits([type]);
|
|
9
|
+
return unit[type];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default ensureUnit;
|
|
13
|
+
//# sourceMappingURL=ensureUnit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","ensureUnit","type","providedUnit","unit","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,OAAOA,MAAP,MAAmB,iBAAnB;;AAIA,MAAMC,UAAU,GAAG,OAIjBC,IAJiB,EAKjBC,YALiB,KAMd;EACH,IAAIA,YAAJ,EAAkB;IAChB,OAAOA,YAAP;EACD;;EACD,MAAMC,IAAI,GAAG,MAAMJ,MAAM,CAACK,iBAAP,CAAyB,CAACH,IAAD,CAAzB,CAAnB;EACA,OAAOE,IAAI,CAACF,IAAD,CAAX;AACD,CAZD;;AAcA,eAAeD,UAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","getDateOfBirth","dateOfBirth","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,OAAOA,MAAP,MAAmB,iBAAnB;;AAEA,MAAMC,cAAc,GAAG,YAAY;EACjC,MAAMC,WAAW,GAAG,MAAMF,MAAM,CAACC,cAAP,EAA1B;EACA,OAAO,IAAIE,IAAJ,CAASD,WAAT,CAAP;AACD,CAHD;;AAKA,eAAeD,cAAf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import queryCategorySamples from './queryCategorySamples';
|
|
2
|
+
|
|
3
|
+
async function getMostRecentCategorySample(identifier) {
|
|
4
|
+
const samples = await queryCategorySamples(identifier, {
|
|
5
|
+
limit: 1,
|
|
6
|
+
ascending: false
|
|
7
|
+
});
|
|
8
|
+
return samples[0] || null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default getMostRecentCategorySample;
|
|
12
|
+
//# sourceMappingURL=getMostRecentCategorySample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["queryCategorySamples","getMostRecentCategorySample","identifier","samples","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,OAAOA,oBAAP,MAAiC,wBAAjC;;AAIA,eAAeC,2BAAf,CAGEC,UAHF,EAIE;EACA,MAAMC,OAAO,GAAG,MAAMH,oBAAoB,CAACE,UAAD,EAAa;IACrDE,KAAK,EAAE,CAD8C;IAErDC,SAAS,EAAE;EAF0C,CAAb,CAA1C;EAKA,OAAOF,OAAO,CAAC,CAAD,CAAP,IAAc,IAArB;AACD;;AAED,eAAeF,2BAAf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import queryQuantitySamples from './queryQuantitySamples';
|
|
2
|
+
|
|
3
|
+
async function getMostRecentQuantitySample(identifier, unit) {
|
|
4
|
+
const samples = await queryQuantitySamples(identifier, {
|
|
5
|
+
limit: 1,
|
|
6
|
+
unit
|
|
7
|
+
});
|
|
8
|
+
return samples[0] || null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default getMostRecentQuantitySample;
|
|
12
|
+
//# sourceMappingURL=getMostRecentQuantitySample.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["queryQuantitySamples","getMostRecentQuantitySample","identifier","unit","samples","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,OAAOA,oBAAP,MAAiC,wBAAjC;;AAIA,eAAeC,2BAAf,CAIEC,UAJF,EAKEC,IALF,EAME;EACA,MAAMC,OAAO,GAAG,MAAMJ,oBAAoB,CAACE,UAAD,EAAa;IACrDG,KAAK,EAAE,CAD8C;IAErDF;EAFqD,CAAb,CAA1C;EAIA,OAAOC,OAAO,CAAC,CAAD,CAAP,IAAc,IAArB;AACD;;AAED,eAAeH,2BAAf"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import queryWorkouts from './queryWorkouts';
|
|
2
|
+
|
|
3
|
+
const getMostRecentWorkout = async options => {
|
|
4
|
+
const workouts = await queryWorkouts({
|
|
5
|
+
limit: 1,
|
|
6
|
+
ascending: false,
|
|
7
|
+
energyUnit: options === null || options === void 0 ? void 0 : options.energyUnit,
|
|
8
|
+
distanceUnit: options === null || options === void 0 ? void 0 : options.distanceUnit
|
|
9
|
+
});
|
|
10
|
+
return workouts[0] || null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default getMostRecentWorkout;
|
|
14
|
+
//# sourceMappingURL=getMostRecentWorkout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["queryWorkouts","getMostRecentWorkout","options","workouts","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,OAAOA,aAAP,MAA0B,iBAA1B;;AAeA,MAAMC,oBAA4C,GAAG,MAAOC,OAAP,IAAmB;EACtE,MAAMC,QAAQ,GAAG,MAAMH,aAAa,CAAC;IACnCI,KAAK,EAAE,CAD4B;IAEnCC,SAAS,EAAE,KAFwB;IAGnCC,UAAU,EAAEJ,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEI,UAHc;IAInCC,YAAY,EAAEL,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK;EAJY,CAAD,CAApC;EAOA,OAAOJ,QAAQ,CAAC,CAAD,CAAR,IAAe,IAAtB;AACD,CATD;;AAWA,eAAeF,oBAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["getPreferredUnits","getPreferredUnit","type","unit"],"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,OAAOA,iBAAP,MAA8B,qBAA9B;;AAQA,MAAMC,gBAAoC,GAAG,MAAOC,IAAP,IAAgB;EAC3D,MAAM,CAACC,IAAD,IAAS,MAAMH,iBAAiB,CAAC,CAACE,IAAD,CAAD,CAAtC;EACA,OAAOC,IAAP;AACD,CAHD;;AAKA,eAAeF,gBAAf"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Native from '../native-types';
|
|
2
|
+
|
|
3
|
+
const getPreferredUnits = async identifiers => {
|
|
4
|
+
const units = await Native.getPreferredUnits(identifiers);
|
|
5
|
+
return identifiers.map(i => units[i]);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default getPreferredUnits;
|
|
9
|
+
//# sourceMappingURL=getPreferredUnits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","getPreferredUnits","identifiers","units","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,OAAOA,MAAP,MAAmB,iBAAnB;;AAQA,MAAMC,iBAAsC,GAAG,MAAOC,WAAP,IAAuB;EACpE,MAAMC,KAAK,GAAG,MAAMH,MAAM,CAACC,iBAAP,CAAyBC,WAAzB,CAApB;EACA,OAAOA,WAAW,CAACE,GAAZ,CAAiBC,CAAD,IAAOF,KAAK,CAACE,CAAD,CAA5B,CAAP;AACD,CAHD;;AAKA,eAAeJ,iBAAf"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Native, { HKQuantityTypeIdentifier, UnitOfEnergy, UnitOfLength } from '../native-types';
|
|
2
|
+
|
|
3
|
+
async function getPreferredUnitsTyped(options) {
|
|
4
|
+
let energyUnit = options === null || options === void 0 ? void 0 : options.energyUnit;
|
|
5
|
+
let distanceUnit = options === null || options === void 0 ? void 0 : options.distanceUnit;
|
|
6
|
+
|
|
7
|
+
if (!energyUnit || !distanceUnit) {
|
|
8
|
+
const units = await Native.getPreferredUnits([HKQuantityTypeIdentifier.distanceWalkingRunning, HKQuantityTypeIdentifier.activeEnergyBurned]);
|
|
9
|
+
|
|
10
|
+
if (!energyUnit) {
|
|
11
|
+
energyUnit = units[HKQuantityTypeIdentifier.activeEnergyBurned];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!distanceUnit) {
|
|
15
|
+
distanceUnit = units[HKQuantityTypeIdentifier.distanceWalkingRunning];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!energyUnit) {
|
|
20
|
+
energyUnit = UnitOfEnergy.Kilocalories;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!distanceUnit) {
|
|
24
|
+
distanceUnit = UnitOfLength.Meter;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
energyUnit,
|
|
29
|
+
distanceUnit
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default getPreferredUnitsTyped;
|
|
34
|
+
//# sourceMappingURL=getPreferredUnitsTyped.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","HKQuantityTypeIdentifier","UnitOfEnergy","UnitOfLength","getPreferredUnitsTyped","options","energyUnit","distanceUnit","units","getPreferredUnits","distanceWalkingRunning","activeEnergyBurned","Kilocalories","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,OAAOA,MAAP,IAAiBC,wBAAjB,EAA2CC,YAA3C,EAAyDC,YAAzD,QAA6E,iBAA7E;;AAIA,eAAeC,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,MAAMR,MAAM,CAACS,iBAAP,CAAyB,CAC3CR,wBAAwB,CAACS,sBADkB,EAE3CT,wBAAwB,CAACU,kBAFkB,CAAzB,CAApB;;IAIA,IAAI,CAACL,UAAL,EAAiB;MACfA,UAAU,GAAGE,KAAK,CAACP,wBAAwB,CAACU,kBAA1B,CAAlB;IAGD;;IACD,IAAI,CAACJ,YAAL,EAAmB;MACjBA,YAAY,GAAGC,KAAK,CAACP,wBAAwB,CAACS,sBAA1B,CAApB;IAGD;EACF;;EAED,IAAI,CAACJ,UAAL,EAAiB;IACfA,UAAU,GAAGJ,YAAY,CAACU,YAA1B;EACD;;EACD,IAAI,CAACL,YAAL,EAAmB;IACjBA,YAAY,GAAGJ,YAAY,CAACU,KAA5B;EACD;;EACD,OAAO;IAAEP,UAAF;IAAcC;EAAd,CAAP;AACD;;AAED,eAAeH,sBAAf"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Native from '../native-types';
|
|
2
|
+
|
|
3
|
+
const getRequestStatusForAuthorization = 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.getRequestStatusForAuthorization(writePermissions, readPermissions);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default getRequestStatusForAuthorization;
|
|
15
|
+
//# sourceMappingURL=getRequestStatusForAuthorization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Native","getRequestStatusForAuthorization","read","write","readPermissions","reduce","obj","cur","writePermissions"],"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,OAAOA,MAAP,MAAmB,iBAAnB;;AAMA,MAAMC,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,OAAOP,MAAM,CAACC,gCAAP,CACLO,gBADK,EAELJ,eAFK,CAAP;AAID,CAZD;;AAcA,eAAeH,gCAAf"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import serializeDate from './serializeDate';
|
|
2
|
+
|
|
3
|
+
const prepareOptions = options => {
|
|
4
|
+
const limit = !options.limit || options.limit === Infinity ? 0 : options.limit;
|
|
5
|
+
const ascending = options.ascending ?? limit === 0;
|
|
6
|
+
const from = serializeDate(options.from);
|
|
7
|
+
const to = serializeDate(options.to);
|
|
8
|
+
return {
|
|
9
|
+
limit,
|
|
10
|
+
ascending,
|
|
11
|
+
from,
|
|
12
|
+
to
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default prepareOptions;
|
|
17
|
+
//# sourceMappingURL=prepareOptions.js.map
|
|
@@ -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 @@
|
|
|
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,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,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;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type
|
|
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;
|