@kingstinct/react-native-healthkit 7.1.1 → 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/Helpers.swift +6 -0
- package/ios/ReactNativeHealthkit.m +8 -1
- package/ios/ReactNativeHealthkit.swift +204 -74
- package/lib/commonjs/index.ios.js +4 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +3 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +5 -5
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/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/saveCorrelationSample.js +20 -4
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +27 -0
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +21 -4
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/index.ios.js +4 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +3 -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/types.js +5 -0
- package/lib/module/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/saveCorrelationSample.js +20 -4
- package/lib/module/utils/saveCorrelationSample.js.map +1 -1
- package/lib/module/utils/saveWorkoutRoute.js +19 -0
- package/lib/module/utils/saveWorkoutRoute.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +21 -4
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.ios.d.ts +4 -0
- package/lib/typescript/src/native-types.d.ts +102 -78
- package/lib/typescript/src/types.d.ts +16 -3
- 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/saveWorkoutRoute.d.ts +3 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +5 -1
- package/package.json +1 -1
- package/src/index.ios.tsx +4 -0
- package/src/index.tsx +3 -1
- package/src/jest.setup.ts +3 -1
- package/src/native-types.ts +158 -114
- package/src/types.ts +17 -2
- package/src/utils/ensureTotals.ts +5 -0
- package/src/utils/getWorkoutPlanById.ts +7 -0
- package/src/utils/saveCorrelationSample.ts +10 -1
- package/src/utils/saveWorkoutRoute.ts +21 -0
- package/src/utils/saveWorkoutSample.ts +15 -1
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
|
/**
|
|
@@ -1233,6 +1243,7 @@ export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> =
|
|
|
1233
1243
|
| HKQuantityTypeIdentifier.basalBodyTemperature
|
|
1234
1244
|
? TemperatureUnit
|
|
1235
1245
|
: T extends
|
|
1246
|
+
| HKQuantityTypeIdentifier.runningSpeed
|
|
1236
1247
|
| HKQuantityTypeIdentifier.stairAscentSpeed
|
|
1237
1248
|
| HKQuantityTypeIdentifier.stairDescentSpeed
|
|
1238
1249
|
| HKQuantityTypeIdentifier.walkingSpeed
|
|
@@ -1388,7 +1399,7 @@ contraceptive = 'HKCategoryTypeIdentifierContraceptive',
|
|
|
1388
1399
|
|
|
1389
1400
|
export type HKHeartbeatSeriesSampleMetadata = HKGenericMetadata & {
|
|
1390
1401
|
readonly HKMetadataKeyAlgorithmVersion: string;
|
|
1391
|
-
}
|
|
1402
|
+
};
|
|
1392
1403
|
|
|
1393
1404
|
export type MetadataMapperForCategoryIdentifier<
|
|
1394
1405
|
T extends HKCategoryTypeIdentifier
|
|
@@ -1642,7 +1653,7 @@ export type HKDevice = {
|
|
|
1642
1653
|
readonly manufacturer: string; // ex: "Apple Inc."
|
|
1643
1654
|
readonly model: string; // ex: "Watch"
|
|
1644
1655
|
readonly softwareVersion: string; // ex: "9.0"
|
|
1645
|
-
readonly udiDeviceIdentifier: string | null
|
|
1656
|
+
readonly udiDeviceIdentifier: string | null;
|
|
1646
1657
|
};
|
|
1647
1658
|
|
|
1648
1659
|
/**
|
|
@@ -1682,9 +1693,9 @@ export type HKQuantitySampleRaw<
|
|
|
1682
1693
|
};
|
|
1683
1694
|
|
|
1684
1695
|
export type HKHeartbeatRaw = {
|
|
1685
|
-
readonly timeSinceSeriesStart: number
|
|
1686
|
-
readonly precededByGap: boolean
|
|
1687
|
-
}
|
|
1696
|
+
readonly timeSinceSeriesStart: number;
|
|
1697
|
+
readonly precededByGap: boolean;
|
|
1698
|
+
};
|
|
1688
1699
|
|
|
1689
1700
|
export type HKHeartbeatSeriesSampleRaw = {
|
|
1690
1701
|
readonly uuid: string;
|
|
@@ -1694,7 +1705,18 @@ export type HKHeartbeatSeriesSampleRaw = {
|
|
|
1694
1705
|
readonly heartbeats: readonly HKHeartbeatRaw[];
|
|
1695
1706
|
readonly metadata?: HKHeartbeatSeriesSampleMetadata;
|
|
1696
1707
|
readonly sourceRevision?: HKSourceRevision;
|
|
1697
|
-
}
|
|
1708
|
+
};
|
|
1709
|
+
|
|
1710
|
+
export type CLLocationRawForSaving = {
|
|
1711
|
+
readonly latitude: number;
|
|
1712
|
+
readonly longitude: number;
|
|
1713
|
+
readonly altitude: number;
|
|
1714
|
+
readonly horizontalAccuracy: number;
|
|
1715
|
+
readonly verticalAccuracy: number;
|
|
1716
|
+
readonly course: number;
|
|
1717
|
+
readonly speed: number;
|
|
1718
|
+
readonly timestamp: string; // unix timestamp in milliseconds
|
|
1719
|
+
};
|
|
1698
1720
|
|
|
1699
1721
|
export type HKQuantitySampleRawForSaving<
|
|
1700
1722
|
TQuantityIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
@@ -1702,19 +1724,25 @@ export type HKQuantitySampleRawForSaving<
|
|
|
1702
1724
|
> = Omit<
|
|
1703
1725
|
HKQuantitySampleRaw<TQuantityIdentifier, TUnit>,
|
|
1704
1726
|
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
1705
|
-
|
|
1727
|
+
> & {
|
|
1728
|
+
readonly startDate?: string;
|
|
1729
|
+
readonly endDate?: string;
|
|
1730
|
+
};
|
|
1706
1731
|
|
|
1707
1732
|
export type HKCategorySampleRawForSaving<
|
|
1708
1733
|
TCategory extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
1709
1734
|
> = Omit<
|
|
1710
1735
|
HKCategorySampleRaw<TCategory>,
|
|
1711
1736
|
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
1712
|
-
|
|
1737
|
+
> & {
|
|
1738
|
+
readonly startDate?: string;
|
|
1739
|
+
readonly endDate?: string;
|
|
1740
|
+
};
|
|
1713
1741
|
|
|
1714
1742
|
export interface HKWorkoutEvent {
|
|
1715
|
-
readonly type: HKWorkoutEventType
|
|
1716
|
-
readonly startDate: string
|
|
1717
|
-
readonly endDate: string
|
|
1743
|
+
readonly type: HKWorkoutEventType;
|
|
1744
|
+
readonly startDate: string;
|
|
1745
|
+
readonly endDate: string;
|
|
1718
1746
|
}
|
|
1719
1747
|
|
|
1720
1748
|
export enum HKWorkoutEventType {
|
|
@@ -1729,10 +1757,10 @@ export enum HKWorkoutEventType {
|
|
|
1729
1757
|
}
|
|
1730
1758
|
|
|
1731
1759
|
export interface HKWorkoutActivity {
|
|
1732
|
-
readonly startDate: string
|
|
1733
|
-
readonly endDate: string
|
|
1734
|
-
readonly uuid: string
|
|
1735
|
-
readonly duration: number
|
|
1760
|
+
readonly startDate: string;
|
|
1761
|
+
readonly endDate: string;
|
|
1762
|
+
readonly uuid: string;
|
|
1763
|
+
readonly duration: number;
|
|
1736
1764
|
}
|
|
1737
1765
|
|
|
1738
1766
|
export type HKWorkoutRaw<
|
|
@@ -1801,36 +1829,40 @@ export type HKCategorySampleRaw<
|
|
|
1801
1829
|
|
|
1802
1830
|
export type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
1803
1831
|
readonly uuid: string;
|
|
1804
|
-
readonly metadata: MetadataMapperForCategoryIdentifier<T
|
|
1805
|
-
}
|
|
1832
|
+
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
1833
|
+
};
|
|
1806
1834
|
|
|
1807
1835
|
export type DeletedHeartbeatSeriesSampleRaw = {
|
|
1808
1836
|
readonly uuid: string;
|
|
1809
1837
|
readonly metadata: HKHeartbeatSeriesSampleMetadata;
|
|
1810
|
-
}
|
|
1838
|
+
};
|
|
1811
1839
|
|
|
1812
1840
|
export type DeletedQuantitySampleRaw<T extends HKQuantityTypeIdentifier> = {
|
|
1813
1841
|
readonly uuid: string;
|
|
1814
|
-
readonly metadata: MetadataMapperForQuantityIdentifier<T
|
|
1815
|
-
}
|
|
1842
|
+
readonly metadata: MetadataMapperForQuantityIdentifier<T>;
|
|
1843
|
+
};
|
|
1816
1844
|
|
|
1817
|
-
export type QueryCategorySamplesResponseRaw<
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
readonly
|
|
1821
|
-
|
|
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
|
+
};
|
|
1822
1852
|
|
|
1823
1853
|
export type QueryHeartbeatSeriesSamplesResponseRaw = {
|
|
1824
|
-
readonly samples: readonly HKHeartbeatSeriesSampleRaw[]
|
|
1825
|
-
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[]
|
|
1826
|
-
readonly newAnchor: string
|
|
1827
|
-
}
|
|
1854
|
+
readonly samples: readonly HKHeartbeatSeriesSampleRaw[];
|
|
1855
|
+
readonly deletedSamples: readonly DeletedHeartbeatSeriesSampleRaw[];
|
|
1856
|
+
readonly newAnchor: string;
|
|
1857
|
+
};
|
|
1828
1858
|
|
|
1829
|
-
export type QueryQuantitySamplesResponseRaw<
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
readonly
|
|
1833
|
-
|
|
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
|
+
};
|
|
1834
1866
|
|
|
1835
1867
|
export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
1836
1868
|
{
|
|
@@ -1844,8 +1876,8 @@ export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
|
1844
1876
|
type QueryId = string;
|
|
1845
1877
|
|
|
1846
1878
|
/**
|
|
1847
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1848
|
-
*/
|
|
1879
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1880
|
+
*/
|
|
1849
1881
|
export enum HKUpdateFrequency {
|
|
1850
1882
|
immediate = 1,
|
|
1851
1883
|
hourly = 2,
|
|
@@ -1884,8 +1916,8 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1884
1916
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
1885
1917
|
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
1886
1918
|
/**
|
|
1887
|
-
|
|
1888
|
-
|
|
1919
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
|
|
1920
|
+
*/
|
|
1889
1921
|
readonly enableBackgroundDelivery: (
|
|
1890
1922
|
typeIdentifier: HKSampleTypeIdentifier,
|
|
1891
1923
|
updateFrequency: HKUpdateFrequency
|
|
@@ -1897,8 +1929,8 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1897
1929
|
typeIdentifier: HKSampleTypeIdentifier
|
|
1898
1930
|
) => Promise<boolean>;
|
|
1899
1931
|
/**
|
|
1900
|
-
|
|
1901
|
-
|
|
1932
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
|
|
1933
|
+
*/
|
|
1902
1934
|
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
1903
1935
|
|
|
1904
1936
|
readonly saveCorrelationSample: <
|
|
@@ -1920,7 +1952,16 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1920
1952
|
quantities: readonly HKQuantitySampleRawForSaving[],
|
|
1921
1953
|
start: string,
|
|
1922
1954
|
end: string,
|
|
1955
|
+
totals: {
|
|
1956
|
+
readonly distance?: number;
|
|
1957
|
+
readonly energyBurned?: number;
|
|
1958
|
+
},
|
|
1923
1959
|
metadata: HKWorkoutMetadata
|
|
1960
|
+
) => Promise<string | null>;
|
|
1961
|
+
|
|
1962
|
+
readonly saveWorkoutRoute: (
|
|
1963
|
+
workoutUUID: string,
|
|
1964
|
+
locations: readonly CLLocationRawForSaving[]
|
|
1924
1965
|
) => Promise<boolean>;
|
|
1925
1966
|
|
|
1926
1967
|
readonly queryCorrelationSamples: <
|
|
@@ -1936,18 +1977,20 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1936
1977
|
): Promise<QueryId>;
|
|
1937
1978
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
1938
1979
|
/**
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
authorizationStatusFor(
|
|
1980
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
|
|
1981
|
+
*/
|
|
1982
|
+
authorizationStatusFor(
|
|
1983
|
+
type: HealthkitReadAuthorization
|
|
1984
|
+
): Promise<HKAuthorizationStatus>;
|
|
1942
1985
|
/**
|
|
1943
|
-
|
|
1986
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
1944
1987
|
*/
|
|
1945
1988
|
getRequestStatusForAuthorization(
|
|
1946
1989
|
write: WritePermissions,
|
|
1947
1990
|
read: ReadPermissions
|
|
1948
1991
|
): Promise<HKAuthorizationRequestStatus>;
|
|
1949
1992
|
/**
|
|
1950
|
-
|
|
1993
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
1951
1994
|
*/
|
|
1952
1995
|
requestAuthorization(
|
|
1953
1996
|
write: WritePermissions,
|
|
@@ -1971,7 +2014,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1971
2014
|
readonly deleteSamples: <TIdentifier extends HKQuantityTypeIdentifier>(
|
|
1972
2015
|
identifier: TIdentifier,
|
|
1973
2016
|
start: string,
|
|
1974
|
-
end: string
|
|
2017
|
+
end: string
|
|
1975
2018
|
) => Promise<boolean>;
|
|
1976
2019
|
readonly queryWorkoutSamples: <
|
|
1977
2020
|
TEnergy extends EnergyUnit,
|
|
@@ -1989,7 +2032,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1989
2032
|
from: string,
|
|
1990
2033
|
to: string,
|
|
1991
2034
|
limit: number,
|
|
1992
|
-
ascending: boolean
|
|
2035
|
+
ascending: boolean
|
|
1993
2036
|
) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
1994
2037
|
readonly queryQuantitySamples: <
|
|
1995
2038
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
@@ -2000,7 +2043,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2000
2043
|
from: string,
|
|
2001
2044
|
to: string,
|
|
2002
2045
|
limit: number,
|
|
2003
|
-
ascending: boolean
|
|
2046
|
+
ascending: boolean
|
|
2004
2047
|
) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
2005
2048
|
readonly queryCategorySamplesWithAnchor: <T extends HKCategoryTypeIdentifier>(
|
|
2006
2049
|
identifier: T,
|
|
@@ -2024,7 +2067,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2024
2067
|
from: string,
|
|
2025
2068
|
to: string,
|
|
2026
2069
|
limit: number,
|
|
2027
|
-
ascending: boolean
|
|
2070
|
+
ascending: boolean
|
|
2028
2071
|
) => Promise<readonly HKHeartbeatSeriesSampleRaw[]>;
|
|
2029
2072
|
readonly queryHeartbeatSeriesSamplesWithAnchor: (
|
|
2030
2073
|
from: string,
|
|
@@ -2060,6 +2103,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2060
2103
|
readonly getWorkoutRoutes: (
|
|
2061
2104
|
workoutUUID: string
|
|
2062
2105
|
) => Promise<readonly WorkoutRoute[]>;
|
|
2106
|
+
readonly getWorkoutPlanById: (workoutUUID: string) => Promise<{readonly id: string, readonly activityType: HKWorkoutActivityType} | null>;
|
|
2063
2107
|
};
|
|
2064
2108
|
|
|
2065
2109
|
const Native = NativeModules.ReactNativeHealthkit as ReactNativeHealthkitTypeNative
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
CLLocationRawForSaving,
|
|
2
3
|
EnergyUnit,
|
|
3
4
|
HKCategorySampleRaw,
|
|
4
5
|
HKCategoryTypeIdentifier,
|
|
@@ -117,13 +118,19 @@ export interface QueryStatisticsResponse<TIdentifier extends HKQuantityTypeIdent
|
|
|
117
118
|
* Represents a category sample for saving.
|
|
118
119
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorysample Apple Docs HKCategorySample}
|
|
119
120
|
*/
|
|
120
|
-
export type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
121
|
+
export type HKCategorySampleForSaving = Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'> & {
|
|
122
|
+
readonly startDate?: Date;
|
|
123
|
+
readonly endDate?: Date;
|
|
124
|
+
}
|
|
121
125
|
|
|
122
126
|
/**
|
|
123
127
|
* Represents a quantity sample for saving.
|
|
124
128
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitysample Apple Docs HKQuantitySample}
|
|
125
129
|
*/
|
|
126
|
-
export type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
130
|
+
export type HKQuantitySampleForSaving = Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'> & {
|
|
131
|
+
readonly startDate?: Date;
|
|
132
|
+
readonly endDate?: Date;
|
|
133
|
+
};
|
|
127
134
|
|
|
128
135
|
/**
|
|
129
136
|
* Represents a correlation.
|
|
@@ -139,3 +146,11 @@ export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>
|
|
|
139
146
|
readonly startDate: Date;
|
|
140
147
|
readonly endDate: Date;
|
|
141
148
|
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Represents a location sample for saving.
|
|
152
|
+
* @see {@link https://developer.apple.com/documentation/corelocation/cllocation Apple Docs CLLocation}
|
|
153
|
+
*/
|
|
154
|
+
export type CLLocationForSaving = Omit<CLLocationRawForSaving, 'timestamp'> & {
|
|
155
|
+
readonly timestamp: number;
|
|
156
|
+
};
|
|
@@ -24,7 +24,16 @@ async function saveCorrelationSample<
|
|
|
24
24
|
|
|
25
25
|
return Native.saveCorrelationSample(
|
|
26
26
|
typeIdentifier,
|
|
27
|
-
samples.map((
|
|
27
|
+
samples.map((sample) => {
|
|
28
|
+
const { startDate, endDate, ...rest } = sample
|
|
29
|
+
const updatedSample = {
|
|
30
|
+
...rest,
|
|
31
|
+
...(startDate && { startDate: new Date(startDate).toISOString() }),
|
|
32
|
+
...(endDate && { endDate: new Date(endDate).toISOString() }),
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return { ...updatedSample, metadata: ensureMetadata(sample.metadata) }
|
|
36
|
+
}),
|
|
28
37
|
start,
|
|
29
38
|
end,
|
|
30
39
|
ensureMetadata(options?.metadata),
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Native from '../native-types'
|
|
2
|
+
|
|
3
|
+
import type { CLLocationForSaving } from '../types'
|
|
4
|
+
|
|
5
|
+
async function saveWorkoutRoute(
|
|
6
|
+
workoutUUID: string,
|
|
7
|
+
locations: readonly CLLocationForSaving[],
|
|
8
|
+
) {
|
|
9
|
+
return Native.saveWorkoutRoute(
|
|
10
|
+
workoutUUID,
|
|
11
|
+
locations.map((location) => {
|
|
12
|
+
const { timestamp, ...rest } = location
|
|
13
|
+
return {
|
|
14
|
+
...rest,
|
|
15
|
+
...(timestamp ? { timestamp: new Date(timestamp).toISOString() } : { timestamp: '' }),
|
|
16
|
+
}
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default saveWorkoutRoute
|
|
@@ -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
|
) {
|
|
@@ -18,9 +23,18 @@ async function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(
|
|
|
18
23
|
|
|
19
24
|
return Native.saveWorkoutSample(
|
|
20
25
|
typeIdentifier,
|
|
21
|
-
quantities.map((
|
|
26
|
+
quantities.map((quantity) => {
|
|
27
|
+
const { startDate, endDate, ...rest } = quantity
|
|
28
|
+
const updatedQuantity = {
|
|
29
|
+
...rest,
|
|
30
|
+
...(startDate && { startDate: startDate.toISOString() }),
|
|
31
|
+
...(endDate && { endDate: endDate.toISOString() }),
|
|
32
|
+
}
|
|
33
|
+
return { ...updatedQuantity, metadata: ensureMetadata(quantity.metadata) }
|
|
34
|
+
}),
|
|
22
35
|
start,
|
|
23
36
|
end,
|
|
37
|
+
ensureTotals(options?.totals),
|
|
24
38
|
ensureMetadata(options?.metadata),
|
|
25
39
|
)
|
|
26
40
|
}
|