@kingstinct/react-native-healthkit 7.2.0 → 7.3.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.
Files changed (45) hide show
  1. package/ios/Constants.swift +1 -1
  2. package/ios/ReactNativeHealthkit.m +2 -1
  3. package/ios/ReactNativeHealthkit.swift +74 -23
  4. package/lib/commonjs/index.ios.js +2 -0
  5. package/lib/commonjs/index.ios.js.map +1 -1
  6. package/lib/commonjs/index.js +1 -0
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/jest.setup.js +2 -1
  9. package/lib/commonjs/jest.setup.js.map +1 -1
  10. package/lib/commonjs/native-types.js +5 -5
  11. package/lib/commonjs/native-types.js.map +1 -1
  12. package/lib/commonjs/utils/ensureTotals.js +12 -0
  13. package/lib/commonjs/utils/ensureTotals.js.map +1 -0
  14. package/lib/commonjs/utils/getWorkoutPlanById.js +14 -0
  15. package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -0
  16. package/lib/commonjs/utils/saveWorkoutSample.js +2 -1
  17. package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
  18. package/lib/module/index.ios.js +2 -0
  19. package/lib/module/index.ios.js.map +1 -1
  20. package/lib/module/index.js +1 -0
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/jest.setup.js +2 -1
  23. package/lib/module/jest.setup.js.map +1 -1
  24. package/lib/module/native-types.js +3 -3
  25. package/lib/module/native-types.js.map +1 -1
  26. package/lib/module/utils/ensureTotals.js +5 -0
  27. package/lib/module/utils/ensureTotals.js.map +1 -0
  28. package/lib/module/utils/getWorkoutPlanById.js +6 -0
  29. package/lib/module/utils/getWorkoutPlanById.js.map +1 -0
  30. package/lib/module/utils/saveWorkoutSample.js +2 -1
  31. package/lib/module/utils/saveWorkoutSample.js.map +1 -1
  32. package/lib/typescript/src/index.d.ts +1 -0
  33. package/lib/typescript/src/index.ios.d.ts +2 -0
  34. package/lib/typescript/src/native-types.d.ts +82 -75
  35. package/lib/typescript/src/utils/ensureTotals.d.ts +2 -0
  36. package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +5 -0
  37. package/lib/typescript/src/utils/saveWorkoutSample.d.ts +4 -0
  38. package/package.json +1 -1
  39. package/src/index.ios.tsx +2 -0
  40. package/src/index.tsx +1 -0
  41. package/src/jest.setup.ts +2 -1
  42. package/src/native-types.ts +143 -116
  43. package/src/utils/ensureTotals.ts +5 -0
  44. package/src/utils/getWorkoutPlanById.ts +7 -0
  45. package/src/utils/saveWorkoutSample.ts +6 -0
@@ -9,7 +9,7 @@ export declare const HKWorkoutTypeIdentifier: "HKWorkoutTypeIdentifier";
9
9
  * Represents a type that identifies activity summary objects.
10
10
  * @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
11
11
  */
12
- export declare const HKActivitySummaryType: "HKActivitySummaryType";
12
+ export declare const HKActivitySummaryTypeIdentifier: "HKActivitySummaryTypeIdentifier";
13
13
  /**
14
14
  * Represents an audiogram type identifier.
15
15
  * @see {@link https://developer.apple.com/documentation/healthkit/HKAudiogramSampleType Apple Docs HKAudiogramSampleType}
@@ -36,24 +36,24 @@ export declare enum HKQuantityTypeIdentifier {
36
36
  */
37
37
  bodyMassIndex = "HKQuantityTypeIdentifierBodyMassIndex",
38
38
  /**
39
- * Body Fat Percentage
40
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodyfatpercentage Apple Docs HKQuantityTypeIdentifierBodyFatPercentage}
41
- */
39
+ * Body Fat Percentage
40
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodyfatpercentage Apple Docs HKQuantityTypeIdentifierBodyFatPercentage}
41
+ */
42
42
  bodyFatPercentage = "HKQuantityTypeIdentifierBodyFatPercentage",
