@ovok/core 0.4.49-rc.1 → 0.4.49-rc.2

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 (278) hide show
  1. package/README.md +27 -79
  2. package/dist/client/observation/measurement-fields.d.ts +1 -1
  3. package/dist/client/observation/methods/observationsToMeasurements.d.ts +1 -1
  4. package/dist/client/observation/methods/observationsToMeasurements.js +59 -59
  5. package/dist/client/observation/services/base-observation-service.d.ts +1 -1
  6. package/dist/client/observation/services/blood-oxygen.d.ts +1 -1
  7. package/dist/client/observation/services/blood-oxygen.js +7 -7
  8. package/dist/client/observation/services/blood-pressure.d.ts +1 -1
  9. package/dist/client/observation/services/blood-pressure.js +16 -16
  10. package/dist/client/observation/services/component-observation-services.d.ts +1 -1
  11. package/dist/client/observation/services/component-observation-services.js +3 -3
  12. package/dist/client/observation/services/creator.d.ts +1 -1
  13. package/dist/client/observation/services/creator.js +10 -10
  14. package/dist/client/observation/services/ecg-observation-fragments.d.ts +1 -1
  15. package/dist/client/observation/services/ecg.d.ts +1 -1
  16. package/dist/client/observation/services/ecg.js +10 -10
  17. package/dist/client/observation/services/lipid-panel.d.ts +1 -1
  18. package/dist/client/observation/services/lipid-panel.js +13 -13
  19. package/dist/client/observation/services/single-value-services.d.ts +1 -1
  20. package/dist/client/observation/services/single-value-services.js +19 -19
  21. package/dist/client/observation/services/step-count.d.ts +1 -1
  22. package/dist/client/observation/services/step-count.js +5 -5
  23. package/dist/client/observation/services/uric-acid-service.d.ts +1 -1
  24. package/dist/client/observation/services/uric-acid-service.js +7 -7
  25. package/dist/client/offline/offline-measurement-queue.d.ts +1 -2
  26. package/dist/client/signals/methods.d.ts +2 -23
  27. package/dist/client/signals/methods.js +10 -93
  28. package/dist/client/signals/types.d.ts +6 -132
  29. package/dist/client/wearables/types.d.ts +5 -0
  30. package/dist/conformance/api-requirements.js +2 -9
  31. package/dist/conformance/capability-requirements.js +1 -1
  32. package/dist/hooks/index.d.ts +1 -1
  33. package/dist/hooks/index.js +1 -9
  34. package/dist/hooks/notification-invalidation.d.ts +0 -7
  35. package/dist/hooks/signals-hooks.d.ts +2 -23
  36. package/dist/hooks/signals-hooks.js +1 -15
  37. package/dist/next/auth/access-token.d.ts +9 -0
  38. package/dist/next/auth/access-token.js +18 -0
  39. package/dist/next/auth/client-credentials.d.ts +16 -0
  40. package/dist/next/auth/client-credentials.js +40 -0
  41. package/dist/next/auth/credentials.d.ts +5 -0
  42. package/dist/next/auth/credentials.js +7 -0
  43. package/dist/next/auth/saved-accounts-store.d.ts +26 -0
  44. package/dist/next/auth/saved-accounts-store.js +93 -0
  45. package/dist/next/auth/session-store.d.ts +12 -0
  46. package/dist/next/auth/session-store.js +33 -0
  47. package/dist/next/auth/session.d.ts +28 -0
  48. package/dist/next/auth/session.js +27 -0
  49. package/dist/next/auth/token-endpoint.d.ts +12 -0
  50. package/dist/next/auth/token-endpoint.js +28 -0
  51. package/dist/next/auth/user-session.d.ts +39 -0
  52. package/dist/next/auth/user-session.js +183 -0
  53. package/dist/next/config/ovok-config.d.ts +42 -0
  54. package/dist/next/config/ovok-config.js +2 -0
  55. package/dist/next/config/settings.d.ts +6 -0
  56. package/dist/next/config/settings.js +74 -0
  57. package/dist/next/errors/error-from-response.d.ts +2 -0
  58. package/dist/next/errors/error-from-response.js +35 -0
  59. package/dist/next/errors/ovok-account-error.d.ts +5 -0
  60. package/dist/next/errors/ovok-account-error.js +13 -0
  61. package/dist/next/errors/ovok-errors.d.ts +42 -0
  62. package/dist/next/errors/ovok-errors.js +74 -0
  63. package/dist/next/http/http-client.d.ts +36 -0
  64. package/dist/next/http/http-client.js +116 -0
  65. package/dist/next/http/retry-after.d.ts +1 -0
  66. package/dist/next/http/retry-after.js +16 -0
  67. package/dist/next/http/retry-policy.d.ts +13 -0
  68. package/dist/next/http/retry-policy.js +27 -0
  69. package/dist/next/http/transmit.d.ts +14 -0
  70. package/dist/next/http/transmit.js +57 -0
  71. package/dist/next/http/url.d.ts +6 -0
  72. package/dist/next/http/url.js +22 -0
  73. package/dist/next/index.d.ts +77 -0
  74. package/dist/next/index.js +35 -0
  75. package/dist/next/ovok.d.ts +56 -0
  76. package/dist/next/ovok.js +86 -0
  77. package/dist/next/paging/bundle-page.d.ts +4 -0
  78. package/dist/next/paging/bundle-page.js +25 -0
  79. package/dist/next/paging/cursor-pages.d.ts +7 -0
  80. package/dist/next/paging/cursor-pages.js +14 -0
  81. package/dist/next/paging/numbered-pages.d.ts +15 -0
  82. package/dist/next/paging/numbered-pages.js +20 -0
  83. package/dist/next/paging/page.d.ts +12 -0
  84. package/dist/next/paging/page.js +17 -0
  85. package/dist/next/react/context.d.ts +4 -0
  86. package/dist/{hooks/signals-alert-item-hooks.js → next/react/context.js} +10 -26
  87. package/dist/next/react/index.d.ts +14 -0
  88. package/dist/next/react/index.js +68 -0
  89. package/dist/next/react/query-hooks.d.ts +31 -0
  90. package/dist/next/react/query-hooks.js +160 -0
  91. package/dist/next/resources/accounts/accounts-resource.d.ts +8 -0
  92. package/dist/next/resources/accounts/accounts-resource.js +13 -0
  93. package/dist/next/resources/ai/ai-chat-resource.d.ts +8 -0
  94. package/dist/next/resources/ai/ai-chat-resource.js +12 -0
  95. package/dist/next/resources/ai/ai-resource.d.ts +16 -0
  96. package/dist/next/resources/ai/ai-resource.js +19 -0
  97. package/dist/next/resources/ai/chat-messages-resource.d.ts +9 -0
  98. package/dist/next/resources/ai/chat-messages-resource.js +18 -0
  99. package/dist/next/resources/ai/chat-sessions-resource.d.ts +14 -0
  100. package/dist/next/resources/ai/chat-sessions-resource.js +23 -0
  101. package/dist/next/resources/auth/auth-sessions-resource.d.ts +13 -0
  102. package/dist/next/resources/auth/auth-sessions-resource.js +25 -0
  103. package/dist/next/resources/auth/registration.d.ts +35 -0
  104. package/dist/next/resources/auth/registration.js +24 -0
  105. package/dist/next/resources/auth/social-login.d.ts +8 -0
  106. package/dist/next/resources/auth/social-login.js +7 -0
  107. package/dist/next/resources/auth-resource.d.ts +63 -0
  108. package/dist/next/resources/auth-resource.js +119 -0
  109. package/dist/next/resources/bots/bots-resource.d.ts +10 -0
  110. package/dist/next/resources/bots/bots-resource.js +15 -0
  111. package/dist/next/resources/cms/cms-delivery.d.ts +22 -0
  112. package/dist/next/resources/cms/cms-delivery.js +36 -0
  113. package/dist/next/resources/cms/cms-documents-resource.d.ts +11 -0
  114. package/dist/next/resources/cms/cms-documents-resource.js +17 -0
  115. package/dist/next/resources/cms/cms-resource.d.ts +17 -0
  116. package/dist/next/resources/cms/cms-resource.js +38 -0
  117. package/dist/next/resources/cms/payload-pages.d.ts +6 -0
  118. package/dist/next/resources/cms/payload-pages.js +15 -0
  119. package/dist/next/resources/cms/release-notes-resource.d.ts +10 -0
  120. package/dist/next/resources/cms/release-notes-resource.js +15 -0
  121. package/dist/next/resources/cms/translation-tree.d.ts +3 -0
  122. package/dist/next/resources/cms/translation-tree.js +45 -0
  123. package/dist/next/resources/consent/consent-resource.d.ts +23 -0
  124. package/dist/next/resources/consent/consent-resource.js +43 -0
  125. package/dist/next/resources/content/content-resource.d.ts +19 -0
  126. package/dist/next/resources/content/content-resource.js +41 -0
  127. package/dist/next/resources/documents/documents-resource.d.ts +26 -0
  128. package/dist/next/resources/documents/documents-resource.js +41 -0
  129. package/dist/next/resources/email/email-resource.d.ts +6 -0
  130. package/dist/next/resources/email/email-resource.js +10 -0
  131. package/dist/next/resources/email/email-templates-resource.d.ts +8 -0
  132. package/dist/next/resources/email/email-templates-resource.js +13 -0
  133. package/dist/next/resources/fhir-resource.d.ts +28 -0
  134. package/dist/next/resources/fhir-resource.js +64 -0
  135. package/dist/next/resources/health-resource.d.ts +17 -0
  136. package/dist/next/resources/health-resource.js +14 -0
  137. package/dist/next/resources/invites/invite-flow-resource.d.ts +12 -0
  138. package/dist/next/resources/invites/invite-flow-resource.js +19 -0
  139. package/dist/next/resources/invites/invites-resource.d.ts +22 -0
  140. package/dist/next/resources/invites/invites-resource.js +29 -0
  141. package/dist/next/resources/localization/i18next-resource.d.ts +10 -0
  142. package/dist/next/resources/localization/i18next-resource.js +18 -0
  143. package/dist/next/resources/localization/locales-resource.d.ts +9 -0
  144. package/dist/next/resources/localization/locales-resource.js +16 -0
  145. package/dist/next/resources/localization/localizations-resource.d.ts +17 -0
  146. package/dist/next/resources/localization/localizations-resource.js +27 -0
  147. package/dist/next/resources/measurements/measurements-resource.d.ts +58 -0
  148. package/dist/next/resources/measurements/measurements-resource.js +98 -0
  149. package/dist/next/resources/measurements/observation-builder.d.ts +5 -0
  150. package/dist/next/resources/measurements/observation-builder.js +57 -0
  151. package/dist/next/resources/measurements/offline-measurement-queue-types.d.ts +22 -0
  152. package/dist/next/resources/measurements/offline-measurement-queue-types.js +2 -0
  153. package/dist/next/resources/measurements/offline-measurement-queue.d.ts +25 -0
  154. package/dist/next/resources/measurements/offline-measurement-queue.js +154 -0
  155. package/dist/next/resources/measurements/save-error.d.ts +5 -0
  156. package/dist/next/resources/measurements/save-error.js +18 -0
  157. package/dist/next/resources/measurements/signed-in-account.d.ts +11 -0
  158. package/dist/next/resources/measurements/signed-in-account.js +26 -0
  159. package/dist/next/resources/patient/fhir-records.d.ts +19 -0
  160. package/dist/next/resources/patient/fhir-records.js +33 -0
  161. package/dist/next/resources/patient/patient-resource.d.ts +21 -0
  162. package/dist/next/resources/patient/patient-resource.js +38 -0
  163. package/dist/next/resources/projects/project-features-resource.d.ts +9 -0
  164. package/dist/next/resources/projects/project-features-resource.js +17 -0
  165. package/dist/next/resources/projects/project-members-resource.d.ts +19 -0
  166. package/dist/next/resources/projects/project-members-resource.js +25 -0
  167. package/dist/next/resources/projects/project-settings-resource.d.ts +10 -0
  168. package/dist/next/resources/projects/project-settings-resource.js +21 -0
  169. package/dist/next/resources/projects/projects-resource.d.ts +20 -0
  170. package/dist/next/resources/projects/projects-resource.js +21 -0
  171. package/dist/next/resources/questionnaires/questionnaires-resource.d.ts +18 -0
  172. package/dist/next/resources/questionnaires/questionnaires-resource.js +36 -0
  173. package/dist/next/resources/realtime/realtime-binding.d.ts +7 -0
  174. package/dist/next/resources/realtime/realtime-binding.js +44 -0
  175. package/dist/next/resources/realtime/realtime-connection.d.ts +38 -0
  176. package/dist/next/resources/realtime/realtime-connection.js +167 -0
  177. package/dist/next/resources/realtime/realtime-resource.d.ts +13 -0
  178. package/dist/next/resources/realtime/realtime-resource.js +39 -0
  179. package/dist/next/resources/realtime/realtime-socket.d.ts +23 -0
  180. package/dist/next/resources/realtime/realtime-socket.js +152 -0
  181. package/dist/next/resources/realtime/realtime-types.d.ts +6 -0
  182. package/dist/next/resources/realtime/realtime-types.js +2 -0
  183. package/dist/next/resources/session/saved-accounts-resource.d.ts +13 -0
  184. package/dist/next/resources/session/saved-accounts-resource.js +44 -0
  185. package/dist/next/resources/session/session-resource.d.ts +12 -0
  186. package/dist/next/resources/session/session-resource.js +19 -0
  187. package/dist/next/resources/sharing/sharing-invites-resource.d.ts +9 -0
  188. package/dist/next/resources/sharing/sharing-invites-resource.js +17 -0
  189. package/dist/next/resources/sharing/sharing-resource.d.ts +10 -0
  190. package/dist/next/resources/sharing/sharing-resource.js +14 -0
  191. package/dist/next/resources/sharing/sharing-settings-resource.d.ts +9 -0
  192. package/dist/next/resources/sharing/sharing-settings-resource.js +16 -0
  193. package/dist/next/resources/sharing/sharing-shares-resource.d.ts +9 -0
  194. package/dist/next/resources/sharing/sharing-shares-resource.js +27 -0
  195. package/dist/next/resources/signals/signals-gateway-resource.d.ts +14 -0
  196. package/dist/next/resources/signals/signals-gateway-resource.js +44 -0
  197. package/dist/next/resources/signals/signals-resource.d.ts +13 -0
  198. package/dist/next/resources/signals/signals-resource.js +19 -0
  199. package/dist/next/resources/signals/undeliverable-resource.d.ts +26 -0
  200. package/dist/next/resources/signals/undeliverable-resource.js +18 -0
  201. package/dist/next/resources/slim/live-reads.d.ts +13 -0
  202. package/dist/next/resources/slim/live-reads.js +87 -0
  203. package/dist/next/resources/slim/slim-alarms-resource.d.ts +13 -0
  204. package/dist/next/resources/slim/slim-alarms-resource.js +25 -0
  205. package/dist/next/resources/slim/slim-change-history-resource.d.ts +9 -0
  206. package/dist/next/resources/slim/slim-change-history-resource.js +19 -0
  207. package/dist/next/resources/slim/slim-child-projects-resource.d.ts +17 -0
  208. package/dist/next/resources/slim/slim-child-projects-resource.js +22 -0
  209. package/dist/next/resources/slim/slim-devices-resource.d.ts +29 -0
  210. package/dist/next/resources/slim/slim-devices-resource.js +81 -0
  211. package/dist/next/resources/slim/slim-exports-resource.d.ts +8 -0
  212. package/dist/next/resources/slim/slim-exports-resource.js +14 -0
  213. package/dist/next/resources/slim/slim-locations-resource.d.ts +14 -0
  214. package/dist/next/resources/slim/slim-locations-resource.js +30 -0
  215. package/dist/next/resources/slim/slim-medical-notifications-resource.d.ts +18 -0
  216. package/dist/next/resources/slim/slim-medical-notifications-resource.js +46 -0
  217. package/dist/next/resources/slim/slim-notification-notes-resource.d.ts +12 -0
  218. package/dist/next/resources/slim/slim-notification-notes-resource.js +34 -0
  219. package/dist/next/resources/slim/slim-notifications-resource.d.ts +19 -0
  220. package/dist/next/resources/slim/slim-notifications-resource.js +26 -0
  221. package/dist/next/resources/slim/slim-organizations-resource.d.ts +11 -0
  222. package/dist/next/resources/slim/slim-organizations-resource.js +25 -0
  223. package/dist/next/resources/slim/slim-out-of-bed-resource.d.ts +13 -0
  224. package/dist/next/resources/slim/slim-out-of-bed-resource.js +20 -0
  225. package/dist/next/resources/slim/slim-paths.d.ts +6 -0
  226. package/dist/next/resources/slim/slim-paths.js +9 -0
  227. package/dist/next/resources/slim/slim-patient-thresholds-resource.d.ts +10 -0
  228. package/dist/next/resources/slim/slim-patient-thresholds-resource.js +20 -0
  229. package/dist/next/resources/slim/slim-patients-resource.d.ts +20 -0
  230. package/dist/next/resources/slim/slim-patients-resource.js +39 -0
  231. package/dist/next/resources/slim/slim-policies-resource.d.ts +12 -0
  232. package/dist/next/resources/slim/slim-policies-resource.js +29 -0
  233. package/dist/next/resources/slim/slim-practitioners-resource.d.ts +8 -0
  234. package/dist/next/resources/slim/slim-practitioners-resource.js +14 -0
  235. package/dist/next/resources/slim/slim-projects-resource.d.ts +16 -0
  236. package/dist/next/resources/slim/slim-projects-resource.js +35 -0
  237. package/dist/next/resources/slim/slim-queries.d.ts +34 -0
  238. package/dist/next/resources/slim/slim-queries.js +2 -0
  239. package/dist/next/resources/slim/slim-resource.d.ts +39 -0
  240. package/dist/next/resources/slim/slim-resource.js +44 -0
  241. package/dist/next/resources/slim/slim-sleep-resource.d.ts +9 -0
  242. package/dist/next/resources/slim/slim-sleep-resource.js +15 -0
  243. package/dist/next/resources/slim/slim-thresholds-resource.d.ts +11 -0
  244. package/dist/next/resources/slim/slim-thresholds-resource.js +18 -0
  245. package/dist/next/resources/slim/slim-trends-resource.d.ts +11 -0
  246. package/dist/next/resources/slim/slim-trends-resource.js +19 -0
  247. package/dist/next/resources/slim/slim-users-resource.d.ts +11 -0
  248. package/dist/next/resources/slim/slim-users-resource.js +15 -0
  249. package/dist/next/resources/slim/slim-zones-resource.d.ts +12 -0
  250. package/dist/next/resources/slim/slim-zones-resource.js +24 -0
  251. package/dist/next/resources/video-calls/video-call-access-resource.d.ts +11 -0
  252. package/dist/next/resources/video-calls/video-call-access-resource.js +19 -0
  253. package/dist/next/resources/video-calls/video-call-appointments-resource.d.ts +10 -0
  254. package/dist/next/resources/video-calls/video-call-appointments-resource.js +21 -0
  255. package/dist/next/resources/video-calls/video-call-emails-resource.d.ts +10 -0
  256. package/dist/next/resources/video-calls/video-call-emails-resource.js +19 -0
  257. package/dist/next/resources/video-calls/video-calls-resource.d.ts +14 -0
  258. package/dist/next/resources/video-calls/video-calls-resource.js +20 -0
  259. package/dist/next/resources/wearables/wearable-connections-resource.d.ts +12 -0
  260. package/dist/next/resources/wearables/wearable-connections-resource.js +25 -0
  261. package/dist/next/resources/wearables/wearable-providers-resource.d.ts +12 -0
  262. package/dist/next/resources/wearables/wearable-providers-resource.js +27 -0
  263. package/dist/next/resources/wearables/wearables-resource.d.ts +8 -0
  264. package/dist/next/resources/wearables/wearables-resource.js +14 -0
  265. package/dist/next/storage/ovok-storage.d.ts +11 -0
  266. package/dist/next/storage/ovok-storage.js +19 -0
  267. package/dist/types/MeasurementTypes.d.ts +5 -0
  268. package/dist/types/MeasurementTypes.js +21 -0
  269. package/dist/types/index.d.ts +1 -5
  270. package/dist/types/index.js +1 -5
  271. package/next/index.d.ts +1 -0
  272. package/next/index.js +3 -0
  273. package/next/react/index.d.ts +1 -0
  274. package/next/react/index.js +1 -0
  275. package/package.json +14 -2
  276. package/dist/hooks/signals-alert-hooks.d.ts +0 -22
  277. package/dist/hooks/signals-alert-hooks.js +0 -166
  278. package/dist/hooks/signals-alert-item-hooks.d.ts +0 -19
