@kingstinct/react-native-healthkit 9.0.4 → 9.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/app.plugin.js +88 -0
  2. package/app.plugin.ts +67 -0
  3. package/ios/CoreModule.swift +83 -85
  4. package/ios/Helpers.swift +0 -21
  5. package/lib/commonjs/index.ios.js +15 -0
  6. package/lib/commonjs/index.js +15 -0
  7. package/lib/commonjs/types/index.js +37 -0
  8. package/lib/module/index.ios.js +1 -0
  9. package/lib/module/index.js +1 -0
  10. package/lib/module/types/index.js +21 -0
  11. package/lib/typescript/hooks/useSubscribeToChanges.d.ts +1 -1
  12. package/lib/typescript/index.d.ts +41 -46
  13. package/lib/typescript/index.ios.d.ts +79 -78
  14. package/lib/typescript/specs/CoreModule.nitro.d.ts +1 -1
  15. package/lib/typescript/types/QuantityType.d.ts +2 -2
  16. package/lib/typescript/types/QueryOptions.d.ts +11 -3
  17. package/lib/typescript/types/index.d.ts +21 -0
  18. package/lib/typescript/utils/getCategorySampleById.d.ts +1 -1
  19. package/lib/typescript/utils/getMostRecentCategorySample.d.ts +1 -1
  20. package/lib/typescript/utils/getMostRecentQuantitySample.d.ts +1 -1
  21. package/lib/typescript/utils/getQuantitySampleById.d.ts +1 -1
  22. package/lib/typescript/utils/subscribeToChanges.d.ts +1 -1
  23. package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +0 -9
  24. package/nitrogen/generated/ios/swift/StatisticsQueryOptions.swift +33 -19
  25. package/nitrogen/generated/shared/c++/StatisticsQueryOptions.hpp +11 -5
  26. package/package.json +15 -1
  27. package/src/hooks/useSubscribeToChanges.ts +1 -1
  28. package/src/index.ios.ts +2 -0
  29. package/src/index.ts +2 -13
  30. package/src/specs/CoreModule.nitro.ts +1 -1
  31. package/src/types/QuantityType.ts +2 -2
  32. package/src/types/QueryOptions.ts +25 -4
  33. package/src/types/index.ts +21 -0
  34. package/src/utils/subscribeToChanges.ts +1 -1
  35. package/nitrogen/generated/ios/swift/Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout.swift +0 -19
  36. /package/lib/commonjs/types/{Subscriptons.js → Subscriptions.js} +0 -0
  37. /package/lib/module/types/{Subscriptons.js → Subscriptions.js} +0 -0
  38. /package/lib/typescript/types/{Subscriptons.d.ts → Subscriptions.d.ts} +0 -0
  39. /package/src/types/{Subscriptons.ts → Subscriptions.ts} +0 -0
