@ovok/native 0.4.5 → 0.4.7

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 (380) hide show
  1. package/lib/commonjs/modules/bt-management/index.js +176 -0
  2. package/lib/commonjs/modules/bt-management/index.js.map +1 -1
  3. package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js +49 -0
  4. package/lib/commonjs/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
  5. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js +47 -41
  6. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
  7. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
  8. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
  9. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js +98 -0
  10. package/lib/commonjs/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
  11. package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js +24 -1
  12. package/lib/commonjs/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
  13. package/lib/commonjs/modules/bt-management/services/device-creator.js +15 -8
  14. package/lib/commonjs/modules/bt-management/services/device-creator.js.map +1 -1
  15. package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js +85 -0
  16. package/lib/commonjs/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
  17. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -74
  18. package/lib/commonjs/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
  19. package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js +141 -0
  20. package/lib/commonjs/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
  21. package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js +16 -50
  22. package/lib/commonjs/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
  23. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js +17 -6
  24. package/lib/commonjs/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  25. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js +21 -14
  26. package/lib/commonjs/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  27. package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +36 -0
  28. package/lib/commonjs/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
  29. package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js +81 -14
  30. package/lib/commonjs/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
  31. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js +48 -0
  32. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
  33. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js +37 -0
  34. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
  35. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js +83 -0
  36. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
  37. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js +26 -0
  38. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
  39. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js +36 -0
  40. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
  41. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +155 -0
  42. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
  43. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +98 -0
  44. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
  45. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js +29 -0
  46. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
  47. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +103 -0
  48. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
  49. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js +32 -0
  50. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
  51. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js +64 -0
  52. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
  53. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js +143 -0
  54. package/lib/commonjs/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
  55. package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js +38 -0
  56. package/lib/commonjs/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
  57. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +156 -0
  58. package/lib/commonjs/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
  59. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +124 -0
  60. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
  61. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +113 -0
  62. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
  63. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js +117 -0
  64. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
  65. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js +82 -0
  66. package/lib/commonjs/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
  67. package/lib/commonjs/modules/bt-management/types/command-sequencer.js +6 -0
  68. package/lib/commonjs/modules/bt-management/types/command-sequencer.js.map +1 -0
  69. package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
  70. package/lib/commonjs/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
  71. package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js +6 -0
  72. package/lib/commonjs/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
  73. package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js +2 -0
  74. package/lib/commonjs/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
  75. package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js +6 -0
  76. package/lib/commonjs/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
  77. package/lib/commonjs/modules/bt-management/types/device-command.js +2 -0
  78. package/lib/commonjs/modules/bt-management/types/device-command.js.map +1 -0
  79. package/lib/commonjs/modules/bt-management/types/measurement-group.js +6 -0
  80. package/lib/commonjs/modules/bt-management/types/measurement-group.js.map +1 -0
  81. package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js +49 -0
  82. package/lib/commonjs/modules/bt-management/utils/calculate-checksum.js.map +1 -0
  83. package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js +9 -0
  84. package/lib/commonjs/modules/bt-management/utils/create-frame-validator.js.map +1 -1
  85. package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js +19 -0
  86. package/lib/commonjs/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
  87. package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js +13 -0
  88. package/lib/commonjs/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
  89. package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js +22 -0
  90. package/lib/commonjs/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
  91. package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js +18 -0
  92. package/lib/commonjs/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
  93. package/lib/module/modules/bt-management/index.js +16 -0
  94. package/lib/module/modules/bt-management/index.js.map +1 -1
  95. package/lib/module/modules/bt-management/services/custom/compile-case-fields.js +44 -0
  96. package/lib/module/modules/bt-management/services/custom/compile-case-fields.js.map +1 -0
  97. package/lib/module/modules/bt-management/services/custom/compile-custom-case.js +47 -41
  98. package/lib/module/modules/bt-management/services/custom/compile-custom-case.js.map +1 -1
  99. package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js +48 -2
  100. package/lib/module/modules/bt-management/services/custom/compile-custom-frame.js.map +1 -1
  101. package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js +93 -0
  102. package/lib/module/modules/bt-management/services/custom/compile-custom-lepu.js.map +1 -0
  103. package/lib/module/modules/bt-management/services/custom/define-custom-device.js +24 -1
  104. package/lib/module/modules/bt-management/services/custom/define-custom-device.js.map +1 -1
  105. package/lib/module/modules/bt-management/services/device-creator.js +16 -8
  106. package/lib/module/modules/bt-management/services/device-creator.js.map +1 -1
  107. package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js +81 -0
  108. package/lib/module/modules/bt-management/services/devices/aoj/aoj.thermometers.js.map +1 -0
  109. package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js +8 -73
  110. package/lib/module/modules/bt-management/services/devices/bp2/bp2.frame-reader.js.map +1 -1
  111. package/lib/module/modules/bt-management/services/devices/bt-command-writer.js +136 -0
  112. package/lib/module/modules/bt-management/services/devices/bt-command-writer.js.map +1 -0
  113. package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js +16 -50
  114. package/lib/module/modules/bt-management/services/devices/bt-connection-handler.js.map +1 -1
  115. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js +17 -6
  116. package/lib/module/modules/bt-management/services/devices/bt-data-processor.js.map +1 -1
  117. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js +21 -14
  118. package/lib/module/modules/bt-management/services/devices/bt-managed-device.js.map +1 -1
  119. package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js +32 -0
  120. package/lib/module/modules/bt-management/services/devices/custom/custom-lepu-sequencer.js.map +1 -0
  121. package/lib/module/modules/bt-management/services/devices/custom/custom.device.js +81 -14
  122. package/lib/module/modules/bt-management/services/devices/custom/custom.device.js.map +1 -1
  123. package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js +43 -0
  124. package/lib/module/modules/bt-management/services/devices/lepu/lepu.command-builder.js.map +1 -0
  125. package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js +33 -0
  126. package/lib/module/modules/bt-management/services/devices/lepu/lepu.commands.js.map +1 -0
  127. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js +79 -0
  128. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-info.js.map +1 -0
  129. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js +22 -0
  130. package/lib/module/modules/bt-management/services/devices/lepu/lepu.device-names.js.map +1 -0
  131. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js +32 -0
  132. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-names.js.map +1 -0
  133. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js +150 -0
  134. package/lib/module/modules/bt-management/services/devices/lepu/lepu.file-transfer.js.map +1 -0
  135. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js +93 -0
  136. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame-reader.js.map +1 -0
  137. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js +24 -0
  138. package/lib/module/modules/bt-management/services/devices/lepu/lepu.frame.js.map +1 -0
  139. package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js +98 -0
  140. package/lib/module/modules/bt-management/services/devices/lepu/lepu.identity-gate.js.map +1 -0
  141. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js +27 -0
  142. package/lib/module/modules/bt-management/services/devices/lepu/lepu.name-match.js.map +1 -0
  143. package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js +59 -0
  144. package/lib/module/modules/bt-management/services/devices/lepu/lepu.response-type.js.map +1 -0
  145. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js +140 -0
  146. package/lib/module/modules/bt-management/services/devices/lepu/lepu.transports.js.map +1 -0
  147. package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js +34 -0
  148. package/lib/module/modules/bt-management/services/devices/polling-command-sequencer.js.map +1 -0
  149. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js +149 -0
  150. package/lib/module/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.js.map +1 -0
  151. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js +118 -0
  152. package/lib/module/modules/bt-management/services/devices/viatom/viatom.bp-monitors.js.map +1 -0
  153. package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js +108 -0
  154. package/lib/module/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.js.map +1 -0
  155. package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js +114 -0
  156. package/lib/module/modules/bt-management/services/devices/viatom/viatom.lepod.js.map +1 -0
  157. package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js +79 -0
  158. package/lib/module/modules/bt-management/services/devices/viatom/viatom.oximeters.js.map +1 -0
  159. package/lib/module/modules/bt-management/types/command-sequencer.js +4 -0
  160. package/lib/module/modules/bt-management/types/command-sequencer.js.map +1 -0
  161. package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js +2 -0
  162. package/lib/module/modules/bt-management/types/custom-checksum-algorithm.js.map +1 -0
  163. package/lib/module/modules/bt-management/types/custom-checksum-spec.js +4 -0
  164. package/lib/module/modules/bt-management/types/custom-checksum-spec.js.map +1 -0
  165. package/lib/module/modules/bt-management/types/custom-device-definition.js.map +1 -1
  166. package/lib/module/modules/bt-management/types/custom-lepu-spec.js +2 -0
  167. package/lib/module/modules/bt-management/types/custom-lepu-spec.js.map +1 -0
  168. package/lib/module/modules/bt-management/types/custom-measurement-spec.js +4 -0
  169. package/lib/module/modules/bt-management/types/custom-measurement-spec.js.map +1 -0
  170. package/lib/module/modules/bt-management/types/device-command.js +2 -0
  171. package/lib/module/modules/bt-management/types/device-command.js.map +1 -0
  172. package/lib/module/modules/bt-management/types/measurement-group.js +4 -0
  173. package/lib/module/modules/bt-management/types/measurement-group.js.map +1 -0
  174. package/lib/module/modules/bt-management/utils/calculate-checksum.js +44 -0
  175. package/lib/module/modules/bt-management/utils/calculate-checksum.js.map +1 -0
  176. package/lib/module/modules/bt-management/utils/create-frame-validator.js +9 -0
  177. package/lib/module/modules/bt-management/utils/create-frame-validator.js.map +1 -1
  178. package/lib/module/modules/bt-management/utils/hex-to-bytes.js +14 -0
  179. package/lib/module/modules/bt-management/utils/hex-to-bytes.js.map +1 -0
  180. package/lib/module/modules/bt-management/utils/le-32-to-bytes.js +8 -0
  181. package/lib/module/modules/bt-management/utils/le-32-to-bytes.js.map +1 -0
  182. package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js +17 -0
  183. package/lib/module/modules/bt-management/utils/summarise-measurement-for-log.js.map +1 -0
  184. package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js +13 -0
  185. package/lib/module/modules/bt-management/utils/supported-measurement-type-keys.js.map +1 -0
  186. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts +16 -0
  187. package/lib/typescript/commonjs/src/modules/bt-management/index.d.ts.map +1 -1
  188. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
  189. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
  191. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
  192. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
  193. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -1
  195. package/lib/typescript/commonjs/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  196. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts +24 -0
  197. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
  199. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
  200. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
  201. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
  202. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
  203. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
  204. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -1
  205. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  206. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts +12 -1
  207. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  208. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
  209. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
  210. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
  211. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
  212. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
  213. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
  214. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
  215. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
  216. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
  217. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
  218. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
  219. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
  220. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
  221. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
  222. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
  223. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
  224. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
  225. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
  226. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
  227. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
  228. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
  229. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
  230. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
  231. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
  232. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
  233. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
  234. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
  235. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
  236. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
  237. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
  238. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
  239. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
  240. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
  241. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
  242. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
  243. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
  244. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
  245. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
  246. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
  247. package/lib/typescript/commonjs/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
  248. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
  249. package/lib/typescript/commonjs/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
  250. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
  251. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
  252. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
  253. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
  254. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
  255. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
  256. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
  257. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
  258. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
  259. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
  260. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
  261. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
  262. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
  263. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
  264. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
  265. package/lib/typescript/commonjs/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
  266. package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts +18 -0
  267. package/lib/typescript/commonjs/src/modules/bt-management/types/device-command.d.ts.map +1 -0
  268. package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts +14 -0
  269. package/lib/typescript/commonjs/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
  270. package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts +9 -0
  271. package/lib/typescript/commonjs/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
  272. package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
  273. package/lib/typescript/commonjs/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
  274. package/lib/typescript/commonjs/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
  275. package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
  276. package/lib/typescript/commonjs/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
  277. package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
  278. package/lib/typescript/commonjs/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
  279. package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
  280. package/lib/typescript/commonjs/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
  281. package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
  282. package/lib/typescript/commonjs/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
  283. package/lib/typescript/module/src/modules/bt-management/index.d.ts +16 -0
  284. package/lib/typescript/module/src/modules/bt-management/index.d.ts.map +1 -1
  285. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts +13 -0
  286. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-case-fields.d.ts.map +1 -0
  287. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-case.d.ts.map +1 -1
  288. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-frame.d.ts.map +1 -1
  289. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts +11 -0
  290. package/lib/typescript/module/src/modules/bt-management/services/custom/compile-custom-lepu.d.ts.map +1 -0
  291. package/lib/typescript/module/src/modules/bt-management/services/custom/define-custom-device.d.ts.map +1 -1
  292. package/lib/typescript/module/src/modules/bt-management/services/device-creator.d.ts.map +1 -1
  293. package/lib/typescript/module/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts +24 -0
  294. package/lib/typescript/module/src/modules/bt-management/services/devices/aoj/aoj.thermometers.d.ts.map +1 -0
  295. package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts +5 -8
  296. package/lib/typescript/module/src/modules/bt-management/services/devices/bp2/bp2.frame-reader.d.ts.map +1 -1
  297. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts +67 -0
  298. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-command-writer.d.ts.map +1 -0
  299. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts +6 -4
  300. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-connection-handler.d.ts.map +1 -1
  301. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts +20 -1
  302. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-data-processor.d.ts.map +1 -1
  303. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts +12 -1
  304. package/lib/typescript/module/src/modules/bt-management/services/devices/bt-managed-device.d.ts.map +1 -1
  305. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts +21 -0
  306. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom-lepu-sequencer.d.ts.map +1 -0
  307. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts +33 -0
  308. package/lib/typescript/module/src/modules/bt-management/services/devices/custom/custom.device.d.ts.map +1 -1
  309. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts +24 -0
  310. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.command-builder.d.ts.map +1 -0
  311. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts +32 -0
  312. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.commands.d.ts.map +1 -0
  313. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts +27 -0
  314. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-info.d.ts.map +1 -0
  315. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts +20 -0
  316. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.device-names.d.ts.map +1 -0
  317. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts +14 -0
  318. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-names.d.ts.map +1 -0
  319. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts +75 -0
  320. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.file-transfer.d.ts.map +1 -0
  321. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts +28 -0
  322. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame-reader.d.ts.map +1 -0
  323. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts +12 -0
  324. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.frame.d.ts.map +1 -0
  325. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts +81 -0
  326. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.identity-gate.d.ts.map +1 -0
  327. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts +17 -0
  328. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.name-match.d.ts.map +1 -0
  329. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts +33 -0
  330. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.response-type.d.ts.map +1 -0
  331. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts +85 -0
  332. package/lib/typescript/module/src/modules/bt-management/services/devices/lepu/lepu.transports.d.ts.map +1 -0
  333. package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts +27 -0
  334. package/lib/typescript/module/src/modules/bt-management/services/devices/polling-command-sequencer.d.ts.map +1 -0
  335. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts +44 -0
  336. package/lib/typescript/module/src/modules/bt-management/services/devices/standard-gatt/standard-gatt.devices.d.ts.map +1 -0
  337. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts +44 -0
  338. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.bp-monitors.d.ts.map +1 -0
  339. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts +32 -0
  340. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.ecg-recorders.d.ts.map +1 -0
  341. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts +25 -0
  342. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.lepod.d.ts.map +1 -0
  343. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts +39 -0
  344. package/lib/typescript/module/src/modules/bt-management/services/devices/viatom/viatom.oximeters.d.ts.map +1 -0
  345. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts +26 -0
  346. package/lib/typescript/module/src/modules/bt-management/types/command-sequencer.d.ts.map +1 -0
  347. package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts +13 -0
  348. package/lib/typescript/module/src/modules/bt-management/types/custom-case-spec.d.ts.map +1 -1
  349. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts +10 -0
  350. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-algorithm.d.ts.map +1 -0
  351. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts +23 -0
  352. package/lib/typescript/module/src/modules/bt-management/types/custom-checksum-spec.d.ts.map +1 -0
  353. package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts +5 -0
  354. package/lib/typescript/module/src/modules/bt-management/types/custom-device-definition.d.ts.map +1 -1
  355. package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts +12 -0
  356. package/lib/typescript/module/src/modules/bt-management/types/custom-device-spec.d.ts.map +1 -1
  357. package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts +8 -0
  358. package/lib/typescript/module/src/modules/bt-management/types/custom-frame-spec.d.ts.map +1 -1
  359. package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts +44 -0
  360. package/lib/typescript/module/src/modules/bt-management/types/custom-lepu-spec.d.ts.map +1 -0
  361. package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts +9 -0
  362. package/lib/typescript/module/src/modules/bt-management/types/custom-measurement-spec.d.ts.map +1 -0
  363. package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts +18 -0
  364. package/lib/typescript/module/src/modules/bt-management/types/device-command.d.ts.map +1 -0
  365. package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts +14 -0
  366. package/lib/typescript/module/src/modules/bt-management/types/measurement-group.d.ts.map +1 -0
  367. package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts +9 -0
  368. package/lib/typescript/module/src/modules/bt-management/types/parsing-case.d.ts.map +1 -1
  369. package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts +13 -0
  370. package/lib/typescript/module/src/modules/bt-management/utils/calculate-checksum.d.ts.map +1 -0
  371. package/lib/typescript/module/src/modules/bt-management/utils/create-frame-validator.d.ts.map +1 -1
  372. package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts +10 -0
  373. package/lib/typescript/module/src/modules/bt-management/utils/hex-to-bytes.d.ts.map +1 -0
  374. package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts +3 -0
  375. package/lib/typescript/module/src/modules/bt-management/utils/le-32-to-bytes.d.ts.map +1 -0
  376. package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts +9 -0
  377. package/lib/typescript/module/src/modules/bt-management/utils/summarise-measurement-for-log.d.ts.map +1 -0
  378. package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts +10 -0
  379. package/lib/typescript/module/src/modules/bt-management/utils/supported-measurement-type-keys.d.ts.map +1 -0
  380. package/package.json +12 -1
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["modules/bt-management/index.ts"],"mappings":";;AAAA,cAAc,gCAA6B;AAC3C,cAAc,4BAAyB;AACvC,cAAc,kCAA+B;AAC7C,cAAc,8BAA2B;AACzC,cAAc,6BAA0B;AACxC,cAAc,6BAA0B;AACxC,cAAc,qCAAkC;AAChD,cAAc,6BAA0B;AACxC,cAAc,+BAA4B;AAC1C,cAAc,kCAA+B;AAC7C,cAAc,8BAA2B;AACzC,cAAc,8BAA2B;AACzC,cAAc,+BAA4B;AAC1C,cAAc,gCAA6B;AAC3C,cAAc,gCAA6B;AAC3C,cAAc,uBAAoB;AAClC,cAAc,0BAAuB;AACrC,cAAc,wBAAqB;AACnC,cAAc,0BAAuB;AACrC,cAAc,+BAA4B;AAC1C,cAAc,6BAA0B;AACxC,cAAc,yBAAsB;AACpC,cAAc,0BAAuB;AACrC,cAAc,6BAA0B;AACxC,cAAc,sCAAmC;AACjD,cAAc,4BAAyB;AACvC,cAAc,2BAAwB;AACtC,cAAc,0CAAuC;AAErD,cAAc,yCAAsC;AACpD,cAAc,4CAAyC;AACvD,cAAc,0BAAuB;AACrC,cAAc,2CAAwC;AAEtD,cAAc,0CAAuC;AAErD,cAAc,6BAA0B;AACxC,cAAc,6CAA0C;AACxD,cAAc,oCAAiC","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["modules/bt-management/index.ts"],"mappings":";;AAAA,cAAc,gCAA6B;AAC3C,cAAc,4BAAyB;AACvC,cAAc,kCAA+B;AAC7C,cAAc,8BAA2B;AACzC,cAAc,6BAA0B;AACxC,cAAc,6BAA0B;AACxC,cAAc,qCAAkC;AAChD,cAAc,6BAA0B;AACxC,cAAc,+BAA4B;AAC1C,cAAc,kCAA+B;AAC7C,cAAc,8BAA2B;AACzC,cAAc,8BAA2B;AACzC,cAAc,6BAA0B;AACxC,cAAc,+BAA4B;AAC1C,cAAc,gCAA6B;AAC3C,cAAc,gCAA6B;AAC3C,cAAc,8BAA2B;AACzC,cAAc,2BAAwB;AACtC,cAAc,uBAAoB;AAClC,cAAc,0BAAuB;AACrC,cAAc,wBAAqB;AACnC,cAAc,0BAAuB;AACrC,cAAc,+BAA4B;AAC1C,cAAc,6BAA0B;AACxC,cAAc,yBAAsB;AACpC,cAAc,0BAAuB;AACrC,cAAc,6BAA0B;AACxC,cAAc,sCAAmC;AACjD,cAAc,4BAAyB;AACvC,cAAc,2BAAwB;AACtC,cAAc,0CAAuC;AAErD,cAAc,yCAAsC;AACpD,cAAc,4CAAyC;AACvD,cAAc,0BAAuB;AACrC,cAAc,2CAAwC;AACtD,cAAc,2DAAwD;AACtE,cAAc,4CAAyC;AACvD,cAAc,4CAAyC;AACvD,cAAc,iDAA8C;AAC5D,cAAc,+CAA4C;AAC1D,cAAc,mDAAgD;AAC9D,cAAc,2CAAwC;AACtD,cAAc,8CAA2C;AACzD,cAAc,4CAAyC;AACvD,cAAc,0CAAuC;AACrD,cAAc,6CAA0C;AACxD,cAAc,+CAA4C;AAC1D,cAAc,+CAA4C;AAE1D,cAAc,0CAAuC;AAErD,cAAc,6BAA0B;AACxC,cAAc,6CAA0C;AACxD,cAAc,oCAAiC","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ import { measurementFieldCatalog } from "../../constants/measurement-field-catalog.js";
4
+ import { createCustomFieldParser } from "../../utils/create-custom-field-parser.js";
5
+ import { compileCustomField } from "./compile-custom-field.js";
6
+ import { customDeviceError } from "./custom-device-error.js";
7
+ const registerField = (id, path, compiled, measurementTypeKey, fields) => {
8
+ const key = `${measurementTypeKey}:${compiled.name}`;
9
+ const existing = fields.get(key);
10
+ if (existing && (existing.min !== compiled.min || existing.max !== compiled.max)) {
11
+ throw customDeviceError(id, path, `declares ${compiled.name} with different bounds (${compiled.min}-${compiled.max}) than an earlier case (${existing.min}-${existing.max}); a property must mean the same thing in every frame`);
12
+ }
13
+ fields.set(key, compiled);
14
+ };
15
+
16
+ /**
17
+ * A reading must carry every property that makes it that measurement. A blood pressure
18
+ * without a diastolic is not a partial blood pressure, it is a clinical record of something
19
+ * the device never reported, so the declaration is refused rather than the reading dropped.
20
+ */
21
+ const assertRequiredFields = (id, path, declared, measurementTypeKey) => {
22
+ const catalog = measurementFieldCatalog[measurementTypeKey] ?? {};
23
+ const declaredNames = new Set(declared.map(field => field?.name));
24
+ const missing = Object.entries(catalog).filter(([name, field]) => field.required && !declaredNames.has(name)).map(([name]) => name);
25
+ if (missing.length > 0) {
26
+ throw customDeviceError(id, `${path}.fields`, `does not declare ${missing.join(", ")}, which ${measurementTypeKey} needs to be a complete reading`);
27
+ }
28
+ };
29
+ const compileFields = (id, path, declared, measurementTypeKey, minLengthBytes, fields, names) => declared.map((field, index) => {
30
+ if (names.has(field.name)) {
31
+ throw customDeviceError(id, `${path}.fields[${index}].name`, `"${field.name}" is declared twice in this frame; a property name must be unique across every reading the frame carries, because the decoded frame is one flat object`);
32
+ }
33
+ names.add(field.name);
34
+ const compiled = compileCustomField(id, `${path}.fields[${index}]`, field, measurementTypeKey, minLengthBytes);
35
+ registerField(id, path, compiled, measurementTypeKey, fields);
36
+ return {
37
+ name: compiled.name,
38
+ parseType: "custom",
39
+ byteIndexes: compiled.byteIndexes,
40
+ customParserDefinition: createCustomFieldParser(compiled)
41
+ };
42
+ });
43
+ export { assertRequiredFields, compileFields };
44
+ //# sourceMappingURL=compile-case-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["measurementFieldCatalog","createCustomFieldParser","compileCustomField","customDeviceError","registerField","id","path","compiled","measurementTypeKey","fields","key","name","existing","get","min","max","set","assertRequiredFields","declared","catalog","declaredNames","Set","map","field","missing","Object","entries","filter","required","has","length","join","compileFields","minLengthBytes","names","index","add","parseType","byteIndexes","customParserDefinition"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-case-fields.ts"],"mappings":";;AAEA,SAASA,uBAAuB,QAAQ,8CAA2C;AAInF,SAASC,uBAAuB,QAAQ,2CAAwC;AAEhF,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SAASC,iBAAiB,QAAQ,0BAAuB;AAEzD,MAAMC,aAAa,GAAGA,CACpBC,EAAU,EACVC,IAAY,EACZC,QAA6B,EAC7BC,kBAAsC,EACtCC,MAAwC,KAC/B;EACT,MAAMC,GAAG,GAAG,GAAGF,kBAAkB,IAAID,QAAQ,CAACI,IAAI,EAAE;EACpD,MAAMC,QAAQ,GAAGH,MAAM,CAACI,GAAG,CAACH,GAAG,CAAC;EAEhC,IACEE,QAAQ,KACPA,QAAQ,CAACE,GAAG,KAAKP,QAAQ,CAACO,GAAG,IAAIF,QAAQ,CAACG,GAAG,KAAKR,QAAQ,CAACQ,GAAG,CAAC,EAChE;IACA,MAAMZ,iBAAiB,CACrBE,EAAE,EACFC,IAAI,EACJ,YAAYC,QAAQ,CAACI,IAAI,2BAA2BJ,QAAQ,CAACO,GAAG,IAAIP,QAAQ,CAACQ,GAAG,2BAA2BH,QAAQ,CAACE,GAAG,IAAIF,QAAQ,CAACG,GAAG,uDACzI,CAAC;EACH;EAEAN,MAAM,CAACO,GAAG,CAACN,GAAG,EAAEH,QAAQ,CAAC;AAC3B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,MAAMU,oBAAoB,GAAGA,CAC3BZ,EAAU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I,WAAW6B,KAAK,GAAG,EAC1BZ,KAAK,EACLf,kBAAkB,EAClByB,cACF,CAAC;EAED7B,aAAa,CAACC,EAAE,EAAEC,IAAI,EAAEC,QAAQ,EAAEC,kBAAkB,EAAEC,MAAM,CAAC;EAE7D,OAAO;IACLE,IAAI,EAAEJ,QAAQ,CAACI,IAAI;IACnB0B,SAAS,EAAE,QAAQ;IACnBC,WAAW,EAAE/B,QAAQ,CAAC+B,WAAW;IACjCC,sBAAsB,EAAEtC,uBAAuB,CAACM,QAAQ;EAC1D,CAAC;AACH,CAAC,CAAC;AAEJ,SAASU,oBAAoB,EAAEe,aAAa","ignoreList":[]}
@@ -2,8 +2,7 @@
2
2
 
