@ovok/core 0.4.49-dev.495 → 0.4.49-dev.497

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 (243) hide show
  1. package/dist/client/observation/measurement-fields.d.ts +1 -1
  2. package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
  3. package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
  4. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  5. package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
  6. package/dist/client/observation/services/blood-oxygen.js +7 -7
  7. package/dist/client/observation/services/blood-pressure.d.ts +1 -1
  8. package/dist/client/observation/services/blood-pressure.js +16 -16
  9. package/dist/client/observation/services/component-observation-services.d.ts +1 -1
  10. package/dist/client/observation/services/component-observation-services.js +3 -3
  11. package/dist/client/observation/services/creator.d.ts +1 -1
  12. package/dist/client/observation/services/creator.js +10 -10
  13. package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
  14. package/dist/client/observation/services/ecg.d.ts +1 -1
  15. package/dist/client/observation/services/ecg.js +10 -10
  16. package/dist/client/observation/services/lipid-panel.d.ts +1 -1
  17. package/dist/client/observation/services/lipid-panel.js +13 -13
  18. package/dist/client/observation/services/single-value-services.d.ts +1 -1
  19. package/dist/client/observation/services/single-value-services.js +19 -19
  20. package/dist/client/observation/services/step-count.d.ts +1 -1
  21. package/dist/client/observation/services/step-count.js +5 -5
  22. package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
  23. package/dist/client/observation/services/uric-acid-service.js +7 -7
  24. package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
  25. package/dist/client/wearables/types.d.ts +5 -0
  26. package/dist/conformance/capability-requirements.js +1 -1
  27. package/dist/next/auth/access-token.d.ts +9 -0
  28. package/dist/next/auth/access-token.js +18 -0
  29. package/dist/next/auth/client-credentials.d.ts +16 -0
  30. package/dist/next/auth/client-credentials.js +40 -0
  31. package/dist/next/auth/credentials.d.ts +5 -0
  32. package/dist/next/auth/credentials.js +7 -0
  33. package/dist/next/auth/saved-accounts-store.d.ts +26 -0
  34. package/dist/next/auth/saved-accounts-store.js +93 -0
  35. package/dist/next/auth/session-store.d.ts +12 -0
  36. package/dist/next/auth/session-store.js +33 -0
  37. package/dist/next/auth/session.d.ts +28 -0
  38. package/dist/next/auth/session.js +27 -0
  39. package/dist/next/auth/token-endpoint.d.ts +12 -0
  40. package/dist/next/auth/token-endpoint.js +28 -0
  41. package/dist/next/auth/user-session.d.ts +39 -0
  42. package/dist/next/auth/user-session.js +183 -0
  43. package/dist/next/config/ovok-config.d.ts +42 -0
  44. package/dist/next/config/ovok-config.js +2 -0
  45. package/dist/next/config/settings.d.ts +6 -0
  46. package/dist/next/config/settings.js +74 -0
  47. package/dist/next/errors/error-from-response.d.ts +2 -0
  48. package/dist/next/errors/error-from-response.js +35 -0
  49. package/dist/next/errors/ovok-account-error.d.ts +5 -0
  50. package/dist/next/errors/ovok-account-error.js +13 -0
  51. package/dist/next/errors/ovok-errors.d.ts +42 -0
  52. package/dist/next/errors/ovok-errors.js +74 -0
  53. package/dist/next/http/http-client.d.ts +36 -0
  54. package/dist/next/http/http-client.js +116 -0
  55. package/dist/next/http/retry-after.d.ts +1 -0
  56. package/dist/next/http/retry-after.js +16 -0
  57. package/dist/next/http/retry-policy.d.ts +13 -0
  58. package/dist/next/http/retry-policy.js +27 -0
  59. package/dist/next/http/transmit.d.ts +14 -0
  60. package/dist/next/http/transmit.js +57 -0
  61. package/dist/next/http/url.d.ts +6 -0
  62. package/dist/next/http/url.js +22 -0
  63. package/dist/next/index.d.ts +74 -0
  64. package/dist/next/index.js +35 -0
  65. package/dist/next/ovok.d.ts +54 -0
  66. package/dist/next/ovok.js +77 -0
  67. package/dist/next/paging/bundle-page.d.ts +4 -0
  68. package/dist/next/paging/bundle-page.js +25 -0
  69. package/dist/next/paging/cursor-pages.d.ts +7 -0
  70. package/dist/next/paging/cursor-pages.js +14 -0
  71. package/dist/next/paging/numbered-pages.d.ts +15 -0
  72. package/dist/next/paging/numbered-pages.js +20 -0
  73. package/dist/next/paging/page.d.ts +12 -0
  74. package/dist/next/paging/page.js +17 -0
  75. package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
  76. package/dist/next/resources/accounts/accounts-resource.js +13 -0
  77. package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
  78. package/dist/next/resources/ai/ai-chat-resource.js +12 -0
  79. package/dist/next/resources/ai/ai-resource.d.ts +16 -0
  80. package/dist/next/resources/ai/ai-resource.js +19 -0
  81. package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
  82. package/dist/next/resources/ai/chat-messages-resource.js +18 -0
  83. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  84. package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
  85. package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
  86. package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
  87. package/dist/next/resources/auth/registration.d.ts +35 -0
  88. package/dist/next/resources/auth/registration.js +24 -0
  89. package/dist/next/resources/auth/social-login.d.ts +8 -0
  90. package/dist/next/resources/auth/social-login.js +7 -0
  91. package/dist/next/resources/auth-resource.d.ts +63 -0
  92. package/dist/next/resources/auth-resource.js +119 -0
  93. package/dist/next/resources/bots/bots-resource.d.ts +10 -0
  94. package/dist/next/resources/bots/bots-resource.js +15 -0
  95. package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
  96. package/dist/next/resources/cms/cms-delivery.js +36 -0
  97. package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
  98. package/dist/next/resources/cms/cms-documents-resource.js +17 -0
  99. package/dist/next/resources/cms/cms-resource.d.ts +17 -0
  100. package/dist/next/resources/cms/cms-resource.js +38 -0
  101. package/dist/next/resources/cms/payload-pages.d.ts +6 -0
  102. package/dist/next/resources/cms/payload-pages.js +15 -0
  103. package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
  104. package/dist/next/resources/cms/release-notes-resource.js +15 -0
  105. package/dist/next/resources/cms/translation-tree.d.ts +3 -0
  106. package/dist/next/resources/cms/translation-tree.js +45 -0
  107. package/dist/next/resources/consent/consent-resource.d.ts +23 -0
  108. package/dist/next/resources/consent/consent-resource.js +43 -0
  109. package/dist/next/resources/content/content-resource.d.ts +19 -0
  110. package/dist/next/resources/content/content-resource.js +41 -0
  111. package/dist/next/resources/documents/documents-resource.d.ts +26 -0
  112. package/dist/next/resources/documents/documents-resource.js +41 -0
  113. package/dist/next/resources/email/email-resource.d.ts +6 -0
  114. package/dist/next/resources/email/email-resource.js +10 -0
  115. package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
  116. package/dist/next/resources/email/email-templates-resource.js +13 -0
  117. package/dist/next/resources/fhir-resource.d.ts +28 -0
  118. package/dist/next/resources/fhir-resource.js +64 -0
  119. package/dist/next/resources/health-resource.d.ts +17 -0
  120. package/dist/next/resources/health-resource.js +14 -0
  121. package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
  122. package/dist/next/resources/invites/invite-flow-resource.js +19 -0
  123. package/dist/next/resources/invites/invites-resource.d.ts +22 -0
  124. package/dist/next/resources/invites/invites-resource.js +29 -0
  125. package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
  126. package/dist/next/resources/localization/i18next-resource.js +18 -0
  127. package/dist/next/resources/localization/locales-resource.d.ts +9 -0
  128. package/dist/next/resources/localization/locales-resource.js +16 -0
  129. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  130. package/dist/next/resources/localization/localizations-resource.js +27 -0
  131. package/dist/next/resources/measurements/measurements-resource.d.ts +42 -0
  132. package/dist/next/resources/measurements/measurements-resource.js +77 -0
  133. package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
  134. package/dist/next/resources/measurements/observation-builder.js +57 -0
  135. package/dist/next/resources/measurements/save-error.d.ts +5 -0
  136. package/dist/next/resources/measurements/save-error.js +18 -0
  137. package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
  138. package/dist/next/resources/measurements/signed-in-account.js +26 -0
  139. package/dist/next/resources/patient/fhir-records.d.ts +19 -0
  140. package/dist/next/resources/patient/fhir-records.js +33 -0
  141. package/dist/next/resources/patient/patient-resource.d.ts +21 -0
  142. package/dist/next/resources/patient/patient-resource.js +38 -0
  143. package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
  144. package/dist/next/resources/projects/project-features-resource.js +17 -0
  145. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  146. package/dist/next/resources/projects/project-members-resource.js +25 -0
  147. package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
  148. package/dist/next/resources/projects/project-settings-resource.js +21 -0
  149. package/dist/next/resources/projects/projects-resource.d.ts +20 -0
  150. package/dist/next/resources/projects/projects-resource.js +21 -0
  151. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
  152. package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
  153. package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
  154. package/dist/next/resources/session/saved-accounts-resource.js +44 -0
  155. package/dist/next/resources/session/session-resource.d.ts +11 -0
  156. package/dist/next/resources/session/session-resource.js +15 -0
  157. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
  158. package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
  159. package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
  160. package/dist/next/resources/sharing/sharing-resource.js +14 -0
  161. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
  162. package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
  163. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
  164. package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
  165. package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
  166. package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
  167. package/dist/next/resources/signals/signals-resource.d.ts +13 -0
  168. package/dist/next/resources/signals/signals-resource.js +19 -0
  169. package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
  170. package/dist/next/resources/signals/undeliverable-resource.js +18 -0
  171. package/dist/next/resources/slim/live-reads.d.ts +13 -0
  172. package/dist/next/resources/slim/live-reads.js +87 -0
  173. package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
  174. package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
  175. package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
  176. package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
  177. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
  178. package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
  179. package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
  180. package/dist/next/resources/slim/slim-devices-resource.js +81 -0
  181. package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
  182. package/dist/next/resources/slim/slim-exports-resource.js +14 -0
  183. package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
  184. package/dist/next/resources/slim/slim-locations-resource.js +30 -0
  185. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
  186. package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
  187. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
  188. package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
  189. package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
  190. package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
  191. package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
  192. package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
  193. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
  194. package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
  195. package/dist/next/resources/slim/slim-paths.d.ts +6 -0
  196. package/dist/next/resources/slim/slim-paths.js +9 -0
  197. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
  198. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
  199. package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
  200. package/dist/next/resources/slim/slim-patients-resource.js +39 -0
  201. package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
  202. package/dist/next/resources/slim/slim-policies-resource.js +29 -0
  203. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
  204. package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
  205. package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
  206. package/dist/next/resources/slim/slim-projects-resource.js +35 -0
  207. package/dist/next/resources/slim/slim-queries.d.ts +34 -0
  208. package/dist/next/resources/slim/slim-queries.js +2 -0
  209. package/dist/next/resources/slim/slim-resource.d.ts +39 -0
  210. package/dist/next/resources/slim/slim-resource.js +44 -0
  211. package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
  212. package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
  213. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
  214. package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
  215. package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
  216. package/dist/next/resources/slim/slim-trends-resource.js +19 -0
  217. package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
  218. package/dist/next/resources/slim/slim-users-resource.js +15 -0
  219. package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
  220. package/dist/next/resources/slim/slim-zones-resource.js +24 -0
  221. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
  222. package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
  223. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
  224. package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
  225. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
  226. package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
  227. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  228. package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
  229. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
  230. package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
  231. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
  232. package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
  233. package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
  234. package/dist/next/resources/wearables/wearables-resource.js +14 -0
  235. package/dist/next/storage/ovok-storage.d.ts +11 -0
  236. package/dist/next/storage/ovok-storage.js +19 -0
  237. package/dist/types/MeasurementTypes.d.ts +5 -0
  238. package/dist/types/MeasurementTypes.js +21 -0
  239. package/dist/types/index.d.ts +1 -5
  240. package/dist/types/index.js +1 -5
  241. package/next/index.d.ts +1 -0
  242. package/next/index.js +3 -0
  243. package/package.json +3 -2
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LipidPanelService = void 0;
4
- const types_1 = require("../../../types");
4
+ const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
5
  const fhir_systems_1 = require("../fhir-systems");