@@ -1,144 +1,18 @@
1
- import { ValidationError } from "../../types/ValidationError";
2
- export type SignalsThresholdSource = "organization" | "individual" | "auto" | "unknown";
3
- export type SignalsThreshold = {
4
- code: string;
5
- low: number | null;
6
- high: number | null;
7
- editable: boolean;
8
- version: number;
9
- updatedAt: string;
10
- source: SignalsThresholdSource;
11
- };
12
- export type SignalsThresholds = {
13
- patientId: string;
14
- thresholds: SignalsThreshold[];
15
- };
16
- export type SetSignalsThresholdBody = {
17
- low: number | null;
18
- high: number | null;
19
- reason?: string | null;
20
- };
21
- export type SignalsAlertStatus = "OPEN" | "CLOSED";
22
- export type SignalsAlert = {
23
- id: string;
24
- patientId: string;
25
- signalsPatientId: string;
26
- code: string;
27
- status: SignalsAlertStatus;
28
- noteCount: number | null;
29
- [key: string]: unknown;
30
- };
31
- export type SignalsAlertsQuery = {
32
- status?: SignalsAlertStatus;
33
- since?: string;
34
- acknowledged?: boolean;
35
- codes?: readonly string[];
36
- limit?: number;
37
- cursor?: string;
38
- };
39
- export type SignalsAlertsPage = {
40
- items: SignalsAlert[];
41
- nextCursor: string | null;
42
- };
43
- /** Signals' own state of a raw alert: ACTIVE while breaching, RESOLVED once recovered or acknowledged. */
44
- export type SignalsRawAlertStatus = "ACTIVE" | "RESOLVED";
45
- /** The person who acknowledged an alert. */
46
- export type SignalsAcknowledgedActor = {
47
- /** A FHIR reference, e.g. `Practitioner/<id>`. */
48
- reference: string;
49
- display: string | null;
50
- };
51
- /**
52
- * One individual Signals alert, not an episode: available whether or not the project's
53
- * `episodicAlerts` is on. `id`, `createdAt` and `resolvedAt` are Signals' own.
54
- *
55
- * An alert stays open for the practitioner until it is acknowledged: `acknowledgedAt` is null until
56
- * then, even when `status` is already RESOLVED because the reading recovered. Acknowledging
57
- * resolves it, and the next breaching reading opens a new alert.
58
- */
59
- export type SignalsRawAlert = {
60
- id: string;
61
- /** The resident's Medplum Patient id. */
62
- patientId: string;
63
- signalsPatientId: string;
64
- /** The LOINC code that breached; null when no reading's code raised it. */
65
- code: string | null;
66
- /**
67
- * TRIGGER is a threshold breach; EMPTY a reading with no value; NOTE a note; INACTIVE a resident
68
- * who stopped reporting.
69
- */
70
- reason: "TRIGGER" | "EMPTY" | "NOTE" | "INACTIVE";
71
- /** The latest breaching reading, as a number or as text. */
72
- valueNumber: number | null;
73
- valueString: string | null;
74
- /** The rule's own payload; it names the bound that was crossed. */
75
- message: string | null;
76
- observationId: string | null;
77
- triggerCode: string | null;
78
- triggerVersion: number | null;
79
- status: SignalsRawAlertStatus;
80
- createdAt: string;
81
- resolvedAt: string | null;
82
- acknowledgedAt: string | null;
83
- /** The Signals client that acknowledged it (Ovok's), not a person: use `acknowledgedActor`. */
84
- acknowledgedBy: string | null;
85
- acknowledgedActor: SignalsAcknowledgedActor | null;
86
- noteCount: number | null;
87
- [key: string]: unknown;
88
- };
89
- export type SignalsRawAlertsQuery = {
90
- status?: SignalsRawAlertStatus;
91
- /** `false` for the alerts still open for the practitioner, whatever their `status`. */
92
- acknowledged?: boolean;
93
- /**
94
- * One resident's alerts, by Medplum Patient id. 404 when the caller can't read the resident,
95
- * 409 `signals_patient_not_enrolled` when they aren't in Signals yet.
96
- */
97
- patientId?: string;
98
- /** LOINC codes, e.g. `["8867-4", "9279-1"]`. Omitted or empty, every alert. */
99
- codes?: readonly string[];
100
- /** Alerts created at or after this date-time, with `Z` or an offset. */
101
- since?: string;
102
- /** Alerts created before this date-time, with `Z` or an offset. */
103
- until?: string;
104
- /** 1 to 50; 50 when omitted. */
105
- limit?: number;
106
- /** The previous page's `nextCursor`, passed back unchanged. */
107
- cursor?: string;
108
- };
109
- /**
110
- * Newest first. A page can be shorter than `limit`, even empty, and still have a next one: alerts
111
- * of residents the caller can't read are left out. Page until `nextCursor` is null.
112
- */
113
- export type SignalsRawAlertsPage = {
114
- items: SignalsRawAlert[];
115
- nextCursor: string | null;
116
- };
117
- export type SignalsSettings = {
118
- episodicAlerts: boolean;
119
- synchronousMode: boolean;
120
- throttleLimit: number | null;
121
- };
122
- export type SignalsTenantKind = "project" | "shared";
1
+ import type { ValidationError } from "../../types/ValidationError";
123
2
  export type UnconfirmedLimitResident = {
124
3
  patientId: string;
125
- since: string | null;
126
- reason: string | null;
127
4
  };