3
3
  import { measurementFieldCatalog } from "../../constants/measurement-field-catalog.js";
4
4
  import { CaseType } from "../../types/case-type.js";
5
- import { createCustomFieldParser } from "../../utils/create-custom-field-parser.js";
6
- import { compileCustomField } from "./compile-custom-field.js";
5
+ import { assertRequiredFields, compileFields } from "./compile-case-fields.js";
7
6
  import { customDeviceError } from "./custom-device-error.js";
8
7
 
9
8
  /**
@@ -33,44 +32,28 @@ const assertMeasurementTypeKey = (id, path, caseSpec) => {
33
32
  }
34
33
  return key;
35
34
  };
36
- const registerField = (id, path, compiled, measurementTypeKey, fields) => {
37
- const key = `${measurementTypeKey}:${compiled.name}`;
38
- const existing = fields.get(key);
39
- if (existing && (existing.min !== compiled.min || existing.max !== compiled.max)) {
40
- throw customDeviceError(id, path, `declares ${compiled.name} with different bounds (${compiled.min}-${compiled.max}) than an earlier case (${existing.min}-${existing.max}); a property must mean the same thing in every frame`);
41
- }
42
- fields.set(key, compiled);
43
- };
44
35
 
45
36
  /**
46
- * A reading must carry every property that makes it that measurement. A blood pressure
47
- * without a diastolic is not a partial blood pressure, it is a clinical record of something
48
- * the device never reported, so the declaration is refused rather than the reading dropped.
37
+ * Every reading the frame carries, the declared one first.
38
+ *
39
+ * A frame reporting one measurement and a frame reporting six are the same shape here, so
40
+ * nothing downstream needs to know which it was reading.
49
41
  */
