@kingstinct/react-native-healthkit 8.1.0 → 8.2.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 +1588 -1219
- package/lib/commonjs/index.ios.js +18 -2
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.native.js +33 -23
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +1 -1
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js +26 -0
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js.map +1 -0
- package/lib/module/index.ios.js +14 -3
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.native.js +20 -12
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js +2 -2
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +1 -1
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js +19 -0
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js.map +1 -0
- package/lib/typescript/src/index.ios.d.ts +14 -3
- package/lib/typescript/src/index.native.d.ts +6 -2
- package/lib/typescript/src/native-types.d.ts +10 -1
- package/lib/typescript/src/utils/queryWorkoutSamplesWithAnchor.d.ts +9 -0
- package/package.json +1 -1
- package/src/index.ios.tsx +15 -2
- package/src/index.native.tsx +30 -20
- package/src/native-types.ts +15 -1
- package/src/utils/queryCategorySamplesWithAnchor.ts +2 -2
- package/src/utils/queryWorkoutSamplesWithAnchor.ts +46 -0
|
@@ -26,7 +26,8 @@ import queryQuantitySamples from './utils/queryQuantitySamples';
|
|
|
26
26
|
import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor';
|
|
27
27
|
import querySources from './utils/querySources';
|
|
28
28
|
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
|
|
29
|
-
import
|
|
29
|
+
import queryWorkoutSamples from './utils/queryWorkouts';
|
|
30
|
+
import queryWorkoutSamplesWithAnchor from './utils/queryWorkoutSamplesWithAnchor';
|
|
30
31
|
import requestAuthorization from './utils/requestAuthorization';
|
|
31
32
|
import saveCategorySample from './utils/saveCategorySample';
|
|
32
33
|
import saveCorrelationSample from './utils/saveCorrelationSample';
|
|
@@ -124,7 +125,12 @@ declare const _default: {
|
|
|
124
125
|
queryQuantitySamples: import("./utils/queryQuantitySamples").QueryQuantitySamplesFn;
|
|
125
126
|
queryQuantitySamplesWithAnchor: import("./utils/queryQuantitySamplesWithAnchor").QueryQuantitySamplesWithAnchorFn;
|
|
126
127
|
queryStatisticsForQuantity: typeof queryStatisticsForQuantity;
|
|
127
|
-
|
|
128
|
+
/**
|
|
129
|
+
* @deprecated Use queryWorkoutSamples instead
|
|
130
|
+
*/
|
|
131
|
+
queryWorkouts: typeof queryWorkoutSamples;
|
|
132
|
+
queryWorkoutSamples: typeof queryWorkoutSamples;
|
|
133
|
+
queryWorkoutSamplesWithAnchor: typeof queryWorkoutSamplesWithAnchor;
|
|
128
134
|
querySources: import("./utils/querySources").QuerySourcesFn;
|
|
129
135
|
requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
|
|
130
136
|
deleteQuantitySample: import("./utils/deleteQuantitySample").DeleteQuantitySampleFn;
|
|
@@ -168,5 +174,10 @@ declare const _default: {
|
|
|
168
174
|
useStatisticsForQuantity: typeof useStatisticsForQuantity;
|
|
169
175
|
};
|
|
170
176
|
export default _default;
|
|
171
|
-
|
|
177
|
+
declare const queryWorkouts: typeof queryWorkoutSamples;
|
|
178
|
+
export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity,
|
|
179
|
+
/**
|
|
180
|
+
* @deprecated Use queryWorkoutSamples instead
|
|
181
|
+
*/
|
|
182
|
+
queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useSources, useStatisticsForQuantity, isProtectedDataAvailable, };
|
|
172
183
|
export * from './types';
|
|
@@ -22,8 +22,12 @@ declare const authorizationStatusFor: () => Promise<HKAuthorizationStatus>, avai
|
|
|
22
22
|
mostRecentQuantity: undefined;
|
|
23
23
|
mostRecentQuantityDateInterval: undefined;
|
|
24
24
|
duration: undefined;
|
|
25
|
-
}>, queryWorkouts: () => Promise<never[]>,
|
|
25
|
+
}>, queryWorkouts: () => Promise<never[]>, queryWorkoutSamples: () => Promise<never[]>, queryWorkoutSamplesWithAnchor: () => Promise<{
|
|
26
|
+
samples: never[];
|
|
27
|
+
deletedSamples: never[];
|
|
28
|
+
newAnchor: string;
|
|
29
|
+
}>, querySources: () => Promise<never[]>, requestAuthorization: () => Promise<boolean>, deleteQuantitySample: () => Promise<boolean>, deleteSamples: () => Promise<boolean>, getWorkoutPlanById: () => Promise<null>, saveCategorySample: () => Promise<boolean>, saveCorrelationSample: () => Promise<boolean>, saveQuantitySample: () => Promise<boolean>, saveWorkoutSample: () => Promise<null>, saveWorkoutRoute: () => Promise<boolean>, subscribeToChanges: () => Promise<() => Promise<boolean>>, useMostRecentCategorySample: () => null, useMostRecentQuantitySample: () => null, useMostRecentWorkout: () => null, useSubscribeToChanges: () => ((() => null) | null)[], useHealthkitAuthorization: () => readonly [null, () => Promise<HKAuthorizationRequestStatus>], useIsHealthDataAvailable: () => boolean, isProtectedDataAvailable: () => Promise<boolean>;
|
|
26
30
|
declare const Healthkit: typeof ReactNativeHealthkit;
|
|
27
|
-
export { authorizationStatusFor, availableQuantityTypes,
|
|
31
|
+
export { authorizationStatusFor, availableQuantityTypes, deleteQuantitySample, deleteSamples, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutPlanById, getWorkoutRoutes, isHealthDataAvailable, isProtectedDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, querySources, queryStatisticsForQuantity, queryWorkouts, queryWorkoutSamples, queryWorkoutSamplesWithAnchor, requestAuthorization, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutRoute, saveWorkoutSample, subscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSources, useStatisticsForQuantity, useSubscribeToChanges, };
|
|
28
32
|
export * from './types';
|
|
29
33
|
export default Healthkit;
|
|
@@ -1441,6 +1441,10 @@ export type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
|
1441
1441
|
readonly uuid: string;
|
|
1442
1442
|
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
1443
1443
|
};
|
|
1444
|
+
export type DeletedWorkoutSampleRaw = {
|
|
1445
|
+
readonly uuid: string;
|
|
1446
|
+
readonly metadata: HKWorkoutMetadata;
|
|
1447
|
+
};
|
|
1444
1448
|
export type DeletedHeartbeatSeriesSampleRaw = {
|
|
1445
1449
|
readonly uuid: string;
|
|
1446
1450
|
readonly metadata: HKHeartbeatSeriesSampleMetadata;
|
|
@@ -1497,6 +1501,11 @@ export type WorkoutRoute = {
|
|
|
1497
1501
|
readonly HKMetadataKeySyncIdentifier?: string;
|
|
1498
1502
|
readonly HKMetadataKeySyncVersion?: number;
|
|
1499
1503
|
};
|
|
1504
|
+
type QueryWorkoutSamplesWithAnchorResponseRaw<TEnergy extends EnergyUnit, TDistance extends LengthUnit> = {
|
|
1505
|
+
readonly samples: readonly HKWorkoutRaw<TEnergy, TDistance>[];
|
|
1506
|
+
readonly deletedSamples: readonly DeletedWorkoutSampleRaw[];
|
|
1507
|
+
readonly newAnchor: string;
|
|
1508
|
+
};
|
|
1500
1509
|
type ReactNativeHealthkitTypeNative = {
|
|
1501
1510
|
/**
|
|
1502
1511
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
|
|
@@ -1548,7 +1557,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1548
1557
|
readonly queryCategorySamples: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKCategorySampleRaw<T>[]>;
|
|
1549
1558
|
readonly queryQuantitySamples: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKQuantitySampleRaw<TIdentifier>[]>;
|
|
1550
1559
|
readonly queryCategorySamplesWithAnchor: <T extends HKCategoryTypeIdentifier>(identifier: T, from: string, to: string, limit: number, anchor: string) => Promise<QueryCategorySamplesResponseRaw<T>>;
|
|
1551
|
-
readonly queryWorkoutSamplesWithAnchor: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(energyUnit: TEnergy, distanceUnit: TDistance, from: string, to: string, limit: number, anchor: string) => Promise<
|
|
1560
|
+
readonly queryWorkoutSamplesWithAnchor: <TEnergy extends EnergyUnit, TDistance extends LengthUnit>(energyUnit: TEnergy, distanceUnit: TDistance, from: string, to: string, limit: number, anchor: string) => Promise<QueryWorkoutSamplesWithAnchorResponseRaw<TEnergy, TDistance>>;
|
|
1552
1561
|
readonly queryQuantitySamplesWithAnchor: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit: TUnit, from: string, to: string, limit: number, anchor: string) => Promise<QueryQuantitySamplesResponseRaw<TIdentifier>>;
|
|
1553
1562
|
readonly queryHeartbeatSeriesSamples: (from: string, to: string, limit: number, ascending: boolean) => Promise<readonly HKHeartbeatSeriesSampleRaw[]>;
|
|
1554
1563
|
readonly queryHeartbeatSeriesSamplesWithAnchor: (from: string, to: string, limit: number, anchor: string) => Promise<QueryHeartbeatSeriesSamplesResponseRaw>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EnergyUnit, LengthUnit } from '../native-types';
|
|
2
|
+
import type { DeletedWorkoutSampleRaw, HKWorkout, QueryWorkoutsOptions } from '../types';
|
|
3
|
+
export type QueryWorkoutSamplesWithAnchorResponse<TEnergy extends EnergyUnit, TDistance extends LengthUnit> = {
|
|
4
|
+
readonly samples: readonly HKWorkout<TEnergy, TDistance>[];
|
|
5
|
+
readonly deletedSamples: readonly DeletedWorkoutSampleRaw[];
|
|
6
|
+
readonly newAnchor: string;
|
|
7
|
+
};
|
|
8
|
+
declare function queryCategorySamplesWithAnchor<TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options: Omit<QueryWorkoutsOptions<TEnergy, TDistance>, 'ascending'>): Promise<QueryWorkoutSamplesWithAnchorResponse<TEnergy, TDistance>>;
|
|
9
|
+
export default queryCategorySamplesWithAnchor;
|
package/package.json
CHANGED
package/src/index.ios.tsx
CHANGED
|
@@ -28,7 +28,8 @@ import queryQuantitySamples from './utils/queryQuantitySamples'
|
|
|
28
28
|
import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'
|
|
29
29
|
import querySources from './utils/querySources'
|
|
30
30
|
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'
|
|
31
|
-
import
|
|
31
|
+
import queryWorkoutSamples from './utils/queryWorkouts'
|
|
32
|
+
import queryWorkoutSamplesWithAnchor from './utils/queryWorkoutSamplesWithAnchor'
|
|
32
33
|
import requestAuthorization from './utils/requestAuthorization'
|
|
33
34
|
import saveCategorySample from './utils/saveCategorySample'
|
|
34
35
|
import saveCorrelationSample from './utils/saveCorrelationSample'
|
|
@@ -158,7 +159,12 @@ export default {
|
|
|
158
159
|
queryQuantitySamples,
|
|
159
160
|
queryQuantitySamplesWithAnchor,
|
|
160
161
|
queryStatisticsForQuantity,
|
|
161
|
-
|
|
162
|
+
/**
|
|
163
|
+
* @deprecated Use queryWorkoutSamples instead
|
|
164
|
+
*/
|
|
165
|
+
queryWorkouts: queryWorkoutSamples,
|
|
166
|
+
queryWorkoutSamples,
|
|
167
|
+
queryWorkoutSamplesWithAnchor,
|
|
162
168
|
querySources,
|
|
163
169
|
|
|
164
170
|
requestAuthorization,
|
|
@@ -210,6 +216,8 @@ export default {
|
|
|
210
216
|
useStatisticsForQuantity,
|
|
211
217
|
}
|
|
212
218
|
|
|
219
|
+
const queryWorkouts = queryWorkoutSamples
|
|
220
|
+
|
|
213
221
|
export {
|
|
214
222
|
authorizationStatusFor,
|
|
215
223
|
availableQuantityTypes,
|
|
@@ -237,7 +245,12 @@ export {
|
|
|
237
245
|
queryQuantitySamples,
|
|
238
246
|
queryQuantitySamplesWithAnchor,
|
|
239
247
|
queryStatisticsForQuantity,
|
|
248
|
+
/**
|
|
249
|
+
* @deprecated Use queryWorkoutSamples instead
|
|
250
|
+
*/
|
|
240
251
|
queryWorkouts,
|
|
252
|
+
queryWorkoutSamples,
|
|
253
|
+
queryWorkoutSamplesWithAnchor,
|
|
241
254
|
querySources,
|
|
242
255
|
requestAuthorization,
|
|
243
256
|
deleteQuantitySample,
|
package/src/index.native.tsx
CHANGED
|
@@ -74,6 +74,12 @@ const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStat
|
|
|
74
74
|
duration: undefined,
|
|
75
75
|
})),
|
|
76
76
|
queryWorkouts = UnavailableFn(Promise.resolve([])),
|
|
77
|
+
queryWorkoutSamples = UnavailableFn(Promise.resolve([])),
|
|
78
|
+
queryWorkoutSamplesWithAnchor = UnavailableFn(Promise.resolve({
|
|
79
|
+
samples: [],
|
|
80
|
+
deletedSamples: [],
|
|
81
|
+
newAnchor: '',
|
|
82
|
+
})),
|
|
77
83
|
querySources = UnavailableFn(Promise.resolve([])),
|
|
78
84
|
requestAuthorization = UnavailableFn(Promise.resolve(false)),
|
|
79
85
|
deleteQuantitySample = UnavailableFn(Promise.resolve(false)),
|
|
@@ -96,8 +102,8 @@ const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStat
|
|
|
96
102
|
const Healthkit: typeof ReactNativeHealthkit = {
|
|
97
103
|
authorizationStatusFor,
|
|
98
104
|
availableQuantityTypes,
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
deleteQuantitySample,
|
|
106
|
+
deleteSamples,
|
|
101
107
|
disableAllBackgroundDelivery,
|
|
102
108
|
disableBackgroundDelivery,
|
|
103
109
|
enableBackgroundDelivery,
|
|
@@ -112,8 +118,10 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
112
118
|
getPreferredUnits,
|
|
113
119
|
getRequestStatusForAuthorization,
|
|
114
120
|
getWheelchairUse,
|
|
121
|
+
getWorkoutPlanById,
|
|
115
122
|
getWorkoutRoutes,
|
|
116
123
|
isHealthDataAvailable,
|
|
124
|
+
isProtectedDataAvailable,
|
|
117
125
|
queryCategorySamples,
|
|
118
126
|
queryCategorySamplesWithAnchor,
|
|
119
127
|
queryCorrelationSamples,
|
|
@@ -121,36 +129,36 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
121
129
|
queryHeartbeatSeriesSamplesWithAnchor,
|
|
122
130
|
queryQuantitySamples,
|
|
123
131
|
queryQuantitySamplesWithAnchor,
|
|
132
|
+
querySources,
|
|
124
133
|
queryStatisticsForQuantity,
|
|
125
134
|
queryWorkouts,
|
|
126
|
-
|
|
135
|
+
queryWorkoutSamples,
|
|
136
|
+
queryWorkoutSamplesWithAnchor,
|
|
127
137
|
requestAuthorization,
|
|
128
|
-
deleteQuantitySample,
|
|
129
|
-
deleteSamples,
|
|
130
|
-
getWorkoutPlanById,
|
|
131
138
|
saveCategorySample,
|
|
132
139
|
saveCorrelationSample,
|
|
133
140
|
saveQuantitySample,
|
|
134
|
-
saveWorkoutSample,
|
|
135
141
|
saveWorkoutRoute,
|
|
142
|
+
saveWorkoutSample,
|
|
136
143
|
subscribeToChanges,
|
|
144
|
+
useHealthkitAuthorization,
|
|
145
|
+
useIsHealthDataAvailable,
|
|
137
146
|
useMostRecentCategorySample,
|
|
138
147
|
useMostRecentQuantitySample,
|
|
139
148
|
useMostRecentWorkout,
|
|
149
|
+
useSources,
|
|
150
|
+
useStatisticsForQuantity,
|
|
140
151
|
useSubscribeToChanges,
|
|
141
|
-
useHealthkitAuthorization,
|
|
142
|
-
useIsHealthDataAvailable,
|
|
143
|
-
isProtectedDataAvailable,
|
|
144
152
|
}
|
|
145
153
|
|
|
146
154
|
export {
|
|
147
155
|
authorizationStatusFor,
|
|
148
156
|
availableQuantityTypes,
|
|
157
|
+
deleteQuantitySample,
|
|
158
|
+
deleteSamples,
|
|
149
159
|
disableAllBackgroundDelivery,
|
|
150
160
|
disableBackgroundDelivery,
|
|
151
161
|
enableBackgroundDelivery,
|
|
152
|
-
useSources,
|
|
153
|
-
useStatisticsForQuantity,
|
|
154
162
|
getBiologicalSex,
|
|
155
163
|
getBloodType,
|
|
156
164
|
getDateOfBirth,
|
|
@@ -162,8 +170,10 @@ export {
|
|
|
162
170
|
getPreferredUnits,
|
|
163
171
|
getRequestStatusForAuthorization,
|
|
164
172
|
getWheelchairUse,
|
|
173
|
+
getWorkoutPlanById,
|
|
165
174
|
getWorkoutRoutes,
|
|
166
175
|
isHealthDataAvailable,
|
|
176
|
+
isProtectedDataAvailable,
|
|
167
177
|
queryCategorySamples,
|
|
168
178
|
queryCategorySamplesWithAnchor,
|
|
169
179
|
queryCorrelationSamples,
|
|
@@ -171,26 +181,26 @@ export {
|
|
|
171
181
|
queryHeartbeatSeriesSamplesWithAnchor,
|
|
172
182
|
queryQuantitySamples,
|
|
173
183
|
queryQuantitySamplesWithAnchor,
|
|
184
|
+
querySources,
|
|
174
185
|
queryStatisticsForQuantity,
|
|
175
186
|
queryWorkouts,
|
|
176
|
-
|
|
187
|
+
queryWorkoutSamples,
|
|
188
|
+
queryWorkoutSamplesWithAnchor,
|
|
177
189
|
requestAuthorization,
|
|
178
|
-
deleteQuantitySample,
|
|
179
|
-
deleteSamples,
|
|
180
|
-
getWorkoutPlanById,
|
|
181
190
|
saveCategorySample,
|
|
182
191
|
saveCorrelationSample,
|
|
183
192
|
saveQuantitySample,
|
|
184
|
-
saveWorkoutSample,
|
|
185
193
|
saveWorkoutRoute,
|
|
194
|
+
saveWorkoutSample,
|
|
186
195
|
subscribeToChanges,
|
|
196
|
+
useHealthkitAuthorization,
|
|
197
|
+
useIsHealthDataAvailable,
|
|
187
198
|
useMostRecentCategorySample,
|
|
188
199
|
useMostRecentQuantitySample,
|
|
189
200
|
useMostRecentWorkout,
|
|
201
|
+
useSources,
|
|
202
|
+
useStatisticsForQuantity,
|
|
190
203
|
useSubscribeToChanges,
|
|
191
|
-
useHealthkitAuthorization,
|
|
192
|
-
useIsHealthDataAvailable,
|
|
193
|
-
isProtectedDataAvailable,
|
|
194
204
|
}
|
|
195
205
|
|
|
196
206
|
export * from './types'
|
package/src/native-types.ts
CHANGED
|
@@ -1923,6 +1923,11 @@ export type DeletedCategorySampleRaw<T extends HKCategoryTypeIdentifier> = {
|
|
|
1923
1923
|
readonly metadata: MetadataMapperForCategoryIdentifier<T>;
|
|
1924
1924
|
};
|
|
1925
1925
|
|
|
1926
|
+
export type DeletedWorkoutSampleRaw = {
|
|
1927
|
+
readonly uuid: string;
|
|
1928
|
+
readonly metadata: HKWorkoutMetadata;
|
|
1929
|
+
};
|
|
1930
|
+
|
|
1926
1931
|
export type DeletedHeartbeatSeriesSampleRaw = {
|
|
1927
1932
|
readonly uuid: string;
|
|
1928
1933
|
readonly metadata: HKHeartbeatSeriesSampleMetadata;
|
|
@@ -1994,6 +1999,15 @@ export type WorkoutRoute = {
|
|
|
1994
1999
|
readonly HKMetadataKeySyncVersion?: number;
|
|
1995
2000
|
};
|
|
1996
2001
|
|
|
2002
|
+
type QueryWorkoutSamplesWithAnchorResponseRaw<
|
|
2003
|
+
TEnergy extends EnergyUnit,
|
|
2004
|
+
TDistance extends LengthUnit
|
|
2005
|
+
> = {
|
|
2006
|
+
readonly samples: readonly HKWorkoutRaw<TEnergy, TDistance>[],
|
|
2007
|
+
readonly deletedSamples: readonly DeletedWorkoutSampleRaw[],
|
|
2008
|
+
readonly newAnchor: string
|
|
2009
|
+
}
|
|
2010
|
+
|
|
1997
2011
|
type ReactNativeHealthkitTypeNative = {
|
|
1998
2012
|
/**
|
|
1999
2013
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
|
|
@@ -2152,7 +2166,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
2152
2166
|
to: string,
|
|
2153
2167
|
limit: number,
|
|
2154
2168
|
anchor: string
|
|
2155
|
-
) => Promise<
|
|
2169
|
+
) => Promise<QueryWorkoutSamplesWithAnchorResponseRaw<TEnergy, TDistance>>;
|
|
2156
2170
|
readonly queryQuantitySamplesWithAnchor: <
|
|
2157
2171
|
TIdentifier extends HKQuantityTypeIdentifier,
|
|
2158
2172
|
TUnit extends UnitForIdentifier<TIdentifier>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import deserializeCategorySample from './deserializeCategorySample'
|
|
2
2
|
import prepareOptions from './prepareOptions'
|
|
3
3
|
import Native from '../native-types'
|
|
4
4
|
|
|
@@ -30,7 +30,7 @@ const queryCategorySamplesWithAnchor: QueryCategorySamplesWithAnchorFn = async (
|
|
|
30
30
|
)
|
|
31
31
|
|
|
32
32
|
return {
|
|
33
|
-
samples: raw.samples.map(
|
|
33
|
+
samples: raw.samples.map(deserializeCategorySample),
|
|
34
34
|
deletedSamples: raw.deletedSamples,
|
|
35
35
|
newAnchor: raw.newAnchor,
|
|
36
36
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import deserializeWorkout from './deserializeWorkout'
|
|
2
|
+
import getPreferredUnitsTyped from './getPreferredUnitsTyped'
|
|
3
|
+
import prepareOptions from './prepareOptions'
|
|
4
|
+
import Native from '../native-types'
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
EnergyUnit, LengthUnit,
|
|
8
|
+
} from '../native-types'
|
|
9
|
+
import type {
|
|
10
|
+
DeletedWorkoutSampleRaw, HKWorkout, QueryWorkoutsOptions,
|
|
11
|
+
} from '../types'
|
|
12
|
+
|
|
13
|
+
export type QueryWorkoutSamplesWithAnchorResponse<
|
|
14
|
+
TEnergy extends EnergyUnit,
|
|
15
|
+
TDistance extends LengthUnit
|
|
16
|
+
> = {
|
|
17
|
+
readonly samples: readonly HKWorkout<TEnergy, TDistance>[],
|
|
18
|
+
readonly deletedSamples: readonly DeletedWorkoutSampleRaw[],
|
|
19
|
+
readonly newAnchor: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function queryCategorySamplesWithAnchor<
|
|
23
|
+
TEnergy extends EnergyUnit,
|
|
24
|
+
TDistance extends LengthUnit
|
|
25
|
+
>(
|
|
26
|
+
options: Omit<QueryWorkoutsOptions<TEnergy, TDistance>, 'ascending'>,
|
|
27
|
+
): Promise<QueryWorkoutSamplesWithAnchorResponse<TEnergy, TDistance>> {
|
|
28
|
+
const opts = prepareOptions(options)
|
|
29
|
+
const { energyUnit, distanceUnit } = await getPreferredUnitsTyped(options)
|
|
30
|
+
const raw = await Native.queryWorkoutSamplesWithAnchor(
|
|
31
|
+
energyUnit,
|
|
32
|
+
distanceUnit,
|
|
33
|
+
opts.from,
|
|
34
|
+
opts.to,
|
|
35
|
+
opts.limit,
|
|
36
|
+
opts.anchor,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
samples: raw.samples.map(deserializeWorkout),
|
|
41
|
+
deletedSamples: raw.deletedSamples,
|
|
42
|
+
newAnchor: raw.newAnchor,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default queryCategorySamplesWithAnchor
|