43
43
  /**
44
- * Height
45
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheight Apple Docs HKQuantityTypeIdentifierHeight}
46
- */
44
+ * Height
45
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheight Apple Docs HKQuantityTypeIdentifierHeight}
46
+ */
47
47
  height = "HKQuantityTypeIdentifierHeight",
48
48
  /**
49
- * Body Mass
50
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodymass Apple Docs HKQuantityTypeIdentifierBodyMass}
51
- */
49
+ * Body Mass
50
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodymass Apple Docs HKQuantityTypeIdentifierBodyMass}
51
+ */
52
52
  bodyMass = "HKQuantityTypeIdentifierBodyMass",
53
53
  /**
54
- * Lean Body Mass
55
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierleanbodymass Apple Docs HKQuantityTypeIdentifierLeanBodyMass}
56
- */
54
+ * Lean Body Mass
55
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierleanbodymass Apple Docs HKQuantityTypeIdentifierLeanBodyMass}
56
+ */
57
57
  leanBodyMass = "HKQuantityTypeIdentifierLeanBodyMass",
58
58
  /**
59
59
  * Waist Circumference
@@ -180,7 +180,7 @@ export declare enum HKQuantityTypeIdentifier {
180
180
  * Heart Rate Variability SDNN
181
181
  * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheartratevariabilitysdnn Apple Docs HKQuantityTypeIdentifierHeartRateVariabilitySDNN}
182
182
  * @since iOS 11.0
183
- */
183
+ */
184
184
  heartRateVariabilitySDNN = "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
185
185
  /**
186
186
  * Oxygen Saturation
@@ -257,20 +257,20 @@ export declare enum HKQuantityTypeIdentifier {
257
257
  */
258
258
  headphoneAudioExposure = "HKQuantityTypeIdentifierHeadphoneAudioExposure",
259
259
  /**
260
- * Dietary Fat Total
261
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfattotal Apple Docs HKQuantityTypeIdentifierDietaryFatTotal}
262
- * @since iOS 8
263
- */
260
+ * Dietary Fat Total
261
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfattotal Apple Docs HKQuantityTypeIdentifierDietaryFatTotal}
262
+ * @since iOS 8
263
+ */
264
264
  dietaryFatTotal = "HKQuantityTypeIdentifierDietaryFatTotal",
265
265
  /**
266
- * Dietary Fat Polyunsaturated
267
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatpolyunsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatPolyunsaturated}
268
- */
266
+ * Dietary Fat Polyunsaturated
267
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatpolyunsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatPolyunsaturated}
268
+ */
269
269
  dietaryFatPolyunsaturated = "HKQuantityTypeIdentifierDietaryFatPolyunsaturated",
270
270
  /**
271
- * Dietary Fat Monounsaturated
272
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatmonounsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatMonounsaturated}
273
- */
271
+ * Dietary Fat Monounsaturated
272
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatmonounsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatMonounsaturated}
273
+ */
274
274
  dietaryFatMonounsaturated = "HKQuantityTypeIdentifierDietaryFatMonounsaturated",
275
275
  /**
276
276
  * Dietary Fat Saturated
@@ -278,24 +278,24 @@ export declare enum HKQuantityTypeIdentifier {
278
278
  */
279
279
  dietaryFatSaturated = "HKQuantityTypeIdentifierDietaryFatSaturated",
280
280
  /**
281
- * Dietary Cholesterol
282
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycholesterol Apple Docs HKQuantityTypeIdentifierDietaryCholesterol}
283
- */
281
+ * Dietary Cholesterol
282
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycholesterol Apple Docs HKQuantityTypeIdentifierDietaryCholesterol}
283
+ */
284
284
  dietaryCholesterol = "HKQuantityTypeIdentifierDietaryCholesterol",
285
285
  /**
286
- * Dietary Sodium
287
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarysodium Apple Docs HKQuantityTypeIdentifierDietarySodium}
288
- */
286
+ * Dietary Sodium
287
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarysodium Apple Docs HKQuantityTypeIdentifierDietarySodium}
288
+ */
289
289
  dietarySodium = "HKQuantityTypeIdentifierDietarySodium",
