@ovok/native 1.17.0-dev.2213 → 1.17.0-dev.2219

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 (261) hide show
  1. package/lib/commonjs/modules/next/bluetooth/adapters/android-foreground-service.js +58 -5
  2. package/lib/commonjs/modules/next/bluetooth/adapters/android-foreground-service.js.map +1 -1
  3. package/lib/commonjs/modules/next/bluetooth/adapters/ble-plx-central.js +45 -24
  4. package/lib/commonjs/modules/next/bluetooth/adapters/ble-plx-central.js.map +1 -1
  5. package/lib/commonjs/modules/next/bluetooth/adapters/ecg-measurements.js +25 -0
  6. package/lib/commonjs/modules/next/bluetooth/adapters/ecg-measurements.js.map +1 -0
  7. package/lib/commonjs/modules/next/bluetooth/adapters/live-supersession.js +62 -0
  8. package/lib/commonjs/modules/next/bluetooth/adapters/live-supersession.js.map +1 -0
  9. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-outbox-watch.js +42 -0
  10. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-outbox-watch.js.map +1 -0
  11. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js +97 -96
  12. package/lib/commonjs/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
  13. package/lib/commonjs/modules/next/bluetooth/adapters/reading-source-id.js +33 -0
  14. package/lib/commonjs/modules/next/bluetooth/adapters/reading-source-id.js.map +1 -0
  15. package/lib/commonjs/modules/next/bluetooth/adapters/reading-values.js +38 -0
  16. package/lib/commonjs/modules/next/bluetooth/adapters/reading-values.js.map +1 -0
  17. package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js +101 -0
  18. package/lib/commonjs/modules/next/bluetooth/adapters/series-saving.js.map +1 -0
  19. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js +24 -0
  20. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -0
  21. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-rows.js +65 -0
  22. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-rows.js.map +1 -0
  23. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +53 -0
  24. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -0
  25. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.js +82 -0
  26. package/lib/commonjs/modules/next/bluetooth/adapters/sqlite-outbox-store.js.map +1 -0
  27. package/lib/commonjs/modules/next/bluetooth/adapters/storage-paired-devices.js +1 -0
  28. package/lib/commonjs/modules/next/bluetooth/adapters/storage-paired-devices.js.map +1 -1
  29. package/lib/commonjs/modules/next/bluetooth/adapters/web-bluetooth-central.js +9 -1
  30. package/lib/commonjs/modules/next/bluetooth/adapters/web-bluetooth-central.js.map +1 -1
  31. package/lib/commonjs/modules/next/bluetooth/core/bluetooth.js +9 -3
  32. package/lib/commonjs/modules/next/bluetooth/core/bluetooth.js.map +1 -1
  33. package/lib/commonjs/modules/next/bluetooth/core/device-deps.js +6 -0
  34. package/lib/commonjs/modules/next/bluetooth/core/device-deps.js.map +1 -0
  35. package/lib/commonjs/modules/next/bluetooth/core/device-link.js +2 -1
  36. package/lib/commonjs/modules/next/bluetooth/core/device-link.js.map +1 -1
  37. package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js +3 -1
  38. package/lib/commonjs/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
  39. package/lib/commonjs/modules/next/bluetooth/core/device.js +19 -6
  40. package/lib/commonjs/modules/next/bluetooth/core/device.js.map +1 -1
  41. package/lib/commonjs/modules/next/bluetooth/core/live-ledger.js +54 -0
  42. package/lib/commonjs/modules/next/bluetooth/core/live-ledger.js.map +1 -0
  43. package/lib/commonjs/modules/next/bluetooth/core/measuring-watch.js +45 -0
  44. package/lib/commonjs/modules/next/bluetooth/core/measuring-watch.js.map +1 -0
  45. package/lib/commonjs/modules/next/bluetooth/core/outbox-watch.js +17 -0
  46. package/lib/commonjs/modules/next/bluetooth/core/outbox-watch.js.map +1 -0
  47. package/lib/commonjs/modules/next/bluetooth/core/paired-device.js +1 -0
  48. package/lib/commonjs/modules/next/bluetooth/core/paired-device.js.map +1 -1
  49. package/lib/commonjs/modules/next/bluetooth/core/ports.js.map +1 -1
  50. package/lib/commonjs/modules/next/bluetooth/core/reading-log.js +89 -7
  51. package/lib/commonjs/modules/next/bluetooth/core/reading-log.js.map +1 -1
  52. package/lib/commonjs/modules/next/bluetooth/core/series-slots.js +94 -0
  53. package/lib/commonjs/modules/next/bluetooth/core/series-slots.js.map +1 -0
  54. package/lib/commonjs/modules/next/bluetooth/core/stream-recorder.js +219 -0
  55. package/lib/commonjs/modules/next/bluetooth/core/stream-recorder.js.map +1 -0
  56. package/lib/commonjs/modules/next/bluetooth/core/waveform-segments.js +110 -0
  57. package/lib/commonjs/modules/next/bluetooth/core/waveform-segments.js.map +1 -0
  58. package/lib/commonjs/modules/next/bluetooth/create-bluetooth.js +19 -11
  59. package/lib/commonjs/modules/next/bluetooth/create-bluetooth.js.map +1 -1
  60. package/lib/commonjs/modules/next/bluetooth/index.js +9 -1
  61. package/lib/commonjs/modules/next/bluetooth/index.js.map +1 -1
  62. package/lib/commonjs/modules/next/bluetooth/shared.js +14 -0
  63. package/lib/commonjs/modules/next/bluetooth/shared.js.map +1 -1
  64. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth.js +2 -0
  65. package/lib/commonjs/modules/next/bluetooth/web/create-web-bluetooth.js.map +1 -1
  66. package/lib/module/modules/next/bluetooth/adapters/android-foreground-service.js +59 -6
  67. package/lib/module/modules/next/bluetooth/adapters/android-foreground-service.js.map +1 -1
  68. package/lib/module/modules/next/bluetooth/adapters/ble-plx-central.js +45 -24
  69. package/lib/module/modules/next/bluetooth/adapters/ble-plx-central.js.map +1 -1
  70. package/lib/module/modules/next/bluetooth/adapters/ecg-measurements.js +22 -0
  71. package/lib/module/modules/next/bluetooth/adapters/ecg-measurements.js.map +1 -0
  72. package/lib/module/modules/next/bluetooth/adapters/live-supersession.js +59 -0
  73. package/lib/module/modules/next/bluetooth/adapters/live-supersession.js.map +1 -0
  74. package/lib/module/modules/next/bluetooth/adapters/ovok-outbox-watch.js +38 -0
  75. package/lib/module/modules/next/bluetooth/adapters/ovok-outbox-watch.js.map +1 -0
  76. package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js +76 -75
  77. package/lib/module/modules/next/bluetooth/adapters/ovok-reading-sink.js.map +1 -1
  78. package/lib/module/modules/next/bluetooth/adapters/reading-source-id.js +27 -0
  79. package/lib/module/modules/next/bluetooth/adapters/reading-source-id.js.map +1 -0
  80. package/lib/module/modules/next/bluetooth/adapters/reading-values.js +33 -0
  81. package/lib/module/modules/next/bluetooth/adapters/reading-values.js.map +1 -0
  82. package/lib/module/modules/next/bluetooth/adapters/series-saving.js +94 -0
  83. package/lib/module/modules/next/bluetooth/adapters/series-saving.js.map +1 -0
  84. package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js +20 -0
  85. package/lib/module/modules/next/bluetooth/adapters/sqlite-database.js.map +1 -0
  86. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-rows.js +59 -0
  87. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-rows.js.map +1 -0
  88. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js +49 -0
  89. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-schema.js.map +1 -0
  90. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.js +79 -0
  91. package/lib/module/modules/next/bluetooth/adapters/sqlite-outbox-store.js.map +1 -0
  92. package/lib/module/modules/next/bluetooth/adapters/storage-paired-devices.js +1 -0
  93. package/lib/module/modules/next/bluetooth/adapters/storage-paired-devices.js.map +1 -1
  94. package/lib/module/modules/next/bluetooth/adapters/web-bluetooth-central.js +9 -1
  95. package/lib/module/modules/next/bluetooth/adapters/web-bluetooth-central.js.map +1 -1
  96. package/lib/module/modules/next/bluetooth/core/bluetooth.js +9 -3
  97. package/lib/module/modules/next/bluetooth/core/bluetooth.js.map +1 -1
  98. package/lib/module/modules/next/bluetooth/core/device-deps.js +4 -0
  99. package/lib/module/modules/next/bluetooth/core/device-deps.js.map +1 -0
  100. package/lib/module/modules/next/bluetooth/core/device-link.js +2 -1
  101. package/lib/module/modules/next/bluetooth/core/device-link.js.map +1 -1
  102. package/lib/module/modules/next/bluetooth/core/device-snapshot.js +3 -1
  103. package/lib/module/modules/next/bluetooth/core/device-snapshot.js.map +1 -1
  104. package/lib/module/modules/next/bluetooth/core/device.js +19 -6
  105. package/lib/module/modules/next/bluetooth/core/device.js.map +1 -1
  106. package/lib/module/modules/next/bluetooth/core/live-ledger.js +50 -0
  107. package/lib/module/modules/next/bluetooth/core/live-ledger.js.map +1 -0
  108. package/lib/module/modules/next/bluetooth/core/measuring-watch.js +41 -0
  109. package/lib/module/modules/next/bluetooth/core/measuring-watch.js.map +1 -0
  110. package/lib/module/modules/next/bluetooth/core/outbox-watch.js +14 -0
  111. package/lib/module/modules/next/bluetooth/core/outbox-watch.js.map +1 -0
  112. package/lib/module/modules/next/bluetooth/core/paired-device.js +1 -0
  113. package/lib/module/modules/next/bluetooth/core/paired-device.js.map +1 -1
  114. package/lib/module/modules/next/bluetooth/core/ports.js.map +1 -1
  115. package/lib/module/modules/next/bluetooth/core/reading-log.js +89 -7
  116. package/lib/module/modules/next/bluetooth/core/reading-log.js.map +1 -1
  117. package/lib/module/modules/next/bluetooth/core/series-slots.js +90 -0
  118. package/lib/module/modules/next/bluetooth/core/series-slots.js.map +1 -0
  119. package/lib/module/modules/next/bluetooth/core/stream-recorder.js +215 -0
  120. package/lib/module/modules/next/bluetooth/core/stream-recorder.js.map +1 -0
  121. package/lib/module/modules/next/bluetooth/core/waveform-segments.js +106 -0
  122. package/lib/module/modules/next/bluetooth/core/waveform-segments.js.map +1 -0
  123. package/lib/module/modules/next/bluetooth/create-bluetooth.js +19 -11
  124. package/lib/module/modules/next/bluetooth/create-bluetooth.js.map +1 -1
  125. package/lib/module/modules/next/bluetooth/index.js +1 -0
  126. package/lib/module/modules/next/bluetooth/index.js.map +1 -1
  127. package/lib/module/modules/next/bluetooth/shared.js +2 -0
  128. package/lib/module/modules/next/bluetooth/shared.js.map +1 -1
  129. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth.js +2 -0
  130. package/lib/module/modules/next/bluetooth/web/create-web-bluetooth.js.map +1 -1
  131. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts +17 -4
  132. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts.map +1 -1
  133. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ble-plx-central.d.ts.map +1 -1
  134. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts +6 -0
  135. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts.map +1 -0
  136. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/live-supersession.d.ts +9 -0
  137. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/live-supersession.d.ts.map +1 -0
  138. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts +8 -0
  139. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts.map +1 -0
  140. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +9 -3
  141. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
  142. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-source-id.d.ts +9 -0
  143. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-source-id.d.ts.map +1 -0
  144. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-values.d.ts +9 -0
  145. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/reading-values.d.ts.map +1 -0
  146. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts +28 -0
  147. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -0
  148. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +23 -0
  149. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -0
  150. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts +29 -0
  151. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts.map +1 -0
  152. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts +6 -0
  153. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts.map +1 -0
  154. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +38 -0
  155. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/storage-paired-devices.d.ts.map +1 -1
  157. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/web-bluetooth-central.d.ts +4 -0
  158. package/lib/typescript/commonjs/src/modules/next/bluetooth/adapters/web-bluetooth-central.d.ts.map +1 -1
  159. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth-options.d.ts +3 -0
  160. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth-options.d.ts.map +1 -1
  161. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/bluetooth.d.ts.map +1 -1
  162. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-deps.d.ts +16 -0
  163. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-deps.d.ts.map +1 -0
  164. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts +5 -0
  165. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts +6 -13
  167. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-ledger.d.ts +13 -0
  169. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/live-ledger.d.ts.map +1 -0
  170. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/measuring-watch.d.ts +17 -0
  171. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/measuring-watch.d.ts.map +1 -0
  172. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/outbox-watch.d.ts +27 -0
  173. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/outbox-watch.d.ts.map +1 -0
  174. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/paired-device.d.ts +3 -1
  175. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/paired-device.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/ports.d.ts +3 -2
  177. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/ports.d.ts.map +1 -1
  178. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading-log.d.ts +25 -6
  179. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading-log.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts +16 -1
  181. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
  182. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/series-slots.d.ts +35 -0
  183. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/series-slots.d.ts.map +1 -0
  184. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/stream-recorder.d.ts +58 -0
  185. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/stream-recorder.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/waveform-segments.d.ts +26 -0
  187. package/lib/typescript/commonjs/src/modules/next/bluetooth/core/waveform-segments.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/src/modules/next/bluetooth/create-bluetooth.d.ts +3 -2
  189. package/lib/typescript/commonjs/src/modules/next/bluetooth/create-bluetooth.d.ts.map +1 -1
  190. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts +4 -1
  191. package/lib/typescript/commonjs/src/modules/next/bluetooth/index.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts +5 -1
  193. package/lib/typescript/commonjs/src/modules/next/bluetooth/shared.d.ts.map +1 -1
  194. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts +3 -2
  195. package/lib/typescript/commonjs/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts.map +1 -1
  196. package/lib/typescript/module/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts +17 -4
  197. package/lib/typescript/module/src/modules/next/bluetooth/adapters/android-foreground-service.d.ts.map +1 -1
  198. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ble-plx-central.d.ts.map +1 -1
  199. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts +6 -0
  200. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ecg-measurements.d.ts.map +1 -0
  201. package/lib/typescript/module/src/modules/next/bluetooth/adapters/live-supersession.d.ts +9 -0
  202. package/lib/typescript/module/src/modules/next/bluetooth/adapters/live-supersession.d.ts.map +1 -0
  203. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts +8 -0
  204. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-outbox-watch.d.ts.map +1 -0
  205. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts +9 -3
  206. package/lib/typescript/module/src/modules/next/bluetooth/adapters/ovok-reading-sink.d.ts.map +1 -1
  207. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-source-id.d.ts +9 -0
  208. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-source-id.d.ts.map +1 -0
  209. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-values.d.ts +9 -0
  210. package/lib/typescript/module/src/modules/next/bluetooth/adapters/reading-values.d.ts.map +1 -0
  211. package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts +28 -0
  212. package/lib/typescript/module/src/modules/next/bluetooth/adapters/series-saving.d.ts.map +1 -0
  213. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts +23 -0
  214. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-database.d.ts.map +1 -0
  215. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts +29 -0
  216. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-rows.d.ts.map +1 -0
  217. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts +6 -0
  218. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-schema.d.ts.map +1 -0
  219. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts +38 -0
  220. package/lib/typescript/module/src/modules/next/bluetooth/adapters/sqlite-outbox-store.d.ts.map +1 -0
  221. package/lib/typescript/module/src/modules/next/bluetooth/adapters/storage-paired-devices.d.ts.map +1 -1
  222. package/lib/typescript/module/src/modules/next/bluetooth/adapters/web-bluetooth-central.d.ts +4 -0
  223. package/lib/typescript/module/src/modules/next/bluetooth/adapters/web-bluetooth-central.d.ts.map +1 -1
  224. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth-options.d.ts +3 -0
  225. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth-options.d.ts.map +1 -1
  226. package/lib/typescript/module/src/modules/next/bluetooth/core/bluetooth.d.ts.map +1 -1
  227. package/lib/typescript/module/src/modules/next/bluetooth/core/device-deps.d.ts +16 -0
  228. package/lib/typescript/module/src/modules/next/bluetooth/core/device-deps.d.ts.map +1 -0
  229. package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts +5 -0
  230. package/lib/typescript/module/src/modules/next/bluetooth/core/device-snapshot.d.ts.map +1 -1
  231. package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts +6 -13
  232. package/lib/typescript/module/src/modules/next/bluetooth/core/device.d.ts.map +1 -1
  233. package/lib/typescript/module/src/modules/next/bluetooth/core/live-ledger.d.ts +13 -0
  234. package/lib/typescript/module/src/modules/next/bluetooth/core/live-ledger.d.ts.map +1 -0
  235. package/lib/typescript/module/src/modules/next/bluetooth/core/measuring-watch.d.ts +17 -0
  236. package/lib/typescript/module/src/modules/next/bluetooth/core/measuring-watch.d.ts.map +1 -0
  237. package/lib/typescript/module/src/modules/next/bluetooth/core/outbox-watch.d.ts +27 -0
  238. package/lib/typescript/module/src/modules/next/bluetooth/core/outbox-watch.d.ts.map +1 -0
  239. package/lib/typescript/module/src/modules/next/bluetooth/core/paired-device.d.ts +3 -1
  240. package/lib/typescript/module/src/modules/next/bluetooth/core/paired-device.d.ts.map +1 -1
  241. package/lib/typescript/module/src/modules/next/bluetooth/core/ports.d.ts +3 -2
  242. package/lib/typescript/module/src/modules/next/bluetooth/core/ports.d.ts.map +1 -1
  243. package/lib/typescript/module/src/modules/next/bluetooth/core/reading-log.d.ts +25 -6
  244. package/lib/typescript/module/src/modules/next/bluetooth/core/reading-log.d.ts.map +1 -1
  245. package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts +16 -1
  246. package/lib/typescript/module/src/modules/next/bluetooth/core/reading.d.ts.map +1 -1
  247. package/lib/typescript/module/src/modules/next/bluetooth/core/series-slots.d.ts +35 -0
  248. package/lib/typescript/module/src/modules/next/bluetooth/core/series-slots.d.ts.map +1 -0
  249. package/lib/typescript/module/src/modules/next/bluetooth/core/stream-recorder.d.ts +58 -0
  250. package/lib/typescript/module/src/modules/next/bluetooth/core/stream-recorder.d.ts.map +1 -0
  251. package/lib/typescript/module/src/modules/next/bluetooth/core/waveform-segments.d.ts +26 -0
  252. package/lib/typescript/module/src/modules/next/bluetooth/core/waveform-segments.d.ts.map +1 -0
  253. package/lib/typescript/module/src/modules/next/bluetooth/create-bluetooth.d.ts +3 -2
  254. package/lib/typescript/module/src/modules/next/bluetooth/create-bluetooth.d.ts.map +1 -1
  255. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts +4 -1
  256. package/lib/typescript/module/src/modules/next/bluetooth/index.d.ts.map +1 -1
  257. package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts +5 -1
  258. package/lib/typescript/module/src/modules/next/bluetooth/shared.d.ts.map +1 -1
  259. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts +3 -2
  260. package/lib/typescript/module/src/modules/next/bluetooth/web/create-web-bluetooth.d.ts.map +1 -1
  261. package/package.json +7 -3
