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

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 +68 -0
  148. package/dist/next/resources/measurements/measurements-resource.js +116 -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
@@ -0,0 +1,12 @@
1
+ export type Page<T> = {
2
+ data: T[];
3
+ hasMore: boolean;
4
+ total: number | null;
5
+ };
6
+ /** Await it for the first page, or `for await` over it to walk every page. */
7
+ export type PagePromise<T> = Promise<Page<T>> & AsyncIterable<T>;
8
+ export type LoadedPage<T> = {
9
+ page: Page<T>;
10
+ next: (() => Promise<LoadedPage<T>>) | null;
11
+ };
12
+ export declare function pagePromise<T>(loadFirst: () => Promise<LoadedPage<T>>): PagePromise<T>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pagePromise = pagePromise;
4
+ function pagePromise(loadFirst) {
5
+ const first = loadFirst();
6
+ const firstPage = first.then((loaded) => loaded.page);
7
+ // A caller that only iterates never awaits firstPage; its rejection still reaches them through first.
8
+ firstPage.catch(() => undefined);
9
+ return Object.assign(firstPage, { [Symbol.asyncIterator]: () => everyItem(first) });
10
+ }
11
+ async function* everyItem(first) {
12
+ let loaded = await first;
13
+ while (loaded !== null) {
14
+ yield* loaded.page.data;
15
+ loaded = loaded.next === null ? null : await loaded.next();
16
+ }
17
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from "react";
2
+ import type { Ovok } from "../ovok";
3
+ export declare const OvokContext: React.Context<Ovok | null>;
4
+ export declare const useOvok: () => Ovok;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- "use client";
3
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
3
  if (k2 === undefined) k2 = k;
5
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -34,29 +33,14 @@ var __importStar = (this && this.__importStar) || (function () {
34
33
  };
35
34
  })();
36
35
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.useSignalsAlert = useSignalsAlert;
38
- exports.useAcknowledgeSignalsAlert = useAcknowledgeSignalsAlert;
36
+ exports.useOvok = exports.OvokContext = void 0;
39
37
  const React = __importStar(require("react"));
