@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
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
1
|
import deserializeHeartbeatSeriesSample from './deserializeHeartbeatSeriesSample'
|
|
3
2
|
import prepareOptions from './prepareOptions'
|
|
3
|
+
import Native from '../native-types'
|
|
4
4
|
|
|
5
5
|
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types'
|
|
6
6
|
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types'
|
|
@@ -11,7 +11,7 @@ export type QueryHeartbeatSeriesSamplesResponse = {
|
|
|
11
11
|
readonly newAnchor: string
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export type QueryHeartbeatSeriesSamplesFn = (options: GenericQueryOptions) => Promise<
|
|
14
|
+
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'anchor'>) => Promise<readonly HKHeartbeatSeriesSample[]>;
|
|
15
15
|
|
|
16
16
|
const queryHeartbeatSeriesSamples: QueryHeartbeatSeriesSamplesFn = async (options) => {
|
|
17
17
|
const opts = prepareOptions(options)
|
|
@@ -21,14 +21,9 @@ const queryHeartbeatSeriesSamples: QueryHeartbeatSeriesSamplesFn = async (option
|
|
|
21
21
|
opts.to,
|
|
22
22
|
opts.limit,
|
|
23
23
|
opts.ascending,
|
|
24
|
-
opts.anchor,
|
|
25
24
|
)
|
|
26
25
|
|
|
27
|
-
return
|
|
28
|
-
deletedSamples: result.deletedSamples,
|
|
29
|
-
newAnchor: result.newAnchor,
|
|
30
|
-
samples: result.samples.map(deserializeHeartbeatSeriesSample),
|
|
31
|
-
}
|
|
26
|
+
return result.map(deserializeHeartbeatSeriesSample)
|
|
32
27
|
}
|
|
33
28
|
|
|
34
29
|
export default queryHeartbeatSeriesSamples
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import deserializeHeartbeatSeriesSample from './deserializeHeartbeatSeriesSample'
|
|
2
|
+
import prepareOptions from './prepareOptions'
|
|
3
|
+
import Native from '../native-types'
|
|
4
|
+
|
|
5
|
+
import type { DeletedHeartbeatSeriesSampleRaw } from '../native-types'
|
|
6
|
+
import type { GenericQueryOptions, HKHeartbeatSeriesSample } from '../types'
|
|
7
|
+
|
|
8
|
+
export type QueryHeartbeatSeriesSamplesResponse = {
|
|
9
|
+
readonly samples: readonly HKHeartbeatSeriesSample[],
|
|
10
|
+
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[],
|
|
11
|
+
readonly newAnchor: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type QueryHeartbeatSeriesSamplesFn = (options: Omit<GenericQueryOptions, 'ascending'>) => Promise<QueryHeartbeatSeriesSamplesResponse>;
|
|
15
|
+
|
|
16
|
+
const queryHeartbeatSeriesSamplesWithAnchor: QueryHeartbeatSeriesSamplesFn = async (options) => {
|
|
17
|
+
const opts = prepareOptions(options)
|
|
18
|
+
|
|
19
|
+
const result = await Native.queryHeartbeatSeriesSamplesWithAnchor(
|
|
20
|
+
opts.from,
|
|
21
|
+
opts.to,
|
|
22
|
+
opts.limit,
|
|
23
|
+
opts.anchor,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
deletedSamples: result.deletedSamples,
|
|
28
|
+
newAnchor: result.newAnchor,
|
|
29
|
+
samples: result.samples.map(deserializeHeartbeatSeriesSample),
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default queryHeartbeatSeriesSamplesWithAnchor
|
|
@@ -1,24 +1,19 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
|
-
import deserializeQuantitySample from './deserializeSample'
|
|
3
1
|
import ensureUnit from './ensureUnit'
|
|
4
2
|
import prepareOptions from './prepareOptions'
|
|
3
|
+
import Native from '../native-types'
|
|
5
4
|
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly samples: readonly HKQuantitySample<T>[],
|
|
11
|
-
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[],
|
|
12
|
-
readonly newAnchor: string
|
|
13
|
-
}
|
|
5
|
+
import type {
|
|
6
|
+
HKQuantityTypeIdentifier, UnitForIdentifier, HKQuantitySampleRaw,
|
|
7
|
+
} from '../native-types'
|
|
8
|
+
import type { GenericQueryOptions } from '../types'
|
|
14
9
|
|
|
15
10
|
export type QueryQuantitySamplesFn = <
|
|
16
11
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
17
12
|
TUnit extends UnitForIdentifier<TIdentifier>
|
|
18
13
|
>(
|
|
19
14
|
identifier: TIdentifier,
|
|
20
|
-
options: GenericQueryOptions & { readonly unit?: TUnit }
|
|
21
|
-
) => Promise<
|
|
15
|
+
options: Omit<GenericQueryOptions, 'anchor'> & { readonly unit?: TUnit }
|
|
16
|
+
) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
22
17
|
|
|
23
18
|
const queryQuantitySamples: QueryQuantitySamplesFn = async (
|
|
24
19
|
identifier,
|
|
@@ -34,14 +29,9 @@ const queryQuantitySamples: QueryQuantitySamplesFn = async (
|
|
|
34
29
|
opts.to,
|
|
35
30
|
opts.limit,
|
|
36
31
|
opts.ascending,
|
|
37
|
-
opts.anchor,
|
|
38
32
|
)
|
|
39
33
|
|
|
40
|
-
return
|
|
41
|
-
deletedSamples: result.deletedSamples,
|
|
42
|
-
newAnchor: result.newAnchor,
|
|
43
|
-
samples: result.samples.map(deserializeQuantitySample),
|
|
44
|
-
}
|
|
34
|
+
return result
|
|
45
35
|
}
|
|
46
36
|
|
|
47
37
|
export default queryQuantitySamples
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import deserializeQuantitySample from './deserializeSample'
|
|
2
|
+
import ensureUnit from './ensureUnit'
|
|
3
|
+
import prepareOptions from './prepareOptions'
|
|
4
|
+
import Native from '../native-types'
|
|
5
|
+
|
|
6
|
+
import type { HKQuantityTypeIdentifier, UnitForIdentifier, DeletedQuantitySampleRaw } from '../native-types'
|
|
7
|
+
import type { GenericQueryOptions, HKQuantitySample } from '../types'
|
|
8
|
+
|
|
9
|
+
export type QueryQuantitySamplesWithAnchorResponse<T extends HKQuantityTypeIdentifier> = {
|
|
10
|
+
readonly samples: readonly HKQuantitySample<T>[],
|
|
11
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[],
|
|
12
|
+
readonly newAnchor: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type QueryQuantitySamplesWithAnchorFn = <
|
|
16
|
+
TIdentifier extends HKQuantityTypeIdentifier,
|
|
17
|
+
TUnit extends UnitForIdentifier<TIdentifier>
|
|
18
|
+
>(
|
|
19
|
+
identifier: TIdentifier,
|
|
20
|
+
options: Omit<GenericQueryOptions, 'ascending'> & { readonly unit?: TUnit }
|
|
21
|
+
) => Promise<QueryQuantitySamplesWithAnchorResponse<TIdentifier>>;
|
|
22
|
+
|
|
23
|
+
const queryQuantitySamplesWithAnchor: QueryQuantitySamplesWithAnchorFn = async (
|
|
24
|
+
identifier,
|
|
25
|
+
options,
|
|
26
|
+
) => {
|
|
27
|
+
const unit = await ensureUnit(identifier, options.unit)
|
|
28
|
+
const opts = prepareOptions(options)
|
|
29
|
+
|
|
30
|
+
const result = await Native.queryQuantitySamplesWithAnchor(
|
|
31
|
+
identifier,
|
|
32
|
+
unit,
|
|
33
|
+
opts.from,
|
|
34
|
+
opts.to,
|
|
35
|
+
opts.limit,
|
|
36
|
+
opts.anchor,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
deletedSamples: result.deletedSamples,
|
|
41
|
+
newAnchor: result.newAnchor,
|
|
42
|
+
samples: result.samples.map(deserializeQuantitySample),
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default queryQuantitySamplesWithAnchor
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
1
|
import deserializeWorkout from './deserializeWorkout'
|
|
3
2
|
import getPreferredUnitsTyped from './getPreferredUnitsTyped'
|
|
4
3
|
import prepareOptions from './prepareOptions'
|
|
4
|
+
import Native from '../native-types'
|
|
5
5
|
|
|
6
6
|
import type { EnergyUnit, LengthUnit } from '../native-types'
|
|
7
7
|
import type { QueryWorkoutsOptions } from '../types'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Native from '../native-types'
|
|
2
1
|
import ensureMetadata from './ensureMetadata'
|
|
2
|
+
import Native from '../native-types'
|
|
3
3
|
|
|
4
4
|
import type { MetadataMapperForCorrelationIdentifier, HKCorrelationTypeIdentifier } from '../native-types'
|
|
5
5
|
import type { HKCategorySampleForSaving, HKQuantitySampleForSaving } from '../types'
|
package/android/.project
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<projectDescription>
|
|
3
|
-
<name>kingstinct_react-native-healthkit</name>
|
|
4
|
-
<comment>Project android_ created by Buildship.</comment>
|
|
5
|
-
<projects>
|
|
6
|
-
</projects>
|
|
7
|
-
<buildSpec>
|
|
8
|
-
<buildCommand>
|
|
9
|
-
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
10
|
-
<arguments>
|
|
11
|
-
</arguments>
|
|
12
|
-
</buildCommand>
|
|
13
|
-
<buildCommand>
|
|
14
|
-
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
15
|
-
<arguments>
|
|
16
|
-
</arguments>
|
|
17
|
-
</buildCommand>
|
|
18
|
-
</buildSpec>
|
|
19
|
-
<natures>
|
|
20
|
-
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
21
|
-
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
22
|
-
</natures>
|
|
23
|
-
<filteredResources>
|
|
24
|
-
<filter>
|
|
25
|
-
<id>1663745272821</id>
|
|
26
|
-
<name></name>
|
|
27
|
-
<type>30</type>
|
|
28
|
-
<matcher>
|
|
29
|
-
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
|
30
|
-
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
|
31
|
-
</matcher>
|
|
32
|
-
</filter>
|
|
33
|
-
</filteredResources>
|
|
34
|
-
</projectDescription>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
arguments=--init-script /var/folders/lb/4fb2wm497wq1_0vknwt43h3h0000gn/T/init5242912127258488867.gradle --init-script /var/folders/lb/4fb2wm497wq1_0vknwt43h3h0000gn/T/init4373878353927339792.gradle
|
|
2
|
-
auto.sync=false
|
|
3
|
-
build.scans.enabled=false
|
|
4
|
-
connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(7.4.2))
|
|
5
|
-
connection.project.dir=../example/android
|
|
6
|
-
eclipse.preferences.version=1
|
|
7
|
-
gradle.user.home=
|
|
8
|
-
java.home=/Users/andarius/.sdkman/candidates/java/11.0.2-open
|
|
9
|
-
jvm.arguments=
|
|
10
|
-
offline.mode=false
|
|
11
|
-
override.workspace.settings=true
|
|
12
|
-
show.console.view=true
|
|
13
|
-
show.executions.view=true
|
package/android/build.gradle
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
buildscript {
|
|
2
|
-
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
-
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeHealthkit_kotlinVersion']
|
|
4
|
-
|
|
5
|
-
repositories {
|
|
6
|
-
google()
|
|
7
|
-
jcenter()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
dependencies {
|
|
11
|
-
classpath 'com.android.tools.build:gradle:3.2.1'
|
|
12
|
-
// noinspection DifferentKotlinGradleVersion
|
|
13
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
apply plugin: 'com.android.library'
|
|
18
|
-
apply plugin: 'kotlin-android'
|
|
19
|
-
|
|
20
|
-
def getExtOrDefault(name) {
|
|
21
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeHealthkit_' + name]
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
def getExtOrIntegerDefault(name) {
|
|
25
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeHealthkit_' + name]).toInteger()
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
android {
|
|
29
|
-
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
|
|
30
|
-
buildToolsVersion getExtOrDefault('buildToolsVersion')
|
|
31
|
-
defaultConfig {
|
|
32
|
-
minSdkVersion 16
|
|
33
|
-
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
|
|
34
|
-
versionCode 1
|
|
35
|
-
versionName "1.0"
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
buildTypes {
|
|
40
|
-
release {
|
|
41
|
-
minifyEnabled false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
lintOptions {
|
|
45
|
-
disable 'GradleCompatible'
|
|
46
|
-
}
|
|
47
|
-
compileOptions {
|
|
48
|
-
sourceCompatibility JavaVersion.VERSION_1_8
|
|
49
|
-
targetCompatibility JavaVersion.VERSION_1_8
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
repositories {
|
|
54
|
-
mavenCentral()
|
|
55
|
-
jcenter()
|
|
56
|
-
google()
|
|
57
|
-
|
|
58
|
-
def found = false
|
|
59
|
-
def defaultDir = null
|
|
60
|
-
def androidSourcesName = 'React Native sources'
|
|
61
|
-
|
|
62
|
-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
|
|
63
|
-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
|
|
64
|
-
} else {
|
|
65
|
-
defaultDir = new File(
|
|
66
|
-
projectDir,
|
|
67
|
-
'/../../../node_modules/react-native/android'
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (defaultDir.exists()) {
|
|
72
|
-
maven {
|
|
73
|
-
url defaultDir.toString()
|
|
74
|
-
name androidSourcesName
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
|
|
78
|
-
found = true
|
|
79
|
-
} else {
|
|
80
|
-
def parentDir = rootProject.projectDir
|
|
81
|
-
|
|
82
|
-
1.upto(5, {
|
|
83
|
-
if (found) return true
|
|
84
|
-
parentDir = parentDir.parentFile
|
|
85
|
-
|
|
86
|
-
def androidSourcesDir = new File(
|
|
87
|
-
parentDir,
|
|
88
|
-
'node_modules/react-native'
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
def androidPrebuiltBinaryDir = new File(
|
|
92
|
-
parentDir,
|
|
93
|
-
'node_modules/react-native/android'
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
if (androidPrebuiltBinaryDir.exists()) {
|
|
97
|
-
maven {
|
|
98
|
-
url androidPrebuiltBinaryDir.toString()
|
|
99
|
-
name androidSourcesName
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
|
|
103
|
-
found = true
|
|
104
|
-
} else if (androidSourcesDir.exists()) {
|
|
105
|
-
maven {
|
|
106
|
-
url androidSourcesDir.toString()
|
|
107
|
-
name androidSourcesName
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
|
|
111
|
-
found = true
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (!found) {
|
|
117
|
-
throw new GradleException(
|
|
118
|
-
"${project.name}: unable to locate React Native android sources. " +
|
|
119
|
-
"Ensure you have you installed React Native as a dependency in your project and try again."
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
def kotlin_version = getExtOrDefault('kotlinVersion')
|
|
125
|
-
|
|
126
|
-
dependencies {
|
|
127
|
-
// noinspection GradleDynamicVersion
|
|
128
|
-
api 'com.facebook.react:react-native:+'
|
|
129
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
130
|
-
}
|
package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitModule.kt
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
package com.kingstinctreactnativehealthkit
|
|
2
|
-
|
|
3
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
-
import com.facebook.react.bridge.ReactMethod
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
|
-
|
|
8
|
-
class ReactNativeHealthkitModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
9
|
-
|
|
10
|
-
override fun getName(): String {
|
|
11
|
-
return "ReactNativeHealthkit"
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Example method
|
|
15
|
-
// See https://facebook.github.io/react-native/docs/native-modules-android
|
|
16
|
-
@ReactMethod
|
|
17
|
-
fun multiply(a: Int, b: Int, promise: Promise) {
|
|
18
|
-
|
|
19
|
-
promise.resolve(a * b)
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
package/android/src/main/java/com/kingstinctreactnativehealthkit/ReactNativeHealthkitPackage.kt
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
package com.kingstinctreactnativehealthkit
|
|
2
|
-
|
|
3
|
-
import java.util.Arrays
|
|
4
|
-
import java.util.Collections
|
|
5
|
-
|
|
6
|
-
import com.facebook.react.ReactPackage
|
|
7
|
-
import com.facebook.react.bridge.NativeModule
|
|
8
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
-
import com.facebook.react.uimanager.ViewManager
|
|
10
|
-
import com.facebook.react.bridge.JavaScriptModule
|
|
11
|
-
|
|
12
|
-
class ReactNativeHealthkitPackage : ReactPackage {
|
|
13
|
-
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
14
|
-
return Arrays.asList<NativeModule>(ReactNativeHealthkitModule(reactContext))
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
18
|
-
return emptyList<ViewManager<*, *>>()
|
|
19
|
-
}
|
|
20
|
-
}
|