@kingstinct/react-native-healthkit 6.1.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -5
- package/app.plugin.js +69 -0
- package/ios/Constants.swift +28 -0
- package/ios/Helpers.swift +152 -0
- package/ios/ReactNativeHealthkit.m +24 -0
- package/ios/ReactNativeHealthkit.swift +534 -728
- package/ios/Serializers.swift +206 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -6
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +2 -9
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +1 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -6
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +1 -6
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +1 -7
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -10
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -10
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/hooks/useSources.js +0 -5
- package/lib/commonjs/hooks/useSources.js.map +1 -1
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +1 -7
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -1
- package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -8
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -1
- package/lib/commonjs/index.ios.js +6 -33
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +7 -11
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +3 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +166 -250
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/test-utils.js +1 -3
- package/lib/commonjs/test-utils.js.map +1 -1
- package/lib/commonjs/types.js +0 -2
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deleteQuantitySample.js +0 -4
- package/lib/commonjs/utils/deleteQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/deleteSamples.js +0 -4
- package/lib/commonjs/utils/deleteSamples.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +2 -3
- package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.test.js +3 -5
- package/lib/commonjs/utils/deserializeCategorySample.test.js.map +1 -1
- package/lib/commonjs/utils/deserializeCorrelation.js +2 -7
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -1
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +2 -3
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
- package/lib/commonjs/utils/deserializeSample.js +2 -3
- package/lib/commonjs/utils/deserializeSample.js.map +1 -1
- package/lib/commonjs/utils/deserializeWorkout.js +2 -3
- package/lib/commonjs/utils/deserializeWorkout.js.map +1 -1
- package/lib/commonjs/utils/ensureMetadata.js +0 -2
- package/lib/commonjs/utils/ensureMetadata.js.map +1 -1
- package/lib/commonjs/utils/ensureUnit.js +0 -5
- package/lib/commonjs/utils/ensureUnit.js.map +1 -1
- package/lib/commonjs/utils/getDateOfBirth.js +0 -4
- package/lib/commonjs/utils/getDateOfBirth.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +1 -5
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +1 -5
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentWorkout.js +0 -4
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnit.js +0 -4
- package/lib/commonjs/utils/getPreferredUnit.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnits.js +0 -4
- package/lib/commonjs/utils/getPreferredUnits.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -11
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -1
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +4 -6
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -1
- package/lib/commonjs/utils/prepareOptions.js +0 -4
- package/lib/commonjs/utils/prepareOptions.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamples.js +3 -14
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +22 -0
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +1 -0
- package/lib/commonjs/utils/queryCorrelationSamples.js +1 -7
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +3 -13
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +1 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +22 -0
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -0
- package/lib/commonjs/utils/queryQuantitySamples.js +3 -15
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -1
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +24 -0
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +1 -0
- package/lib/commonjs/utils/querySources.js +0 -4
- package/lib/commonjs/utils/querySources.js.map +1 -1
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +3 -7
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -1
- package/lib/commonjs/utils/queryWorkouts.js +1 -8
- package/lib/commonjs/utils/queryWorkouts.js.map +1 -1
- package/lib/commonjs/utils/requestAuthorization.js +4 -6
- package/lib/commonjs/utils/requestAuthorization.js.map +1 -1
- package/lib/commonjs/utils/saveCategorySample.js +0 -4
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -1
- package/lib/commonjs/utils/saveCorrelationSample.js +3 -7
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -1
- package/lib/commonjs/utils/saveQuantitySample.js +0 -4
- package/lib/commonjs/utils/saveQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +3 -8
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.js +0 -2
- package/lib/commonjs/utils/serializeDate.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.test.js +0 -2
- package/lib/commonjs/utils/serializeDate.test.js.map +1 -1
- package/lib/commonjs/utils/subscribeToChanges.js +0 -7
- package/lib/commonjs/utils/subscribeToChanges.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +0 -2
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js.map +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js +0 -3
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +1 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +1 -3
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +0 -5
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentWorkout.js +0 -5
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/module/hooks/useSources.js +0 -2
- package/lib/module/hooks/useSources.js.map +1 -1
- package/lib/module/hooks/useStatisticsForQuantity.js +1 -3
- package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -1
- package/lib/module/hooks/useSubscribeToChanges.js +0 -5
- package/lib/module/hooks/useSubscribeToChanges.js.map +1 -1
- package/lib/module/index.ios.js +6 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +8 -8
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +3 -0
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +134 -201
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/test-utils.js +0 -2
- package/lib/module/test-utils.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deleteQuantitySample.js +0 -2
- package/lib/module/utils/deleteQuantitySample.js.map +1 -1
- package/lib/module/utils/deleteSamples.js +0 -2
- package/lib/module/utils/deleteSamples.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.js +2 -2
- package/lib/module/utils/deserializeCategorySample.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.test.js +3 -2
- package/lib/module/utils/deserializeCategorySample.test.js.map +1 -1
- package/lib/module/utils/deserializeCorrelation.js +2 -4
- package/lib/module/utils/deserializeCorrelation.js.map +1 -1
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js +2 -2
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
- package/lib/module/utils/deserializeSample.js +2 -2
- package/lib/module/utils/deserializeSample.js.map +1 -1
- package/lib/module/utils/deserializeWorkout.js +2 -2
- package/lib/module/utils/deserializeWorkout.js.map +1 -1
- package/lib/module/utils/ensureMetadata.js +0 -1
- package/lib/module/utils/ensureMetadata.js.map +1 -1
- package/lib/module/utils/ensureUnit.js +0 -3
- package/lib/module/utils/ensureUnit.js.map +1 -1
- package/lib/module/utils/getDateOfBirth.js +0 -2
- package/lib/module/utils/getDateOfBirth.js.map +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js +1 -3
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +1 -3
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/module/utils/getMostRecentWorkout.js +0 -2
- package/lib/module/utils/getMostRecentWorkout.js.map +1 -1
- package/lib/module/utils/getPreferredUnit.js +0 -2
- package/lib/module/utils/getPreferredUnit.js.map +1 -1
- package/lib/module/utils/getPreferredUnits.js +0 -2
- package/lib/module/utils/getPreferredUnits.js.map +1 -1
- package/lib/module/utils/getPreferredUnitsTyped.js +0 -8
- package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -1
- package/lib/module/utils/getRequestStatusForAuthorization.js +4 -4
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -1
- package/lib/module/utils/prepareOptions.js +0 -2
- package/lib/module/utils/prepareOptions.js.map +1 -1
- package/lib/module/utils/queryCategorySamples.js +3 -10
- package/lib/module/utils/queryCategorySamples.js.map +1 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js +14 -0
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +1 -0
- package/lib/module/utils/queryCorrelationSamples.js +1 -3
- package/lib/module/utils/queryCorrelationSamples.js.map +1 -1
- package/lib/module/utils/queryHeartbeatSeriesSamples.js +3 -9
- package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +1 -1
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +14 -0
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -0
- package/lib/module/utils/queryQuantitySamples.js +3 -10
- package/lib/module/utils/queryQuantitySamples.js.map +1 -1
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js +16 -0
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +1 -0
- package/lib/module/utils/querySources.js +0 -2
- package/lib/module/utils/querySources.js.map +1 -1
- package/lib/module/utils/queryStatisticsForQuantity.js +3 -4
- package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -1
- package/lib/module/utils/queryWorkouts.js +1 -3
- package/lib/module/utils/queryWorkouts.js.map +1 -1
- package/lib/module/utils/requestAuthorization.js +4 -4
- package/lib/module/utils/requestAuthorization.js.map +1 -1
- package/lib/module/utils/saveCategorySample.js +0 -2
- package/lib/module/utils/saveCategorySample.js.map +1 -1
- package/lib/module/utils/saveCorrelationSample.js +3 -4
- package/lib/module/utils/saveCorrelationSample.js.map +1 -1
- package/lib/module/utils/saveQuantitySample.js +0 -2
- package/lib/module/utils/saveQuantitySample.js.map +1 -1
- package/lib/module/utils/saveWorkoutSample.js +3 -5
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/utils/serializeDate.js +0 -1
- package/lib/module/utils/serializeDate.js.map +1 -1
- package/lib/module/utils/serializeDate.test.js.map +1 -1
- package/lib/module/utils/subscribeToChanges.js +0 -3
- package/lib/module/utils/subscribeToChanges.js.map +1 -1
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +2 -3
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +2 -3
- package/lib/typescript/src/index.ios.d.ts +4 -1
- package/lib/typescript/src/native-types.d.ts +66 -63
- package/lib/typescript/src/types.d.ts +3 -3
- package/lib/typescript/src/utils/deleteQuantitySample.d.ts +1 -1
- package/lib/typescript/src/utils/deleteSamples.d.ts +1 -1
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +1 -1
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +1 -1
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +1 -1
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +1 -1
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +1 -1
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +3 -8
- package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +10 -0
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +1 -1
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +2 -2
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +10 -0
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +4 -9
- package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +12 -0
- package/lib/typescript/src/utils/querySources.d.ts +1 -1
- package/package.json +20 -18
- package/src/hooks/useHealthkitAuthorization.test.ts +1 -1
- package/src/hooks/useIsHealthDataAvailable.test.ts +1 -1
- package/src/hooks/useMostRecentCategorySample.ts +3 -4
- package/src/hooks/useMostRecentQuantitySample.ts +2 -3
- package/src/hooks/useStatisticsForQuantity.ts +1 -1
- package/src/index.ios.tsx +6 -0
- package/src/index.tsx +10 -5
- package/src/jest.setup.ts +3 -0
- package/src/native-types.ts +28 -7
- package/src/utils/deserializeCategorySample.test.ts +1 -1
- package/src/utils/getMostRecentCategorySample.ts +1 -1
- package/src/utils/getMostRecentQuantitySample.ts +1 -1
- package/src/utils/queryCategorySamples.ts +6 -18
- package/src/utils/queryCategorySamplesWithAnchor.ts +39 -0
- package/src/utils/queryCorrelationSamples.ts +2 -2
- package/src/utils/queryHeartbeatSeriesSamples.ts +3 -8
- package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +33 -0
- package/src/utils/queryQuantitySamples.ts +8 -18
- package/src/utils/queryQuantitySamplesWithAnchor.ts +46 -0
- package/src/utils/queryStatisticsForQuantity.ts +1 -1
- package/src/utils/queryWorkouts.ts +1 -1
- package/src/utils/saveCorrelationSample.ts +1 -1
- package/src/utils/saveWorkoutSample.ts +1 -1
- package/android/.project +0 -34
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -13
- package/android/build.gradle +0 -130
- package/android/gradle.properties +0 -4
- package/android/src/main/AndroidManifest.xml +0 -4
- package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitModule.kt +0 -24
- package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitPackage.kt +0 -20
|
@@ -8,7 +8,7 @@ export interface HKCategorySample<T extends HKCategoryTypeIdentifier = HKCategor
|
|
|
8
8
|
readonly startDate: Date;
|
|
9
9
|
readonly endDate: Date;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type GenericQueryOptions = {
|
|
12
12
|
readonly from?: Date;
|
|
13
13
|
readonly to?: Date;
|
|
14
14
|
readonly limit?: number;
|
|
@@ -40,8 +40,8 @@ export interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdent
|
|
|
40
40
|
readonly to: Date;
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
export
|
|
44
|
-
export
|
|
43
|
+
export type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
|
|
44
|
+
export type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>;
|
|
45
45
|
export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier> extends Omit<HKCorrelationRaw<TIdentifier>, 'endDate' | 'objects' | 'startDate'> {
|
|
46
46
|
readonly objects: readonly (HKCategorySample | HKQuantitySample)[];
|
|
47
47
|
readonly startDate: Date;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier } from '../native-types';
|
|
2
|
-
export
|
|
2
|
+
export type DeleteQuantitySampleFn = <TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, uuid: string) => Promise<boolean>;
|
|
3
3
|
declare const deleteQuantitySample: DeleteQuantitySampleFn;
|
|
4
4
|
export default deleteQuantitySample;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier } from '../native-types';
|
|
2
|
-
export
|
|
2
|
+
export type DeleteSamplesFn = <TIdentifier extends HKQuantityTypeIdentifier>(sample: {
|
|
3
3
|
readonly identifier: TIdentifier;
|
|
4
4
|
readonly startDate?: Date;
|
|
5
5
|
readonly endDate?: Date;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HKCategoryTypeIdentifier } from '../native-types';
|
|
2
|
-
declare function getMostRecentCategorySample<T extends HKCategoryTypeIdentifier>(identifier: T): Promise<import("
|
|
2
|
+
declare function getMostRecentCategorySample<T extends HKCategoryTypeIdentifier>(identifier: T): Promise<import("../native-types").HKCategorySampleRaw<T> | null>;
|
|
3
3
|
export default getMostRecentCategorySample;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
|
|
2
|
-
declare function getMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit): Promise<import("
|
|
2
|
+
declare function getMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit): Promise<import("../native-types").HKQuantitySampleRaw<TIdentifier, UnitForIdentifier<TIdentifier>> | null>;
|
|
3
3
|
export default getMostRecentQuantitySample;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnergyUnit, LengthUnit } from '../native-types';
|
|
2
2
|
import type { HKWorkout, QueryWorkoutsOptions } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type GetMostRecentWorkoutFn = <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => Promise<HKWorkout<TEnergy, TDistance> | null>;
|
|
4
4
|
declare const getMostRecentWorkout: GetMostRecentWorkoutFn;
|
|
5
5
|
export default getMostRecentWorkout;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier, HKUnit } from '../native-types';
|
|
2
|
-
export
|
|
2
|
+
export type GetPreferredUnitFn = (identifier: HKQuantityTypeIdentifier) => Promise<HKUnit | undefined>;
|
|
3
3
|
declare const getPreferredUnit: GetPreferredUnitFn;
|
|
4
4
|
export default getPreferredUnit;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier, HKUnit } from '../native-types';
|
|
2
|
-
export
|
|
2
|
+
export type GetPreferredUnitsFn = (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<readonly HKUnit[]>;
|
|
3
3
|
declare const getPreferredUnits: GetPreferredUnitsFn;
|
|
4
4
|
export default getPreferredUnits;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import type { HKCategoryTypeIdentifier,
|
|
2
|
-
import type { GenericQueryOptions
|
|
3
|
-
export
|
|
4
|
-
readonly samples: readonly HKCategorySample<T>[];
|
|
5
|
-
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
|
|
6
|
-
readonly newAnchor: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<QueryCategorySamplesResponse<T>>;
|
|
1
|
+
import type { HKCategoryTypeIdentifier, HKCategorySampleRaw } from '../native-types';
|
|
2
|
+
import type { GenericQueryOptions } from '../types';
|
|
3
|
+
export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
9
4
|
declare const queryCategorySamples: QueryCategorySamplesFn;
|
|
10
5
|
export default queryCategorySamples;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types';
|
|
2
|
+
import type { GenericQueryOptions, HKCategorySample } from '../types';
|
|
3
|
+
export type QueryCategorySamplesWithAnchorResponse<T extends HKCategoryTypeIdentifier> = {
|
|
4
|
+
readonly samples: readonly HKCategorySample<T>[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
8
|
+
export type QueryCategorySamplesWithAnchorFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryCategorySamplesWithAnchorResponse<T>>;
|
|
9
|
+
declare const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn;
|
|
10
|
+
export default queryCategorySamplesWithAnchor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HKCorrelationTypeIdentifier } from '../native-types';
|
|
2
2
|
import type { GenericQueryOptions, HKCorrelation } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type QueryCorrelationSamplesFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, options: Omit<GenericQueryOptions, 'anchor' | 'ascending' | 'limit'>) => Promise<readonly HKCorrelation<TIdentifier>[]>;
|
|
4
4
|
declare const queryCorrelationSamples: QueryCorrelationSamplesFn;
|
|
5
5
|
export default queryCorrelationSamples;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types';
|
|
2
2
|
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types';
|
|
3
|
-
export
|
|
3
|
+
export type QueryHeartbeatSeriesSamplesResponse = {
|
|
4
4
|
readonly samples: readonly HKHeartbeatSeriesSample[];
|
|
5
5
|
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
|
|
6
6
|
readonly newAnchor: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
8
|
+
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKHeartbeatSeriesSample[]>;
|
|
9
9
|
declare const queryHeartbeatSeriesSamples: QueryHeartbeatSeriesSamplesFn;
|
|
10
10
|
export default queryHeartbeatSeriesSamples;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types';
|
|
2
|
+
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types';
|
|
3
|
+
export type QueryHeartbeatSeriesSamplesResponse = {
|
|
4
|
+
readonly samples: readonly HKHeartbeatSeriesSample[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
8
|
+
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryHeartbeatSeriesSamplesResponse>;
|
|
9
|
+
declare const queryHeartbeatSeriesSamplesWithAnchor: QueryHeartbeatSeriesSamplesFn;
|
|
10
|
+
export default queryHeartbeatSeriesSamplesWithAnchor;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import type { HKQuantityTypeIdentifier, UnitForIdentifier,
|
|
2
|
-
import type { GenericQueryOptions
|
|
3
|
-
export
|
|
4
|
-
readonly samples: readonly HKQuantitySample<T>[];
|
|
5
|
-
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
|
|
6
|
-
readonly newAnchor: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: GenericQueryOptions & {
|
|
1
|
+
import type { HKQuantityTypeIdentifier, UnitForIdentifier, HKQuantitySampleRaw } from '../native-types';
|
|
2
|
+
import type { GenericQueryOptions } from '../types';
|
|
3
|
+
export type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: Omit<GenericQueryOptions, 'anchor'> & {
|
|
9
4
|
readonly unit?: TUnit;
|
|
10
|
-
}) => Promise<
|
|
5
|
+
}) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
11
6
|
declare const queryQuantitySamples: QueryQuantitySamplesFn;
|
|
12
7
|
export default queryQuantitySamples;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types';
|
|
2
|
+
import type { GenericQueryOptions, HKQuantitySample } from '../types';
|
|
3
|
+
export type QueryQuantitySamplesWithAnchorResponse<T extends HKQuantityTypeIdentifier> = {
|
|
4
|
+
readonly samples: readonly HKQuantitySample<T>[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
8
|
+
export type QueryQuantitySamplesWithAnchorFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, options: Omit<GenericQueryOptions, 'ascending'> & {
|
|
9
|
+
readonly unit?: TUnit;
|
|
10
|
+
}) => Promise<QueryQuantitySamplesWithAnchorResponse<TIdentifier>>;
|
|
11
|
+
declare const queryQuantitySamplesWithAnchor: QueryQuantitySamplesWithAnchorFn;
|
|
12
|
+
export default queryQuantitySamplesWithAnchor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier, HKSource, HKCategoryTypeIdentifier } from '../native-types';
|
|
2
|
-
export
|
|
2
|
+
export type QuerySourcesFn = <TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier>(identifier: TIdentifier) => Promise<readonly HKSource[]>;
|
|
3
3
|
declare const querySources: QuerySourcesFn;
|
|
4
4
|
export default querySources;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingstinct/react-native-healthkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "React Native bindings for HealthKit",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -10,26 +10,32 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"src",
|
|
12
12
|
"lib",
|
|
13
|
-
"android",
|
|
14
13
|
"ios",
|
|
15
14
|
"cpp",
|
|
16
15
|
"kingstinct-react-native-healthkit.podspec",
|
|
17
16
|
"!lib/typescript/example",
|
|
18
17
|
"!**/__tests__",
|
|
19
18
|
"!**/__fixtures__",
|
|
20
|
-
"!**/__mocks__"
|
|
19
|
+
"!**/__mocks__",
|
|
20
|
+
"app.plugin.js"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test-only": "jest",
|
|
24
24
|
"test": "concurrently \"yarn test-only\" \"yarn typecheck\" \"yarn lint\"",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --cache",
|
|
27
|
-
"prepare": "bob build",
|
|
27
|
+
"prepare": "bob build && husky install",
|
|
28
28
|
"release": "release-it",
|
|
29
29
|
"example": "yarn --cwd example",
|
|
30
30
|
"pods": "cd example && pod-install --quiet",
|
|
31
31
|
"bootstrap": "yarn example && yarn && yarn pods"
|
|
32
32
|
},
|
|
33
|
+
"lint-staged": {
|
|
34
|
+
"*.swift": "swiftlint ios --fix",
|
|
35
|
+
"*.ts": "eslint --fix",
|
|
36
|
+
"*.js": "eslint --fix",
|
|
37
|
+
"*.json": "eslint --fix"
|
|
38
|
+
},
|
|
33
39
|
"keywords": [
|
|
34
40
|
"react-native",
|
|
35
41
|
"ios",
|
|
@@ -51,15 +57,14 @@
|
|
|
51
57
|
"@expo/config-plugins": "^6.0.1",
|
|
52
58
|
"@graphql-eslint/eslint-plugin": ">=3",
|
|
53
59
|
"@release-it/conventional-changelog": "2",
|
|
54
|
-
"@testing-library/react-native": "
|
|
60
|
+
"@testing-library/react-native": "12",
|
|
55
61
|
"@types/jest": ">=26",
|
|
56
62
|
"@types/node": "^18.7.14",
|
|
57
|
-
"@types/react": "
|
|
58
|
-
"@types/react-native": "0.67",
|
|
63
|
+
"@types/react": "~18.0.27",
|
|
59
64
|
"@typescript-eslint/eslint-plugin": ">=5",
|
|
60
65
|
"@typescript-eslint/parser": ">=5",
|
|
61
66
|
"commitlint": "^17.1.1",
|
|
62
|
-
"concurrently": "
|
|
67
|
+
"concurrently": "8",
|
|
63
68
|
"eslint": ">=8",
|
|
64
69
|
"eslint-config-airbnb": ">=19",
|
|
65
70
|
"eslint-config-airbnb-base": ">=15",
|
|
@@ -82,26 +87,23 @@
|
|
|
82
87
|
"husky": "8",
|
|
83
88
|
"jest": ">=26",
|
|
84
89
|
"jest-environment-jsdom": "^29.0.2",
|
|
90
|
+
"lint-staged": "^13.2.2",
|
|
85
91
|
"metro-react-native-babel-preset": "^0.70.3",
|
|
86
92
|
"pod-install": "^0.1.0",
|
|
87
|
-
"react": "
|
|
88
|
-
"react-native": "0.
|
|
93
|
+
"react": "18.2.0",
|
|
94
|
+
"react-native": "0.71.8",
|
|
89
95
|
"react-native-builder-bob": "^0.18.1",
|
|
90
|
-
"react-test-renderer": "
|
|
96
|
+
"react-test-renderer": "18",
|
|
91
97
|
"release-it": "14",
|
|
98
|
+
"solidarity": "^3.0.4",
|
|
99
|
+
"solidarity-react-native": "^2.1.2",
|
|
92
100
|
"ts-node": "^10.9.1",
|
|
93
|
-
"typescript": "
|
|
101
|
+
"typescript": "^4.9.4"
|
|
94
102
|
},
|
|
95
103
|
"peerDependencies": {
|
|
96
104
|
"react": "*",
|
|
97
105
|
"react-native": "*"
|
|
98
106
|
},
|
|
99
|
-
"husky": {
|
|
100
|
-
"hooks": {
|
|
101
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
102
|
-
"pre-commit": "yarn lint && yarn typescript"
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
107
|
"commitlint": {
|
|
106
108
|
"extends": [
|
|
107
109
|
"@commitlint/config-conventional"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { renderHook, act } from '@testing-library/react-native'
|
|
2
2
|
|
|
3
|
+
import useHealthkitAuthorization from './useHealthkitAuthorization'
|
|
3
4
|
import Native, { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier } from '../native-types'
|
|
4
5
|
import waitForNextUpdate from '../test-utils'
|
|
5
|
-
import useHealthkitAuthorization from './useHealthkitAuthorization'
|
|
6
6
|
|
|
7
7
|
describe('useHealthkitAuthorization', () => {
|
|
8
8
|
test('should return shouldRequest', async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react-native'
|
|
2
2
|
|
|
3
|
+
import useIsHealthDataAvailable from './useIsHealthDataAvailable'
|
|
3
4
|
import Native from '../native-types'
|
|
4
5
|
import waitForNextUpdate from '../test-utils'
|
|
5
|
-
import useIsHealthDataAvailable from './useIsHealthDataAvailable'
|
|
6
6
|
|
|
7
7
|
describe('useIsHealthDataAvailable', () => {
|
|
8
8
|
test('should return false', async () => {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { useCallback, useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import getMostRecentCategorySample from '../utils/getMostRecentCategorySample'
|
|
4
3
|
import useSubscribeToChanges from './useSubscribeToChanges'
|
|
4
|
+
import getMostRecentCategorySample from '../utils/getMostRecentCategorySample'
|
|
5
5
|
|
|
6
|
-
import type { HKCategoryTypeIdentifier } from '../native-types'
|
|
7
|
-
import type { HKCategorySample } from '../types'
|
|
6
|
+
import type { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../native-types'
|
|
8
7
|
|
|
9
8
|
function useMostRecentCategorySample<
|
|
10
9
|
TCategory extends HKCategoryTypeIdentifier
|
|
11
10
|
>(identifier: TCategory) {
|
|
12
|
-
const [category, setCategory] = useState<
|
|
11
|
+
const [category, setCategory] = useState<HKCategorySampleRaw<TCategory> | null>(
|
|
13
12
|
null,
|
|
14
13
|
)
|
|
15
14
|
const updater = useCallback(() => {
|
|
@@ -4,14 +4,13 @@ import ensureUnit from '../utils/ensureUnit'
|
|
|
4
4
|
import getMostRecentQuantitySample from '../utils/getMostRecentQuantitySample'
|
|
5
5
|
import subscribeToChanges from '../utils/subscribeToChanges'
|
|
6
6
|
|
|
7
|
-
import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
|
|
8
|
-
import type { HKQuantitySample } from '../types'
|
|
7
|
+
import type { HKQuantitySampleRaw, HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types'
|
|
9
8
|
|
|
10
9
|
function useMostRecentQuantitySample<
|
|
11
10
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
12
11
|
TUnit extends UnitForIdentifier<TIdentifier>
|
|
13
12
|
>(identifier: TIdentifier, unit?: TUnit) {
|
|
14
|
-
const [lastSample, setLastSample] = useState<
|
|
13
|
+
const [lastSample, setLastSample] = useState<HKQuantitySampleRaw<
|
|
15
14
|
TIdentifier
|
|
16
15
|
> | null>(null)
|
|
17
16
|
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
useState, useEffect, useCallback, useRef,
|
|
3
3
|
} from 'react'
|
|
4
4
|
|
|
5
|
-
import queryStatisticsForQuantity from '../utils/queryStatisticsForQuantity'
|
|
6
5
|
import useSubscribeToChanges from './useSubscribeToChanges'
|
|
6
|
+
import queryStatisticsForQuantity from '../utils/queryStatisticsForQuantity'
|
|
7
7
|
|
|
8
8
|
import type { HKQuantityTypeIdentifier, HKStatisticsOptions, UnitForIdentifier } from '../native-types'
|
|
9
9
|
import type { QueryStatisticsResponse } from '../types'
|
package/src/index.ios.tsx
CHANGED
|
@@ -15,9 +15,12 @@ import getPreferredUnit from './utils/getPreferredUnit'
|
|
|
15
15
|
import getPreferredUnits from './utils/getPreferredUnits'
|
|
16
16
|
import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'
|
|
17
17
|
import queryCategorySamples from './utils/queryCategorySamples'
|
|
18
|
+
import queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'
|
|
18
19
|
import queryCorrelationSamples from './utils/queryCorrelationSamples'
|
|
19
20
|
import queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples'
|
|
21
|
+
import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor'
|
|
20
22
|
import queryQuantitySamples from './utils/queryQuantitySamples'
|
|
23
|
+
import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'
|
|
21
24
|
import querySources from './utils/querySources'
|
|
22
25
|
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'
|
|
23
26
|
import queryWorkouts from './utils/queryWorkouts'
|
|
@@ -59,9 +62,12 @@ const Healthkit = {
|
|
|
59
62
|
|
|
60
63
|
// query methods
|
|
61
64
|
queryCategorySamples,
|
|
65
|
+
queryCategorySamplesWithAnchor,
|
|
62
66
|
queryCorrelationSamples,
|
|
63
67
|
queryHeartbeatSeriesSamples,
|
|
68
|
+
queryHeartbeatSeriesSamplesWithAnchor,
|
|
64
69
|
queryQuantitySamples,
|
|
70
|
+
queryQuantitySamplesWithAnchor,
|
|
65
71
|
queryStatisticsForQuantity,
|
|
66
72
|
queryWorkouts,
|
|
67
73
|
querySources,
|
package/src/index.tsx
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType,
|
|
4
|
+
HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse, QueryQuantitySamplesResponseRaw,
|
|
5
5
|
} from './native-types'
|
|
6
6
|
|
|
7
7
|
import type ReactNativeHealthkit from './index.ios'
|
|
8
|
+
import type { QueryCategorySamplesFn } from './utils/queryCategorySamples'
|
|
9
|
+
import type { QueryQuantitySamplesFn } from './utils/queryQuantitySamples'
|
|
8
10
|
|
|
9
11
|
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${
|
|
10
12
|
Platform.OS
|
|
@@ -24,7 +26,7 @@ function UnavailableFn<T = unknown>(retVal: T) {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
const Healthkit: typeof ReactNativeHealthkit = {
|
|
27
|
-
authorizationStatusFor: UnavailableFn(Promise.resolve(
|
|
29
|
+
authorizationStatusFor: UnavailableFn(Promise.resolve(HKAuthorizationStatus.notDetermined)),
|
|
28
30
|
disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
29
31
|
disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
30
32
|
enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
@@ -41,18 +43,21 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
41
43
|
getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
|
|
42
44
|
getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
|
|
43
45
|
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
44
|
-
queryCategorySamples: UnavailableFn(Promise.resolve(
|
|
46
|
+
queryCategorySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryCategorySamplesFn,
|
|
47
|
+
queryCategorySamplesWithAnchor: UnavailableFn(Promise.resolve({
|
|
45
48
|
samples: [],
|
|
46
49
|
deletedSamples: [],
|
|
47
50
|
newAnchor: '',
|
|
48
51
|
})),
|
|
49
52
|
queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
|
|
50
|
-
queryHeartbeatSeriesSamples: UnavailableFn(Promise.resolve(
|
|
53
|
+
queryHeartbeatSeriesSamples: UnavailableFn(Promise.resolve([])),
|
|
54
|
+
queryHeartbeatSeriesSamplesWithAnchor: UnavailableFn(Promise.resolve({
|
|
51
55
|
samples: [],
|
|
52
56
|
deletedSamples: [],
|
|
53
57
|
newAnchor: '',
|
|
54
58
|
})),
|
|
55
|
-
queryQuantitySamples: UnavailableFn(Promise.resolve(
|
|
59
|
+
queryQuantitySamples: UnavailableFn(Promise.resolve([])) as unknown as QueryQuantitySamplesFn,
|
|
60
|
+
queryQuantitySamplesWithAnchor: UnavailableFn(Promise.resolve({
|
|
56
61
|
samples: [],
|
|
57
62
|
deletedSamples: [],
|
|
58
63
|
newAnchor: '',
|
package/src/jest.setup.ts
CHANGED
|
@@ -14,6 +14,8 @@ const mockModule: (NativeModule & typeof Native) = {
|
|
|
14
14
|
disableAllBackgroundDelivery: jest.fn(),
|
|
15
15
|
disableBackgroundDelivery: jest.fn(),
|
|
16
16
|
enableBackgroundDelivery: jest.fn(),
|
|
17
|
+
queryCategorySamplesWithAnchor: jest.fn(),
|
|
18
|
+
queryQuantitySamplesWithAnchor: jest.fn(),
|
|
17
19
|
getBiologicalSex: jest.fn(),
|
|
18
20
|
getBloodType: jest.fn(),
|
|
19
21
|
getDateOfBirth: jest.fn(),
|
|
@@ -25,6 +27,7 @@ const mockModule: (NativeModule & typeof Native) = {
|
|
|
25
27
|
queryCategorySamples: jest.fn(),
|
|
26
28
|
queryCorrelationSamples: jest.fn(),
|
|
27
29
|
queryHeartbeatSeriesSamples: jest.fn(),
|
|
30
|
+
queryHeartbeatSeriesSamplesWithAnchor: jest.fn(),
|
|
28
31
|
queryQuantitySamples: jest.fn(),
|
|
29
32
|
querySources: jest.fn(),
|
|
30
33
|
queryStatisticsForQuantity: jest.fn(),
|
package/src/native-types.ts
CHANGED
|
@@ -1240,7 +1240,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1240
1240
|
identifier: HKSampleTypeIdentifier
|
|
1241
1241
|
): Promise<QueryId>;
|
|
1242
1242
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
1243
|
-
authorizationStatusFor(type: HealthkitReadAuthorization): Promise<
|
|
1243
|
+
authorizationStatusFor(type: HealthkitReadAuthorization): Promise<HKAuthorizationStatus>;
|
|
1244
1244
|
getRequestStatusForAuthorization(
|
|
1245
1245
|
write: WritePermissions,
|
|
1246
1246
|
read: ReadPermissions
|
|
@@ -1286,16 +1286,26 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1286
1286
|
to: string,
|
|
1287
1287
|
limit: number,
|
|
1288
1288
|
ascending: boolean,
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1289
|
+
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
1290
|
+
readonly queryQuantitySamples: <
|
|
1291
|
+
TIdentifier extends HKQuantityTypeIdentifier,
|
|
1292
|
+
TUnit extends UnitForIdentifier<TIdentifier>
|
|
1293
|
+
>(
|
|
1294
|
+
identifier: TIdentifier,
|
|
1295
|
+
unit: TUnit,
|
|
1292
1296
|
from: string,
|
|
1293
1297
|
to: string,
|
|
1294
1298
|
limit: number,
|
|
1295
1299
|
ascending: boolean,
|
|
1300
|
+
) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
1301
|
+
readonly queryCategorySamplesWithAnchor: <T extends HKCategoryTypeIdentifier>(
|
|
1302
|
+
identifier: T,
|
|
1303
|
+
from: string,
|
|
1304
|
+
to: string,
|
|
1305
|
+
limit: number,
|
|
1296
1306
|
anchor: string
|
|
1297
|
-
) => Promise<
|
|
1298
|
-
readonly
|
|
1307
|
+
) => Promise<QueryCategorySamplesResponseRaw<T>>;
|
|
1308
|
+
readonly queryQuantitySamplesWithAnchor: <
|
|
1299
1309
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
1300
1310
|
TUnit extends UnitForIdentifier<TIdentifier>
|
|
1301
1311
|
>(
|
|
@@ -1304,9 +1314,20 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1304
1314
|
from: string,
|
|
1305
1315
|
to: string,
|
|
1306
1316
|
limit: number,
|
|
1307
|
-
ascending: boolean,
|
|
1308
1317
|
anchor: string
|
|
1309
1318
|
) => Promise<QueryQuantitySamplesResponseRaw<TIdentifier>>;
|
|
1319
|
+
readonly queryHeartbeatSeriesSamples: (
|
|
1320
|
+
from: string,
|
|
1321
|
+
to: string,
|
|
1322
|
+
limit: number,
|
|
1323
|
+
ascending: boolean,
|
|
1324
|
+
) => Promise<readonly HKHeartbeatSeriesSampleRaw[]>;
|
|
1325
|
+
readonly queryHeartbeatSeriesSamplesWithAnchor: (
|
|
1326
|
+
from: string,
|
|
1327
|
+
to: string,
|
|
1328
|
+
limit: number,
|
|
1329
|
+
anchor: string
|
|
1330
|
+
) => Promise<QueryHeartbeatSeriesSamplesResponseRaw>;
|
|
1310
1331
|
readonly querySources: <
|
|
1311
1332
|
TIdentifier extends HKCategoryTypeIdentifier | HKQuantityTypeIdentifier
|
|
1312
1333
|
>(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../types'
|
|
2
1
|
import deserializeCategorySample from './deserializeCategorySample'
|
|
2
|
+
import { HKCategorySampleRaw, HKCategoryTypeIdentifier } from '../types'
|
|
3
3
|
|
|
4
4
|
describe('deserializeCategorySample', () => {
|
|
5
5
|
it('should deserialize category sample', () => {
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
import deserializCategorySample from './deserializeCategorySample'
|
|
3
1
|
import prepareOptions from './prepareOptions'
|
|
2
|
+
import Native from '../native-types'
|
|
4
3
|
|
|
5
|
-
import type { HKCategoryTypeIdentifier,
|
|
6
|
-
import type { GenericQueryOptions
|
|
7
|
-
|
|
8
|
-
export type QueryCategorySamplesResponse<T extends HKCategoryTypeIdentifier> = {
|
|
9
|
-
readonly samples: readonly HKCategorySample<T>[],
|
|
10
|
-
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
|
|
11
|
-
readonly newAnchor: string
|
|
12
|
-
}
|
|
4
|
+
import type { HKCategoryTypeIdentifier, HKCategorySampleRaw } from '../native-types'
|
|
5
|
+
import type { GenericQueryOptions } from '../types'
|
|
13
6
|
|
|
14
7
|
export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(
|
|
15
8
|
identifier: T,
|
|
16
|
-
options: GenericQueryOptions
|
|
17
|
-
) => Promise<
|
|
9
|
+
options: Omit<GenericQueryOptions, 'anchor'>
|
|
10
|
+
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
18
11
|
|
|
19
12
|
const queryCategorySamples: QueryCategorySamplesFn = async (
|
|
20
13
|
identifier,
|
|
@@ -27,14 +20,9 @@ const queryCategorySamples: QueryCategorySamplesFn = async (
|
|
|
27
20
|
opts.to,
|
|
28
21
|
opts.limit,
|
|
29
22
|
opts.ascending,
|
|
30
|
-
opts.anchor,
|
|
31
23
|
)
|
|
32
24
|
|
|
33
|
-
return
|
|
34
|
-
samples: raw.samples.map(deserializCategorySample),
|
|
35
|
-
deletedSamples: raw.deletedSamples,
|
|
36
|
-
newAnchor: raw.newAnchor,
|
|
37
|
-
}
|
|
25
|
+
return raw
|
|
38
26
|
}
|
|
39
27
|
|
|
40
28
|
export default queryCategorySamples
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import deserializCategorySample from './deserializeCategorySample'
|
|
2
|
+
import prepareOptions from './prepareOptions'
|
|
3
|
+
import Native from '../native-types'
|
|
4
|
+
|
|
5
|
+
import type { HKCategoryTypeIdentifier, DeletedCategorySampleRaw } from '../native-types'
|
|
6
|
+
import type { GenericQueryOptions, HKCategorySample } from '../types'
|
|
7
|
+
|
|
8
|
+
export type QueryCategorySamplesWithAnchorResponse<T extends HKCategoryTypeIdentifier> = {
|
|
9
|
+
readonly samples: readonly HKCategorySample<T>[],
|
|
10
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[],
|
|
11
|
+
readonly newAnchor: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type QueryCategorySamplesWithAnchorFn = <T extends HKCategoryTypeIdentifier>(
|
|
15
|
+
identifier: T,
|
|
16
|
+
options: Omit<GenericQueryOptions, 'ascending'>
|
|
17
|
+
) => Promise<QueryCategorySamplesWithAnchorResponse<T>>;
|
|
18
|
+
|
|
19
|
+
const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn = async (
|
|
20
|
+
identifier,
|
|
21
|
+
options,
|
|
22
|
+
) => {
|
|
23
|
+
const opts = prepareOptions(options)
|
|
24
|
+
const raw = await Native.queryCategorySamplesWithAnchor(
|
|
25
|
+
identifier,
|
|
26
|
+
opts.from,
|
|
27
|
+
opts.to,
|
|
28
|
+
opts.limit,
|
|
29
|
+
opts.anchor,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
samples: raw.samples.map(deserializCategorySample),
|
|
34
|
+
deletedSamples: raw.deletedSamples,
|
|
35
|
+
newAnchor: raw.newAnchor,
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default queryCategorySamplesWithAnchor
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
1
|
import deserializeCorrelation from './deserializeCorrelation'
|
|
3
2
|
import prepareOptions from './prepareOptions'
|
|
3
|
+
import Native from '../native-types'
|
|
4
4
|
|
|
5
5
|
import type { HKCorrelationTypeIdentifier } from '../native-types'
|
|
6
6
|
import type { GenericQueryOptions, HKCorrelation } from '../types'
|
|
@@ -9,7 +9,7 @@ export type QueryCorrelationSamplesFn = <
|
|
|
9
9
|
TIdentifier extends HKCorrelationTypeIdentifier
|
|
10
10
|
>(
|
|
11
11
|
typeIdentifier: TIdentifier,
|
|
12
|
-
options: Omit<GenericQueryOptions, 'ascending' | 'limit'>
|
|
12
|
+
options: Omit<GenericQueryOptions, 'anchor' | 'ascending' | 'limit'>
|
|
13
13
|
) => Promise<readonly HKCorrelation<TIdentifier>[]>;
|
|
14
14
|
|
|
15
15
|
const queryCorrelationSamples: QueryCorrelationSamplesFn = async (
|