40
- const api_hooks_1 = require("./api-hooks");
41
- const notification_invalidation_1 = require("./notification-invalidation");
42
- const index_1 = require("./index");
43
- function useSignalsAlert(id, grain = {}) {
44
- const client = (0, index_1.useClient)();
45
- const episodes = grain.episodes !== false;
46
- const load = React.useCallback((signal) => episodes
47
- ? client.getSignalsAlert(id, { signal })
48
- : client.getSignalsRawAlert(id, { signal }), [client, id, episodes]);
49
- return (0, api_hooks_1.useOvokRequest)(load, id !== undefined);
50
- }
51
- function useAcknowledgeSignalsAlert(grain = {}) {
52
- const episodes = grain.episodes !== false;
53
- return (0, api_hooks_1.useOvokMutation)(async (client, id) => {
54
- const result = episodes
55
- ? await client.acknowledgeSignalsAlert(id)
56
- : await client.acknowledgeSignalsRawAlert(id);
57
- (0, notification_invalidation_1.notifyNotificationChanges)(client, episodes
58
- ? { type: "signals-alert", alert: result }
59
- : { type: "signals-raw-alert", alert: result });
60
- return result;
61
- });
62
- }
38
+ exports.OvokContext = React.createContext(null);
39
+ const useOvok = () => {
40
+ const client = React.useContext(exports.OvokContext);
41
+ if (client === null) {
42
+ throw new Error("useOvok must be used inside an OvokProvider.");
43
+ }
44
+ return client;
45
+ };
46
+ exports.useOvok = useOvok;
@@ -0,0 +1,14 @@
1
+ import * as React from "react";
2
+ import type { Session } from "../auth/session";
3
+ import type { Ovok } from "../ovok";
4
+ import type { OvokQueryState } from "./query-hooks";
5
+ import { useOvok } from "./context";
6
+ export type OvokProviderProps = React.PropsWithChildren<{
7
+ client: Ovok;
8
+ }>;
9
+ export declare const OvokProvider: ({ client, children }: OvokProviderProps) => React.ReactElement;
10
+ export declare const useSession: () => OvokQueryState<Session | null>;
11
+ export declare const useProfile: () => OvokQueryState<Session["profile"] | null>;
12
+ export { useOvokMutation, useOvokQuery, useResource, useSearch, useSubscription } from "./query-hooks";
13
+ export { useOvok };
14
+ export type { OvokMutationState, OvokQueryOptions, OvokQueryState } from "./query-hooks";
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ "use client";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ exports.useOvok = exports.useSubscription = exports.useSearch = exports.useResource = exports.useOvokQuery = exports.useOvokMutation = exports.useProfile = exports.useSession = exports.OvokProvider = void 0;
38
+ const React = __importStar(require("react"));
39
+ const context_1 = require("./context");
40
+ Object.defineProperty(exports, "useOvok", { enumerable: true, get: function () { return context_1.useOvok; } });
41
+ const query_hooks_1 = require("./query-hooks");
42
+ const OvokProvider = ({ client, children }) => (React.createElement(context_1.OvokContext.Provider, { value: client }, children));
43
+ exports.OvokProvider = OvokProvider;
44
+ const useSession = () => {
45
+ const client = (0, context_1.useOvok)();
46
+ const subscribe = React.useCallback((listener) => client.session.onChange(listener), [client]);
47
+ const changedSession = (0, query_hooks_1.useSubscription)(subscribe);
48
+ const state = (0, query_hooks_1.useOvokQuery)((ovok) => ovok.session.current(), { queryKey: ["session"] });
49
+ return changedSession === undefined
50
+ ? state
51
+ : { ...state, data: changedSession, loading: false, isRefreshing: false, isStale: false, error: undefined };
52
+ };
53
+ exports.useSession = useSession;
54
+ const useProfile = () => {
55
+ var _a, _b;
56
+ const session = (0, exports.useSession)();
57
+ return {
58
+ ...session,
59
+ data: session.data === undefined ? undefined : (_b = (_a = session.data) === null || _a === void 0 ? void 0 : _a.profile) !== null && _b !== void 0 ? _b : null,
60
+ };
61
+ };
62
+ exports.useProfile = useProfile;
63
+ var query_hooks_2 = require("./query-hooks");
64
+ Object.defineProperty(exports, "useOvokMutation", { enumerable: true, get: function () { return query_hooks_2.useOvokMutation; } });
65
+ Object.defineProperty(exports, "useOvokQuery", { enumerable: true, get: function () { return query_hooks_2.useOvokQuery; } });
66
+ Object.defineProperty(exports, "useResource", { enumerable: true, get: function () { return query_hooks_2.useResource; } });
67
+ Object.defineProperty(exports, "useSearch", { enumerable: true, get: function () { return query_hooks_2.useSearch; } });
68
+ Object.defineProperty(exports, "useSubscription", { enumerable: true, get: function () { return query_hooks_2.useSubscription; } });
@@ -0,0 +1,31 @@
1
+ import type { QueryParams } from "../http/url";
2
+ import type { Ovok } from "../ovok";
3
+ import type { Page } from "../paging/page";
4
+ import type { ExtractResource, ResourceType } from "@medplum/fhirtypes";
5
+ export type OvokQueryOptions = {
6
+ queryKey: readonly unknown[];
7
+ enabled?: boolean;
8
+ };
9
+ export type OvokQueryState<T> = {
10
+ data: T | undefined;
11
+ loading: boolean;
12
+ isRefreshing: boolean;
13
+ isStale: boolean;
14
+ error: Error | undefined;
15
+ refetch: () => void;
16
+ };
17
+ export type OvokMutationState<TVariables, TResult> = {
18
+ data: TResult | undefined;
19
+ loading: boolean;
20
+ error: Error | undefined;
21
+ mutate: (variables: TVariables) => Promise<TResult>;
22
+ reset: () => void;
23
+ };
24
+ type OvokQuery<T> = (client: Ovok, signal: AbortSignal) => Promise<T>;
25
+ type OvokMutation<TVariables, TResult> = (client: Ovok, variables: TVariables) => Promise<TResult>;
26
+ export declare const useOvokQuery: <T>(query: OvokQuery<T>, options: OvokQueryOptions) => OvokQueryState<T>;
27
+ export declare const useOvokMutation: <TVariables, TResult>(mutation: OvokMutation<TVariables, TResult>) => OvokMutationState<TVariables, TResult>;
28
+ export declare const useResource: <K extends ResourceType>(type: K, id: string | undefined, options?: Pick<OvokQueryOptions, "enabled">) => OvokQueryState<ExtractResource<K>>;
29
+ export declare const useSearch: <K extends ResourceType>(type: K, params?: QueryParams, options?: Pick<OvokQueryOptions, "enabled">) => OvokQueryState<Page<ExtractResource<K>>>;
30
+ export declare const useSubscription: <T>(subscribe: (listener: (value: T) => void) => () => void) => T | undefined;
31
+ export {};
@@ -0,0 +1,160 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useSubscription = exports.useSearch = exports.useResource = exports.useOvokMutation = exports.useOvokQuery = void 0;
37
+ const React = __importStar(require("react"));
38
+ const context_1 = require("./context");
39
+ const useOvokQuery = (query, options) => {
40
+ var _a, _b;
41
+ const client = (0, context_1.useOvok)();
42
+ const key = (_a = JSON.stringify(options.queryKey)) !== null && _a !== void 0 ? _a : "[]";
43
+ const enabled = (_b = options.enabled) !== null && _b !== void 0 ? _b : true;
44
+ const queryRef = React.useRef(query);
45
+ const previousQuery = React.useRef(null);
46
+ const [data, setData] = React.useState();
47
+ const [loading, setLoading] = React.useState(enabled);
48
+ const [error, setError] = React.useState();
49
+ const [revision, setRevision] = React.useState(0);
50
+ queryRef.current = query;
51
+ React.useEffect(() => {
52
+ const previous = previousQuery.current;
53
+ const changed = previous === null || previous.client !== client || previous.key !== key;
54
+ previousQuery.current = { client, key };
55
+ if (changed) {
56
+ setData(undefined);
57
+ }
58
+ if (!enabled) {
59
+ setError(undefined);
60
+ setLoading(false);
61
+ return undefined;
62
+ }
63
+ const controller = new AbortController();
64
+ let disposed = false;
65
+ setLoading(true);
66
+ setError(undefined);
67
+ void Promise.resolve()
68
+ .then(() => queryRef.current(client, controller.signal))
69
+ .then((result) => {
70
+ if (!disposed) {
71
+ setData(result);
72
+ setLoading(false);
73
+ }
74
+ })
75
+ .catch((reason) => {
76
+ if (!disposed) {
77
+ setError(toError(reason));
78
+ setLoading(false);
79
+ }
80
+ });
81
+ return () => {
82
+ disposed = true;
83
+ controller.abort();
84
+ };
85
+ }, [client, enabled, key, revision]);
86
+ const refetch = React.useCallback(() => setRevision((value) => value + 1), []);
87
+ return {
88
+ data,
89
+ loading,
90
+ isRefreshing: data !== undefined && loading,
91
+ isStale: data !== undefined && (loading || error !== undefined),
92
+ error,
93
+ refetch,
94
+ };
95
+ };
96
+ exports.useOvokQuery = useOvokQuery;
97
+ const useOvokMutation = (mutation) => {
98
+ const client = (0, context_1.useOvok)();
99
+ const mutationRef = React.useRef(mutation);
100
+ const pendingCount = React.useRef(0);
101
+ const [data, setData] = React.useState();
102
+ const [loading, setLoading] = React.useState(false);
103
+ const [error, setError] = React.useState();
104
+ mutationRef.current = mutation;
105
+ const mutate = React.useCallback(async (variables) => {
106
+ pendingCount.current += 1;
107
+ setLoading(true);
108
+ setError(undefined);
109
+ try {
110
+ const result = await mutationRef.current(client, variables);
111
+ setData(result);
112
+ return result;
113
+ }
114
+ catch (reason) {
115
+ const mutationError = toError(reason);
116
+ setError(mutationError);
117
+ throw mutationError;
118
+ }
119
+ finally {
120
+ pendingCount.current -= 1;
121
+ setLoading(pendingCount.current > 0);
122
+ }
123
+ }, [client]);
124
+ const reset = React.useCallback(() => {
125
+ setData(undefined);
126
+ setError(undefined);
127
+ }, []);
128
+ return { data, loading, error, mutate, reset };
129
+ };
130
+ exports.useOvokMutation = useOvokMutation;
131
+ const useResource = (type, id, options = {}) => {
132
+ var _a;
133
+ return (0, exports.useOvokQuery)((client, signal) => {
134
+ if (!id) {
135
+ return Promise.reject(new Error("A resource id is required."));
136
+ }
137
+ return client.fhir.read(type, id, { signal });
138
+ }, { queryKey: [type, id], enabled: (_a = options.enabled) !== null && _a !== void 0 ? _a : Boolean(id) });
139
+ };
140
+ exports.useResource = useResource;
141
+ const useSearch = (type, params = {}, options = {}) => (0, exports.useOvokQuery)((client, signal) => client.fhir.search(type, params, { signal }), { queryKey: [type, params], enabled: options.enabled });
142
+ exports.useSearch = useSearch;
143
+ const useSubscription = (subscribe) => {
144
+ const [subscription, setSubscription] = React.useState();
145
+ React.useEffect(() => {
146
+ let active = true;
147
+ const unsubscribe = subscribe((value) => {
148
+ if (active) {
149
+ setSubscription({ subscribe, value });
150
+ }
151
+ });
152
+ return () => {
153
+ active = false;
154
+ unsubscribe();
155
+ };
156
+ }, [subscribe]);
157
+ return (subscription === null || subscription === void 0 ? void 0 : subscription.subscribe) === subscribe ? subscription.value : undefined;
158
+ };
159
+ exports.useSubscription = useSubscription;
160
+ const toError = (reason) => (reason instanceof Error ? reason : new Error(String(reason)));
@@ -0,0 +1,8 @@
1
+ import type { OvokAccount } from "../../../client/platform/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class AccountsResource {
5
+ private readonly http;
6
+ constructor(http: HttpClient);
7
+ list(options?: RequestOptions): Promise<OvokAccount[]>;
8
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountsResource = void 0;
4
+ const ACCOUNTS_PATH = "accounts";
5
+ class AccountsResource {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ list(options) {
10
+ return this.http.get(ACCOUNTS_PATH, options);
11
+ }
12
+ }
13
+ exports.AccountsResource = AccountsResource;
@@ -0,0 +1,8 @@
1
+ import { HttpClient } from "../../http/http-client";
2
+ import { ChatMessagesResource } from "./chat-messages-resource";
3
+ import { ChatSessionsResource } from "./chat-sessions-resource";
4
+ export declare class AiChatResource {
5
+ readonly sessions: ChatSessionsResource;
6
+ readonly messages: ChatMessagesResource;
7
+ constructor(ai: HttpClient);
8
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiChatResource = void 0;
4
+ const chat_messages_resource_1 = require("./chat-messages-resource");
5
+ const chat_sessions_resource_1 = require("./chat-sessions-resource");
6
+ class AiChatResource {
7
+ constructor(ai) {
8
+ this.sessions = new chat_sessions_resource_1.ChatSessionsResource(ai);
9
+ this.messages = new chat_messages_resource_1.ChatMessagesResource(ai);
10
+ }
11
+ }
12
+ exports.AiChatResource = AiChatResource;
@@ -0,0 +1,16 @@
1
+ import type { AIFhirRequest, AIFhirResponse } from "../../../client/ai-fhir/types";
2
+ import type { OvokTranslationRequest, OvokTranslationResponse } from "../../../client/experience/types";
3
+ import { HttpClient } from "../../http/http-client";
4
+ import { RequestOptions } from "../../http/transmit";
5
+ import { AiChatResource } from "./ai-chat-resource";
6
+ export type AiFhirSearchRequest = AIFhirRequest & {
7
+ fhirVersion?: "R4" | "R5";
8
+ };
9
+ export declare class AiResource {
10
+ readonly chat: AiChatResource;
11
+ private readonly ai;
12
+ constructor(http: HttpClient);
13
+ translate(body: OvokTranslationRequest, options?: RequestOptions): Promise<OvokTranslationResponse>;
14
+ /** An LLM plans and runs the FHIR queries, so the answer can be wrong or invented. */
15
+ fhirSearch(body: AiFhirSearchRequest, options?: RequestOptions): Promise<AIFhirResponse>;
16
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AiResource = void 0;
4
+ const ai_chat_resource_1 = require("./ai-chat-resource");
5
+ const AI_PATH = "ai";
6
+ class AiResource {
7
+ constructor(http) {
8
+ this.ai = http.under(AI_PATH);
9
+ this.chat = new ai_chat_resource_1.AiChatResource(this.ai);
10
+ }
11
+ translate(body, options) {
12
+ return this.ai.post("translation", body, options);
13
+ }
14
+ /** An LLM plans and runs the FHIR queries, so the answer can be wrong or invented. */
15
+ fhirSearch(body, options) {
16
+ return this.ai.post("fhir/search", body, options);
17
+ }
18
+ }
19
+ exports.AiResource = AiResource;
@@ -0,0 +1,9 @@
1
+ import type { OvokChatMessage, OvokChatMessageInput, OvokChatMessageQuery, OvokChatMessagesResponse } from "../../../client/experience/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export declare class ChatMessagesResource {
5
+ private readonly ai;
6
+ constructor(ai: HttpClient);
7
+ list(sessionId: string, params?: OvokChatMessageQuery, options?: RequestOptions): Promise<OvokChatMessagesResponse>;
8
+ send(sessionId: string, body: OvokChatMessageInput, options?: RequestOptions): Promise<OvokChatMessage>;
9
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatMessagesResource = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const chat_sessions_resource_1 = require("./chat-sessions-resource");
6
+ const messagesPath = (sessionId) => `${(0, chat_sessions_resource_1.sessionPath)(sessionId)}/message`;
7
+ class ChatMessagesResource {
8
+ constructor(ai) {
9
+ this.ai = ai;
10
+ }
11
+ list(sessionId, params = {}, options) {
12
+ return this.ai.get(`${messagesPath(sessionId)}${(0, query_string_1.toQueryString)(params)}`, options);
13
+ }
14
+ send(sessionId, body, options) {
15
+ return this.ai.post(messagesPath(sessionId), body, options);
16
+ }
17
+ }
18
+ exports.ChatMessagesResource = ChatMessagesResource;
@@ -0,0 +1,14 @@
1
+ import type { OvokChatSession, OvokChatSessionQuery, OvokChatSessionsResponse, OvokCreateChatSession } from "../../../client/experience/types";
2
+ import { HttpClient } from "../../http/http-client";
3
+ import { RequestOptions } from "../../http/transmit";
4
+ export type ChatSessionRetrieveParams = {
5
+ messageCount?: number;
6
+ };
7
+ export declare const sessionPath: (sessionId: string) => string;
8
+ export declare class ChatSessionsResource {
9
+ private readonly ai;
10
+ constructor(ai: HttpClient);
11
+ create(body: OvokCreateChatSession, options?: RequestOptions): Promise<OvokChatSession>;
12
+ list(params?: OvokChatSessionQuery, options?: RequestOptions): Promise<OvokChatSessionsResponse>;
13
+ retrieve(sessionId: string, params?: ChatSessionRetrieveParams, options?: RequestOptions): Promise<OvokChatSession>;
14
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatSessionsResource = exports.sessionPath = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const url_1 = require("../../http/url");
6
+ const SESSION_PATH = "session";
7
+ const sessionPath = (sessionId) => `${SESSION_PATH}/${(0, url_1.pathSegment)(sessionId)}`;
8
+ exports.sessionPath = sessionPath;
9
+ class ChatSessionsResource {
10
+ constructor(ai) {
11
+ this.ai = ai;
12
+ }
13
+ create(body, options) {
14
+ return this.ai.post(SESSION_PATH, body, options);
15
+ }
16
+ list(params = {}, options) {
17
+ return this.ai.get(`${SESSION_PATH}${(0, query_string_1.toQueryString)(params)}`, options);
18
+ }
19
+ retrieve(sessionId, params = {}, options) {
20
+ return this.ai.get(`${(0, exports.sessionPath)(sessionId)}${(0, query_string_1.toQueryString)(params)}`, options);
21
+ }
22
+ }
23
+ exports.ChatSessionsResource = ChatSessionsResource;
@@ -0,0 +1,13 @@
1
+ import type { OvokSession, SessionRevokeOption } from "../../../client/auth/types/Session";
2
+ import { UserSession } from "../../auth/user-session";
3
+ import { HttpClient } from "../../http/http-client";
4
+ import { RequestOptions } from "../../http/transmit";
5
+ /** The account's sessions on the server. */
6
+ export declare class AuthSessionsResource {
7
+ private readonly http;
8
+ private readonly session;
9
+ constructor(http: HttpClient, session: UserSession | null);
10
+ list(options?: RequestOptions): Promise<OvokSession[]>;
11
+ /** Revoking the current session also ends it here. */
12
+ revoke(option: SessionRevokeOption, options?: RequestOptions): Promise<void>;
13
+ }
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthSessionsResource = void 0;
4
+ const url_1 = require("../../http/url");
5
+ const SESSIONS_PATH = "auth/session";
6
+ const CURRENT_SESSION = "current";
7
+ /** The account's sessions on the server. */
8
+ class AuthSessionsResource {
9
+ constructor(http, session) {
10
+ this.http = http;
11
+ this.session = session;
12
+ }
13
+ list(options) {
14
+ return this.http.get(SESSIONS_PATH, options);
15
+ }
16
+ /** Revoking the current session also ends it here. */
17
+ async revoke(option, options) {
18
+ var _a;
19
+ await this.http.delete(`${SESSIONS_PATH}/${(0, url_1.pathSegment)(option)}`, options);
20
+ if (option === CURRENT_SESSION) {
21
+ await ((_a = this.session) === null || _a === void 0 ? void 0 : _a.end());
22
+ }
23
+ }
24
+ }
25
+ exports.AuthSessionsResource = AuthSessionsResource;
@@ -0,0 +1,35 @@
1
+ import type { RegisterBody } from "../../../client/auth/types/RegisterBody";
2
+ import type { RegisterPractitionerBody } from "../../../client/auth/types/RegisterPractitionerBody";
3
+ import type { ClinicianInviteStep } from "../../../client/auth/types/RegisterResponse";
4
+ import { LoginTokens, Session } from "../../auth/session";
5
+ /** The tenant comes from the client's config, as it does for login. */
6
+ export type PatientRegistration = Omit<RegisterBody, "tenantCode">;
7
+ export type PractitionerRegistration = Omit<RegisterPractitionerBody, "tenantCode">;
8
+ export type RegisterResult = {
9
+ status: "signed-in";
10
+ session: Session;
11
+ } | {
12
+ status: "clinician-invite";
13
+ };
14
+ export type RegisterResponse = LoginTokens | ClinicianInviteStep;
15
+ export declare const REGISTER_PATHS: {
16
+ readonly patient: "auth/tenant/Patient/register";
17
+ readonly practitioner: "auth/tenant/Practitioner/register";
18
+ };
19
+ export declare const isClinicianInvite: (response: RegisterResponse) => response is ClinicianInviteStep;
20
+ /** The confirmation is checked here and never sent. */
21
+ export declare function practitionerRegistrationBody(details: PractitionerRegistration, tenantCode: string): {
22
+ email: string;
23
+ password: string;
24
+ name: string;
25
+ surname: string;
26
+ tenantCode: string;
27
+ };
28
+ export declare const patientRegistrationBody: (details: PatientRegistration, tenantCode: string) => {
29
+ continueAsPatientToken: string | undefined;
30
+ email: string;
31
+ password: string;
32
+ name: string;
33
+ surname: string;
34
+ tenantCode: string;
35
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.patientRegistrationBody = exports.isClinicianInvite = exports.REGISTER_PATHS = void 0;
4
+ exports.practitionerRegistrationBody = practitionerRegistrationBody;
5
+ const ovok_errors_1 = require("../../errors/ovok-errors");
6
+ exports.REGISTER_PATHS = {
7
+ patient: "auth/tenant/Patient/register",
8
+ practitioner: "auth/tenant/Practitioner/register",
9
+ };
10
+ const isClinicianInvite = (response) => "nextStep" in response && response.nextStep === "clinician-invite";
11
+ exports.isClinicianInvite = isClinicianInvite;
12
+ /** The confirmation is checked here and never sent. */
13
+ function practitionerRegistrationBody(details, tenantCode) {
14
+ if (details.password !== details.passwordConfirm) {
15
+ throw new ovok_errors_1.OvokValidationError((0, ovok_errors_1.detailsFor)("Password and password confirm do not match."));
16
+ }
17
+ const { email, password, name, surname } = details;
18
+ return { email, password, name, surname, tenantCode };
19
+ }
20
+ const patientRegistrationBody = (details, tenantCode) => ({
21
+ ...practitionerRegistrationBody(details, tenantCode),
22
+ continueAsPatientToken: details.continueAsPatientToken,
23
+ });
24
+ exports.patientRegistrationBody = patientRegistrationBody;
@@ -0,0 +1,8 @@
1
+ import type { AppleLoginBody } from "../../../client/auth/types/AppleLoginBody";
2
+ import type { GoogleLoginBody } from "../../../client/auth/types/GoogleLoginBody";
3
+ export type SocialCredentials = {
4
+ apple: AppleLoginBody;
5
+ google: GoogleLoginBody;
6
+ };
7
+ export type SocialProvider = keyof SocialCredentials;
8
+ export declare const socialLoginPath: (provider: SocialProvider, clientId: string, internalId: string) => string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.socialLoginPath = void 0;
4
+ const query_string_1 = require("../../../client/query-string");
5
+ const url_1 = require("../../http/url");
6
+ const socialLoginPath = (provider, clientId, internalId) => `auth/external/${(0, url_1.pathSegment)(provider)}${(0, query_string_1.toQueryString)({ client: `ClientApplication/${clientId}`, internalId })}`;
7
+ exports.socialLoginPath = socialLoginPath;