6
6
  const base_observation_service_1 = require("./base-observation-service");
7
7
  const measurement_time_1 = require("./measurement-time");
@@ -9,37 +9,37 @@ const COMPONENTS = [
9
9
  {
10
10
  key: "totalCholesterol",
11
11
  display: "Total cholesterol",
12
- massCode: types_1.ObservationCode.TOTAL_CHOLESTEROL_MASS,
13
- molarCode: types_1.ObservationCode.TOTAL_CHOLESTEROL_MOLAR,
12
+ massCode: MeasurementTypes_1.ObservationCode.TOTAL_CHOLESTEROL_MASS,
13
+ molarCode: MeasurementTypes_1.ObservationCode.TOTAL_CHOLESTEROL_MOLAR,
14
14
  },
15
15
  {
16
16
  key: "hdlCholesterol",
17
17
  display: "HDL cholesterol",
18
- massCode: types_1.ObservationCode.HDL_CHOLESTEROL_MASS,
19
- molarCode: types_1.ObservationCode.HDL_CHOLESTEROL_MOLAR,
18
+ massCode: MeasurementTypes_1.ObservationCode.HDL_CHOLESTEROL_MASS,
19
+ molarCode: MeasurementTypes_1.ObservationCode.HDL_CHOLESTEROL_MOLAR,
20
20
  },
21
21
  {
22
22
  key: "ldlCholesterol",
23
23
  display: "LDL cholesterol",
24
- massCode: types_1.ObservationCode.LDL_CHOLESTEROL_MASS,
25
- molarCode: types_1.ObservationCode.LDL_CHOLESTEROL_MOLAR,
24
+ massCode: MeasurementTypes_1.ObservationCode.LDL_CHOLESTEROL_MASS,
25
+ molarCode: MeasurementTypes_1.ObservationCode.LDL_CHOLESTEROL_MOLAR,
26
26
  },
27
27
  {
28
28
  key: "triglycerides",
29
29
  display: "Triglycerides",
30
- massCode: types_1.ObservationCode.TRIGLYCERIDES_MASS,
31
- molarCode: types_1.ObservationCode.TRIGLYCERIDES_MOLAR,
30
+ massCode: MeasurementTypes_1.ObservationCode.TRIGLYCERIDES_MASS,
31
+ molarCode: MeasurementTypes_1.ObservationCode.TRIGLYCERIDES_MOLAR,
32
32
  },
33
33
  {
34
34
  key: "totalCholesterolHdlRatio",
35
35
  display: "Total cholesterol/HDL ratio",
36
- massCode: types_1.ObservationCode.TOTAL_CHOLESTEROL_HDL_RATIO,
36
+ massCode: MeasurementTypes_1.ObservationCode.TOTAL_CHOLESTEROL_HDL_RATIO,
37
37
  },
38
38
  ];