290
290
  /**
291
- * Dietary Carbohydrates
292
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycarbohydrates Apple Docs HKQuantityTypeIdentifierDietaryCarbohydrates}
293
- */
291
+ * Dietary Carbohydrates
292
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycarbohydrates Apple Docs HKQuantityTypeIdentifierDietaryCarbohydrates}
293
+ */
294
294
  dietaryCarbohydrates = "HKQuantityTypeIdentifierDietaryCarbohydrates",
295
295
  /**
296
- * Dietary Fiber
297
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfiber Apple Docs HKQuantityTypeIdentifierDietaryFiber}
298
- */
296
+ * Dietary Fiber
297
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfiber Apple Docs HKQuantityTypeIdentifierDietaryFiber}
298
+ */
299
299
  dietaryFiber = "HKQuantityTypeIdentifierDietaryFiber",
300
300
  /**
301
301
  * Dietary Sugar
@@ -353,49 +353,49 @@ export declare enum HKQuantityTypeIdentifier {
353
353
  */
354
354
  dietaryCalcium = "HKQuantityTypeIdentifierDietaryCalcium",
355
355
  /**
356
- * Dietary Iron
357
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiron Apple Docs HKQuantityTypeIdentifierDietaryIron}
358
- */
356
+ * Dietary Iron
357
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiron Apple Docs HKQuantityTypeIdentifierDietaryIron}
358
+ */
359
359
  dietaryIron = "HKQuantityTypeIdentifierDietaryIron",
360
360
  /**
361
- * Dietary Thiamin
362
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarythiamin Apple Docs HKQuantityTypeIdentifierDietaryThiamin}
363
- */
361
+ * Dietary Thiamin
362
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarythiamin Apple Docs HKQuantityTypeIdentifierDietaryThiamin}
363
+ */
364
364
  dietaryThiamin = "HKQuantityTypeIdentifierDietaryThiamin",
365
365
  /**
366
- * Dietary Riboflavin
367
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryriboflavin Apple Docs HKQuantityTypeIdentifierDietaryRiboflavin}
368
- */
366
+ * Dietary Riboflavin
367
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryriboflavin Apple Docs HKQuantityTypeIdentifierDietaryRiboflavin}
368
+ */
369
369
  dietaryRiboflavin = "HKQuantityTypeIdentifierDietaryRiboflavin",
370
370
  /**
371
- * Dietary Niacin
372
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryniacin Apple Docs HKQuantityTypeIdentifierDietaryNiacin}
373
- */
371
+ * Dietary Niacin
372
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryniacin Apple Docs HKQuantityTypeIdentifierDietaryNiacin}
373
+ */
374
374
  dietaryNiacin = "HKQuantityTypeIdentifierDietaryNiacin",
375
375
  /**
376
- * Dietary Folate
377
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfolate Apple Docs HKQuantityTypeIdentifierDietaryFolate}
378
- */
376
+ * Dietary Folate
377
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfolate Apple Docs HKQuantityTypeIdentifierDietaryFolate}
378
+ */
379
379
  dietaryFolate = "HKQuantityTypeIdentifierDietaryFolate",
380
380
  /**
381
- * Dietary Biotin
382
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarybiotin Apple Docs HKQuantityTypeIdentifierDietaryBiotin}
383
- */
381
+ * Dietary Biotin
382
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarybiotin Apple Docs HKQuantityTypeIdentifierDietaryBiotin}
383
+ */
384
384
  dietaryBiotin = "HKQuantityTypeIdentifierDietaryBiotin",
385
385
  /**
386
- * Dietary Pantothenic Acid
387
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarypantothenicacid Apple Docs HKQuantityTypeIdentifierDietaryPantothenicAcid}
388
- */
386
+ * Dietary Pantothenic Acid
387
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarypantothenicacid Apple Docs HKQuantityTypeIdentifierDietaryPantothenicAcid}
388
+ */
389
389
  dietaryPantothenicAcid = "HKQuantityTypeIdentifierDietaryPantothenicAcid",
390
390
  /**
391
- * Dietary Phosphorus
392
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryphosphorus Apple Docs HKQuantityTypeIdentifierDietaryPhosphorus}
393
- */
391
+ * Dietary Phosphorus
392
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryphosphorus Apple Docs HKQuantityTypeIdentifierDietaryPhosphorus}
393
+ */
394
394
  dietaryPhosphorus = "HKQuantityTypeIdentifierDietaryPhosphorus",
