@neurosity/sdk 6.0.0-next.11

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 (312) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -0
  3. package/dist/browser/neurosity.iife.js +48736 -0
  4. package/dist/browser/neurosity.js +672 -0
  5. package/dist/browser/neurosity.js.map +1 -0
  6. package/dist/cjs/Notion.d.ts +619 -0
  7. package/dist/cjs/Notion.js +1291 -0
  8. package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +59 -0
  9. package/dist/cjs/api/bluetooth/BluetoothClient.js +287 -0
  10. package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +32 -0
  11. package/dist/cjs/api/bluetooth/BluetoothTransport.js +2 -0
  12. package/dist/cjs/api/bluetooth/constants.d.ts +4 -0
  13. package/dist/cjs/api/bluetooth/constants.js +9 -0
  14. package/dist/cjs/api/bluetooth/index.d.ts +4 -0
  15. package/dist/cjs/api/bluetooth/index.js +20 -0
  16. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
  17. package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.js +386 -0
  18. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  19. package/dist/cjs/api/bluetooth/react-native/types/BleManagerTypes.js +11 -0
  20. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  21. package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.js +10 -0
  22. package/dist/cjs/api/bluetooth/types/index.d.ts +31 -0
  23. package/dist/cjs/api/bluetooth/types/index.js +22 -0
  24. package/dist/cjs/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
  25. package/dist/cjs/api/bluetooth/utils/create6DigitPin.js +8 -0
  26. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
  27. package/dist/cjs/api/bluetooth/utils/csvBufferToEpoch.js +36 -0
  28. package/dist/cjs/api/bluetooth/utils/encoding.d.ts +3 -0
  29. package/dist/cjs/api/bluetooth/utils/encoding.js +22 -0
  30. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
  31. package/dist/cjs/api/bluetooth/utils/osHasBluetoothSupport.js +23 -0
  32. package/dist/cjs/api/bluetooth/utils/stitch.d.ts +5 -0
  33. package/dist/cjs/api/bluetooth/utils/stitch.js +22 -0
  34. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
  35. package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.js +412 -0
  36. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
  37. package/dist/cjs/api/bluetooth/web/isMaybeWebWorkerContext.js +8 -0
  38. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
  39. package/dist/cjs/api/bluetooth/web/isWebBluetoothSupported.js +11 -0
  40. package/dist/cjs/api/firebase/FirebaseApp.d.ts +20 -0
  41. package/dist/cjs/api/firebase/FirebaseApp.js +70 -0
  42. package/dist/cjs/api/firebase/FirebaseDevice.d.ts +68 -0
  43. package/dist/cjs/api/firebase/FirebaseDevice.js +146 -0
  44. package/dist/cjs/api/firebase/FirebaseUser.d.ts +53 -0
  45. package/dist/cjs/api/firebase/FirebaseUser.js +434 -0
  46. package/dist/cjs/api/firebase/config.d.ts +8 -0
  47. package/dist/cjs/api/firebase/config.js +11 -0
  48. package/dist/cjs/api/firebase/deviceStore.d.ts +26 -0
  49. package/dist/cjs/api/firebase/deviceStore.js +191 -0
  50. package/dist/cjs/api/firebase/index.d.ts +3 -0
  51. package/dist/cjs/api/firebase/index.js +19 -0
  52. package/dist/cjs/api/https/config.d.ts +1 -0
  53. package/dist/cjs/api/https/config.js +4 -0
  54. package/dist/cjs/api/https/createOAuthURL.d.ts +3 -0
  55. package/dist/cjs/api/https/createOAuthURL.js +18 -0
  56. package/dist/cjs/api/https/getOAuthToken.d.ts +3 -0
  57. package/dist/cjs/api/https/getOAuthToken.js +34 -0
  58. package/dist/cjs/api/https/utils.d.ts +2 -0
  59. package/dist/cjs/api/https/utils.js +13 -0
  60. package/dist/cjs/api/index.d.ts +108 -0
  61. package/dist/cjs/api/index.js +306 -0
  62. package/dist/cjs/index.d.ts +3 -0
  63. package/dist/cjs/index.js +19 -0
  64. package/dist/cjs/skills/NotionOnDevice.d.ts +7 -0
  65. package/dist/cjs/skills/NotionOnDevice.js +25 -0
  66. package/dist/cjs/skills/createSkill.d.ts +7 -0
  67. package/dist/cjs/skills/createSkill.js +40 -0
  68. package/dist/cjs/skills/index.d.ts +2 -0
  69. package/dist/cjs/skills/index.js +18 -0
  70. package/dist/cjs/subscriptions/SubscriptionManager.d.ts +11 -0
  71. package/dist/cjs/subscriptions/SubscriptionManager.js +27 -0
  72. package/dist/cjs/timesync/Timesync.d.ts +20 -0
  73. package/dist/cjs/timesync/Timesync.js +78 -0
  74. package/dist/cjs/timesync/index.d.ts +1 -0
  75. package/dist/cjs/timesync/index.js +17 -0
  76. package/dist/cjs/types/accelerometer.d.ts +10 -0
  77. package/dist/cjs/types/accelerometer.js +2 -0
  78. package/dist/cjs/types/actions.d.ts +16 -0
  79. package/dist/cjs/types/actions.js +2 -0
  80. package/dist/cjs/types/awareness.d.ts +1 -0
  81. package/dist/cjs/types/awareness.js +2 -0
  82. package/dist/cjs/types/brainwaves.d.ts +26 -0
  83. package/dist/cjs/types/brainwaves.js +2 -0
  84. package/dist/cjs/types/calm.d.ts +6 -0
  85. package/dist/cjs/types/calm.js +2 -0
  86. package/dist/cjs/types/client.d.ts +22 -0
  87. package/dist/cjs/types/client.js +2 -0
  88. package/dist/cjs/types/credentials.d.ts +12 -0
  89. package/dist/cjs/types/credentials.js +2 -0
  90. package/dist/cjs/types/deviceInfo.d.ts +18 -0
  91. package/dist/cjs/types/deviceInfo.js +2 -0
  92. package/dist/cjs/types/epoch.d.ts +12 -0
  93. package/dist/cjs/types/epoch.js +2 -0
  94. package/dist/cjs/types/experiment.d.ts +9 -0
  95. package/dist/cjs/types/experiment.js +2 -0
  96. package/dist/cjs/types/focus.d.ts +6 -0
  97. package/dist/cjs/types/focus.js +2 -0
  98. package/dist/cjs/types/hapticEffects.d.ts +125 -0
  99. package/dist/cjs/types/hapticEffects.js +2 -0
  100. package/dist/cjs/types/kinesis.d.ts +6 -0
  101. package/dist/cjs/types/kinesis.js +2 -0
  102. package/dist/cjs/types/marker.d.ts +7 -0
  103. package/dist/cjs/types/marker.js +2 -0
  104. package/dist/cjs/types/metrics.d.ts +21 -0
  105. package/dist/cjs/types/metrics.js +2 -0
  106. package/dist/cjs/types/oauth.d.ts +20 -0
  107. package/dist/cjs/types/oauth.js +2 -0
  108. package/dist/cjs/types/options.d.ts +51 -0
  109. package/dist/cjs/types/options.js +2 -0
  110. package/dist/cjs/types/sample.d.ts +15 -0
  111. package/dist/cjs/types/sample.js +2 -0
  112. package/dist/cjs/types/settings.d.ts +13 -0
  113. package/dist/cjs/types/settings.js +2 -0
  114. package/dist/cjs/types/signalQuality.d.ts +13 -0
  115. package/dist/cjs/types/signalQuality.js +2 -0
  116. package/dist/cjs/types/skill.d.ts +68 -0
  117. package/dist/cjs/types/skill.js +2 -0
  118. package/dist/cjs/types/status.d.ts +26 -0
  119. package/dist/cjs/types/status.js +22 -0
  120. package/dist/cjs/types/streaming.d.ts +15 -0
  121. package/dist/cjs/types/streaming.js +20 -0
  122. package/dist/cjs/types/subscriptions.d.ts +23 -0
  123. package/dist/cjs/types/subscriptions.js +2 -0
  124. package/dist/cjs/types/training.d.ts +19 -0
  125. package/dist/cjs/types/training.js +2 -0
  126. package/dist/cjs/types/user.d.ts +12 -0
  127. package/dist/cjs/types/user.js +2 -0
  128. package/dist/cjs/utils/errors.d.ts +5 -0
  129. package/dist/cjs/utils/errors.js +17 -0
  130. package/dist/cjs/utils/filterInternalKeys.d.ts +3 -0
  131. package/dist/cjs/utils/filterInternalKeys.js +21 -0
  132. package/dist/cjs/utils/hapticEffects.d.ts +123 -0
  133. package/dist/cjs/utils/hapticEffects.js +130 -0
  134. package/dist/cjs/utils/heartbeat.d.ts +4 -0
  135. package/dist/cjs/utils/heartbeat.js +34 -0
  136. package/dist/cjs/utils/is-node.d.ts +1 -0
  137. package/dist/cjs/utils/is-node.js +9 -0
  138. package/dist/cjs/utils/metrics.d.ts +1 -0
  139. package/dist/cjs/utils/metrics.js +56 -0
  140. package/dist/cjs/utils/oauth.d.ts +9 -0
  141. package/dist/cjs/utils/oauth.js +92 -0
  142. package/dist/cjs/utils/pick.d.ts +1 -0
  143. package/dist/cjs/utils/pick.js +5 -0
  144. package/dist/cjs/utils/pipes.d.ts +46 -0
  145. package/dist/cjs/utils/pipes.js +71 -0
  146. package/dist/cjs/utils/platform.d.ts +30 -0
  147. package/dist/cjs/utils/platform.js +47 -0
  148. package/dist/cjs/utils/subscription.d.ts +6 -0
  149. package/dist/cjs/utils/subscription.js +55 -0
  150. package/dist/cjs/utils/transferDevice.d.ts +9 -0
  151. package/dist/cjs/utils/transferDevice.js +2 -0
  152. package/dist/cjs/utils/whileOnline.d.ts +8 -0
  153. package/dist/cjs/utils/whileOnline.js +15 -0
  154. package/dist/electron/index.js +92 -0
  155. package/dist/electron/index.js.map +1 -0
  156. package/dist/esm/Notion.d.ts +619 -0
  157. package/dist/esm/Notion.js +1260 -0
  158. package/dist/esm/api/bluetooth/BluetoothClient.d.ts +59 -0
  159. package/dist/esm/api/bluetooth/BluetoothClient.js +283 -0
  160. package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +32 -0
  161. package/dist/esm/api/bluetooth/BluetoothTransport.js +1 -0
  162. package/dist/esm/api/bluetooth/constants.d.ts +4 -0
  163. package/dist/esm/api/bluetooth/constants.js +6 -0
  164. package/dist/esm/api/bluetooth/index.d.ts +4 -0
  165. package/dist/esm/api/bluetooth/index.js +4 -0
  166. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +65 -0
  167. package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.js +382 -0
  168. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.d.ts +63 -0
  169. package/dist/esm/api/bluetooth/react-native/types/BleManagerTypes.js +8 -0
  170. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +180 -0
  171. package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.js +9 -0
  172. package/dist/esm/api/bluetooth/types/index.d.ts +31 -0
  173. package/dist/esm/api/bluetooth/types/index.js +19 -0
  174. package/dist/esm/api/bluetooth/utils/create6DigitPin.d.ts +1 -0
  175. package/dist/esm/api/bluetooth/utils/create6DigitPin.js +4 -0
  176. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.d.ts +11 -0
  177. package/dist/esm/api/bluetooth/utils/csvBufferToEpoch.js +31 -0
  178. package/dist/esm/api/bluetooth/utils/encoding.d.ts +3 -0
  179. package/dist/esm/api/bluetooth/utils/encoding.js +17 -0
  180. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.d.ts +2 -0
  181. package/dist/esm/api/bluetooth/utils/osHasBluetoothSupport.js +16 -0
  182. package/dist/esm/api/bluetooth/utils/stitch.d.ts +5 -0
  183. package/dist/esm/api/bluetooth/utils/stitch.js +18 -0
  184. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +47 -0
  185. package/dist/esm/api/bluetooth/web/WebBluetoothTransport.js +408 -0
  186. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.d.ts +1 -0
  187. package/dist/esm/api/bluetooth/web/isMaybeWebWorkerContext.js +4 -0
  188. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.d.ts +1 -0
  189. package/dist/esm/api/bluetooth/web/isWebBluetoothSupported.js +7 -0
  190. package/dist/esm/api/firebase/FirebaseApp.d.ts +20 -0
  191. package/dist/esm/api/firebase/FirebaseApp.js +63 -0
  192. package/dist/esm/api/firebase/FirebaseDevice.d.ts +68 -0
  193. package/dist/esm/api/firebase/FirebaseDevice.js +139 -0
  194. package/dist/esm/api/firebase/FirebaseUser.d.ts +53 -0
  195. package/dist/esm/api/firebase/FirebaseUser.js +426 -0
  196. package/dist/esm/api/firebase/config.d.ts +8 -0
  197. package/dist/esm/api/firebase/config.js +8 -0
  198. package/dist/esm/api/firebase/deviceStore.d.ts +26 -0
  199. package/dist/esm/api/firebase/deviceStore.js +184 -0
  200. package/dist/esm/api/firebase/index.d.ts +3 -0
  201. package/dist/esm/api/firebase/index.js +3 -0
  202. package/dist/esm/api/https/config.d.ts +1 -0
  203. package/dist/esm/api/https/config.js +1 -0
  204. package/dist/esm/api/https/createOAuthURL.d.ts +3 -0
  205. package/dist/esm/api/https/createOAuthURL.js +11 -0
  206. package/dist/esm/api/https/getOAuthToken.d.ts +3 -0
  207. package/dist/esm/api/https/getOAuthToken.js +27 -0
  208. package/dist/esm/api/https/utils.d.ts +2 -0
  209. package/dist/esm/api/https/utils.js +9 -0
  210. package/dist/esm/api/index.d.ts +108 -0
  211. package/dist/esm/api/index.js +299 -0
  212. package/dist/esm/index.d.ts +3 -0
  213. package/dist/esm/index.js +3 -0
  214. package/dist/esm/neurosity.mjs +48722 -0
  215. package/dist/esm/skills/NotionOnDevice.d.ts +7 -0
  216. package/dist/esm/skills/NotionOnDevice.js +21 -0
  217. package/dist/esm/skills/createSkill.d.ts +7 -0
  218. package/dist/esm/skills/createSkill.js +36 -0
  219. package/dist/esm/skills/index.d.ts +2 -0
  220. package/dist/esm/skills/index.js +2 -0
  221. package/dist/esm/subscriptions/SubscriptionManager.d.ts +11 -0
  222. package/dist/esm/subscriptions/SubscriptionManager.js +23 -0
  223. package/dist/esm/timesync/Timesync.d.ts +20 -0
  224. package/dist/esm/timesync/Timesync.js +71 -0
  225. package/dist/esm/timesync/index.d.ts +1 -0
  226. package/dist/esm/timesync/index.js +1 -0
  227. package/dist/esm/types/accelerometer.d.ts +10 -0
  228. package/dist/esm/types/accelerometer.js +1 -0
  229. package/dist/esm/types/actions.d.ts +16 -0
  230. package/dist/esm/types/actions.js +1 -0
  231. package/dist/esm/types/awareness.d.ts +1 -0
  232. package/dist/esm/types/awareness.js +1 -0
  233. package/dist/esm/types/brainwaves.d.ts +26 -0
  234. package/dist/esm/types/brainwaves.js +1 -0
  235. package/dist/esm/types/calm.d.ts +6 -0
  236. package/dist/esm/types/calm.js +1 -0
  237. package/dist/esm/types/client.d.ts +22 -0
  238. package/dist/esm/types/client.js +1 -0
  239. package/dist/esm/types/credentials.d.ts +12 -0
  240. package/dist/esm/types/credentials.js +1 -0
  241. package/dist/esm/types/deviceInfo.d.ts +18 -0
  242. package/dist/esm/types/deviceInfo.js +1 -0
  243. package/dist/esm/types/epoch.d.ts +12 -0
  244. package/dist/esm/types/epoch.js +1 -0
  245. package/dist/esm/types/experiment.d.ts +9 -0
  246. package/dist/esm/types/experiment.js +1 -0
  247. package/dist/esm/types/focus.d.ts +6 -0
  248. package/dist/esm/types/focus.js +1 -0
  249. package/dist/esm/types/hapticEffects.d.ts +125 -0
  250. package/dist/esm/types/hapticEffects.js +1 -0
  251. package/dist/esm/types/kinesis.d.ts +6 -0
  252. package/dist/esm/types/kinesis.js +1 -0
  253. package/dist/esm/types/marker.d.ts +7 -0
  254. package/dist/esm/types/marker.js +1 -0
  255. package/dist/esm/types/metrics.d.ts +21 -0
  256. package/dist/esm/types/metrics.js +1 -0
  257. package/dist/esm/types/oauth.d.ts +20 -0
  258. package/dist/esm/types/oauth.js +1 -0
  259. package/dist/esm/types/options.d.ts +51 -0
  260. package/dist/esm/types/options.js +1 -0
  261. package/dist/esm/types/sample.d.ts +15 -0
  262. package/dist/esm/types/sample.js +1 -0
  263. package/dist/esm/types/settings.d.ts +13 -0
  264. package/dist/esm/types/settings.js +1 -0
  265. package/dist/esm/types/signalQuality.d.ts +13 -0
  266. package/dist/esm/types/signalQuality.js +1 -0
  267. package/dist/esm/types/skill.d.ts +68 -0
  268. package/dist/esm/types/skill.js +1 -0
  269. package/dist/esm/types/status.d.ts +26 -0
  270. package/dist/esm/types/status.js +19 -0
  271. package/dist/esm/types/streaming.d.ts +15 -0
  272. package/dist/esm/types/streaming.js +17 -0
  273. package/dist/esm/types/subscriptions.d.ts +23 -0
  274. package/dist/esm/types/subscriptions.js +1 -0
  275. package/dist/esm/types/training.d.ts +19 -0
  276. package/dist/esm/types/training.js +1 -0
  277. package/dist/esm/types/user.d.ts +12 -0
  278. package/dist/esm/types/user.js +1 -0
  279. package/dist/esm/utils/errors.d.ts +5 -0
  280. package/dist/esm/utils/errors.js +11 -0
  281. package/dist/esm/utils/filterInternalKeys.d.ts +3 -0
  282. package/dist/esm/utils/filterInternalKeys.js +17 -0
  283. package/dist/esm/utils/hapticEffects.d.ts +123 -0
  284. package/dist/esm/utils/hapticEffects.js +125 -0
  285. package/dist/esm/utils/heartbeat.d.ts +4 -0
  286. package/dist/esm/utils/heartbeat.js +29 -0
  287. package/dist/esm/utils/is-node.d.ts +1 -0
  288. package/dist/esm/utils/is-node.js +5 -0
  289. package/dist/esm/utils/metrics.d.ts +1 -0
  290. package/dist/esm/utils/metrics.js +52 -0
  291. package/dist/esm/utils/oauth.d.ts +9 -0
  292. package/dist/esm/utils/oauth.js +64 -0
  293. package/dist/esm/utils/pick.d.ts +1 -0
  294. package/dist/esm/utils/pick.js +1 -0
  295. package/dist/esm/utils/pipes.d.ts +46 -0
  296. package/dist/esm/utils/pipes.js +65 -0
  297. package/dist/esm/utils/platform.d.ts +30 -0
  298. package/dist/esm/utils/platform.js +41 -0
  299. package/dist/esm/utils/subscription.d.ts +6 -0
  300. package/dist/esm/utils/subscription.js +24 -0
  301. package/dist/esm/utils/transferDevice.d.ts +9 -0
  302. package/dist/esm/utils/transferDevice.js +1 -0
  303. package/dist/esm/utils/whileOnline.d.ts +8 -0
  304. package/dist/esm/utils/whileOnline.js +11 -0
  305. package/dist/examples/auth.html +32 -0
  306. package/dist/examples/cloud.html +17 -0
  307. package/dist/examples/index.html +1 -0
  308. package/dist/examples/neurosity.iife.js +48736 -0
  309. package/dist/examples/neurosity.js +672 -0
  310. package/dist/examples/neurosity.mjs +48722 -0
  311. package/dist/examples/training.html +49 -0
  312. package/package.json +78 -0
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCloudMetric = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const whileOnline_1 = require("./whileOnline");
7
+ const subscription_1 = require("./subscription");
8
+ /**
9
+ * @internal
10
+ */
11
+ function getCloudMetric(dependencies, subscription) {
12
+ const { options, cloudClient, onDeviceChange, status } = dependencies;
13
+ const { metric, labels, atomic } = subscription;
14
+ const metricError = (0, subscription_1.validate)(metric, labels, options);
15
+ if (metricError) {
16
+ return (0, rxjs_1.throwError)(() => metricError);
17
+ }
18
+ const metric$ = new rxjs_1.Observable((observer) => {
19
+ const subscriptions = atomic
20
+ ? [
21
+ cloudClient.metrics.subscribe({
22
+ metric: metric,
23
+ labels: labels,
24
+ atomic: atomic
25
+ })
26
+ ]
27
+ : labels.map((label) => {
28
+ return cloudClient.metrics.subscribe({
29
+ metric: metric,
30
+ labels: [label],
31
+ atomic: atomic
32
+ });
33
+ });
34
+ const subscriptionWithListeners = subscriptions.map((subscription) => ({
35
+ subscription,
36
+ listener: cloudClient.metrics.on(subscription, (...data) => {
37
+ observer.next(...data);
38
+ })
39
+ }));
40
+ return () => {
41
+ subscriptionWithListeners.forEach(({ subscription, listener }) => {
42
+ cloudClient.metrics.unsubscribe(subscription, listener);
43
+ });
44
+ };
45
+ });
46
+ return onDeviceChange().pipe((0, operators_1.switchMap)((device) => {
47
+ if (!device) {
48
+ return rxjs_1.EMPTY;
49
+ }
50
+ return metric$.pipe((0, whileOnline_1.whileOnline)({
51
+ status$: status(),
52
+ allowWhileOnSleepMode: false
53
+ }));
54
+ }));
55
+ }
56
+ exports.getCloudMetric = getCloudMetric;
@@ -0,0 +1,9 @@
1
+ import { Action } from "../types/actions";
2
+ declare type OAuthClaims = {
3
+ oauth?: true;
4
+ authId?: string;
5
+ scopes?: string;
6
+ };
7
+ export declare function validateOAuthScopeForAction(userClaims: OAuthClaims, action: Action): [boolean, Error | null];
8
+ export declare function validateOAuthScopeForFunctionName(userClaims: OAuthClaims, functionName: string): [boolean, Error | null];
9
+ export {};
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.validateOAuthScopeForFunctionName = exports.validateOAuthScopeForAction = void 0;
27
+ const errors = __importStar(require("../utils/errors"));
28
+ const scopeRequiredByAction = {
29
+ "marker/add": "write:brainwave-markers",
30
+ "brainwaves/record": "write:brainwaves",
31
+ "haptics/queue": "write:haptics",
32
+ "training/record": "write:kinesis",
33
+ "training/stop": "write:kinesis",
34
+ "training/stopAll": "write:kinesis",
35
+ "wifi/reset": "write:wifi-settings"
36
+ };
37
+ const scopeRequiredByFunctionName = {
38
+ //metrics
39
+ accelerometer: "read:accelerometer",
40
+ brainwaves: "read:brainwaves",
41
+ calm: "read:calm",
42
+ focus: "read:focus",
43
+ kinesis: "read:kinesis",
44
+ predictions: "read:kinesis",
45
+ signalQuality: "read:signal-quality",
46
+ // end of metrics
47
+ // device info
48
+ getInfo: "read:devices-info",
49
+ getSelectedDevice: "read:devices-info",
50
+ selectDevice: "read:devices-info",
51
+ onDeviceChange: "read:devices-info",
52
+ onUserDevicesChange: "read:devices-info",
53
+ // end device info
54
+ settings: "read:devices-settings",
55
+ changeSettings: "write:devices-settings",
56
+ status: "read:devices-status",
57
+ addDevice: "write:devices-add",
58
+ removeDevice: "write:devices-remove",
59
+ transferDevice: "write:devices-remove"
60
+ };
61
+ function validateOAuthScopeForAction(userClaims, action) {
62
+ const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
63
+ if (!oauth) {
64
+ return [false, null];
65
+ }
66
+ const scopes = scopesString.split(",");
67
+ const { command, action: actionName } = action;
68
+ const requiredScope = scopeRequiredByAction[`${command}/${actionName}`];
69
+ const hasRequireScopes = scopes.includes(requiredScope);
70
+ if (hasRequireScopes) {
71
+ return [false, null];
72
+ }
73
+ return [true, getScopeError(requiredScope)];
74
+ }
75
+ exports.validateOAuthScopeForAction = validateOAuthScopeForAction;
76
+ function validateOAuthScopeForFunctionName(userClaims, functionName) {
77
+ const { oauth, scopes: scopesString } = userClaims !== null && userClaims !== void 0 ? userClaims : {};
78
+ if (!oauth) {
79
+ return [false, null];
80
+ }
81
+ const scopes = scopesString.split(",");
82
+ const requiredScope = scopeRequiredByFunctionName[functionName];
83
+ const hasRequireScopes = scopes.includes(requiredScope);
84
+ if (hasRequireScopes) {
85
+ return [false, null];
86
+ }
87
+ return [true, getScopeError(requiredScope)];
88
+ }
89
+ exports.validateOAuthScopeForFunctionName = validateOAuthScopeForFunctionName;
90
+ function getScopeError(...requiredScopes) {
91
+ return new Error(`${errors.prefix}You are trying to access data with an OAuth token without access to the following scopes: ${requiredScopes.join(", ")}.`);
92
+ }
@@ -0,0 +1 @@
1
+ export declare const pick: (object: any, props: any) => any;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pick = void 0;
4
+ const pick = (object, props) => props.reduce((acc, prop) => (Object.assign(Object.assign({}, acc), (object.hasOwnProperty(prop) ? { [prop]: object[prop] } : {}))), {});
5
+ exports.pick = pick;
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Annotates stream with user-defined metadata
3
+ * @method addInfo
4
+ * @example eeg$.pipe(addinfo({ samplingRate: 256, channelNames: ["Af7", "Fp1", "Fp2", "Af8"] })
5
+ * @param {Object} info Info to be added to the EEG stream. Relevant info may include: `samplingRate` and `channelNames`
6
+ * @returns {Observable<Sample|Epoch|PSD>}
7
+ */
8
+ export declare const addInfo: (infoValue: any) => import("rxjs").UnaryFunction<import("rxjs").Observable<any>, import("rxjs").Observable<any>>;
9
+ /**
10
+ * Takes an array or RxJS buffer of EEG Samples and returns an Epoch.
11
+ * @method bufferToEpoch
12
+ * @example eeg$.pipe(bufferTime(1000), bufferToEpoch({ samplingRate: 256 }))
13
+ *
14
+ * @param {Object} options - Data structure options
15
+ * @param {number} [options.samplingRate] Sampling rate
16
+ * @param {string} [options.dataProp='data'] Name of the key associated with eeg data
17
+ *
18
+ * @returns {Observable<Epoch>}
19
+ */
20
+ export declare const bufferToEpoch: ({ samplingRate, dataProp }?: {
21
+ samplingRate?: number;
22
+ dataProp?: string;
23
+ }) => import("rxjs").UnaryFunction<import("rxjs").Observable<unknown>, import("rxjs").Observable<{
24
+ [x: string]: any;
25
+ info: any;
26
+ }>>;
27
+ /**
28
+ * Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval. This operator functions similarly to a circular buffer internally and allows overlapping Epochs of data to be emitted (e.g. emitting the last one second of data every 100ms).
29
+ * @method epoch
30
+ * @example eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))
31
+ * @param {Object} options - Epoching options
32
+ * @param {number} [options.duration=256] Number of samples to include in each epoch
33
+ * @param {number} [options.interval=100] Time (ms) between emitted Epochs
34
+ * @param {number} [options.samplingRate=256] Sampling rate
35
+ * @param {string} [options.dataProp='data'] Name of the key associated with eeg data
36
+ * @returns {Observable} Epoch
37
+ */
38
+ export declare const epoch: ({ duration, interval, samplingRate, dataProp }: {
39
+ duration: any;
40
+ interval: any;
41
+ samplingRate: any;
42
+ dataProp?: string;
43
+ }) => import("rxjs").UnaryFunction<import("rxjs").Observable<unknown>, import("rxjs").Observable<{
44
+ [x: string]: any;
45
+ info: any;
46
+ }>>;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.epoch = exports.bufferToEpoch = exports.addInfo = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const defaultDataProp = "data";
7
+ const defaultSamplingRate = 256;
8
+ const isObject = (object) => object instanceof Object && object === Object(object);
9
+ const isFunction = (object) => typeof object === "function";
10
+ const patch = (sample) => (info) => {
11
+ var _a;
12
+ return (Object.assign(Object.assign({}, sample), { info: Object.assign(Object.assign({}, ((_a = sample === null || sample === void 0 ? void 0 : sample.info) !== null && _a !== void 0 ? _a : {})), (info || {})) }));
13
+ };
14
+ /**
15
+ * Annotates stream with user-defined metadata
16
+ * @method addInfo
17
+ * @example eeg$.pipe(addinfo({ samplingRate: 256, channelNames: ["Af7", "Fp1", "Fp2", "Af8"] })
18
+ * @param {Object} info Info to be added to the EEG stream. Relevant info may include: `samplingRate` and `channelNames`
19
+ * @returns {Observable<Sample|Epoch|PSD>}
20
+ */
21
+ const addInfo = (infoValue) => (0, rxjs_1.pipe)((0, operators_1.map)((sample) => {
22
+ if (!isObject(sample) ||
23
+ (!isObject(infoValue) && !isFunction(infoValue))) {
24
+ return sample;
25
+ }
26
+ const info = isFunction(infoValue) ? infoValue(sample) : infoValue;
27
+ return patch(sample)(info);
28
+ }));
29
+ exports.addInfo = addInfo;
30
+ /**
31
+ * Get a 2D data array organized by channel from an array of Samples. Credit to Ken from Seattle's elegant transposition
32
+ * http://www.codesuck.com/2012/02/transpose-javascript-array-in-one-line.html
33
+ * @method groupByChannel
34
+ * @param {Array<Sample>} samplesBuffer Array of Samples to be grouped
35
+ * @param {string} [dataProp] Name of the key associated with EEG data
36
+ * @returns {Array<Array<number>>}
37
+ */
38
+ const groupByChannel = (samplesBuffer, dataProp = defaultDataProp) => samplesBuffer[0][dataProp].map((_, channelIndex) => samplesBuffer.map((sample) => sample[dataProp][channelIndex]));
39
+ /**
40
+ * Takes an array or RxJS buffer of EEG Samples and returns an Epoch.
41
+ * @method bufferToEpoch
42
+ * @example eeg$.pipe(bufferTime(1000), bufferToEpoch({ samplingRate: 256 }))
43
+ *
44
+ * @param {Object} options - Data structure options
45
+ * @param {number} [options.samplingRate] Sampling rate
46
+ * @param {string} [options.dataProp='data'] Name of the key associated with eeg data
47
+ *
48
+ * @returns {Observable<Epoch>}
49
+ */
50
+ const bufferToEpoch = ({ samplingRate = defaultSamplingRate, dataProp = defaultDataProp } = {}) => (0, rxjs_1.pipe)((0, operators_1.map)((samplesArray) => ({
51
+ [dataProp]: groupByChannel(samplesArray, dataProp),
52
+ info: Object.assign(Object.assign({}, (samplesArray[0] && samplesArray[0].info
53
+ ? samplesArray[0].info
54
+ : {})), { startTime: samplesArray[0].timestamp, samplingRate: samplesArray[0].info && samplesArray[0].info.samplingRate
55
+ ? samplesArray[0].info.samplingRate
56
+ : samplingRate })
57
+ })));
58
+ exports.bufferToEpoch = bufferToEpoch;
59
+ /**
60
+ * Converts a stream of individual Samples of EEG data into a stream of Epochs of a given duration emitted at specified interval. This operator functions similarly to a circular buffer internally and allows overlapping Epochs of data to be emitted (e.g. emitting the last one second of data every 100ms).
61
+ * @method epoch
62
+ * @example eeg$.pipe(epoch({ duration: 1024, interval: 100, samplingRate: 256 }))
63
+ * @param {Object} options - Epoching options
64
+ * @param {number} [options.duration=256] Number of samples to include in each epoch
65
+ * @param {number} [options.interval=100] Time (ms) between emitted Epochs
66
+ * @param {number} [options.samplingRate=256] Sampling rate
67
+ * @param {string} [options.dataProp='data'] Name of the key associated with eeg data
68
+ * @returns {Observable} Epoch
69
+ */
70
+ const epoch = ({ duration, interval, samplingRate, dataProp = defaultDataProp }) => (0, rxjs_1.pipe)((0, operators_1.bufferCount)(interval), (0, operators_1.scan)((acc, val) => acc.concat(val).slice(acc.length < duration ? 0 : -duration)), (0, operators_1.filter)((samplesArray) => samplesArray.length === duration), (0, exports.bufferToEpoch)({ samplingRate, dataProp }));
71
+ exports.epoch = epoch;
@@ -0,0 +1,30 @@
1
+ export declare const MODEL_VERSION_1 = "1";
2
+ export declare const MODEL_VERSION_2 = "2";
3
+ export declare const MODEL_VERSION_3 = "3";
4
+ export declare const FEATURE_HAPTICS = "haptics";
5
+ export declare const FEATURE_ACCEL = "accel";
6
+ export declare const HAPTIC_P7 = "P7";
7
+ export declare const HAPTIC_P8 = "P8";
8
+ export declare const platformFeaturesByModelVersion: {
9
+ 1: any[];
10
+ 2: string[];
11
+ 3: string[];
12
+ };
13
+ export declare const platformConfigByModelVersion: {
14
+ 1: {};
15
+ 2: {
16
+ motorByMotorName: {
17
+ P7: any[];
18
+ P8: any[];
19
+ };
20
+ };
21
+ 3: {
22
+ motorByMotorName: {
23
+ P7: any[];
24
+ P8: any[];
25
+ };
26
+ };
27
+ };
28
+ export declare const supportsHaptics: (modelVersion: string) => boolean;
29
+ export declare const supportsAccel: (modelVersion: string) => boolean;
30
+ export declare const getPlatformHapticMotors: (modelVersion: string) => any;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPlatformHapticMotors = exports.supportsAccel = exports.supportsHaptics = exports.platformConfigByModelVersion = exports.platformFeaturesByModelVersion = exports.HAPTIC_P8 = exports.HAPTIC_P7 = exports.FEATURE_ACCEL = exports.FEATURE_HAPTICS = exports.MODEL_VERSION_3 = exports.MODEL_VERSION_2 = exports.MODEL_VERSION_1 = void 0;
4
+ exports.MODEL_VERSION_1 = "1";
5
+ exports.MODEL_VERSION_2 = "2";
6
+ exports.MODEL_VERSION_3 = "3";
7
+ exports.FEATURE_HAPTICS = "haptics";
8
+ exports.FEATURE_ACCEL = "accel";
9
+ exports.HAPTIC_P7 = "P7";
10
+ exports.HAPTIC_P8 = "P8";
11
+ exports.platformFeaturesByModelVersion = {
12
+ [exports.MODEL_VERSION_1]: [],
13
+ [exports.MODEL_VERSION_2]: [exports.FEATURE_HAPTICS, exports.FEATURE_ACCEL],
14
+ [exports.MODEL_VERSION_3]: [exports.FEATURE_HAPTICS, exports.FEATURE_ACCEL]
15
+ };
16
+ exports.platformConfigByModelVersion = {
17
+ [exports.MODEL_VERSION_1]: {},
18
+ [exports.MODEL_VERSION_2]: {
19
+ motorByMotorName: {
20
+ [exports.HAPTIC_P7]: [],
21
+ [exports.HAPTIC_P8]: []
22
+ }
23
+ },
24
+ [exports.MODEL_VERSION_3]: {
25
+ motorByMotorName: {
26
+ [exports.HAPTIC_P7]: [],
27
+ [exports.HAPTIC_P8]: []
28
+ }
29
+ }
30
+ };
31
+ const supportsHaptics = (modelVersion) => {
32
+ const platformFeaturesForModel = exports.platformFeaturesByModelVersion[modelVersion];
33
+ return platformFeaturesForModel.includes(exports.FEATURE_HAPTICS);
34
+ };
35
+ exports.supportsHaptics = supportsHaptics;
36
+ const supportsAccel = (modelVersion) => {
37
+ const platformFeaturesForModel = exports.platformFeaturesByModelVersion[modelVersion];
38
+ return platformFeaturesForModel.includes(exports.FEATURE_ACCEL);
39
+ };
40
+ exports.supportsAccel = supportsAccel;
41
+ const getPlatformHapticMotors = (modelVersion) => {
42
+ var _a;
43
+ const platformConfigForModel = exports.platformConfigByModelVersion[modelVersion];
44
+ const platformMotorByMotorName = (_a = platformConfigForModel === null || platformConfigForModel === void 0 ? void 0 : platformConfigForModel.motorByMotorName) !== null && _a !== void 0 ? _a : {};
45
+ return Object.assign({}, platformMotorByMotorName);
46
+ };
47
+ exports.getPlatformHapticMotors = getPlatformHapticMotors;
@@ -0,0 +1,6 @@
1
+ import { SDKOptions } from "../types/options";
2
+ export declare const isMetric: (metric: string) => boolean;
3
+ export declare const getLabels: (metric: string) => string[];
4
+ export declare const hasInvalidLabels: (metric: string, labels: string[]) => boolean;
5
+ export declare const isMetricDisallowed: (metricName: string, options: SDKOptions) => boolean;
6
+ export declare const validate: (metric: string, labels: string[], options: SDKOptions) => Error | false;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.validate = exports.isMetricDisallowed = exports.hasInvalidLabels = exports.getLabels = exports.isMetric = void 0;
27
+ const ipk_1 = require("@neurosity/ipk");
28
+ const errors = __importStar(require("../utils/errors"));
29
+ const isMetric = (metric) => Object.keys(ipk_1.metrics).includes(metric);
30
+ exports.isMetric = isMetric;
31
+ const getLabels = (metric) => Object.keys(ipk_1.metrics[metric]);
32
+ exports.getLabels = getLabels;
33
+ const hasInvalidLabels = (metric, labels) => {
34
+ const validLabels = (0, exports.getLabels)(metric);
35
+ return !labels.every((label) => validLabels.includes(label));
36
+ };
37
+ exports.hasInvalidLabels = hasInvalidLabels;
38
+ const isMetricDisallowed = (metricName, options) => "skill" in options &&
39
+ "metrics" in options.skill &&
40
+ !options.skill.metrics.includes(metricName);
41
+ exports.isMetricDisallowed = isMetricDisallowed;
42
+ const validate = (metric, labels, options) => {
43
+ const validLabels = (0, exports.getLabels)(metric).join(", ");
44
+ if (!labels.length) {
45
+ return new Error(`${errors.prefix}At least one label is required for ${metric} metric. Please add one of the following labels: ${validLabels}`);
46
+ }
47
+ if ((0, exports.isMetricDisallowed)(metric, options)) {
48
+ return new Error(`${errors.prefix}No permission to access the ${metric} metric. To access this metric, edit the skill's permissions`);
49
+ }
50
+ if ((0, exports.hasInvalidLabels)(metric, labels)) {
51
+ return new Error(`${errors.prefix}One ore more labels provided to ${metric} are invalid. The valid labels for ${metric} are ${validLabels}`);
52
+ }
53
+ return false;
54
+ };
55
+ exports.validate = validate;
@@ -0,0 +1,9 @@
1
+ export declare type TransferDeviceByEmail = {
2
+ recipientsEmail: string;
3
+ deviceId: string;
4
+ };
5
+ export declare type TransferDeviceByUserId = {
6
+ recipientsUserId: string;
7
+ deviceId: string;
8
+ };
9
+ export declare type TransferDeviceOptions = TransferDeviceByEmail | TransferDeviceByUserId;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ import { Observable } from "rxjs";
2
+ import { DeviceStatus } from "../types/status";
3
+ declare type Options = {
4
+ status$: Observable<DeviceStatus>;
5
+ allowWhileOnSleepMode: boolean;
6
+ };
7
+ export declare function whileOnline({ status$, allowWhileOnSleepMode }: Options): import("rxjs").UnaryFunction<Observable<unknown>, Observable<any>>;
8
+ export {};
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.whileOnline = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ function whileOnline({ status$, allowWhileOnSleepMode }) {
7
+ return (0, rxjs_1.pipe)((0, operators_1.withLatestFrom)(status$), (0, operators_1.mergeMap)(([value, status]) => shouldAllowMetrics(status, allowWhileOnSleepMode)
8
+ ? (0, rxjs_1.of)(value)
9
+ : rxjs_1.EMPTY));
10
+ }
11
+ exports.whileOnline = whileOnline;
12
+ function shouldAllowMetrics(status, allowWhileOnSleepMode) {
13
+ return (status.state === "online" &&
14
+ (allowWhileOnSleepMode ? true : !status.sleepMode));
15
+ }