@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.
@@ -1,9 +1,12 @@
1
- import { EmitterSubscription, NativeEventEmitter } from 'react-native';
2
- export declare type HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier';
3
- export declare type HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier';
4
- export declare type HKSampleTypeIdentifier = HKWorkoutTypeIdentifier | HKQuantityTypeIdentifier | HKCategoryTypeIdentifier | HKAudiogramTypeIdentifier | HKCorrelationTypeIdentifier;
1
+ import { NativeEventEmitter } from 'react-native';
2
+ import type { EmitterSubscription } from 'react-native';
3
+ export declare const HKWorkoutTypeIdentifier = "HKWorkoutTypeIdentifier";
4
+ export declare const HKAudiogramTypeIdentifier = "HKAudiogramTypeIdentifier";
5
+ export declare const HKWorkoutRouteTypeIdentifier = "HKWorkoutRouteTypeIdentifier";
6
+ export declare const HKDataTypeIdentifierHeartbeatSeries = "HKDataTypeIdentifierHeartbeatSeries";
7
+ export declare type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier;
5
8
  export declare type TypeToUnitMapping = {
6
- [key in HKQuantityTypeIdentifier]: HKUnit;
9
+ readonly [key in HKQuantityTypeIdentifier]: HKUnit;
7
10
  };