package/app.plugin.js ADDED
@@ -0,0 +1,88 @@
1
+ const {
2
+ withPlugins,
3
+ createRunOncePlugin,
4
+ withEntitlementsPlist,
5
+ withInfoPlist,
6
+ } = require('@expo/config-plugins')
7
+
8
+ /**
9
+ * @typedef ConfigPlugin
10
+ * @type {import('@expo/config-plugins').ConfigPlugin<T>}
11
+ * @template T = void
12
+ */
13
+
14
+ /**
15
+ * @typedef InfoPlistConfig
16
+ * @type {{
17
+ * NSHealthShareUsageDescription?: string | boolean,
18
+ * NSHealthUpdateUsageDescription?: string | boolean
19
+ * }}
20
+ */
21
+
22
+ /**
23
+ * @typedef AppPluginConfig
24
+ * @type {InfoPlistConfig & { background?: boolean }}
25
+ */
26
+
27
+ /**
28
+ * @type {ConfigPlugin<{background: boolean}>}
29
+ */
30
+ const withEntitlementsPlugin = (
31
+ config,
32
+ /**
33
+ * @type {{background: boolean} | undefined}
34
+ * */
35
+ props,
36
+ ) =>
37
+ withEntitlementsPlist(config, (config) => {
38
+ config.modResults['com.apple.developer.healthkit'] = true
39
+
40
+ // background is enabled by default, but possible to opt-out from
41
+ // (haven't seen any drawbacks from having it enabled)
42
+ if (props?.background !== false) {
43
+ config.modResults['com.apple.developer.healthkit.background-delivery'] =
44
+ true
45
+ }
46
+
47
+ return config
48
+ })
49
+
50
+ /**
51
+ * @type {ConfigPlugin<InfoPlistConfig>}
52
+ */
53
+ const withInfoPlistPlugin = (
54
+ config,
55
+ /**
56
+ * @type {{NSHealthShareUsageDescription: string | true, NSHealthUpdateUsageDescription: string | true} | undefined}
57
+ * */
58
+ props,
59
+ ) =>
60
+ withInfoPlist(config, (config) => {
61
+ config.modResults.NSHealthShareUsageDescription =
62
+ typeof props.NSHealthShareUsageDescription === 'string'
63
+ ? props.NSHealthShareUsageDescription
64
+ : `${config.name} wants to read your health data`
65
+
66
+ config.modResults.NSHealthUpdateUsageDescription =
67
+ typeof props.NSHealthUpdateUsageDescription === 'string'
68
+ ? props.NSHealthUpdateUsageDescription
69
+ : `${config.name} wants to update your health data`
70
+
71
+ return config
72
+ })
73
+
74
+ const pkg = require('./package.json')
75
+
76
+ /**
77
+ * @type {ConfigPlugin<AppPluginConfig>}
78
+ */
79
+ const healthkitAppPlugin = (config, props) =>
80
+ withPlugins(config, [
81
+ [withEntitlementsPlugin, props],
82
+ [withInfoPlistPlugin, props],
83
+ ])
84
+
85
+ /**
86
+ * @type {ConfigPlugin<AppPluginConfig>}
87
+ */
88
+ module.exports = createRunOncePlugin(healthkitAppPlugin, pkg.name, pkg.version)
package/app.plugin.ts ADDED
@@ -0,0 +1,67 @@
1
+ import {
2
+ type ConfigPlugin,
3
+ createRunOncePlugin,
4
+ withEntitlementsPlist,
5
+ withInfoPlist,
6
+ withPlugins,
7
+ } from '@expo/config-plugins'
8
+
9
+ import pkg from './package.json'
10
+
11
+ // please note that the BackgroundConfig currently doesn't actually enable background delivery for any types, but you
12
+ // can set it to false if you don't want the entitlement
13
+ type BackgroundConfig = boolean
14
+
15
+ type InfoPlistConfig = {
16
+ NSHealthShareUsageDescription?: string | true
17
+ NSHealthUpdateUsageDescription?: string | true
18
+ }
19
+
20
+ type AppPluginConfig = InfoPlistConfig & {
21
+ background?: BackgroundConfig
22
+ }
23
+
24
+ const withEntitlementsPlugin: ConfigPlugin<{
25
+ background?: BackgroundConfig
26
+ }> = (config, props) => {
27
+ return withEntitlementsPlist(config, (configPlist) => {
28
+ configPlist.modResults['com.apple.developer.healthkit'] = true
29
+
30
+ // background is enabled by default, but possible to opt-out from
31
+ // (haven't seen any drawbacks from having it enabled)
32
+ if (props?.background !== false) {
33
+ configPlist.modResults[
34
+ 'com.apple.developer.healthkit.background-delivery'
35
+ ] = true
36
+ }
37
+
38
+ return configPlist
39
+ })
40
+ }
41
+
42
+ const withInfoPlistPlugin: ConfigPlugin<InfoPlistConfig> = (config, props) => {
43
+ return withInfoPlist(config, (configPlist) => {
44
+ configPlist.modResults.NSHealthShareUsageDescription =
45
+ typeof props.NSHealthShareUsageDescription === 'string'
46
+ ? props.NSHealthShareUsageDescription
47
+ : `${config.name ?? pkg.name} wants to read your health data`
48
+
49
+ // Add description if it's not undefined and not explicitly false
50
+
51
+ configPlist.modResults.NSHealthUpdateUsageDescription =
52
+ typeof props.NSHealthUpdateUsageDescription === 'string'
53
+ ? props.NSHealthUpdateUsageDescription
54
+ : `${config.name ?? pkg.name} wants to update your health data`
55
+
56
+ return configPlist
57
+ })
58
+ }
59
+
60
+ const healthkitAppPlugin: ConfigPlugin<AppPluginConfig> = (config, props) => {
61
+ return withPlugins(config, [
62
+ [withEntitlementsPlugin, props],
63
+ [withInfoPlistPlugin, props],
64
+ ])
65
+ }
66
+
67
+ export default createRunOncePlugin(healthkitAppPlugin, pkg.name, pkg.version)
@@ -9,102 +9,99 @@ import NitroModules
9
9
 
