@kingstinct/react-native-healthkit 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ReactNativeHealthkit.swift +2 -2
- package/lib/commonjs/index.ios.js +92 -103
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +2 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +9 -1
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.ios.js +92 -103
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +4 -0
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +126 -120
- package/lib/typescript/src/types.d.ts +79 -79
- package/package.json +20 -35
- package/src/index.ios.tsx +260 -269
- package/src/index.tsx +13 -13
- package/src/native-types.ts +184 -182
- package/src/types.ts +100 -100
package/src/types.ts
CHANGED
|
@@ -26,55 +26,55 @@ import type {
|
|
|
26
26
|
MetadataMapperForQuantityIdentifier,
|
|
27
27
|
QueryStatisticsResponseRaw,
|
|
28
28
|
WorkoutRoute,
|
|
29
|
-
} from './native-types'
|
|
29
|
+
} from './native-types'
|
|
30
30
|
|
|
31
31
|
export interface QueryWorkoutsOptions<
|
|
32
32
|
TEnergy extends HKUnit,
|
|
33
33
|
TDistance extends HKUnit
|
|
34
34
|
> extends GenericQueryOptions {
|
|
35
|
-
energyUnit?: TEnergy;
|
|
36
|
-
distanceUnit?: TDistance;
|
|
35
|
+
readonly energyUnit?: TEnergy;
|
|
36
|
+
readonly distanceUnit?: TDistance;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export interface HKCategorySample<
|
|
40
40
|
T extends HKCategoryTypeIdentifier = HKCategoryTypeIdentifier
|
|
41
|
-
> extends Omit<HKCategorySampleRaw<T>, '
|
|
42
|
-
startDate: Date;
|
|
43
|
-
endDate: Date;
|
|
41
|
+
> extends Omit<HKCategorySampleRaw<T>, 'endDate' | 'startDate'> {
|
|
42
|
+
readonly startDate: Date;
|
|
43
|
+
readonly endDate: Date;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export type GenericQueryOptions = {
|
|
47
|
-
from?: Date;
|
|
48
|
-
to?: Date;
|
|
49
|
-
limit?:
|
|
50
|
-
ascending?: boolean;
|
|
47
|
+
readonly from?: Date;
|
|
48
|
+
readonly to?: Date;
|
|
49
|
+
readonly limit?: number;
|
|
50
|
+
readonly ascending?: boolean;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
export interface HKWorkout<
|
|
54
54
|
TEnergy extends HKUnit = HKUnit,
|
|
55
55
|
TDistance extends HKUnit = HKUnit
|
|
56
|
-
> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, '
|
|
57
|
-
startDate: Date;
|
|
58
|
-
endDate: Date;
|
|
56
|
+
> extends Omit<HKWorkoutRaw<TEnergy, TDistance>, 'endDate' | 'startDate'> {
|
|
57
|
+
readonly startDate: Date;
|
|
58
|
+
readonly endDate: Date;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export interface HKQuantitySample<
|
|
62
62
|
TIdentifier extends HKQuantityTypeIdentifier = HKQuantityTypeIdentifier,
|
|
63
63
|
TUnit extends HKUnit = HKUnit
|
|
64
64
|
> extends Omit<
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
HKQuantitySampleRaw<TIdentifier, TUnit>,
|
|
66
|
+
'endDate' | 'startDate'
|
|
67
67
|
> {
|
|
68
|
-
startDate: Date;
|
|
69
|
-
endDate: Date;
|
|
68
|
+
readonly startDate: Date;
|
|
69
|
+
readonly endDate: Date;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface QueryStatisticsResponse<T extends HKUnit = HKUnit>
|
|
73
73
|
extends Omit<
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
QueryStatisticsResponseRaw<T>,
|
|
75
|
+
'mostRecentQuantityDateInterval'
|
|
76
76
|
> {
|
|
77
|
-
mostRecentQuantityDateInterval?: { from: Date; to: Date };
|
|
77
|
+
readonly mostRecentQuantityDateInterval?: { readonly from: Date; readonly to: Date };
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
type UnsubscribeFunction = () => Promise<boolean>;
|
|
@@ -90,7 +90,7 @@ export type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;
|
|
|
90
90
|
|
|
91
91
|
export type QueryStatisticsForQuantityFn = <TUnit extends HKUnit>(
|
|
92
92
|
identifier: HKQuantityTypeIdentifier,
|
|
93
|
-
options: HKStatisticsOptions[],
|
|
93
|
+
options: readonly HKStatisticsOptions[],
|
|
94
94
|
from: Date,
|
|
95
95
|
to?: Date,
|
|
96
96
|
unit?: TUnit
|
|
@@ -101,25 +101,25 @@ export type QueryWorkoutsFn = <
|
|
|
101
101
|
TDistance extends HKUnit
|
|
102
102
|
>(
|
|
103
103
|
options: QueryWorkoutsOptions<TEnergy, TDistance>
|
|
104
|
-
) => Promise<HKWorkout<TEnergy, TDistance>[]>;
|
|
104
|
+
) => Promise<readonly HKWorkout<TEnergy, TDistance>[]>;
|
|
105
105
|
|
|
106
106
|
export type AuthorizationStatusForFn = (
|
|
107
|
-
type:
|
|
107
|
+
type: HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier
|
|
108
108
|
) => Promise<boolean>;
|
|
109
109
|
|
|
110
110
|
export type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(
|
|
111
111
|
identifier: T,
|
|
112
112
|
options: GenericQueryOptions
|
|
113
|
-
) => Promise<HKCategorySample<T>[]>;
|
|
113
|
+
) => Promise<readonly HKCategorySample<T>[]>;
|
|
114
114
|
|
|
115
115
|
export type GetRequestStatusForAuthorizationFn = (
|
|
116
|
-
read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],
|
|
117
|
-
write?: HKSampleTypeIdentifier[]
|
|
116
|
+
read: readonly (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],
|
|
117
|
+
write?: readonly HKSampleTypeIdentifier[]
|
|
118
118
|
) => Promise<HKAuthorizationRequestStatus>;
|
|
119
119
|
|
|
120
120
|
export type RequestAuthorizationFn = (
|
|
121
|
-
read: (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],
|
|
122
|
-
write?: HKSampleTypeIdentifier[]
|
|
121
|
+
read: readonly (HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier)[],
|
|
122
|
+
write?: readonly HKSampleTypeIdentifier[]
|
|
123
123
|
) => Promise<boolean>;
|
|
124
124
|
|
|
125
125
|
export type SaveQuantitySampleFn = <TUnit extends HKQuantityTypeIdentifier>(
|
|
@@ -127,9 +127,9 @@ export type SaveQuantitySampleFn = <TUnit extends HKQuantityTypeIdentifier>(
|
|
|
127
127
|
unit: HKUnit,
|
|
128
128
|
value: number,
|
|
129
129
|
options?: {
|
|
130
|
-
start?: Date;
|
|
131
|
-
end?: Date;
|
|
132
|
-
metadata?: MetadataMapperForQuantityIdentifier<TUnit>;
|
|
130
|
+
readonly start?: Date;
|
|
131
|
+
readonly end?: Date;
|
|
132
|
+
readonly metadata?: MetadataMapperForQuantityIdentifier<TUnit>;
|
|
133
133
|
}
|
|
134
134
|
) => Promise<boolean>;
|
|
135
135
|
|
|
@@ -138,8 +138,8 @@ export type QueryQuantitySamplesFn = <
|
|
|
138
138
|
TUnit extends HKUnit = HKUnit
|
|
139
139
|
>(
|
|
140
140
|
identifier: TIdentifier,
|
|
141
|
-
options: GenericQueryOptions & { unit?: TUnit }
|
|
142
|
-
) => Promise<HKQuantitySample<TIdentifier, TUnit>[]>;
|
|
141
|
+
options: GenericQueryOptions & { readonly unit?: TUnit }
|
|
142
|
+
) => Promise<readonly HKQuantitySample<TIdentifier, TUnit>[]>;
|
|
143
143
|
|
|
144
144
|
export type SubscribeToChangesFn = (
|
|
145
145
|
identifier: HKSampleTypeIdentifier,
|
|
@@ -150,9 +150,9 @@ export type SaveCategorySampleFn = <T extends HKCategoryTypeIdentifier>(
|
|
|
150
150
|
identifier: T,
|
|
151
151
|
value: HKCategoryValueForIdentifier<T>,
|
|
152
152
|
options?: {
|
|
153
|
-
start?: Date;
|
|
154
|
-
end?: Date;
|
|
155
|
-
metadata?: MetadataMapperForCategoryIdentifier<T>;
|
|
153
|
+
readonly start?: Date;
|
|
154
|
+
readonly end?: Date;
|
|
155
|
+
readonly metadata?: MetadataMapperForCategoryIdentifier<T>;
|
|
156
156
|
}
|
|
157
157
|
) => Promise<boolean>;
|
|
158
158
|
|
|
@@ -193,8 +193,8 @@ export type GetMostRecentWorkoutFn = <
|
|
|
193
193
|
TDistance extends HKUnit
|
|
194
194
|
>(
|
|
195
195
|
options?: Pick<
|
|
196
|
-
|
|
197
|
-
|
|
196
|
+
QueryWorkoutsOptions<TEnergy, TDistance>,
|
|
197
|
+
'distanceUnit' | 'energyUnit'
|
|
198
198
|
>
|
|
199
199
|
) => Promise<HKWorkout<TEnergy, TDistance> | null>;
|
|
200
200
|
|
|
@@ -203,14 +203,14 @@ export type MostRecentWorkoutHook = <
|
|
|
203
203
|
TDistance extends HKUnit
|
|
204
204
|
>(
|
|
205
205
|
options?: Pick<
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
QueryWorkoutsOptions<TEnergy, TDistance>,
|
|
207
|
+
'distanceUnit' | 'energyUnit'
|
|
208
208
|
>
|
|
209
209
|
) => HKWorkout<TEnergy, TDistance> | null;
|
|
210
210
|
|
|
211
211
|
export type GetPreferredUnitsFn = (
|
|
212
|
-
identifiers: HKQuantityTypeIdentifier[]
|
|
213
|
-
) => Promise<HKUnit[]>;
|
|
212
|
+
identifiers: readonly HKQuantityTypeIdentifier[]
|
|
213
|
+
) => Promise<readonly HKUnit[]>;
|
|
214
214
|
|
|
215
215
|
export type GetPreferredUnitFn = (
|
|
216
216
|
identifier: HKQuantityTypeIdentifier
|
|
@@ -220,46 +220,46 @@ export type SaveCorrelationSampleFn = <
|
|
|
220
220
|
TIdentifier extends HKCorrelationTypeIdentifier
|
|
221
221
|
>(
|
|
222
222
|
typeIdentifier: TIdentifier,
|
|
223
|
-
samples: (
|
|
224
|
-
| Omit<HKCategorySample, '
|
|
225
|
-
| Omit<HKQuantitySample, '
|
|
223
|
+
samples: readonly (
|
|
224
|
+
| Omit<HKCategorySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
225
|
+
| Omit<HKQuantitySample, 'device' | 'endDate' | 'startDate' | 'uuid'>
|
|
226
226
|
)[],
|
|
227
227
|
options?: {
|
|
228
|
-
start?: Date;
|
|
229
|
-
end?: Date;
|
|
230
|
-
metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
228
|
+
readonly start?: Date;
|
|
229
|
+
readonly end?: Date;
|
|
230
|
+
readonly metadata?: MetadataMapperForCorrelationIdentifier<TIdentifier>;
|
|
231
231
|
}
|
|
232
232
|
) => Promise<boolean>;
|
|
233
233
|
|
|
234
234
|
export type SaveWorkoutSampleFn = (
|
|
235
235
|
typeIdentifier: HKWorkoutActivityType,
|
|
236
|
-
quantities: Omit<
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
quantities: readonly Omit<
|
|
237
|
+
HKQuantitySample,
|
|
238
|
+
'device' | 'endDate' | 'startDate' | 'uuid'
|
|
239
239
|
>[],
|
|
240
240
|
start: Date,
|
|
241
241
|
options?: {
|
|
242
|
-
end?: Date;
|
|
243
|
-
metadata?: HKWorkoutMetadata;
|
|
242
|
+
readonly end?: Date;
|
|
243
|
+
readonly metadata?: HKWorkoutMetadata;
|
|
244
244
|
}
|
|
245
245
|
) => Promise<boolean>;
|
|
246
246
|
|
|
247
247
|
export interface HKCorrelation<TIdentifier extends HKCorrelationTypeIdentifier>
|
|
248
248
|
extends Omit<
|
|
249
|
-
|
|
250
|
-
|
|
249
|
+
HKCorrelationRaw<TIdentifier>,
|
|
250
|
+
'endDate' | 'objects' | 'startDate'
|
|
251
251
|
> {
|
|
252
|
-
objects: (
|
|
253
|
-
startDate: Date;
|
|
254
|
-
endDate: Date;
|
|
252
|
+
readonly objects: readonly (HKCategorySample | HKQuantitySample)[];
|
|
253
|
+
readonly startDate: Date;
|
|
254
|
+
readonly endDate: Date;
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
export type QueryCorrelationSamplesFn = <
|
|
258
258
|
TIdentifier extends HKCorrelationTypeIdentifier
|
|
259
259
|
>(
|
|
260
260
|
typeIdentifier: TIdentifier,
|
|
261
|
-
options: Omit<GenericQueryOptions, '
|
|
262
|
-
) => Promise<HKCorrelation<TIdentifier>[]>;
|
|
261
|
+
options: Omit<GenericQueryOptions, 'ascending' | 'limit'>
|
|
262
|
+
) => Promise<readonly HKCorrelation<TIdentifier>[]>;
|
|
263
263
|
|
|
264
264
|
export type SubscribeToChangesHook = <
|
|
265
265
|
TIdentifier extends HKSampleTypeIdentifier
|
|
@@ -271,54 +271,54 @@ export type SubscribeToChangesHook = <
|
|
|
271
271
|
|
|
272
272
|
export type GetWorkoutRoutesFn = (
|
|
273
273
|
workoutUUID: string
|
|
274
|
-
) => Promise<WorkoutRoute[]>;
|
|
274
|
+
) => Promise<readonly WorkoutRoute[]>;
|
|
275
275
|
|
|
276
276
|
export type ReactNativeHealthkit = {
|
|
277
|
-
authorizationStatusFor: AuthorizationStatusForFn;
|
|
278
|
-
|
|
279
|
-
getBiologicalSex: GetBiologicalSexFn;
|
|
280
|
-
getBloodType: GetBloodTypeFn;
|
|
281
|
-
getDateOfBirth: GetDateOfBirthFn;
|
|
282
|
-
getFitzpatrickSkinType: GetFitzpatrickSkinTypeFn;
|
|
283
|
-
getMostRecentQuantitySample: GetMostRecentQuantitySampleFn;
|
|
284
|
-
getMostRecentCategorySample: GetMostRecentCategorySampleFn;
|
|
285
|
-
getMostRecentWorkout: GetMostRecentWorkoutFn;
|
|
286
|
-
getPreferredUnit: GetPreferredUnitFn;
|
|
287
|
-
getPreferredUnits: GetPreferredUnitsFn;
|
|
288
|
-
getRequestStatusForAuthorization: GetRequestStatusForAuthorizationFn;
|
|
289
|
-
getWheelchairUse: GetWheelchairUseFn;
|
|
290
|
-
getWorkoutRoutes: GetWorkoutRoutesFn;
|
|
291
|
-
|
|
292
|
-
buildUnitWithPrefix: (prefix: HKUnitSIPrefix, unit: HKUnitSI) => HKUnit;
|
|
293
|
-
|
|
294
|
-
isHealthDataAvailable: IsHealthDataAvailableFn;
|
|
295
|
-
|
|
296
|
-
queryCategorySamples: QueryCategorySamplesFn;
|
|
297
|
-
queryQuantitySamples: QueryQuantitySamplesFn;
|
|
298
|
-
queryStatisticsForQuantity: QueryStatisticsForQuantityFn;
|
|
299
|
-
queryWorkouts: QueryWorkoutsFn;
|
|
300
|
-
queryCorrelationSamples: QueryCorrelationSamplesFn;
|
|
301
|
-
|
|
302
|
-
requestAuthorization: RequestAuthorizationFn;
|
|
303
|
-
|
|
304
|
-
saveCategorySample: SaveCategorySampleFn;
|
|
305
|
-
saveQuantitySample: SaveQuantitySampleFn;
|
|
306
|
-
saveCorrelationSample: SaveCorrelationSampleFn;
|
|
307
|
-
saveWorkoutSample: SaveWorkoutSampleFn;
|
|
308
|
-
enableBackgroundDelivery: (
|
|
277
|
+
readonly authorizationStatusFor: AuthorizationStatusForFn;
|
|
278
|
+
|
|
279
|
+
readonly getBiologicalSex: GetBiologicalSexFn;
|
|
280
|
+
readonly getBloodType: GetBloodTypeFn;
|
|
281
|
+
readonly getDateOfBirth: GetDateOfBirthFn;
|
|
282
|
+
readonly getFitzpatrickSkinType: GetFitzpatrickSkinTypeFn;
|
|
283
|
+
readonly getMostRecentQuantitySample: GetMostRecentQuantitySampleFn;
|
|
284
|
+
readonly getMostRecentCategorySample: GetMostRecentCategorySampleFn;
|
|
285
|
+
readonly getMostRecentWorkout: GetMostRecentWorkoutFn;
|
|
286
|
+
readonly getPreferredUnit: GetPreferredUnitFn;
|
|
287
|
+
readonly getPreferredUnits: GetPreferredUnitsFn;
|
|
288
|
+
readonly getRequestStatusForAuthorization: GetRequestStatusForAuthorizationFn;
|
|
289
|
+
readonly getWheelchairUse: GetWheelchairUseFn;
|
|
290
|
+
readonly getWorkoutRoutes: GetWorkoutRoutesFn;
|
|
291
|
+
|
|
292
|
+
readonly buildUnitWithPrefix: (prefix: HKUnitSIPrefix, unit: HKUnitSI) => HKUnit;
|
|
293
|
+
|
|
294
|
+
readonly isHealthDataAvailable: IsHealthDataAvailableFn;
|
|
295
|
+
|
|
296
|
+
readonly queryCategorySamples: QueryCategorySamplesFn;
|
|
297
|
+
readonly queryQuantitySamples: QueryQuantitySamplesFn;
|
|
298
|
+
readonly queryStatisticsForQuantity: QueryStatisticsForQuantityFn;
|
|
299
|
+
readonly queryWorkouts: QueryWorkoutsFn;
|
|
300
|
+
readonly queryCorrelationSamples: QueryCorrelationSamplesFn;
|
|
301
|
+
|
|
302
|
+
readonly requestAuthorization: RequestAuthorizationFn;
|
|
303
|
+
|
|
304
|
+
readonly saveCategorySample: SaveCategorySampleFn;
|
|
305
|
+
readonly saveQuantitySample: SaveQuantitySampleFn;
|
|
306
|
+
readonly saveCorrelationSample: SaveCorrelationSampleFn;
|
|
307
|
+
readonly saveWorkoutSample: SaveWorkoutSampleFn;
|
|
308
|
+
readonly enableBackgroundDelivery: (
|
|
309
309
|
typeIdentifier: HKSampleTypeIdentifier,
|
|
310
310
|
updateFrequency: HKUpdateFrequency
|
|
311
311
|
) => Promise<boolean>;
|
|
312
|
-
disableBackgroundDelivery: (
|
|
312
|
+
readonly disableBackgroundDelivery: (
|
|
313
313
|
typeIdentifier: HKSampleTypeIdentifier
|
|
314
314
|
) => Promise<boolean>;
|
|
315
|
-
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
315
|
+
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
316
316
|
|
|
317
|
-
subscribeToChanges: SubscribeToChangesFn;
|
|
317
|
+
readonly subscribeToChanges: SubscribeToChangesFn;
|
|
318
318
|
|
|
319
|
-
useMostRecentWorkout: MostRecentWorkoutHook;
|
|
320
|
-
useMostRecentCategorySample: MostRecentCategorySampleHook;
|
|
321
|
-
useMostRecentQuantitySample: MostRecentQuantitySampleHook;
|
|
319
|
+
readonly useMostRecentWorkout: MostRecentWorkoutHook;
|
|
320
|
+
readonly useMostRecentCategorySample: MostRecentCategorySampleHook;
|
|
321
|
+
readonly useMostRecentQuantitySample: MostRecentQuantitySampleHook;
|
|
322
322
|
|
|
323
|
-
useSubscribeToChanges: SubscribeToChangesHook;
|
|
323
|
+
readonly useSubscribeToChanges: SubscribeToChangesHook;
|
|
324
324
|
};
|