@@ -5,9 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.androidForegroundService = void 0;
7
7
  var _reactNative = require("react-native");
8
+ var _outboxWatch = require("../core/outbox-watch.js");
8
9
  var _ports = require("../core/ports.js");
9
10
  /** The notification Android shows while the service runs. */
10
11
 
12
+ /** What the service watches and reports besides its text. */
13
+
11
14
  const nativeService = () => {
12
15
  const service = _reactNative.NativeModules.OvokBackgroundSync;
13
16
  if (!service) {
@@ -15,11 +18,61 @@ const nativeService = () => {
15
18
  }
16
19
  return service;
17
20
  };
21
+ const describeUnsent = unsent => `${unsent} ${unsent === 1 ? "reading" : "readings"} waiting to upload`;
22
+
23
+ /** The text for the native module: the function is dropped, and the body names the unsent count while there is one. */
24
+ const textFor = ({
25
+ unsentBody = describeUnsent,
26
+ ...text
27
+ }, unsent) => unsent > 0 ? {
28
+ ...text,
29
+ notificationBody: unsentBody(unsent)
30
+ } : text;
31
+
32
+ /** Android re-posts the same notification when the service is started again, which is how the text changes. */
33
+ class AndroidForegroundService {
34
+ stopWatching = null;
35
+ shownUnsent = 0;
36
+ constructor(text, outbox, logger) {
37
+ this.text = text;
38
+ this.outbox = outbox;
39
+ this.logger = logger;
40
+ }
41
+ start = async () => {
42
+ this.stopWatching?.();
43
+ this.shownUnsent = 0;
44
+
45
+ // Watch before the first await, so a stop that follows at once also ends the watching.
46
+ this.stopWatching = this.outbox.subscribe(({
47
+ waiting
48
+ }) => this.showCount(waiting.size));
49
+ await this.show();
50
+ };
51
+ stop = async () => {
52
+ this.stopWatching?.();
53
+ this.stopWatching = null;
54
+ await nativeService().stopBluetoothForegroundService();
55
+ };
56
+ showCount(unsent) {
57
+ if (unsent !== this.shownUnsent) {
58
+ this.shownUnsent = unsent;
59
+ this.show().catch(() => this.logger.error("bluetooth.keep-alive.notification-failed", {
60
+ unsent
61
+ }));
62
+ }
63
+ }
64
+ show() {
65
+ return nativeService().startBluetoothForegroundService(textFor(this.text, this.shownUnsent));
66
+ }
67
+ }
18
68
 
19
- /** Android's connected-device foreground service, which keeps the process alive for background sync; nothing elsewhere. */
20
- const androidForegroundService = (text = {}) => _reactNative.Platform.OS === "android" ? {
21
- start: async () => nativeService().startBluetoothForegroundService(text),
22
- stop: async () => nativeService().stopBluetoothForegroundService()
23
- } : _ports.noKeepAlive;
69
+ /**
70
+ * Android's connected-device foreground service, which keeps the process alive for background sync; nothing elsewhere.
71
+ * With an `outbox`, its notification says how many readings wait to upload.
72
+ */
73
+ const androidForegroundService = (text = {}, {
74
+ outbox = _outboxWatch.noOutboxWatch,
75
+ logger = _ports.silentLogger
76
+ } = {}) => _reactNative.Platform.OS === "android" ? new AndroidForegroundService(text, outbox, logger) : _ports.noKeepAlive;
24
77
  exports.androidForegroundService = androidForegroundService;
25
78
  //# sourceMappingURL=android-foreground-service.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_ports","nativeService","service","NativeModules","OvokBackgroundSync","Error","androidForegroundService","text","Platform","OS","start","startBluetoothForegroundService","stop","stopBluetoothForegroundService","noKeepAlive","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/android-foreground-service.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAEA;;AAeA,MAAME,aAAa,GAAGA,CAAA,KAA+B;EACnD,MAAMC,OAAO,GAAGC,0BAAa,CAACC,kBAAyD;EAEvF,IAAI,CAACF,OAAO,EAAE;IACZ,MAAM,IAAIG,KAAK,CAAC,2FAA2F,CAAC;EAC9G;EAEA,OAAOH,OAAO;AAChB,CAAC;;AAED;AACA,MAAMI,wBAAwB,GAAGA,CAACC,IAA2B,GAAG,CAAC,CAAC,KAChEC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GACrB;EACEC,KAAK,EAAE,MAAAA,CAAA,KAAYT,aAAa,CAAC,CAAC,CAACU,+BAA+B,CAACJ,IAAI,CAAC;EACxEK,IAAI,EAAE,MAAAA,CAAA,KAAYX,aAAa,CAAC,CAAC,CAACY,8BAA8B,CAAC;AACnE,CAAC,GACDC,kBAAW;AAACC,OAAA,CAAAT,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_outboxWatch","_ports","nativeService","service","NativeModules","OvokBackgroundSync","Error","describeUnsent","unsent","textFor","unsentBody","text","notificationBody","AndroidForegroundService","stopWatching","shownUnsent","constructor","outbox","logger","start","subscribe","waiting","showCount","size","show","stop","stopBluetoothForegroundService","catch","error","startBluetoothForegroundService","androidForegroundService","noOutboxWatch","silentLogger","Platform","OS","noKeepAlive","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/android-foreground-service.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA;;AAaA;;AAiBA,MAAMG,aAAa,GAAGA,CAAA,KAA+B;EACnD,MAAMC,OAAO,GAAGC,0BAAa,CAACC,kBAAyD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,SAASA,CAACd,MAAc,EAAQ;IACtC,IAAIA,MAAM,KAAK,IAAI,CAACO,WAAW,EAAE;MAC/B,IAAI,CAACA,WAAW,GAAGP,MAAM;MACzB,IAAI,CAACgB,IAAI,CAAC,CAAC,CAACG,KAAK,CAAC,MAAM,IAAI,CAACT,MAAM,CAACU,KAAK,CAAC,0CAA0C,EAAE;QAAEpB;MAAO,CAAC,CAAC,CAAC;IACpG;EACF;EAEQgB,IAAIA,CAAA,EAAkB;IAC5B,OAAOtB,aAAa,CAAC,CAAC,CAAC2B,+BAA+B,CAACpB,OAAO,CAAC,IAAI,CAACE,IAAI,EAAE,IAAI,CAACI,WAAW,CAAC,CAAC;EAC9F;AACF;;AAEA;AACA;AACA;AACA;AACA,MAAMe,wBAAwB,GAAGA,CAC/BnB,IAA2B,GAAG,CAAC,CAAC,EAChC;EAAEM,MAAM,GAAGc,0BAAa;EAAEb,MAAM,GAAGc;AAAuC,CAAC,GAAG,CAAC,CAAC,KACjEC,qBAAQ,CAACC,EAAE,KAAK,SAAS,GAAG,IAAIrB,wBAAwB,CAACF,IAAI,EAAEM,MAAM,EAAEC,MAAM,CAAC,GAAGiB,kBAAY;AAACC,OAAA,CAAAN,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -37,30 +37,51 @@ const advertisementOf = device => ({
37
37
  serviceData: new Map(Object.entries(device.serviceData ?? {}).map(([uuid, data]) => [(0, _advertisement.fullUuid)(uuid), (0, _base.fromBase64)(data)])),
38
38
  rssi: device.rssi ?? null
39
39
  });