50
- const assertRequiredFields = (id, path, declared, measurementTypeKey) => {
51
- const catalog = measurementFieldCatalog[measurementTypeKey] ?? {};
52
- const declaredNames = new Set(declared.map(field => field?.name));
53
- const missing = Object.entries(catalog).filter(([name, field]) => field.required && !declaredNames.has(name)).map(([name]) => name);
54
- if (missing.length > 0) {
55
- throw customDeviceError(id, `${path}.fields`, `does not declare ${missing.join(", ")}, which ${measurementTypeKey} needs to be a complete reading`);
42
+ const declaredMeasurements = (id, path, caseSpec, measurementTypeKey) => {
43
+ const additional = caseSpec.additionalMeasurements ?? [];
44
+ if (!Array.isArray(additional)) {
45
+ throw customDeviceError(id, `${path}.additionalMeasurements`, "must be an array of further readings this frame carries");
56
46
  }
57
- };
58
- const compileFields = (id, path, declared, measurementTypeKey, minLengthBytes, fields) => {
59
- const names = new Set();
60
- return declared.map((field, index) => {
61
- if (names.has(field.name)) {
62
- throw customDeviceError(id, `${path}.fields[${index}].name`, `"${field.name}" is declared twice in this case`);
47
+ return [{
48
+ path,
49
+ measurement: {
50
+ measurementTypeKey,
51
+ fields: caseSpec.fields ?? []
63
52
  }
64
- names.add(field.name);
65
- const compiled = compileCustomField(id, `${path}.fields[${index}]`, field, measurementTypeKey, minLengthBytes);
66
- registerField(id, path, compiled, measurementTypeKey, fields);
67
- return {
68
- name: compiled.name,
69
- parseType: "custom",
70
- byteIndexes: compiled.byteIndexes,
71
- customParserDefinition: createCustomFieldParser(compiled)
72
- };
73
- });
53
+ }, ...additional.map((measurement, index) => ({
54
+ path: `${path}.additionalMeasurements[${index}]`,
55
+ measurement
56
+ }))];
74
57
  };
75
58
 
76
59
  /** Validates one declared frame shape and turns it into a parsing case. */
@@ -82,7 +65,7 @@ export const compileCustomCase = (id, path, caseSpec, minLengthBytes, fields) =>
82
65
  const measurementTypeKey = assertMeasurementTypeKey(id, path, caseSpec);
83
66
  const declared = caseSpec.fields ?? [];
84
67
  if (caseSpec.kind !== "result") {
85
- if (declared.length > 0) {
68
+ if (declared.length > 0 || caseSpec.additionalMeasurements) {
86
69
  throw customDeviceError(id, path, 'declares fields, but fields may be declared on only a "result" case');
87
70
  }
88
71
  return {
@@ -97,16 +80,39 @@ export const compileCustomCase = (id, path, caseSpec, minLengthBytes, fields) =>
97
80
  throw customDeviceError(id, path, 'is a "result" case and must declare at least one field');
98
81
  }
99
82
 
100
- // Every field is checked first, so a misspelt property is reported as the typo it is
101
- // rather than as the required property it failed to satisfy.
102
- const parseDefinitions = compileFields(id, path, declared, measurementTypeKey, minLengthBytes, fields);
103
- assertRequiredFields(id, path, declared, measurementTypeKey);
83
+ /** Shared, so a property declared under two readings in one frame is refused. */
84
+ const names = new Set();
85
+ const parseDefinitions = [];
86
+ const measurements = [];
87
+ declaredMeasurements(id, path, caseSpec, measurementTypeKey).forEach(({
88
+ path: measurementPath,
89
+ measurement
90
+ }) => {
91
+ const key = assertMeasurementTypeKey(id, measurementPath, {
92
+ ...measurement,
93
+ kind: "result",
94
+ selector: caseSpec.selector
95
+ });
96
+ if (!key || (measurement.fields ?? []).length === 0) {
97
+ throw customDeviceError(id, measurementPath, "is a reading and must declare at least one field");
98
+ }
99
+
100
+ // Every field is checked first, so a misspelt property is reported as the typo it is
101
+ // rather than as the required property it failed to satisfy.
102
+ parseDefinitions.push(...compileFields(id, measurementPath, measurement.fields, key, minLengthBytes, fields, names));
103
+ assertRequiredFields(id, measurementPath, measurement.fields, key);
104
+ measurements.push({
105
+ measurementTypeKey: key,
106
+ fieldNames: measurement.fields.map(field => field.name)
107
+ });
108
+ });
104
109
  return {
105
110
  measurementTypeKey,
106
111
  caseType,
107
112
  caseValue: String(caseSpec.selector ?? "").toLowerCase(),
108
113
  parseDefinitions,
109
- description: caseSpec.description
114
+ description: caseSpec.description,
115
+ measurements
110
116
  };
111
117
  };
112
118
  //# sourceMappingURL=compile-custom-case.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["measurementFieldCatalog","CaseType","createCustomFieldParser","compileCustomField","customDeviceError","CASE_TYPES","result","DEPENDENT","stream","STREAM","idle","OTHER","assertMeasurementTypeKey","id","path","caseSpec","key","measurementTypeKey","undefined","kind","Object","keys","join","registerField","compiled","fields","name","existing","get","min","max","set","assertRequiredFields","declared","catalog","declaredNames","Set","map","field","missing","entries","filter","required","has","length","compileFields","minLengthBytes","names","index","add","parseType","byteIndexes","customParserDefinition","compileCustomCase","caseType","String","caseValue","selector","toLowerCase","parseDefinitions","description"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-case.ts"],"mappings":";;AAEA,SAASA,uBAAuB,QAAQ,8CAA2C;AACnF,SAASC,QAAQ,QAAQ,0BAAuB;AAMhD,SAASC,uBAAuB,QAAQ,2CAAwC;AAEhF,SAASC,kBAAkB,QAAQ,2BAAwB;AAC3D,SAASC,iBAAiB,QAAQ,0BAAuB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAoD,GAAG;EAC3DC,MAAM,EAAEL,QAAQ,CAACM,SAAS;EAC1BC,MAAM,EAAEP,QAAQ,CAACQ,MAAM;EACvBC,IAAI,EAAET,QAAQ,CAACU;AACjB,CAAC;AAED,MAAMC,wBAAwB,GAAGA,CAC/BC,EAAU,EACVC,IAAY,EACZC,QAAwB,KACW;EACnC,MAAMC,GAAG,GAAGD,QAAQ,CAACE,kBAAkB;EAEvC,IAAID,GAAG,KAAKE,SAAS,EAAE;IACrB,IAAIH,QAAQ,CAACI,IAAI,KAAK,QAAQ,EAAE;MAC9B,MAAMf,iBAAiB,CACrBS,EAAE,EACF,GAAGC,IAAI,qBAAqB,EAC5B,gCACF,CAAC;IACH;IAEA,OAAOI,SAAS;EAClB;EAEA,IAAI,CAAClB,uBAAuB,CAACgB,GAAG,CAAC,EAAE;IACjC,MAAMZ,iBAAiB,CACrBS,EAAE,EACF,GAAGC,IAAI,qBAAqB,EAC5B,IAAIE,GAAG,6HAA6HI,MAAM,CAACC,IAAI,CAC7IrB,uBACF,CAAC,CAACsB,IAAI,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EDO,oBAAoB,CAACnB,EAAE,EAAEC,IAAI,EAAEmB,QAAQ,EAAEhB,kBAAkB,CAAC;EAE5D,OAAO;IACLA,kBAAkB;IAClBqC,QAAQ;IACRE,SAAS,EAAED,MAAM,CAACxC,QAAQ,CAAC0C,QAAQ,IAAI,EAAE,CAAC,CAACC,WAAW,CAAC,CAAC;IACxDC,gBAAgB;IAChBC,WAAW,EAAE7C,QAAQ,CAAC6C;EACxB,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["measurementFieldCatalog","CaseType","assertRequiredFields","compileFields","customDeviceError","CASE_TYPES","result","DEPENDENT","stream","STREAM","idle","OTHER","assertMeasurementTypeKey","id","path","caseSpec","key","measurementTypeKey","undefined","kind","Object","keys","join","declaredMeasurements","additional","additionalMeasurements","Array","isArray","measurement","fields","map","index","compileCustomCase","minLengthBytes","caseType","String","declared","length","caseValue","selector","toLowerCase","parseDefinitions","description","names","Set","measurements","forEach","measurementPath","push","fieldNames","field","name"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-case.ts"],"mappings":";;AAEA,SAASA,uBAAuB,QAAQ,8CAA2C;AACnF,SAASC,QAAQ,QAAQ,0BAAuB;AAQhD,SACEC,oBAAoB,EACpBC,aAAa,QACR,0BAAuB;AAC9B,SAASC,iBAAiB,QAAQ,0BAAuB;;AAEzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAoD,GAAG;EAC3DC,MAAM,EAAEL,QAAQ,CAACM,SAAS;EAC1BC,MAAM,EAAEP,QAAQ,CAACQ,MAAM;EACvBC,IAAI,EAAET,QAAQ,CAACU;AACjB,CAAC;AAED,MAAMC,wBAAwB,GAAGA,CAC/BC,EAAU,EACVC,IAAY,EACZC,QAAwB,KACW;EACnC,MAAMC,GAAG,GAAGD,QAAQ,CAACE,kBAAkB;EAEvC,IAAID,GAAG,KAAKE,SAAS,EAAE;IACrB,IAAIH,QAAQ,CAACI,IAAI,KAAK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AAwB,CAACC,EAAE,EAAEkC,eAAe,EAAE;MACxD,GAAGnB,WAAW;MACdT,IAAI,EAAE,QAAQ;MACdoB,QAAQ,EAAExB,QAAQ,CAACwB;IACrB,CAAC,CAAC;IAEF,IAAI,CAACvB,GAAG,IAAI,CAACY,WAAW,CAACC,MAAM,IAAI,EAAE,EAAEQ,MAAM,KAAK,CAAC,EAAE;MACnD,MAAMjC,iBAAiB,CACrBS,EAAE,EACFkC,eAAe,EACf,kDACF,CAAC;IACH;;IAEA;IACA;IACAN,gBAAgB,CAACO,IAAI,CACnB,GAAG7C,aAAa,CACdU,EAAE,EACFkC,eAAe,EACfnB,WAAW,CAACC,MAAM,EAClBb,GAAG,EACHiB,cAAc,EACdJ,MAAM,EACNc,KACF,CACF,CAAC;IAEDzC,oBAAoB,CAACW,EAAE,EAAEkC,eAAe,EAAEnB,WAAW,CAACC,MAAM,EAAEb,GAAG,CAAC;IAElE6B,YAAY,CAACG,IAAI,CAAC;MAChB/B,kBAAkB,EAAED,GAAG;MACvBiC,UAAU,EAAErB,WAAW,CAACC,MAAM,CAACC,GAAG,CAAEoB,KAAK,IAAKA,KAAK,CAACC,IAAI;IAC1D,CAAC,CAAC;EACJ,CACF,CAAC;EAED,OAAO;IACLlC,kBAAkB;IAClBiB,QAAQ;IACRI,SAAS,EAAEH,MAAM,CAACpB,QAAQ,CAACwB,QAAQ,IAAI,EAAE,CAAC,CAACC,WAAW,CAAC,CAAC;IACxDC,gBAAgB;IAChBC,WAAW,EAAE3B,QAAQ,CAAC2B,WAAW;IACjCG;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,8 +1,47 @@
1
1
  "use strict";
2
2
 
3
+ import { isChecksumAlgorithm } from "../../utils/calculate-checksum.js";
3
4
  import { customDeviceError } from "./custom-device-error.js";
4
5
  const HEX_BYTE = /^[0-9a-f]{2}$/;
5
6
 
7
+ /**
8
+ * Checks a checksum declaration against the frame it belongs to.
9
+ *
10
+ * Every byte it reads must be inside minLengthBytes, for the same reason field offsets are:
11
+ * a checksum verified against bytes the frame does not guarantee are present would pass on
12
+ * a truncated buffer and reject a whole one.
13
+ */
14
+ const compileChecksum = (id, path, minLengthBytes, checksum) => {
15
+ if (!isChecksumAlgorithm(checksum.algorithm)) {
16
+ throw customDeviceError(id, `${path}.algorithm`, 'must be one of "crc8", "xor" or "sum"');
17
+ }
18
+ if (!Number.isInteger(checksum.index) || checksum.index < 0) {
19
+ throw customDeviceError(id, `${path}.index`, "must be a byte offset of at least 0");
20
+ }
21
+ if (checksum.index >= minLengthBytes) {
22
+ throw customDeviceError(id, `${path}.index`, `reads byte ${checksum.index}, which frame.minLengthBytes (${minLengthBytes}) does not guarantee is present`);
23
+ }
24
+ const from = checksum.from ?? 0;
25
+ if (!Number.isInteger(from) || from < 0) {
26
+ throw customDeviceError(id, `${path}.from`, "must be a byte offset of at least 0");
27
+ }
28
+ const byteCount = checksum.byteCount ?? checksum.index - from;
29
+ if (!Number.isInteger(byteCount) || byteCount < 1) {
30
+ throw customDeviceError(id, `${path}.byteCount`, "must cover at least one byte");
31
+ }
32
+ if (from + byteCount > minLengthBytes) {
33
+ throw customDeviceError(id, `${path}.byteCount`, `covers bytes ${from}-${from + byteCount - 1}, which frame.minLengthBytes (${minLengthBytes}) does not guarantee are present`);
34
+ }
35
+ if (checksum.index >= from && checksum.index < from + byteCount) {
36
+ throw customDeviceError(id, `${path}.index`, `is inside the bytes it covers (${from}-${from + byteCount - 1}), so it could never match`);
37
+ }
38
+ return Object.freeze({
39
+ ...checksum,
40
+ from,
41
+ byteCount
42
+ });
43
+ };
44
+
6
45
  /**
7
46
  * Checks that a frame declaration can actually recognise a complete package, and returns a
8
47
  * frozen, lower-cased copy of it.
@@ -29,11 +68,15 @@ export const compileCustomFrame = (id, path, frame) => {
29
68
  if (header.length > minLengthBytes) {
30
69
  throw customDeviceError(id, `${path}.header`, `is ${header.length} bytes, which does not fit inside minLengthBytes (${minLengthBytes})`);
31
70
  }
71
+ const checksum = frame.checksum ? compileChecksum(id, `${path}.checksum`, minLengthBytes, frame.checksum) : undefined;
32
72
  const length = frame.length;
33
73
  if (!length) {
34
74
  return Object.freeze({
35
75
  header: Object.freeze(header),
36
- minLengthBytes
76
+ minLengthBytes,
77
+ ...(checksum ? {
78
+ checksum
79
+ } : {})
37
80
  });
38
81
  }
39
82
  if (!Number.isInteger(length.index) || length.index < 0) {
@@ -53,7 +96,10 @@ export const compileCustomFrame = (id, path, frame) => {
53
96
  minLengthBytes,
54
97
  length: Object.freeze({
55
98
  ...length
56
- })
99
+ }),
100
+ ...(checksum ? {
101
+ checksum
102
+ } : {})
57
103
  });
58
104
  };
59
105
  //# sourceMappingURL=compile-custom-frame.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["customDeviceError","HEX_BYTE","compileCustomFrame","id","path","frame","minLengthBytes","Number","isInteger","declaredHeader","header","Array","isArray","map","byte","String","toLowerCase","some","test","length","Object","freeze","index","widthBytes","overheadBytes"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-frame.ts"],"mappings":";;AAEA,SAASA,iBAAiB,QAAQ,0BAAuB;AAEzD,MAAMC,QAAQ,GAAG,eAAe;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,EAAU,EACVC,IAAY,EACZC,KAAsB,KACF;EACpB,MAAMC,cAAc,GAAGD,KAAK,EAAEC,cAAc;EAE5C,IAAI,CAACC,MAAM,CAACC,SAAS,CAACF,cAAc,CAAC,IAAIA,cAAc,GAAG,CAAC,EAAE;IAC3D,MAAMN,iBAAiB,CACrBG,EAAE,EACF,GAAGC,IAAI,iBAAiB,EACxB,sCACF,CAAC;EACH;EAEA,MAAMK,cAAc,GAAGJ,KAAK,CAACK,MAAM,IAAI,EAAE;EAEzC,IAAI,CAACC,KAAK,CAACC,OAAO,CAACH,cAAc,CAAC,EAAE;IAClC,MAAMT,iBAAiB,CAACG,EAAE,EAAE,G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,CACrBG,EAAE,EACF,GAAGC,IAAI,uBAAuB,EAC9B,sCACF,CAAC;EACH;EAEA,IAAIe,MAAM,CAACG,KAAK,GAAGH,MAAM,CAACI,UAAU,GAAGjB,cAAc,EAAE;IACrD,MAAMN,iBAAiB,CACrBG,EAAE,EACF,GAAGC,IAAI,SAAS,EAChB,eAAee,MAAM,CAACG,KAAK,IAAIH,MAAM,CAACG,KAAK,GAAGH,MAAM,CAACI,UAAU,GAAG,CAAC,iCAAiCjB,cAAc,kCACpH,CAAC;EACH;EAEA,OAAOc,MAAM,CAACC,MAAM,CAAC;IACnBX,MAAM,EAAEU,MAAM,CAACC,MAAM,CAACX,MAAM,CAAa;IACzCJ,cAAc;IACda,MAAM,EAAEC,MAAM,CAACC,MAAM,CAAC;MAAE,GAAGF;IAAO,CAAC;EACrC,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["isChecksumAlgorithm","customDeviceError","HEX_BYTE","compileChecksum","id","path","minLengthBytes","checksum","algorithm","Number","isInteger","index","from","byteCount","Object","freeze","compileCustomFrame","frame","declaredHeader","header","Array","isArray","map","byte","String","toLowerCase","some","test","length","undefined","widthBytes","overheadBytes"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-frame.ts"],"mappings":";;AAEA,SAASA,mBAAmB,QAAQ,mCAAgC;AAEpE,SAASC,iBAAiB,QAAQ,0BAAuB;AAEzD,MAAMC,QAAQ,GAAG,eAAe;;AAEhC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGA,CACtBC,EAAU,EACVC,IAAY,EACZC,cAAsB,EACtBC,QAA4B,KACL;EACvB,IAAI,CAACP,mBAAmB,CAACO,QAAQ,CAACC,SAAS,CAAC,EAAE;IAC5C,MAAMP,iBAAiB,CACrBG,EAAE,EACF,GAAGC,IAAI,YAAY,EACnB,uCACF,CAAC;EACH;EAEA,IAAI,CAACI,MAAM,CAACC,SAAS,CAACH,QAAQ,CAACI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AACC,MAAM,CAAC;IACnBI,MAAM,EAAEL,MAAM,CAACC,MAAM,CAACI,MAAM,CAAa;IACzCb,cAAc;IACdsB,MAAM,EAAEd,MAAM,CAACC,MAAM,CAAC;MAAE,GAAGa;IAAO,CAAC,CAAC;IACpC,IAAIrB,QAAQ,GAAG;MAAEA;IAAS,CAAC,GAAG,CAAC,CAAC;EAClC,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ import { customDeviceError } from "./custom-device-error.js";
4
+ import { normalizeBleUuid } from "./normalize-ble-uuid.js";
5
+ const HEX_BYTE = /^[0-9a-f]{2}$/;
6
+ const MAX_OPCODE = 0xff;
7
+ const MAX_DEVICE_TYPE = 0xffff;
8
+ const assertStartBytes = (id, startBytes) => {
9
+ if (!Array.isArray(startBytes) || startBytes.length === 0) {
10
+ throw customDeviceError(id, "lepu.startBytes", "must list at least one frame start byte, such as [\"a5\"]");
11
+ }
12
+ return startBytes.map((byte, index) => {
13
+ const normalized = String(byte).toLowerCase();
14
+ if (!HEX_BYTE.test(normalized)) {
15
+ throw customDeviceError(id, `lepu.startBytes[${index}]`, `is "${String(byte)}"; it must be exactly two hex digits`);
16
+ }
17
+ return normalized;
18
+ });
19
+ };
20
+ const assertDeviceTypes = (id, deviceTypes) => {
21
+ if (!Array.isArray(deviceTypes)) {
22
+ throw customDeviceError(id, "lepu.expectedDeviceTypes", "must be an array of the model numbers this declaration was written for");
23
+ }
24
+ return deviceTypes.map((deviceType, index) => {
25
+ if (!Number.isInteger(deviceType) || deviceType < 0 || deviceType > MAX_DEVICE_TYPE) {
26
+ throw customDeviceError(id, `lepu.expectedDeviceTypes[${index}]`, `is ${String(deviceType)}; a model number is a whole number between 0 and ${MAX_DEVICE_TYPE}`);
27
+ }
28
+ return deviceType;
29
+ });
30
+ };
31
+
32
+ /**
33
+ * The opcode to poll with, once the device has been identified.
34
+ *
35
+ * Identification is the advertised name unless `expectedDeviceTypes` narrows it further.
36
+ * The name is what the vendor's own SDK binds every one of its products on - a 732-line
37
+ * cascade of name checks resolving to 176 models - so requiring more than that to poll at
38
+ * all would hold this SDK to a bar the hardware's own maker does not meet, and would leave
39
+ * every device undeclarable.
40
+ *
41
+ * Naming the models is still the stronger declaration, and is worth doing once the numbers
42
+ * are known: the family's low opcodes act, and a frame built for the wrong product is still
43
+ * well formed, so a name that matched the wrong hardware would not be caught by anything
44
+ * else in the protocol.
45
+ */
46
+ const assertPollCommand = (id, lepu) => {
47
+ const {
48
+ pollCommand
49
+ } = lepu;
50
+ if (pollCommand === undefined) {
51
+ return undefined;
52
+ }
53
+ if (!Number.isInteger(pollCommand) || pollCommand < 0 || pollCommand > MAX_OPCODE) {
54
+ throw customDeviceError(id, "lepu.pollCommand", `is ${String(pollCommand)}; an opcode is a whole number between 0 and ${MAX_OPCODE}`);
55
+ }
56
+ return pollCommand;
57
+ };
58
+
59
+ /**
60
+ * Validates the Lepu declaration and normalises its UUIDs.
61
+ *
62
+ * The write service has to be one the declaration already monitors: a command written to a
63
+ * service the device never opened is accepted by nothing and answered by nothing, which
64
+ * looks exactly like hardware that is simply not responding.
65
+ */
66
+ export const compileCustomLepu = (id, spec, serviceUuids) => {
67
+ const lepu = spec.lepu;
68
+ if (!lepu) {
69
+ return undefined;
70
+ }
71
+ if (spec.services.some(service => service.write)) {
72
+ throw customDeviceError(id, "services[].write", "cannot be declared alongside lepu, which builds its own commands and addresses them through lepu.write");
73
+ }
74
+ const startBytes = assertStartBytes(id, lepu.startBytes);
75
+ const expectedDeviceTypes = assertDeviceTypes(id, lepu.expectedDeviceTypes);
76
+ const pollCommand = assertPollCommand(id, lepu);
77
+ const serviceUuid = normalizeBleUuid(id, "lepu.write.serviceUuid", lepu.write?.serviceUuid);
78
+ if (!serviceUuids.includes(serviceUuid)) {
79
+ throw customDeviceError(id, "lepu.write.serviceUuid", `is "${serviceUuid}", which this device does not declare among its services`);
80
+ }
81
+ return {
82
+ startBytes,
83
+ expectedDeviceTypes,
84
+ ...(pollCommand === undefined ? {} : {
85
+ pollCommand
86
+ }),
87
+ write: {
88
+ serviceUuid,
89
+ characteristicUuid: normalizeBleUuid(id, "lepu.write.characteristicUuid", lepu.write?.characteristicUuid)
90
+ }
91
+ };
92
+ };
93
+ //# sourceMappingURL=compile-custom-lepu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["customDeviceError","normalizeBleUuid","HEX_BYTE","MAX_OPCODE","MAX_DEVICE_TYPE","assertStartBytes","id","startBytes","Array","isArray","length","map","byte","index","normalized","String","toLowerCase","test","assertDeviceTypes","deviceTypes","deviceType","Number","isInteger","assertPollCommand","lepu","pollCommand","undefined","compileCustomLepu","spec","serviceUuids","services","some","service","write","expectedDeviceTypes","serviceUuid","includes","characteristicUuid"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/compile-custom-lepu.ts"],"mappings":";;AAGA,SAASA,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,gBAAgB,QAAQ,yBAAsB;AAEvD,MAAMC,QAAQ,GAAG,eAAe;AAChC,MAAMC,UAAU,GAAG,IAAI;AACvB,MAAMC,eAAe,GAAG,MAAM;AAE9B,MAAMC,gBAAgB,GAAGA,CAACC,EAAU,EAAEC,UAAmB,KAAe;EACtE,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,UAAU,CAAC,IAAIA,UAAU,CAACG,MAAM,KAAK,CAAC,EAAE;IACzD,MAAMV,iBAAiB,CACrBM,EAAE,EACF,iBAAiB,EACjB,2DACF,CAAC;EACH;EAEA,OAAOC,UAAU,CAACI,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;IACrC,MAAMC,UAAU,GAAGC,MAAM,CAACH,IAAI,CAAC,CAACI,WAAW,CAAC,CAAC;IAE7C,IAAI,CAACd,QAAQ,CAACe,IAAI,CAACH,UAAU,CAAC,EAAE;MAC9B,MAAMd,iBAAiB,CACrBM,EAAE,EACF,mBAAmBO,KAAK,GAAG,EAC3B,OAAOE,M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EAAU,EACVsB,IAAsB,EACtBC,YAA+B,KACA;EAC/B,MAAML,IAAI,GAAGI,IAAI,CAACJ,IAAI;EAEtB,IAAI,CAACA,IAAI,EAAE;IACT,OAAOE,SAAS;EAClB;EAEA,IAAIE,IAAI,CAACE,QAAQ,CAACC,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACC,KAAK,CAAC,EAAE;IAClD,MAAMjC,iBAAiB,CACrBM,EAAE,EACF,kBAAkB,EAClB,wGACF,CAAC;EACH;EAEA,MAAMC,UAAU,GAAGF,gBAAgB,CAACC,EAAE,EAAEkB,IAAI,CAACjB,UAAU,CAAC;EACxD,MAAM2B,mBAAmB,GAAGhB,iBAAiB,CAACZ,EAAE,EAAEkB,IAAI,CAACU,mBAAmB,CAAC;EAC3E,MAAMT,WAAW,GAAGF,iBAAiB,CAACjB,EAAE,EAAEkB,IAAI,CAAC;EAE/C,MAAMW,WAAW,GAAGlC,gBAAgB,CAClCK,EAAE,EACF,wBAAwB,EACxBkB,IAAI,CAACS,KAAK,EAAEE,WACd,CAAC;EAED,IAAI,CAACN,YAAY,CAACO,QAAQ,CAACD,WAAW,CAAC,EAAE;IACvC,MAAMnC,iBAAiB,CACrBM,EAAE,EACF,wBAAwB,EACxB,OAAO6B,WAAW,0DACpB,CAAC;EACH;EAEA,OAAO;IACL5B,UAAU;IACV2B,mBAAmB;IACnB,IAAIT,WAAW,KAAKC,SAAS,GAAG,CAAC,CAAC,GAAG;MAAED;IAAY,CAAC,CAAC;IACrDQ,KAAK,EAAE;MACLE,WAAW;MACXE,kBAAkB,EAAEpC,gBAAgB,CAClCK,EAAE,EACF,+BAA+B,EAC/BkB,IAAI,CAACS,KAAK,EAAEI,kBACd;IACF;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -2,11 +2,16 @@
2
2
 
3
3
  import { CUSTOM_DEVICE_BRAND } from "../../constants/custom-device-brand.js";
4
4
  import { IntegratedDevices } from "../../types/integrated-devices.js";
5
+ import { compileCustomLepu } from "./compile-custom-lepu.js";
5
6
  import { compileCustomMonitor } from "./compile-custom-monitor.js";
6
7
  import { customDeviceError } from "./custom-device-error.js";
7
8
  import { normalizeBleUuid } from "./normalize-ble-uuid.js";
8
9
  const MIN_STUCK_TIMEOUT_MS = 1_000;
9
10
 
11
+ /** The smallest MTU a BLE link has, and the largest an ATT packet may declare. */
12
+ const MIN_MTU = 23;
13
+ const MAX_MTU = 517;
14
+
10
15
  // The SDK's own F4 scale waits this long, because it sleeps while still connected.
11
16
  const MAX_STUCK_TIMEOUT_MS = 6_000_000;
12
17
  const HEX_BYTES = /^([0-9a-f]{2})+$/;
@@ -42,6 +47,16 @@ const assertStuckTimeout = (id, spec) => {
42
47
  }
43
48
  return timeout;
44
49
  };
50
+ const assertPreferredMtu = (id, spec) => {
51
+ const mtu = spec.preferredMtu;
52
+ if (mtu === undefined) {
53
+ return undefined;
54
+ }
55
+ if (!Number.isInteger(mtu) || mtu < MIN_MTU || mtu > MAX_MTU) {
56
+ throw customDeviceError(id, "preferredMtu", `is ${String(mtu)}; it must be a whole number between ${MIN_MTU} and ${MAX_MTU}`);
57
+ }
58
+ return mtu;
59
+ };
45
60
  const compileWrite = (id, path, write) => {
46
61
  if (!write) {
47
62
  return undefined;
@@ -68,6 +83,7 @@ export const defineCustomDevice = spec => {
68
83
  const id = assertIdentity(spec);
69
84
  const nameMatch = compileNameMatch(id, spec);
70
85
  const stuckDataTimeout = assertStuckTimeout(id, spec);
86
+ const preferredMtu = assertPreferredMtu(id, spec);
71
87
  if (!Array.isArray(spec.services) || spec.services.length === 0) {
72
88
  throw customDeviceError(id, "services", "must declare at least one service");
73
89
  }
@@ -101,6 +117,7 @@ export const defineCustomDevice = spec => {
101
117
  writeUuid: compileWrite(id, path, service.write)
102
118
  };
103
119
  });
120
+ const lepu = compileCustomLepu(id, spec, mainServices.map(service => service.uuid));
104
121
  return {
105
122
  [CUSTOM_DEVICE_BRAND]: true,
106
123
  id: id,
@@ -109,7 +126,13 @@ export const defineCustomDevice = spec => {
109
126
  mainServices,
110
127
  stuckDataTimeout,
111
128
  fields,
112
- frames
129
+ frames,
130
+ ...(preferredMtu === undefined ? {} : {
131
+ preferredMtu
132
+ }),
133
+ ...(lepu === undefined ? {} : {
134
+ lepu
135
+ })
113
136
  };
114
137
  };
115
138
  //# sourceMappingURL=define-custom-device.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CUSTOM_DEVICE_BRAND","IntegratedDevices","compileCustomMonitor","customDeviceError","normalizeBleUuid","MIN_STUCK_TIMEOUT_MS","MAX_STUCK_TIMEOUT_MS","HEX_BYTES","assertIdentity","spec","id","trim","String","builtIn","Object","values","find","name","toLowerCase","compileNameMatch","nameMatch","RegExp","global","sticky","exact","replace","assertStuckTimeout","timeout","stuckDataTimeoutMs","Number","isInteger","compileWrite","path","write","undefined","commandHex","test","uuid","mainCommandUuid","defineCustomDevice","stuckDataTimeout","Array","isArray","services","length","fields","Map","frames","seenCharacteristics","Set","mainServices","map","service","serviceIndex","monitor","monitorUuids","monitorIndex","monitorPath","characteristic","frame","has","add","set","writeUuid"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/define-custom-device.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,wCAAqC;AAMzE,SAASC,iBAAiB,QAAQ,mCAAgC;AAGlE,SAASC,oBAAoB,QAAQ,6BAA0B;AAC/D,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,gBAAgB,QAAQ,yBAAsB;AAEvD,MAAMC,oBAAoB,GAAG,KAAK;;AAElC;AACA,MAAMC,oBAAoB,GAAG,SAAS;AACtC,MAAMC,SAAS,GAAG,kBAAkB;AAEpC,MAAMC,cAAc,GAAIC,IAAsB,IAAa;EACzD,MAAMC,EAAE,GAAG,OAAOD,IAAI,EAAEC,EAAE,KAAK,QAAQ,GAAGD,IAAI,CAACC,EAAE,CAACC,IAAI,CAAC,CAAC,GAAG,EAAE;EAE7D,IAAI,CAACD,EAAE,EAAE;IACP,MAAMP,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sB,KAAK,CAAC;MAEtC,OAAOD,cAAc;IACvB,CAAC,CAAC;IAEF,OAAO;MACLrB,IAAI,EAAEjC,gBAAgB,CAACM,EAAE,EAAE,GAAGsB,IAAI,OAAO,EAAEoB,OAAO,CAACf,IAAI,CAAC;MACxDkB,YAAY;MACZQ,SAAS,EAAEhC,YAAY,CAACrB,EAAE,EAAEsB,IAAI,EAAEoB,OAAO,CAACnB,KAAK;IACjD,CAAC;EACH,CAAC,CAAC;EAEF,OAAO;IACL,CAACjC,mBAAmB,GAAG,IAAI;IAC3BU,EAAE,EAAEA,EAAoB;IACxBD,IAAI;IACJW,SAAS;IACT8B,YAAY;IACZV,gBAAgB;IAChBK,MAAM;IACNE;EACF,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["CUSTOM_DEVICE_BRAND","IntegratedDevices","compileCustomLepu","compileCustomMonitor","customDeviceError","normalizeBleUuid","MIN_STUCK_TIMEOUT_MS","MIN_MTU","MAX_MTU","MAX_STUCK_TIMEOUT_MS","HEX_BYTES","assertIdentity","spec","id","trim","String","builtIn","Object","values","find","name","toLowerCase","compileNameMatch","nameMatch","RegExp","global","sticky","exact","replace","assertStuckTimeout","timeout","stuckDataTimeoutMs","Number","isInteger","assertPreferredMtu","mtu","preferredMtu","undefined","compileWrite","path","write","commandHex","test","uuid","mainCommandUuid","defineCustomDevice","stuckDataTimeout","Array","isArray","services","length","fields","Map","frames","seenCharacteristics","Set","mainServices","map","service","serviceIndex","monitor","monitorUuids","monitorIndex","monitorPath","characteristic","frame","has","add","set","writeUuid","lepu"],"sourceRoot":"../../../../../../src","sources":["modules/bt-management/services/custom/define-custom-device.ts"],"mappings":";;AAAA,SAASA,mBAAmB,QAAQ,wCAAqC;AAMzE,SAASC,iBAAiB,QAAQ,mCAAgC;AAGlE,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC,oBAAoB,QAAQ,6BAA0B;AAC/D,SAASC,iBAAiB,QAAQ,0BAAuB;AACzD,SAASC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;EAEF,MAAM8B,IAAI,GAAGpE,iBAAiB,CAC5BW,EAAE,EACFD,IAAI,EACJ4C,YAAY,CAACC,GAAG,CAAEC,OAAO,IAAKA,OAAO,CAACf,IAAI,CAC5C,CAAC;EAED,OAAO;IACL,CAAC3C,mBAAmB,GAAG,IAAI;IAC3Ba,EAAE,EAAEA,EAAoB;IACxBD,IAAI;IACJW,SAAS;IACTiC,YAAY;IACZV,gBAAgB;IAChBK,MAAM;IACNE,MAAM;IACN,IAAIjB,YAAY,KAAKC,SAAS,GAAG,CAAC,CAAC,GAAG;MAAED;IAAa,CAAC,CAAC;IACvD,IAAIkC,IAAI,KAAKjC,SAAS,GAAG,CAAC,CAAC,GAAG;MAAEiC;IAAK,CAAC;EACxC,CAAC;AACH,CAAC","ignoreList":[]}
@@ -8,6 +8,20 @@ import { BP2Device } from "./devices/bp2/bp2.device.js";
8
8
  import { CustomDevice } from "./devices/custom/custom.device.js";
9
9
  import { F4Device } from "./devices/f4/f4.device.js";
10
10
  import { SPO2Device } from "./devices/spo/spo2.device.js";
11
+
12
+ /**
13
+ * The built-in names the SDK can actually build.
14
+ *
15
+ * `integratedDevicesMap` matches more names than this, on purpose: matching is what names a
16
+ * device in a scan result and a device list, which is useful for hardware the SDK cannot
17
+ * yet decode. Connecting to one of those is what fails, and it fails saying so.
18
+ */
19
+ const DEVICE_CLASSES = {
20
+ [IntegratedDevices.BP2]: BP2Device,
21
+ [IntegratedDevices.F4]: F4Device,
22
+ [IntegratedDevices.PC60WF]: SPO2Device,
23
+ [IntegratedDevices.BC01]: BC01Device
24
+ };
11
25
  const collectCustomDevices = acceptedDevices => {
12
26
  const customDevices = new Map();
13
27
  const matchers = new Set();
@@ -67,15 +81,9 @@ export class DeviceCreator {
67
81
  // @ts-expect-error - the caller asked for this custom device by its own id
68
82
  return new CustomDevice(params.device, params, custom);
69
83
  }
70
- const deviceMap = {
71
- [IntegratedDevices.BP2]: BP2Device,
72
- [IntegratedDevices.F4]: F4Device,
73
- [IntegratedDevices.PC60WF]: SPO2Device,
74
- [IntegratedDevices.BC01]: BC01Device
75
- };
76
- const deviceClass = deviceMap[params.deviceName];
84
+ const deviceClass = DEVICE_CLASSES[params.deviceName];
77
85
  if (!deviceClass) {
78
- throw new Error(`Device ${params.device.name} not found`);
86
+ throw new Error(`"${params.deviceName}" is a name the SDK matches during a scan but has no decoder for, so "${params.device.name}" cannot be connected. The names it can decode are ${Object.keys(DEVICE_CLASSES).join(", ")}; anything else needs a declaration registered with defineCustomDevice and passed in acceptedDevices.`);
79
87
  }
80
88
 
81
89
  // @ts-expect-error - This is a workaround to allow the deviceClass to be instantiated with the correct type
@@ -1 +1 @@
1
- {"version":3,"names":["integratedDevicesMap","IntegratedDevices","isCustomDeviceDefinition","BC01Device","BP2Device","CustomDevice","F4Device","SPO2Device","collectCustomDevices","acceptedDevices","customDevices","Map","matchers","Set","forEach","entry","index","Error","has","id","nameMatch","source","set","add","DeviceCreator","deviceNameCache","CACHE_MAX_SIZE","constructor","acceptedDeviceNames","getDeviceName","foundName","undefined","get","matched","matchDeviceName","cacheDeviceName","createDevice","params","String","deviceName","trim","device","name","custom","deviceMap","BP2","F4","PC60WF","BC01","deviceClass","destroy","clear","regex","deviceType","test","some","values","size","firstKey","keys","next","value","delete"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/services/device-creator.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,wCAAqC;AAM1E,SAASC,iBAAiB,QAAQ,gCAA6B;AAC/D,SAASC,wBAAwB,QAAQ,yCAAsC;AAE/E,SAASC,UAAU,QAAQ,+BAA4B;AACvD,SAASC,SAAS,QAAQ,6BAA0B;AAEpD,SAASC,YAAY,QAAQ,mCAAgC;AAC7D,SAASC,QAAQ,QAAQ,2BAAwB;AACjD,SAASC,UAAU,QAAQ,8BAA2B;AAEtD,MAAMC,oBAAoB,GACxBC,eAA0C,IACF;EACxC,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAiC,CAAC;EAC/D,MAAMC,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iB,UAAU,EAAEc,UAAU,CAAC;EAClD;AACF","ignoreList":[]}
1
+ {"version":3,"names":["integratedDevicesMap","IntegratedDevices","isCustomDeviceDefinition","BC01Device","BP2Device","CustomDevice","F4Device","SPO2Device","DEVICE_CLASSES","BP2","F4","PC60WF","BC01","collectCustomDevices","acceptedDevices","customDevices","Map","matchers","Set","forEach","entry","index","Error","has","id","nameMatch","source","set","add","DeviceCreator","deviceNameCache","CACHE_MAX_SIZE","constructor","acceptedDeviceNames","getDeviceName","foundName","undefined","get","matched","matchDeviceName","cacheDeviceName","createDevice","params","String","deviceName","trim","device","name","custom","deviceClass","Object","keys","join","destroy","clear","regex","deviceType","test","some","values","size","firstKey","next","value","delete"],"sourceRoot":"../../../../../src","sources":["modules/bt-management/services/device-creator.ts"],"mappings":";;AAAA,SAASA,oBAAoB,QAAQ,wCAAqC;AAM1E,SAASC,iBAAiB,QAAQ,gCAA6B;AAC/D,SAASC,wBAAwB,QAAQ,yCAAsC;AAE/E,SAASC,UAAU,QAAQ,+BAA4B;AACvD,SAASC,SAAS,QAAQ,6BAA0B;AAEpD,SAASC,YAAY,QAAQ,mCAAgC;AAC7D,SAASC,QAAQ,QAAQ,2BAAwB;AACjD,SAASC,UAAU,QAAQ,8BAA2B;;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAG;EACrB,CAACP,iBAAiB,CAACQ,GAAG,GAAGL,SAAS;EAClC,CAACH,iBAAiB,CAACS,EAAE,GAAGJ,QAAQ;EAChC,CAACL,iBAAiB,CAACU,MAAM,GAAGJ,UAAU;EACtC,CAACN,iBAAiB,CAACW,IAAI,GAAGT;AAC5B,CAAC;AAID,MAAMU,oBAAoB,GACxBC,eAA0C,IACF;EACxC,MAAMC,aAAa,GAAG,IAAIC,GAAG,CAAiC,CAAC;EAC/D,MAAMC,QAAQ,GAAG,IAAIC,GAAG,CAAS,CAAC;EAElCJ,eAAe,CAACK,OAAO,CAAC,CAACC,KAAK,EAAEC,K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