hypertrack-sdk-react-native 13.5.0 → 13.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/android/gradle.properties +1 -1
  2. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackReactNativePlugin.kt +40 -37
  3. package/android/src/main/java/com/reactnativehypertracksdk/HyperTrackSdkPackage.kt +3 -6
  4. package/android/src/main/java/com/reactnativehypertracksdk/ReactNativeSerialization.kt +2 -3
  5. package/android/src/main/java/com/reactnativehypertracksdk/common/HyperTrackSdkWrapper.kt +42 -65
  6. package/android/src/main/java/com/reactnativehypertracksdk/common/Serialization.kt +69 -103
  7. package/android/src/main/java/com/reactnativehypertracksdk/common/WrapperResult.kt +14 -14
  8. package/hypertrack-sdk-react-native.podspec +1 -1
  9. package/lib/commonjs/HyperTrack/HyperTrack.js +5 -1
  10. package/lib/commonjs/HyperTrack/HyperTrack.js.map +1 -1
  11. package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
  12. package/lib/commonjs/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
  13. package/lib/commonjs/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
  14. package/lib/module/HyperTrack/HyperTrack.js +5 -1
  15. package/lib/module/HyperTrack/HyperTrack.js.map +1 -1
  16. package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js +2 -0
  17. package/lib/module/HyperTrack/data_types/internal/IsInsideGeofence.js.map +1 -0
  18. package/lib/module/HyperTrack/data_types/internal/OrderInternal.js.map +1 -1
  19. package/lib/typescript/HyperTrack/data_types/internal/IsInsideGeofence.d.ts +4 -0
  20. package/lib/typescript/HyperTrack/data_types/internal/OrderInternal.d.ts +2 -1
  21. package/package.json +1 -1
  22. package/src/HyperTrack/HyperTrack.ts +7 -2
  23. package/src/HyperTrack/data_types/internal/IsInsideGeofence.ts +4 -0
  24. package/src/HyperTrack/data_types/internal/OrderInternal.ts +2 -1
  25. package/android/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock +0 -0
  26. package/android/.gradle/7.2/dependencies-accessors/gc.properties +0 -0
  27. package/android/.gradle/7.2/fileChanges/last-build.bin +0 -0
  28. package/android/.gradle/7.2/fileHashes/fileHashes.lock +0 -0
  29. package/android/.gradle/7.2/gc.properties +0 -0
  30. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  31. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  32. package/android/.gradle/checksums/checksums.lock +0 -0
  33. package/android/.gradle/vcs-1/gc.properties +0 -0
  34. package/android/.idea/gradle.xml +0 -15
  35. package/android/.idea/misc.xml +0 -9
  36. package/android/.idea/vcs.xml +0 -6
  37. package/android/local.properties +0 -8
@@ -9,17 +9,16 @@ import com.hypertrack.sdk.android.Result
9
9
  * to Map<String, T> or List<T> where T is any JSON-compatible type
10
10
  */
