@hipnation-truth/sdk 0.26.13 → 0.26.15

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.
package/dist/index.mjs CHANGED
@@ -140,6 +140,11 @@ var REQUIRE_TOKEN_RETRY_DELAY_MS = 150;
140
140
  function delay(ms) {
141
141
  return new Promise((resolve) => setTimeout(resolve, ms));
142
142
  }
143
+ var USER_TOKEN_HEADER = "X-Truth-Authorization";
144
+ function setUserToken(headers, token) {
145
+ headers.Authorization = `Bearer ${token}`;
146
+ headers[USER_TOKEN_HEADER] = `Bearer ${token}`;
147
+ }
143
148
  function resolveAuthToken(getAuthToken) {
144
149
  return __async(this, null, function* () {
145
150
  try {
@@ -170,7 +175,7 @@ function buildAuthHeaders(auth, options) {
170
175
  for (let attempt = 0; attempt < REQUIRE_TOKEN_MAX_ATTEMPTS; attempt++) {
171
176
  const token = yield resolveAuthToken(auth.getAuthToken);
172
177
  if (token) {
173
- headers.Authorization = `Bearer ${token}`;
178
+ setUserToken(headers, token);
174
179
  return headers;
175
180
  }
176
181
  if (attempt < REQUIRE_TOKEN_MAX_ATTEMPTS - 1) {
@@ -184,7 +189,7 @@ function buildAuthHeaders(auth, options) {
184
189
  if (auth.getAuthToken) {
185
190
  const token = yield resolveAuthToken(auth.getAuthToken);
186
191
  if (token) {
187
- headers.Authorization = `Bearer ${token}`;
192
+ setUserToken(headers, token);
188
193
  }
189
194
  }
190
195
  return headers;
@@ -1306,6 +1311,34 @@ var PatientDetailsResource = class {
1306
1311
  }
1307
1312
  };
1308
1313
 
1314
+ // src/react/elation-id.ts
1315
+ function toBigIntElationId(value) {
1316
+ if (value === void 0 || value === null || value === "") {
1317
+ return void 0;
1318
+ }
1319
+ if (typeof value === "bigint") {
1320
+ return value;
1321
+ }
1322
+ if (typeof value === "number") {
1323
+ if (!Number.isFinite(value) || !Number.isInteger(value)) {
1324
+ return void 0;
1325
+ }
1326
+ return BigInt(Math.trunc(value));
1327
+ }
1328
+ if (typeof value === "string") {
1329
+ const trimmed = value.trim();
1330
+ if (!/^\d+$/.test(trimmed)) {
1331
+ return void 0;
1332
+ }
1333
+ try {
1334
+ return BigInt(trimmed);
1335
+ } catch (e) {
1336
+ return void 0;
1337
+ }
1338
+ }
1339
+ return void 0;
1340
+ }
1341
+
1309
1342
  // src/resources/patients.ts
1310
1343
  var PatientResource = class {
1311
1344
  constructor(convexClient) {
@@ -1331,13 +1364,21 @@ var PatientResource = class {
1331
1364
  }
1332
1365
  /**
1333
1366
  * Get a patient by their Elation EHR ID.
1367
+ *
1368
+ * Accepts the id in any form (string/number/bigint) and coerces it to a
1369
+ * `bigint` (int64) for the now-int64 Convex `patients:getByElationId` arg.
1370
+ * Returns `null` for a non-numeric / absent id.
1334
1371
  */
1335
1372
  getByElationId(elationId) {
1336
1373
  return __async(this, null, function* () {
1374
+ const id = toBigIntElationId(elationId);
1375
+ if (id === void 0) {
1376
+ return null;
1377
+ }
1337
1378
  try {
1338
1379
  const result = yield this.convex.query(
1339
1380
  "patients:getByElationId",
1340
- { elationId }
1381
+ { elationId: id }
1341
1382
  );
1342
1383
  return result != null ? result : null;
1343
1384
  } catch (e) {