128
5
  export type UnconfirmedLimits = {
129
6
  count: number;
130
7
  residents: UnconfirmedLimitResident[];
131
8
  };
132
9
  export type RepushUnconfirmedLimitsResult = {
133
- patients: number;
134
- unconfirmed: number;
135
- reason: string | null;
136
- };
137
- export type SignalsSettingsResponse = {
138
- tenant: SignalsTenantKind;
139
- settings: SignalsSettings;
10
+ attempted: number;
11
+ repaired: number;
12
+ stillUndeliverable: number;
13
+ skipped: number;
14
+ notReached: number;
140
15
  };
141
- export type SignalsSettingsPatch = Partial<SignalsSettings>;
142
16
  export type EnableSignalsResponse = {
143
17
  patientId: string;
144
18
  signalsPatientId: string;
@@ -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
+ };
@@ -155,15 +155,8 @@ exports.OVOK_CORE_API_REQUIREMENTS = {
155
155
  { method: "POST", path: "/v1/slim/notifications/medical/:episodeId/ack", group: "Slim/Notifications" },
156
156
  { method: "PATCH", path: "/v1/slim/notifications/:id/ack", group: "Slim/Notifications" },
157
157
  { method: "GET", path: "/v1/slim/change-history", group: "Slim/ChangeHistory" },
158
- { method: "GET", path: "/v1/signals/alerts/:episodeId/notes", group: "Signals/Notes" },
159
- { method: "POST", path: "/v1/signals/alerts/:episodeId/notes", group: "Signals/Notes" },
160
- { method: "GET", path: "/v1/signals/raw-alerts/:alertId/notes", group: "Signals/Notes" },
161
- { method: "POST", path: "/v1/signals/raw-alerts/:alertId/notes", group: "Signals/Notes" },
162
- { method: "PUT", path: "/v1/signals/notes/:noteId", group: "Signals/Notes" },
163
- { method: "PATCH", path: "/v1/signals/notes/:noteId", group: "Signals/Notes" },
164
- { method: "DELETE", path: "/v1/signals/notes/:noteId", group: "Signals/Notes" },
165
- { method: "GET", path: "/signals/config/unconfirmed", group: "Signals/Thresholds" },
166
- { method: "POST", path: "/signals/config/unconfirmed/repush", group: "Signals/Thresholds" },
158
+ { method: "GET", path: "/signals/config/undeliverable", group: "Signals/Delivery" },
159
+ { method: "POST", path: "/signals/config/undeliverable/repair", group: "Signals/Delivery" },
167
160
  { method: "GET", path: "/v1/slim/threshold", group: "Slim/Threshold" },
168
161
  { method: "PUT", path: "/v1/slim/threshold", group: "Slim/Threshold" },
169
162
  { method: "GET", path: "/v1/slim/threshold/patient/:patientId", group: "Slim/Threshold" },
@@ -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-rc.1",
51
+ version: "0.4.49-rc.2",
52
52
  },
