@ovok/core 0.2.47

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 (202) hide show
  1. package/README.md +40 -0
  2. package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +14 -0
  3. package/dist/client/ai-fhir/methods/AIFhirResources.js +16 -0
  4. package/dist/client/ai-fhir/methods/index.d.ts +1 -0
  5. package/dist/client/ai-fhir/methods/index.js +17 -0
  6. package/dist/client/ai-fhir/types/AIFhirPlan.d.ts +6 -0
  7. package/dist/client/ai-fhir/types/AIFhirPlan.js +2 -0
  8. package/dist/client/ai-fhir/types/AIFhirPlanRequest.d.ts +5 -0
  9. package/dist/client/ai-fhir/types/AIFhirPlanRequest.js +2 -0
  10. package/dist/client/ai-fhir/types/AIFhirRequest.d.ts +7 -0
  11. package/dist/client/ai-fhir/types/AIFhirRequest.js +2 -0
  12. package/dist/client/ai-fhir/types/AIFhirResponse.d.ts +18 -0
  13. package/dist/client/ai-fhir/types/AIFhirResponse.js +2 -0
  14. package/dist/client/ai-fhir/types/index.d.ts +4 -0
  15. package/dist/client/ai-fhir/types/index.js +20 -0
  16. package/dist/client/auth/methods/appleLogin.d.ts +4 -0
  17. package/dist/client/auth/methods/appleLogin.js +11 -0
  18. package/dist/client/auth/methods/changePassword.d.ts +4 -0
  19. package/dist/client/auth/methods/changePassword.js +6 -0
  20. package/dist/client/auth/methods/googleLogin.d.ts +4 -0
  21. package/dist/client/auth/methods/googleLogin.js +11 -0
  22. package/dist/client/auth/methods/index.d.ts +8 -0
  23. package/dist/client/auth/methods/index.js +24 -0
  24. package/dist/client/auth/methods/login.d.ts +4 -0
  25. package/dist/client/auth/methods/login.js +38 -0
  26. package/dist/client/auth/methods/refetchProfile.d.ts +2 -0
  27. package/dist/client/auth/methods/refetchProfile.js +9 -0
  28. package/dist/client/auth/methods/register.d.ts +4 -0
  29. package/dist/client/auth/methods/register.js +15 -0
  30. package/dist/client/auth/methods/requestDeleteUser.d.ts +11 -0
  31. package/dist/client/auth/methods/requestDeleteUser.js +13 -0
  32. package/dist/client/auth/methods/resetPassword.d.ts +13 -0
  33. package/dist/client/auth/methods/resetPassword.js +19 -0
  34. package/dist/client/auth/types/AppleLoginBody.d.ts +68 -0
  35. package/dist/client/auth/types/AppleLoginBody.js +17 -0
  36. package/dist/client/auth/types/AuthResponse.d.ts +15 -0
  37. package/dist/client/auth/types/AuthResponse.js +2 -0
  38. package/dist/client/auth/types/ChangePasswordBody.d.ts +5 -0
  39. package/dist/client/auth/types/ChangePasswordBody.js +2 -0
  40. package/dist/client/auth/types/GoogleLoginBody.d.ts +26 -0
  41. package/dist/client/auth/types/GoogleLoginBody.js +2 -0
  42. package/dist/client/auth/types/LoginBody.d.ts +26 -0
  43. package/dist/client/auth/types/LoginBody.js +2 -0
  44. package/dist/client/auth/types/RegisterBody.d.ts +8 -0
  45. package/dist/client/auth/types/RegisterBody.js +2 -0
  46. package/dist/client/auth/types/RequestDeleteUserBody.d.ts +11 -0
  47. package/dist/client/auth/types/RequestDeleteUserBody.js +2 -0
  48. package/dist/client/auth/types/RequestDeleteUserResponse.d.ts +12 -0
  49. package/dist/client/auth/types/RequestDeleteUserResponse.js +2 -0
  50. package/dist/client/auth/types/ResetPasswordBody.d.ts +14 -0
  51. package/dist/client/auth/types/ResetPasswordBody.js +2 -0
  52. package/dist/client/auth/types/StartLoginResponse.d.ts +34 -0
  53. package/dist/client/auth/types/StartLoginResponse.js +2 -0
  54. package/dist/client/bot/methods/executeBot.d.ts +10 -0
  55. package/dist/client/bot/methods/executeBot.js +14 -0
  56. package/dist/client/bot/methods/index.d.ts +1 -0
  57. package/dist/client/bot/methods/index.js +17 -0
  58. package/dist/client/chat/ai/methods/createAiSession.d.ts +4 -0
  59. package/dist/client/chat/ai/methods/createAiSession.js +17 -0
  60. package/dist/client/chat/ai/methods/index.d.ts +1 -0
  61. package/dist/client/chat/ai/methods/index.js +17 -0
  62. package/dist/client/chat/ai/types/CreateAiSessionProps.d.ts +51 -0
  63. package/dist/client/chat/ai/types/CreateAiSessionProps.js +2 -0
  64. package/dist/client/chat/ai/types/CreateAiSessionResponse.d.ts +21 -0
  65. package/dist/client/chat/ai/types/CreateAiSessionResponse.js +2 -0
  66. package/dist/client/chat/ai/types/SessionMessagesResponse.d.ts +9 -0
  67. package/dist/client/chat/ai/types/SessionMessagesResponse.js +2 -0
  68. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.d.ts +4 -0
  69. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +40 -0
  70. package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +4 -0
  71. package/dist/client/observation/methods/getLatestObservationsByCodes.js +19 -0
  72. package/dist/client/observation/methods/index.d.ts +2 -0
  73. package/dist/client/observation/methods/index.js +18 -0
  74. package/dist/client/observation/services/base-observation-service.d.ts +22 -0
  75. package/dist/client/observation/services/base-observation-service.js +70 -0
  76. package/dist/client/observation/services/blood-glucose.d.ts +12 -0
  77. package/dist/client/observation/services/blood-glucose.js +36 -0
  78. package/dist/client/observation/services/blood-oxygen.d.ts +14 -0
  79. package/dist/client/observation/services/blood-oxygen.js +57 -0
  80. package/dist/client/observation/services/blood-pressure.d.ts +15 -0
  81. package/dist/client/observation/services/blood-pressure.js +72 -0
  82. package/dist/client/observation/services/body-temperature.d.ts +13 -0
  83. package/dist/client/observation/services/body-temperature.js +36 -0
  84. package/dist/client/observation/services/body-weight.d.ts +13 -0
  85. package/dist/client/observation/services/body-weight.js +36 -0
  86. package/dist/client/observation/services/creator.d.ts +10 -0
  87. package/dist/client/observation/services/creator.js +54 -0
  88. package/dist/client/observation/services/ecg.d.ts +16 -0
  89. package/dist/client/observation/services/ecg.js +110 -0
  90. package/dist/client/observation/services/heart-rate-variability.d.ts +13 -0
  91. package/dist/client/observation/services/heart-rate-variability.js +38 -0
  92. package/dist/client/observation/services/heart-rate.d.ts +13 -0
  93. package/dist/client/observation/services/heart-rate.js +39 -0
  94. package/dist/client/observation/services/index.d.ts +1 -0
  95. package/dist/client/observation/services/index.js +17 -0
  96. package/dist/client/observation/services/respiratory-rate.d.ts +13 -0
  97. package/dist/client/observation/services/respiratory-rate.js +38 -0
  98. package/dist/client/observation/services/resting-heart-rate.d.ts +13 -0
  99. package/dist/client/observation/services/resting-heart-rate.js +38 -0
  100. package/dist/client/observation/services/step-count.d.ts +15 -0
  101. package/dist/client/observation/services/step-count.js +55 -0
  102. package/dist/client/observation/services/uric-acid-service.d.ts +21 -0
  103. package/dist/client/observation/services/uric-acid-service.js +120 -0
  104. package/dist/client/observation/services/vo2-max.d.ts +13 -0
  105. package/dist/client/observation/services/vo2-max.js +38 -0
  106. package/dist/client/observation/services/walking-heart-rate-average.d.ts +12 -0
  107. package/dist/client/observation/services/walking-heart-rate-average.js +38 -0
  108. package/dist/client/observation/types/GetLatestObservationsByCodeParams.d.ts +9 -0
  109. package/dist/client/observation/types/GetLatestObservationsByCodeParams.js +2 -0
  110. package/dist/client/observation/types/IObservationService.d.ts +15 -0
  111. package/dist/client/observation/types/IObservationService.js +2 -0
  112. package/dist/client/observation/types/MeasurementTypeKey.d.ts +20 -0
  113. package/dist/client/observation/types/MeasurementTypeKey.js +24 -0
  114. package/dist/client/observation/types/ObservationCode.d.ts +37 -0
  115. package/dist/client/observation/types/ObservationCode.js +41 -0
  116. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +641 -0
  117. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +45 -0
  118. package/dist/client/observation/types/generate-measurement/Sample.d.ts +32 -0
  119. package/dist/client/observation/types/generate-measurement/Sample.js +2 -0
  120. package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.d.ts +1 -0
  121. package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.js +2 -0
  122. package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +7 -0
  123. package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.js +2 -0
  124. package/dist/client/observation/types/generate-observation-body/ObservationValue.d.ts +14 -0
  125. package/dist/client/observation/types/generate-observation-body/ObservationValue.js +2 -0
  126. package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.d.ts +6 -0
  127. package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.js +2 -0
  128. package/dist/client/observation/types/measurement/BloodPressureMeasurement.d.ts +10 -0
  129. package/dist/client/observation/types/measurement/BloodPressureMeasurement.js +2 -0
  130. package/dist/client/observation/types/measurement/BloodPressureStates.d.ts +7 -0
  131. package/dist/client/observation/types/measurement/BloodPressureStates.js +11 -0
  132. package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.d.ts +6 -0
  133. package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.js +2 -0
  134. package/dist/client/observation/types/measurement/BodyWeightMeasurmement.d.ts +7 -0
  135. package/dist/client/observation/types/measurement/BodyWeightMeasurmement.js +2 -0
  136. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.d.ts +15 -0
  137. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.js +19 -0
  138. package/dist/client/observation/types/measurement/EcgMeasurement.d.ts +13 -0
  139. package/dist/client/observation/types/measurement/EcgMeasurement.js +2 -0
  140. package/dist/client/observation/types/measurement/HeartRateMeasurement.d.ts +6 -0
  141. package/dist/client/observation/types/measurement/HeartRateMeasurement.js +2 -0
  142. package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.d.ts +6 -0
  143. package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.js +2 -0
  144. package/dist/client/observation/types/measurement/Measurement.d.ts +4 -0
  145. package/dist/client/observation/types/measurement/Measurement.js +2 -0
  146. package/dist/client/observation/types/measurement/MeasurementDevice.d.ts +7 -0
  147. package/dist/client/observation/types/measurement/MeasurementDevice.js +2 -0
  148. package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +9 -0
  149. package/dist/client/observation/types/measurement/PulseOximeterMeasurement.js +2 -0
  150. package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.d.ts +6 -0
  151. package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.js +2 -0
  152. package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.d.ts +6 -0
  153. package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.js +2 -0
  154. package/dist/client/observation/types/measurement/SpirometryMeasurement.d.ts +21 -0
  155. package/dist/client/observation/types/measurement/SpirometryMeasurement.js +2 -0
  156. package/dist/client/observation/types/measurement/StepCountMeasurement.d.ts +8 -0
  157. package/dist/client/observation/types/measurement/StepCountMeasurement.js +2 -0
  158. package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +23 -0
  159. package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.js +2 -0
  160. package/dist/client/observation/types/measurement/Vo2MaxMeasurement.d.ts +6 -0
  161. package/dist/client/observation/types/measurement/Vo2MaxMeasurement.js +2 -0
  162. package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.d.ts +6 -0
  163. package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.js +2 -0
  164. package/dist/client/observation/types/measurement/index.d.ts +11 -0
  165. package/dist/client/observation/types/measurement/index.js +27 -0
  166. package/dist/client/observation/types/service/ObservationMetadata.d.ts +8 -0
  167. package/dist/client/observation/types/service/ObservationMetadata.js +2 -0
  168. package/dist/client/observation/utils/getDeviceObject.d.ts +3 -0
  169. package/dist/client/observation/utils/getDeviceObject.js +34 -0
  170. package/dist/client/observation/utils/getObservationValueDisplay.d.ts +15 -0
  171. package/dist/client/observation/utils/getObservationValueDisplay.js +25 -0
  172. package/dist/client/observation/utils/index.d.ts +1 -0
  173. package/dist/client/observation/utils/index.js +17 -0
  174. package/dist/client/ovok-client.d.ts +35 -0
  175. package/dist/client/ovok-client.js +85 -0
  176. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +3 -0
  177. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +28 -0
  178. package/dist/client/questionnaire-response/methods/index.d.ts +1 -0
  179. package/dist/client/questionnaire-response/methods/index.js +17 -0
  180. package/dist/hooks/index.d.ts +7 -0
  181. package/dist/hooks/index.js +58 -0
  182. package/dist/index.d.ts +666 -0
  183. package/dist/index.js +49 -0
  184. package/dist/types/ValidationError.d.ts +6 -0
  185. package/dist/types/ValidationError.js +2 -0
  186. package/dist/types/index.d.ts +17 -0
  187. package/dist/types/index.js +38 -0
  188. package/dist/utils/auth/exchange-code.d.ts +14 -0
  189. package/dist/utils/auth/exchange-code.js +17 -0
  190. package/dist/utils/auth/generate-code-challenge-and-verifier.d.ts +6 -0
  191. package/dist/utils/auth/generate-code-challenge-and-verifier.js +45 -0
  192. package/dist/utils/auth/handle-tenant-code.d.ts +6 -0
  193. package/dist/utils/auth/handle-tenant-code.js +21 -0
  194. package/dist/utils/auth/sha256.d.ts +8 -0
  195. package/dist/utils/auth/sha256.js +300 -0
  196. package/dist/utils/auth/start-login.d.ts +10 -0
  197. package/dist/utils/auth/start-login.js +19 -0
  198. package/dist/utils/index.d.ts +2 -0
  199. package/dist/utils/index.js +18 -0
  200. package/dist/utils/patch/getPatchOperationType.d.ts +2 -0
  201. package/dist/utils/patch/getPatchOperationType.js +16 -0
  202. package/package.json +83 -0
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Ovok Core
2
+
3
+ [![npm version](https://badge.fury.io/js/@actimi%2Fovok-core.svg)](https://badge.fury.io/js/@actimi%2Fovok-core)
4
+ [![Documentation](https://img.shields.io/badge/docs-sdk.ovok.com-blue)](https://sdk.ovok.com/)
5
+
6
+ Core TypeScript SDK for healthcare applications. Provides authentication, AI-FHIR integration, observations, and healthcare data management.
7
+
8
+ ## Features
9
+
10
+ - 🔐 Authentication & user management
11
+ - 🤖 AI-FHIR resources and planning
12
+ - 📊 Healthcare observations and measurements
13
+ - 💬 Chat AI integration
14
+ - 🤖 Bot execution framework
15
+ - 📋 Questionnaire responses
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @actimi/ovok-core
21
+ # or
22
+ yarn add @actimi/ovok-core
23
+ # or
24
+ pnpm add @actimi/ovok-core
25
+ ```
26
+
27
+ ## Quick Start
28
+
29
+ ```typescript
30
+ import { OvokClient } from "@actimi/ovok-core";
31
+
32
+ const client = new OvokClient({
33
+ apiUrl: "your-api-url",
34
+ // configuration
35
+ });
36
+ ```
37
+
38
+ ## Documentation
39
+
40
+ Full documentation and examples available at **[sdk.ovok.com](https://sdk.ovok.com/)**
@@ -0,0 +1,14 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AIFhirRequest } from "../types/AIFhirRequest";
3
+ import { AIFhirResponse } from "../types/AIFhirResponse";
4
+ /**
5
+ * AI FHIR Search uses LLMs for FHIR query planning and execution.
6
+ * After the LLM generates the FHIR query plan, it's executed against the server
7
+ * to generate the results, and then the results are used to create a summary response.
8
+ *
9
+ * @warning The search may fail or return hallucinated results due to the nature of LLMs.
10
+ *
11
+ * @param request - The search request containing the text to search for
12
+ * @returns Promise with the search response containing markdown, plan, and results
13
+ */
14
+ export declare function AIFhirResources(this: OvokClient, request: AIFhirRequest): Promise<AIFhirResponse>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AIFhirResources = AIFhirResources;
4
+ /**
5
+ * AI FHIR Search uses LLMs for FHIR query planning and execution.
6
+ * After the LLM generates the FHIR query plan, it's executed against the server
7
+ * to generate the results, and then the results are used to create a summary response.
8
+ *
9
+ * @warning The search may fail or return hallucinated results due to the nature of LLMs.
10
+ *
11
+ * @param request - The search request containing the text to search for
12
+ * @returns Promise with the search response containing markdown, plan, and results
13
+ */
14
+ async function AIFhirResources(request) {
15
+ return this.post("/ai/fhir/search", request);
16
+ }
@@ -0,0 +1 @@
1
+ export * from "./AIFhirResources";
@@ -0,0 +1,17 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AIFhirResources"), exports);
@@ -0,0 +1,6 @@
1
+ import { AIFhirPlanRequest } from "./AIFhirPlanRequest";
2
+ export interface AIFhirPlan {
3
+ child?: AIFhirPlan;
4
+ requests: AIFhirPlanRequest[];
5
+ visibleResults?: string[];
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export interface AIFhirPlanRequest {
2
+ identifier: string;
3
+ query: string;
4
+ resourceType: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export interface AIFhirRequest {
2
+ /**
3
+ * The text to search for.
4
+ * @example "What is the blood pressure of John Doe?"
5
+ */
6
+ text: string;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,18 @@
1
+ import { AIFhirPlan } from "./AIFhirPlan";
2
+ export interface AIFhirResponse {
3
+ /**
4
+ * Markdown formatted response summarizing the results
5
+ */
6
+ markdown: string;
7
+ /**
8
+ * The FHIR query plan generated by the LLM
9
+ */
10
+ plan: AIFhirPlan;
11
+ /**
12
+ * Results of the FHIR queries executed based on the plan
13
+ * Key is the identifier from the request, value is array of FHIR resources
14
+ */
15
+ results: Record<string, Array<{
16
+ resource: unknown;
17
+ }>>;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export * from "./AIFhirRequest";
2
+ export * from "./AIFhirResponse";
3
+ export * from "./AIFhirPlan";
4
+ export * from "./AIFhirPlanRequest";
@@ -0,0 +1,20 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./AIFhirRequest"), exports);
18
+ __exportStar(require("./AIFhirResponse"), exports);
19
+ __exportStar(require("./AIFhirPlan"), exports);
20
+ __exportStar(require("./AIFhirPlanRequest"), exports);
@@ -0,0 +1,4 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AppleLoginBody } from "../types/AppleLoginBody";
3
+ import { AuthResponse } from "../types/AuthResponse";
4
+ export declare function appleLogin(this: OvokClient, body: AppleLoginBody): Promise<AuthResponse>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appleLogin = appleLogin;
4
+ async function appleLogin(body) {
5
+ const { internalId, ...rest } = body;
6
+ const queryParams = new URLSearchParams({
7
+ client: `ClientApplication/${this.socialLoginClientId}`,
8
+ internalId,
9
+ });
10
+ return this.post(`auth/external/apple?${queryParams.toString()}`, rest, "application/json");
11
+ }
@@ -0,0 +1,4 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AuthResponse } from "../types/AuthResponse";
3
+ import { ChangePasswordBody } from "../types/ChangePasswordBody";
4
+ export declare function changePassword(this: OvokClient, body: ChangePasswordBody): Promise<AuthResponse>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.changePassword = changePassword;
4
+ async function changePassword(body) {
5
+ return this.post("auth/change-password", body);
6
+ }
@@ -0,0 +1,4 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AuthResponse } from "../types/AuthResponse";
3
+ import { GoogleLoginBody } from "../types/GoogleLoginBody";
4
+ export declare function googleLogin(this: OvokClient, body: GoogleLoginBody): Promise<AuthResponse>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.googleLogin = googleLogin;
4
+ async function googleLogin(body) {
5
+ const { internalId, ...rest } = body;
6
+ const queryParams = new URLSearchParams({
7
+ client: `ClientApplication/${this.socialLoginClientId}`,
8
+ internalId,
9
+ });
10
+ return this.post(`auth/external/google?${queryParams.toString()}`, rest, "application/json");
11
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./login";
2
+ export * from "./register";
3
+ export * from "./refetchProfile";
4
+ export * from "./changePassword";
5
+ export * from "./requestDeleteUser";
6
+ export * from "./googleLogin";
7
+ export * from "./appleLogin";
8
+ export * from "./resetPassword";
@@ -0,0 +1,24 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./login"), exports);
18
+ __exportStar(require("./register"), exports);
19
+ __exportStar(require("./refetchProfile"), exports);
20
+ __exportStar(require("./changePassword"), exports);
21
+ __exportStar(require("./requestDeleteUser"), exports);
22
+ __exportStar(require("./googleLogin"), exports);
23
+ __exportStar(require("./appleLogin"), exports);
24
+ __exportStar(require("./resetPassword"), exports);
@@ -0,0 +1,4 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AuthResponse } from "../types/AuthResponse";
3
+ import { LoginBody } from "../types/LoginBody";
4
+ export declare function login(this: OvokClient, body: LoginBody): Promise<AuthResponse>;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.login = login;
4
+ const exchange_code_1 = require("../../../utils/auth/exchange-code");
5
+ const generate_code_challenge_and_verifier_1 = require("../../../utils/auth/generate-code-challenge-and-verifier");
6
+ const handle_tenant_code_1 = require("../../../utils/auth/handle-tenant-code");
7
+ const start_login_1 = require("../../../utils/auth/start-login");
8
+ async function login(body) {
9
+ const { codeVerifier, codeChallenge } = (0, generate_code_challenge_and_verifier_1.generateCodeChallengeAndVerifier)();
10
+ const startResponse = await (0, start_login_1.startLogin)({
11
+ client: this,
12
+ body,
13
+ codeChallenge,
14
+ });
15
+ const tenantCode = (0, handle_tenant_code_1.handleTenantCode)({
16
+ profiles: startResponse.profiles,
17
+ tenantCode: body.tenantCode,
18
+ type: body.type,
19
+ });
20
+ if (!tenantCode) {
21
+ throw new Error("No tenant code found");
22
+ }
23
+ const exchangeCodeProps = body.type === "Practitioner"
24
+ ? {
25
+ client: this,
26
+ type: "Practitioner",
27
+ sessionCode: startResponse.sessionCode,
28
+ codeVerifier,
29
+ tenantCode,
30
+ }
31
+ : {
32
+ client: this,
33
+ type: "Patient",
34
+ sessionCode: startResponse.sessionCode,
35
+ codeVerifier,
36
+ };
37
+ return (0, exchange_code_1.exchangeCode)(exchangeCodeProps);
38
+ }
@@ -0,0 +1,2 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ export declare function refetchProfile(this: OvokClient): Promise<any>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refetchProfile = refetchProfile;
4
+ async function refetchProfile() {
5
+ // TODO: find a better way to do this.
6
+ // Right now this function is private and I have to call this to refresh profile after update it
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ return this.refreshProfile();
9
+ }
@@ -0,0 +1,4 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { AuthResponse } from "../types/AuthResponse";
3
+ import { RegisterBody } from "../types/RegisterBody";
4
+ export declare function register(this: OvokClient, body: RegisterBody): Promise<AuthResponse>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.register = register;
4
+ async function register(body) {
5
+ if (body.password !== body.passwordConfirm) {
6
+ throw new Error("Password and password confirm do not match");
7
+ }
8
+ return this.post("auth/tenant/Patient/register", {
9
+ email: body.email,
10
+ password: body.password,
11
+ name: body.name,
12
+ surname: body.surname,
13
+ tenantCode: body.tenantCode,
14
+ }, "application/json");
15
+ }
@@ -0,0 +1,11 @@
1
+ import { OvokClient } from "../../ovok-client";
2
+ import { RequestDeleteUserBody } from "../types/RequestDeleteUserBody";
3
+ import { RequestDeleteUserResponse } from "../types/RequestDeleteUserResponse";
4
+ /**
5
+ * Schedules deletion of user account
6
+ * @param body - Configuration for user deletion
7
+ * @param {number} body.daysUntilDeletion - After how many days the user should be deleted
8
+ * @param {boolean} body.shouldPurgeAllMedicalData - If true, deletes all user's medical data
9
+ * @returns {Promise<RequestDeleteUserResponse>} Response containing scheduled deletion status and user information
10
+ */
11
+ export declare function requestDeleteUser(this: OvokClient, body: RequestDeleteUserBody): Promise<RequestDeleteUserResponse>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requestDeleteUser = requestDeleteUser;
4
+ /**
5
+ * Schedules deletion of user account
6
+ * @param body - Configuration for user deletion
7
+ * @param {number} body.daysUntilDeletion - After how many days the user should be deleted
8
+ * @param {boolean} body.shouldPurgeAllMedicalData - If true, deletes all user's medical data
9
+ * @returns {Promise<RequestDeleteUserResponse>} Response containing scheduled deletion status and user information
10
+ */
11
+ async function requestDeleteUser(body) {
12
+ return this.delete(`auth/delete?days=${body.days}&wipe=${body.wipe}`);
13
+ }
@@ -0,0 +1,13 @@
1
+ import { OperationOutcome } from "@medplum/fhirtypes";
2
+ import { OvokClient } from "../../ovok-client";
3
+ import { ResetPasswordBody } from "../types/ResetPasswordBody";
4
+ /**
5
+ * Resets a user's password by sending a reset password email
6
+ * Implementation based on https://ovok-internal.readme.io/reference/authresetpasswordcontroller_resetpassword_v2
7
+ *
8
+ * @param this OvokClient instance
9
+ * @param body Reset password request body containing email
10
+ * @returns Promise with the OperationOutcome
11
+ * @throws Reset password error response
12
+ */
13
+ export declare function resetPassword(this: OvokClient, body: ResetPasswordBody): Promise<OperationOutcome>;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resetPassword = resetPassword;
4
+ /**
5
+ * Resets a user's password by sending a reset password email
6
+ * Implementation based on https://ovok-internal.readme.io/reference/authresetpasswordcontroller_resetpassword_v2
7
+ *
8
+ * @param this OvokClient instance
9
+ * @param body Reset password request body containing email
10
+ * @returns Promise with the OperationOutcome
11
+ * @throws Reset password error response
12
+ */
13
+ async function resetPassword(body) {
14
+ var _a;
15
+ return this.post("v2/auth/reset-password", {
16
+ ...body,
17
+ clientId: (_a = body.clientId) !== null && _a !== void 0 ? _a : this.socialLoginClientId,
18
+ }, "application/json");
19
+ }
@@ -0,0 +1,68 @@
1
+ export interface AppleLoginBody {
2
+ /**
3
+ * The internal ID of the extension with url "https://api.ovok.com/StructureDefinition/external-auth-internal-id"
4
+ */
5
+ internalId: string;
6
+ /**
7
+ * A JSON Web Token (JWT) that securely communicates information about the user to your app.
8
+ */
9
+ identityToken: string;
10
+ /**
11
+ * An identifier associated with the authenticated user. You can use this to check if the user is
12
+ * still authenticated later. This is stable and can be shared across apps released under the same
13
+ * development team. The same user will have a different identifier for apps released by other
14
+ * developers.
15
+ */
16
+ user: string;
17
+ /**
18
+ * An arbitrary string that your app provided as `state` in the request that generated the
19
+ * credential. Used to verify that the response was from the request you made. Can be used to
20
+ * avoid replay attacks. If you did not provide `state` when making the sign-in request, this field
21
+ * will be `null`.
22
+ */
23
+ state: string | null;
24
+ /**
25
+ * The user's name. May be `null` or contain `null` values if you didn't request the `FULL_NAME`
26
+ * scope, if the user denied access, or if this is not the first time the user has signed into
27
+ * your app.
28
+ */
29
+ fullName: {
30
+ namePrefix: string | null;
31
+ givenName: string | null;
32
+ middleName: string | null;
33
+ familyName: string | null;
34
+ nameSuffix: string | null;
35
+ nickname: string | null;
36
+ } | null;
37
+ /**
38
+ * The user's email address. Might not be present if you didn't request the `EMAIL` scope. May
39
+ * also be null if this is not the first time the user has signed into your app. If the user chose
40
+ * to withhold their email address, this field will instead contain an obscured email address with
41
+ * an Apple domain.
42
+ */
43
+ email: string;
44
+ /**
45
+ * A value that indicates whether the user appears to the system to be a real person.
46
+ */
47
+ realUserStatus: AppleAuthenticationUserDetectionStatus;
48
+ /**
49
+ * A short-lived session token used by your app for proof of authorization when interacting with
50
+ * the app's server counterpart. Unlike `user`, this is ephemeral and will change each session.
51
+ */
52
+ authorizationCode: string | null;
53
+ }
54
+ declare enum AppleAuthenticationUserDetectionStatus {
55
+ /**
56
+ * The system does not support this determination and there is no data.
57
+ */
58
+ UNSUPPORTED = 0,
59
+ /**
60
+ * The system has not determined whether the user might be a real person.
61
+ */
62
+ UNKNOWN = 1,
63
+ /**
64
+ * The user appears to be a real person.
65
+ */
66
+ LIKELY_REAL = 2
67
+ }
68
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var AppleAuthenticationUserDetectionStatus;
4
+ (function (AppleAuthenticationUserDetectionStatus) {
5
+ /**
6
+ * The system does not support this determination and there is no data.
7
+ */
8
+ AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNSUPPORTED"] = 0] = "UNSUPPORTED";
9
+ /**
10
+ * The system has not determined whether the user might be a real person.
11
+ */
12
+ AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNKNOWN"] = 1] = "UNKNOWN";
13
+ /**
14
+ * The user appears to be a real person.
15
+ */
16
+ AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["LIKELY_REAL"] = 2] = "LIKELY_REAL";
17
+ })(AppleAuthenticationUserDetectionStatus || (AppleAuthenticationUserDetectionStatus = {}));
@@ -0,0 +1,15 @@
1
+ import { ProfileResource } from "@medplum/core";
2
+ import { Project, Reference } from "@medplum/fhirtypes";
3
+ export type AuthResponse = {
4
+ accessToken: string;
5
+ refreshToken: string;
6
+ expiresIn: number;
7
+ profile: {
8
+ reference: Reference<ProfileResource>;
9
+ display: string;
10
+ };
11
+ project: {
12
+ reference: Reference<Project>;
13
+ display: string;
14
+ };
15
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export interface ChangePasswordBody {
2
+ oldPassword: string;
3
+ newPassword: string;
4
+ confirmPassword: string;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ export interface GoogleLoginBody {
2
+ /**
3
+ * The internal ID of the extension with url "https://api.ovok.com/StructureDefinition/external-auth-internal-id"
4
+ */
5
+ internalId: string;
6
+ /**
7
+ * The ID token obtained from Google OAuth
8
+ */
9
+ idToken: string;
10
+ /**
11
+ * The access token obtained from Google OAuth
12
+ */
13
+ access_token?: string;
14
+ /**
15
+ * Token expiration time in seconds
16
+ */
17
+ expires_in?: number;
18
+ /**
19
+ * OAuth scope (e.g. "openid")
20
+ */
21
+ scope?: string;
22
+ /**
23
+ * Type of token (e.g. "bearer")
24
+ */
25
+ token_type?: string;
26
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,26 @@
1
+ export type LoginBody = {
2
+ /**
3
+ * The email address of the patient
4
+ */
5
+ email: string;
6
+ /**
7
+ * The password of the patient
8
+ */
9
+ password: string;
10
+ /**
11
+ * The type of user to login
12
+ */
13
+ type: "Patient" | "Practitioner";
14
+ } & ({
15
+ type: "Patient";
16
+ /**
17
+ * The tenant code to login to. This is required for patient login.
18
+ */
19
+ tenantCode: string;
20
+ } | {
21
+ type: "Practitioner";
22
+ /**
23
+ * The tenant code to login to. This is optional for practitioner login. If not provided, the first tenant code will be used.
24
+ */
25
+ tenantCode?: string;
26
+ });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface RegisterBody {
2
+ email: string;
3
+ password: string;
4
+ passwordConfirm: string;
5
+ name: string;
6
+ surname: string;
7
+ tenantCode: string;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ export interface RequestDeleteUserBody {
2
+ /**
3
+ * @type {number} Between 1 and 30
4
+ * @description After how many days the user should be deleted.
5
+ */
6
+ days: number;
7
+ /**
8
+ * @description Deletes all medical data related to the user. If true, all medical data of the user will be deleted at the time of deletion. By default, this is false.
9
+ */
10
+ wipe: boolean;
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ export interface RequestDeleteUserResponse {
2
+ scheduled: string;
3
+ user: {
4
+ resourceType: string;
5
+ id: string;
6
+ firstName: string;
7
+ lastName: string;
8
+ email: string;
9
+ project: Record<string, unknown>;
10
+ meta: Record<string, unknown>;
11
+ };
12
+ }