react-native-spike-sdk 4.4.13 → 4.5.23-beta.1
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/android/build.gradle +3 -1
- package/android/src/main/java/com/spikesdk/SpikeSdkModule.kt +96 -1
- package/ios/SpikeSdk.m +19 -0
- package/ios/SpikeSdk.swift +123 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/v3/RecordConfig.js +16 -0
- package/lib/commonjs/v3/RecordConfig.js.map +1 -0
- package/lib/commonjs/v3/SpikeRNConnectionAPIv3.js +113 -3
- package/lib/commonjs/v3/SpikeRNConnectionAPIv3.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/v3/RecordConfig.js +11 -0
- package/lib/module/v3/RecordConfig.js.map +1 -0
- package/lib/module/v3/SpikeRNConnectionAPIv3.js +113 -3
- package/lib/module/v3/SpikeRNConnectionAPIv3.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/v3/RecordConfig.d.ts +8 -0
- package/lib/typescript/v3/RecordConfig.d.ts.map +1 -0
- package/lib/typescript/v3/SpikeRNConnectionAPIv3.d.ts +99 -1
- package/lib/typescript/v3/SpikeRNConnectionAPIv3.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/lib/typescript/version.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +3 -0
- package/src/v3/RecordConfig.ts +13 -0
- package/src/v3/SpikeRNConnectionAPIv3.ts +189 -3
- package/src/version.ts +1 -1
package/android/build.gradle
CHANGED
|
@@ -76,10 +76,12 @@ dependencies {
|
|
|
76
76
|
//noinspection GradleDynamicVersion
|
|
77
77
|
implementation "com.facebook.react:react-android:0.71.3"
|
|
78
78
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
79
|
-
implementation 'com.spikeapi.sdk:spike-sdk:4.
|
|
79
|
+
implementation 'com.spikeapi.sdk:spike-sdk:4.5.22-beta.1'
|
|
80
80
|
implementation 'androidx.core:core-ktx:1.9.0'
|
|
81
81
|
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
|
|
82
82
|
implementation 'com.google.code.gson:gson:2.10.1'
|
|
83
|
+
implementation 'com.squareup.moshi:moshi:1.15.0'
|
|
84
|
+
implementation 'com.squareup.moshi:moshi-kotlin:1.15.0'
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
if (isNewArchitectureEnabled()) {
|
|
@@ -17,6 +17,7 @@ import com.spikeapi.healthconnect.HealthConnectAvailability
|
|
|
17
17
|
import com.spikeapi.apiv3.SpikeConnectionAPIv3
|
|
18
18
|
import com.spikeapi.apiv3.datamodels.MetricType
|
|
19
19
|
import com.spikeapi.apiv3.datamodels.ActivityConfig
|
|
20
|
+
import com.spikeapi.apiv3.datamodels.RecordConfig
|
|
20
21
|
import com.spikeapi.apiv3.datamodels.SleepConfig
|
|
21
22
|
import com.spikeapi.apiv3.datamodels.StatisticsType
|
|
22
23
|
import com.spikeapi.apiv3.datamodels.NutritionRecord
|
|
@@ -748,6 +749,7 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
|
|
|
748
749
|
from: String, // Instant
|
|
749
750
|
to: String, // Instant
|
|
750
751
|
filter: String?, // StatisticsFilter?
|
|
752
|
+
configJson: String?, // RecordConfig?
|
|
751
753
|
promise: Promise
|
|
752
754
|
) {
|
|
753
755
|
executeV3MethodWithConnection("getRecords", connectionUUID, promise) { connection ->
|
|
@@ -757,12 +759,14 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
|
|
|
757
759
|
val dateFrom = convertIsoStringToInstant(from)
|
|
758
760
|
val dateTo = convertIsoStringToInstant(to)
|
|
759
761
|
val statsFilter = StatisticsFilter.fromValue(filter)
|
|
762
|
+
val recordConfig = makeRecordConfig(configJson)
|
|
760
763
|
|
|
761
764
|
val result = connection.getRecords(
|
|
762
765
|
types = statTypes,
|
|
763
766
|
from = dateFrom,
|
|
764
767
|
to = dateTo,
|
|
765
|
-
filter = statsFilter
|
|
768
|
+
filter = statsFilter,
|
|
769
|
+
config = recordConfig
|
|
766
770
|
)
|
|
767
771
|
|
|
768
772
|
promise.resolve(SpikeConnectionAPIv3.convertToJson(result))
|
|
@@ -1123,6 +1127,45 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
|
|
|
1123
1127
|
}
|
|
1124
1128
|
}
|
|
1125
1129
|
|
|
1130
|
+
@ReactMethod
|
|
1131
|
+
fun backfill(
|
|
1132
|
+
connectionUUID: String,
|
|
1133
|
+
days: String?,
|
|
1134
|
+
statisticTypes: ReadableArray,
|
|
1135
|
+
metricTypes: ReadableArray,
|
|
1136
|
+
activityConfigs: ReadableArray,
|
|
1137
|
+
sleepConfigs: ReadableArray,
|
|
1138
|
+
promise: Promise
|
|
1139
|
+
) {
|
|
1140
|
+
executeV3MethodWithConnection("backfill", connectionUUID, promise) { connection ->
|
|
1141
|
+
val statTypes = statisticTypes.toArrayList().mapNotNull {
|
|
1142
|
+
StatisticsTypeUtils.fromValue(it as String)
|
|
1143
|
+
}.toSet()
|
|
1144
|
+
|
|
1145
|
+
val mTypes = metricTypes.toArrayList().mapNotNull {
|
|
1146
|
+
MetricTypeUtils.fromValue(it as String)
|
|
1147
|
+
}.toSet()
|
|
1148
|
+
|
|
1149
|
+
val aConfigs = activityConfigs.toArrayList().mapNotNull {
|
|
1150
|
+
ActivityConfigUtils.fromValue(it as String)
|
|
1151
|
+
}.toSet()
|
|
1152
|
+
|
|
1153
|
+
val sConfigs = sleepConfigs.toArrayList().mapNotNull {
|
|
1154
|
+
SleepConfigUtils.fromValue(it as String)
|
|
1155
|
+
}.toSet()
|
|
1156
|
+
|
|
1157
|
+
connection.backfill(
|
|
1158
|
+
days = days?.toIntOrNull(),
|
|
1159
|
+
statisticsTypes = statTypes,
|
|
1160
|
+
metricTypes = mTypes,
|
|
1161
|
+
activityConfigs = aConfigs,
|
|
1162
|
+
sleepConfigs = sConfigs
|
|
1163
|
+
)
|
|
1164
|
+
|
|
1165
|
+
promise.resolve(true)
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1126
1169
|
@ReactMethod
|
|
1127
1170
|
fun disableBackgroundDelivery(
|
|
1128
1171
|
connectionUUID: String,
|
|
@@ -1393,7 +1436,50 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
|
|
|
1393
1436
|
}
|
|
1394
1437
|
}
|
|
1395
1438
|
|
|
1439
|
+
@ReactMethod
|
|
1440
|
+
fun requestSamsungPermissionsAndBackfill(
|
|
1441
|
+
connectionUUID: String,
|
|
1442
|
+
statisticTypes: ReadableArray,
|
|
1443
|
+
metricTypes: ReadableArray,
|
|
1444
|
+
activityConfigs: ReadableArray,
|
|
1445
|
+
sleepConfigs: ReadableArray,
|
|
1446
|
+
days: String?,
|
|
1447
|
+
promise: Promise
|
|
1448
|
+
) {
|
|
1449
|
+
executeV3MethodWithConnection("requestSamsungPermissionsAndBackfill", connectionUUID, promise) { connection ->
|
|
1450
|
+
val activity = reactApplicationContext.currentActivity
|
|
1451
|
+
if (activity == null) {
|
|
1452
|
+
throw SpikeExceptions.SpikeException("Activity is required to request Samsung Health Data permissions and backfill")
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1455
|
+
val statTypes = statisticTypes.toArrayList().mapNotNull {
|
|
1456
|
+
StatisticsTypeUtils.fromValue(it as String)
|
|
1457
|
+
}.toSet()
|
|
1458
|
+
|
|
1459
|
+
val mTypes = metricTypes.toArrayList().mapNotNull {
|
|
1460
|
+
MetricTypeUtils.fromValue(it as String)
|
|
1461
|
+
}.toSet()
|
|
1462
|
+
|
|
1463
|
+
val aConfigs = activityConfigs.toArrayList().mapNotNull {
|
|
1464
|
+
ActivityConfigUtils.fromValue(it as String)
|
|
1465
|
+
}.toSet()
|
|
1466
|
+
|
|
1467
|
+
val sConfigs = sleepConfigs.toArrayList().mapNotNull {
|
|
1468
|
+
SleepConfigUtils.fromValue(it as String)
|
|
1469
|
+
}.toSet()
|
|
1396
1470
|
|
|
1471
|
+
connection.requestSamsungPermissionsAndBackfill(
|
|
1472
|
+
activity = activity,
|
|
1473
|
+
statisticsTypes = statTypes,
|
|
1474
|
+
metricTypes = mTypes,
|
|
1475
|
+
activityConfigs = aConfigs,
|
|
1476
|
+
sleepConfigs = sConfigs,
|
|
1477
|
+
backfillDays = days?.toIntOrNull()
|
|
1478
|
+
)
|
|
1479
|
+
|
|
1480
|
+
promise.resolve(true)
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1397
1483
|
|
|
1398
1484
|
/// --- Nutrition AI ---
|
|
1399
1485
|
|
|
@@ -1594,6 +1680,15 @@ class SpikeSdkModule(reactContext: ReactApplicationContext) :
|
|
|
1594
1680
|
|
|
1595
1681
|
}
|
|
1596
1682
|
|
|
1683
|
+
private fun makeRecordConfig(json: String?): RecordConfig? {
|
|
1684
|
+
if (json == null) return null
|
|
1685
|
+
val moshi = com.squareup.moshi.Moshi.Builder()
|
|
1686
|
+
.addLast(com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory())
|
|
1687
|
+
.build()
|
|
1688
|
+
val adapter = moshi.adapter(RecordConfig::class.java)
|
|
1689
|
+
return adapter.fromJson(json)
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1597
1692
|
private fun convertIsoStringToInstant(isoString: String): Instant {
|
|
1598
1693
|
return Instant.parse(isoString)
|
|
1599
1694
|
}
|
package/ios/SpikeSdk.m
CHANGED
|
@@ -122,6 +122,15 @@ RCT_EXTERN_METHOD(requestPermissionsFromHealthKit: (NSString)connectionUUID
|
|
|
122
122
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
123
123
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
124
124
|
|
|
125
|
+
RCT_EXTERN_METHOD(requestPermissionsFromHealthKitAndBackfill: (NSString)connectionUUID
|
|
126
|
+
withStatistics: (NSArray<NSString>)statistics
|
|
127
|
+
metrics: (NSArray<NSString>)metrics
|
|
128
|
+
activityConfigs: (NSArray<NSString>)activityConfigs
|
|
129
|
+
sleepConfigs: (NSArray<NSString>)sleepConfigs
|
|
130
|
+
days: (NSString)days
|
|
131
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
132
|
+
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
133
|
+
|
|
125
134
|
RCT_EXTERN_METHOD(getUserInfo: (NSString)connectionUUID
|
|
126
135
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
127
136
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
@@ -151,6 +160,7 @@ RCT_EXTERN_METHOD(getRecords: (NSString)connectionUUID
|
|
|
151
160
|
from: (NSString)from
|
|
152
161
|
to: (NSString)to
|
|
153
162
|
filter: (NSString)filter
|
|
163
|
+
config: (NSString)config
|
|
154
164
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
155
165
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
156
166
|
|
|
@@ -180,6 +190,15 @@ RCT_EXTERN_METHOD(enableBackgroundDeliveryV3: (NSString)connectionUUID
|
|
|
180
190
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
181
191
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
182
192
|
|
|
193
|
+
RCT_EXTERN_METHOD(backfill: (NSString)connectionUUID
|
|
194
|
+
days: (NSString)days
|
|
195
|
+
withStatistics: (NSArray<NSString>)statistics
|
|
196
|
+
metrics: (NSArray<NSString>)metrics
|
|
197
|
+
activityConfigs: (NSArray<NSString>)activityConfigs
|
|
198
|
+
sleepConfigs: (NSArray<NSString>)sleepConfigs
|
|
199
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
200
|
+
withRejecter: (RCTPromiseRejectBlock)reject)
|
|
201
|
+
|
|
183
202
|
RCT_EXTERN_METHOD(disableBackgroundDelivery: (NSString)connectionUUID
|
|
184
203
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
185
204
|
withRejecter: (RCTPromiseRejectBlock)reject)
|
package/ios/SpikeSdk.swift
CHANGED
|
@@ -611,6 +611,59 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
+
@objc(requestPermissionsFromHealthKitAndBackfill:
|
|
615
|
+
withStatistics:
|
|
616
|
+
metrics:
|
|
617
|
+
activityConfigs:
|
|
618
|
+
sleepConfigs:
|
|
619
|
+
days:
|
|
620
|
+
withResolver:
|
|
621
|
+
withRejecter:)
|
|
622
|
+
func requestPermissionsFromHealthKitAndBackfill(
|
|
623
|
+
connectionUUID: String,
|
|
624
|
+
forStatistics statistics: [String],
|
|
625
|
+
metrics: [String],
|
|
626
|
+
activityConfigs: [String],
|
|
627
|
+
sleepConfigs: [String],
|
|
628
|
+
days: String?,
|
|
629
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
630
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
631
|
+
) {
|
|
632
|
+
Task {
|
|
633
|
+
do {
|
|
634
|
+
guard let connection = getConnectionV3(withUUID: connectionUUID) else {
|
|
635
|
+
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
636
|
+
return
|
|
637
|
+
}
|
|
638
|
+
let stats = statistics.compactMap {
|
|
639
|
+
StatisticsType(rawValue: $0)
|
|
640
|
+
}
|
|
641
|
+
let metricsObjects = metrics.compactMap {
|
|
642
|
+
MetricType(rawValue: $0)
|
|
643
|
+
}
|
|
644
|
+
let activityConfigsObjects = activityConfigs.compactMap {
|
|
645
|
+
try? makeActivityConfig(fromString: $0)
|
|
646
|
+
}
|
|
647
|
+
let sleepConfigsObjects = sleepConfigs.compactMap {
|
|
648
|
+
try? makeSleepConfig(fromString: $0)
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
let daysValue: Int? = days != nil ? Int(days!) : nil
|
|
652
|
+
try await connection.requestPermissionsFromHealthKitAndBackfill(
|
|
653
|
+
forStatistics: stats,
|
|
654
|
+
forMetrics: metricsObjects,
|
|
655
|
+
forActivities: activityConfigsObjects,
|
|
656
|
+
forSleep: sleepConfigsObjects,
|
|
657
|
+
backfillDays: daysValue
|
|
658
|
+
)
|
|
659
|
+
|
|
660
|
+
resolve(Void())
|
|
661
|
+
} catch let error {
|
|
662
|
+
spikeReject(with: error, reject: reject)
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
|
|
614
667
|
@objc(getUserInfo:
|
|
615
668
|
withResolver:
|
|
616
669
|
withRejecter:)
|
|
@@ -728,6 +781,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
728
781
|
from:
|
|
729
782
|
to:
|
|
730
783
|
filter:
|
|
784
|
+
config:
|
|
731
785
|
withResolver:
|
|
732
786
|
withRejecter:)
|
|
733
787
|
func getRecords(
|
|
@@ -736,6 +790,7 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
736
790
|
from: String, // Date
|
|
737
791
|
to: String, // Date
|
|
738
792
|
filter: String?, // StatisticsFilter?
|
|
793
|
+
config: String?, // RecordConfig?
|
|
739
794
|
resolve: @escaping RCTPromiseResolveBlock,
|
|
740
795
|
reject: @escaping RCTPromiseRejectBlock
|
|
741
796
|
) { // -> [Record]
|
|
@@ -747,12 +802,14 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
747
802
|
let dateFrom = try makeDate(fromString: from)
|
|
748
803
|
let dateTo = try makeDate(fromString: to)
|
|
749
804
|
let statsFilter = try makeStatisticsFilter(fromString: filter)
|
|
805
|
+
let recordConfig = try makeRecordConfig(fromString: config)
|
|
750
806
|
|
|
751
807
|
let result = try await connection.getRecords(
|
|
752
808
|
ofTypes: types.compactMap{ MetricType(rawValue: $0) },
|
|
753
809
|
from: dateFrom,
|
|
754
810
|
to: dateTo,
|
|
755
|
-
filter: statsFilter
|
|
811
|
+
filter: statsFilter,
|
|
812
|
+
configured: recordConfig
|
|
756
813
|
)
|
|
757
814
|
|
|
758
815
|
let encoder = SpikeSDK.JSONEncoder.spikeDefaultJsonEncoder
|
|
@@ -904,6 +961,59 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
904
961
|
}
|
|
905
962
|
}
|
|
906
963
|
|
|
964
|
+
@objc(backfill:
|
|
965
|
+
days:
|
|
966
|
+
withStatistics:
|
|
967
|
+
metrics:
|
|
968
|
+
activityConfigs:
|
|
969
|
+
sleepConfigs:
|
|
970
|
+
withResolver:
|
|
971
|
+
withRejecter:)
|
|
972
|
+
func backfill(
|
|
973
|
+
connectionUUID: String,
|
|
974
|
+
days: String?,
|
|
975
|
+
withStatistics statistics: [String],
|
|
976
|
+
metrics: [String],
|
|
977
|
+
activityConfigs: [String],
|
|
978
|
+
sleepConfigs: [String],
|
|
979
|
+
resolve: @escaping RCTPromiseResolveBlock,
|
|
980
|
+
reject: @escaping RCTPromiseRejectBlock
|
|
981
|
+
) {
|
|
982
|
+
Task {
|
|
983
|
+
do {
|
|
984
|
+
guard let connection = getConnectionV3(withUUID: connectionUUID) else {
|
|
985
|
+
spikeReject(with: SpikeConnectionNotFoundException(), reject: reject)
|
|
986
|
+
return
|
|
987
|
+
}
|
|
988
|
+
let stats = statistics.compactMap {
|
|
989
|
+
StatisticsType(rawValue: $0)
|
|
990
|
+
}
|
|
991
|
+
let metricsObjects = metrics.compactMap {
|
|
992
|
+
MetricType(rawValue: $0)
|
|
993
|
+
}
|
|
994
|
+
let activityConfigsObjects = activityConfigs.compactMap {
|
|
995
|
+
try? makeActivityConfig(fromString: $0)
|
|
996
|
+
}
|
|
997
|
+
let sleepConfigsObjects = sleepConfigs.compactMap {
|
|
998
|
+
try? makeSleepConfig(fromString: $0)
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
let daysValue: Int? = days != nil ? Int(days!) : nil
|
|
1002
|
+
try await connection.backfill(
|
|
1003
|
+
days: daysValue,
|
|
1004
|
+
forStatistics: stats,
|
|
1005
|
+
forMetrics: metricsObjects,
|
|
1006
|
+
forActivities: activityConfigsObjects,
|
|
1007
|
+
forSleep: sleepConfigsObjects
|
|
1008
|
+
)
|
|
1009
|
+
|
|
1010
|
+
resolve(true)
|
|
1011
|
+
} catch let error {
|
|
1012
|
+
spikeReject(with: error, reject: reject)
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
|
|
907
1017
|
@objc(disableBackgroundDelivery:
|
|
908
1018
|
withResolver:
|
|
909
1019
|
withRejecter:)
|
|
@@ -984,6 +1094,18 @@ class SpikeSdk: RCTEventEmitter {
|
|
|
984
1094
|
return date
|
|
985
1095
|
}
|
|
986
1096
|
|
|
1097
|
+
private func makeRecordConfig(fromString string: String?) throws -> RecordConfig? {
|
|
1098
|
+
guard let string else {
|
|
1099
|
+
return nil
|
|
1100
|
+
}
|
|
1101
|
+
guard let data = string.data(using: .utf8) else {
|
|
1102
|
+
throw SpikeDataDecodingException()
|
|
1103
|
+
}
|
|
1104
|
+
let decoder = SpikeSDK.JSONDecoder.spikeDefaultJsonDecoder
|
|
1105
|
+
let config = try decoder.decode(RecordConfig.self, from: data)
|
|
1106
|
+
return config
|
|
1107
|
+
}
|
|
1108
|
+
|
|
987
1109
|
private func makeActivityConfig(fromString string: String?) throws -> ActivityConfig? {
|
|
988
1110
|
guard let string else {
|
|
989
1111
|
return ActivityConfig()
|
package/lib/commonjs/index.js
CHANGED
|
@@ -111,6 +111,12 @@ Object.defineProperty(exports, "ProviderSource", {
|
|
|
111
111
|
return _ProviderSource.ProviderSource;
|
|
112
112
|
}
|
|
113
113
|
});
|
|
114
|
+
Object.defineProperty(exports, "RecordConfig", {
|
|
115
|
+
enumerable: true,
|
|
116
|
+
get: function () {
|
|
117
|
+
return _RecordConfig.RecordConfig;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
114
120
|
Object.defineProperty(exports, "SamsungHealthDataAvailabilityStatus", {
|
|
115
121
|
enumerable: true,
|
|
116
122
|
get: function () {
|
|
@@ -248,6 +254,7 @@ var _SamsungHealthDataAvailabilityStatus = require("./v3/DataModels/SamsungHealt
|
|
|
248
254
|
var _ActivityAdditionalData = require("./v3/DataModels/ActivityAdditionalData");
|
|
249
255
|
var _ActivityConfig = require("./v3/DataModels/ActivityConfig");
|
|
250
256
|
var _SleepConfig = require("./v3/DataModels/SleepConfig");
|
|
257
|
+
var _RecordConfig = require("./v3/RecordConfig");
|
|
251
258
|
var _LogLevel = require("./v3/DataModels/LogLevel");
|
|
252
259
|
var _NutritionRecordStatus = require("./v3/DataModels/NutritionRecordStatus");
|
|
253
260
|
var _NutritionRecordAnalysisMode = require("./v3/DataModels/NutritionRecordAnalysisMode");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_SpikeDataTypes","require","_Spike","_SpikeConnection","_SpikeException","_SpikeRNConnectionAPIv","_ActivityTag","_ActivityType","_ActivityCategory","_InputMethod","_MetricType","_Provider","_ProviderSource","_StatisticsType","_StatisticsInterval","_Unit","_StatisticsFilter","_HealthConnectAvailabilityStatus","_HealthConnectFeature","_SamsungHealthDataAvailabilityStatus","_ActivityAdditionalData","_ActivityConfig","_SleepConfig","_LogLevel","_NutritionRecordStatus","_NutritionRecordAnalysisMode","_NutritionalField","_NutritionalUnit","_NutritionRecordUtils","_NutritionRecordIngredientUtils","_default","exports","default","createConnection","getBackgroundConnections","ensurePermissionsAreGranted","isPackageInstalled","isHealthDataAvailable","createConnectionAPIv3","createConnectionAPIv3Legacy","setLogCallback"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_SpikeDataTypes","require","_Spike","_SpikeConnection","_SpikeException","_SpikeRNConnectionAPIv","_ActivityTag","_ActivityType","_ActivityCategory","_InputMethod","_MetricType","_Provider","_ProviderSource","_StatisticsType","_StatisticsInterval","_Unit","_StatisticsFilter","_HealthConnectAvailabilityStatus","_HealthConnectFeature","_SamsungHealthDataAvailabilityStatus","_ActivityAdditionalData","_ActivityConfig","_SleepConfig","_RecordConfig","_LogLevel","_NutritionRecordStatus","_NutritionRecordAnalysisMode","_NutritionalField","_NutritionalUnit","_NutritionRecordUtils","_NutritionRecordIngredientUtils","_default","exports","default","createConnection","getBackgroundConnections","ensurePermissionsAreGranted","isPackageInstalled","isHealthDataAvailable","createConnectionAPIv3","createConnectionAPIv3Legacy","setLogCallback"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAYA,IAAAE,gBAAA,GAAAF,OAAA;AAIA,IAAAG,eAAA,GAAAH,OAAA;AAuEA,IAAAI,sBAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,iBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AACA,IAAAY,eAAA,GAAAZ,OAAA;AACA,IAAAa,mBAAA,GAAAb,OAAA;AACA,IAAAc,KAAA,GAAAd,OAAA;AACA,IAAAe,iBAAA,GAAAf,OAAA;AACA,IAAAgB,gCAAA,GAAAhB,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AACA,IAAAkB,oCAAA,GAAAlB,OAAA;AACA,IAAAmB,uBAAA,GAAAnB,OAAA;AACA,IAAAoB,eAAA,GAAApB,OAAA;AAIA,IAAAqB,YAAA,GAAArB,OAAA;AACA,IAAAsB,aAAA,GAAAtB,OAAA;AAQA,IAAAuB,SAAA,GAAAvB,OAAA;AAIA,IAAAwB,sBAAA,GAAAxB,OAAA;AACA,IAAAyB,4BAAA,GAAAzB,OAAA;AAEA,IAAA0B,iBAAA,GAAA1B,OAAA;AACA,IAAA2B,gBAAA,GAAA3B,OAAA;AAGA,IAAA4B,qBAAA,GAAA5B,OAAA;AAIA,IAAA6B,+BAAA,GAAA7B,OAAA;AAGmD,IAAA8B,QAAA,GAAAC,OAAA,CAAAC,OAAA,GA9FpC;EACbC,gBAAgB,EAAhBA,uBAAgB;EAChBC,wBAAwB,EAAxBA,+BAAwB;EACxBC,2BAA2B,EAA3BA,kCAA2B;EAC3BC,kBAAkB,EAAlBA,yBAAkB;EAClBC,qBAAqB,EAArBA,4BAAqB;EACrB;EACAC,qBAAqB,EAArBA,4BAAqB;EACrBC,2BAA2B,EAA3BA,kCAA2B;EAC3BC,cAAc,EAAdA;AACF,CAAC,EAoCD","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RecordConfig = void 0;
|
|
7
|
+
class RecordConfig {
|
|
8
|
+
includeSamples = false;
|
|
9
|
+
constructor({
|
|
10
|
+
includeSamples = false
|
|
11
|
+
}) {
|
|
12
|
+
this.includeSamples = includeSamples;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.RecordConfig = RecordConfig;
|
|
16
|
+
//# sourceMappingURL=RecordConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["RecordConfig","includeSamples","constructor","exports"],"sourceRoot":"../../../src","sources":["v3/RecordConfig.ts"],"mappings":";;;;;;AAIO,MAAMA,YAAY,CAAC;EACtBC,cAAc,GAAY,KAAK;EAE/BC,WAAWA,CAAC;IACRD,cAAc,GAAG;EACc,CAAC,EAAE;IAClC,IAAI,CAACA,cAAc,GAAGA,cAAc;EACxC;AACJ;AAACE,OAAA,CAAAH,YAAA,GAAAA,YAAA","ignoreList":[]}
|
|
@@ -81,12 +81,12 @@ class SpikeRNConnectionAPIv3 {
|
|
|
81
81
|
ofTypes,
|
|
82
82
|
from,
|
|
83
83
|
to,
|
|
84
|
-
filter = null
|
|
84
|
+
filter = null,
|
|
85
|
+
config = null
|
|
85
86
|
}) {
|
|
86
87
|
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
87
88
|
const stringTypes = ofTypes.map(item => item);
|
|
88
|
-
|
|
89
|
-
const result = await _SpikeSdk.SpikeSdk.getRecords(this.connectionUUID, stringTypes, from.toISOString(), to.toISOString(), !!filter ? JSON.stringify(filter) : null);
|
|
89
|
+
const result = await _SpikeSdk.SpikeSdk.getRecords(this.connectionUUID, stringTypes, from.toISOString(), to.toISOString(), !!filter ? JSON.stringify(filter) : null, config ? JSON.stringify((0, _Conversion.camelToSnake)(config)) : null);
|
|
90
90
|
const jsonResult = JSON.parse(result);
|
|
91
91
|
const finalResult = (0, _Conversion.snakeToCamel)(jsonResult);
|
|
92
92
|
return finalResult;
|
|
@@ -219,6 +219,29 @@ class SpikeRNConnectionAPIv3 {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Triggers a backfill of health data for the specified number of days.
|
|
224
|
+
*
|
|
225
|
+
* This method pushes historical health data to the Spike backend. It requires that
|
|
226
|
+
* health permissions have already been granted (via `requestHealthPermissions` on iOS
|
|
227
|
+
* or Health Connect / Samsung Health Data integration on Android).
|
|
228
|
+
*
|
|
229
|
+
* The number of days to backfill configured in the Spike dashboard will be used if
|
|
230
|
+
* `days` is not provided.
|
|
231
|
+
*
|
|
232
|
+
* @category Backfill
|
|
233
|
+
*/
|
|
234
|
+
async backfill({
|
|
235
|
+
days = undefined,
|
|
236
|
+
statisticTypes = [],
|
|
237
|
+
metricTypes = [],
|
|
238
|
+
activityConfigs = [],
|
|
239
|
+
sleepConfigs = []
|
|
240
|
+
}) {
|
|
241
|
+
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
242
|
+
await _SpikeSdk.SpikeSdk.backfill(this.connectionUUID, days !== undefined ? String(days) : null, statisticTypes, metricTypes, activityConfigs.map(object => JSON.stringify(object)), sleepConfigs.map(object => JSON.stringify(object)));
|
|
243
|
+
}
|
|
244
|
+
|
|
222
245
|
/**
|
|
223
246
|
* Disables background checks for new data.
|
|
224
247
|
*
|
|
@@ -273,6 +296,27 @@ class SpikeRNConnectionAPIv3 {
|
|
|
273
296
|
return await _SpikeSdk.SpikeSdk.isHealthKitIntegrationEnabled(this.connectionUUID);
|
|
274
297
|
}
|
|
275
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Requests HealthKit read permissions for the given categories, then starts a backfill.
|
|
301
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
302
|
+
*
|
|
303
|
+
* For manual control over backfill, use {@link requestHealthPermissions} and {@link backfill} instead.
|
|
304
|
+
*
|
|
305
|
+
* @category iOS HealthKit
|
|
306
|
+
* @category Backfill
|
|
307
|
+
*/
|
|
308
|
+
async requestPermissionsFromHealthKitAndBackfill({
|
|
309
|
+
days = undefined,
|
|
310
|
+
statisticTypes = [],
|
|
311
|
+
metricTypes = [],
|
|
312
|
+
activityConfigs = [],
|
|
313
|
+
sleepConfigs = []
|
|
314
|
+
}) {
|
|
315
|
+
if (_reactNative.Platform.OS !== 'ios') return;
|
|
316
|
+
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
317
|
+
await _SpikeSdk.SpikeSdk.requestPermissionsFromHealthKitAndBackfill(this.connectionUUID, statisticTypes, metricTypes, activityConfigs.map(object => JSON.stringify(object)), sleepConfigs.map(object => JSON.stringify(object)), days !== undefined ? String(days) : null);
|
|
318
|
+
}
|
|
319
|
+
|
|
276
320
|
// ------------------------- Android specific Health Connect permissions -------------------------
|
|
277
321
|
|
|
278
322
|
/**
|
|
@@ -418,6 +462,51 @@ class SpikeRNConnectionAPIv3 {
|
|
|
418
462
|
return await _SpikeSdk.SpikeSdk.isHealthConnectFeatureAvailable(this.connectionUUID, feature);
|
|
419
463
|
}
|
|
420
464
|
|
|
465
|
+
/**
|
|
466
|
+
* Enables Health Connect integration, requests permissions for the given categories, then starts a backfill.
|
|
467
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
468
|
+
*
|
|
469
|
+
* This mirrors the native {@link requestSamsungPermissionsAndBackfill} flow: enable integration,
|
|
470
|
+
* request permissions, then run backfill (implemented by composing existing Health Connect APIs).
|
|
471
|
+
*
|
|
472
|
+
* For manual control, use {@link enableHealthConnectIntegration}, {@link getHealthConnectPermissions},
|
|
473
|
+
* {@link requestPermissionsFromHealthConnect}, and {@link backfill} instead.
|
|
474
|
+
*
|
|
475
|
+
* @category Android Health Connect
|
|
476
|
+
* @category Backfill
|
|
477
|
+
*/
|
|
478
|
+
async requestHealthConnectPermissionsAndBackfill({
|
|
479
|
+
days = undefined,
|
|
480
|
+
statisticTypes = [],
|
|
481
|
+
metricTypes = [],
|
|
482
|
+
activityConfigs = [],
|
|
483
|
+
sleepConfigs = [],
|
|
484
|
+
includeEnhancedPermissions = false,
|
|
485
|
+
includeBackgroundDelivery = false
|
|
486
|
+
}) {
|
|
487
|
+
if (_reactNative.Platform.OS !== 'android') return;
|
|
488
|
+
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
489
|
+
await this.enableHealthConnectIntegration();
|
|
490
|
+
const permissions = await this.getHealthConnectPermissions({
|
|
491
|
+
statisticTypes,
|
|
492
|
+
metricTypes,
|
|
493
|
+
activityConfigs,
|
|
494
|
+
sleepConfigs,
|
|
495
|
+
includeEnhancedPermissions,
|
|
496
|
+
includeBackgroundDelivery
|
|
497
|
+
});
|
|
498
|
+
await this.requestPermissionsFromHealthConnect({
|
|
499
|
+
permissions
|
|
500
|
+
});
|
|
501
|
+
await this.backfill({
|
|
502
|
+
days,
|
|
503
|
+
statisticTypes,
|
|
504
|
+
metricTypes,
|
|
505
|
+
activityConfigs,
|
|
506
|
+
sleepConfigs
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
|
|
421
510
|
// ------------------------- Samsung Health Data permissions -------------------------
|
|
422
511
|
|
|
423
512
|
/**
|
|
@@ -531,6 +620,27 @@ class SpikeRNConnectionAPIv3 {
|
|
|
531
620
|
return await _SpikeSdk.SpikeSdk.requestPermissionsFromSamsungHealthData(this.connectionUUID, statisticTypes, metricTypes, activityConfigs.map(object => JSON.stringify(object)), sleepConfigs.map(object => JSON.stringify(object)));
|
|
532
621
|
}
|
|
533
622
|
|
|
623
|
+
/**
|
|
624
|
+
* Enables Samsung Health Data integration, requests permissions for the given categories, then starts a backfill.
|
|
625
|
+
* Data for today and yesterday is pushed before this method resolves; older days continue in the background.
|
|
626
|
+
*
|
|
627
|
+
* For manual control, use {@link enableSamsungHealthDataIntegration}, {@link requestPermissionsFromSamsungHealthData}, and {@link backfill} instead.
|
|
628
|
+
*
|
|
629
|
+
* @category Samsung Health Data
|
|
630
|
+
* @category Backfill
|
|
631
|
+
*/
|
|
632
|
+
async requestSamsungPermissionsAndBackfill({
|
|
633
|
+
days = undefined,
|
|
634
|
+
statisticTypes = [],
|
|
635
|
+
metricTypes = [],
|
|
636
|
+
activityConfigs = [],
|
|
637
|
+
sleepConfigs = []
|
|
638
|
+
}) {
|
|
639
|
+
if (_reactNative.Platform.OS !== 'android') return;
|
|
640
|
+
if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
|
|
641
|
+
await _SpikeSdk.SpikeSdk.requestSamsungPermissionsAndBackfill(this.connectionUUID, statisticTypes, metricTypes, activityConfigs.map(object => JSON.stringify(object)), sleepConfigs.map(object => JSON.stringify(object)), days !== undefined ? String(days) : null);
|
|
642
|
+
}
|
|
643
|
+
|
|
534
644
|
// ------------------------- Nutrition AI -------------------------
|
|
535
645
|
|
|
536
646
|
/**
|