53
53
  fhirVersion: "4.0.1",
54
54
  format: ["json"],
@@ -22,4 +22,4 @@ export { useAcceptCareInvite, useAcceptInvite, useAcceptRecordShare, useInvitePa
22
22
  export { useCurrentPatientProfile, useExtractQuestionnaireObservations, usePatientAppointments, usePatientCarePlans, usePatientDevices, usePatientMeasurement, usePatientMeasurementHistory, usePatientDashboard, usePatientLatestObservations, usePatientNotifications, usePatientQuestionnaireResponses, usePatientQuestionnaires, usePatientSchedules, usePatientSlots, usePopulateQuestionnaire, useSubmitQuestionnaireResponse, } from "./patient-hooks";
23
23
  export { useCreatePatientSharingInvite, usePatientSharing, usePatientSharingSettings, useRedeemPatientSharingInvite, useRevokePatientSharing, useUpdatePatientSharingSettings, } from "./patient-sharing-hooks";
24
24
  export { useAuthorizeWearableConnection, useCreateWearableProvider, useDeleteWearableConnection, useDeleteWearableProvider, useUpdateWearableProvider, useWearableConnections, useWearableProviders, } from "./wearables-hooks";
25
- export { useAcknowledgeSignalsAlert, useEnableSignalsForPatient, useRemoveSignalsThreshold, useSetSignalsThreshold, useSignalsAlert, useSignalsAlerts, useSignalsSettings, useSignalsThresholds, useUpdateSignalsSettings, } from "./signals-hooks";
25
+ export { useEnableSignalsForPatient, } from "./signals-hooks";
@@ -36,7 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  exports.useSlimPatientThresholdV2 = exports.useSetMedicalConsent = exports.useSetLegalConsent = exports.useRepushUnconfirmedLimits = exports.useMedicalConsent = exports.useLegalConsent = exports.useChangeHistory = exports.useEmailTemplates = exports.useUpdateProjectTextSetting = exports.useUpdateLocalization = exports.useUpdateI18nextDocument = exports.useLocalizations = exports.useLocales = exports.useI18nextDocument = exports.useVideoCallAppointments = exports.useVideoCallAccess = exports.useDocuments = exports.useCreateVideoCallUserAccess = exports.useCreateVideoCallAppointment = exports.useContent = exports.useConsentSignature = exports.useOvokPoll = exports.usePublicApiEndpoints = exports.useProjectSettings = exports.useProjectFeatures = exports.useOvokRequest = exports.useOvokMutation = exports.useCapabilityStatement = exports.useSlimPatients = exports.useSlimDevices = exports.useSlimDeviceTelemetry = exports.useAdministeredProjects = exports.useUrineTests = exports.useSaveMeasurement = exports.useObservations = exports.useEcgRecording = exports.observationsToMeasurements = exports.OvokProvider = exports.useClient = exports.useCachedBinaryUrl = exports.reactContext = exports.useSubscription = exports.useSearchResources = exports.useSearchOne = exports.useSearch = exports.useResource = exports.usePrevious = exports.useMedplumProfile = exports.useMedplumNavigate = exports.useMedplumContext = void 0;
38
38
  exports.usePopulateQuestionnaire = exports.usePatientSlots = exports.usePatientSchedules = exports.usePatientQuestionnaires = exports.usePatientQuestionnaireResponses = exports.usePatientNotifications = exports.usePatientLatestObservations = exports.usePatientDashboard = exports.usePatientMeasurementHistory = exports.usePatientMeasurement = exports.usePatientDevices = exports.usePatientCarePlans = exports.usePatientAppointments = exports.useExtractQuestionnaireObservations = exports.useCurrentPatientProfile = exports.useShareRecord = exports.useInviteToCare = exports.useInvitePractitioner = exports.useInvitePatient = exports.useAcceptRecordShare = exports.useAcceptInvite = exports.useAcceptCareInvite = exports.useTranslations = exports.useReleaseNotes = exports.useLegalPage = exports.useCmsDocuments = exports.useCmsDocument = exports.useAcknowledgeSlimMedicalNotification = exports.useAcknowledgeSlimAlarm = exports.useUpdateSignalsNote = exports.useUpdateNotificationNote = exports.useSignalsRawAlertNotes = exports.useSignalsAlertNotes = exports.useNotificationNotes = exports.useDeleteSignalsNote = exports.useDeleteNotificationNote = exports.useCreateSignalsRawAlertNote = exports.useCreateSignalsAlertNote = exports.useCreateNotificationNote = exports.useSlimOutOfBedNotifications = exports.useSlimNotifications = exports.useSlimMedicalNotifications = exports.useSlimAlarms = exports.useRecentSlimNotifications = exports.useRecentOutOfBed = exports.useRecentAlarms = exports.useUpdateSlimThresholdV2 = exports.useUpdateSlimPatientThresholdV2 = exports.useUnconfirmedLimits = exports.useSlimThresholdV2 = void 0;
39
- exports.useUpdateSignalsSettings = exports.useSignalsThresholds = exports.useSignalsSettings = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useSetSignalsThreshold = exports.useRemoveSignalsThreshold = exports.useEnableSignalsForPatient = exports.useAcknowledgeSignalsAlert = exports.useWearableProviders = exports.useWearableConnections = exports.useUpdateWearableProvider = exports.useDeleteWearableProvider = exports.useDeleteWearableConnection = exports.useCreateWearableProvider = exports.useAuthorizeWearableConnection = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = void 0;
39
+ exports.useEnableSignalsForPatient = exports.useWearableProviders = exports.useWearableConnections = exports.useUpdateWearableProvider = exports.useDeleteWearableProvider = exports.useDeleteWearableConnection = exports.useCreateWearableProvider = exports.useAuthorizeWearableConnection = exports.useUpdatePatientSharingSettings = exports.useRevokePatientSharing = exports.useRedeemPatientSharingInvite = exports.usePatientSharingSettings = exports.usePatientSharing = exports.useCreatePatientSharingInvite = exports.useSubmitQuestionnaireResponse = void 0;
40
40
  /*
41
41
  * The only React-dependent module in the package.
42
42
  *
@@ -189,12 +189,4 @@ Object.defineProperty(exports, "useUpdateWearableProvider", { enumerable: true,
189
189
  Object.defineProperty(exports, "useWearableConnections", { enumerable: true, get: function () { return wearables_hooks_1.useWearableConnections; } });
190
190
  Object.defineProperty(exports, "useWearableProviders", { enumerable: true, get: function () { return wearables_hooks_1.useWearableProviders; } });
191
191
  var signals_hooks_1 = require("./signals-hooks");
192
- Object.defineProperty(exports, "useAcknowledgeSignalsAlert", { enumerable: true, get: function () { return signals_hooks_1.useAcknowledgeSignalsAlert; } });
193
192
  Object.defineProperty(exports, "useEnableSignalsForPatient", { enumerable: true, get: function () { return signals_hooks_1.useEnableSignalsForPatient; } });
194
- Object.defineProperty(exports, "useRemoveSignalsThreshold", { enumerable: true, get: function () { return signals_hooks_1.useRemoveSignalsThreshold; } });
195
- Object.defineProperty(exports, "useSetSignalsThreshold", { enumerable: true, get: function () { return signals_hooks_1.useSetSignalsThreshold; } });
196
- Object.defineProperty(exports, "useSignalsAlert", { enumerable: true, get: function () { return signals_hooks_1.useSignalsAlert; } });
197
- Object.defineProperty(exports, "useSignalsAlerts", { enumerable: true, get: function () { return signals_hooks_1.useSignalsAlerts; } });
198
- Object.defineProperty(exports, "useSignalsSettings", { enumerable: true, get: function () { return signals_hooks_1.useSignalsSettings; } });
199
- Object.defineProperty(exports, "useSignalsThresholds", { enumerable: true, get: function () { return signals_hooks_1.useSignalsThresholds; } });
200
- Object.defineProperty(exports, "useUpdateSignalsSettings", { enumerable: true, get: function () { return signals_hooks_1.useUpdateSignalsSettings; } });
@@ -1,18 +1,11 @@
1
1
  import { SlimMedicalNotificationRow } from "../client/notifications/types";
2
2
  import { OvokClient } from "../client/ovok-client";
3
- import { SignalsAlert, SignalsRawAlert } from "../client/signals/types";
4
3
  import { SlimNotification } from "../client/slim/types";
5
4
  export type NotificationChange = {
6
5
  type: "patient-sharing";
7
6
  } | {
8
7
  type: "slim";
9
8
  notification: SlimNotification | SlimMedicalNotificationRow;
10
- } | {
11
- type: "signals-alert";
12
- alert: SignalsAlert;
13
- } | {
14
- type: "signals-raw-alert";
15
- alert: SignalsRawAlert;
16
9
  };
17
10
  type NotificationChangeListener = (change?: NotificationChange) => void;
18
11
  export declare function subscribeToNotificationChanges(client: OvokClient, listener: NotificationChangeListener): () => void;
@@ -1,24 +1,3 @@
1
- import { EnableSignalsResponse, SetSignalsThresholdBody, SignalsSettingsPatch, SignalsSettingsResponse, SignalsThreshold, SignalsThresholds } from "../client/signals";
2
- import { OvokMutationState, OvokRequestState } from "./api-hooks";
3
- export { useAcknowledgeSignalsAlert, useSignalsAlert, useSignalsAlerts, } from "./signals-alert-hooks";
4
- export type { SignalsAlertGrain, SignalsAlertsHookState } from "./signals-alert-hooks";
5
- type SetSignalsThresholdParams = {
6
- patientId: string;
7
- code: string;
8
- body: SetSignalsThresholdBody;
9
- };
10
- type RemoveSignalsThresholdParams = {
11
- patientId: string;
12
- code: string;
13
- reason: string;
14
- };
15
- type UpdateSignalsSettingsParams = {
16
- patch: SignalsSettingsPatch;
17
- reason?: string | null;
18
- };
1
+ import type { EnableSignalsResponse } from "../client/signals";
2
+ import { OvokMutationState } from "./api-hooks";
19
3
  export declare const useEnableSignalsForPatient: () => OvokMutationState<string, EnableSignalsResponse>;
20
- export declare const useSignalsThresholds: (patientId?: string) => OvokRequestState<SignalsThresholds>;
21
- export declare const useSetSignalsThreshold: () => OvokMutationState<SetSignalsThresholdParams, SignalsThreshold>;
22
- export declare const useRemoveSignalsThreshold: () => OvokMutationState<RemoveSignalsThresholdParams, void>;
23
- export declare const useSignalsSettings: () => OvokRequestState<SignalsSettingsResponse>;
24
- export declare const useUpdateSignalsSettings: () => OvokMutationState<UpdateSignalsSettingsParams, SignalsSettingsResponse>;
@@ -1,21 +1,7 @@
1
1
  "use strict";
2
2
  "use client";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.useUpdateSignalsSettings = exports.useSignalsSettings = exports.useRemoveSignalsThreshold = exports.useSetSignalsThreshold = exports.useSignalsThresholds = exports.useEnableSignalsForPatient = exports.useSignalsAlerts = exports.useSignalsAlert = exports.useAcknowledgeSignalsAlert = void 0;
4
+ exports.useEnableSignalsForPatient = void 0;
5
5
  const api_hooks_1 = require("./api-hooks");
6
- var signals_alert_hooks_1 = require("./signals-alert-hooks");
7
- Object.defineProperty(exports, "useAcknowledgeSignalsAlert", { enumerable: true, get: function () { return signals_alert_hooks_1.useAcknowledgeSignalsAlert; } });
8
- Object.defineProperty(exports, "useSignalsAlert", { enumerable: true, get: function () { return signals_alert_hooks_1.useSignalsAlert; } });
9
- Object.defineProperty(exports, "useSignalsAlerts", { enumerable: true, get: function () { return signals_alert_hooks_1.useSignalsAlerts; } });
10
6
  const useEnableSignalsForPatient = () => (0, api_hooks_1.useOvokMutation)((client, patientId) => client.enableSignalsForPatient(patientId));
11
7
  exports.useEnableSignalsForPatient = useEnableSignalsForPatient;
12
- const useSignalsThresholds = (patientId) => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getSignalsThresholds(patientId, { signal }), patientId, patientId !== undefined);
13
- exports.useSignalsThresholds = useSignalsThresholds;
14
- const useSetSignalsThreshold = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.setSignalsThreshold(params.patientId, params.code, params.body));
15
- exports.useSetSignalsThreshold = useSetSignalsThreshold;
16
- const useRemoveSignalsThreshold = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.removeSignalsThreshold(params.patientId, params.code, params.reason));
17
- exports.useRemoveSignalsThreshold = useRemoveSignalsThreshold;
18
- const useSignalsSettings = () => (0, api_hooks_1.useOvokClientRequest)((client, signal) => client.getSignalsSettings({ signal }));
19
- exports.useSignalsSettings = useSignalsSettings;
20
- const useUpdateSignalsSettings = () => (0, api_hooks_1.useOvokMutation)((client, params) => client.updateSignalsSettings(params.patch, params.reason));
21
- exports.useUpdateSignalsSettings = useUpdateSignalsSettings;
@@ -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;
@@ -0,0 +1,12 @@
1
+ import { OvokSettings } from "../config/ovok-config";
2
+ export type OAuthTokenResponse = {
3
+ access_token: string;
4
+ refresh_token?: string;
5
+ expires_in: number;
6
+ token_type: string;
7
+ };
8
+ export declare class TokenEndpoint {
9
+ private readonly settings;
10
+ constructor(settings: OvokSettings);
11
+ request(form: Record<string, string>): Promise<OAuthTokenResponse>;
12
+ }