@ovok/core 0.4.36 → 0.4.38

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 (127) hide show
  1. package/dist/client/auth/account-storage.d.ts +1 -0
  2. package/dist/client/auth/account-storage.js +2 -1
  3. package/dist/{utils → client}/auth/exchange-code.d.ts +1 -1
  4. package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.js +5 -17
  5. package/dist/{utils → client}/auth/handle-tenant-code.d.ts +1 -1
  6. package/dist/{utils → client}/auth/handle-tenant-code.js +1 -1
  7. package/dist/client/auth/methods/appleLogin.js +2 -6
  8. package/dist/client/auth/methods/changePassword.js +2 -1
  9. package/dist/client/auth/methods/getSessions.js +2 -1
  10. package/dist/client/auth/methods/googleLogin.js +2 -6
  11. package/dist/client/auth/methods/login.js +26 -44
  12. package/dist/client/auth/methods/logout.js +2 -1
  13. package/dist/client/auth/methods/requestDeleteUser.js +5 -4
  14. package/dist/client/auth/methods/revokeSessions.js +2 -1
  15. package/dist/client/auth/methods/socialLogin.d.ts +7 -0
  16. package/dist/client/auth/methods/socialLogin.js +11 -0
  17. package/dist/client/auth/session-fetch.d.ts +35 -0
  18. package/dist/client/auth/session-fetch.js +206 -0
  19. package/dist/client/auth/session-http.d.ts +11 -0
  20. package/dist/client/auth/session-http.js +169 -0
  21. package/dist/client/auth/sha256.d.ts +2 -0
  22. package/dist/client/auth/sha256.js +65 -0
  23. package/dist/{utils → client}/auth/start-login.d.ts +2 -2
  24. package/dist/client/change-history/methods.js +2 -1
  25. package/dist/client/cms/methods.js +16 -28
  26. package/dist/client/consent/methods.js +3 -2
  27. package/dist/client/email/methods.js +2 -1
  28. package/dist/client/errors/ovok-error-utils.d.ts +6 -0
  29. package/dist/client/errors/ovok-error-utils.js +10 -1
  30. package/dist/client/errors/ovok-error.js +6 -13
  31. package/dist/client/errors/rate-limit-error.js +2 -6
  32. package/dist/client/experience/methods.js +28 -37
  33. package/dist/client/invites/methods.js +8 -12
  34. package/dist/client/notifications/methods.js +5 -5
  35. package/dist/client/observation/fhir-systems.d.ts +4 -0
  36. package/dist/client/observation/fhir-systems.js +7 -0
  37. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +23 -29
  38. package/dist/client/observation/methods/getLatestObservationsByCodes.js +6 -9
  39. package/dist/client/observation/methods/observationsToMeasurements.js +44 -91
  40. package/dist/client/observation/services/base-observation-service.js +4 -3
  41. package/dist/client/observation/services/blood-pressure.js +1 -4
  42. package/dist/client/observation/services/{baby-sleep.d.ts → component-observation-services.d.ts} +18 -13
  43. package/dist/client/observation/services/component-observation-services.js +69 -0
  44. package/dist/client/observation/services/creator.d.ts +1 -2
  45. package/dist/client/observation/services/creator.js +15 -33
  46. package/dist/client/observation/services/ecg-observation-fragments.js +5 -6
  47. package/dist/client/observation/services/ecg.js +3 -2
  48. package/dist/client/observation/services/lipid-panel.js +8 -12
  49. package/dist/client/observation/services/measurement-time.d.ts +4 -0
  50. package/dist/client/observation/services/measurement-time.js +6 -0
  51. package/dist/client/observation/services/single-value-services.d.ts +36 -0
  52. package/dist/client/observation/services/single-value-services.js +100 -0
  53. package/dist/client/observation/services/uric-acid-service.js +6 -7
  54. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +2 -458
  55. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +0 -6
  56. package/dist/client/offline/offline-measurement-queue.js +31 -28
  57. package/dist/client/ovok-client.d.ts +7 -15
  58. package/dist/client/ovok-client.js +54 -398
  59. package/dist/client/patient/methods.js +27 -36
  60. package/dist/client/patient-sharing/methods.js +4 -4
  61. package/dist/client/platform/methods.js +21 -30
  62. package/dist/client/platform/types.d.ts +3 -6
  63. package/dist/client/query-string.d.ts +3 -0
  64. package/dist/client/query-string.js +15 -0
  65. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +2 -1
  66. package/dist/client/questionnaire-response/methods/extractQuestionnaireObservations.js +1 -2
  67. package/dist/client/questionnaire-response/methods/populateQuestionnaire.js +1 -2
  68. package/dist/client/questionnaire-response/methods/submitQuestionnaireResponse.js +2 -1
  69. package/dist/client/request-options.d.ts +2 -0
  70. package/dist/client/request-options.js +6 -0
  71. package/dist/client/signals/errors.js +2 -6
  72. package/dist/client/signals/methods.js +22 -22
  73. package/dist/client/slim/live-read.d.ts +4 -0
  74. package/dist/client/slim/live-read.js +87 -0
  75. package/dist/client/slim/methods.d.ts +3 -0
  76. package/dist/client/slim/methods.js +73 -166
  77. package/dist/client/storage.js +3 -2
  78. package/dist/conformance/capability-requirements.js +1 -1
  79. package/dist/conformance/capability.js +8 -7
  80. package/dist/hooks/account-hooks.js +6 -68
  81. package/dist/hooks/api-hooks.d.ts +10 -6
  82. package/dist/hooks/api-hooks.js +29 -88
  83. package/dist/hooks/cms-hooks.js +8 -13
  84. package/dist/hooks/email-hooks.js +1 -40
  85. package/dist/hooks/experience-hooks.js +4 -60
  86. package/dist/hooks/index.d.ts +2 -2
  87. package/dist/hooks/index.js +4 -4
  88. package/dist/hooks/invites-hooks.js +0 -1
  89. package/dist/hooks/notification-hooks.d.ts +4 -1
  90. package/dist/hooks/notification-hooks.js +29 -86
  91. package/dist/hooks/notification-invalidation.d.ts +6 -0
  92. package/dist/hooks/notification-invalidation.js +52 -0
  93. package/dist/hooks/notification-note-hooks.js +13 -28
  94. package/dist/hooks/observation-hooks.js +2 -4
  95. package/dist/hooks/patient-hooks.js +13 -113
  96. package/dist/hooks/patient-sharing-hooks.js +2 -7
  97. package/dist/hooks/platform-hooks.js +3 -51
  98. package/dist/hooks/poll-hooks.js +10 -8
  99. package/dist/hooks/signals-alert-hooks.js +4 -6
  100. package/dist/hooks/signals-hooks.js +2 -45
  101. package/package.json +1 -1
  102. package/dist/client/observation/services/baby-sleep.js +0 -69
  103. package/dist/client/observation/services/blood-glucose.d.ts +0 -12
  104. package/dist/client/observation/services/blood-glucose.js +0 -36
  105. package/dist/client/observation/services/body-temperature.d.ts +0 -13
  106. package/dist/client/observation/services/body-temperature.js +0 -36
  107. package/dist/client/observation/services/body-weight.d.ts +0 -13
  108. package/dist/client/observation/services/body-weight.js +0 -36
  109. package/dist/client/observation/services/heart-rate-variability.d.ts +0 -13
  110. package/dist/client/observation/services/heart-rate-variability.js +0 -38
  111. package/dist/client/observation/services/heart-rate.d.ts +0 -13
  112. package/dist/client/observation/services/heart-rate.js +0 -39
  113. package/dist/client/observation/services/respiratory-rate.d.ts +0 -13
  114. package/dist/client/observation/services/respiratory-rate.js +0 -38
  115. package/dist/client/observation/services/respiratory-therapy.d.ts +0 -28
  116. package/dist/client/observation/services/respiratory-therapy.js +0 -69
  117. package/dist/client/observation/services/resting-heart-rate.d.ts +0 -13
  118. package/dist/client/observation/services/resting-heart-rate.js +0 -38
  119. package/dist/client/observation/services/vo2-max.d.ts +0 -13
  120. package/dist/client/observation/services/vo2-max.js +0 -38
  121. package/dist/client/observation/services/walking-heart-rate-average.d.ts +0 -12
  122. package/dist/client/observation/services/walking-heart-rate-average.js +0 -38
  123. package/dist/utils/auth/sha256.d.ts +0 -8
  124. package/dist/utils/auth/sha256.js +0 -300
  125. /package/dist/{utils → client}/auth/exchange-code.js +0 -0
  126. /package/dist/{utils → client}/auth/generate-code-challenge-and-verifier.d.ts +0 -0
  127. /package/dist/{utils → client}/auth/start-login.js +0 -0
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refreshBackoffMs = exports.fetchWithTimeout = exports.isNetworkError = exports.refreshResponseError = exports.refreshUnavailableError = exports.isTemporaryRefreshFailure = exports.waitForRetry = exports.withHttpErrorMetadata = exports.retryAfterMs = void 0;
4
+ const ovok_error_utils_1 = require("../errors/ovok-error-utils");
5
+ const retryAfterMs = (response) => {
6
+ var _a, _b;
7
+ const value = (_b = (_a = response.headers) === null || _a === void 0 ? void 0 : _a.get) === null || _b === void 0 ? void 0 : _b.call(_a, "Retry-After");
8
+ if (!value) {
9
+ return undefined;
10
+ }
11
+ const seconds = Number(value);
12
+ if (Number.isFinite(seconds)) {
13
+ return Math.max(0, seconds * 1000);
14
+ }
15
+ const date = Date.parse(value);
16
+ return Number.isFinite(date) ? Math.max(0, date - Date.now()) : undefined;
17
+ };
18
+ exports.retryAfterMs = retryAfterMs;
19
+ const timeoutError = () => (0, ovok_error_utils_1.namedError)("TimeoutError", "The request timed out.");
20
+ const withHttpErrorMetadata = async (response) => {
21
+ var _a, _b;
22
+ if (response.ok || typeof response.clone !== "function") {
23
+ return response;
24
+ }
25
+ let bodyText = "";
26
+ let body;
27
+ try {
28
+ bodyText = await response.clone().text();
29
+ body = JSON.parse(bodyText);
30
+ }
31
+ catch (_c) {
32
+ body = undefined;
33
+ }
34
+ const outcome = body && typeof body === "object" && body.resourceType === "OperationOutcome"
35
+ ? body
36
+ : undefined;
37
+ const envelope = body && typeof body === "object" ? body : undefined;
38
+ const nestedError = (envelope === null || envelope === void 0 ? void 0 : envelope.error) && typeof envelope.error === "object"
39
+ ? envelope.error
40
+ : undefined;
41
+ const safeResponse = envelope
42
+ ? Object.fromEntries(Object.entries(envelope).filter(([key]) => ["code", "error", "message", "requestId", "retryAfterSec", "status", "statusCode", "errors", "missing"].includes(key)))
43
+ : { message: typeof body === "string" ? body : response.statusText };
44
+ const status = response.status;
45
+ const retryAfter = (_a = (0, exports.retryAfterMs)(response)) !== null && _a !== void 0 ? _a : (typeof (envelope === null || envelope === void 0 ? void 0 : envelope.retryAfterSec) === "number" ? envelope.retryAfterSec * 1000 : undefined);
46
+ const requestId = (_b = response.headers.get("x-request-id")) !== null && _b !== void 0 ? _b : (typeof (envelope === null || envelope === void 0 ? void 0 : envelope.requestId) === "string" ? envelope.requestId : undefined);
47
+ const message = typeof (envelope === null || envelope === void 0 ? void 0 : envelope.message) === "string"
48
+ ? envelope.message
49
+ : typeof (nestedError === null || nestedError === void 0 ? void 0 : nestedError.message) === "string"
50
+ ? nestedError.message
51
+ : response.statusText || `HTTP ${status}`;
52
+ const extensions = [];
53
+ const addMetadata = (url, value, kind) => {
54
+ if (value !== undefined) {
55
+ extensions.push({ url, [`value${kind}`]: value });
56
+ }
57
+ };
58
+ addMetadata("status", status, "Integer");
59
+ addMetadata("requestId", requestId, "String");
60
+ addMetadata("retryAfterMs", retryAfter, "Integer");
61
+ if (!outcome) {
62
+ extensions.push({ url: "response", valueString: JSON.stringify(safeResponse) });
63
+ }
64
+ const enrichedOutcome = outcome !== null && outcome !== void 0 ? outcome : {
65
+ resourceType: "OperationOutcome",
66
+ id: "ovok-http-error",
67
+ issue: [{
68
+ severity: "error",
69
+ code: status === 429 ? "throttled" : "exception",
70
+ details: { text: bodyText || message },
71
+ }],
72
+ };
73
+ const existingExtensions = Array.isArray(enrichedOutcome.extension)
74
+ ? enrichedOutcome.extension
75
+ : [];
76
+ enrichedOutcome.extension = [
77
+ ...existingExtensions,
78
+ { url: ovok_error_utils_1.OVOK_HTTP_ERROR_EXTENSION_URL, extension: extensions },
79
+ ];
80
+ const headers = new Headers(response.headers);
81
+ headers.delete("content-length");
82
+ headers.set("content-type", "application/fhir+json");
83
+ return new Response(JSON.stringify(enrichedOutcome), {
84
+ status,
85
+ statusText: response.statusText,
86
+ headers,
87
+ });
88
+ };
89
+ exports.withHttpErrorMetadata = withHttpErrorMetadata;
90
+ const waitForRetry = (milliseconds, signal) => new Promise((resolve, reject) => {
91
+ var _a;
92
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
93
+ reject((_a = signal.reason) !== null && _a !== void 0 ? _a : (0, ovok_error_utils_1.namedError)("AbortError", "Token refresh aborted"));
94
+ return;
95
+ }
96
+ const timer = setTimeout(() => {
97
+ signal === null || signal === void 0 ? void 0 : signal.removeEventListener("abort", abort);
98
+ resolve();
99
+ }, milliseconds);
100
+ const abort = () => {
101
+ var _a;
102
+ clearTimeout(timer);
103
+ reject((_a = signal === null || signal === void 0 ? void 0 : signal.reason) !== null && _a !== void 0 ? _a : (0, ovok_error_utils_1.namedError)("AbortError", "Token refresh aborted"));
104
+ };
105
+ signal === null || signal === void 0 ? void 0 : signal.addEventListener("abort", abort, { once: true });
106
+ });
107
+ exports.waitForRetry = waitForRetry;
108
+ const isTemporaryRefreshFailure = (status) => status === 429 || (status >= 500 && status <= 599);
109
+ exports.isTemporaryRefreshFailure = isTemporaryRefreshFailure;
110
+ const refreshUnavailableError = (response) => {
111
+ return Object.assign((0, ovok_error_utils_1.namedError)("NetworkError", "Token refresh is temporarily unavailable"), { cause: response });
112
+ };
113
+ exports.refreshUnavailableError = refreshUnavailableError;
114
+ const refreshResponseError = (response) => {
115
+ return Object.assign((0, ovok_error_utils_1.namedError)("TokenRefreshError", `Token refresh returned HTTP ${response.status}`), {
116
+ status: response.status,
117
+ cause: response,
118
+ });
119
+ };
120
+ exports.refreshResponseError = refreshResponseError;
121
+ const isNetworkError = (error) => {
122
+ if (!(error instanceof Error)) {
123
+ return false;
124
+ }
125
+ if (error.name === "NetworkError" ||
126
+ error.name === "UnknownHostException" ||
127
+ /network request failed|failed to fetch|load failed|unknownhostexception|econn|enotfound/i.test(error.message)) {
128
+ return true;
129
+ }
130
+ return (0, exports.isNetworkError)(error.cause);
131
+ };
132
+ exports.isNetworkError = isNetworkError;
133
+ /** Fetches with an upper time bound, still honouring the caller's own abort signal. */
134
+ const fetchWithTimeout = async (fetchImplementation, url, options, requestTimeoutMs) => {
135
+ if (requestTimeoutMs === undefined) {
136
+ return fetchImplementation(url, options);
137
+ }
138
+ const controller = new AbortController();
139
+ const callerSignal = options === null || options === void 0 ? void 0 : options.signal;
140
+ let timedOut = false;
141
+ const abortFromCaller = () => controller.abort(callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.reason);
142
+ const timeout = setTimeout(() => {
143
+ timedOut = true;
144
+ controller.abort(timeoutError());
145
+ }, requestTimeoutMs);
146
+ if (callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.aborted) {
147
+ abortFromCaller();
148
+ }
149
+ else {
150
+ callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.addEventListener("abort", abortFromCaller, { once: true });
151
+ }
152
+ try {
153
+ return await fetchImplementation(url, { ...options, signal: controller.signal });
154
+ }
155
+ catch (error) {
156
+ if (timedOut) {
157
+ throw timeoutError();
158
+ }
159
+ throw error;
160
+ }
161
+ finally {
162
+ clearTimeout(timeout);
163
+ callerSignal === null || callerSignal === void 0 ? void 0 : callerSignal.removeEventListener("abort", abortFromCaller);
164
+ }
165
+ };
166
+ exports.fetchWithTimeout = fetchWithTimeout;
167
+ /** Exponential refresh backoff: 500 ms doubling per attempt, capped at 30 s. */
168
+ const refreshBackoffMs = (attempt) => Math.min(500 * (2 ** Math.min(attempt, 6)), 30000);
169
+ exports.refreshBackoffMs = refreshBackoffMs;
@@ -0,0 +1,2 @@
1
+ /** SHA-256 digest of an ASCII string (a PKCE verifier is `[A-Za-z0-9-._~]`). */
2
+ export declare const sha256Bytes: (ascii: string) => Uint8Array;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ // SHA-256 (FIPS 180-4), synchronous and dependency-free: React Native has no `crypto.subtle`,
3
+ // and the PKCE login start is synchronous.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.sha256Bytes = void 0;
6
+ const K = new Uint32Array([
7
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
8
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
9
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
10
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
11
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
12
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
13
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
14
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
15
+ ]);
16
+ const rotr = (x, n) => (x >>> n) | (x << (32 - n));
17
+ /** SHA-256 digest of an ASCII string (a PKCE verifier is `[A-Za-z0-9-._~]`). */
18
+ const sha256Bytes = (ascii) => {
19
+ const blocks = new Uint8Array(Math.ceil((ascii.length + 9) / 64) * 64);
20
+ const view = new DataView(blocks.buffer);
21
+ for (let i = 0; i < ascii.length; i += 1) {
22
+ const code = ascii.charCodeAt(i);
23
+ if (code > 0x7f) {
24
+ throw new RangeError("sha256Bytes hashes ASCII input only.");
25
+ }
26
+ blocks[i] = code;
27
+ }
28
+ blocks[ascii.length] = 0x80;
29
+ view.setUint32(blocks.length - 4, ascii.length * 8);
30
+ const hash = new Uint32Array([
31
+ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,
32
+ ]);
33
+ const w = new Uint32Array(64);
34
+ for (let offset = 0; offset < blocks.length; offset += 64) {
35
+ for (let t = 0; t < 16; t += 1) {
36
+ w[t] = view.getUint32(offset + t * 4);
37
+ }
38
+ for (let t = 16; t < 64; t += 1) {
39
+ const s0 = rotr(w[t - 15], 7) ^ rotr(w[t - 15], 18) ^ (w[t - 15] >>> 3);
40
+ const s1 = rotr(w[t - 2], 17) ^ rotr(w[t - 2], 19) ^ (w[t - 2] >>> 10);
41
+ w[t] = w[t - 16] + s0 + w[t - 7] + s1;
42
+ }
43
+ let [a, b, c, d, e, f, g, h] = hash;
44
+ for (let t = 0; t < 64; t += 1) {
45
+ const t1 = (h + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K[t] + w[t]) >>> 0;
46
+ const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0;
47
+ h = g;
48
+ g = f;
49
+ f = e;
50
+ e = (d + t1) >>> 0;
51
+ d = c;
52
+ c = b;
53
+ b = a;
54
+ a = (t1 + t2) >>> 0;
55
+ }
56
+ [a, b, c, d, e, f, g, h].forEach((value, index) => {
57
+ hash[index] += value;
58
+ });
59
+ }
60
+ const digest = new Uint8Array(32);
61
+ const digestView = new DataView(digest.buffer);
62
+ hash.forEach((word, index) => digestView.setUint32(index * 4, word));
63
+ return digest;
64
+ };
65
+ exports.sha256Bytes = sha256Bytes;
@@ -1,7 +1,7 @@
1
1
  import type { MedplumRequestOptions } from "@medplum/core";