39
39
  class LipidPanelService extends base_observation_service_1.BaseObservationService {
40
40
  constructor() {
41
41
  super(...arguments);
42
- this.measurementTypeKey = types_1.MeasurementTypeKey.lipidPanel;
42
+ this.measurementTypeKey = MeasurementTypes_1.MeasurementTypeKey.lipidPanel;
43
43
  this.measurementTypeName = "lipid panel";
44
44
  this.observationMetadata = [];
45
45
  }
@@ -74,7 +74,7 @@ class LipidPanelService extends base_observation_service_1.BaseObservationServic
74
74
  return [{
75
75
  code: {
76
76
  coding: [{
77
- code: types_1.ObservationCode.LIPID_PANEL,
77
+ code: MeasurementTypes_1.ObservationCode.LIPID_PANEL,
78
78
  display: "Lipid panel - Serum or Plasma",
79
79
  system: fhir_systems_1.LOINC_SYSTEM,
80
80
  }],
@@ -88,7 +88,7 @@ class LipidPanelService extends base_observation_service_1.BaseObservationServic
88
88
  getObservationCodes() {
89
89
  return [{
90
90
  coding: [{
91
- code: types_1.ObservationCode.LIPID_PANEL,
91
+ code: MeasurementTypes_1.ObservationCode.LIPID_PANEL,
92
92
  display: "Lipid panel - Serum or Plasma",
93
93
  system: fhir_systems_1.LOINC_SYSTEM,
94
94
  }],
@@ -1,4 +1,4 @@
1
- import { MeasurementTypeKey } from "../../../types";
1
+ import { MeasurementTypeKey } from "../../../types/MeasurementTypes";
2
2
  import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
3
3
  import { Sample } from "../types/generate-measurement/Sample";
4
4
  import { Measurement } from "../types/measurement/Measurement";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.singleValueFields = exports.singleValueObservationServices = void 0;
4
- const types_1 = require("../../../types");
4
+ const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
5
  const base_observation_service_1 = require("./base-observation-service");
6
6
  /** An observation with one value: what varies per measurement is data, not code. */
7
7
  class SingleValueObservationService extends base_observation_service_1.BaseObservationService {
@@ -30,62 +30,62 @@ class SingleValueObservationService extends base_observation_service_1.BaseObser
30
30
  }
31
31
  const specs = [
32
32
  {
33
- measurementTypeKey: types_1.MeasurementTypeKey.bloodGlucose,
33
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.bloodGlucose,
34
34
  measurementTypeName: "blood glucose",
35
- metadata: { primaryCode: types_1.ObservationCode.BLOOD_GLUCOSE, display: "Blood Glucose", unit: "mg/dL", valueKey: "bloodGlucose", toFixed: 1 },
35
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.BLOOD_GLUCOSE, display: "Blood Glucose", unit: "mg/dL", valueKey: "bloodGlucose", toFixed: 1 },
36
36
  fromRecord: (record) => record.level.inMilligramsPerDeciliter,
37
37
  },
38
38
  {
39
- measurementTypeKey: types_1.MeasurementTypeKey.temperature,
39
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.temperature,
40
40
  measurementTypeName: "body temperature",
41
- metadata: { primaryCode: types_1.ObservationCode.BODY_TEMPERATURE, display: "Body Temperature", unit: "°C", valueKey: "bodyTemp", toFixed: 2 },
41
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.BODY_TEMPERATURE, display: "Body Temperature", unit: "°C", valueKey: "bodyTemp", toFixed: 2 },
42
42
  fromRecord: (record) => record.temperature.inCelsius,
43
43
  },
44
44
  {
45
- measurementTypeKey: types_1.MeasurementTypeKey.bodyWeight,
45
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.bodyWeight,
46
46
  measurementTypeName: "body weight",
47
- metadata: { primaryCode: types_1.ObservationCode.BODY_WEIGHT, display: "Body Weight", unit: "kg", valueKey: "bodyWeight", toFixed: 2 },
47
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.BODY_WEIGHT, display: "Body Weight", unit: "kg", valueKey: "bodyWeight", toFixed: 2 },
48
48
  fromRecord: (record) => record.weight.inKilograms,
49
49
  },
50
50
  {
51
- measurementTypeKey: types_1.MeasurementTypeKey.heartRateVariability,
51
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.heartRateVariability,
52
52
  measurementTypeName: "heart rate variability",
53
- metadata: { primaryCode: types_1.ObservationCode.HEART_RATE_VARIABILITY, display: "Heart Rate Variability", unit: "ms", valueKey: "heartRateVariability", toFixed: 1 },
53
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.HEART_RATE_VARIABILITY, display: "Heart Rate Variability", unit: "ms", valueKey: "heartRateVariability", toFixed: 1 },
54
54
  sampleType: "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
55
55
  fromRecord: (record) => record.heartRateVariabilityMillis,
56
56
  },
57
57
  {
58
- measurementTypeKey: types_1.MeasurementTypeKey.heartRate,
58
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.heartRate,
59
59
  measurementTypeName: "heart rate",
60
- metadata: { primaryCode: types_1.ObservationCode.HEART_RATE, display: "Heart Rate", unit: "bpm", valueKey: "heartRate", toFixed: 0 },
60
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.HEART_RATE, display: "Heart Rate", unit: "bpm", valueKey: "heartRate", toFixed: 0 },
61
61
  sampleType: "HKQuantityTypeIdentifierHeartRate",
62
62
  fromRecord: (record) => { var _a, _b; return (_b = (_a = record.samples) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.beatsPerMinute; },
63
63
  },
64
64
  {
65
- measurementTypeKey: types_1.MeasurementTypeKey.respiratoryRate,
65
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.respiratoryRate,
66
66
  measurementTypeName: "respiratory rate",
67
- metadata: { primaryCode: types_1.ObservationCode.RESPIRATORY_RATE, display: "Respiratory Rate", unit: "breaths/min", valueKey: "respiratoryRate", toFixed: 1 },
67
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.RESPIRATORY_RATE, display: "Respiratory Rate", unit: "breaths/min", valueKey: "respiratoryRate", toFixed: 1 },
68
68
  sampleType: "HKQuantityTypeIdentifierRespiratoryRate",
69
69
  fromRecord: (record) => record.rate,
70
70
  },
71
71
  {
72
- measurementTypeKey: types_1.MeasurementTypeKey.restingHeartRate,
72
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.restingHeartRate,
73
73
  measurementTypeName: "resting heart rate",
74
- metadata: { primaryCode: types_1.ObservationCode.RESTING_HEART_RATE, display: "Resting Heart Rate", unit: "bpm", valueKey: "restingHeartRate", toFixed: 0 },
74
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.RESTING_HEART_RATE, display: "Resting Heart Rate", unit: "bpm", valueKey: "restingHeartRate", toFixed: 0 },
75
75
  sampleType: "HKQuantityTypeIdentifierRestingHeartRate",
76
76
  fromRecord: (record) => record.beatsPerMinute,
77
77
  },
78
78
  {
79
- measurementTypeKey: types_1.MeasurementTypeKey.vo2Max,
79
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.vo2Max,
80
80
  measurementTypeName: "VO2 max",
81
- metadata: { primaryCode: types_1.ObservationCode.VO2_MAX, display: "VO2 Max", unit: "mL/kg/min", valueKey: "vo2Max", toFixed: 1 },
81
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.VO2_MAX, display: "VO2 Max", unit: "mL/kg/min", valueKey: "vo2Max", toFixed: 1 },
82
82
  sampleType: "HKQuantityTypeIdentifierVO2Max",
83
83
  fromRecord: (record) => record.vo2MillilitersPerMinuteKilogram,
84
84
  },
85
85
  {
86
- measurementTypeKey: types_1.MeasurementTypeKey.walkingHeartRateAverage,
86
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.walkingHeartRateAverage,
87
87
  measurementTypeName: "walking heart rate average",
88
- metadata: { primaryCode: types_1.ObservationCode.WALKING_HEART_RATE_AVERAGE, display: "Walking Heart Rate Average", unit: "bpm", valueKey: "walkingHeartRateAverage", toFixed: 0 },
88
+ metadata: { primaryCode: MeasurementTypes_1.ObservationCode.WALKING_HEART_RATE_AVERAGE, display: "Walking Heart Rate Average", unit: "bpm", valueKey: "walkingHeartRateAverage", toFixed: 0 },
89
89
  sampleType: "HKQuantityTypeIdentifierWalkingHeartRateAverage",
90
90
  // Health Connect has no walking-heart-rate-average record.
91
91
  fromRecord: () => 0,
@@ -1,5 +1,5 @@
1
1
  import { Observation } from "@medplum/fhirtypes";
2
- import { Measurement, MeasurementTypeKey } from "../../../types";
2
+ import { Measurement, MeasurementTypeKey } from "../../../types/MeasurementTypes";
3
3
  import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
4
4
  import { Sample } from "../types/generate-measurement/Sample";
5
5
  import { StepCountMeasurement } from "../types/measurement/StepCountMeasurement";
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StepCountService = void 0;
4
- const types_1 = require("../../../types");
4
+ const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
5
5
  const base_observation_service_1 = require("./base-observation-service");
6
6
  class StepCountService extends base_observation_service_1.BaseObservationService {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.measurementTypeKey = types_1.MeasurementTypeKey.stepCount;
9
+ this.measurementTypeKey = MeasurementTypes_1.MeasurementTypeKey.stepCount;
10
10
  this.measurementTypeName = "step count";
11
11
  this.observationMetadata = [
12
12
  {
13
- primaryCode: types_1.ObservationCode.STEPS,
13
+ primaryCode: MeasurementTypes_1.ObservationCode.STEPS,
14
14
  additionalCodes: [],
15
15
  display: "Step Count",
16
16
  unit: "steps",
@@ -41,14 +41,14 @@ class StepCountService extends base_observation_service_1.BaseObservationService
41
41
  convertSamplesToMeasurement(samples) {
42
42
  return {
43
43
  stepCount: samples[0].quantity,
44
- measurementTypeKey: types_1.MeasurementTypeKey.stepCount,
44
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.stepCount,
45
45
  };
46
46
  }
47
47
  convertRecordToMeasurement(record) {
48
48
  const stepCountRecord = record;
49
49
  return {
50
50
  stepCount: stepCountRecord.count,
51
- measurementTypeKey: types_1.MeasurementTypeKey.stepCount,
51
+ measurementTypeKey: MeasurementTypes_1.MeasurementTypeKey.stepCount,
52
52
  };
53
53
  }
54
54
  }
@@ -1,5 +1,5 @@
1
1
  import { Observation } from "@medplum/fhirtypes";
2
- import { Measurement, MeasurementTypeKey, Sample, UrineAnalyzeMeasurement } from "../../../types";
2
+ import { Measurement, MeasurementTypeKey, Sample, UrineAnalyzeMeasurement } from "../../../types/MeasurementTypes";
3
3
  import { RecordResult, RecordType } from "../types/generate-measurement/HealthConnectTypes";
4
4
  import { ObservationFragment } from "../types/generate-observation-body/ObservationFragment";
5
5
  import { ObservationValue } from "../types/generate-observation-body/ObservationValue";
@@ -2,18 +2,18 @@
2
2
  /* eslint-disable max-lines */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.UricAcidService = void 0;
5
- const types_1 = require("../../../types");
5
+ const MeasurementTypes_1 = require("../../../types/MeasurementTypes");
6
6
  const fhir_systems_1 = require("../fhir-systems");
7
7
  const base_observation_service_1 = require("./base-observation-service");
8
8
  const measurement_time_1 = require("./measurement-time");
9
9
  class UricAcidService extends base_observation_service_1.BaseObservationService {
10
10
  constructor() {
11
11
  super(...arguments);
12
- this.measurementTypeKey = types_1.MeasurementTypeKey.uricAcid;
12
+ this.measurementTypeKey = MeasurementTypes_1.MeasurementTypeKey.uricAcid;
13
13
  this.measurementTypeName = "uric acid";
14
14
  this.observationMetadata = [
15
15
  {
16
- primaryCode: types_1.ObservationCode.URIC_ACID,
16
+ primaryCode: MeasurementTypes_1.ObservationCode.URIC_ACID,
17
17
  additionalCodes: [],
18
18
  display: "URINE",
19
19
  unit: "problems",
@@ -23,8 +23,8 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
23
23
  ];
24
24
  }
25
25
  getCastedMeasurement(measurement) {
26
- if (measurement.measurementTypeKey !== types_1.MeasurementTypeKey.urineAnalysis &&
27
- measurement.measurementTypeKey !== types_1.MeasurementTypeKey.uricAcid) {
26
+ if (measurement.measurementTypeKey !== MeasurementTypes_1.MeasurementTypeKey.urineAnalysis &&
27
+ measurement.measurementTypeKey !== MeasurementTypes_1.MeasurementTypeKey.uricAcid) {
28
28
  throw new Error("Measurement is not a uric acid measurement");
29
29
  }
30
30
  return measurement;
@@ -37,7 +37,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
37
37
  valueQuantity: {
38
38
  value: problemCount,
39
39
  unit: "problems",
40
- code: types_1.ObservationCode.URIC_ACID,
40
+ code: MeasurementTypes_1.ObservationCode.URIC_ACID,
41
41
  system: fhir_systems_1.LOINC_SYSTEM,
42
42
  },
43
43
  });
@@ -66,7 +66,7 @@ class UricAcidService extends base_observation_service_1.BaseObservationService
66
66
  generateObservationFragments(measurement) {
67
67
  const castedMeasurement = this.getCastedMeasurement(measurement);
68
68
  const effectiveDateTime = (0, measurement_time_1.recordedAtOrNow)(castedMeasurement).toISOString();
69
- return types_1.URINE_ANALYTE_DEFINITIONS.flatMap((analyte) => {
69
+ return MeasurementTypes_1.URINE_ANALYTE_DEFINITIONS.flatMap((analyte) => {
70
70
  const value = castedMeasurement[analyte.key];
71
71
  if (value === undefined || value === null || !Number.isFinite(value)) {
72
72
  return [];
@@ -1,6 +1,5 @@
1
- import { IClientStorage } from "@medplum/core";
2
1
  import { Bundle, BundleEntry, Observation } from "@medplum/fhirtypes";
3
- import type { MedplumRequestOptions } from "@medplum/core";
2
+ import type { IClientStorage, MedplumRequestOptions } from "@medplum/core";
4
3
  export declare const OFFLINE_MEASUREMENT_QUEUE_STORAGE_KEY = "ovok.core.offline-measurements";
5
4
  declare const IDENTIFIER_SYSTEM = "https://api.ovok.com/fhir/StructureDefinition/offline-measurement-id";
6
5
  export type OfflineMeasurementQueueOptions = {
@@ -36,3 +36,8 @@ export type WearableConnectionAuthorization = {
36
36
  provider: WearableProvider;
37
37
  authorizationUrl: string;
38
38
  };
39
+ export type WearableSyncResult = {
40
+ provider: WearableProvider;
41
+ created: number;
42
+ syncedThrough: string;
43
+ };
@@ -48,7 +48,7 @@ exports.OVOK_CORE_REQUIREMENTS = {
48
48
  description: "The FHIR surface a server must provide for the @ovok/core client library's own methods to function.",
49
49
  software: {
50
50
  name: "@ovok/core",
51
- version: "0.4.49-dev.495+2f9a307",
51
+ version: "0.4.49-dev.497+7201066",
52
52
  },
53
53
  fhirVersion: "4.0.1",
54
54
  format: ["json"],
@@ -0,0 +1,9 @@
1
+ export type Clock = () => number;
2
+ export declare const expiresAtFor: (expiresInSeconds: number, now: number) => number;
3
+ export declare class AccessToken {
4
+ readonly value: string;
5
+ readonly expiresAt: number;
6
+ constructor(value: string, expiresAt: number);
7
+ /** Stale a minute early, so a token never expires between the check and the request. */
8
+ isStaleAt(now: number): boolean;
9
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccessToken = exports.expiresAtFor = void 0;
4
+ const REFRESH_MARGIN_MS = 60000;
5
+ const MS_PER_SECOND = 1000;
6
+ const expiresAtFor = (expiresInSeconds, now) => now + expiresInSeconds * MS_PER_SECOND;
7
+ exports.expiresAtFor = expiresAtFor;
8
+ class AccessToken {
9
+ constructor(value, expiresAt) {
10
+ this.value = value;
11
+ this.expiresAt = expiresAt;
12
+ }
13
+ /** Stale a minute early, so a token never expires between the check and the request. */
14
+ isStaleAt(now) {
15
+ return now >= this.expiresAt - REFRESH_MARGIN_MS;
16
+ }
17
+ }
18
+ exports.AccessToken = AccessToken;
@@ -0,0 +1,16 @@
1
+ import { MachineClient } from "../config/ovok-config";
2
+ import { Clock } from "./access-token";
3
+ import { Credentials } from "./credentials";
4
+ import { TokenEndpoint } from "./token-endpoint";
5
+ export declare class ClientCredentials implements Credentials {
6
+ private readonly endpoint;
7
+ private readonly client;
8
+ private readonly now;
9
+ private token;
10
+ private pending;
11
+ constructor(endpoint: TokenEndpoint, client: MachineClient, now?: Clock);
12
+ accessToken(): Promise<string>;
13
+ refresh(): Promise<boolean>;
14
+ private fetchToken;
15
+ private requestToken;
16
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ClientCredentials = void 0;
4
+ const access_token_1 = require("./access-token");
5
+ class ClientCredentials {
6
+ constructor(endpoint, client, now = Date.now) {
7
+ this.endpoint = endpoint;
8
+ this.client = client;
9
+ this.now = now;
10
+ this.token = null;
11
+ this.pending = null;
12
+ }
13
+ async accessToken() {
14
+ const cached = this.token;
15
+ const stale = cached === null || cached.isStaleAt(this.now());
16
+ return stale ? (await this.fetchToken()).value : cached.value;
17
+ }
18
+ async refresh() {
19
+ this.token = null;
20
+ await this.fetchToken();
21
+ return true;
22
+ }
23
+ fetchToken() {
24
+ var _a;
25
+ (_a = this.pending) !== null && _a !== void 0 ? _a : (this.pending = this.requestToken().finally(() => {
26
+ this.pending = null;
27
+ }));
28
+ return this.pending;
29
+ }
30
+ async requestToken() {
31
+ const response = await this.endpoint.request({
32
+ grant_type: "client_credentials",
33
+ client_id: this.client.clientId,
34
+ client_secret: this.client.clientSecret,
35
+ });
36
+ this.token = new access_token_1.AccessToken(response.access_token, (0, access_token_1.expiresAtFor)(response.expires_in, this.now()));
37
+ return this.token;
38
+ }
39
+ }
40
+ exports.ClientCredentials = ClientCredentials;
@@ -0,0 +1,5 @@
1
+ export interface Credentials {
2
+ accessToken(): Promise<string | null>;
3
+ refresh(): Promise<boolean>;
4
+ }
5
+ export declare const noCredentials: Credentials;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.noCredentials = void 0;
4
+ exports.noCredentials = {
5
+ accessToken: async () => null,
6
+ refresh: async () => false,
7
+ };
@@ -0,0 +1,26 @@
1
+ import { OvokStorage } from "../storage/ovok-storage";
2
+ import { OvokReference, Session } from "./session";
3
+ export type SavedAccount = {
4
+ id: string;
5
+ profile: OvokReference;
6
+ project: OvokReference;
7
+ active: boolean;
8
+ expired: boolean;
9
+ };
10
+ export type StoredSavedAccount = {
11
+ session: Session;
12
+ expired: boolean;
13
+ };
14
+ export declare class SavedAccountsStore {
15
+ private readonly storage;
16
+ private readonly key;
17
+ constructor(storage: OvokStorage, key: string);
18
+ list(activeAccountId: string | null): Promise<SavedAccount[]>;
19
+ get(accountId: string): Promise<StoredSavedAccount | null>;
20
+ save(session: Session): Promise<void>;
21
+ markExpired(accountId: string): Promise<void>;
22
+ remove(accountId: string): Promise<void>;
23
+ private read;
24
+ private write;
25
+ }
26
+ export declare const savedAccountsStoreFor: (storage: OvokStorage, tenantCode: string) => SavedAccountsStore;
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.savedAccountsStoreFor = exports.SavedAccountsStore = void 0;
4
+ class SavedAccountsStore {
5
+ constructor(storage, key) {
6
+ this.storage = storage;
7
+ this.key = key;
8
+ }
9
+ async list(activeAccountId) {
10
+ return (await this.read()).map(({ session, expired }) => ({
11
+ id: session.profile.reference,
12
+ profile: session.profile,
13
+ project: session.project,
14
+ active: session.profile.reference === activeAccountId,
15
+ expired,
16
+ }));
17
+ }
18
+ async get(accountId) {
19
+ var _a;
20
+ return (_a = (await this.read()).find(({ session }) => session.profile.reference === accountId)) !== null && _a !== void 0 ? _a : null;
21
+ }
22
+ async save(session) {
23
+ const accounts = await this.read();
24
+ const saved = { session, expired: false };
25
+ const existingIndex = accounts.findIndex((account) => account.session.profile.reference === session.profile.reference);
26
+ if (existingIndex === -1) {
27
+ accounts.unshift(saved);
28
+ }
29
+ else {
30
+ accounts[existingIndex] = saved;
31
+ }
32
+ await this.write(accounts);
33
+ }
34
+ async markExpired(accountId) {
35
+ const accounts = await this.read();
36
+ const account = accounts.find(({ session }) => session.profile.reference === accountId);
37
+ if (!account) {
38
+ return;
39
+ }
40
+ account.session = { ...account.session, accessToken: "", refreshToken: null };
41
+ account.expired = true;
42
+ await this.write(accounts);
43
+ }
44
+ async remove(accountId) {
45
+ const accounts = await this.read();
46
+ await this.write(accounts.filter(({ session }) => session.profile.reference !== accountId));
47
+ }
48
+ async read() {
49
+ const raw = await this.storage.getItem(this.key);
50
+ if (raw === null) {
51
+ return [];
52
+ }
53
+ try {
54
+ const value = JSON.parse(raw);
55
+ return Array.isArray(value) ? value.filter(isStoredSavedAccount) : [];
56
+ }
57
+ catch (_a) {
58
+ return [];
59
+ }
60
+ }
61
+ async write(accounts) {
62
+ if (accounts.length === 0) {
63
+ await this.storage.removeItem(this.key);
64
+ return;
65
+ }
66
+ await this.storage.setItem(this.key, JSON.stringify(accounts));
67
+ }
68
+ }
69
+ exports.SavedAccountsStore = SavedAccountsStore;
70
+ const savedAccountsStoreFor = (storage, tenantCode) => new SavedAccountsStore(storage, `ovok:${tenantCode}:saved-accounts`);
71
+ exports.savedAccountsStoreFor = savedAccountsStoreFor;
72
+ const isStoredSavedAccount = (value) => {
73
+ if (typeof value !== "object" || value === null || !("session" in value)) {
74
+ return false;
75
+ }
76
+ const record = value;
77
+ const session = record.session;
78
+ if (typeof session !== "object" || session === null || typeof record.expired !== "boolean") {
79
+ return false;
80
+ }
81
+ const candidate = session;
82
+ return (typeof candidate.accessToken === "string" &&
83
+ (candidate.refreshToken === null || typeof candidate.refreshToken === "string") &&
84
+ typeof candidate.expiresAt === "number" &&
85
+ isReference(candidate.profile) &&
86
+ isReference(candidate.project));
87
+ };
88
+ const isReference = (value) => typeof value === "object" &&
89
+ value !== null &&
90
+ "reference" in value &&
91
+ typeof value.reference === "string" &&
92
+ "display" in value &&
93
+ (typeof value.display === "string" || value.display === null);
@@ -0,0 +1,12 @@
1
+ import { OvokStorage } from "../storage/ovok-storage";
2
+ import { Session } from "./session";
3
+ export declare class SessionStore {
4
+ private readonly storage;
5
+ private readonly key;
6
+ constructor(storage: OvokStorage, key: string);
7
+ load(): Promise<Session | null>;
8
+ save(session: Session): Promise<void>;
9
+ clear(): Promise<void>;
10
+ }
11
+ /** One key per tenant, so clearing a session never touches anything else in shared storage. */
12
+ export declare const sessionStoreFor: (storage: OvokStorage, tenantCode: string) => SessionStore;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sessionStoreFor = exports.SessionStore = void 0;
4
+ class SessionStore {
5
+ constructor(storage, key) {
6
+ this.storage = storage;
7
+ this.key = key;
8
+ }
9
+ async load() {
10
+ const raw = await this.storage.getItem(this.key);
11
+ return raw === null ? null : parseSession(raw);
12
+ }
13
+ async save(session) {
14
+ await this.storage.setItem(this.key, JSON.stringify(session));
15
+ }
16
+ async clear() {
17
+ await this.storage.removeItem(this.key);
18
+ }
19
+ }
20
+ exports.SessionStore = SessionStore;
21
+ /** One key per tenant, so clearing a session never touches anything else in shared storage. */
22
+ const sessionStoreFor = (storage, tenantCode) => new SessionStore(storage, `ovok:${tenantCode}:session`);
23
+ exports.sessionStoreFor = sessionStoreFor;
24
+ const parseSession = (raw) => {
25
+ try {
26
+ const value = JSON.parse(raw);
27
+ const complete = typeof value.accessToken === "string" && typeof value.expiresAt === "number";
28
+ return complete ? value : null;
29
+ }
30
+ catch (_a) {
31
+ return null;
32
+ }
33
+ };
@@ -0,0 +1,28 @@
1
+ import { OAuthTokenResponse } from "./token-endpoint";
2
+ export type OvokReference = {
3
+ reference: string;
4
+ display: string | null;
5
+ };
6
+ export type Session = {
7
+ accessToken: string;
8
+ refreshToken: string | null;
9
+ expiresAt: number;
10
+ project: OvokReference;
11
+ profile: OvokReference;
12
+ };
13
+ export type LoginTokens = {
14
+ accessToken: string;
15
+ refreshToken?: string | null;
16
+ expiresIn: number;
17
+ project: {
18
+ reference: string;
19
+ display?: string | null;
20
+ };
21
+ profile: {
22
+ reference: string;
23
+ display?: string | null;
24
+ };
25
+ };
26
+ export declare const sessionFromLogin: (tokens: LoginTokens, now: number) => Session;
27
+ export declare const sessionAfterRefresh: (session: Session, response: OAuthTokenResponse, now: number) => Session;
28
+ export declare const isSessionStaleAt: (session: Session, now: number) => boolean;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSessionStaleAt = exports.sessionAfterRefresh = exports.sessionFromLogin = void 0;
4
+ const access_token_1 = require("./access-token");
5
+ const sessionFromLogin = (tokens, now) => {
6
+ var _a, _b, _c;
7
+ return ({
8
+ accessToken: tokens.accessToken,
9
+ refreshToken: (_a = tokens.refreshToken) !== null && _a !== void 0 ? _a : null,
10
+ expiresAt: (0, access_token_1.expiresAtFor)(tokens.expiresIn, now),
11
+ project: { reference: tokens.project.reference, display: (_b = tokens.project.display) !== null && _b !== void 0 ? _b : null },
12
+ profile: { reference: tokens.profile.reference, display: (_c = tokens.profile.display) !== null && _c !== void 0 ? _c : null },
13
+ });
14
+ };
15
+ exports.sessionFromLogin = sessionFromLogin;
16
+ const sessionAfterRefresh = (session, response, now) => {
17
+ var _a;
18
+ return ({
19
+ ...session,
20
+ accessToken: response.access_token,
21
+ refreshToken: (_a = response.refresh_token) !== null && _a !== void 0 ? _a : session.refreshToken,
22
+ expiresAt: (0, access_token_1.expiresAtFor)(response.expires_in, now),
23
+ });
24
+ };
25
+ exports.sessionAfterRefresh = sessionAfterRefresh;
26
+ const isSessionStaleAt = (session, now) => new access_token_1.AccessToken(session.accessToken, session.expiresAt).isStaleAt(now);
27
+ exports.isSessionStaleAt = isSessionStaleAt;