395
395
  /**
396
- * Dietary Iodine
397
- * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiodine Apple Docs HKQuantityTypeIdentifierDietaryIodine}
398
- */
396
+ * Dietary Iodine
397
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiodine Apple Docs HKQuantityTypeIdentifierDietaryIodine}
398
+ */
399
399
  dietaryIodine = "HKQuantityTypeIdentifierDietaryIodine",
400
400
  /**
401
401
  * Dietary Magnesium
@@ -713,7 +713,7 @@ export declare enum HKCategoryTypeIdentifier {
713
713
  vomiting = "HKCategoryTypeIdentifierVomiting",
714
714
  wheezing = "HKCategoryTypeIdentifierWheezing"
715
715
  }
716
- export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKActivitySummaryType | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
716
+ export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKActivitySummaryTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
717
717
  export type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`;
718
718
  export type HealthkitWriteAuthorization = HKSampleTypeIdentifier;
719
719
  export declare enum HKCategoryValueAppleStandHour {
@@ -1392,8 +1392,8 @@ export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
1392
1392
  };
1393
1393
  type QueryId = string;
1394
1394
  /**
1395
- * @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
1396
- */
1395
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
1396
+ */
1397
1397
  export declare enum HKUpdateFrequency {
1398
1398
  immediate = 1,
1399
1399
  hourly = 2,
@@ -1428,33 +1428,36 @@ type ReactNativeHealthkitTypeNative = {
1428
1428
  getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
1429
1429
  readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
1430
1430
  /**
1431
- * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
1432
- */
1431
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
1432
+ */
1433
1433
  readonly enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
1434
1434
  /**
1435
1435
  * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery Apple Docs }
1436
1436
  */
1437
1437
  readonly disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
1438
1438
  /**
1439
- * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
1440
- */
1439
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
1440
+ */
1441
1441
  readonly disableAllBackgroundDelivery: () => Promise<boolean>;
1442
1442
  readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier, TSamples extends readonly (HKCategorySampleRawForSaving | HKQuantitySampleRawForSaving)[]>(typeIdentifier: TIdentifier, samples: TSamples, start: string, end: string, metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>) => Promise<boolean>;
1443
- readonly saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: readonly HKQuantitySampleRawForSaving[], start: string, end: string, metadata: HKWorkoutMetadata) => Promise<string | null>;
1443
+ readonly saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: readonly HKQuantitySampleRawForSaving[], start: string, end: string, totals: {
1444
+ readonly distance?: number;
1445
+ readonly energyBurned?: number;
1446
+ }, metadata: HKWorkoutMetadata) => Promise<string | null>;
1444
1447
  readonly saveWorkoutRoute: (workoutUUID: string, locations: readonly CLLocationRawForSaving[]) => Promise<boolean>;
1445
1448
  readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, from: string, to: string) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
1446
1449
  subscribeToObserverQuery(identifier: HKSampleTypeIdentifier): Promise<QueryId>;
1447
1450
  unsubscribeQuery(queryId: QueryId): Promise<boolean>;
1448
1451
  /**
1449
- * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
1450
- */
1452
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
1453
+ */
1451
1454
  authorizationStatusFor(type: HealthkitReadAuthorization): Promise<HKAuthorizationStatus>;
1452
1455
  /**
1453
- * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
1456
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
1454
1457
  */
1455
1458
  getRequestStatusForAuthorization(write: WritePermissions, read: ReadPermissions): Promise<HKAuthorizationRequestStatus>;
1456
1459
  /**
1457
- * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
1460
+ * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
1458
1461
  */
1459
1462
  requestAuthorization(write: WritePermissions, read: ReadPermissions): Promise<boolean>;
1460
1463
  readonly saveQuantitySample: <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType> = UnitForIdentifier<TType>>(identifier: TType, unit: TUnit, value: number, start: string, end: string, metadata: unknown) => Promise<boolean>;
