@kingstinct/react-native-healthkit 4.3.0 → 4.4.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.swift +2 -2
- package/lib/commonjs/index.ios.js +92 -103
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +2 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +9 -1
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.ios.js +92 -103
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +4 -0
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +126 -120
- package/lib/typescript/src/types.d.ts +79 -79
- package/package.json +20 -35
- package/src/index.ios.tsx +260 -269
- package/src/index.tsx +13 -13
- package/src/native-types.ts +184 -182
- package/src/types.ts +100 -100
package/src/index.tsx
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Platform } from 'react-native'
|
|
2
|
-
import type { ReactNativeHealthkit } from './types';
|
|
1
|
+
import { Platform } from 'react-native'
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import type { ReactNativeHealthkit } from './types'
|
|
4
|
+
|
|
5
|
+
const notAvailableError = `Platform "${
|
|
6
|
+
Platform.OS
|
|
7
|
+
}" not supported, use isHealthDataAvailable to check for availability before using it`
|
|
8
8
|
|
|
9
9
|
const UnavailableFn = () => {
|
|
10
|
-
throw new Error(notAvailableError)
|
|
11
|
-
}
|
|
10
|
+
throw new Error(notAvailableError)
|
|
11
|
+
}
|
|
12
12
|
|
|
13
13
|
const Healthkit: ReactNativeHealthkit = {
|
|
14
14
|
authorizationStatusFor: UnavailableFn,
|
|
@@ -28,7 +28,7 @@ const Healthkit: ReactNativeHealthkit = {
|
|
|
28
28
|
getRequestStatusForAuthorization: UnavailableFn,
|
|
29
29
|
getWheelchairUse: UnavailableFn,
|
|
30
30
|
getWorkoutRoutes: UnavailableFn,
|
|
31
|
-
isHealthDataAvailable: () => Promise.resolve(false),
|
|
31
|
+
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
32
32
|
queryCategorySamples: UnavailableFn,
|
|
33
33
|
queryCorrelationSamples: UnavailableFn,
|
|
34
34
|
queryQuantitySamples: UnavailableFn,
|
|
@@ -44,9 +44,9 @@ const Healthkit: ReactNativeHealthkit = {
|
|
|
44
44
|
useMostRecentQuantitySample: UnavailableFn,
|
|
45
45
|
useMostRecentWorkout: UnavailableFn,
|
|
46
46
|
useSubscribeToChanges: UnavailableFn,
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
export * from './native-types'
|
|
50
|
-
export * from './types'
|
|
49
|
+
export * from './native-types'
|
|
50
|
+
export * from './types'
|
|
51
51
|
|
|
52
|
-
export default Healthkit
|
|
52
|
+
export default Healthkit
|
package/src/native-types.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
-
EmitterSubscription,
|
|
3
2
|
NativeEventEmitter,
|
|
4
3
|
NativeModules,
|
|
5
|
-
} from 'react-native'
|
|
4
|
+
} from 'react-native'
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
import type { EmitterSubscription } from 'react-native'
|
|
7
|
+
|
|
8
|
+
export const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier'
|
|
9
|
+
export const HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier'
|
|
10
|
+
export const HKWorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier'
|
|
11
|
+
export const HKDataTypeIdentifierHeartbeatSeries = 'HKDataTypeIdentifierHeartbeatSeries'
|
|
9
12
|
|
|
10
13
|
export type HKSampleTypeIdentifier =
|
|
11
|
-
| HKWorkoutTypeIdentifier
|
|
12
|
-
| HKQuantityTypeIdentifier
|
|
13
14
|
| HKCategoryTypeIdentifier
|
|
14
|
-
|
|
|
15
|
-
|
|
|
15
|
+
| HKCorrelationTypeIdentifier
|
|
16
|
+
| HKQuantityTypeIdentifier
|
|
17
|
+
| typeof HKAudiogramTypeIdentifier
|
|
18
|
+
| typeof HKDataTypeIdentifierHeartbeatSeries
|
|
19
|
+
| typeof HKWorkoutRouteTypeIdentifier
|
|
20
|
+
| typeof HKWorkoutTypeIdentifier;
|
|
16
21
|
|
|
17
|
-
export type TypeToUnitMapping = {
|
|
22
|
+
export type TypeToUnitMapping = { readonly
|
|
18
23
|
[key in HKQuantityTypeIdentifier]: HKUnit;
|
|
19
24
|
};
|
|
20
25
|
|
|
@@ -126,21 +131,21 @@ export enum HKWorkoutActivityType {
|
|
|
126
131
|
}
|
|
127
132
|
|
|
128
133
|
export type HKGenericMetadata = {
|
|
129
|
-
[key: string]:
|
|
130
|
-
HKExternalUUID?: string;
|
|
131
|
-
HKTimeZone?: string;
|
|
132
|
-
HKWasUserEntered?: boolean;
|
|
133
|
-
HKDeviceSerialNumber?: string;
|
|
134
|
-
HKUDIDeviceIdentifier?: string;
|
|
135
|
-
HKUDIProductionIdentifier?: string;
|
|
136
|
-
HKDigitalSignature?: string;
|
|
137
|
-
HKDeviceName?: string;
|
|
138
|
-
HKDeviceManufacturerName?: string;
|
|
139
|
-
HKSyncIdentifier?: string;
|
|
140
|
-
HKSyncVersion?: number;
|
|
141
|
-
HKWasTakenInLab?: boolean;
|
|
142
|
-
HKReferenceRangeLowerLimit?: number;
|
|
143
|
-
HKReferenceRangeUpperLimit?: number;
|
|
134
|
+
readonly [key: string]: HKQuantity | boolean | number | string | undefined;
|
|
135
|
+
readonly HKExternalUUID?: string;
|
|
136
|
+
readonly HKTimeZone?: string;
|
|
137
|
+
readonly HKWasUserEntered?: boolean;
|
|
138
|
+
readonly HKDeviceSerialNumber?: string;
|
|
139
|
+
readonly HKUDIDeviceIdentifier?: string;
|
|
140
|
+
readonly HKUDIProductionIdentifier?: string;
|
|
141
|
+
readonly HKDigitalSignature?: string;
|
|
142
|
+
readonly HKDeviceName?: string;
|
|
143
|
+
readonly HKDeviceManufacturerName?: string;
|
|
144
|
+
readonly HKSyncIdentifier?: string;
|
|
145
|
+
readonly HKSyncVersion?: number;
|
|
146
|
+
readonly HKWasTakenInLab?: boolean;
|
|
147
|
+
readonly HKReferenceRangeLowerLimit?: number;
|
|
148
|
+
readonly HKReferenceRangeUpperLimit?: number;
|
|
144
149
|
};
|
|
145
150
|
|
|
146
151
|
// documented at https://developer.apple.com/documentation/healthkit/hkweathercondition
|
|
@@ -176,9 +181,9 @@ export enum HKWeatherCondition {
|
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
export interface HKWorkoutMetadata
|
|
179
|
-
extends HKGenericMetadata
|
|
180
|
-
HKWeatherCondition?: HKWeatherCondition;
|
|
181
|
-
HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
184
|
+
extends HKGenericMetadata /* <TTemperatureUnit extends HKUnit> */ {
|
|
185
|
+
readonly HKWeatherCondition?: HKWeatherCondition;
|
|
186
|
+
readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
182
187
|
// HKWeatherTemperature: HKQuantity<TTemperatureUnit>
|
|
183
188
|
}
|
|
184
189
|
|
|
@@ -304,8 +309,8 @@ export enum HKAuthorizationStatus {
|
|
|
304
309
|
}
|
|
305
310
|
|
|
306
311
|
export type HKQuantity<T extends HKUnit = HKUnit> = {
|
|
307
|
-
unit: T;
|
|
308
|
-
quantity: number;
|
|
312
|
+
readonly unit: T;
|
|
313
|
+
readonly quantity: number;
|
|
309
314
|
};
|
|
310
315
|
|
|
311
316
|
export enum HKBloodType {
|
|
@@ -349,13 +354,13 @@ export enum HKStatisticsOptions {
|
|
|
349
354
|
}
|
|
350
355
|
|
|
351
356
|
export type QueryStatisticsResponseRaw<TUnit extends HKUnit = HKUnit> = {
|
|
352
|
-
averageQuantity?: HKQuantity<TUnit>;
|
|
353
|
-
maximumQuantity?: HKQuantity<TUnit>;
|
|
354
|
-
minimumQuantity?: HKQuantity<TUnit>;
|
|
355
|
-
sumQuantity?: HKQuantity<TUnit>;
|
|
356
|
-
mostRecentQuantity?: HKQuantity<TUnit>;
|
|
357
|
-
mostRecentQuantityDateInterval?: { from: string; to: string };
|
|
358
|
-
duration?: HKQuantity<HKUnit.Seconds>;
|
|
357
|
+
readonly averageQuantity?: HKQuantity<TUnit>;
|
|
358
|
+
readonly maximumQuantity?: HKQuantity<TUnit>;
|
|
359
|
+
readonly minimumQuantity?: HKQuantity<TUnit>;
|
|
360
|
+
readonly sumQuantity?: HKQuantity<TUnit>;
|
|
361
|
+
readonly mostRecentQuantity?: HKQuantity<TUnit>;
|
|
362
|
+
readonly mostRecentQuantityDateInterval?: { readonly from: string; readonly to: string };
|
|
363
|
+
readonly duration?: HKQuantity<HKUnit.Seconds>;
|
|
359
364
|
};
|
|
360
365
|
|
|
361
366
|
export enum HKCategoryValueCervicalMucusQuality {
|
|
@@ -413,13 +418,13 @@ export enum HKCategoryValueNotApplicable {
|
|
|
413
418
|
|
|
414
419
|
export type HKCategoryValue =
|
|
415
420
|
| HKCategoryValueAppetiteChanges
|
|
421
|
+
| HKCategoryValueCervicalMucusQuality
|
|
422
|
+
| HKCategoryValueMenstrualFlow
|
|
423
|
+
| HKCategoryValueOvulationTestResult
|
|
416
424
|
| HKCategoryValuePresence
|
|
417
|
-
| HKCategoryValueSeverity
|
|
418
425
|
| HKCategoryValuePresence
|
|
419
|
-
|
|
|
426
|
+
| HKCategoryValueSeverity
|
|
420
427
|
| HKCategoryValueSleepAnalysis
|
|
421
|
-
| HKCategoryValueCervicalMucusQuality
|
|
422
|
-
| HKCategoryValueOvulationTestResult
|
|
423
428
|
| number;
|
|
424
429
|
|
|
425
430
|
export enum HKInsulinDeliveryReason {
|
|
@@ -431,58 +436,58 @@ export type MetadataMapperForQuantityIdentifier<
|
|
|
431
436
|
TQuantityTypeIdentifier = HKQuantityTypeIdentifier
|
|
432
437
|
> = TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.insulinDelivery
|
|
433
438
|
? HKGenericMetadata & {
|
|
434
|
-
|
|
435
|
-
|
|
439
|
+
readonly HKInsulinDeliveryReason: HKInsulinDeliveryReason;
|
|
440
|
+
}
|
|
436
441
|
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.bloodGlucose
|
|
437
|
-
|
|
438
|
-
HKBloodGlucoseMealTime?: number;
|
|
442
|
+
? HKGenericMetadata & {
|
|
443
|
+
readonly HKBloodGlucoseMealTime?: number;
|
|
439
444
|
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
+
: TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate
|
|
446
|
+
? HKGenericMetadata & {
|
|
447
|
+
readonly HKHeartRateMotionContext?: HKHeartRateMotionContext;
|
|
448
|
+
}
|
|
449
|
+
: HKGenericMetadata;
|
|
445
450
|
|
|
446
451
|
export type MetadataMapperForCorrelationIdentifier<
|
|
447
452
|
TCorrelationTypeIdentifier = HKCorrelationTypeIdentifier
|
|
448
453
|
> = TCorrelationTypeIdentifier extends HKCorrelationTypeIdentifier.food
|
|
449
454
|
? HKGenericMetadata & {
|
|
450
|
-
|
|
451
|
-
|
|
455
|
+
readonly HKFoodType?: string;
|
|
456
|
+
}
|
|
452
457
|
: HKGenericMetadata;
|
|
453
458
|
|
|
454
459
|
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> =
|
|
455
460
|
T extends HKCategoryTypeIdentifier.cervicalMucusQuality
|
|
456
461
|
? HKCategoryValueCervicalMucusQuality
|
|
457
462
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
463
|
+
? HKCategoryValueMenstrualFlow
|
|
464
|
+
: T extends HKCategoryTypeIdentifier.ovulationTestResult
|
|
465
|
+
? HKCategoryValueOvulationTestResult
|
|
466
|
+
: T extends HKCategoryTypeIdentifier.sleepAnalysis
|
|
467
|
+
? HKCategoryValueSleepAnalysis
|
|
468
|
+
: T extends HKCategoryTypeIdentifier.mindfulSession
|
|
469
|
+
? HKCategoryValueNotApplicable
|
|
470
|
+
: T extends HKCategoryTypeIdentifier.intermenstrualBleeding
|
|
471
|
+
? HKCategoryValueNotApplicable
|
|
472
|
+
: T extends HKCategoryTypeIdentifier.highHeartRateEvent
|
|
473
|
+
? HKCategoryValueNotApplicable
|
|
474
|
+
: T extends HKCategoryTypeIdentifier.sexualActivity
|
|
475
|
+
? HKCategoryValueNotApplicable
|
|
476
|
+
: T extends HKCategoryTypeIdentifier.appleStandHour
|
|
477
|
+
? HKCategoryValueAppleStandHour
|
|
478
|
+
: number;
|
|
474
479
|
|
|
475
480
|
export type MetadataMapperForCategoryIdentifier<
|
|
476
481
|
T extends HKCategoryTypeIdentifier
|
|
477
482
|
> = T extends HKCategoryTypeIdentifier.sexualActivity
|
|
478
483
|
? HKGenericMetadata & {
|
|
479
|
-
|
|
480
|
-
|
|
484
|
+
readonly HKSexualActivityProtectionUsed: boolean;
|
|
485
|
+
}
|
|
481
486
|
: T extends HKCategoryTypeIdentifier.menstrualFlow
|
|
482
|
-
|
|
483
|
-
HKMenstrualCycleStart: boolean;
|
|
487
|
+
? HKGenericMetadata & {
|
|
488
|
+
readonly HKMenstrualCycleStart: boolean;
|
|
484
489
|
}
|
|
485
|
-
|
|
490
|
+
: HKGenericMetadata;
|
|
486
491
|
|
|
487
492
|
// Maps directly to https://developer.apple.com/documentation/healthkit/hkwheelchairuse
|
|
488
493
|
export enum HKWheelchairUse {
|
|
@@ -564,53 +569,55 @@ export enum HKUnit {
|
|
|
564
569
|
}
|
|
565
570
|
|
|
566
571
|
export type HKDevice = {
|
|
567
|
-
name: string;
|
|
568
|
-
firmwareVersion: string;
|
|
569
|
-
hardwareVersion: string;
|
|
570
|
-
localIdentifier: string;
|
|
571
|
-
manufacturer: string;
|
|
572
|
-
model: string;
|
|
573
|
-
softwareVersion: string;
|
|
572
|
+
readonly name: string;
|
|
573
|
+
readonly firmwareVersion: string;
|
|
574
|
+
readonly hardwareVersion: string;
|
|
575
|
+
readonly localIdentifier: string;
|
|
576
|
+
readonly manufacturer: string;
|
|
577
|
+
readonly model: string;
|
|
578
|
+
readonly softwareVersion: string;
|
|
574
579
|
};
|
|
575
580
|
|
|
576
581
|
export type HKSource = {
|
|
577
|
-
name: string;
|
|
578
|
-
bundleIdentifier: string;
|
|
582
|
+
readonly name: string;
|
|
583
|
+
readonly bundleIdentifier: string;
|
|
579
584
|
};
|
|
580
585
|
|
|
581
586
|
export type HKSourceRevision = {
|
|
582
|
-
source: HKSource;
|
|
583
|
-
version: string;
|
|
584
|
-
operatingSystemVersion?: string;
|
|
585
|
-
productType?: string;
|
|
587
|
+
readonly source: HKSource;
|
|
588
|
+
readonly version: string;
|
|
589
|
+
readonly operatingSystemVersion?: string;
|
|
590
|
+
readonly productType?: string;
|
|
586
591
|
};
|
|
587
592
|
|
|
588
593
|
export type HKQuantitySampleRaw<
|
|
589
594
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
590
595
|
TUnit extends HKUnit = HKUnit
|
|
591
596
|
> = {
|
|
592
|
-
uuid: string;
|
|
593
|
-
device?: HKDevice;
|
|
594
|
-
quantityType: TQuantityIdentifier;
|
|
595
|
-
startDate: string;
|
|
596
|
-
endDate: string;
|
|
597
|
-
quantity: number;
|
|
598
|
-
unit: TUnit;
|
|
599
|
-
metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
600
|
-
sourceRevision?: HKSourceRevision;
|
|
597
|
+
readonly uuid: string;
|
|
598
|
+
readonly device?: HKDevice;
|
|
599
|
+
readonly quantityType: TQuantityIdentifier;
|
|
600
|
+
readonly startDate: string;
|
|
601
|
+
readonly endDate: string;
|
|
602
|
+
readonly quantity: number;
|
|
603
|
+
readonly unit: TUnit;
|
|
604
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
|
|
605
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
601
606
|
};
|
|
602
607
|
|
|
603
608
|
export type HKWorkoutRaw<TEnergy extends HKUnit, TDistance extends HKUnit> = {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
609
|
+
readonly uuid: string;
|
|
610
|
+
readonly device?: HKDevice;
|
|
611
|
+
readonly workoutActivityType: HKWorkoutActivityType;
|
|
612
|
+
readonly duration: number;
|
|
613
|
+
readonly totalDistance?: HKQuantity<TDistance>;
|
|
614
|
+
readonly totalEnergyBurned?: HKQuantity<TEnergy>;
|
|
615
|
+
readonly totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
|
|
616
|
+
readonly totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
|
|
617
|
+
readonly startDate: string;
|
|
618
|
+
readonly endDate: string;
|
|
619
|
+
readonly metadata?: HKWorkoutMetadata;
|
|
620
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
614
621
|
};
|
|
615
622
|
|
|
616
623
|
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkcharacteristictypeidentifier
|
|
@@ -622,40 +629,34 @@ export enum HKCharacteristicTypeIdentifier {
|
|
|
622
629
|
wheelchairUse = 'HKCharacteristicTypeIdentifierWheelchairUse',
|
|
623
630
|
}
|
|
624
631
|
|
|
625
|
-
export type
|
|
626
|
-
[key in
|
|
627
|
-
| HKCharacteristicTypeIdentifier
|
|
628
|
-
| HKQuantityTypeIdentifier
|
|
629
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
632
|
+
export type WritePermissions = {
|
|
633
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
630
634
|
};
|
|
631
635
|
|
|
632
|
-
export type
|
|
633
|
-
[key in
|
|
634
|
-
| HKQuantityTypeIdentifier
|
|
635
|
-
| HKCharacteristicTypeIdentifier
|
|
636
|
-
| HKCategoryTypeIdentifier]: boolean;
|
|
636
|
+
export type ReadPermissions = {
|
|
637
|
+
readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
|
|
637
638
|
};
|
|
638
639
|
|
|
639
640
|
export type HKCategorySampleRaw<
|
|
640
641
|
T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
641
642
|
> = {
|
|
642
|
-
uuid: string;
|
|
643
|
-
device?: HKDevice;
|
|
644
|
-
categoryType: T;
|
|
645
|
-
startDate: string;
|
|
646
|
-
endDate: string;
|
|
647
|
-
value: HKCategoryValueForIdentifier<T>;
|
|
648
|
-
metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
649
|
-
sourceRevision?: HKSourceRevision;
|
|
643
|
+
readonly uuid: string;
|
|
644
|
+
readonly device?: HKDevice;
|
|
645
|
+
readonly categoryType: T;
|
|
646
|
+
readonly startDate: string;
|
|
647
|
+
readonly endDate: string;
|
|
648
|
+
readonly value: HKCategoryValueForIdentifier<T>;
|
|
649
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
650
|
+
readonly sourceRevision?: HKSourceRevision;
|
|
650
651
|
};
|
|
651
652
|
|
|
652
653
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
653
654
|
{
|
|
654
|
-
correlationType: HKCorrelationTypeIdentifier;
|
|
655
|
-
objects: (
|
|
656
|
-
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
657
|
-
startDate: string;
|
|
658
|
-
endDate: string;
|
|
655
|
+
readonly correlationType: HKCorrelationTypeIdentifier;
|
|
656
|
+
readonly objects: readonly (HKCategorySampleRaw | HKQuantitySampleRaw)[];
|
|
657
|
+
readonly metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
658
|
+
readonly startDate: string;
|
|
659
|
+
readonly endDate: string;
|
|
659
660
|
};
|
|
660
661
|
|
|
661
662
|
type QueryId = string;
|
|
@@ -673,106 +674,108 @@ export enum HKUpdateFrequency {
|
|
|
673
674
|
}
|
|
674
675
|
|
|
675
676
|
export type WorkoutLocation = {
|
|
676
|
-
longitude: number;
|
|
677
|
-
latitude: number;
|
|
678
|
-
altitude: number;
|
|
679
|
-
speed: number;
|
|
680
|
-
timestamp: number;
|
|
681
|
-
horizontalAccuracy: number;
|
|
682
|
-
speedAccuracy: number;
|
|
683
|
-
verticalAccuracy: number;
|
|
677
|
+
readonly longitude: number;
|
|
678
|
+
readonly latitude: number;
|
|
679
|
+
readonly altitude: number;
|
|
680
|
+
readonly speed: number;
|
|
681
|
+
readonly timestamp: number;
|
|
682
|
+
readonly horizontalAccuracy: number;
|
|
683
|
+
readonly speedAccuracy: number;
|
|
684
|
+
readonly verticalAccuracy: number;
|
|
684
685
|
};
|
|
685
686
|
|
|
686
687
|
export type WorkoutRoute = {
|
|
687
|
-
locations: WorkoutLocation[];
|
|
688
|
-
HKMetadataKeySyncIdentifier?: string;
|
|
689
|
-
HKMetadataKeySyncVersion?: number;
|
|
688
|
+
readonly locations: readonly WorkoutLocation[];
|
|
689
|
+
readonly HKMetadataKeySyncIdentifier?: string;
|
|
690
|
+
readonly HKMetadataKeySyncVersion?: number;
|
|
690
691
|
};
|
|
691
692
|
|
|
693
|
+
type AuthorizationStatusFor = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier
|
|
694
|
+
|
|
692
695
|
type ReactNativeHealthkitTypeNative = {
|
|
693
696
|
isHealthDataAvailable(): Promise<boolean>;
|
|
694
697
|
getBloodType(): Promise<HKBloodType>;
|
|
695
698
|
getDateOfBirth(): Promise<string>;
|
|
696
699
|
getBiologicalSex(): Promise<HKBiologicalSex>;
|
|
697
700
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
698
|
-
getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
701
|
+
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
699
702
|
|
|
700
|
-
enableBackgroundDelivery: (
|
|
703
|
+
readonly enableBackgroundDelivery: (
|
|
701
704
|
typeIdentifier: HKSampleTypeIdentifier,
|
|
702
705
|
updateFrequency: HKUpdateFrequency
|
|
703
706
|
) => Promise<boolean>;
|
|
704
|
-
disableBackgroundDelivery: (
|
|
707
|
+
readonly disableBackgroundDelivery: (
|
|
705
708
|
typeIdentifier: HKSampleTypeIdentifier
|
|
706
709
|
) => Promise<boolean>;
|
|
707
|
-
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
710
|
+
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
708
711
|
|
|
709
|
-
saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
712
|
+
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
710
713
|
typeIdentifier: TIdentifier,
|
|
711
|
-
samples: Omit<
|
|
712
|
-
|
|
713
|
-
|
|
714
|
+
samples: readonly Omit<
|
|
715
|
+
HKCategorySampleRaw | HKQuantitySampleRaw,
|
|
716
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
714
717
|
>[],
|
|
715
718
|
start: string,
|
|
716
719
|
end: string,
|
|
717
720
|
metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>
|
|
718
721
|
) => Promise<boolean>;
|
|
719
722
|
|
|
720
|
-
saveWorkoutSample: (
|
|
723
|
+
readonly saveWorkoutSample: (
|
|
721
724
|
typeIdentifier: HKWorkoutActivityType,
|
|
722
|
-
quantities: Omit<
|
|
723
|
-
|
|
724
|
-
|
|
725
|
+
quantities: readonly Omit<
|
|
726
|
+
HKQuantitySampleRaw,
|
|
727
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
725
728
|
>[],
|
|
726
729
|
start: string,
|
|
727
730
|
end: string,
|
|
728
731
|
metadata: HKWorkoutMetadata
|
|
729
732
|
) => Promise<boolean>;
|
|
730
733
|
|
|
731
|
-
queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
734
|
+
readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(
|
|
732
735
|
typeIdentifier: TIdentifier,
|
|
733
736
|
from: string,
|
|
734
737
|
to: string
|
|
735
|
-
) => Promise<HKCorrelationRaw<TIdentifier>[]>;
|
|
738
|
+
) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
|
|
736
739
|
|
|
737
740
|
subscribeToObserverQuery(
|
|
738
741
|
identifier: HKSampleTypeIdentifier
|
|
739
742
|
): Promise<QueryId>;
|
|
740
743
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
741
744
|
authorizationStatusFor(
|
|
742
|
-
type:
|
|
745
|
+
type: AuthorizationStatusFor
|
|
743
746
|
): Promise<boolean>;
|
|
744
747
|
getRequestStatusForAuthorization(
|
|
745
|
-
write:
|
|
746
|
-
read:
|
|
748
|
+
write: WritePermissions,
|
|
749
|
+
read: ReadPermissions
|
|
747
750
|
): Promise<HKAuthorizationRequestStatus>;
|
|
748
751
|
requestAuthorization(
|
|
749
|
-
write:
|
|
750
|
-
read:
|
|
752
|
+
write: WritePermissions,
|
|
753
|
+
read: ReadPermissions
|
|
751
754
|
): Promise<boolean>;
|
|
752
|
-
saveQuantitySample: (
|
|
755
|
+
readonly saveQuantitySample: (
|
|
753
756
|
identifier: HKQuantityTypeIdentifier,
|
|
754
757
|
unit: HKUnit,
|
|
755
758
|
value: number,
|
|
756
759
|
start: string,
|
|
757
760
|
end: string,
|
|
758
|
-
metadata:
|
|
761
|
+
metadata: unknown
|
|
759
762
|
) => Promise<boolean>;
|
|
760
|
-
queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
763
|
+
readonly queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(
|
|
761
764
|
energyUnit: TEnergy,
|
|
762
765
|
distanceUnit: TDistance,
|
|
763
766
|
from: string,
|
|
764
767
|
to: string,
|
|
765
|
-
limit:
|
|
768
|
+
limit: number,
|
|
766
769
|
ascending: boolean
|
|
767
|
-
) => Promise<HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
768
|
-
queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
770
|
+
) => Promise<readonly HKWorkoutRaw<TEnergy, TDistance>[]>;
|
|
771
|
+
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(
|
|
769
772
|
identifier: T,
|
|
770
773
|
from: string,
|
|
771
774
|
to: string,
|
|
772
|
-
limit:
|
|
775
|
+
limit: number,
|
|
773
776
|
ascending: boolean
|
|
774
|
-
) => Promise<HKCategorySampleRaw<T>[]>;
|
|
775
|
-
queryQuantitySamples: <
|
|
777
|
+
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
778
|
+
readonly queryQuantitySamples: <
|
|
776
779
|
TUnit extends HKUnit,
|
|
777
780
|
TIdentifier extends HKQuantityTypeIdentifier
|
|
778
781
|
>(
|
|
@@ -780,47 +783,46 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
780
783
|
unit: TUnit,
|
|
781
784
|
from: string,
|
|
782
785
|
to: string,
|
|
783
|
-
limit:
|
|
786
|
+
limit: number,
|
|
784
787
|
ascending: boolean
|
|
785
|
-
) => Promise<HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
786
|
-
saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
788
|
+
) => Promise<readonly HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
|
|
789
|
+
readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(
|
|
787
790
|
identifier: T,
|
|
788
791
|
value: HKCategoryValueForIdentifier<T>,
|
|
789
792
|
start: string,
|
|
790
793
|
end: string,
|
|
791
|
-
metadata:
|
|
794
|
+
metadata: unknown
|
|
792
795
|
) => Promise<boolean>;
|
|
793
|
-
queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
796
|
+
readonly queryStatisticsForQuantity: <TUnit extends HKUnit>(
|
|
794
797
|
identifier: HKQuantityTypeIdentifier,
|
|
795
798
|
unit: TUnit,
|
|
796
799
|
from: string,
|
|
797
800
|
to: string,
|
|
798
|
-
options: HKStatisticsOptions[]
|
|
801
|
+
options: readonly HKStatisticsOptions[]
|
|
799
802
|
) => Promise<QueryStatisticsResponseRaw<TUnit>>;
|
|
800
|
-
getPreferredUnits: (
|
|
801
|
-
identifiers: HKQuantityTypeIdentifier[]
|
|
803
|
+
readonly getPreferredUnits: (
|
|
804
|
+
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
802
805
|
) => Promise<TypeToUnitMapping>;
|
|
803
|
-
getWorkoutRoutes: (workoutUUID: string) => Promise<WorkoutRoute[]>;
|
|
806
|
+
readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
|
|
804
807
|
};
|
|
805
808
|
|
|
806
|
-
const Native =
|
|
807
|
-
NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative;
|
|
809
|
+
const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
|
|
808
810
|
|
|
809
811
|
type OnChangeCallback = ({
|
|
810
812
|
typeIdentifier,
|
|
811
813
|
}: {
|
|
812
|
-
typeIdentifier: HKSampleTypeIdentifier;
|
|
814
|
+
readonly typeIdentifier: HKSampleTypeIdentifier;
|
|
813
815
|
}) => void;
|
|
814
816
|
|
|
815
817
|
interface HealthkitEventEmitter extends NativeEventEmitter {
|
|
816
|
-
addListener: (
|
|
818
|
+
readonly addListener: (
|
|
817
819
|
eventType: 'onChange',
|
|
818
820
|
callback: OnChangeCallback
|
|
819
821
|
) => EmitterSubscription;
|
|
820
822
|
}
|
|
821
823
|
|
|
822
824
|
export const EventEmitter = new NativeEventEmitter(
|
|
823
|
-
NativeModules.ReactNativeHealthkit
|
|
824
|
-
) as HealthkitEventEmitter
|
|
825
|
+
NativeModules.ReactNativeHealthkit,
|
|
826
|
+
) as HealthkitEventEmitter
|
|
825
827
|
|
|
826
|
-
export default Native
|
|
828
|
+
export default Native
|