40
- const gattLinkOf = (manager, device) => ({
41
- read: async (service, characteristic) => (0, _base.fromBase64)((await device.readCharacteristicForService(lower(service), lower(characteristic))).value ?? ""),
42
- write: async (service, characteristic, bytes) => {
43
- await device.writeCharacteristicWithResponseForService(lower(service), lower(characteristic), (0, _base.toBase64)(bytes));
44
- },
45
- writeWithoutResponse: async (service, characteristic, bytes) => {
46
- await device.writeCharacteristicWithoutResponseForService(lower(service), lower(characteristic), (0, _base.toBase64)(bytes));
47
- },
48
- subscribe: async (service, characteristic, onValue) => {
49
- const subscription = device.monitorCharacteristicForService(lower(service), lower(characteristic), (error, value) => {
50
- if (!error && value?.value) {
51
- onValue((0, _base.fromBase64)(value.value));
52
- }
53
- });
54
- return () => subscription.remove();
55
- },
56
- onDisconnect: listener => {
57
- const subscription = manager.onDeviceDisconnected(device.id, () => listener());
58
- return () => subscription.remove();
59
- },
60
- close: async () => {
61
- await manager.cancelDeviceConnection(device.id).catch(() => undefined);
62
- }
63
- });
40
+
41
+ /** Whether a discovered characteristic refuses a write with response but takes one without, as the vendor apps check. */
42
+ const takesOnlyWritesWithoutResponse = async (device, service, characteristic) => {
43
+ const found = (await device.characteristicsForService(service)).find(({
44
+ uuid
45
+ }) => lower(uuid) === characteristic);
46
+ return found !== undefined && !found.isWritableWithResponse && found.isWritableWithoutResponse;
47
+ };
48
+ const gattLinkOf = (manager, device) => {
49
+ const writeTypes = new Map();
50
+
51
+ /** Looks a characteristic's write type up once per link. */
52
+ const writesWithoutResponse = (service, characteristic) => {
53
+ const key = `${service}/${characteristic}`;
54
+ const known = writeTypes.get(key) ?? takesOnlyWritesWithoutResponse(device, service, characteristic);
55
+ writeTypes.set(key, known);
56
+ return known;
57
+ };
58
+ return {
59
+ read: async (service, characteristic) => (0, _base.fromBase64)((await device.readCharacteristicForService(lower(service), lower(characteristic))).value ?? ""),
60
+ write: async (service, characteristic, bytes) => {
61
+ const [serviceUuid, characteristicUuid] = [lower(service), lower(characteristic)];
62
+ const value = (0, _base.toBase64)(bytes);
63
+ await ((await writesWithoutResponse(serviceUuid, characteristicUuid)) ? device.writeCharacteristicWithoutResponseForService(serviceUuid, characteristicUuid, value) : device.writeCharacteristicWithResponseForService(serviceUuid, characteristicUuid, value));
64
+ },
65
+ writeWithoutResponse: async (service, characteristic, bytes) => {
66
+ await device.writeCharacteristicWithoutResponseForService(lower(service), lower(characteristic), (0, _base.toBase64)(bytes));
67
+ },
68
+ subscribe: async (service, characteristic, onValue) => {
69
+ const subscription = device.monitorCharacteristicForService(lower(service), lower(characteristic), (error, value) => {
70
+ if (!error && value?.value) {
71
+ onValue((0, _base.fromBase64)(value.value));
72
+ }
73
+ });
74
+ return () => subscription.remove();
75
+ },
76
+ onDisconnect: listener => {
77
+ const subscription = manager.onDeviceDisconnected(device.id, () => listener());
78
+ return () => subscription.remove();
79
+ },
80
+ close: async () => {
81
+ await manager.cancelDeviceConnection(device.id).catch(() => undefined);
82
+ }
83
+ };
84
+ };
64
85
 