11
11
  internal object Serialization {
12
- fun deserializeDynamicPublishableKey(args: Serialized): WrapperResult<String> {
13
- return parse(args) {
12
+ fun deserializeDynamicPublishableKey(args: Serialized): WrapperResult<String> =
13
+ parse(args) {
14
14
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_DYNAMIC_PUBLISHABLE_KEY)
15
15
  it
16
16
  .get<String>(KEY_VALUE)
17
17
  .getOrThrow()
18
18
  }
19
- }
20
19
 
21
- fun deserializeGeotagData(map: Serialized): WrapperResult<GeotagData> {
22
- return parse(map) {
20
+ fun deserializeGeotagData(map: Serialized): WrapperResult<GeotagData> =
21
+ parse(map) {
23
22
  val data =
24
23
  it
25
24
  .get<Serialized>(KEY_GEOTAG_DATA)
@@ -49,69 +48,61 @@ internal object Serialization {
49
48
  orderStatus = orderStatus,
50
49
  )
51
50
  }
52
- }
53
51
 
54
- fun deserializeIsAvailable(isAvailable: Serialized): WrapperResult<Boolean> {
55
- return parse(isAvailable) {
52
+ fun deserializeIsAvailable(isAvailable: Serialized): WrapperResult<Boolean> =
53
+ parse(isAvailable) {
56
54
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_AVAILABLE)
57
55
  it
58
56
  .get<Boolean>(KEY_VALUE)
59
57
  .getOrThrow()
60
58
  }
61
- }
62
59
 
63
- fun deserializeIsTracking(isTracking: Serialized): WrapperResult<Boolean> {
64
- return parse(isTracking) {
60
+ fun deserializeIsTracking(isTracking: Serialized): WrapperResult<Boolean> =
61
+ parse(isTracking) {
65
62
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_IS_TRACKING)
66
63
  it
67
64
  .get<Boolean>(KEY_VALUE)
68
65
  .getOrThrow()
69
66
  }
70
- }
71
67
 
72
- fun deserializeMetadata(metadata: Serialized): WrapperResult<Serialized> {
73
- return parse(metadata) {
68
+ fun deserializeMetadata(metadata: Serialized): WrapperResult<Serialized> =
69
+ parse(metadata) {
74
70
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_METADATA)
75
71
  it
76
72
  .get<Serialized>(KEY_VALUE)
77
73
  .getOrThrow()
78
74
  }
79
- }
80
75
 
81
- fun deserializeName(name: Serialized): WrapperResult<String> {
82
- return parse(name) {
76
+ fun deserializeName(name: Serialized): WrapperResult<String> =
77
+ parse(name) {
83
78
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_NAME)
84
79
  it
85
80
  .get<String>(KEY_VALUE)
86
81
  .getOrThrow()
87
82
  }
88
- }
89
83
 
90
- fun deserializeWorkerHandle(map: Serialized): WrapperResult<String> {
91
- return parse(map) {
84
+ fun deserializeWorkerHandle(map: Serialized): WrapperResult<String> =
85
+ parse(map) {
92
86
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_WORKER_HANDLE)
93
87
  it
94
88
  .get<String>(KEY_VALUE)
95
89
  .getOrThrow()
96
90
  }
97
- }
98
91
 
99
- fun serializeDeviceId(deviceId: String): Serialized {
100
- return mapOf(
92
+ fun serializeDeviceId(deviceId: String): Serialized =
93
+ mapOf(
101
94
  KEY_TYPE to TYPE_DEVICE_ID,
102
95
  KEY_VALUE to deviceId,
103
96
  )
104
- }
105
97
 
106
- fun serializeDynamicPublishableKey(publishableKey: String): Serialized {
107
- return mapOf(
98
+ fun serializeDynamicPublishableKey(publishableKey: String): Serialized =
99
+ mapOf(
108
100
  KEY_TYPE to TYPE_DYNAMIC_PUBLISHABLE_KEY,
109
101
  KEY_VALUE to publishableKey,
110
102
  )
111
- }
112
103
 
113
- fun serializeError(error: HyperTrack.Error): Map<String, String> {
114
- return mapOf(
104
+ fun serializeError(error: HyperTrack.Error): Map<String, String> =
105
+ mapOf(
115
106
  KEY_TYPE to TYPE_ERROR,
116
107
  KEY_VALUE to
117
108
  when (error) {
@@ -128,30 +119,26 @@ internal object Serialization {
128
119
  HyperTrack.Error.Permissions.Notifications.Denied -> "permissions.notifications.denied"
129
120
  },
130
121
  )
131
- }
132
122
 
133
- fun serializeErrors(errors: Set<HyperTrack.Error>): List<Map<String, String>> {
134
- return errors.map {
123
+ fun serializeErrors(errors: Set<HyperTrack.Error>): List<Map<String, String>> =
124
+ errors.map {
135
125
  serializeError(it)
136
126
  }
137
- }
138
127
 
139
- fun serializeIsAvailable(isAvailable: Boolean): Serialized {
140
- return mapOf(
128
+ fun serializeIsAvailable(isAvailable: Boolean): Serialized =
129
+ mapOf(
141
130
  KEY_TYPE to TYPE_IS_AVAILABLE,
142
131
  KEY_VALUE to isAvailable,
143
132
  )
144
- }
145
133
 
146
- fun serializeIsTracking(isTracking: Boolean): Serialized {
147
- return mapOf(
134
+ fun serializeIsTracking(isTracking: Boolean): Serialized =
135
+ mapOf(
148
136
  KEY_TYPE to TYPE_IS_TRACKING,
149
137
  KEY_VALUE to isTracking,
150
138
  )
151
- }
152
139
 
153
- fun serializeLocateResult(locationResult: Result<HyperTrack.Location, Set<HyperTrack.Error>>): Serialized {
154
- return when (locationResult) {
140
+ fun serializeLocateResult(locationResult: Result<HyperTrack.Location, Set<HyperTrack.Error>>): Serialized =
141
+ when (locationResult) {
155
142
  is Result.Failure -> {
156
143
  serializeFailure(serializeErrors(locationResult.failure))
157
144
  }
@@ -160,10 +147,9 @@ internal object Serialization {
160
147
  serializeLocationSuccess(locationResult.success)
161
148
  }
162
149
  }
163
- }
164
150
 
165
- fun serializeLocationResult(locationResult: Result<HyperTrack.Location, HyperTrack.LocationError>): Serialized {
166
- return when (locationResult) {
151
+ fun serializeLocationResult(locationResult: Result<HyperTrack.Location, HyperTrack.LocationError>): Serialized =
152
+ when (locationResult) {
167
153
  is Result.Failure -> {
168
154
  serializeLocationErrorFailure(locationResult.failure)
169
155
  }
@@ -172,40 +158,33 @@ internal object Serialization {
172
158
  serializeLocationSuccess(locationResult.success)
173
159
  }
174
160
  }
175
- }
176
161
 
177
- fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Serialized {
178
- return serializeFailure(serializeLocationError(locationError))
179
- }
162
+ fun serializeLocationErrorFailure(locationError: HyperTrack.LocationError): Serialized =
163
+ serializeFailure(serializeLocationError(locationError))
180
164
 
181
- fun serializeLocationSuccess(location: HyperTrack.Location): Serialized {
182
- return serializeSuccess(serializeLocation(location))
183
- }
165
+ fun serializeLocationSuccess(location: HyperTrack.Location): Serialized = serializeSuccess(serializeLocation(location))
184
166
 
185
- fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized {
186
- return serializeSuccess(
167
+ fun serializeLocationWithDeviationSuccess(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized =
168
+ serializeSuccess(
187
169
  serializeLocationWithDeviation(
188
170
  locationWithDeviation,
189
171
  ),
190
172
  )
191
- }
192
173
 
193
- fun serializeMetadata(metadata: Serialized): Serialized {
194
- return mapOf(
174
+ fun serializeMetadata(metadata: Serialized): Serialized =
175
+ mapOf(
195
176
  KEY_TYPE to TYPE_METADATA,
196
177
  KEY_VALUE to metadata,
197
178
  )
198
- }
199
179
 
200
- fun serializeName(name: String): Serialized {
201
- return mapOf(
180
+ fun serializeName(name: String): Serialized =
181
+ mapOf(
202
182
  KEY_TYPE to TYPE_NAME,
203
183
  KEY_VALUE to name,
204
184
  )
205
- }
206
185
 
207
- fun serializeOrders(orders: Collection<HyperTrack.Order>): Serialized {
208
- return mapOf(
186
+ fun serializeOrders(orders: Collection<HyperTrack.Order>): Serialized =
187
+ mapOf(
209
188
  KEY_TYPE to TYPE_ORDERS,
210
189
  KEY_VALUE to
211
190
  orders.mapIndexed { index, order ->
@@ -216,17 +195,15 @@ internal object Serialization {
216
195
  )
217
196
  },
218
197
  )
219
- }
220
198
 
221
- fun serializeWorkerHandle(workerHandle: String): Serialized {
222
- return mapOf(
199
+ fun serializeWorkerHandle(workerHandle: String): Serialized =
200
+ mapOf(
223
201
  KEY_TYPE to TYPE_WORKER_HANDLE,
224
202
  KEY_VALUE to workerHandle,
225
203
  )
226
- }
227
204
 
228
- private fun deserializeLocation(map: Serialized): WrapperResult<Location> {
229
- return parse(map) {
205
+ private fun deserializeLocation(map: Serialized): WrapperResult<Location> =
206
+ parse(map) {
230
207
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_LOCATION)
231
208
  val value =
232
209
  it
@@ -247,19 +224,17 @@ internal object Serialization {
247
224
  }
248
225
  }.getOrThrow()
249
226
  }
250
- }
251
227
 
252
- private fun deserializeOrderHandle(map: Serialized): WrapperResult<String> {
253
- return parse(map) {
228
+ private fun deserializeOrderHandle(map: Serialized): WrapperResult<String> =
229
+ parse(map) {
254
230
  it.assertValue<String>(key = KEY_TYPE, value = TYPE_ORDER_HANDLE)
255
231
  it
256
232
  .get<String>(KEY_VALUE)
257
233
  .getOrThrow()
258
234
  }
259
- }
260
235
 
261
- private fun deserializeOrderStatus(map: Serialized): WrapperResult<HyperTrack.OrderStatus> {
262
- return parse(map) {
236
+ private fun deserializeOrderStatus(map: Serialized): WrapperResult<HyperTrack.OrderStatus> =
237
+ parse(map) {
263
238
  when (it.get<String>(KEY_TYPE).getOrThrow()) {
264
239
  TYPE_GEOTAG_ORDER_STATUS_CLOCK_IN -> HyperTrack.OrderStatus.ClockIn
265
240
  TYPE_GEOTAG_ORDER_STATUS_CLOCK_OUT -> HyperTrack.OrderStatus.ClockOut
@@ -271,10 +246,9 @@ internal object Serialization {
271
246
  else -> throw Error("Unknown order status: $map")
272
247
  }
273
248
  }
274
- }
275
249
 
276
- private fun serializeIsInsideGeofence(isInsideGeofence: Result<Boolean, HyperTrack.LocationError>): Serialized {
277
- return when (isInsideGeofence) {
250
+ private fun serializeIsInsideGeofence(isInsideGeofence: Result<Boolean, HyperTrack.LocationError>): Serialized =
251
+ when (isInsideGeofence) {
278
252
  is Result.Failure -> {
279
253
  serializeFailure(serializeLocationError(isInsideGeofence.failure))
280
254
  }
@@ -288,10 +262,9 @@ internal object Serialization {
288
262
  )
289
263
  }
290
264
  }
291
- }
292
265
 
293
- private fun serializeLocation(location: HyperTrack.Location): Serialized {
294
- return mapOf(
266
+ private fun serializeLocation(location: HyperTrack.Location): Serialized =
267
+ mapOf(
295
268
  KEY_TYPE to TYPE_LOCATION,
296
269
  KEY_VALUE to
297
270
  mapOf(
@@ -299,10 +272,9 @@ internal object Serialization {
299
272
  KEY_LONGITUDE to location.longitude,
300
273
  ),
301
274
  )
302
- }
303
275
 
304
- private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized {
305
- return mapOf(
276
+ private fun serializeLocationWithDeviation(locationWithDeviation: HyperTrack.LocationWithDeviation): Serialized =
277
+ mapOf(
306
278
  KEY_TYPE to TYPE_LOCATION_WITH_DEVIATION,
307
279
  KEY_VALUE to
308
280
  mapOf(
@@ -310,31 +282,27 @@ internal object Serialization {
310
282
  KEY_DEVIATION to locationWithDeviation.deviation,
311
283
  ),
312
284
  )
313
- }
314
285
 
315
- private fun serializeFailure(failure: List<Serialized>): Serialized {
316
- return mapOf(
286
+ private fun serializeFailure(failure: List<Serialized>): Serialized =
287
+ mapOf(
317
288
  KEY_TYPE to TYPE_RESULT_FAILURE,
318
289
  KEY_VALUE to failure,
319
290
  )
320
- }
321
291
 
322
- private fun serializeFailure(failure: Serialized): Serialized {
323
- return mapOf(
292
+ private fun serializeFailure(failure: Serialized): Serialized =
293
+ mapOf(
324
294
  KEY_TYPE to TYPE_RESULT_FAILURE,
325
295
  KEY_VALUE to failure,
326
296
  )
327
- }
328
297
 
329
- private fun serializeSuccess(success: Serialized): Serialized {
330
- return mapOf(
298
+ private fun serializeSuccess(success: Serialized): Serialized =
299
+ mapOf(
331
300
  KEY_TYPE to TYPE_RESULT_SUCCESS,
332
301
  KEY_VALUE to success,
333
302
  )
334
- }
335
303
 
336
- private fun serializeLocationError(locationError: HyperTrack.LocationError): Serialized {
337
- return when (locationError) {
304
+ private fun serializeLocationError(locationError: HyperTrack.LocationError): Serialized =
305
+ when (locationError) {
338
306
  HyperTrack.LocationError.NotRunning -> {
339
307
  mapOf(KEY_TYPE to TYPE_LOCATION_ERROR_NOT_RUNNING)
340
308
  }
@@ -352,7 +320,6 @@ internal object Serialization {
352
320
  )
353
321
  }
354
322
  }
355
- }
356
323
 
357
324
  fun <T> parse(
358
325
  source: Serialized,
@@ -382,8 +349,8 @@ internal object Serialization {
382
349
  private val _exceptions = mutableListOf<Exception>()
383
350
  val exceptions: List<Exception> = _exceptions
384
351
 
385
- inline fun <reified T> get(key: String): WrapperResult<T> {
386
- return try {
352
+ inline fun <reified T> get(key: String): WrapperResult<T> =
353
+ try {
387
354
  Success(source[key]!! as T)
388
355
  } catch (e: Exception) {
389
356
  Failure(
@@ -393,10 +360,9 @@ internal object Serialization {
393
360
  },
394
361
  )
395
362
  }
396
- }
397
363
 
398
- inline fun <reified T> getOptional(key: String): WrapperResult<T?> {
399
- return try {
364
+ inline fun <reified T> getOptional(key: String): WrapperResult<T?> =
365
+ try {
400
366
  Success(source[key] as T?)
401
367
  } catch (e: Exception) {
402
368
  Failure(
@@ -406,7 +372,6 @@ internal object Serialization {
406
372
  },
407
373
  )
408
374
  }
409
- }
410
375
 
411
376
  inline fun <reified T> assertValue(
412
377
  key: String,
@@ -422,7 +387,8 @@ internal object Serialization {
422
387
  val source: Any,
423
388
  val exceptions: List<Exception>,
424
389
  ) : Throwable(
425
- exceptions.joinToString("\n")
390
+ exceptions
391
+ .joinToString("\n")
426
392
  .let {
427
393
  "Invalid input:\n\n${source}\n\n$it"
428
394
  },
@@ -1,8 +1,8 @@
1
1
  package com.reactnativehypertracksdk.common
2
2
 
3
3
  internal sealed class WrapperResult<SuccessType> {
4
- fun <MappedSuccess> flatMapSuccess(onSuccess: (SuccessType) -> WrapperResult<MappedSuccess>): WrapperResult<MappedSuccess> {
5
- return when (this) {
4
+ fun <MappedSuccess> flatMapSuccess(onSuccess: (SuccessType) -> WrapperResult<MappedSuccess>): WrapperResult<MappedSuccess> =
5
+ when (this) {
6
6
  is Success -> {
7
7
  onSuccess.invoke(this.success)
8
8
  }
@@ -11,10 +11,9 @@ internal sealed class WrapperResult<SuccessType> {
11
11
  Failure<MappedSuccess>(this.failure)
12
12
  }
13
13
  }
14
- }
15
14
 
16
- fun <MappedSuccess> mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): WrapperResult<MappedSuccess> {
17
- return when (this) {
15
+ fun <MappedSuccess> mapSuccess(onSuccess: (SuccessType) -> MappedSuccess): WrapperResult<MappedSuccess> =
16
+ when (this) {
18
17
  is Success -> {
19
18
  Success(onSuccess.invoke(this.success))
20
19
  }
@@ -23,29 +22,30 @@ internal sealed class WrapperResult<SuccessType> {
23
22
  Failure<MappedSuccess>(this.failure)
24
23
  }
25
24
  }
26
- }
27
25
 
28
- fun getOrThrow(): SuccessType {
29
- return when (this) {
26
+ fun getOrThrow(): SuccessType =
27
+ when (this) {
30
28
  is Success -> this.success
31
29
  is Failure -> throw Exception(
32
30
  "Result unwrapping failed: ${this.failure}",
33
31
  this.failure,
34
32
  )
35
33
  }
36
- }
37
34
 
38
35
  companion object {
39
- fun <SuccessType> tryAsResult(block: () -> SuccessType): WrapperResult<SuccessType> {
40
- return try {
36
+ fun <SuccessType> tryAsResult(block: () -> SuccessType): WrapperResult<SuccessType> =
37
+ try {
41
38
  Success(block.invoke())
42
39
  } catch (e: Exception) {
43
40
  Failure(e)
44
41
  }
45
- }
46
42
  }
47
43
  }
48
44
 
49
- internal data class Success<SuccessType>(val success: SuccessType) : WrapperResult<SuccessType>()
45
+ internal data class Success<SuccessType>(
46
+ val success: SuccessType,
47
+ ) : WrapperResult<SuccessType>()
50
48
 
51
- internal data class Failure<SuccessType>(val failure: Throwable) : WrapperResult<SuccessType>()
49
+ internal data class Failure<SuccessType>(
50
+ val failure: Throwable,
51
+ ) : WrapperResult<SuccessType>()
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
18
18
  s.source_files = "ios/**/*.{h,m,mm,swift}"
19
19
 
20
20
  s.dependency "React-Core"
21
- s.dependency 'HyperTrack', '5.7.0'
21
+ s.dependency 'HyperTrack', '5.8.0'
22
22
 
23
23
  # Don't install the dependencies when we run `pod install` in the old architecture.
24
24
  if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
@@ -455,9 +455,13 @@ class HyperTrack {
455
455
  static deserializeIsInsideGeofence(isInsideGeofence) {
456
456
  switch (isInsideGeofence.type) {
457
457
  case 'success':
458
+ let successValue = isInsideGeofence.value;
459
+ if (successValue.type !== 'isInsideGeofence') {
460
+ throw new Error(`Invalid isInsideGeofence: ${JSON.stringify(successValue)}`);
461
+ }
458
462
  return {
459
463
  type: 'success',
460
- value: isInsideGeofence.value
464
+ value: successValue.value
461
465
  };
462
466
  case 'failure':
463
467
  return {