react-native-spike-sdk 4.3.73-beta.3 → 4.3.73

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 (172) hide show
  1. package/lib/commonjs/DataModels/SpikeActivitiesStreamDataEntry.js +2 -0
  2. package/lib/commonjs/DataModels/SpikeActivitiesSummaryDataEntry.js +2 -0
  3. package/lib/commonjs/DataModels/SpikeBodyDataEntry.js +2 -0
  4. package/lib/commonjs/DataModels/SpikeBreathingDataEntry.js +2 -0
  5. package/lib/commonjs/DataModels/SpikeCaloriesDataEntry.js +2 -0
  6. package/lib/commonjs/DataModels/SpikeData.js +6 -0
  7. package/lib/commonjs/DataModels/SpikeDataTypes.js +23 -0
  8. package/lib/commonjs/DataModels/SpikeDistanceDataEntry.js +2 -0
  9. package/lib/commonjs/DataModels/SpikeEcgDataEntry.js +2 -0
  10. package/lib/commonjs/DataModels/SpikeGlucoseDataEntry.js +2 -0
  11. package/lib/commonjs/DataModels/SpikeHeartDataEntry.js +2 -0
  12. package/lib/commonjs/DataModels/SpikeOxygenSaturationDataEntry.js +2 -0
  13. package/lib/commonjs/DataModels/SpikeSleepDataEntry.js +2 -0
  14. package/lib/commonjs/DataModels/SpikeStepsDataEntry.js +2 -0
  15. package/lib/commonjs/DataModels/SpikeStepsIntradayDataEntry.js +2 -0
  16. package/lib/commonjs/DataModels/SpikeWebhookJob.js +2 -0
  17. package/lib/commonjs/DataTypes/SpikeDataType.js +59 -0
  18. package/lib/commonjs/Spike.js +116 -0
  19. package/lib/commonjs/SpikeBackgroundDeliveriesLogger.js +2 -0
  20. package/lib/commonjs/SpikeConnection.js +298 -0
  21. package/lib/commonjs/SpikeConnectionTypes.js +6 -0
  22. package/lib/commonjs/SpikeException.js +110 -0
  23. package/lib/commonjs/SpikeLogger.js +6 -0
  24. package/lib/commonjs/SpikeSdk.js +9 -0
  25. package/lib/commonjs/index.js +205 -0
  26. package/lib/commonjs/v3/Conversion.js +53 -0
  27. package/lib/commonjs/v3/DataModels/ActivityAdditionalData.js +18 -0
  28. package/lib/commonjs/v3/DataModels/ActivityAdditionalData.js.map +1 -0
  29. package/lib/commonjs/v3/DataModels/ActivityConfig.js +17 -0
  30. package/lib/commonjs/v3/DataModels/ActivityConfig.js.map +1 -0
  31. package/lib/commonjs/v3/DataModels/ActivityEntry.js +2 -0
  32. package/lib/commonjs/v3/DataModels/ActivitySamples.js +2 -0
  33. package/lib/commonjs/v3/DataModels/ActivityTag.js +32 -0
  34. package/lib/commonjs/v3/DataModels/ActivityType.js +153 -0
  35. package/lib/commonjs/v3/DataModels/BackgroundDeliveryConfig.js +6 -0
  36. package/lib/commonjs/v3/DataModels/Gender.js +15 -0
  37. package/lib/commonjs/v3/DataModels/HealthConnectAvailabilityStatus.js +13 -0
  38. package/lib/commonjs/v3/DataModels/InputMethod.js +15 -0
  39. package/lib/commonjs/v3/DataModels/LogLevel.js +16 -0
  40. package/lib/commonjs/v3/DataModels/MetricType.js +74 -0
  41. package/lib/commonjs/v3/DataModels/Provider.js +25 -0
  42. package/lib/commonjs/v3/DataModels/ProviderSource.js +52 -0
  43. package/lib/commonjs/v3/DataModels/RecordSource.js +2 -0
  44. package/lib/commonjs/v3/DataModels/SamsungHealthDataAvailability.js +6 -0
  45. package/lib/commonjs/v3/DataModels/SamsungHealthDataAvailabilityStatus.js +37 -0
  46. package/lib/commonjs/v3/DataModels/SleepConfig.js +15 -0
  47. package/lib/commonjs/v3/DataModels/SpikeRecord.js +6 -0
  48. package/lib/commonjs/v3/DataModels/Statistic.js +6 -0
  49. package/lib/commonjs/v3/DataModels/StatisticsInterval.js +14 -0
  50. package/lib/commonjs/v3/DataModels/StatisticsType.js +27 -0
  51. package/lib/commonjs/v3/DataModels/UUID.js +2 -0
  52. package/lib/commonjs/v3/DataModels/Unit.js +21 -0
  53. package/lib/commonjs/v3/DataModels/UserInfoResponse.js +6 -0
  54. package/lib/commonjs/v3/DataModels/UserProperties.js +6 -0
  55. package/lib/commonjs/v3/SpikeRNConnectionAPIv3.js +394 -0
  56. package/lib/commonjs/v3/StatisticsFilter.js +20 -0
  57. package/lib/commonjs/version.js +9 -0
  58. package/lib/commonjs/version.js.map +1 -1
  59. package/lib/module/DataModels/SpikeActivitiesStreamDataEntry.js +2 -0
  60. package/lib/module/DataModels/SpikeActivitiesStreamDataEntry.js.map +1 -0
  61. package/lib/module/DataModels/SpikeActivitiesSummaryDataEntry.js +2 -0
  62. package/lib/module/DataModels/SpikeActivitiesSummaryDataEntry.js.map +1 -0
  63. package/lib/module/DataModels/SpikeBodyDataEntry.js +2 -0
  64. package/lib/module/DataModels/SpikeBodyDataEntry.js.map +1 -0
  65. package/lib/module/DataModels/SpikeBreathingDataEntry.js +2 -0
  66. package/lib/module/DataModels/SpikeBreathingDataEntry.js.map +1 -0
  67. package/lib/module/DataModels/SpikeCaloriesDataEntry.js +2 -0
  68. package/lib/module/DataModels/SpikeCaloriesDataEntry.js.map +1 -0
  69. package/lib/module/DataModels/SpikeData.js +4 -0
  70. package/lib/module/DataModels/SpikeData.js.map +1 -0
  71. package/lib/module/DataModels/SpikeDataTypes.js +19 -0
  72. package/lib/module/DataModels/SpikeDataTypes.js.map +1 -0
  73. package/lib/module/DataModels/SpikeDistanceDataEntry.js +2 -0
  74. package/lib/module/DataModels/SpikeDistanceDataEntry.js.map +1 -0
  75. package/lib/module/DataModels/SpikeEcgDataEntry.js +2 -0
  76. package/lib/module/DataModels/SpikeEcgDataEntry.js.map +1 -0
  77. package/lib/module/DataModels/SpikeGlucoseDataEntry.js +2 -0
  78. package/lib/module/DataModels/SpikeGlucoseDataEntry.js.map +1 -0
  79. package/lib/module/DataModels/SpikeHeartDataEntry.js +2 -0
  80. package/lib/module/DataModels/SpikeHeartDataEntry.js.map +1 -0
  81. package/lib/module/DataModels/SpikeOxygenSaturationDataEntry.js +2 -0
  82. package/lib/module/DataModels/SpikeOxygenSaturationDataEntry.js.map +1 -0
  83. package/lib/module/DataModels/SpikeSleepDataEntry.js +2 -0
  84. package/lib/module/DataModels/SpikeSleepDataEntry.js.map +1 -0
  85. package/lib/module/DataModels/SpikeStepsDataEntry.js +2 -0
  86. package/lib/module/DataModels/SpikeStepsDataEntry.js.map +1 -0
  87. package/lib/module/DataModels/SpikeStepsIntradayDataEntry.js +2 -0
  88. package/lib/module/DataModels/SpikeStepsIntradayDataEntry.js.map +1 -0
  89. package/lib/module/DataModels/SpikeWebhookJob.js +2 -0
  90. package/lib/module/DataModels/SpikeWebhookJob.js.map +1 -0
  91. package/lib/module/DataTypes/SpikeDataType.js +42 -0
  92. package/lib/module/DataTypes/SpikeDataType.js.map +1 -0
  93. package/lib/module/Spike.js +108 -0
  94. package/lib/module/Spike.js.map +1 -0
  95. package/lib/module/SpikeBackgroundDeliveriesLogger.js +2 -0
  96. package/lib/module/SpikeBackgroundDeliveriesLogger.js.map +1 -0
  97. package/lib/module/SpikeConnection.js +293 -0
  98. package/lib/module/SpikeConnection.js.map +1 -0
  99. package/lib/module/SpikeConnectionTypes.js +4 -0
  100. package/lib/module/SpikeConnectionTypes.js.map +1 -0
  101. package/lib/module/SpikeException.js +94 -0
  102. package/lib/module/SpikeException.js.map +1 -0
  103. package/lib/module/SpikeLogger.js +4 -0
  104. package/lib/module/SpikeLogger.js.map +1 -0
  105. package/lib/module/SpikeSdk.js +5 -0
  106. package/lib/module/SpikeSdk.js.map +1 -0
  107. package/lib/module/index.js +36 -0
  108. package/lib/module/index.js.map +1 -0
  109. package/lib/module/v3/Conversion.js +48 -0
  110. package/lib/module/v3/Conversion.js.map +1 -0
  111. package/lib/module/v3/DataModels/ActivityAdditionalData.js +14 -0
  112. package/lib/module/v3/DataModels/ActivityAdditionalData.js.map +1 -0
  113. package/lib/module/v3/DataModels/ActivityConfig.js +12 -0
  114. package/lib/module/v3/DataModels/ActivityConfig.js.map +1 -0
  115. package/lib/module/v3/DataModels/ActivityEntry.js +2 -0
  116. package/lib/module/v3/DataModels/ActivityEntry.js.map +1 -0
  117. package/lib/module/v3/DataModels/ActivitySamples.js +2 -0
  118. package/lib/module/v3/DataModels/ActivitySamples.js.map +1 -0
  119. package/lib/module/v3/DataModels/ActivityTag.js +28 -0
  120. package/lib/module/v3/DataModels/ActivityTag.js.map +1 -0
  121. package/lib/module/v3/DataModels/ActivityType.js +149 -0
  122. package/lib/module/v3/DataModels/ActivityType.js.map +1 -0
  123. package/lib/module/v3/DataModels/BackgroundDeliveryConfig.js +4 -0
  124. package/lib/module/v3/DataModels/BackgroundDeliveryConfig.js.map +1 -0
  125. package/lib/module/v3/DataModels/Gender.js +11 -0
  126. package/lib/module/v3/DataModels/Gender.js.map +1 -0
  127. package/lib/module/v3/DataModels/HealthConnectAvailabilityStatus.js +9 -0
  128. package/lib/module/v3/DataModels/HealthConnectAvailabilityStatus.js.map +1 -0
  129. package/lib/module/v3/DataModels/InputMethod.js +11 -0
  130. package/lib/module/v3/DataModels/InputMethod.js.map +1 -0
  131. package/lib/module/v3/DataModels/LogLevel.js +12 -0
  132. package/lib/module/v3/DataModels/LogLevel.js.map +1 -0
  133. package/lib/module/v3/DataModels/MetricType.js +70 -0
  134. package/lib/module/v3/DataModels/MetricType.js.map +1 -0
  135. package/lib/module/v3/DataModels/Provider.js +21 -0
  136. package/lib/module/v3/DataModels/Provider.js.map +1 -0
  137. package/lib/module/v3/DataModels/ProviderSource.js +48 -0
  138. package/lib/module/v3/DataModels/ProviderSource.js.map +1 -0
  139. package/lib/module/v3/DataModels/RecordSource.js +2 -0
  140. package/lib/module/v3/DataModels/RecordSource.js.map +1 -0
  141. package/lib/module/v3/DataModels/SamsungHealthDataAvailability.js +4 -0
  142. package/lib/module/v3/DataModels/SamsungHealthDataAvailability.js.map +1 -0
  143. package/lib/module/v3/DataModels/SamsungHealthDataAvailabilityStatus.js +33 -0
  144. package/lib/module/v3/DataModels/SamsungHealthDataAvailabilityStatus.js.map +1 -0
  145. package/lib/module/v3/DataModels/SleepConfig.js +10 -0
  146. package/lib/module/v3/DataModels/SleepConfig.js.map +1 -0
  147. package/lib/module/v3/DataModels/SpikeRecord.js +4 -0
  148. package/lib/module/v3/DataModels/SpikeRecord.js.map +1 -0
  149. package/lib/module/v3/DataModels/Statistic.js +4 -0
  150. package/lib/module/v3/DataModels/Statistic.js.map +1 -0
  151. package/lib/module/v3/DataModels/StatisticsInterval.js +10 -0
  152. package/lib/module/v3/DataModels/StatisticsInterval.js.map +1 -0
  153. package/lib/module/v3/DataModels/StatisticsType.js +23 -0
  154. package/lib/module/v3/DataModels/StatisticsType.js.map +1 -0
  155. package/lib/module/v3/DataModels/UUID.js +2 -0
  156. package/lib/module/v3/DataModels/UUID.js.map +1 -0
  157. package/lib/module/v3/DataModels/Unit.js +17 -0
  158. package/lib/module/v3/DataModels/Unit.js.map +1 -0
  159. package/lib/module/v3/DataModels/UserInfoResponse.js +4 -0
  160. package/lib/module/v3/DataModels/UserInfoResponse.js.map +1 -0
  161. package/lib/module/v3/DataModels/UserProperties.js +4 -0
  162. package/lib/module/v3/DataModels/UserProperties.js.map +1 -0
  163. package/lib/module/v3/SpikeRNConnectionAPIv3.js +389 -0
  164. package/lib/module/v3/SpikeRNConnectionAPIv3.js.map +1 -0
  165. package/lib/module/v3/StatisticsFilter.js +15 -0
  166. package/lib/module/v3/StatisticsFilter.js.map +1 -0
  167. package/lib/module/version.js +5 -0
  168. package/lib/module/version.js.map +1 -0
  169. package/lib/typescript/version.d.ts +1 -1
  170. package/lib/typescript/version.d.ts.map +1 -1
  171. package/package.json +2 -1
  172. package/src/version.ts +1 -1
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeActivitiesStreamDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeActivitiesSummaryDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeBodyDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeBreathingDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeCaloriesDataEntry.js.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=SpikeData.js.map
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SpikeDataTypes = void 0;
7
+ var _SpikeDataType = require("../DataTypes/SpikeDataType");
8
+ const SpikeDataTypes = exports.SpikeDataTypes = {
9
+ activitiesSummary: new _SpikeDataType.SpikeActivitiesSummaryDataType(),
10
+ activitiesStream: new _SpikeDataType.SpikeActivitiesStreamDataType(),
11
+ breathing: new _SpikeDataType.SpikeBreathingDataType(),
12
+ calories: new _SpikeDataType.SpikeCaloriesDataType(),
13
+ distance: new _SpikeDataType.SpikeDistanceDataType(),
14
+ glucose: new _SpikeDataType.SpikeGlucoseDataType(),
15
+ heart: new _SpikeDataType.SpikeHeartDataType(),
16
+ oxygenSaturation: new _SpikeDataType.SpikeOxygenSaturationDataType(),
17
+ sleep: new _SpikeDataType.SpikeSleepDataType(),
18
+ steps: new _SpikeDataType.SpikeStepsDataType(),
19
+ stepsIntraday: new _SpikeDataType.SpikeStepsIntradayDataType(),
20
+ body: new _SpikeDataType.SpikeBodyDataType(),
21
+ ecg: new _SpikeDataType.SpikeEcgDataType()
22
+ };
23
+ //# sourceMappingURL=SpikeDataTypes.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeDistanceDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeEcgDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeGlucoseDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeHeartDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeOxygenSaturationDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeSleepDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeStepsDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeStepsIntradayDataEntry.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeWebhookJob.js.map
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SpikeStepsIntradayDataType = exports.SpikeStepsDataType = exports.SpikeSleepDataType = exports.SpikeOxygenSaturationDataType = exports.SpikeHeartDataType = exports.SpikeGlucoseDataType = exports.SpikeEcgDataType = exports.SpikeDistanceDataType = exports.SpikeCaloriesDataType = exports.SpikeBreathingDataType = exports.SpikeBodyDataType = exports.SpikeActivitiesSummaryDataType = exports.SpikeActivitiesStreamDataType = void 0;
7
+ class SpikeActivitiesStreamDataType {
8
+ rawValue = 'activities_stream';
9
+ }
10
+ exports.SpikeActivitiesStreamDataType = SpikeActivitiesStreamDataType;
11
+ class SpikeActivitiesSummaryDataType {
12
+ rawValue = 'activities_summary';
13
+ }
14
+ exports.SpikeActivitiesSummaryDataType = SpikeActivitiesSummaryDataType;
15
+ class SpikeBreathingDataType {
16
+ rawValue = 'breathing';
17
+ }
18
+ exports.SpikeBreathingDataType = SpikeBreathingDataType;
19
+ class SpikeCaloriesDataType {
20
+ rawValue = 'calories';
21
+ }
22
+ exports.SpikeCaloriesDataType = SpikeCaloriesDataType;
23
+ class SpikeDistanceDataType {
24
+ rawValue = 'distance';
25
+ }
26
+ exports.SpikeDistanceDataType = SpikeDistanceDataType;
27
+ class SpikeGlucoseDataType {
28
+ rawValue = 'glucose';
29
+ }
30
+ exports.SpikeGlucoseDataType = SpikeGlucoseDataType;
31
+ class SpikeHeartDataType {
32
+ rawValue = 'heart';
33
+ }
34
+ exports.SpikeHeartDataType = SpikeHeartDataType;
35
+ class SpikeOxygenSaturationDataType {
36
+ rawValue = 'oxygen_saturation';
37
+ }
38
+ exports.SpikeOxygenSaturationDataType = SpikeOxygenSaturationDataType;
39
+ class SpikeSleepDataType {
40
+ rawValue = 'sleep';
41
+ }
42
+ exports.SpikeSleepDataType = SpikeSleepDataType;
43
+ class SpikeStepsDataType {
44
+ rawValue = 'steps';
45
+ }
46
+ exports.SpikeStepsDataType = SpikeStepsDataType;
47
+ class SpikeStepsIntradayDataType {
48
+ rawValue = 'steps_intraday';
49
+ }
50
+ exports.SpikeStepsIntradayDataType = SpikeStepsIntradayDataType;
51
+ class SpikeBodyDataType {
52
+ rawValue = 'body';
53
+ }
54
+ exports.SpikeBodyDataType = SpikeBodyDataType;
55
+ class SpikeEcgDataType {
56
+ rawValue = 'ecg';
57
+ }
58
+ exports.SpikeEcgDataType = SpikeEcgDataType;
59
+ //# sourceMappingURL=SpikeDataType.js.map
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isPackageInstalled = exports.isHealthDataAvailable = exports.getBackgroundConnections = exports.ensurePermissionsAreGranted = exports.createConnectionAPIv3Legacy = exports.createConnectionAPIv3 = exports.createConnection = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _SpikeConnection = require("./SpikeConnection");
9
+ var _SpikeException = require("./SpikeException");
10
+ var _SpikeSdk = require("./SpikeSdk");
11
+ var _SpikeRNConnectionAPIv = require("./v3/SpikeRNConnectionAPIv3");
12
+ var _version = require("./version");
13
+ const createConnection = async (config, logger) => {
14
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
15
+ try {
16
+ const connectionUUID = generateUUID();
17
+ const spikeConnection = new _SpikeConnection.SpikeConnection(connectionUUID, logger);
18
+ await _SpikeSdk.SpikeSdk.createConnection(connectionUUID, config.appId, config.authToken, config.customerEndUserId, config.callbackUrl ?? null, !!logger);
19
+ return spikeConnection;
20
+ } catch (error) {
21
+ throw (0, _SpikeException.unwrapSpikeException)(error);
22
+ }
23
+ };
24
+ exports.createConnection = createConnection;
25
+ const getBackgroundConnections = async () => {
26
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
27
+ try {
28
+ const connectionUUIDs = await _SpikeSdk.SpikeSdk.getBackgroundConnections();
29
+ const connections = connectionUUIDs.map(uuid => new _SpikeConnection.SpikeConnection(uuid));
30
+ return connections;
31
+ } catch (error) {
32
+ throw (0, _SpikeException.unwrapSpikeException)(error);
33
+ }
34
+ };
35
+ exports.getBackgroundConnections = getBackgroundConnections;
36
+ const ensurePermissionsAreGranted = async permissions => {
37
+ if (_reactNative.Platform.OS !== 'ios') return;
38
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
39
+ try {
40
+ await _SpikeSdk.SpikeSdk.ensurePermissionsAreGranted(permissions.map(permissionType => permissionType.rawValue));
41
+ } catch (error) {
42
+ throw (0, _SpikeException.unwrapSpikeException)(error);
43
+ }
44
+ };
45
+ exports.ensurePermissionsAreGranted = ensurePermissionsAreGranted;
46
+ const isPackageInstalled = async () => {
47
+ if (_reactNative.Platform.OS !== 'android') return true;
48
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
49
+ try {
50
+ return await _SpikeSdk.SpikeSdk.isPackageInstalled();
51
+ } catch (error) {
52
+ throw (0, _SpikeException.unwrapSpikeException)(error);
53
+ }
54
+ };
55
+ exports.isPackageInstalled = isPackageInstalled;
56
+ const isHealthDataAvailable = async () => {
57
+ if (_reactNative.Platform.OS !== 'ios') return true;
58
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
59
+ try {
60
+ return await _SpikeSdk.SpikeSdk.isHealthDataAvailable();
61
+ } catch (error) {
62
+ throw (0, _SpikeException.unwrapSpikeException)(error);
63
+ }
64
+ };
65
+ exports.isHealthDataAvailable = isHealthDataAvailable;
66
+ function generateUUID() {
67
+ const S4 = function () {
68
+ let str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXZ';
69
+ let uuid = [];
70
+ for (let i = 0; i < 4; i++) {
71
+ uuid.push(str[Math.floor(Math.random() * str.length)]);
72
+ }
73
+ return uuid.join('');
74
+ };
75
+ return S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4();
76
+ }
77
+
78
+ // -------------------------- SpikeConnectionAPIv3 --------------------------
79
+
80
+ const createConnectionAPIv3 = async ({
81
+ applicationId,
82
+ signature,
83
+ endUserId
84
+ }) => {
85
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException("No SpikeSDK found");
86
+ try {
87
+ await _SpikeSdk.SpikeSdk.setWrapper("RN", _version.SPIKE_SDK_VERSION);
88
+ const connectionUUID = generateUUID();
89
+ await _SpikeSdk.SpikeSdk.createConnectionAPIv3(connectionUUID, applicationId, signature, endUserId);
90
+ const spikeConnection = new _SpikeRNConnectionAPIv.SpikeRNConnectionAPIv3(connectionUUID);
91
+ return spikeConnection;
92
+ } catch (error) {
93
+ throw (0, _SpikeException.unwrapSpikeException)(error);
94
+ }
95
+ };
96
+ exports.createConnectionAPIv3 = createConnectionAPIv3;
97
+ const createConnectionAPIv3Legacy = async ({
98
+ appId,
99
+ authToken,
100
+ customerEndUserId
101
+ }) => {
102
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException("No SpikeSDK found");
103
+ try {
104
+ await _SpikeSdk.SpikeSdk.setWrapper("RN", _version.SPIKE_SDK_VERSION);
105
+ const connectionUUID = generateUUID();
106
+ await _SpikeSdk.SpikeSdk.createConnectionAPIv3Legacy(connectionUUID, appId, authToken, customerEndUserId);
107
+ const spikeConnection = new _SpikeRNConnectionAPIv.SpikeRNConnectionAPIv3(connectionUUID);
108
+ return spikeConnection;
109
+ } catch (error) {
110
+ throw (0, _SpikeException.unwrapSpikeException)(error);
111
+ }
112
+ };
113
+
114
+ // -------------------------- end of SpikeConnectionAPIv3 --------------------------
115
+ exports.createConnectionAPIv3Legacy = createConnectionAPIv3Legacy;
116
+ //# sourceMappingURL=Spike.js.map
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=SpikeBackgroundDeliveriesLogger.js.map
@@ -0,0 +1,298 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.SpikeConnection = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _SpikeException = require("./SpikeException");
9
+ var _SpikeSdk = require("./SpikeSdk");
10
+ var _SpikeDataType = require("./DataTypes/SpikeDataType");
11
+ class SpikeConnection {
12
+ backgroundLogger = null;
13
+ logger = null;
14
+ toString() {
15
+ return 'This is wrapper class. To get connection data use `getAppId()`, `getSpikeEndUserId()`, `getCustomerEndUserId()` methods.';
16
+ }
17
+ toJSON() {
18
+ return JSON.stringify({
19
+ warning: 'This is wrapper class. To get connection data use `getAppId()`, `getSpikeEndUserId()`, `getCustomerEndUserId()` methods.'
20
+ });
21
+ }
22
+ constructor(connectionUUID, logger = null) {
23
+ this.connectionUUID = connectionUUID;
24
+ this.setupLogger(logger);
25
+ }
26
+ async manageHealthConnect() {
27
+ if (_reactNative.Platform.OS !== 'android') return;
28
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
29
+ try {
30
+ return await _SpikeSdk.SpikeSdk.manageHealthConnect(this.connectionUUID);
31
+ } catch (error) {
32
+ throw (0, _SpikeException.unwrapSpikeException)(error);
33
+ }
34
+ }
35
+ async checkPermissionsGranted(dataTypes) {
36
+ if (_reactNative.Platform.OS !== 'android') return false;
37
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
38
+ try {
39
+ return await _SpikeSdk.SpikeSdk.checkPermissionsGranted(this.connectionUUID, dataTypes.rawValue);
40
+ } catch (error) {
41
+ throw (0, _SpikeException.unwrapSpikeException)(error);
42
+ }
43
+ }
44
+ async requestHealthPermissions(dataTypes) {
45
+ if (_reactNative.Platform.OS !== 'android') return;
46
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
47
+ if (Array.isArray(dataTypes)) {
48
+ try {
49
+ return await _SpikeSdk.SpikeSdk.requestMultipleHealthPermissions(this.connectionUUID, dataTypes.map(type => type.rawValue));
50
+ } catch (error) {
51
+ throw (0, _SpikeException.unwrapSpikeException)(error);
52
+ }
53
+ }
54
+ try {
55
+ return await _SpikeSdk.SpikeSdk.requestHealthPermissions(this.connectionUUID, dataTypes.rawValue);
56
+ } catch (error) {
57
+ throw (0, _SpikeException.unwrapSpikeException)(error);
58
+ }
59
+ }
60
+ async revokeAllPermissions() {
61
+ if (_reactNative.Platform.OS !== 'android') return;
62
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
63
+ try {
64
+ return await _SpikeSdk.SpikeSdk.revokeAllPermissions(this.connectionUUID);
65
+ } catch (error) {
66
+ throw (0, _SpikeException.unwrapSpikeException)(error);
67
+ }
68
+ }
69
+ async getHealthConnectAvailability() {
70
+ if (_reactNative.Platform.OS !== 'android') return 'notInstalled';
71
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
72
+ try {
73
+ return await _SpikeSdk.SpikeSdk.getHealthConnectAvailability(this.connectionUUID);
74
+ } catch (error) {
75
+ throw (0, _SpikeException.unwrapSpikeException)(error);
76
+ }
77
+ }
78
+ async getAppId() {
79
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
80
+ try {
81
+ return await _SpikeSdk.SpikeSdk.getAppId(this.connectionUUID);
82
+ } catch (error) {
83
+ throw (0, _SpikeException.unwrapSpikeException)(error);
84
+ }
85
+ }
86
+ async getSpikeEndUserId() {
87
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
88
+ try {
89
+ return await _SpikeSdk.SpikeSdk.getSpikeEndUserId(this.connectionUUID);
90
+ } catch (error) {
91
+ throw (0, _SpikeException.unwrapSpikeException)(error);
92
+ }
93
+ }
94
+ async getCustomerEndUserId() {
95
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
96
+ try {
97
+ return await _SpikeSdk.SpikeSdk.getCustomerEndUserId(this.connectionUUID);
98
+ } catch (error) {
99
+ throw (0, _SpikeException.unwrapSpikeException)(error);
100
+ }
101
+ }
102
+ async getCallbackUrl() {
103
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
104
+ try {
105
+ return await _SpikeSdk.SpikeSdk.getCallbackUrl(this.connectionUUID);
106
+ } catch (error) {
107
+ throw (0, _SpikeException.unwrapSpikeException)(error);
108
+ }
109
+ }
110
+ async close() {
111
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
112
+ try {
113
+ await _SpikeSdk.SpikeSdk.close(this.connectionUUID);
114
+ this.removeListeners();
115
+ } catch (error) {
116
+ throw (0, _SpikeException.unwrapSpikeException)(error);
117
+ }
118
+ }
119
+ async extractData(config) {
120
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
121
+ if (_reactNative.Platform.OS === 'android' && config.dataType.rawValue === 'ecg') {
122
+ let dateFrom;
123
+ let dateTo;
124
+ let collectedAt = new Date();
125
+ if ('from' in config) {
126
+ dateFrom = config.from;
127
+ dateTo = config.to;
128
+ } else {
129
+ dateFrom = new Date();
130
+ dateTo = new Date();
131
+ }
132
+ const result = {
133
+ dateFrom: dateFrom.toISOString(),
134
+ dateTo: dateTo.toISOString(),
135
+ collectedAt: collectedAt.toISOString(),
136
+ endUserId: await this.getSpikeEndUserId(),
137
+ sources: [{
138
+ name: 'android',
139
+ isSuccess: false,
140
+ message: 'No ECG data on android health connect'
141
+ }],
142
+ entries: []
143
+ };
144
+ return result;
145
+ }
146
+ try {
147
+ let json = '';
148
+ if ('from' in config) {
149
+ json = await _SpikeSdk.SpikeSdk.extractDataInRange(this.connectionUUID, config.dataType.rawValue, config.from.getTime(), config.to.getTime());
150
+ } else {
151
+ json = await _SpikeSdk.SpikeSdk.extractData(this.connectionUUID, config.dataType.rawValue);
152
+ }
153
+ const data = JSON.parse(json);
154
+ return data;
155
+ } catch (error) {
156
+ throw (0, _SpikeException.unwrapSpikeException)(error);
157
+ }
158
+ }
159
+ async extractAndPostData(config) {
160
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
161
+ if (_reactNative.Platform.OS === 'android' && config.dataType.rawValue === 'ecg') {
162
+ let dateFrom;
163
+ let dateTo;
164
+ let collectedAt = new Date();
165
+ if ('from' in config) {
166
+ dateFrom = config.from;
167
+ dateTo = config.to;
168
+ } else {
169
+ dateFrom = new Date();
170
+ dateTo = new Date();
171
+ }
172
+ const result = {
173
+ dataType: config.dataType.rawValue,
174
+ payloadSize: 0,
175
+ callbackUrl: new URL(await this.getCallbackUrl()),
176
+ dateFrom: dateFrom,
177
+ dateTo: dateTo,
178
+ collectedAt: collectedAt
179
+ };
180
+ return result;
181
+ }
182
+ try {
183
+ let json = '';
184
+ if ('from' in config) {
185
+ json = await _SpikeSdk.SpikeSdk.extractAndPostDataInRange(this.connectionUUID, config.dataType.rawValue, config.from.getTime(), config.to.getTime());
186
+ } else {
187
+ json = await _SpikeSdk.SpikeSdk.extractAndPostData(this.connectionUUID, config.dataType.rawValue);
188
+ }
189
+ const data = JSON.parse(json);
190
+ return data;
191
+ } catch (error) {
192
+ throw (0, _SpikeException.unwrapSpikeException)(error);
193
+ }
194
+ }
195
+ async enableBackgroundDelivery(dataTypes) {
196
+ if (_reactNative.Platform.OS !== 'ios') return;
197
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
198
+ try {
199
+ await _SpikeSdk.SpikeSdk.enableBackgroundDelivery(this.connectionUUID, dataTypes.map(type => type.rawValue));
200
+ } catch (error) {
201
+ throw (0, _SpikeException.unwrapSpikeException)(error);
202
+ }
203
+ }
204
+ async getBackgroundDeliveryDataTypes() {
205
+ if (_reactNative.Platform.OS !== 'ios') return [];
206
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
207
+ const dataTypes = await _SpikeSdk.SpikeSdk.getBackgroundDeliveryDataTypes(this.connectionUUID);
208
+ return dataTypes.map(type => this.convertDataType(type));
209
+ }
210
+ async setListener(listener) {
211
+ if (_reactNative.Platform.OS !== 'ios') return;
212
+ if (!_SpikeSdk.SpikeSdk) throw new _SpikeException.SpikeException();
213
+ try {
214
+ this.setupListener(listener);
215
+ await _SpikeSdk.SpikeSdk.setListener(this.connectionUUID);
216
+ } catch (error) {
217
+ throw (0, _SpikeException.unwrapSpikeException)(error);
218
+ }
219
+ }
220
+ setupLogger(logger) {
221
+ if (!_SpikeSdk.SpikeSdk) return;
222
+ this.removeLogger();
223
+ if (!logger) return;
224
+ this.logEventListener = new _reactNative.NativeEventEmitter(_SpikeSdk.SpikeSdk);
225
+ this.logger = logger;
226
+ this.logEventListener?.addListener('onDebug', data => {
227
+ if (this.connectionUUID !== data.connectionUUID) return;
228
+ if (logger?.isDebugEnabled() === true) {
229
+ logger?.debug(this, data.message);
230
+ }
231
+ });
232
+ this.logEventListener?.addListener('onInfo', data => {
233
+ if (!!logger && this.connectionUUID !== data.connectionUUID) return;
234
+ if (logger?.isInfoEnabled() === true) {
235
+ logger?.info(this, data.message);
236
+ }
237
+ });
238
+ this.logEventListener?.addListener('onError', data => {
239
+ if (this.connectionUUID !== data.connectionUUID) return;
240
+ if (logger?.isErrorEnabled() === true) {
241
+ logger?.error(this, data.message);
242
+ }
243
+ });
244
+ }
245
+ removeLogger() {
246
+ if (!this.logEventListener) return;
247
+ this.logEventListener.removeAllListeners('onDebug');
248
+ this.logEventListener.removeAllListeners('onInfo');
249
+ this.logEventListener.removeAllListeners('onError');
250
+ this.logEventListener = undefined;
251
+ this.logger = null;
252
+ }
253
+ setupListener(listener) {
254
+ if (!_SpikeSdk.SpikeSdk) return;
255
+ this.removeListeners();
256
+ this.eventListener = new _reactNative.NativeEventEmitter(_SpikeSdk.SpikeSdk);
257
+ this.backgroundLogger = listener;
258
+ this.eventListener?.addListener('onBackgroundLog', data => {
259
+ if (this.connectionUUID !== data.connectionUUID) return;
260
+ this.backgroundLogger?.onBackgroundLog(data.log);
261
+ });
262
+ }
263
+ removeListeners() {
264
+ if (!this.eventListener) return;
265
+ this.eventListener.removeAllListeners('onBackgroundLog');
266
+ this.eventListener = undefined;
267
+ }
268
+ convertDataType(dataType) {
269
+ if (dataType === 'activities_summary') {
270
+ return new _SpikeDataType.SpikeActivitiesSummaryDataType();
271
+ } else if (dataType === 'activities_stream') {
272
+ return new _SpikeDataType.SpikeActivitiesStreamDataType();
273
+ } else if (dataType === 'breathing') {
274
+ return new _SpikeDataType.SpikeBreathingDataType();
275
+ } else if (dataType === 'calories') {
276
+ return new _SpikeDataType.SpikeCaloriesDataType();
277
+ } else if (dataType === 'distance') {
278
+ return new _SpikeDataType.SpikeDistanceDataType();
279
+ } else if (dataType === 'glucose') {
280
+ return new _SpikeDataType.SpikeGlucoseDataType();
281
+ } else if (dataType === 'heart') {
282
+ return new _SpikeDataType.SpikeHeartDataType();
283
+ } else if (dataType === 'oxygen_saturation') {
284
+ return new _SpikeDataType.SpikeOxygenSaturationDataType();
285
+ } else if (dataType === 'sleep') {
286
+ return new _SpikeDataType.SpikeSleepDataType();
287
+ } else if (dataType === 'steps') {
288
+ return new _SpikeDataType.SpikeStepsDataType();
289
+ } else if (dataType === 'body') {
290
+ return new _SpikeDataType.SpikeBodyDataType();
291
+ } else if (dataType === 'ecg') {
292
+ return new _SpikeDataType.SpikeEcgDataType();
293
+ }
294
+ return new _SpikeDataType.SpikeStepsDataType();
295
+ }
296
+ }
297
+ exports.SpikeConnection = SpikeConnection;
298
+ //# sourceMappingURL=SpikeConnection.js.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=SpikeConnectionTypes.js.map