65
86
  /** The device's Bluetooth LE radio through `react-native-ble-plx`. */
66
87
  const blePlxCentral = manager => ({
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeBlePlx","require","_base","_bytes","_advertisement","_errors","STATES","State","Unknown","Resetting","Unsupported","Unauthorized","PoweredOff","PoweredOn","ERROR_CODES","BleErrorCode","BluetoothPoweredOff","BluetoothUnauthorized","BluetoothUnsupported","deviceErrorOf","error","DeviceError","errorCode","message","lower","uuid","toLowerCase","manufacturerDataOf","base64","bytes","fromBase64","Uint8Array","length","Map","u16le","subarray","advertisementOf","device","transport","address","id","name","localName","services","serviceUUIDs","map","fullUuid","manufacturerData","serviceData","Object","entries","data","rssi","gattLinkOf","manager","read","service","characteristic","readCharacteristicForService","value","write","writeCharacteristicWithResponseForService","toBase64","writeWithoutResponse","writeCharacteristicWithoutResponseForService","subscribe","onValue","subscription","monitorCharacteristicForService","remove","onDisconnect","listener","onDeviceDisconnected","close","cancelDeviceConnection","catch","undefined","blePlxCentral","watchState","onStateChange","state","scan","filter","onAdvertisement","onError","startDeviceScan","allowDuplicates","stopDeviceScan","connect","connectToDevice","Promise","reject","discoverAllServicesAndCharacteristics","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ble-plx-central.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,O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AEC;EAAQ,CAAC,KAAK;IAC9C,KAAK9B,OAAO,CAAC+B,eAAe,CAACH,MAAM,CAACvC,QAAQ,EAAEE,GAAG,CAACrB,KAAK,CAAC,IAAI,IAAI,EAAE;MAAE8D,eAAe,EAAE;IAAK,CAAC,EAAE,CAAClE,KAAK,EAAEiB,MAAM,KAAK;MAC9G,IAAIjB,KAAK,EAAE;QACTgE,OAAO,CAACjE,aAAa,CAACC,KAAK,CAAC,CAAC;MAC/B,CAAC,MAAM,IAAIiB,MAAM,EAAE;QACjB8C,eAAe,CAAC/C,eAAe,CAACC,MAAM,CAAC,CAAC;MAC1C;IACF,CAAC,CAAC;IAEF,OAAO,MAAM,KAAKiB,OAAO,CAACiC,cAAc,CAAC,CAAC;EAC5C,CAAC;EACDC,OAAO,EAAE,MAAOjD,OAAO,IAAK;IAC1B,MAAMF,MAAM,GAAG,MAAMiB,OAAO,CAACmC,eAAe,CAAClD,OAAO,CAAC,CAACoC,KAAK,CAAEvD,KAAe,IAAKsE,OAAO,CAACC,MAAM,CAACxE,aAAa,CAACC,KAAK,CAAC,CAAC,CAAC;IAEtH,MAAMiB,MAAM,CAACuD,qCAAqC,CAAC,CAAC;IAEpD,OAAOvC,UAAU,CAACC,OAAO,EAAEjB,MAAM,CAAC;EACpC;AACF,CAAC,CAAC;AAACwD,OAAA,CAAAhB,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeBlePlx","require","_base","_bytes","_advertisement","_errors","STATES","State","Unknown","Resetting","Unsupported","Unauthorized","PoweredOff","PoweredOn","ERROR_CODES","BleErrorCode","BluetoothPoweredOff","BluetoothUnauthorized","BluetoothUnsupported","deviceErrorOf","error","DeviceError","errorCode","message","lower","uuid","toLowerCase","manufacturerDataOf","base64","bytes","fromBase64","Uint8Array","length","Map","u16le","subarray","advertisementOf","device","transport","address","id","name","localName","services","serviceUUIDs","map","fullUuid","manufacturerData","serviceData","Object","entries","data","rssi","takesOnlyWritesWithoutResponse","service","characteristic","found","characteristicsForService","find","undefined","isWritableWithResponse","isWritableWithoutResponse","gattLinkOf","manager","writeTypes","writesWithoutResponse","key","known","get","set","read","readCharacteristicForService","value","write","serviceUuid","characteristicUuid","toBase64","writeCharacteristicWithoutResponseForService","writeCharacteristicWithResponseForService","writeWithoutResponse","subscribe","onValue","subscription","monitorCharacteristicForService","remove","onDisconnect","listener","onDeviceDisconnected","close","cancelDeviceConnection","catch","blePlxCentral","watchState","onStateChange","state","scan","filter","onAdvertisement","onError","startDeviceScan","allowDuplicates","stopDeviceScan","connect","connectToDevice","Promise","reject","discoverAllServicesAndCharacteristics","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ble-plx-central.ts"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAGA,MAAMK,MAAmC,GAAG;EAC1C,CAACC,wBAAK,CAACC,OAAO,GAAG,SAAS;EAC1B,CAACD,wBAAK,CAACE,SAAS,GAAG,SAAS;EAC5B,CAACF,wBAAK,CAACG,WAAW,GAAG,aAAa;EAClC,CAACH,wBAAK,CAACI,YAAY,GAAG,cAAc;EACpC,CAACJ,wBAAK,CAACK,UAAU,GAAG,KAAK;EACzB,CAACL,wBAAK,CAACM,SAAS,GAAG;AACrB,CAAC;AAED,MAAMC,WAA2D,GAAG;EAClE,CAACC,+BAAY,CAACC,mBAAmB,GAAG,aAAa;EACjD,CAACD,+BAAY,CAACE,qBAAqB,GAAG,YAAY;EAClD,CAACF,+BAAY,CAACG,oBAAoB,GAAG;AACvC,CAAC;AAED,MAAMC,aAAa,GAAIC,KAAe,IACpC,IAAIC,mBAAW,CAACP,WAAW,CAACM,KAAK,CAACE,SAAS,CAAC,IAAI,gBAAgB,EAAEF,KAAK,CAACG,OAAO,EAAEH,KAAK,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F,CAAC,CAAC;AAACsE,OAAA,CAAAhB,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ecgMeasurements = void 0;
7
+ var _next = require("@ovok/core/next");
8
+ var _readingValues = require("./reading-values.js");
9
+ /** Ovok stores ECG points in millivolts; a trace in any other unit is left out rather than mislabelled. */
10
+ const ECG_POINT_UNIT = "mV";
11
+
12
+ /** One ECG recording per channel, each in millivolts at the waveform's sample rate; the heart rate goes with the first. */
13
+ const ecgMeasurements = reading => {
14
+ const waveform = reading.waveform?.unit === ECG_POINT_UNIT ? reading.waveform : undefined;
15
+ const channels = waveform?.samples ?? [new Int16Array(0)];
16
+ return channels.map((samples, index) => ({
17
+ measurementTypeKey: _next.MeasurementTypeKey.ecg,
18
+ heartRate: index === 0 ? (0, _readingValues.valueOf)(reading, "heart_rate") : undefined,
19
+ diagramPoints: Array.from(samples, sample => sample * (waveform?.scale ?? 1)),
20
+ duration: waveform ? samples.length / waveform.sampleRateHz : undefined,
21
+ recordedAt: reading.takenAt ?? undefined
22
+ }));
23
+ };
24
+ exports.ecgMeasurements = ecgMeasurements;
25
+ //# sourceMappingURL=ecg-measurements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_next","require","_readingValues","ECG_POINT_UNIT","ecgMeasurements","reading","waveform","unit","undefined","channels","samples","Int16Array","map","index","measurementTypeKey","MeasurementTypeKey","ecg","heartRate","valueOf","diagramPoints","Array","from","sample","scale","duration","length","sampleRateHz","recordedAt","takenAt","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ecg-measurements.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAIA,IAAAC,cAAA,GAAAD,OAAA;AAEA;AACA,MAAME,cAAc,GAAG,IAAI;;AAE3B;AACA,MAAMC,eAAe,GAAIC,OAAgB,IAAuB;EAC9D,MAAMC,QAAQ,GAAGD,OAAO,CAACC,QAAQ,EAAEC,IAAI,KAAKJ,cAAc,GAAGE,OAAO,CAACC,QAAQ,GAAGE,SAAS;EACzF,MAAMC,QAAQ,GAAGH,QAAQ,EAAEI,OAAO,IAAI,CAAC,IAAIC,UAAU,CAAC,CAAC,CAAC,CAAC;EAEzD,OAAOF,QAAQ,CAACG,GAAG,CAAC,CAACF,OAAO,EAAEG,KAAK,MAAM;IACvCC,kBAAkB,EAAEC,wBAAkB,CAACC,GAAG;IAC1CC,SAAS,EAAEJ,KAAK,KAAK,CAAC,GAAG,IAAAK,sBAAO,EAACb,OAAO,EAAE,YAAY,CAAC,GAAGG,SAAS;IACnEW,aAAa,EAAEC,KAAK,CAACC,IAAI,CAACX,OAAO,EAAGY,MAAM,IAAKA,MAAM,IAAIhB,QAAQ,EAAEiB,KAAK,IAAI,CAAC,CAAC,CAAC;IAC/EC,QAAQ,EAAElB,QAAQ,GAAGI,OAAO,CAACe,MAAM,GAAGnB,QAAQ,CAACoB,YAAY,GAAGlB,SAAS;IACvEmB,UAAU,EAAEtB,OAAO,CAACuB,OAAO,IAAIpB;EACjC,CAAC,CAAC,CAAC;AACL,CAAC;AAACqB,OAAA,CAAAzB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.replaceLiveRecordings = void 0;
7
+ var _next = require("@ovok/core/next");
8
+ var _readingSourceId = require("./reading-source-id.js");
9
+ var _seriesSaving = require("./series-saving.js");
10
+ /** What queues the deletions: the outbox, with the measurements API and the session that name what to delete. */
11
+
12
+ const LIVE_SLOT_MS = 1_000;
13
+
14
+ /** The observations a live recording was saved as, rebuilt from its span alone; a single stand-in value gives each its identifiers. */
15
+ const observationsOfSpan = async (client, address, span) => {
16
+ const patientId = await (0, _seriesSaving.signedInPatientId)(client);
17
+ const sourceId = (0, _readingSourceId.liveSourceId)(address, span);
18
+ if (span.channel === null) {
19
+ const field = (0, _seriesSaving.seriesFieldOf)(span.metric);
20
+ return field ? (0, _seriesSaving.seriesObservationsOf)(field, {
21
+ start: span.from,
22
+ intervalMs: LIVE_SLOT_MS,
23
+ values: [0]
24
+ }, {
25
+ patientId,
26
+ sourceId
27
+ }) : [];
28
+ }
29
+ const measurement = {
30
+ measurementTypeKey: _next.MeasurementTypeKey.ecg,
31
+ diagramPoints: [0],
32
+ duration: 1,
33
+ recordedAt: span.from
34
+ };
35
+ return client.measurements.build({
36
+ measurement,
37
+ sourceId,
38
+ patientId
39
+ });
40
+ };
41
+
42
+ /** The identifiers that name an observation for good; a segment's own depends on its sample count, which a span does not carry. */
43
+ const deleteTargetsOf = observations => observations.flatMap(({
44
+ identifier = []
45
+ }) => identifier.flatMap(({
46
+ system,
47
+ value
48
+ }) => system && value && system !== _next.SEGMENT_IDENTIFIER_SYSTEM ? [{
49
+ system,
50
+ value
51
+ }] : []));
52
+
53
+ /** Queues the deletion of the live recordings a stored record replaces, so the outbox holds them before it holds the record. */
54
+ const replaceLiveRecordings = async (client, reading) => {
55
+ for (const span of reading.supersedes ?? []) {
56
+ for (const target of deleteTargetsOf(await observationsOfSpan(client, reading.source.address, span))) {
57
+ await client.outbox.enqueueDelete(target);
58
+ }
59
+ }
60
+ };
61
+ exports.replaceLiveRecordings = replaceLiveRecordings;
62
+ //# sourceMappingURL=live-supersession.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_next","require","_readingSourceId","_seriesSaving","LIVE_SLOT_MS","observationsOfSpan","client","address","span","patientId","signedInPatientId","sourceId","liveSourceId","channel","field","seriesFieldOf","metric","seriesObservationsOf","start","from","intervalMs","values","measurement","measurementTypeKey","MeasurementTypeKey","ecg","diagramPoints","duration","recordedAt","measurements","build","deleteTargetsOf","observations","flatMap","identifier","system","value","SEGMENT_IDENTIFIER_SYSTEM","replaceLiveRecordings","reading","supersedes","target","source","outbox","enqueueDelete","exports"],"sourceRoot":"../../../../../../src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AAM,CAAC,KAAMD,MAAM,IAAIC,KAAK,IAAID,MAAM,KAAKE,+BAAyB,GAAG,CAAC;EAAEF,MAAM;EAAEC;AAAM,CAAC,CAAC,GAAG,EAAG,CAChI,CAAC;;AAEH;AACA,MAAME,qBAAqB,GAAG,MAAAA,CAAOhC,MAA0B,EAAEiC,OAAgB,KAAoB;EACnG,KAAK,MAAM/B,IAAI,IAAI+B,OAAO,CAACC,UAAU,IAAI,EAAE,EAAE;IAC3C,KAAK,MAAMC,MAAM,IAAIV,eAAe,CAAC,MAAM1B,kBAAkB,CAACC,MAAM,EAAEiC,OAAO,CAACG,MAAM,CAACnC,OAAO,EAAEC,IAAI,CAAC,CAAC,EAAE;MACpG,MAAMF,MAAM,CAACqC,MAAM,CAACC,aAAa,CAACH,MAAM,CAAC;IAC3C;EACF;AACF,CAAC;AAACI,OAAA,CAAAP,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ovokOutboxWatch = void 0;
7
+ var _ports = require("../core/ports.js");
8
+ const idsOf = items => new Set(items.map(({
9
+ id
10
+ }) => id));
11
+ const itemsIn = (items, state) => idsOf(items.filter(item => item.state === state));
12
+ const viewOf = (items, sent) => ({
13
+ waiting: itemsIn(items, "pending"),
14
+ rejected: itemsIn(items, "rejected"),
15
+ sent: idsOf(sent)
16
+ });
17
+
18
+ /** Watches the signed-in account's Ovok outbox, so the reading log and the notification follow what it sends. */
19
+ const ovokOutboxWatch = (outbox, logger = _ports.silentLogger) => ({
20
+ subscribe: listener => {
21
+ let requests = 0;
22
+ let watching = true;
23
+
24
+ // The outbox's snapshot only says something changed; the items say what.
25
+ const stop = outbox.subscribe(() => {
26
+ const request = ++requests;
27
+ void outbox.items().then(items => {
28
+ if (watching && request === requests) {
29
+ listener(viewOf(items, outbox.recentlySent()));
30
+ }
31
+ }, error => logger.error("bluetooth.outbox-watch.failed", {
32
+ error: error.name
33
+ }));
34
+ });
35
+ return () => {
36
+ watching = false;
37
+ stop();
38
+ };
39
+ }
40
+ });
41
+ exports.ovokOutboxWatch = ovokOutboxWatch;
42
+ //# sourceMappingURL=ovok-outbox-watch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ports","require","idsOf","items","Set","map","id","itemsIn","state","filter","item","viewOf","sent","waiting","rejected","ovokOutboxWatch","outbox","logger","silentLogger","subscribe","listener","requests","watching","stop","request","then","recentlySent","error","name","exports"],"sourceRoot":"../../../../../../src","sources":["modules/next/bluetooth/adapters/ovok-outbox-watch.ts"],"mappings":";;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AAIA,MAAMC,KAAK,GAAIC,KAAoC,IAAkB,IAAIC,GAAG,CAACD,KAAK,CAACE,GAAG,CAAC,CAAC;EAAEC;AAAG,CAAC,KAAKA,EAAE,CAAC,CAAC;AAEvG,MAAMC,OAAO,GAAGA,CAACJ,KAA0B,EAAEK,KAAkB,KAC7DN,KAAK,CAACC,KAAK,CAACM,MAAM,CAAEC,IAAI,IAAKA,IAAI,CAACF,KAAK,KAAKA,KAAK,CAAC,CAAC;AAErD,MAAMG,MAAM,GAAGA,CAACR,KAA0B,EAAES,IAAsB,MAAkB;EAClFC,OAAO,EAAEN,OAAO,CAACJ,KAAK,EAAE,SAAS,CAAC;EAClCW,QAAQ,EAAEP,OAAO,CAACJ,KAAK,EAAE,UAAU,CAAC;EACpCS,IAAI,EAAEV,KAAK,CAACU,IAAI;AAClB,CAAC,CAAC;;AAEF;AACA,MAAMG,eAAe,GAAGA,CAACC,MAAqB,EAAEC,MAAc,GAAGC,mBAAY,MAAmB;EAC9FC,SAAS,EAAGC,QAAQ,IAAK;IACvB,IAAIC,QAAQ,GAAG,CAAC;IAChB,IAAIC,QAAQ,GAAG,IAAI;;IAEnB;IACA,MAAMC,IAAI,GAAGP,MAAM,CAACG,SAAS,CAAC,MAAM;MAClC,MAAMK,OAAO,GAAG,EAAEH,QAAQ;MAE1B,KAAKL,MAAM,CAACb,KAAK,CAAC,CAAC,CAACsB,IAAI,CACrBtB,KAAK,IAAK;QACT,IAAImB,QAAQ,IAAIE,OAAO,KAAKH,QAAQ,EAAE;UACpCD,QAAQ,CAACT,MAAM,CAACR,KAAK,EAAEa,MAAM,CAACU,YAAY,CAAC,CAAC,CAAC,CAAC;QAChD;MACF,CAAC,EACAC,KAAc,IAAKV,MAAM,CAACU,KAAK,CAAC,+BAA+B,EAAE;QAAEA,KAAK,EAAGA,KAAK,CAAWC;MAAK,CAAC,CACpG,CAAC;IACH,CAAC,CAAC;IAEF,OAAO,MAAM;MACXN,QAAQ,GAAG,KAAK;MAChBC,IAAI,CAAC,CAAC;IACR,CAAC;EACH;AACF,CAAC,CAAC;AAACM,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -6,48 +6,25 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.ovokReadingSink = void 0;
7
7
  var _next = require("@ovok/core/next");
8
8
  var _errors = require("../core/errors.js");
9
- const MG_PER_DL_PER_MMOL_PER_L = 18.0182;
10
- const KG_PER_POUND = 0.45359237;
11
- const KG_PER_STONE = 6.35029318;
12
- const MMHG_PER_KPA = 7.50062;
13
- const FAHRENHEIT_ZERO_IN_CELSIUS_STEPS = 32;
14
-
15
- /** A device's UCUM unit to the unit Ovok stores the value in: mg/dL, kg, °C, mmHg, L, L/s or %. */
16
- const TO_OVOK_UNIT = {
17
- "mg/dL": value => value,
18
- "mmol/L": value => value * MG_PER_DL_PER_MMOL_PER_L,
19
- kg: value => value,
20
- "[lb_av]": value => value * KG_PER_POUND,
21
- "[stone_av]": value => value * KG_PER_STONE,
22
- Cel: value => value,
23
- "[degF]": value => (value - FAHRENHEIT_ZERO_IN_CELSIUS_STEPS) * 5 / 9,
24
- "mm[Hg]": value => value,
25
- kPa: value => value * MMHG_PER_KPA,
26
- L: value => value,
27
- "L/s": value => value,
28
- "%": value => value
29
- };
30
- const valueOf = (reading, metric) => reading.values[metric]?.value;
31
-
32
- /** The value in Ovok's unit; `undefined` when the reading lacks it or uses a unit Ovok has no conversion for. */
33
- const ovokValueOf = (reading, metric) => {
34
- const quantity = reading.values[metric];
35
- return quantity && TO_OVOK_UNIT[quantity.unit]?.(quantity.value);
36
- };
9
+ var _ecgMeasurements = require("./ecg-measurements.js");
10
+ var _liveSupersession = require("./live-supersession.js");
11
+ var _readingSourceId = require("./reading-source-id.js");
12
+ var _readingValues = require("./reading-values.js");
13
+ var _seriesSaving = require("./series-saving.js");
37
14
  const flagSet = (reading, code) => reading.deviceFlags.some(flag => flag.code === code && flag.raw !== 0) ? true : undefined;
38
15
  const bloodPressure = reading => ({
39
16
  measurementTypeKey: _next.MeasurementTypeKey.bloodPressure,
40
- systolic: ovokValueOf(reading, "systolic"),
41
- diastolic: ovokValueOf(reading, "diastolic"),
42
- meanArterialPressure: ovokValueOf(reading, "mean_arterial_pressure"),
43
- heartRate: valueOf(reading, "pulse_rate"),
17
+ systolic: (0, _readingValues.ovokValueOf)(reading, "systolic"),
18
+ diastolic: (0, _readingValues.ovokValueOf)(reading, "diastolic"),
19
+ meanArterialPressure: (0, _readingValues.ovokValueOf)(reading, "mean_arterial_pressure"),
20
+ heartRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
44
21
  irregularHeartbeat: flagSet(reading, "irregular_pulse"),
45
22
  recordedAt: reading.takenAt ?? undefined
46
23
  });
47
24
 
48
25
  /** A reading without its main value, or with it in an unconvertible unit, cannot be saved. */
49
26
  const bloodGlucose = reading => {
50
- const bloodGlucoseValue = ovokValueOf(reading, "blood_glucose");
27
+ const bloodGlucoseValue = (0, _readingValues.ovokValueOf)(reading, "blood_glucose");
51
28
  return bloodGlucoseValue === undefined ? undefined : {
52
29
  measurementTypeKey: _next.MeasurementTypeKey.bloodGlucose,
53
30
  bloodGlucose: bloodGlucoseValue,
@@ -55,7 +32,7 @@ const bloodGlucose = reading => {
55
32
  };
56
33
  };
57
34
  const bodyWeight = reading => {
58
- const weight = ovokValueOf(reading, "body_weight");
35
+ const weight = (0, _readingValues.ovokValueOf)(reading, "body_weight");
59
36
  return weight === undefined ? undefined : {
60
37
  measurementTypeKey: _next.MeasurementTypeKey.bodyWeight,
61
38
  bodyWeight: weight,
@@ -63,7 +40,7 @@ const bodyWeight = reading => {
63
40
  };
64
41
  };
65
42
  const bodyTemperature = reading => {
66
- const temperature = ovokValueOf(reading, "body_temperature");
43
+ const temperature = (0, _readingValues.ovokValueOf)(reading, "body_temperature");
67
44
  return temperature === undefined ? undefined : {
68
45
  measurementTypeKey: _next.MeasurementTypeKey.temperature,
69
46
  bodyTemp: temperature,
@@ -72,37 +49,21 @@ const bodyTemperature = reading => {
72
49
  };
73
50
  const pulseOximetry = reading => ({
74
51
  measurementTypeKey: _next.MeasurementTypeKey.bloodOxygenPulseRate,
75
- bloodOxygen: valueOf(reading, "spo2"),
76
- pulseRate: valueOf(reading, "pulse_rate"),
77
- perfusionIndex: valueOf(reading, "perfusion_index"),
52
+ bloodOxygen: (0, _readingValues.valueOf)(reading, "spo2"),
53
+ pulseRate: (0, _readingValues.valueOf)(reading, "pulse_rate"),
54
+ perfusionIndex: (0, _readingValues.valueOf)(reading, "perfusion_index"),
78
55
  recordedAt: reading.takenAt ?? undefined
79
56
  });
80
-
81
- /** Ovok stores ECG points in millivolts; a trace in any other unit is left out rather than mislabelled. */
82
- const ECG_POINT_UNIT = "mV";
83
- const ecg = reading => {
84
- const waveform = reading.waveform?.unit === ECG_POINT_UNIT ? reading.waveform : undefined;
85
- const samples = waveform?.samples[0] ?? new Int16Array(0);
86
- return {
87
- measurementTypeKey: _next.MeasurementTypeKey.ecg,
88
- heartRate: valueOf(reading, "heart_rate"),
89
- diagramPoints: Array.from(samples, sample => sample * (waveform?.scale ?? 1)),
90
- duration: waveform ? samples.length / waveform.sampleRateHz : undefined,
91
- recordedAt: reading.takenAt ?? undefined
92
- };
93
- };
94
-
95
- /** A per-second series, such as an ER1 trend, has no single-value measurement; it waits for series saving in core. */
96
- const heartRate = reading => reading.series ? undefined : {
57
+ const heartRate = reading => ({
97
58
  measurementTypeKey: _next.MeasurementTypeKey.heartRate,
98
- heartRate: valueOf(reading, "heart_rate"),
59
+ heartRate: (0, _readingValues.valueOf)(reading, "heart_rate"),
99
60
  recordedAt: reading.takenAt ?? undefined
100
- };
101
- const respiratoryRate = reading => reading.series ? undefined : {
61
+ });
62
+ const respiratoryRate = reading => ({
102
63
  measurementTypeKey: _next.MeasurementTypeKey.respiratoryRate,
103
- respiratoryRate: valueOf(reading, "respiration_rate"),
64
+ respiratoryRate: (0, _readingValues.valueOf)(reading, "respiration_rate"),
104
65
  recordedAt: reading.takenAt ?? undefined
105
- };
66
+ });
106
67
  const LIPID_METRICS = ["blood_cholesterol", "hdl_cholesterol", "ldl_cholesterol", "triglycerides"];
107
68
  const LIPID_UNITS = ["mg/dL", "mmol/L"];
108
69
  const isLipidUnit = unit => LIPID_UNITS.some(lipidUnit => lipidUnit === unit);
@@ -113,10 +74,10 @@ const lipidPanel = reading => {
113
74
  const [unit] = units;
114
75
  return units.size === 1 && isLipidUnit(unit) ? {
115
76
  measurementTypeKey: _next.MeasurementTypeKey.lipidPanel,
116
- totalCholesterol: valueOf(reading, "blood_cholesterol"),
117
- hdlCholesterol: valueOf(reading, "hdl_cholesterol"),
118
- ldlCholesterol: valueOf(reading, "ldl_cholesterol"),
119
- triglycerides: valueOf(reading, "triglycerides"),
77
+ totalCholesterol: (0, _readingValues.valueOf)(reading, "blood_cholesterol"),
78
+ hdlCholesterol: (0, _readingValues.valueOf)(reading, "hdl_cholesterol"),
79
+ ldlCholesterol: (0, _readingValues.valueOf)(reading, "ldl_cholesterol"),
80
+ triglycerides: (0, _readingValues.valueOf)(reading, "triglycerides"),
120
81
  unit,
121
82
  recordedAt: reading.takenAt ?? undefined
122
83
  } : undefined;
@@ -125,11 +86,11 @@ const lipidPanel = reading => {
125
86
  /** A spirometry test without any value in Ovok's units cannot be saved. */
126
87
  const spirometry = reading => {
127
88
  const values = {
128
- fvc: ovokValueOf(reading, "fvc"),
129
- fev1: ovokValueOf(reading, "fev1"),
130
- "fev1/fvc": ovokValueOf(reading, "fev1_fvc_ratio"),
131
- pef: ovokValueOf(reading, "pef"),
132
- fef2575: ovokValueOf(reading, "fef25_75")
89
+ fvc: (0, _readingValues.ovokValueOf)(reading, "fvc"),
90
+ fev1: (0, _readingValues.ovokValueOf)(reading, "fev1"),
91
+ "fev1/fvc": (0, _readingValues.ovokValueOf)(reading, "fev1_fvc_ratio"),
92
+ pef: (0, _readingValues.ovokValueOf)(reading, "pef"),
93
+ fef2575: (0, _readingValues.ovokValueOf)(reading, "fef25_75")
133
94
  };
134
95
  return Object.values(values).some(value => value !== undefined) ? {
135
96
  measurementTypeKey: _next.MeasurementTypeKey.spirometryPanel,
@@ -137,20 +98,24 @@ const spirometry = reading => {
137
98
  recordedAt: reading.takenAt ?? undefined
138
99
  } : undefined;
139
100
  };
101
+ const single = measure => reading => {
102
+ const measurement = measure(reading);
103
+ return measurement ? [measurement] : [];
104
+ };
140
105
 
141
- /** How each reading type becomes an Ovok measurement; a type missing here cannot be saved yet. */
106
+ /** How each reading type becomes Ovok measurements, one for most and one per channel for an ECG; a type missing here cannot be saved yet. */
142
107
  const MEASUREMENTS = {
143
- blood_pressure: bloodPressure,
144
- blood_glucose: bloodGlucose,
145
- blood_cholesterol: lipidPanel,
146
- ecg,
147
- heart_rate: heartRate,
148
- oxygen_saturation: pulseOximetry,
149
- respiration_rate: respiratoryRate,
150
- spirometry,
151
- temperature: bodyTemperature,
152
- triglycerides: lipidPanel,
153
- weight: bodyWeight
108
+ blood_pressure: single(bloodPressure),
109
+ blood_glucose: single(bloodGlucose),
110
+ blood_cholesterol: single(lipidPanel),
111
+ ecg: _ecgMeasurements.ecgMeasurements,
112
+ heart_rate: single(heartRate),
113
+ oxygen_saturation: single(pulseOximetry),
114
+ respiration_rate: single(respiratoryRate),
115
+ spirometry: single(spirometry),
116
+ temperature: single(bodyTemperature),
117
+ triglycerides: single(lipidPanel),
118
+ weight: single(bodyWeight)
154
119
  };
155
120
  const deviceOf = (reading, device) => ({
156
121
  id: reading.source.address,
@@ -167,24 +132,60 @@ const deviceOf = (reading, device) => ({
167
132
  batteryPercentage: device.battery?.percent
168
133
  });
169
134
 
170
- /** Saves readings for the signed-in account through the Ovok measurements API, queueing them offline. */
135
+ /** What the sink saves with: the measurements API, the outbox that deletes, and the session that names the patient. */
136
+
137
+ const unsupported = what => new _errors.DeviceError("unsupported", `Ovok cannot save ${what} yet`);
138
+
139
+ /** Live numbers are saved as series and a live ECG as a recording; any other live trace has no place in Ovok yet. */
140
+ const isUnsavableLive = reading => reading.live !== undefined && reading.series === undefined && reading.type !== "ecg";
141
+ const hasValues = reading => Object.keys(reading.values).length > 0;
142
+ const saveMeasurements = async (client, reading, device) => {
143
+ const measurements = MEASUREMENTS[reading.type]?.(reading) ?? [];
144
+ if (measurements.length === 0) {
145
+ throw unsupported(`a ${reading.type} reading of this shape`);
146
+ }
147
+ const results = [];
148
+ for (const [index, measurement] of measurements.entries()) {
149
+ results.push(await client.measurements.save({
150
+ measurement,
151
+ sourceId: (0, _readingSourceId.partSourceId)((0, _readingSourceId.sourceIdOf)(reading), index),
152
+ effectiveDateTime: reading.takenAt ?? undefined,
153
+ device
154
+ }));
155
+ }
156
+ return results;
157
+ };
158
+
159
+ /** Queued when any part of the reading is, with the outbox item of each queued part. */
160
+ const receiptOf = results => {
161
+ const queueIds = results.flatMap(result => result.status === "queued" ? [result.queueId] : []);
162
+ return queueIds.length > 0 ? {
163
+ status: "queued",
164
+ queueIds
165
+ } : {
166
+ status: "saved"
167
+ };
168
+ };
169
+
170
+ /**
171
+ * Saves readings for the signed-in account through the Ovok measurements API, queueing them offline. A reading with a
172
+ * series also saves it; a stored record then removes the live recordings it replaces, once it is saved.
173
+ */
171
174
  const ovokReadingSink = client => ({
172
175
  save: async (reading, device) => {
173
- const measurement = MEASUREMENTS[reading.type]?.(reading);
174
- if (!measurement) {
175
- throw new _errors.DeviceError("unsupported", `Ovok cannot save a ${reading.type} reading of this shape yet`);
176
+ if (isUnsavableLive(reading)) {
177
+ throw unsupported(`a live ${reading.live?.metric} recording`);
176
178
  }
177
- const {
178
- address,
179
- recordId
180
- } = reading.source;
181
- const result = await client.measurements.save({
182
- measurement,
183
- sourceId: recordId === null ? undefined : `bluetooth:${address}:${recordId}`,
184
- effectiveDateTime: reading.takenAt ?? undefined,
185
- device: deviceOf(reading, device)
186
- });
187
- return result.status;
179
+ const target = deviceOf(reading, device);
180
+ const results = [];
181
+ if ((0, _seriesSaving.isSeriesReading)(reading)) {
182
+ results.push(await (0, _seriesSaving.saveSeries)(client, reading, target));
183
+ }
184
+ if (!(0, _seriesSaving.isSeriesReading)(reading) || hasValues(reading)) {
185
+ results.push(...(await saveMeasurements(client, reading, target)));
186
+ }
187
+ await (0, _liveSupersession.replaceLiveRecordings)(client, reading);
188
+ return receiptOf(results);
188
189
  }
189
190
  });
190
191
  exports.ovokReadingSink = ovokReadingSink;