@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.
- package/ios/Constants.swift +1 -1
- package/ios/ReactNativeHealthkit.m +2 -1
- package/ios/ReactNativeHealthkit.swift +74 -23
- package/lib/commonjs/index.ios.js +2 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +1 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +2 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +5 -5
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/utils/ensureTotals.js +12 -0
- package/lib/commonjs/utils/ensureTotals.js.map +1 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js +14 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +2 -1
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/index.ios.js +2 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +2 -1
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +3 -3
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/utils/ensureTotals.js +5 -0
- package/lib/module/utils/ensureTotals.js.map +1 -0
- package/lib/module/utils/getWorkoutPlanById.js +6 -0
- package/lib/module/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +2 -1
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.ios.d.ts +2 -0
- package/lib/typescript/src/native-types.d.ts +82 -75
- package/lib/typescript/src/utils/ensureTotals.d.ts +2 -0
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +5 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +4 -0
- package/package.json +1 -1
- package/src/index.ios.tsx +2 -0
- package/src/index.tsx +1 -0
- package/src/jest.setup.ts +2 -1
- package/src/native-types.ts +143 -116
- package/src/utils/ensureTotals.ts +5 -0
- package/src/utils/getWorkoutPlanById.ts +7 -0
- package/src/utils/saveWorkoutSample.ts +6 -0
package/src/native-types.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier' as const
|
|
|
12
12
|
* Represents a type that identifies activity summary objects.
|
|
13
13
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
|
|
14
14
|
*/
|
|
15
|
-
export const
|
|
15
|
+
export const HKActivitySummaryTypeIdentifier = 'HKActivitySummaryTypeIdentifier' as const
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Represents an audiogram type identifier.
|
|
@@ -44,27 +44,27 @@ export enum HKQuantityTypeIdentifier {
|
|
|
44
44
|
bodyMassIndex = 'HKQuantityTypeIdentifierBodyMassIndex',
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
* Body Fat Percentage
|
|
48
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodyfatpercentage Apple Docs HKQuantityTypeIdentifierBodyFatPercentage}
|
|
49
|
+
*/
|
|
50
50
|
bodyFatPercentage = 'HKQuantityTypeIdentifierBodyFatPercentage',
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
* Height
|
|
54
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheight Apple Docs HKQuantityTypeIdentifierHeight}
|
|
55
|
+
*/
|
|
56
56
|
height = 'HKQuantityTypeIdentifierHeight',
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
* Body Mass
|
|
60
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodymass Apple Docs HKQuantityTypeIdentifierBodyMass}
|
|
61
|
+
*/
|
|
62
62
|
bodyMass = 'HKQuantityTypeIdentifierBodyMass',
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
* Lean Body Mass
|
|
66
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierleanbodymass Apple Docs HKQuantityTypeIdentifierLeanBodyMass}
|
|
67
|
+
*/
|
|
68
68
|
leanBodyMass = 'HKQuantityTypeIdentifierLeanBodyMass',
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -198,7 +198,7 @@ export enum HKQuantityTypeIdentifier {
|
|
|
198
198
|
* Heart Rate Variability SDNN
|
|
199
199
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheartratevariabilitysdnn Apple Docs HKQuantityTypeIdentifierHeartRateVariabilitySDNN}
|
|
200
200
|
* @since iOS 11.0
|
|
201
|
-
|
|
201
|
+
*/
|
|
202
202
|
heartRateVariabilitySDNN = 'HKQuantityTypeIdentifierHeartRateVariabilitySDNN', // Time (ms), Discrete
|
|
203
203
|
/**
|
|
204
204
|
* Oxygen Saturation
|
|
@@ -287,22 +287,22 @@ export enum HKQuantityTypeIdentifier {
|
|
|
287
287
|
|
|
288
288
|
// Nutrition
|
|
289
289
|
/**
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
* Dietary Fat Total
|
|
291
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfattotal Apple Docs HKQuantityTypeIdentifierDietaryFatTotal}
|
|
292
|
+
* @since iOS 8
|
|
293
|
+
*/
|
|
294
294
|
dietaryFatTotal = 'HKQuantityTypeIdentifierDietaryFatTotal', // Mass, Cumulative
|
|
295
295
|
|
|
296
296
|
/**
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
* Dietary Fat Polyunsaturated
|
|
298
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatpolyunsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatPolyunsaturated}
|
|
299
|
+
*/
|
|
300
300
|
dietaryFatPolyunsaturated = 'HKQuantityTypeIdentifierDietaryFatPolyunsaturated', // Mass, Cumulative
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
303
|
+
* Dietary Fat Monounsaturated
|
|
304
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatmonounsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatMonounsaturated}
|
|
305
|
+
*/
|
|
306
306
|
dietaryFatMonounsaturated = 'HKQuantityTypeIdentifierDietaryFatMonounsaturated', // Mass, Cumulative
|
|
307
307
|
/**
|
|
308
308
|
* Dietary Fat Saturated
|
|
@@ -311,27 +311,27 @@ export enum HKQuantityTypeIdentifier {
|
|
|
311
311
|
dietaryFatSaturated = 'HKQuantityTypeIdentifierDietaryFatSaturated', // Mass, Cumulative
|
|
312
312
|
|
|
313
313
|
/**
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
314
|
+
* Dietary Cholesterol
|
|
315
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycholesterol Apple Docs HKQuantityTypeIdentifierDietaryCholesterol}
|
|
316
|
+
*/
|
|
317
317
|
dietaryCholesterol = 'HKQuantityTypeIdentifierDietaryCholesterol', // Mass, Cumulative
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
320
|
+
* Dietary Sodium
|
|
321
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarysodium Apple Docs HKQuantityTypeIdentifierDietarySodium}
|
|
322
|
+
*/
|
|
323
323
|
dietarySodium = 'HKQuantityTypeIdentifierDietarySodium', // Mass, Cumulative
|
|
324
324
|
|
|
325
325
|
/**
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
* Dietary Carbohydrates
|
|
327
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycarbohydrates Apple Docs HKQuantityTypeIdentifierDietaryCarbohydrates}
|
|
328
|
+
*/
|
|
329
329
|
dietaryCarbohydrates = 'HKQuantityTypeIdentifierDietaryCarbohydrates', // Mass, Cumulative
|
|
330
330
|
|
|
331
331
|
/**
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
332
|
+
* Dietary Fiber
|
|
333
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfiber Apple Docs HKQuantityTypeIdentifierDietaryFiber}
|
|
334
|
+
*/
|
|
335
335
|
dietaryFiber = 'HKQuantityTypeIdentifierDietaryFiber', // Mass, Cumulative
|
|
336
336
|
/**
|
|
337
337
|
* Dietary Sugar
|
|
@@ -399,57 +399,57 @@ export enum HKQuantityTypeIdentifier {
|
|
|
399
399
|
dietaryCalcium = 'HKQuantityTypeIdentifierDietaryCalcium', // Mass, Cumulative
|
|
400
400
|
|
|
401
401
|
/**
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
402
|
+
* Dietary Iron
|
|
403
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiron Apple Docs HKQuantityTypeIdentifierDietaryIron}
|
|
404
|
+
*/
|
|
405
405
|
dietaryIron = 'HKQuantityTypeIdentifierDietaryIron', // Mass, Cumulative
|
|
406
406
|
|
|
407
407
|
/**
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
408
|
+
* Dietary Thiamin
|
|
409
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarythiamin Apple Docs HKQuantityTypeIdentifierDietaryThiamin}
|
|
410
|
+
*/
|
|
411
411
|
dietaryThiamin = 'HKQuantityTypeIdentifierDietaryThiamin', // Mass, Cumulative
|
|
412
412
|
|
|
413
413
|
/**
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
414
|
+
* Dietary Riboflavin
|
|
415
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryriboflavin Apple Docs HKQuantityTypeIdentifierDietaryRiboflavin}
|
|
416
|
+
*/
|
|
417
417
|
dietaryRiboflavin = 'HKQuantityTypeIdentifierDietaryRiboflavin', // Mass, Cumulative
|
|
418
418
|
|
|
419
419
|
/**
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
420
|
+
* Dietary Niacin
|
|
421
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryniacin Apple Docs HKQuantityTypeIdentifierDietaryNiacin}
|
|
422
|
+
*/
|
|
423
423
|
dietaryNiacin = 'HKQuantityTypeIdentifierDietaryNiacin', // Mass, Cumulative
|
|
424
424
|
|
|
425
425
|
/**
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
426
|
+
* Dietary Folate
|
|
427
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfolate Apple Docs HKQuantityTypeIdentifierDietaryFolate}
|
|
428
|
+
*/
|
|
429
429
|
dietaryFolate = 'HKQuantityTypeIdentifierDietaryFolate', // Mass, Cumulative
|
|
430
430
|
|
|
431
431
|
/**
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
432
|
+
* Dietary Biotin
|
|
433
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarybiotin Apple Docs HKQuantityTypeIdentifierDietaryBiotin}
|
|
434
|
+
*/
|
|
435
435
|
dietaryBiotin = 'HKQuantityTypeIdentifierDietaryBiotin', // Mass, Cumulative
|
|
436
436
|
|
|
437
437
|
/**
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
438
|
+
* Dietary Pantothenic Acid
|
|
439
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarypantothenicacid Apple Docs HKQuantityTypeIdentifierDietaryPantothenicAcid}
|
|
440
|
+
*/
|
|
441
441
|
dietaryPantothenicAcid = 'HKQuantityTypeIdentifierDietaryPantothenicAcid', // Mass, Cumulative
|
|
442
442
|
|
|
443
443
|
/**
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
444
|
+
* Dietary Phosphorus
|
|
445
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryphosphorus Apple Docs HKQuantityTypeIdentifierDietaryPhosphorus}
|
|
446
|
+
*/
|
|
447
447
|
dietaryPhosphorus = 'HKQuantityTypeIdentifierDietaryPhosphorus', // Mass, Cumulative
|
|
448
448
|
|
|
449
449
|
/**
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
450
|
+
* Dietary Iodine
|
|
451
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiodine Apple Docs HKQuantityTypeIdentifierDietaryIodine}
|
|
452
|
+
*/
|
|
453
453
|
dietaryIodine = 'HKQuantityTypeIdentifierDietaryIodine', // Mass, Cumulative
|
|
454
454
|
/**
|
|
455
455
|
* Dietary Magnesium
|
|
@@ -815,7 +815,17 @@ export enum HKCategoryTypeIdentifier {
|
|
|
815
815
|
}
|
|
816
816
|
|
|
817
817
|
export type HKSampleTypeIdentifier =
|
|
818
|
-
|
|
818
|
+
| HKCategoryTypeIdentifier
|
|
819
|
+
| HKCorrelationTypeIdentifier
|
|
820
|
+
| HKQuantityTypeIdentifier
|
|
821
|
+
| typeof HKActivitySummaryTypeIdentifier
|
|
822
|
+
| typeof HKAudiogramTypeIdentifier
|
|
823
|
+
| typeof HKDataTypeIdentifierHeartbeatSeries
|
|
824
|
+
| typeof HKWorkoutRouteTypeIdentifier
|
|
825
|
+
| typeof HKWorkoutTypeIdentifier
|
|
826
|
+
| `${HKCategoryTypeIdentifier}`
|
|
827
|
+
| `${HKCorrelationTypeIdentifier}`
|
|
828
|
+
| `${HKQuantityTypeIdentifier}`;
|
|
819
829
|
|
|
820
830
|
export type HealthkitReadAuthorization =
|
|
821
831
|
| HKCharacteristicTypeIdentifier
|
|
@@ -1115,7 +1125,7 @@ export enum HKCategoryValueSleepAnalysis {
|
|
|
1115
1125
|
awake = 2,
|
|
1116
1126
|
asleepCore = 3,
|
|
1117
1127
|
asleepDeep = 4,
|
|
1118
|
-
asleepREM = 5
|
|
1128
|
+
asleepREM = 5,
|
|
1119
1129
|
}
|
|
1120
1130
|
|
|
1121
1131
|
/**
|
|
@@ -1389,7 +1399,7 @@ contraceptive = 'HKCategoryTypeIdentifierContraceptive',
|
|
|
1389
1399
|
|
|
1390
1400
|
export type HKHeartbeatSeriesSampleMetadata = HKGenericMetadata & {
|
|
1391
1401
|
readonly HKMetadataKeyAlgorithmVersion: string;
|
|
1392
|
-
}
|
|
1402
|
+
};
|
|
1393
1403
|
|
|
1394
1404
|
export type MetadataMapperForCategoryIdentifier<
|
|
1395
1405
|
T extends HKCategoryTypeIdentifier
|
|
@@ -1643,7 +1653,7 @@ export type HKDevice = {
|
|
|
1643
1653
|
readonly manufacturer: string; // ex: "Apple Inc."
|
|
1644
1654
|
readonly model: string; // ex: "Watch"
|
|
1645
1655
|
readonly softwareVersion: string; // ex: "9.0"
|
|
1646
|
-
readonly udiDeviceIdentifier: string | null
|
|
1656
|
+
readonly udiDeviceIdentifier: string | null;
|
|
1647
1657
|
};
|
|
1648
1658
|
|
|
1649
1659
|
/**
|
|
@@ -1683,9 +1693,9 @@ export type HKQuantitySampleRaw<
|
|
|
1683
1693
|
};
|
|
1684
1694
|
|
|
1685
1695
|
export type HKHeartbeatRaw = {
|
|
1686
|
-
readonly timeSinceSeriesStart: number
|
|
1687
|
-
readonly precededByGap: boolean
|
|
1688
|
-
}
|
|
1696
|
+
readonly timeSinceSeriesStart: number;
|
|
1697
|
+
readonly precededByGap: boolean;
|
|
1698
|
+
};
|
|
1689
1699
|
|
|
1690
1700
|
export type HKHeartbeatSeriesSampleRaw = {
|
|
1691
1701
|
readonly uuid: string;
|
|
@@ -1695,7 +1705,7 @@ export type HKHeartbeatSeriesSampleRaw = {
|
|
|
1695
1705
|
readonly heartbeats: readonly HKHeartbeatRaw[];
|
|
1696
1706
|
readonly metadata?: HKHeartbeatSeriesSampleMetadata;
|
|
1697
1707
|
readonly sourceRevision?: HKSourceRevision;
|
|
1698
|
-
}
|
|
1708
|
+
};
|
|
1699
1709
|
|
|
1700
1710
|
export type CLLocationRawForSaving = {
|
|
1701
1711
|
readonly latitude: number;
|
|
@@ -1706,27 +1716,33 @@ export type CLLocationRawForSaving = {
|
|
|
1706
1716
|
readonly course: number;
|
|
1707
1717
|
readonly speed: number;
|
|
1708
1718
|
readonly timestamp: string; // unix timestamp in milliseconds
|
|
1709
|
-
}
|
|
1719
|
+
};
|
|
1710
1720
|
|
|
1711
1721
|
export type HKQuantitySampleRawForSaving<
|
|
1712
1722
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
1713
1723
|
TUnit extends UnitForIdentifier<TQuantityIdentifier> = UnitForIdentifier<TQuantityIdentifier>
|
|
1714
|
-
> = Omit<
|
|
1724
|
+
> = Omit<
|
|
1725
|
+
HKQuantitySampleRaw<TQuantityIdentifier, TUnit>,
|
|
1726
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
1727
|
+
> & {
|
|
1715
1728
|
readonly startDate?: string;
|
|
1716
1729
|
readonly endDate?: string;
|
|
1717
1730
|
};
|
|
1718
1731
|
|
|
1719
1732
|
export type HKCategorySampleRawForSaving<
|
|
1720
1733
|
TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
1721
|
-
> = Omit<
|
|
1734
|
+
> = Omit<
|
|
1735
|
+
HKCategorySampleRaw<TCategory>,
|
|
1736
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
1737
|
+
> & {
|
|
1722
1738
|
readonly startDate?: string;
|
|
1723
1739
|
readonly endDate?: string;
|
|
1724
1740
|
};
|
|
1725
1741
|
|
|
1726
1742
|
export interface HKWorkoutEvent {
|
|
1727
|
-
readonly type: HKWorkoutEventType
|
|
1728
|
-
readonly startDate: string
|
|
1729
|
-
readonly endDate: string
|
|
1743
|
+
readonly type: HKWorkoutEventType;
|
|
1744
|
+
readonly startDate: string;
|
|
1745
|
+
readonly endDate: string;
|
|
1730
1746
|
}
|
|
1731
1747
|
|
|
1732
1748
|
export enum HKWorkoutEventType {
|
|
@@ -1741,10 +1757,10 @@ export enum HKWorkoutEventType {
|
|
|
1741
1757
|
}
|
|
1742
1758
|
|
|
1743
1759
|
export interface HKWorkoutActivity {
|
|
1744
|
-
readonly startDate: string
|
|
1745
|
-
readonly endDate: string
|
|
1746
|
-
readonly uuid: string
|
|
1747
|
-
readonly duration: number
|
|
1760
|
+
readonly startDate: string;
|
|
1761
|
+
readonly endDate: string;
|
|
1762
|
+
readonly uuid: string;
|
|
1763
|
+
readonly duration: number;
|
|
1748
1764
|
}
|
|
1749
1765
|
|
|
1750
1766
|
export type HKWorkoutRaw<
|
|
@@ -1813,36 +1829,40 @@ export type HKCategorySampleRaw<
|
|
|
1813
1829
|
|
|
1814
1830
|
export type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
1815
1831
|
readonly uuid: string;
|
|
1816
|
-
readonly metadata: MetadataMapperForCategoryIdentifier<T
|
|
1817
|
-
}
|
|
1832
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
1833
|
+
};
|
|
1818
1834
|
|
|
1819
1835
|
export type DeletedHeartbeatSeriesSampleRaw = {
|
|
1820
1836
|
readonly uuid: string;
|
|
1821
1837
|
readonly metadata: HKHeartbeatSeriesSampleMetadata;
|
|
1822
|
-
}
|
|
1838
|
+
};
|
|
1823
1839
|
|
|
1824
1840
|
export type DeletedQuantitySampleRaw<T extends HKQuantityTypeIdentifier> = {
|
|
1825
1841
|
readonly uuid: string;
|
|
1826
|
-
readonly metadata: MetadataMapperForQuantityIdentifier<T
|
|
1827
|
-
}
|
|
1842
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<T>;
|
|
1843
|
+
};
|
|
1828
1844
|
|
|
1829
|
-
export type QueryCategorySamplesResponseRaw<
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
readonly
|
|
1833
|
-
|
|
1845
|
+
export type QueryCategorySamplesResponseRaw<
|
|
1846
|
+
T extends HKCategoryTypeIdentifier
|
|
1847
|
+
> = {
|
|
1848
|
+
readonly samples: readonly HKCategorySampleRaw<T>[];
|
|
1849
|
+
readonly deletedSamples: readonly DeletedCategorySampleRaw<T>[];
|
|
1850
|
+
readonly newAnchor: string;
|
|
1851
|
+
};
|
|
1834
1852
|
|
|
1835
1853
|
export type QueryHeartbeatSeriesSamplesResponseRaw = {
|
|
1836
|
-
readonly samples: readonly HKHeartbeatSeriesSampleRaw[]
|
|
1837
|
-
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[]
|
|
1838
|
-
readonly newAnchor: string
|
|
1839
|
-
}
|
|
1854
|
+
readonly samples: readonly HKHeartbeatSeriesSampleRaw[];
|
|
1855
|
+
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
|
|
1856
|
+
readonly newAnchor: string;
|
|
1857
|
+
};
|
|
1840
1858
|
|
|
1841
|
-
export type QueryQuantitySamplesResponseRaw<
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
readonly
|
|
1845
|
-
|
|
1859
|
+
export type QueryQuantitySamplesResponseRaw<
|
|
1860
|
+
T extends HKQuantityTypeIdentifier
|
|
1861
|
+
> = {
|
|
1862
|
+
readonly samples: readonly HKQuantitySampleRaw<T>[];
|
|
1863
|
+
readonly deletedSamples: readonly DeletedQuantitySampleRaw<T>[];
|
|
1864
|
+
readonly newAnchor: string;
|
|
1865
|
+
};
|
|
1846
1866
|
|
|
1847
1867
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
1848
1868
|
{
|
|
@@ -1856,8 +1876,8 @@ export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
|
1856
1876
|
type QueryId = string;
|
|
1857
1877
|
|
|
1858
1878
|
/**
|
|
1859
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1860
|
-
*/
|
|
1879
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1880
|
+
*/
|
|
1861
1881
|
export enum HKUpdateFrequency {
|
|
1862
1882
|
immediate = 1,
|
|
1863
1883
|
hourly = 2,
|
|
@@ -1896,8 +1916,8 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1896
1916
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
1897
1917
|
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
1898
1918
|
/**
|
|
1899
|
-
|
|
1900
|
-
|
|
1919
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
|
|
1920
|
+
*/
|
|
1901
1921
|
readonly enableBackgroundDelivery: (
|
|
1902
1922
|
typeIdentifier: HKSampleTypeIdentifier,
|
|
1903
1923
|
updateFrequency: HKUpdateFrequency
|
|
@@ -1909,8 +1929,8 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1909
1929
|
typeIdentifier: HKSampleTypeIdentifier
|
|
1910
1930
|
) => Promise<boolean>;
|
|
1911
1931
|
/**
|
|
1912
|
-
|
|
1913
|
-
|
|
1932
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
|
|
1933
|
+
*/
|
|
1914
1934
|
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
1915
1935
|
|
|
1916
1936
|
readonly saveCorrelationSample: <
|
|
@@ -1932,12 +1952,16 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1932
1952
|
quantities: readonly HKQuantitySampleRawForSaving[],
|
|
1933
1953
|
start: string,
|
|
1934
1954
|
end: string,
|
|
1955
|
+
totals: {
|
|
1956
|
+
readonly distance?: number;
|
|
1957
|
+
readonly energyBurned?: number;
|
|
1958
|
+
},
|
|
1935
1959
|
metadata: HKWorkoutMetadata
|
|
1936
1960
|
) => Promise<string | null>;
|
|
1937
1961
|
|
|
1938
1962
|
readonly saveWorkoutRoute: (
|
|
1939
1963
|
workoutUUID: string,
|
|
1940
|
-
locations: readonly CLLocationRawForSaving[]
|
|
1964
|
+
locations: readonly CLLocationRawForSaving[]
|
|
1941
1965
|
) => Promise<boolean>;
|
|
1942
1966
|
|
|
1943
1967
|
readonly queryCorrelationSamples: <
|
|
@@ -1953,18 +1977,20 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1953
1977
|
): Promise<QueryId>;
|
|
1954
1978
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
1955
1979
|
/**
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
authorizationStatusFor(
|
|
1980
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
|
|
1981
|
+
*/
|
|
1982
|
+
authorizationStatusFor(
|
|
1983
|
+
type: HealthkitReadAuthorization
|
|
1984
|
+
): Promise<HKAuthorizationStatus>;
|
|
1959
1985
|
/**
|
|
1960
|
-
|
|
1986
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
1961
1987
|
*/
|
|
1962
1988
|
getRequestStatusForAuthorization(
|
|
1963
1989
|
write: WritePermissions,
|
|
1964
1990
|
read: ReadPermissions
|
|
1965
1991
|
): Promise<HKAuthorizationRequestStatus>;
|
|
1966
1992
|
/**
|
|
1967
|
-
|
|
1993
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
1968
1994
|
*/
|
|
1969
1995
|
requestAuthorization(
|
|
1970
1996
|
write: WritePermissions,
|
|
@@ -1988,7 +2014,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1988
2014
|
readonly deleteSamples: <TIdentifier extends HKQuantityTypeIdentifier>(
|
|
1989
2015
|
identifier: TIdentifier,
|
|
1990
2016
|
start: string,
|
|
1991
|
-
end: string
|
|
2017
|
+
end: string
|
|
1992
2018
|
) => Promise<boolean>;
|
|
1993
2019
|
readonly queryWorkoutSamples: <
|
|
1994
2020
|
TEnergy extends EnergyUnit,
|
|
@@ -2006,7 +2032,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2006
2032
|
from: string,
|
|
2007
2033
|
to: string,
|
|
2008
2034
|
limit: number,
|
|
2009
|
-
ascending: boolean
|
|
2035
|
+
ascending: boolean
|
|
2010
2036
|
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
2011
2037
|
readonly queryQuantitySamples: <
|
|
2012
2038
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
@@ -2017,7 +2043,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2017
2043
|
from: string,
|
|
2018
2044
|
to: string,
|
|
2019
2045
|
limit: number,
|
|
2020
|
-
ascending: boolean
|
|
2046
|
+
ascending: boolean
|
|
2021
2047
|
) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
2022
2048
|
readonly queryCategorySamplesWithAnchor: <T extends HKCategoryTypeIdentifier>(
|
|
2023
2049
|
identifier: T,
|
|
@@ -2041,7 +2067,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2041
2067
|
from: string,
|
|
2042
2068
|
to: string,
|
|
2043
2069
|
limit: number,
|
|
2044
|
-
ascending: boolean
|
|
2070
|
+
ascending: boolean
|
|
2045
2071
|
) => Promise<readonly HKHeartbeatSeriesSampleRaw[]>;
|
|
2046
2072
|
readonly queryHeartbeatSeriesSamplesWithAnchor: (
|
|
2047
2073
|
from: string,
|
|
@@ -2077,6 +2103,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2077
2103
|
readonly getWorkoutRoutes: (
|
|
2078
2104
|
workoutUUID: string
|
|
2079
2105
|
) => Promise<readonly WorkoutRoute[]>;
|
|
2106
|
+
readonly getWorkoutPlanById: (workoutUUID: string) => Promise<{readonly id: string, readonly activityType: HKWorkoutActivityType} | null>;
|
|
2080
2107
|
};
|
|
2081
2108
|
|
|
2082
2109
|
const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import ensureMetadata from './ensureMetadata'
|
|
2
|
+
import ensureTotals from './ensureTotals'
|
|
2
3
|
import Native from '../native-types'
|
|
3
4
|
|
|
4
5
|
import type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types'
|
|
@@ -10,6 +11,10 @@ async function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(
|
|
|
10
11
|
_start: Date,
|
|
11
12
|
options?: {
|
|
12
13
|
readonly end?: Date;
|
|
14
|
+
readonly totals?: {
|
|
15
|
+
readonly distance?: number;
|
|
16
|
+
readonly energyBurned?: number;
|
|
17
|
+
}
|
|
13
18
|
readonly metadata?: HKWorkoutMetadata;
|
|
14
19
|
},
|
|
15
20
|
) {
|
|
@@ -29,6 +34,7 @@ async function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(
|
|
|
29
34
|
}),
|
|
30
35
|
start,
|
|
31
36
|
end,
|
|
37
|
+
ensureTotals(options?.totals),
|
|
32
38
|
ensureMetadata(options?.metadata),
|
|
33
39
|
)
|
|
34
40
|
}
|