2
- import { StartLoginResponse } from "../../client/auth/types/StartLoginResponse";
3
- import { OvokClient } from "../../client/ovok-client";
4
2
  import { LoginBody } from "../../types";
3
+ import { OvokClient } from "../ovok-client";
4
+ import { StartLoginResponse } from "./types/StartLoginResponse";
5
5
  type StartLoginProps = {
6
6
  client: OvokClient;
7
7
  body: LoginBody;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serializeChangeHistoryQuery = serializeChangeHistoryQuery;
4
4
  exports.listChangeHistory = listChangeHistory;
5
+ const request_options_1 = require("../request-options");
5
6
  function serializeChangeHistoryQuery(params = {}) {
6
7
  const search = new URLSearchParams();
7
8
  for (const [key, value] of Object.entries(params)) {
@@ -21,5 +22,5 @@ function serializeChangeHistoryQuery(params = {}) {
21
22
  return encoded ? `?${encoded}` : "";
22
23
  }
23
24
  function listChangeHistory(params = {}, requestOptions) {
24
- return this.get(`/v1/slim/change-history${serializeChangeHistoryQuery(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
25
+ return this.get(`/v1/slim/change-history${serializeChangeHistoryQuery(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
25
26
  }
@@ -6,31 +6,19 @@ exports.getLegalPage = getLegalPage;
6
6
  exports.listReleaseNotes = listReleaseNotes;
7
7
  exports.getTranslations = getTranslations;
8
8
  const sign_in_required_error_1 = require("../errors/sign-in-required-error");
9
+ const query_string_1 = require("../query-string");
10
+ const request_options_1 = require("../request-options");
9
11
  const locale_1 = require("./locale");
10
12
  const collectionPath = (collection) => `/v1/public/cms/collections/${encodeURIComponent(collection)}/items`;
11
- const cmsQuery = ({ locale, tenantCode, environment, page, limit, sort }) => {
12
- const params = new URLSearchParams();
13
- if (locale) {
14
- params.set("locale", (0, locale_1.toCmsLocale)(locale));
15
- }
16
- if (tenantCode) {
17
- params.set("tenant", tenantCode);
18
- }
19
- if (environment) {
20
- params.set("environment", environment);
21
- }
22
- if (page !== undefined) {
23
- params.set("page", String(page));
24
- }
25
- if (limit !== undefined) {
26
- params.set("limit", String(limit));
27
- }
28
- if (sort) {
29
- params.set("sort", sort);
30
- }
31
- const query = params.toString();
32
- return query ? `?${query}` : "";
33
- };
13
+ // Empty strings count as absent, like undefined.
14
+ const cmsQuery = ({ locale, tenantCode, environment, page, limit, sort }) => (0, query_string_1.toQueryString)({
15
+ locale: locale ? (0, locale_1.toCmsLocale)(locale) : undefined,
16
+ tenant: tenantCode || undefined,
17
+ environment,
18
+ page,
19
+ limit,
20
+ sort: sort || undefined,
21
+ });
34
22
  /**
35
23
  * Signed out, the backend serves only a few collections, read by tenant code;
36
24
  * any other read is a 401, which MedplumClient answers by clearing its
@@ -53,7 +41,7 @@ async function getCmsDocument(collection, slug, options = {}, requestOptions) {
53
41
  throw new Error("A CMS document read needs a slug.");
54
42
  }
55
43
  assertReadable(this, collection, options);
56
- return this.get(`${collectionPath(collection)}/${encodeURIComponent(slug)}${cmsQuery(options)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
44
+ return this.get(`${collectionPath(collection)}/${encodeURIComponent(slug)}${cmsQuery(options)}`, ...(0, request_options_1.optionalArg)(requestOptions));
57
45
  }
58
46
  /**
59
47
  * A page of a CMS collection's published documents, merged with the shared
@@ -61,17 +49,17 @@ async function getCmsDocument(collection, slug, options = {}, requestOptions) {
61
49
  */
62
50
  async function listCmsDocuments(collection, options = {}, requestOptions) {
63
51
  assertReadable(this, collection, options);
64
- return this.get(`${collectionPath(collection)}${cmsQuery(options)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
52
+ return this.get(`${collectionPath(collection)}${cmsQuery(options)}`, ...(0, request_options_1.optionalArg)(requestOptions));
65
53
  }
66
54
  /** A legal page ("terms-and-conditions", "data-privacy", …). Readable before sign-in with a tenant code. */
67
55
  function getLegalPage(slug, options = {}, requestOptions) {
68
56
  var _a;
69
- return this.getCmsDocument("legal-pages", slug, { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true }, ...(requestOptions === undefined ? [] : [requestOptions]));
57
+ return this.getCmsDocument("legal-pages", slug, { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true }, ...(0, request_options_1.optionalArg)(requestOptions));
70
58
  }
71
59
  /** Release notes, newest first unless `sort` says otherwise. Needs a session. */
72
60
  function listReleaseNotes(options = {}, requestOptions) {
73
61
  var _a;
74
- return this.listCmsDocuments("release-notes", { ...options, sort: (_a = options.sort) !== null && _a !== void 0 ? _a : "-publishedAt" }, ...(requestOptions === undefined ? [] : [requestOptions]));
62
+ return this.listCmsDocuments("release-notes", { ...options, sort: (_a = options.sort) !== null && _a !== void 0 ? _a : "-publishedAt" }, ...(0, request_options_1.optionalArg)(requestOptions));
75
63
  }
76
64
  /** A translations read takes pages of 50 documents, the CMS's most, and at most this many. */
77
65
  const MAX_TRANSLATION_PAGES = 20;
@@ -127,7 +115,7 @@ async function getTranslations(options = {}, requestOptions) {
127
115
  const readOptions = { ...options, allowSignedOut: (_a = options.allowSignedOut) !== null && _a !== void 0 ? _a : true };
128
116
  const translations = {};
129
117
  for (let page = 1; page <= MAX_TRANSLATION_PAGES; page++) {
130
- const { docs, hasNextPage } = await this.listCmsDocuments("translations", { ...readOptions, page, limit: 50 }, ...(requestOptions === undefined ? [] : [requestOptions]));
118
+ const { docs, hasNextPage } = await this.listCmsDocuments("translations", { ...readOptions, page, limit: 50 }, ...(0, request_options_1.optionalArg)(requestOptions));
131
119
  addTranslations(translations, docs);
132
120
  if (!hasNextPage) {
133
121
  break;
@@ -4,15 +4,16 @@ exports.getLegalConsent = getLegalConsent;
4
4
  exports.setLegalConsent = setLegalConsent;
5
5
  exports.getMedicalConsent = getMedicalConsent;
6
6
  exports.setMedicalConsent = setMedicalConsent;
7
+ const request_options_1 = require("../request-options");
7
8
  function getLegalConsent(requestOptions) {
8
- return this.get("/v1/me/consent/legal", ...(requestOptions === undefined ? [] : [requestOptions]));
9
+ return this.get("/v1/me/consent/legal", ...(0, request_options_1.optionalArg)(requestOptions));
9
10
  }
10
11
  function setLegalConsent(accepted, requestOptions) {
11
12
  const body = { termsAndConditionsConsent: accepted };
12
13
  return this.post("/v1/me/consent/legal", body, undefined, requestOptions);
13
14
  }
14
15
  function getMedicalConsent(requestOptions) {
15
- return this.get("/v1/me/consent/medical", ...(requestOptions === undefined ? [] : [requestOptions]));
16
+ return this.get("/v1/me/consent/medical", ...(0, request_options_1.optionalArg)(requestOptions));
16
17
  }
17
18
  function setMedicalConsent(accepted, requestOptions) {
18
19
  const body = { medicalSettingsNotificationsConsent: accepted };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getEmailTemplates = getEmailTemplates;
4
+ const request_options_1 = require("../request-options");
4
5
  function getEmailTemplates(requestOptions) {
5
- return this.get("/v1/email/templates", ...(requestOptions === undefined ? [] : [requestOptions]));
6
+ return this.get("/v1/email/templates", ...(0, request_options_1.optionalArg)(requestOptions));
6
7
  }
@@ -1,5 +1,11 @@
1
1
  import { ValidationError } from "../../types/ValidationError";
2
2
  export declare const OVOK_HTTP_ERROR_EXTENSION_URL = "https://api.ovok.com/fhir/StructureDefinition/http-error-metadata";
3
+ /** `reason` itself when it is an Error, else an Error carrying its string form. */
4
+ export declare const toError: (reason: unknown) => Error;
5
+ /** An Error with its `name` set, e.g. `namedError("AbortError", "The request was aborted.")`. */
6
+ export declare const namedError: (name: string, message: string) => Error;
7
+ /** Sets `cause` the way the SDK's typed errors expose it: read-only and not enumerable. */
8
+ export declare const withCause: <T extends Error>(error: T, cause: unknown) => T;
3
9
  export declare const asRecord: (value: unknown) => Record<string, unknown> | undefined;
4
10
  export declare function readMessage(payload: Record<string, unknown> | undefined, error: unknown): string;
5
11
  export declare function readFieldErrors(payload: Record<string, unknown> | undefined): ValidationError[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.asRecord = exports.OVOK_HTTP_ERROR_EXTENSION_URL = void 0;
3
+ exports.asRecord = exports.withCause = exports.namedError = exports.toError = exports.OVOK_HTTP_ERROR_EXTENSION_URL = void 0;
4
4
  exports.readMessage = readMessage;
5
5
  exports.readFieldErrors = readFieldErrors;
6
6
  exports.codeValue = codeValue;
@@ -11,6 +11,15 @@ exports.numberValue = numberValue;
11
11
  exports.stringValue = stringValue;
12
12
  exports.parseJson = parseJson;
13
13
  exports.OVOK_HTTP_ERROR_EXTENSION_URL = "https://api.ovok.com/fhir/StructureDefinition/http-error-metadata";
14
+ /** `reason` itself when it is an Error, else an Error carrying its string form. */
15
+ const toError = (reason) => reason instanceof Error ? reason : new Error(String(reason));
16
+ exports.toError = toError;
17
+ /** An Error with its `name` set, e.g. `namedError("AbortError", "The request was aborted.")`. */
18
+ const namedError = (name, message) => Object.assign(new Error(message), { name });
19
+ exports.namedError = namedError;
20
+ /** Sets `cause` the way the SDK's typed errors expose it: read-only and not enumerable. */
21
+ const withCause = (error, cause) => Object.defineProperty(error, "cause", { configurable: true, enumerable: false, value: cause, writable: false });
22
+ exports.withCause = withCause;
14
23
  const asRecord = (value) => value && typeof value === "object" ? value : undefined;
15
24
  exports.asRecord = asRecord;
16
25
  function readMessage(payload, error) {
@@ -26,7 +26,7 @@ const HTTP_REASON_PHRASES = new Set([
26
26
  ]);
27
27
  /** Reads the error details Medplum preserves from Ovok's non-FHIR responses. */
28
28
  const readOvokError = (error) => {
29
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
29
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
30
30
  if (error instanceof OvokApiError) {
31
31
  return {
32
32
  status: error.status,
@@ -62,15 +62,13 @@ const readOvokError = (error) => {
62
62
  const missing = Array.isArray(payload === null || payload === void 0 ? void 0 : payload.missing)
63
63
  ? payload.missing.filter((entry) => typeof entry === "string")
64
64
  : [];
65
- const retryAfterMs = (_x = (_w = metadata.retryAfterMs) !== null && _w !== void 0 ? _w : (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterMs)) !== null && _x !== void 0 ? _x : ((0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterSec) === undefined
66
- ? undefined
67
- : (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterSec) * 1000);
65
+ const retryAfterSec = (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterSec);
66
+ const retryAfterMs = (_x = (_w = metadata.retryAfterMs) !== null && _w !== void 0 ? _w : (0, ovok_error_utils_1.numberValue)(payload === null || payload === void 0 ? void 0 : payload.retryAfterMs)) !== null && _x !== void 0 ? _x : (retryAfterSec === undefined ? undefined : retryAfterSec * 1000);
67
+ const requestId = (_y = metadata.requestId) !== null && _y !== void 0 ? _y : (0, ovok_error_utils_1.stringValue)(payload === null || payload === void 0 ? void 0 : payload.requestId);
68
68
  return {
69
69
  status,
70
70
  code,
71
- ...(((_y = metadata.requestId) !== null && _y !== void 0 ? _y : (0, ovok_error_utils_1.stringValue)(payload === null || payload === void 0 ? void 0 : payload.requestId)) === undefined
72
- ? {}
73
- : { requestId: (_z = metadata.requestId) !== null && _z !== void 0 ? _z : (0, ovok_error_utils_1.stringValue)(payload === null || payload === void 0 ? void 0 : payload.requestId) }),
71
+ ...(requestId === undefined ? {} : { requestId }),
74
72
  ...(retryAfterMs === undefined ? {} : { retryAfterMs }),
75
73
  message: (0, ovok_error_utils_1.readMessage)(payload, error),
76
74
  fieldErrors,
@@ -90,12 +88,7 @@ class OvokApiError extends Error {
90
88
  this.missing = details.missing;
91
89
  this.requestId = details.requestId;
92
90
  this.retryAfterMs = details.retryAfterMs;
93
- Object.defineProperty(this, "cause", {
94
- configurable: true,
95
- enumerable: false,
96
- value: cause,
97
- writable: false,
98
- });
91
+ (0, ovok_error_utils_1.withCause)(this, cause);
99
92
  }
100
93
  }
101
94
  exports.OvokApiError = OvokApiError;
@@ -5,6 +5,7 @@ exports.isRateLimitError = isRateLimitError;
5
5
  exports.mapRateLimitError = mapRateLimitError;
6
6
  const core_1 = require("@medplum/core");
7
7
  const ovok_error_1 = require("./ovok-error");
8
+ const ovok_error_utils_1 = require("./ovok-error-utils");
8
9
  const RATE_LIMIT_RESET_EXTENSION_URL = "https://medplum.com/fhir/StructureDefinition/rate-limit-reset";
9
10
  /** A typed error returned when the server asks the client to slow down. */
10
11
  class RateLimitError extends Error {
@@ -14,12 +15,7 @@ class RateLimitError extends Error {
14
15
  this.name = "RateLimitError";
15
16
  this.retryAfterMs = retryAfterMs;
16
17
  if (options) {
17
- Object.defineProperty(this, "cause", {
18
- configurable: true,
19
- enumerable: false,
20
- value: options.cause,
21
- writable: false,
22
- });
18
+ (0, ovok_error_utils_1.withCause)(this, options.cause);
23
19
  }
24
20
  }
25
21
  }
@@ -34,85 +34,76 @@ exports.listChatSessions = listChatSessions;
34
34
  exports.getChatSession = getChatSession;
35
35
  exports.listChatMessages = listChatMessages;
36
36
  exports.searchAIFhir = searchAIFhir;
37
- const segment = (value) => encodeURIComponent(value);
38
- const query = (params) => {
39
- const values = new URLSearchParams();
40
- for (const [key, value] of Object.entries(params)) {
41
- if (value !== undefined) {
42
- values.set(key, String(value));
43
- }
44
- }
45
- const encoded = values.toString();
46
- return encoded === "" ? "" : `?${encoded}`;
47
- };
48
- const documentUrl = (client, path, params) => `${client.getBaseUrl().replace(/\/$/, "")}${path}${query(params)}`;
37
+ const query_string_1 = require("../query-string");
38
+ const request_options_1 = require("../request-options");
39
+ const documentUrl = (client, path, params) => `${client.getBaseUrl().replace(/\/$/, "")}${path}${(0, query_string_1.toQueryString)(params)}`;
49
40
  async function requestConsentSignature(consentId, requestOptions) {
50
- return this.post(`/consent/signature/${segment(consentId)}`, undefined, undefined, requestOptions);
41
+ return this.post(`/consent/signature/${encodeURIComponent(consentId)}`, undefined, undefined, requestOptions);
51
42
  }
52
43
  async function createDocumentUpload(body, requestOptions) {
53
44
  return this.post("/document", body, undefined, requestOptions);
54
45
  }
55
46
  async function listDocuments(params = {}, requestOptions) {
56
- return this.get(`/document${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
47
+ return this.get(`/document${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
57
48
  }
58
49
  /** Returns the authenticated document endpoint; navigating/fetching it follows the backend redirect. */
59
50
  async function getDocumentDownloadUrl(documentId, params = {}) {
60
- return documentUrl(this, `/document/${segment(documentId)}`, params);
51
+ return documentUrl(this, `/document/${encodeURIComponent(documentId)}`, params);
61
52
  }
62
53
  /** Returns a public document endpoint for use in an image, download, or media element. */
63
54
  async function getPublicDocumentDownloadUrl(token, params = {}) {
64
- return documentUrl(this, `/document/public/${segment(token)}`, params);
55
+ return documentUrl(this, `/document/public/${encodeURIComponent(token)}`, params);
65
56
  }
66
57
  async function deleteDocument(documentId, requestOptions) {
67
- return (await this.delete(`/document/${segment(documentId)}`, ...(requestOptions === undefined ? [] : [requestOptions])));
58
+ return (await this.delete(`/document/${encodeURIComponent(documentId)}`, ...(0, request_options_1.optionalArg)(requestOptions)));
68
59
  }
69
60
  async function updateDocumentMetadata(documentId, body, requestOptions) {
70
- return (await this.patch(`/document/${segment(documentId)}`, body, ...(requestOptions === undefined ? [] : [requestOptions])));
61
+ return (await this.patch(`/document/${encodeURIComponent(documentId)}`, body, ...(0, request_options_1.optionalArg)(requestOptions)));
71
62
  }
72
63
  async function generateDocumentReplacementUpload(documentId, body, requestOptions) {
73
- return this.post(`/document/${segment(documentId)}`, body, undefined, requestOptions);
64
+ return this.post(`/document/${encodeURIComponent(documentId)}`, body, undefined, requestOptions);
74
65
  }
75
66
  async function searchMappedContent(type, language, params = {}, requestOptions) {
76
- return this.get(`/cms/${segment(type)}/map/${segment(language)}${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
67
+ return this.get(`/cms/${encodeURIComponent(type)}/map/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
77
68
  }
78
69
  async function copyContentsFromParent(type, language, requestOptions) {
79
- return this.post(`/cms/${segment(type)}/${segment(language)}/copy-from-parent-project`, undefined, undefined, requestOptions);
70
+ return this.post(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/copy-from-parent-project`, undefined, undefined, requestOptions);
80
71
  }
81
72
  async function copyContentFromParent(type, language, key, requestOptions) {
82
- return this.post(`/cms/${segment(type)}/${segment(language)}/${segment(key)}/copy-from-parent-project`, undefined, undefined, requestOptions);
73
+ return this.post(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}/copy-from-parent-project`, undefined, undefined, requestOptions);
83
74
  }
84
75
  async function createContent(type, language, body, requestOptions) {
85
- return this.post(`/cms/${segment(type)}/${segment(language)}`, body, undefined, requestOptions);
76
+ return this.post(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}`, body, undefined, requestOptions);
86
77
  }
87
78
  async function updateContent(type, language, key, body, requestOptions) {
88
- return (await this.put(`/cms/${segment(type)}/${segment(language)}/${segment(key)}`, body, undefined, requestOptions));
79
+ return (await this.put(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, body, undefined, requestOptions));
89
80
  }
90
81
  async function getContent(type, language, key, requestOptions) {
91
- return this.get(`/cms/${segment(type)}/${segment(language)}/${segment(key)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
82
+ return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(0, request_options_1.optionalArg)(requestOptions));
92
83
  }
93
84
  async function deleteContent(type, language, key, requestOptions) {
94
- await this.delete(`/cms/${segment(type)}/${segment(language)}/${segment(key)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
85
+ await this.delete(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}/${encodeURIComponent(key)}`, ...(0, request_options_1.optionalArg)(requestOptions));
95
86
  }
96
87
  async function searchContent(type, language, params = {}, requestOptions) {
97
- return this.get(`/cms/${segment(type)}/${segment(language)}${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
88
+ return this.get(`/cms/${encodeURIComponent(type)}/${encodeURIComponent(language)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
98
89
  }
99
90
  async function createVideoCallAppointment(body, requestOptions) {
100
91
  return this.post("/video-call/livekit/appointment", body, undefined, requestOptions);
101
92
  }
102
93
  async function updateVideoCallAppointment(appointmentId, body, requestOptions) {
103
- return (await this.put(`/video-call/livekit/appointment/${segment(appointmentId)}`, body, undefined, requestOptions));
94
+ return (await this.put(`/video-call/livekit/appointment/${encodeURIComponent(appointmentId)}`, body, undefined, requestOptions));
104
95
  }
105
96
  async function listVideoCallAppointments(params = {}, requestOptions) {
106
- return this.get(`/video-call/livekit/appointment${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
97
+ return this.get(`/video-call/livekit/appointment${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
107
98
  }
108
99
  async function getVideoCallAccessPermission(appointmentId, requestOptions) {
109
- return this.get(`/video-call/livekit/access-permission/${segment(appointmentId)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
100
+ return this.get(`/video-call/livekit/access-permission/${encodeURIComponent(appointmentId)}`, ...(0, request_options_1.optionalArg)(requestOptions));
110
101
  }
111
102
  async function createVideoCallGuestAccess(appointmentId, body, requestOptions) {
112
- return this.post(`/video-call/livekit/guest-access/${segment(appointmentId)}`, body, undefined, requestOptions);
103
+ return this.post(`/video-call/livekit/guest-access/${encodeURIComponent(appointmentId)}`, body, undefined, requestOptions);
113
104
  }
114
105
  async function createVideoCallUserAccess(appointmentId, requestOptions) {
115
- return this.post(`/video-call/livekit/user-access/${segment(appointmentId)}`, undefined, undefined, requestOptions);
106
+ return this.post(`/video-call/livekit/user-access/${encodeURIComponent(appointmentId)}`, undefined, undefined, requestOptions);
116
107
  }
117
108
  async function sendVideoCallInvite(body, requestOptions) {
118
109
  return this.post("/video-call/livekit/mail/invite", body, undefined, requestOptions);
@@ -124,7 +115,7 @@ async function sendVideoCallCancellation(body, requestOptions) {
124
115
  return this.post("/video-call/livekit/mail/cancel", body, undefined, requestOptions);
125
116
  }
126
117
  async function sendVideoCallActiveNotification(appointmentId, requestOptions) {
127
- return this.post(`/video-call/livekit/notification/active-call/${segment(appointmentId)}`, undefined, undefined, requestOptions);
118
+ return this.post(`/video-call/livekit/notification/active-call/${encodeURIComponent(appointmentId)}`, undefined, undefined, requestOptions);
128
119
  }
129
120
  async function translate(body, requestOptions) {
130
121
  return this.post("/ai/translation", body, undefined, requestOptions);
@@ -133,16 +124,16 @@ async function createChatSession(body, requestOptions) {
133
124
  return this.post("/ai/session", body, undefined, requestOptions);
134
125
  }
135
126
  async function sendChatMessage(sessionId, body, requestOptions) {
136
- return this.post(`/ai/session/${segment(sessionId)}/message`, body, undefined, requestOptions);
127
+ return this.post(`/ai/session/${encodeURIComponent(sessionId)}/message`, body, undefined, requestOptions);
137
128
  }
138
129
  async function listChatSessions(params = {}, requestOptions) {
139
- return this.get(`/ai/session${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
130
+ return this.get(`/ai/session${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
140
131
  }
141
132
  async function getChatSession(sessionId, params = {}, requestOptions) {
142
- return this.get(`/ai/session/${segment(sessionId)}${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
133
+ return this.get(`/ai/session/${encodeURIComponent(sessionId)}${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
143
134
  }
144
135
  async function listChatMessages(sessionId, params = {}, requestOptions) {
145
- return this.get(`/ai/session/${segment(sessionId)}/message${query(params)}`, ...(requestOptions === undefined ? [] : [requestOptions]));
136
+ return this.get(`/ai/session/${encodeURIComponent(sessionId)}/message${(0, query_string_1.toQueryString)(params)}`, ...(0, request_options_1.optionalArg)(requestOptions));
146
137
  }
147
138
  async function searchAIFhir(request, requestOptions) {
148
139
  return this.post("/ai/fhir/search", request, undefined, requestOptions);