@@ -1472,6 +1475,10 @@ type ReactNativeHealthkitTypeNative = {
1472
1475
  readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: readonly HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
1473
1476
  readonly getPreferredUnits: (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
1474
1477
  readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
1478
+ readonly getWorkoutPlanById: (workoutUUID: string) => Promise<{
1479
+ readonly id: string;
1480
+ readonly activityType: HKWorkoutActivityType;
1481
+ } | null>;
1475
1482
  };
1476
1483
  declare const Native: ReactNativeHealthkitTypeNative;
1477
1484
  type OnChangeCallback = ({ typeIdentifier, }: {
@@ -0,0 +1,2 @@
1
+ declare function ensureTotals<TTotals>(totals?: TTotals): TTotals;
2
+ export default ensureTotals;
@@ -0,0 +1,5 @@
1
+ declare function getWorkoutPlanById(workoutUUID: string): Promise<{
2
+ readonly id: string;
3
+ readonly activityType: import("../native-types").HKWorkoutActivityType;
4
+ } | null>;
5
+ export default getWorkoutPlanById;
@@ -2,6 +2,10 @@ import type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types';
2
2
  import type { HKQuantitySampleForSaving } from '../types';
3
3
  declare function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(typeIdentifier: TIdentifier, quantities: readonly HKQuantitySampleForSaving[], _start: Date, options?: {
4
4
  readonly end?: Date;
5
+ readonly totals?: {
6
+ readonly distance?: number;
7
+ readonly energyBurned?: number;
8
+ };
5
9
  readonly metadata?: HKWorkoutMetadata;
6
10
  }): Promise<string | null>;
7
11
  export default saveWorkoutSample;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kingstinct/react-native-healthkit",
3
- "version": "7.2.0",
3
+ "version": "7.3.0",
4
4
  "description": "React Native bindings for HealthKit",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
package/src/index.ios.tsx CHANGED
@@ -16,6 +16,7 @@ import getMostRecentWorkout from './utils/getMostRecentWorkout'
16
16
  import getPreferredUnit from './utils/getPreferredUnit'
17
17
  import getPreferredUnits from './utils/getPreferredUnits'
18
18
  import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'
19
+ import getWorkoutPlanById from './utils/getWorkoutPlanById'
19
20
  import queryCategorySamples from './utils/queryCategorySamples'
20
21
  import queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'
21
22
  import queryCorrelationSamples from './utils/queryCorrelationSamples'
@@ -150,6 +151,7 @@ export default {
150
151
  * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}
151
152
  */
152
153
  getWorkoutRoutes,
154
+ getWorkoutPlanById,
153
155
 
154
156
  getPreferredUnit,
155
157
  getPreferredUnits,
package/src/index.tsx CHANGED
@@ -77,6 +77,7 @@ const Healthkit = {
77
77
  requestAuthorization: UnavailableFn(Promise.resolve(false)),
78
78
  deleteQuantitySample: UnavailableFn(Promise.resolve(false)),
79
79
  deleteSamples: UnavailableFn(Promise.resolve(false)),
80
+ getWorkoutPlanById: UnavailableFn(Promise.resolve(null)),
80
81
  saveCategorySample: UnavailableFn(Promise.resolve(false)),
81
82
  saveCorrelationSample: UnavailableFn(Promise.resolve(false)),
82
83
  saveQuantitySample: UnavailableFn(Promise.resolve(false)),
package/src/jest.setup.ts CHANGED
@@ -2,7 +2,7 @@ import { NativeModule, NativeModules } from 'react-native'
2
2
 
3
3
  import type Native from './native-types'
4
4
 
5
- const mockModule: (NativeModule & typeof Native) = {
5
+ const mockModule: NativeModule & typeof Native = {
6
6
  isHealthDataAvailable: jest.fn(),
7
7
  addListener: jest.fn(),
8
8
  removeListeners: jest.fn(),
@@ -40,6 +40,7 @@ const mockModule: (NativeModule & typeof Native) = {
40
40
  // Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)
41
41
  canAccessProtectedData: jest.fn(),
42
42
  saveWorkoutRoute: jest.fn(),
43
+ getWorkoutPlanById: jest.fn(),
43
44
  }
44
45
 
45
46
  NativeModules.ReactNativeHealthkit = mockModule