10
10
  var store = HKHealthStore.init()
11
11
 
12
- var quantityTypeUnitCache = Dictionary<HKQuantityType, HKUnit>()
12
+ var quantityTypeUnitCache = [HKQuantityType: HKUnit]()
13
13
 
14
14
  func getUnitToUse(unitOverride: String?, quantityType: HKQuantityType) async throws -> HKUnit {
15
15
  if let unitOverride = unitOverride {
16
16
  let unit = HKUnit(from: unitOverride)
17
-
18
- if(!quantityType.is(compatibleWith: unit)){
17
+
18
+ if !quantityType.is(compatibleWith: unit) {
19
19
  throw RuntimeError.error(withMessage: "[react-native-healthkit] Unit \(unitOverride) is incompatible with \(quantityType.identifier)")
20
20
  }
21
-
21
+
22
22
  return unit
23
23
  }
24
-
24
+
25
25
  if let preferredUnit = try await getPreferredUnitsInternal(quantityTypes: [quantityType]).first?.value {
26
26
  return preferredUnit
27
27
  }
28
-
28
+
29
29
  throw RuntimeError.error(withMessage: "[react-native-healthkit] Must specify a unit for \(quantityType.identifier)")
30
30
  }
31
31
 
32
32
  func getPreferredUnitsInternal(quantityTypes: [HKQuantityType], forceUpdate: Bool? = false) async throws -> [HKQuantityType: HKUnit] {
33
-
34
- if(forceUpdate != true){
35
- let itemsInCache = quantityTypeUnitCache.filter { (quantityType: HKQuantityType, unit: HKUnit) in
33
+
34
+ if forceUpdate != true {
35
+ let itemsInCache = quantityTypeUnitCache.filter { (quantityType: HKQuantityType, _: HKUnit) in
36
36
  return quantityTypes.contains(where: { $0 == quantityType })
37
37
  }
38
- if(itemsInCache.count == quantityTypes.count){
38
+ if itemsInCache.count == quantityTypes.count {
39
39
  return itemsInCache
40
40
  }
41
41
  }
42
-
43
-
42
+
44
43
  return try await withCheckedThrowingContinuation { continuation in
45
44
  store.preferredUnits(for: Set(quantityTypes)) {
46
45
  (typePerUnits: [HKQuantityType: HKUnit], error: Error?) in
47
46
  if let error = error {
48
47
  return continuation.resume(throwing: error)
49
48
  }
50
-
49
+
51
50
  typePerUnits.forEach { (type: HKQuantityType, unit: HKUnit) in
52
51
  quantityTypeUnitCache.updateValue(unit, forKey: type)
53
52
  }
54
-
53
+
55
54
  return continuation.resume(returning: typePerUnits)
56
55
  }
57
56
  }
58
57
  }
59
58
 
60
- class CoreModule : HybridCoreModuleSpec {
61
- func areObjectTypesAvailable(objectTypeIdentifiers: [ObjectTypeIdentifier]) -> Dictionary<String, Bool> {
62
- var dict = Dictionary<String, Bool>()
63
-
59
+ class CoreModule: HybridCoreModuleSpec {
60
+ func areObjectTypesAvailable(objectTypeIdentifiers: [ObjectTypeIdentifier]) -> [String: Bool] {
61
+ var dict = [String: Bool]()
62
+
64
63
  for objectTypeIdentifier in objectTypeIdentifiers {
65
64
  dict[objectTypeIdentifier.stringValue] = isObjectTypeAvailable(objectTypeIdentifier: objectTypeIdentifier)
66
65
  }
67
-
66
+
68
67
  return dict
69
68
  }
70
-
71
- func areObjectTypesAvailableAsync(objectTypeIdentifiers: [ObjectTypeIdentifier]) -> Promise<Dictionary<String, Bool>> {
72
- return Promise.resolved(withResult: areObjectTypesAvailable(objectTypeIdentifiers: objectTypeIdentifiers))
69
+
70
+ func areObjectTypesAvailableAsync(objectTypeIdentifiers: [ObjectTypeIdentifier]) -> Promise<[String: Bool]> {
71
+ return Promise.resolved(withResult: areObjectTypesAvailable(objectTypeIdentifiers: objectTypeIdentifiers))
73
72
  }
74
-
75
-
76
-
73
+
77
74
  func isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier) -> Bool {
78
75
  do {
79
- let _ = try objectTypeFrom(objectTypeIdentifier: objectTypeIdentifier)
76
+ _ = try objectTypeFrom(objectTypeIdentifier: objectTypeIdentifier)
80
77
  return true
81
78
  } catch {
82
79
  return false
83
80
  }
84
81
  }
85
-
82
+
86
83
  func isObjectTypeAvailableAsync(objectTypeIdentifier: ObjectTypeIdentifier) -> Promise<Bool> {
87
84
  return Promise.resolved(withResult: isObjectTypeAvailable(objectTypeIdentifier: objectTypeIdentifier))
88
85
  }
89
-
86
+
90
87
  func authorizationStatusFor(
91
88
  type: ObjectTypeIdentifier
92
89
  ) throws -> AuthorizationStatus {
93
90
  let objectType = try objectTypeFrom(objectTypeIdentifier: type)
94
-
91
+
95
92
  let authStatus = store.authorizationStatus(for: objectType)
96
-
97
- if let authStatus = AuthorizationStatus(rawValue: Int32(authStatus.rawValue)){
93
+
94
+ if let authStatus = AuthorizationStatus(rawValue: Int32(authStatus.rawValue)) {
98
95
  return authStatus
99
96
  }
100
-
97
+
101
98
  throw RuntimeError.error(withMessage: "[react-native-healthkit] got unrecognized AuthorizationStatus with value \(authStatus.rawValue)")
102
99
  }
103
-
100
+
104
101
  func getRequestStatusForAuthorization(toShare: [SampleTypeIdentifierWriteable], toRead: [ObjectTypeIdentifier]) throws -> Promise<AuthorizationRequestStatus> {
105
102
  let toShare = sampleTypesFromArray(typeIdentifiersWriteable: toShare)
106
103
  let toRead = objectTypesFromArray(typeIdentifiers: toRead)
107
-
104
+
108
105
  return Promise.async {
109
106
  try await withCheckedThrowingContinuation { continuation in
110
107
  store.getRequestStatusForAuthorization(toShare: toShare, read: toRead) { status, error in
@@ -116,17 +113,17 @@ class CoreModule : HybridCoreModuleSpec {
116
113
  } else {
117
114
  continuation.resume(throwing: RuntimeError.error(withMessage: "Unrecognized authStatus returned: \(status.rawValue)"))
118
115
  }
119
-
116
+
120
117
  }
121
118
  }
122
119
  }
123
120
  }
124
121
  }
125
-
122
+
126
123
  func requestAuthorization(toShare: [SampleTypeIdentifierWriteable], toRead: [ObjectTypeIdentifier]) throws -> Promise<Bool> {
127
124
  let share = sampleTypesFromArray(typeIdentifiersWriteable: toShare)
128
125
  let toRead = objectTypesFromArray(typeIdentifiers: toRead)
129
-
126
+
130
127
  return Promise.async {
131
128
  try await withCheckedThrowingContinuation { continuation in
132
129
  store.requestAuthorization(toShare: share, read: toRead) { status, error in
@@ -139,10 +136,10 @@ class CoreModule : HybridCoreModuleSpec {
139
136
  }
140
137
  }
141
138
  }
142
-
139
+
143
140
  func querySources(identifier: SampleTypeIdentifier) throws -> Promise<[HybridSourceProxySpec]> {
144
141
  let sampleType = try sampleTypeFrom(sampleTypeIdentifier: identifier)
145
-
142
+
146
143
  return Promise.async {
147
144
  try await withCheckedThrowingContinuation { continuation in
148
145
  let query = HKSourceQuery(
@@ -153,26 +150,26 @@ class CoreModule : HybridCoreModuleSpec {
153
150
  continuation.resume(throwing: error)
154
151
  return
155
152
  }
156
-
153
+
157
154
  guard let sources = sources else {
158
155
  return continuation.resume(throwing: RuntimeError.error(withMessage: "Empty response for sample type \(identifier.stringValue)"))
159
156
  }
160
-
157
+
161
158
  let serializedSources = sources.map { source -> SourceProxy in
162
-
159
+
163
160
  return SourceProxy(
164
161
  source: source
165
162
  )
166
163
  }
167
-
164
+
168
165
  continuation.resume(returning: serializedSources)
169
166
  }
170
-
167
+
171
168
  store.execute(query)
172
169
  }
173
170
  }
174
171
  }
175
-
172
+
176
173
  func enableBackgroundDelivery(typeIdentifier: ObjectTypeIdentifier, updateFrequency: UpdateFrequency) throws -> Promise<Bool> {
177
174
  if let frequency = HKUpdateFrequency(rawValue: Int(updateFrequency.rawValue)) {
178
175
  let type = try objectTypeFrom(objectTypeIdentifier: typeIdentifier)
@@ -193,7 +190,7 @@ class CoreModule : HybridCoreModuleSpec {
193
190
  throw RuntimeError.error(withMessage: "Invalid update frequency value: \(updateFrequency)")
194
191
  }
195
192
  }
196
-
193
+
197
194
  func disableBackgroundDelivery(
198
195
  typeIdentifier: ObjectTypeIdentifier
199
196
  ) throws -> Promise<Bool> {
@@ -211,7 +208,7 @@ class CoreModule : HybridCoreModuleSpec {
211
208
  }
212
209
  }
213
210
  }
214
-
211
+
215
212
  func disableAllBackgroundDelivery() throws -> Promise<Bool> {
216
213
  return Promise.async {
217
214
  try await withCheckedThrowingContinuation { continuation in
@@ -224,64 +221,65 @@ class CoreModule : HybridCoreModuleSpec {
224
221
  }
225
222
  }
226
223
  }
227
-
224
+
228
225
  func unsubscribeQueryAsync(queryId: String) throws -> Promise<Bool> {
229
226
  let result = try self.unsubscribeQuery(queryId: queryId)
230
-
227
+
231
228
  return Promise.resolved(withResult: result)
232
229
  }
233
-
230
+
234
231
  func isHealthDataAvailableAsync() -> Promise<Bool> {
235
232
  return Promise.resolved(withResult: HKHealthStore.isHealthDataAvailable())
236
233
  }
237
-
234
+
238
235
  func isProtectedDataAvailableAsync() -> Promise<Bool> {
239
236
  return Promise.resolved(withResult: UIApplication.shared.isProtectedDataAvailable)
240
237
  }
241
-
238
+
242
239
  func isHealthDataAvailable() throws -> Bool {
243
240
  return HKHealthStore.isHealthDataAvailable()
244
241
  }
245
-
242
+
246
243
  func isProtectedDataAvailable() throws -> Bool {
247
244
  return UIApplication.shared.isProtectedDataAvailable
248
245
  }
249
-
246
+
250
247
  func getPreferredUnits(identifiers: [QuantityTypeIdentifier], forceUpdate: Bool?) throws -> Promise<[IdentifierWithUnit]> {
251
248
  return Promise.async {
252
-
249
+
253
250
  let quantityTypes = identifiers.compactMap { identifier in
254
251
  do {
255
252
  let quantityType = try initializeQuantityType(identifier.stringValue)
253
+
256
254
  return quantityType
257
255
  } catch {
258
256
  print(error.localizedDescription)
259
257
  return nil
260
258
  }
261
259
  }
262
-
260
+
263
261
  let typePerUnits = try await getPreferredUnitsInternal(quantityTypes: quantityTypes, forceUpdate: forceUpdate)
264
-
262
+
265
263
  let dic = typePerUnits.map { typePerUnit in
266
264
  return IdentifierWithUnit(
267
265
  typeIdentifier: typePerUnit.key.identifier,
268
266
  unit: typePerUnit.value.unitString
269
267
  )
270
268
  }
271
-
269
+
272
270
  return dic
273
271
  }
274
272
  }
275
-
273
+
276
274
  var _runningQueries: [String: HKQuery] = [:]
277
-
275
+
278
276
  func deleteObjects(objectTypeIdentifier: ObjectTypeIdentifier, filter: FilterForSamples) throws -> Promise<Double> {
279
277
  let predicate = try createPredicateForSamples(filter: filter)
280
278
  let of = try objectTypeFrom(objectTypeIdentifier: objectTypeIdentifier)
281
-
279
+
282
280
  return Promise.async {
283
281
  return try await withCheckedThrowingContinuation { continuation in
284
- store.deleteObjects(of: of, predicate: predicate) { (success, count, error) in
282
+ store.deleteObjects(of: of, predicate: predicate) { (_, count, error) in
285
283
  if let error = error {
286
284
  continuation.resume(throwing: error)
287
285
  } else {
@@ -291,21 +289,21 @@ class CoreModule : HybridCoreModuleSpec {
291
289
  }
292
290
  }
293
291
  }
294
-
292
+
295
293
  func subscribeToObserverQuery(
296
294
  typeIdentifier: SampleTypeIdentifier,
297
295
  callback: @escaping (OnChangeCallbackArgs) -> Void
298
296
  ) throws -> String {
299
297
  let sampleType = try sampleTypeFrom(sampleTypeIdentifier: typeIdentifier)
300
-
298
+
301
299
  let predicate = HKQuery.predicateForSamples(
302
300
  withStart: Date.init(),
303
301
  end: nil,
304
302
  options: HKQueryOptions.strictStartDate
305
303
  )
306
-
304
+
307
305
  let queryId = UUID().uuidString
308
-
306
+
309
307
  func responder(
310
308
  query: HKObserverQuery,
311
309
  handler: @escaping HKObserverQueryCompletionHandler,
@@ -316,42 +314,42 @@ class CoreModule : HybridCoreModuleSpec {
316
314
  handler()
317
315
  }
318
316
  }
319
-
317
+
320
318
  let query = HKObserverQuery(
321
319
  sampleType: sampleType,
322
320
  predicate: predicate
323
321
  ) {
324
322
  (query: HKObserverQuery, handler: @escaping HKObserverQueryCompletionHandler, error: Error?)
325
323
  in
326
-
324
+
327
325
  return responder(query: query, handler: handler, error: error)
328
-
326
+
329
327
  }
330
-
328
+
331
329
  store.execute(query)
332
-
330
+
333
331
  self._runningQueries.updateValue(query, forKey: queryId)
334
-
335
- //resolve(queryId)
336
-
332
+
333
+ // resolve(queryId)
334
+
337
335
  return queryId
338
336
  }
339
-
337
+
340
338
  func unsubscribeQuery(queryId: String) throws -> Bool {
341
339
  guard let query = self._runningQueries[queryId] else {
342
340
  throw RuntimeError.error(withMessage: "Query with id \(queryId) not found")
343
341
  }
344
-
342
+
345
343
  store.stop(query)
346
-
344
+
347
345
  self._runningQueries.removeValue(forKey: queryId)
348
-
346
+
349
347
  return true
350
348
  }
351
-
349
+
352
350
  func unsubscribeQueriesAsync(queryIds: [String]) throws -> Promise<Double> {
353
351
  let successCount = self.unsubscribeQueries(queryIds: queryIds)
354
-
352
+
355
353
  return Promise.resolved(withResult: successCount)
356
354
  }
357
355
 
@@ -359,17 +357,17 @@ class CoreModule : HybridCoreModuleSpec {
359
357
  let successCounts = queryIds.map { queryId in
360
358
  if let query = self._runningQueries[queryId] {
361
359
  store.stop(query)
362
-
360
+
363
361
  self._runningQueries.removeValue(forKey: queryId)
364
-
362
+
365
363
  return true
366
364
  }
367
-
365
+
368
366
  print("Query with id \(queryId) not found, skipping unsubscribe")
369
-
367
+
370
368
  return false
371
369
  }
372
-
370
+
373
371
  return Double(successCounts.filter { $0 }.count)
374
372
  }
375
373
 
package/ios/Helpers.swift CHANGED
@@ -136,27 +136,6 @@ func createUUIDsPredicate(uuidsWrapper: PredicateWithUUIDs) -> NSPredicate {
136
136
  return HKQuery.predicateForObjects(with: Set(uuids))
137
137
  }
138
138
 
139
- func createPredicate(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout?) throws -> NSPredicate? {
140
- if let filter = filter {
141
- switch filter {
142
- case .first(let uuidWrapper):
143
- return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
144
- case .second(let uuidsWrapper):
145
- return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
146
- case .third(let metadataKey):
147
- return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
148
- case .fourth(let dateFilter):
149
- return createDatePredicate(dateFilter: dateFilter)
150
- case .fifth(let w):
151
- if let w = w.workout as? WorkoutProxy {
152
- return w.workoutPredicate
153
- }
154
- throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
155
- }
156
- }
157
- return nil
158
- }
159
-
160
139
  func createPredicate(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_FilterForSamplesAnd_FilterForSamplesOr?) throws -> NSPredicate? {
161
140
  if let filter = filter {
162
141
  switch filter {
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
18
  };
@@ -31,6 +45,7 @@ const getMostRecentWorkout_1 = __importDefault(require("./utils/getMostRecentWor
31
45
  exports.getMostRecentWorkout = getMostRecentWorkout_1.default;
32
46
  const getPreferredUnit_1 = __importDefault(require("./utils/getPreferredUnit"));
33
47
  exports.getPreferredUnit = getPreferredUnit_1.default;
48
+ __exportStar(require("./types"), exports);
34
49
  const currentMajorVersionIOS = react_native_1.Platform.OS === 'ios' ? Number.parseInt(react_native_1.Platform.Version, 10) : 0;
35
50
  // Named exports - all functions bound to their respective modules
36
51
  exports.authorizationStatusFor = modules_1.Core.authorizationStatusFor.bind(modules_1.Core);
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.getBiologicalSexAsync = exports.useStatisticsForQuantity = exports.useSources = exports.useIsHealthDataAvailable = exports.useHealthkitAuthorization = exports.useSubscribeToChanges = exports.useMostRecentWorkout = exports.useMostRecentQuantitySample = exports.getPreferredUnit = exports.getMostRecentWorkout = exports.getMostRecentQuantitySample = exports.saveStateOfMindSample = exports.queryStateOfMindSamples = exports.startWatchApp = exports.saveWorkoutSample = exports.queryWorkoutSamplesWithAnchor = exports.queryWorkoutSamples = exports.queryHeartbeatSeriesSamplesWithAnchor = exports.queryHeartbeatSeriesSamples = exports.saveCorrelationSample = exports.queryCorrelationSamples = exports.saveCategorySample = exports.isQuantityCompatibleWithUnit = exports.saveQuantitySample = exports.queryStatisticsCollectionForQuantity = exports.queryStatisticsForQuantity = exports.queryQuantitySamplesWithAnchor = exports.queryQuantitySamples = exports.getWheelchairUse = exports.getFitzpatrickSkinType = exports.getDateOfBirth = exports.getBloodType = exports.getBiologicalSex = exports.areObjectTypesAvailableAsync = exports.areObjectTypesAvailable = exports.isObjectTypeAvailableAsync = exports.isObjectTypeAvailable = exports.isProtectedDataAvailable = exports.subscribeToChanges = exports.deleteObjects = exports.requestAuthorization = exports.querySources = exports.isHealthDataAvailableAsync = exports.isHealthDataAvailable = exports.getRequestStatusForAuthorization = exports.getPreferredUnits = exports.enableBackgroundDelivery = exports.disableBackgroundDelivery = exports.disableAllBackgroundDelivery = exports.authorizationStatusFor = void 0;
4
18
  exports.unsubscribeQueries = exports.getWheelchairUseAsync = exports.getFitzpatrickSkinTypeAsync = exports.getDateOfBirthAsync = exports.getBloodTypeAsync = void 0;
@@ -9,6 +23,7 @@ exports.useMostRecentCategorySample = useMostRecentCategorySample;
9
23
  const react_native_1 = require("react-native");
10
24
  const Auth_1 = require("./types/Auth");
11
25
  const Characteristics_1 = require("./types/Characteristics");
26
+ __exportStar(require("./types"), exports);
12
27
  const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${react_native_1.Platform.OS}" not supported. HealthKit is only available on iOS.`;
13
28
  let hasWarned = false;
14
29
  // @ts-ignore
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Auth"), exports);
18
+ __exportStar(require("./Background"), exports);
19
+ __exportStar(require("./CategoryType"), exports);
20
+ __exportStar(require("./CategoryTypeIdentifier"), exports);
21
+ __exportStar(require("./Characteristics"), exports);
22
+ __exportStar(require("./Constants"), exports);
23
+ __exportStar(require("./CorrelationType"), exports);
24
+ __exportStar(require("./Device"), exports);
25
+ __exportStar(require("./HeartbeatSeries"), exports);
26
+ __exportStar(require("./QuantitySample"), exports);
27
+ __exportStar(require("./QuantityType"), exports);
28
+ __exportStar(require("./QuantityTypeIdentifier"), exports);
29
+ __exportStar(require("./QueryOptions"), exports);
30
+ __exportStar(require("./Shared"), exports);
31
+ __exportStar(require("./Source"), exports);
32
+ __exportStar(require("./StateOfMind"), exports);
33
+ __exportStar(require("./Subscriptions"), exports);
34
+ __exportStar(require("./Units"), exports);
35
+ __exportStar(require("./WeatherCondition"), exports);
36
+ __exportStar(require("./WorkoutKit"), exports);
37
+ __exportStar(require("./Workouts"), exports);