8
11
  export declare enum HKHeartRateMotionContext {
9
12
  active = 2,
@@ -109,21 +112,21 @@ export declare enum HKWorkoutActivityType {
109
112
  other = 3000
110
113
  }
111
114
  export declare type HKGenericMetadata = {
112
- [key: string]: string | number | boolean | HKQuantity | undefined;
113
- HKExternalUUID?: string;
114
- HKTimeZone?: string;
115
- HKWasUserEntered?: boolean;
116
- HKDeviceSerialNumber?: string;
117
- HKUDIDeviceIdentifier?: string;
118
- HKUDIProductionIdentifier?: string;
119
- HKDigitalSignature?: string;
120
- HKDeviceName?: string;
121
- HKDeviceManufacturerName?: string;
122
- HKSyncIdentifier?: string;
123
- HKSyncVersion?: number;
124
- HKWasTakenInLab?: boolean;
125
- HKReferenceRangeLowerLimit?: number;
126
- HKReferenceRangeUpperLimit?: number;
115
+ readonly [key: string]: HKQuantity | boolean | number | string | undefined;
116
+ readonly HKExternalUUID?: string;
117
+ readonly HKTimeZone?: string;
118
+ readonly HKWasUserEntered?: boolean;
119
+ readonly HKDeviceSerialNumber?: string;
120
+ readonly HKUDIDeviceIdentifier?: string;
121
+ readonly HKUDIProductionIdentifier?: string;
122
+ readonly HKDigitalSignature?: string;
123
+ readonly HKDeviceName?: string;
124
+ readonly HKDeviceManufacturerName?: string;
125
+ readonly HKSyncIdentifier?: string;
126
+ readonly HKSyncVersion?: number;
127
+ readonly HKWasTakenInLab?: boolean;
128
+ readonly HKReferenceRangeLowerLimit?: number;
129
+ readonly HKReferenceRangeUpperLimit?: number;
127
130
  };
128
131
  export declare enum HKWeatherCondition {
129
132
  none = 0,
@@ -156,8 +159,8 @@ export declare enum HKWeatherCondition {
156
159
  tornado = 27
157
160
  }
158
161
  export interface HKWorkoutMetadata extends HKGenericMetadata {
159
- HKWeatherCondition?: HKWeatherCondition;
160
- HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
162
+ readonly HKWeatherCondition?: HKWeatherCondition;
163
+ readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
161
164
  }
162
165
  export declare enum HKQuantityTypeIdentifier {
163
166
  bodyMassIndex = "HKQuantityTypeIdentifierBodyMassIndex",
@@ -262,8 +265,8 @@ export declare enum HKAuthorizationStatus {
262
265
  sharingAuthorized = 2
263
266
  }
264
267
  export declare type HKQuantity<T extends HKUnit = HKUnit> = {
265
- unit: T;
266
- quantity: number;
268
+ readonly unit: T;
269
+ readonly quantity: number;
267
270
  };
268
271
  export declare enum HKBloodType {
269
272
  notSet = 0,
@@ -302,16 +305,16 @@ export declare enum HKStatisticsOptions {
302
305
  separateBySource = "separateBySource"
303
306
  }
304
307
  export declare type QueryStatisticsResponseRaw<TUnit extends HKUnit = HKUnit> = {
305
- averageQuantity?: HKQuantity<TUnit>;
306
- maximumQuantity?: HKQuantity<TUnit>;
307
- minimumQuantity?: HKQuantity<TUnit>;
308
- sumQuantity?: HKQuantity<TUnit>;
309
- mostRecentQuantity?: HKQuantity<TUnit>;
310
- mostRecentQuantityDateInterval?: {
311
- from: string;
312
- to: string;
308
+ readonly averageQuantity?: HKQuantity<TUnit>;
309
+ readonly maximumQuantity?: HKQuantity<TUnit>;
310
+ readonly minimumQuantity?: HKQuantity<TUnit>;
311
+ readonly sumQuantity?: HKQuantity<TUnit>;
312
+ readonly mostRecentQuantity?: HKQuantity<TUnit>;
313
+ readonly mostRecentQuantityDateInterval?: {
314
+ readonly from: string;
315
+ readonly to: string;
313
316
  };
314
- duration?: HKQuantity<HKUnit.Seconds>;
317
+ readonly duration?: HKQuantity<HKUnit.Seconds>;
315
318
  };
316
319
  export declare enum HKCategoryValueCervicalMucusQuality {
317
320
  dry = 1,
@@ -358,26 +361,26 @@ export declare enum HKCategoryValueSeverity {
358
361
  export declare enum HKCategoryValueNotApplicable {
359
362
  notApplicable = 0
360
363
  }
361
- export declare type HKCategoryValue = HKCategoryValueAppetiteChanges | HKCategoryValuePresence | HKCategoryValueSeverity | HKCategoryValuePresence | HKCategoryValueMenstrualFlow | HKCategoryValueSleepAnalysis | HKCategoryValueCervicalMucusQuality | HKCategoryValueOvulationTestResult | number;
364
+ export declare type HKCategoryValue = HKCategoryValueAppetiteChanges | HKCategoryValueCervicalMucusQuality | HKCategoryValueMenstrualFlow | HKCategoryValueOvulationTestResult | HKCategoryValuePresence | HKCategoryValuePresence | HKCategoryValueSeverity | HKCategoryValueSleepAnalysis | number;
362
365
  export declare enum HKInsulinDeliveryReason {
363
366
  basal = 1,
364
367
  bolus = 2
365
368
  }
366
369
  export declare type MetadataMapperForQuantityIdentifier<TQuantityTypeIdentifier = HKQuantityTypeIdentifier> = TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.insulinDelivery ? HKGenericMetadata & {
367
- HKInsulinDeliveryReason: HKInsulinDeliveryReason;
370
+ readonly HKInsulinDeliveryReason: HKInsulinDeliveryReason;
368
371
  } : TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.bloodGlucose ? HKGenericMetadata & {
369
- HKBloodGlucoseMealTime?: number;
372
+ readonly HKBloodGlucoseMealTime?: number;
370
373
  } : TQuantityTypeIdentifier extends HKQuantityTypeIdentifier.heartRate ? HKGenericMetadata & {
371
- HKHeartRateMotionContext?: HKHeartRateMotionContext;
374
+ readonly HKHeartRateMotionContext?: HKHeartRateMotionContext;
372
375
  } : HKGenericMetadata;
373
376
  export declare type MetadataMapperForCorrelationIdentifier<TCorrelationTypeIdentifier = HKCorrelationTypeIdentifier> = TCorrelationTypeIdentifier extends HKCorrelationTypeIdentifier.food ? HKGenericMetadata & {
374
- HKFoodType?: string;
377
+ readonly HKFoodType?: string;
375
378
  } : HKGenericMetadata;
376
379
  export declare type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> = T extends HKCategoryTypeIdentifier.cervicalMucusQuality ? HKCategoryValueCervicalMucusQuality : T extends HKCategoryTypeIdentifier.menstrualFlow ? HKCategoryValueMenstrualFlow : T extends HKCategoryTypeIdentifier.ovulationTestResult ? HKCategoryValueOvulationTestResult : T extends HKCategoryTypeIdentifier.sleepAnalysis ? HKCategoryValueSleepAnalysis : T extends HKCategoryTypeIdentifier.mindfulSession ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.intermenstrualBleeding ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.highHeartRateEvent ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.sexualActivity ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.appleStandHour ? HKCategoryValueAppleStandHour : number;
377
380
  export declare type MetadataMapperForCategoryIdentifier<T extends HKCategoryTypeIdentifier> = T extends HKCategoryTypeIdentifier.sexualActivity ? HKGenericMetadata & {
378
- HKSexualActivityProtectionUsed: boolean;
381
+ readonly HKSexualActivityProtectionUsed: boolean;
379
382
  } : T extends HKCategoryTypeIdentifier.menstrualFlow ? HKGenericMetadata & {
380
- HKMenstrualCycleStart: boolean;
383
+ readonly HKMenstrualCycleStart: boolean;
381
384
  } : HKGenericMetadata;
382
385
  export declare enum HKWheelchairUse {
383
386
  notSet = 0,
@@ -451,46 +454,48 @@ export declare enum HKUnit {
451
454
  GlucoseMgPerDl = "mg/dL"
452
455
  }
453
456
  export declare type HKDevice = {
454
- name: string;
455
- firmwareVersion: string;
456
- hardwareVersion: string;
457
- localIdentifier: string;
458
- manufacturer: string;
459
- model: string;
460
- softwareVersion: string;
457
+ readonly name: string;
458
+ readonly firmwareVersion: string;
459
+ readonly hardwareVersion: string;
460
+ readonly localIdentifier: string;
461
+ readonly manufacturer: string;
462
+ readonly model: string;
463
+ readonly softwareVersion: string;
461
464
  };
462
465
  export declare type HKSource = {
463
- name: string;
464
- bundleIdentifier: string;
466
+ readonly name: string;
467
+ readonly bundleIdentifier: string;
465
468
  };
466
469
  export declare type HKSourceRevision = {
467
- source: HKSource;
468
- version: string;
469
- operatingSystemVersion?: string;
470
- productType?: string;
470
+ readonly source: HKSource;
471
+ readonly version: string;
472
+ readonly operatingSystemVersion?: string;
473
+ readonly productType?: string;
471
474
  };
472
475
  export declare type HKQuantitySampleRaw<TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends HKUnit = HKUnit> = {
473
- uuid: string;
474
- device?: HKDevice;
475
- quantityType: TQuantityIdentifier;
476
- startDate: string;
477
- endDate: string;
478
- quantity: number;
479
- unit: TUnit;
480
- metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
481
- sourceRevision?: HKSourceRevision;
476
+ readonly uuid: string;
477
+ readonly device?: HKDevice;
478
+ readonly quantityType: TQuantityIdentifier;
479
+ readonly startDate: string;
480
+ readonly endDate: string;
481
+ readonly quantity: number;
482
+ readonly unit: TUnit;
483
+ readonly metadata: MetadataMapperForQuantityIdentifier<TQuantityIdentifier>;
484
+ readonly sourceRevision?: HKSourceRevision;
482
485
  };
483
486
  export declare type HKWorkoutRaw<TEnergy extends HKUnit, TDistance extends HKUnit> = {
484
- workoutActivityType: HKWorkoutActivityType;
485
- duration: number;
486
- totalDistance?: HKQuantity<TDistance>;
487
- totalEnergyBurned?: HKQuantity<TEnergy>;
488
- totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
489
- totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
490
- startDate: string;
491
- endDate: string;
492
- metadata?: HKWorkoutMetadata;
493
- sourceRevision?: HKSourceRevision;
487
+ readonly uuid: string;
488
+ readonly device?: HKDevice;
489
+ readonly workoutActivityType: HKWorkoutActivityType;
490
+ readonly duration: number;
491
+ readonly totalDistance?: HKQuantity<TDistance>;
492
+ readonly totalEnergyBurned?: HKQuantity<TEnergy>;
493
+ readonly totalSwimmingStrokeCount?: HKQuantity<HKUnit.Count>;
494
+ readonly totalFlightsClimbed?: HKQuantity<HKUnit.Count>;
495
+ readonly startDate: string;
496
+ readonly endDate: string;
497
+ readonly metadata?: HKWorkoutMetadata;
498
+ readonly sourceRevision?: HKSourceRevision;
494
499
  };
495
500
  export declare enum HKCharacteristicTypeIdentifier {
496
501
  fitzpatrickSkinType = "HKCharacteristicTypeIdentifierFitzpatrickSkinType",
@@ -499,28 +504,28 @@ export declare enum HKCharacteristicTypeIdentifier {
499
504
  dateOfBirth = "HKCharacteristicTypeIdentifierDateOfBirth",
500
505
  wheelchairUse = "HKCharacteristicTypeIdentifierWheelchairUse"
501
506
  }
502
- export declare type WritePermssions = {
503
- [key in HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier | HKCategoryTypeIdentifier]: boolean;
507
+ export declare type WritePermissions = {
508
+ readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
504
509
  };
505
- export declare type ReadPermssions = {
506
- [key in HKQuantityTypeIdentifier | HKCharacteristicTypeIdentifier | HKCategoryTypeIdentifier]: boolean;
510
+ export declare type ReadPermissions = {
511
+ readonly [key in HKCategoryTypeIdentifier | HKCharacteristicTypeIdentifier | HKQuantityTypeIdentifier]: boolean;
507
512
  };
508
513
  export declare type HKCategorySampleRaw<T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier> = {
509
- uuid: string;
510
- device?: HKDevice;
511
- categoryType: T;
512
- startDate: string;
513
- endDate: string;
514
- value: HKCategoryValueForIdentifier<T>;
515
- metadata: MetadataMapperForCategoryIdentifier<T>;
516
- sourceRevision?: HKSourceRevision;
514
+ readonly uuid: string;
515
+ readonly device?: HKDevice;
516
+ readonly categoryType: T;
517
+ readonly startDate: string;
518
+ readonly endDate: string;
519
+ readonly value: HKCategoryValueForIdentifier<T>;
520
+ readonly metadata: MetadataMapperForCategoryIdentifier<T>;
521
+ readonly sourceRevision?: HKSourceRevision;
517
522
  };
518
523
  export declare type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> = {
519
- correlationType: HKCorrelationTypeIdentifier;
520
- objects: (HKQuantitySampleRaw | HKCategorySampleRaw)[];
521
- metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
522
- startDate: string;
523
- endDate: string;
524
+ readonly correlationType: HKCorrelationTypeIdentifier;
525
+ readonly objects: readonly (HKCategorySampleRaw | HKQuantitySampleRaw)[];
526
+ readonly metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>;
527
+ readonly startDate: string;
528
+ readonly endDate: string;
524
529
  };
525
530
  declare type QueryId = string;
526
531
  export declare enum HKCorrelationTypeIdentifier {
@@ -534,53 +539,54 @@ export declare enum HKUpdateFrequency {
534
539
  weekly = 4
535
540
  }
536
541
  export declare type WorkoutLocation = {
537
- longitude: number;
538
- latitude: number;
539
- altitude: number;
540
- speed: number;
541
- timestamp: number;
542
- horizontalAccuracy: number;
543
- speedAccuracy: number;
544
- verticalAccuracy: number;
542
+ readonly longitude: number;
543
+ readonly latitude: number;
544
+ readonly altitude: number;
545
+ readonly speed: number;
546
+ readonly timestamp: number;
547
+ readonly horizontalAccuracy: number;
548
+ readonly speedAccuracy: number;
549
+ readonly verticalAccuracy: number;
545
550
  };
546
551
  export declare type WorkoutRoute = {
547
- locations: WorkoutLocation[];
548
- HKMetadataKeySyncIdentifier?: string;
549
- HKMetadataKeySyncVersion?: number;
552
+ readonly locations: readonly WorkoutLocation[];
553
+ readonly HKMetadataKeySyncIdentifier?: string;
554
+ readonly HKMetadataKeySyncVersion?: number;
550
555
  };
556
+ declare type AuthorizationStatusFor = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier;
551
557
  declare type ReactNativeHealthkitTypeNative = {
552
558
  isHealthDataAvailable(): Promise<boolean>;
553
559
  getBloodType(): Promise<HKBloodType>;
554
560
  getDateOfBirth(): Promise<string>;
555
561
  getBiologicalSex(): Promise<HKBiologicalSex>;
556
562
  getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
557
- getWheelchairUse: () => Promise<HKWheelchairUse>;
558
- enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
559
- disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
560
- disableAllBackgroundDelivery: () => Promise<boolean>;
561
- saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, samples: Omit<HKQuantitySampleRaw | HKCategorySampleRaw, 'startDate' | 'endDate' | 'uuid' | 'device'>[], start: string, end: string, metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>) => Promise<boolean>;
562
- saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: Omit<HKQuantitySampleRaw, 'startDate' | 'endDate' | 'uuid' | 'device'>[], start: string, end: string, metadata: HKWorkoutMetadata) => Promise<boolean>;
563
- queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, from: string, to: string) => Promise<HKCorrelationRaw<TIdentifier>[]>;
563
+ readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
564
+ readonly enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
565
+ readonly disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
566
+ readonly disableAllBackgroundDelivery: () => Promise<boolean>;
567
+ readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, samples: readonly Omit<HKCategorySampleRaw | HKQuantitySampleRaw, 'device' | 'endDate' | 'startDate' | 'uuid'>[], start: string, end: string, metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>) => Promise<boolean>;
568
+ readonly saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: readonly Omit<HKQuantitySampleRaw, 'device' | 'endDate' | 'startDate' | 'uuid'>[], start: string, end: string, metadata: HKWorkoutMetadata) => Promise<boolean>;
569
+ readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, from: string, to: string) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
564
570
  subscribeToObserverQuery(identifier: HKSampleTypeIdentifier): Promise<QueryId>;
565
571
  unsubscribeQuery(queryId: QueryId): Promise<boolean>;
566
- authorizationStatusFor(type: HKSampleTypeIdentifier | HKCharacteristicTypeIdentifier): Promise<boolean>;
567
- getRequestStatusForAuthorization(write: WritePermssions | {}, read: ReadPermssions | {}): Promise<HKAuthorizationRequestStatus>;
568
- requestAuthorization(write: WritePermssions | {}, read: ReadPermssions | {}): Promise<boolean>;
569
- saveQuantitySample: (identifier: HKQuantityTypeIdentifier, unit: HKUnit, value: number, start: string, end: string, metadata: Object) => Promise<boolean>;
570
- queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(energyUnit: TEnergy, distanceUnit: TDistance, from: string, to: string, limit: Number, ascending: boolean) => Promise<HKWorkoutRaw<TEnergy, TDistance>[]>;
571
- queryCategorySamples: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: Number, ascending: boolean) => Promise<HKCategorySampleRaw<T>[]>;
572
- queryQuantitySamples: <TUnit extends HKUnit, TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: Number, ascending: boolean) => Promise<HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
573
- saveCategorySample: <T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, start: string, end: string, metadata: Object) => Promise<boolean>;
574
- queryStatisticsForQuantity: <TUnit extends HKUnit>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TUnit>>;
575
- getPreferredUnits: (identifiers: HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
576
- getWorkoutRoutes: (workoutUUID: string) => Promise<WorkoutRoute[]>;
572
+ authorizationStatusFor(type: AuthorizationStatusFor): Promise<boolean>;
573
+ getRequestStatusForAuthorization(write: WritePermissions, read: ReadPermissions): Promise<HKAuthorizationRequestStatus>;
574
+ requestAuthorization(write: WritePermissions, read: ReadPermissions): Promise<boolean>;
575
+ readonly saveQuantitySample: (identifier: HKQuantityTypeIdentifier, unit: HKUnit, value: number, start: string, end: string, metadata: unknown) => Promise<boolean>;
576
+ readonly queryWorkoutSamples: <TEnergy extends HKUnit, TDistance extends HKUnit>(energyUnit: TEnergy, distanceUnit: TDistance, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKWorkoutRaw<TEnergy, TDistance>[]>;
577
+ readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKCategorySampleRaw<T>[]>;
578
+ readonly queryQuantitySamples: <TUnit extends HKUnit, TIdentifier extends HKQuantityTypeIdentifier>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKQuantitySampleRaw<TIdentifier, TUnit>[]>;
579
+ readonly saveCategorySample: <T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, start: string, end: string, metadata: unknown) => Promise<boolean>;
580
+ readonly queryStatisticsForQuantity: <TUnit extends HKUnit>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: readonly HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TUnit>>;
581
+ readonly getPreferredUnits: (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
582
+ readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
577
583
  };
578
584
  declare const Native: ReactNativeHealthkitTypeNative;
579
585
  declare type OnChangeCallback = ({ typeIdentifier, }: {
580
- typeIdentifier: HKSampleTypeIdentifier;
586
+ readonly typeIdentifier: HKSampleTypeIdentifier;
581
587
  }) => void;
582
588
  interface HealthkitEventEmitter extends NativeEventEmitter {
583
- addListener: (eventType: 'onChange', callback: OnChangeCallback) => EmitterSubscription;
589
+ readonly addListener: (eventType: 'onChange', callback: OnChangeCallback) => EmitterSubscription;
584
590
  }
585
591
  export declare const EventEmitter: HealthkitEventEmitter;
586
592
  export default Native;
@@ -1,30 +1,30 @@
1
1
  import type { HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKCategorySampleRaw, HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, HKCharacteristicTypeIdentifier, HKCorrelationRaw, HKCorrelationTypeIdentifier, HKFitzpatrickSkinType, HKQuantitySampleRaw, HKQuantityTypeIdentifier, HKSampleTypeIdentifier, HKStatisticsOptions, HKUnit, HKUnitSI, HKUnitSIPrefix, HKUpdateFrequency, HKWheelchairUse, HKWorkoutActivityType, HKWorkoutMetadata, HKWorkoutRaw, MetadataMapperForCategoryIdentifier, MetadataMapperForCorrelationIdentifier, MetadataMapperForQuantityIdentifier, QueryStatisticsResponseRaw, WorkoutRoute } from './native-types';
2
2
  export interface QueryWorkoutsOptions<TEnergy extends HKUnit, TDistance extends HKUnit> extends GenericQueryOptions {
3
- energyUnit?: TEnergy;
4
- distanceUnit?: TDistance;
3
+ readonly energyUnit?: TEnergy;
4
+ readonly distanceUnit?: TDistance;
5
5
  }
6
- export interface HKCategorySample<T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier> extends Omit<HKCategorySampleRaw<T>, 'startDate' | 'endDate'> {
7
- startDate: Date;
8
- endDate: Date;
6
+ export interface HKCategorySample<T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier> extends Omit<HKCategorySampleRaw<T>, 'endDate' | 'startDate'> {
7
+ readonly startDate: Date;
8
+ readonly endDate: Date;
9
9
  }
10
10
  export declare type GenericQueryOptions = {
11
- from?: Date;
12
- to?: Date;
13
- limit?: Number;
14
- ascending?: boolean;
11
+ readonly from?: Date;
12
+ readonly to?: Date;
13
+ readonly limit?: number;
14
+ readonly ascending?: boolean;
15
15
  };
16
- export interface HKWorkout<TEnergy extends HKUnit = HKUnit, TDistance extends HKUnit = HKUnit> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'startDate' | 'endDate'> {
17
- startDate: Date;
18
- endDate: Date;
16
+ export interface HKWorkout<TEnergy extends HKUnit = HKUnit, TDistance extends HKUnit = HKUnit> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {
17
+ readonly startDate: Date;
18
+ readonly endDate: Date;
19
19
  }
20
- export interface HKQuantitySample<TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends HKUnit = HKUnit> extends Omit<HKQuantitySampleRaw<TIdentifier, TUnit>, 'startDate' | 'endDate'> {
21
- startDate: Date;
22
- endDate: Date;
20
+ export interface HKQuantitySample<TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier, TUnit extends HKUnit = HKUnit> extends Omit<HKQuantitySampleRaw<TIdentifier, TUnit>, 'endDate' | 'startDate'> {
21
+ readonly startDate: Date;
22
+ readonly endDate: Date;
23
23
  }
24
24
  export interface QueryStatisticsResponse<T extends HKUnit = HKUnit> extends Omit<QueryStatisticsResponseRaw<T>, 'mostRecentQuantityDateInterval'> {
25
- mostRecentQuantityDateInterval?: {
26
- from: Date;
27
- to: Date;
25
+ readonly mostRecentQuantityDateInterval?: {
26
+ readonly from: Date;
27
+ readonly to: Date;
28
28
  };
29
29
  }
30
30
  declare type UnsubscribeFunction = () => Promise<boolean>;
@@ -34,25 +34,25 @@ export declare type GetDateOfBirthFn = () => Promise<Date>;
34
34
  export declare type GetBiologicalSexFn = () => Promise<HKBiologicalSex>;
35
35
  export declare type GetWheelchairUseFn = () => Promise<HKWheelchairUse>;
36
36
  export declare type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;
37
- export declare type QueryStatisticsForQuantityFn = <TUnit extends HKUnit>(identifier: HKQuantityTypeIdentifier, options: HKStatisticsOptions[], from: Date, to?: Date, unit?: TUnit) => Promise<QueryStatisticsResponse<TUnit>>;
38
- export declare type QueryWorkoutsFn = <TEnergy extends HKUnit, TDistance extends HKUnit>(options: QueryWorkoutsOptions<TEnergy, TDistance>) => Promise<HKWorkout<TEnergy, TDistance>[]>;
39
- export declare type AuthorizationStatusForFn = (type: HKSampleTypeIdentifier | HKCharacteristicTypeIdentifier) => Promise<boolean>;
40
- export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<HKCategorySample<T>[]>;
41
- export declare type GetRequestStatusForAuthorizationFn = (read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[], write?: HKSampleTypeIdentifier[]) => Promise<HKAuthorizationRequestStatus>;
42
- export declare type RequestAuthorizationFn = (read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[], write?: HKSampleTypeIdentifier[]) => Promise<boolean>;
37
+ export declare type QueryStatisticsForQuantityFn = <TUnit extends HKUnit>(identifier: HKQuantityTypeIdentifier, options: readonly HKStatisticsOptions[], from: Date, to?: Date, unit?: TUnit) => Promise<QueryStatisticsResponse<TUnit>>;
38
+ export declare type QueryWorkoutsFn = <TEnergy extends HKUnit, TDistance extends HKUnit>(options: QueryWorkoutsOptions<TEnergy, TDistance>) => Promise<readonly HKWorkout<TEnergy, TDistance>[]>;
39
+ export declare type AuthorizationStatusForFn = (type: HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier) => Promise<boolean>;
40
+ export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<readonly HKCategorySample<T>[]>;
41
+ export declare type GetRequestStatusForAuthorizationFn = (read: readonly (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[], write?: readonly HKSampleTypeIdentifier[]) => Promise<HKAuthorizationRequestStatus>;
42
+ export declare type RequestAuthorizationFn = (read: readonly (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[], write?: readonly HKSampleTypeIdentifier[]) => Promise<boolean>;
43
43
  export declare type SaveQuantitySampleFn = <TUnit extends HKQuantityTypeIdentifier>(identifier: TUnit, unit: HKUnit, value: number, options?: {
44
- start?: Date;
45
- end?: Date;
46
- metadata?: MetadataMapperForQuantityIdentifier<TUnit>;
44
+ readonly start?: Date;
45
+ readonly end?: Date;
46
+ readonly metadata?: MetadataMapperForQuantityIdentifier<TUnit>;
47
47
  }) => Promise<boolean>;
48
48
  export declare type QueryQuantitySamplesFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends HKUnit = HKUnit>(identifier: TIdentifier, options: GenericQueryOptions & {
49
- unit?: TUnit;
50
- }) => Promise<HKQuantitySample<TIdentifier, TUnit>[]>;
49
+ readonly unit?: TUnit;
50
+ }) => Promise<readonly HKQuantitySample<TIdentifier, TUnit>[]>;
51
51
  export declare type SubscribeToChangesFn = (identifier: HKSampleTypeIdentifier, callback: () => void) => Promise<UnsubscribeFunction>;
52
52
  export declare type SaveCategorySampleFn = <T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, options?: {
53
- start?: Date;
54
- end?: Date;
55
- metadata?: MetadataMapperForCategoryIdentifier<T>;
53
+ readonly start?: Date;
54
+ readonly end?: Date;
55
+ readonly metadata?: MetadataMapperForCategoryIdentifier<T>;
56
56
  }) => Promise<boolean>;
57
57
  export declare type GetMostRecentCategorySampleFn = <T extends HKCategoryTypeIdentifier>(identifier: T) => Promise<HKCategorySample<T> | null>;
58
58
  export declare type MostRecentCategorySampleHook = <T extends HKCategoryTypeIdentifier>(identifier: T) => HKCategorySample<T> | null;
@@ -61,58 +61,58 @@ export declare type GetMostRecentQuantitySampleFn = <TIdentifier extends HKQuant
61
61
  export declare type MostRecentQuantitySampleHook = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends HKUnit>(identifier: TIdentifier, unit?: TUnit) => HKQuantitySample<TIdentifier, TUnit> | null;
62
62
  export declare type GetMostRecentWorkoutFn = <TEnergy extends HKUnit, TDistance extends HKUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => Promise<HKWorkout<TEnergy, TDistance> | null>;
63
63
  export declare type MostRecentWorkoutHook = <TEnergy extends HKUnit, TDistance extends HKUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => HKWorkout<TEnergy, TDistance> | null;
64
- export declare type GetPreferredUnitsFn = (identifiers: HKQuantityTypeIdentifier[]) => Promise<HKUnit[]>;
64
+ export declare type GetPreferredUnitsFn = (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<readonly HKUnit[]>;
65
65
  export declare type GetPreferredUnitFn = (identifier: HKQuantityTypeIdentifier) => Promise<HKUnit>;
66
- export declare type SaveCorrelationSampleFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, samples: (Omit<HKCategorySample, 'startDate' | 'endDate' | 'uuid' | 'device'> | Omit<HKQuantitySample, 'startDate' | 'endDate' | 'uuid' | 'device'>)[], options?: {
67
- start?: Date;
68
- end?: Date;
69
- metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
66
+ export declare type SaveCorrelationSampleFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, samples: readonly (Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'> | Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>)[], options?: {
67
+ readonly start?: Date;
68
+ readonly end?: Date;
69
+ readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
70
70
  }) => Promise<boolean>;
71
- export declare type SaveWorkoutSampleFn = (typeIdentifier: HKWorkoutActivityType, quantities: Omit<HKQuantitySample, 'startDate' | 'endDate' | 'uuid' | 'device'>[], start: Date, options?: {
72
- end?: Date;
73
- metadata?: HKWorkoutMetadata;
71
+ export declare type SaveWorkoutSampleFn = (typeIdentifier: HKWorkoutActivityType, quantities: readonly Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>[], start: Date, options?: {
72
+ readonly end?: Date;
73
+ readonly metadata?: HKWorkoutMetadata;
74
74
  }) => Promise<boolean>;
75
- export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier> extends Omit<HKCorrelationRaw<TIdentifier>, 'startDate' | 'endDate' | 'objects'> {
76
- objects: (HKQuantitySample | HKCategorySample)[];
77
- startDate: Date;
78
- endDate: Date;
75
+ export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier> extends Omit<HKCorrelationRaw<TIdentifier>, 'endDate' | 'objects' | 'startDate'> {
76
+ readonly objects: readonly (HKCategorySample | HKQuantitySample)[];
77
+ readonly startDate: Date;
78
+ readonly endDate: Date;
79
79
  }
80
- export declare type QueryCorrelationSamplesFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, options: Omit<GenericQueryOptions, 'limit' | 'ascending'>) => Promise<HKCorrelation<TIdentifier>[]>;
80
+ export declare type QueryCorrelationSamplesFn = <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, options: Omit<GenericQueryOptions, 'ascending' | 'limit'>) => Promise<readonly HKCorrelation<TIdentifier>[]>;
81
81
  export declare type SubscribeToChangesHook = <TIdentifier extends HKSampleTypeIdentifier>(identifier: TIdentifier, onChange: () => void, runInitialUpdate?: boolean) => void;
82
- export declare type GetWorkoutRoutesFn = (workoutUUID: string) => Promise<WorkoutRoute[]>;
82
+ export declare type GetWorkoutRoutesFn = (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
83
83
  export declare type ReactNativeHealthkit = {
84
- authorizationStatusFor: AuthorizationStatusForFn;
85
- getBiologicalSex: GetBiologicalSexFn;
86
- getBloodType: GetBloodTypeFn;
87
- getDateOfBirth: GetDateOfBirthFn;
88
- getFitzpatrickSkinType: GetFitzpatrickSkinTypeFn;
89
- getMostRecentQuantitySample: GetMostRecentQuantitySampleFn;
90
- getMostRecentCategorySample: GetMostRecentCategorySampleFn;
91
- getMostRecentWorkout: GetMostRecentWorkoutFn;
92
- getPreferredUnit: GetPreferredUnitFn;
93
- getPreferredUnits: GetPreferredUnitsFn;
94
- getRequestStatusForAuthorization: GetRequestStatusForAuthorizationFn;
95
- getWheelchairUse: GetWheelchairUseFn;
96
- getWorkoutRoutes: GetWorkoutRoutesFn;
97
- buildUnitWithPrefix: (prefix: HKUnitSIPrefix, unit: HKUnitSI) => HKUnit;
98
- isHealthDataAvailable: IsHealthDataAvailableFn;
99
- queryCategorySamples: QueryCategorySamplesFn;
100
- queryQuantitySamples: QueryQuantitySamplesFn;
101
- queryStatisticsForQuantity: QueryStatisticsForQuantityFn;
102
- queryWorkouts: QueryWorkoutsFn;
103
- queryCorrelationSamples: QueryCorrelationSamplesFn;
104
- requestAuthorization: RequestAuthorizationFn;
105
- saveCategorySample: SaveCategorySampleFn;
106
- saveQuantitySample: SaveQuantitySampleFn;
107
- saveCorrelationSample: SaveCorrelationSampleFn;
108
- saveWorkoutSample: SaveWorkoutSampleFn;
109
- enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
110
- disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
111
- disableAllBackgroundDelivery: () => Promise<boolean>;
112
- subscribeToChanges: SubscribeToChangesFn;
113
- useMostRecentWorkout: MostRecentWorkoutHook;
114
- useMostRecentCategorySample: MostRecentCategorySampleHook;
115
- useMostRecentQuantitySample: MostRecentQuantitySampleHook;
116
- useSubscribeToChanges: SubscribeToChangesHook;
84
+ readonly authorizationStatusFor: AuthorizationStatusForFn;
85
+ readonly getBiologicalSex: GetBiologicalSexFn;
86
+ readonly getBloodType: GetBloodTypeFn;
87
+ readonly getDateOfBirth: GetDateOfBirthFn;
88
+ readonly getFitzpatrickSkinType: GetFitzpatrickSkinTypeFn;
89
+ readonly getMostRecentQuantitySample: GetMostRecentQuantitySampleFn;
90
+ readonly getMostRecentCategorySample: GetMostRecentCategorySampleFn;
91
+ readonly getMostRecentWorkout: GetMostRecentWorkoutFn;
92
+ readonly getPreferredUnit: GetPreferredUnitFn;
93
+ readonly getPreferredUnits: GetPreferredUnitsFn;
94
+ readonly getRequestStatusForAuthorization: GetRequestStatusForAuthorizationFn;
95
+ readonly getWheelchairUse: GetWheelchairUseFn;
96
+ readonly getWorkoutRoutes: GetWorkoutRoutesFn;
97
+ readonly buildUnitWithPrefix: (prefix: HKUnitSIPrefix, unit: HKUnitSI) => HKUnit;
98
+ readonly isHealthDataAvailable: IsHealthDataAvailableFn;
99
+ readonly queryCategorySamples: QueryCategorySamplesFn;
100
+ readonly queryQuantitySamples: QueryQuantitySamplesFn;
101
+ readonly queryStatisticsForQuantity: QueryStatisticsForQuantityFn;
102
+ readonly queryWorkouts: QueryWorkoutsFn;
103
+ readonly queryCorrelationSamples: QueryCorrelationSamplesFn;
104
+ readonly requestAuthorization: RequestAuthorizationFn;
105
+ readonly saveCategorySample: SaveCategorySampleFn;
106
+ readonly saveQuantitySample: SaveQuantitySampleFn;
107
+ readonly saveCorrelationSample: SaveCorrelationSampleFn;
108
+ readonly saveWorkoutSample: SaveWorkoutSampleFn;
109
+ readonly enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
110
+ readonly disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
111
+ readonly disableAllBackgroundDelivery: () => Promise<boolean>;
112
+ readonly subscribeToChanges: SubscribeToChangesFn;
113
+ readonly useMostRecentWorkout: MostRecentWorkoutHook;
114
+ readonly useMostRecentCategorySample: MostRecentCategorySampleHook;
115
+ readonly useMostRecentQuantitySample: MostRecentQuantitySampleHook;
116
+ readonly useSubscribeToChanges: SubscribeToChangesHook;
117
117
  };
118
118
  export {};