@healthcloudai/hc-sdk 0.3.0 → 0.5.0

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.js CHANGED
@@ -8,7 +8,9 @@ var SERVICES = [
8
8
  "appointments",
9
9
  "rppg",
10
10
  "session",
11
- "telehealth"
11
+ "telehealth",
12
+ "fieldagent",
13
+ "mcp"
12
14
  ];
13
15
  function isServiceName(value) {
14
16
  return SERVICES.includes(value);
@@ -22,6 +24,15 @@ function assertEnvironment(environment) {
22
24
  throw new Error(`Unsupported HealthCloud environment: "${environment}"`);
23
25
  }
24
26
  }
27
+ function withTenantId(request, tenantId) {
28
+ if (!tenantId) {
29
+ return request;
30
+ }
31
+ return {
32
+ ...request,
33
+ tenant_id: tenantId
34
+ };
35
+ }
25
36
 
26
37
  // src/errors/SDKError.ts
27
38
  var SDKError = class extends Error {
@@ -72,9 +83,6 @@ var HttpClient = class {
72
83
  Accept: "application/json",
73
84
  ...(_a = options.headers) != null ? _a : {}
74
85
  };
75
- if (this.state.tenantId) {
76
- headers["X-Tenant-ID"] = this.state.tenantId;
77
- }
78
86
  if (options.auth !== false) {
79
87
  if (!this.state.accessToken) {
80
88
  throw new SDKError({
@@ -169,12 +177,11 @@ var HttpClient = class {
169
177
  return response.statusText || `HealthCloud API request failed with HTTP ${response.status}.`;
170
178
  }
171
179
  readMessage(payload) {
172
- if (typeof payload !== "object" || payload === null) {
180
+ if (typeof payload !== "object" || payload === null || Array.isArray(payload)) {
173
181
  return void 0;
174
182
  }
175
- const record = payload;
176
183
  for (const key of ["message", "error", "ErrorMessage", "Message", "detail"]) {
177
- const value = record[key];
184
+ const value = payload[key];
178
185
  if (typeof value === "string" && value.trim()) {
179
186
  return value;
180
187
  }
@@ -195,7 +202,9 @@ var BaseServiceClient = class {
195
202
  }
196
203
  /**
197
204
  * Low-level escape hatch — allows consumers to call any path on this service
198
- * without waiting for a typed SDK method to be added.
205
+ * without waiting for a typed SDK method to be added. The response shape is
206
+ * intentionally generic since this targets undocumented/future paths; the
207
+ * caller must supply `TResponse` once the path's contract is known.
199
208
  */
200
209
  request(method, path, options = {}) {
201
210
  return this.send(method, path, options);
@@ -227,62 +236,30 @@ var AuthClient = class extends BaseServiceClient {
227
236
  }
228
237
  async register(request) {
229
238
  return this.send("POST", "/auth/register", {
230
- body: this.withTenantId(request),
239
+ body: withTenantId(request, this.getTenantId()),
231
240
  auth: false
232
241
  });
233
242
  }
234
243
  async login(request) {
235
244
  const response = await this.send("POST", "/auth/login", {
236
- body: this.withTenantId(request),
245
+ body: withTenantId(request, this.getTenantId()),
237
246
  auth: false
238
247
  });
239
- const accessToken = this.extractAccessToken(response);
240
- if (!accessToken) {
248
+ if (!response.access_token) {
241
249
  throw new SDKError({
242
250
  message: "Login response did not include an access token.",
243
- statusCode: 0,
244
- response
251
+ statusCode: 0
245
252
  });
246
253
  }
247
- this.setAccessToken(accessToken);
254
+ this.setAccessToken(response.access_token);
248
255
  return response;
249
256
  }
250
257
  async verifyEmail(request) {
251
258
  return this.send("POST", "/auth/verify-email", {
252
- body: this.withTenantId(request),
259
+ body: withTenantId(request, this.getTenantId()),
253
260
  auth: false
254
261
  });
255
262
  }
256
- withTenantId(request) {
257
- const tenantId = this.getTenantId();
258
- if (!tenantId) {
259
- return request;
260
- }
261
- return {
262
- ...request,
263
- tenant_id: tenantId
264
- };
265
- }
266
- extractAccessToken(response) {
267
- if (typeof response !== "object" || response === null) {
268
- return void 0;
269
- }
270
- const record = response;
271
- for (const key of ["token", "access_token", "accessToken", "AccessToken", "idToken", "IDToken"]) {
272
- const value = record[key];
273
- if (typeof value === "string" && value.trim()) {
274
- return value;
275
- }
276
- }
277
- for (const key of ["data", "Data", "result", "Result"]) {
278
- const nested = record[key];
279
- const token = this.extractAccessToken(nested);
280
- if (token) {
281
- return token;
282
- }
283
- }
284
- return void 0;
285
- }
286
263
  };
287
264
 
288
265
  // src/clients/DiagnosticsClient.ts
@@ -299,10 +276,10 @@ var DiagnosticsClient = class extends BaseServiceClient {
299
276
  body: request
300
277
  });
301
278
  }
302
- list(patientId, query) {
279
+ // No documented query params for this endpoint — see curl reference.
280
+ list(patientId) {
303
281
  return this.send("GET", "/patients/{patient_id}/diagnostics", {
304
- pathParams: { patient_id: patientId },
305
- query
282
+ pathParams: { patient_id: patientId }
306
283
  });
307
284
  }
308
285
  };
@@ -317,6 +294,114 @@ var EhrClient = class extends BaseServiceClient {
317
294
  }
318
295
  };
319
296
 
297
+ // src/clients/FieldAgentClient.ts
298
+ var FieldAgentClient = class extends BaseServiceClient {
299
+ constructor(http, setAccessToken, getTenantId) {
300
+ super(http, "fieldagent");
301
+ this.setAccessToken = setAccessToken;
302
+ this.getTenantId = getTenantId;
303
+ }
304
+ connect() {
305
+ return this.connectService();
306
+ }
307
+ register(request) {
308
+ return this.send("POST", "/auth/register", {
309
+ body: withTenantId(request, this.getTenantId()),
310
+ auth: false
311
+ });
312
+ }
313
+ resetPassword(request) {
314
+ return this.send("POST", "/auth/reset-password", {
315
+ body: withTenantId(request, this.getTenantId()),
316
+ auth: false
317
+ });
318
+ }
319
+ async login(request) {
320
+ const response = await this.send("POST", "/auth/login", {
321
+ body: withTenantId(request, this.getTenantId()),
322
+ auth: false
323
+ });
324
+ if (!response.access_token) {
325
+ throw new SDKError({
326
+ message: "Login response did not include an access token.",
327
+ statusCode: 0
328
+ });
329
+ }
330
+ this.setAccessToken(response.access_token);
331
+ return response;
332
+ }
333
+ verifyEmail(request) {
334
+ return this.send("POST", "/auth/verify-email", {
335
+ body: withTenantId(request, this.getTenantId()),
336
+ auth: false
337
+ });
338
+ }
339
+ verifySms(request) {
340
+ return this.send("POST", "/auth/verify-sms", {
341
+ body: withTenantId(request, this.getTenantId()),
342
+ auth: false
343
+ });
344
+ }
345
+ getAgent(agentSub) {
346
+ return this.send("GET", "/agents/{sub}", {
347
+ pathParams: { sub: agentSub }
348
+ });
349
+ }
350
+ updateAgent(agentSub, request) {
351
+ return this.send("PATCH", "/agents/{sub}", {
352
+ pathParams: { sub: agentSub },
353
+ body: request
354
+ });
355
+ }
356
+ getDashboard(agentSub, query) {
357
+ return this.send("GET", "/agents/{sub}/dashboard", {
358
+ pathParams: { sub: agentSub },
359
+ query
360
+ });
361
+ }
362
+ getPhotoUploadUrl(agentSub) {
363
+ return this.send("GET", "/agents/{sub}/photo/upload-url", {
364
+ pathParams: { sub: agentSub }
365
+ });
366
+ }
367
+ uploadPhoto(agentSub, request) {
368
+ return this.send("POST", "/agents/{sub}/photo", {
369
+ pathParams: { sub: agentSub },
370
+ body: request
371
+ });
372
+ }
373
+ getPhoto(agentSub, query) {
374
+ return this.send("GET", "/agents/{sub}/photo", {
375
+ pathParams: { sub: agentSub },
376
+ query
377
+ });
378
+ }
379
+ listPatients(query) {
380
+ return this.send("GET", "/patients", { query });
381
+ }
382
+ listEncounters(query) {
383
+ return this.send("GET", "/encounters", { query });
384
+ }
385
+ };
386
+
387
+ // src/clients/MCPClient.ts
388
+ var MCPClient = class extends BaseServiceClient {
389
+ constructor(http) {
390
+ super(http, "mcp");
391
+ }
392
+ connect() {
393
+ return this.connectService();
394
+ }
395
+ /** Calls one of the 14 Patient API tools via `POST /patient`. */
396
+ patient(request) {
397
+ return this.send("POST", "/patient", { body: request });
398
+ }
399
+ /** Calls one of the 8 Field Agent API tools via `POST /fieldagent`. */
400
+ fieldAgent(request) {
401
+ return this.send("POST", "/fieldagent", { body: request });
402
+ }
403
+ };
404
+
320
405
  // src/clients/PatientClient.ts
321
406
  var PatientClient = class extends BaseServiceClient {
322
407
  constructor(http) {
@@ -354,6 +439,11 @@ var PatientClient = class extends BaseServiceClient {
354
439
  pathParams: { id: patientId }
355
440
  });
356
441
  }
442
+ getDashboard(patientId) {
443
+ return this.send("GET", "/patients/{id}/dashboard", {
444
+ pathParams: { id: patientId }
445
+ });
446
+ }
357
447
  uploadPhoto(patientId, request) {
358
448
  return this.send("POST", "/patients/{id}/photo", {
359
449
  pathParams: { id: patientId },
@@ -401,9 +491,10 @@ var PatientClient = class extends BaseServiceClient {
401
491
  body: request
402
492
  });
403
493
  }
404
- listMedications(patientId) {
494
+ listMedications(patientId, query) {
405
495
  return this.send("GET", "/patients/{id}/medications", {
406
- pathParams: { id: patientId }
496
+ pathParams: { id: patientId },
497
+ query
407
498
  });
408
499
  }
409
500
  getMedication(patientId, medicationId) {
@@ -448,6 +539,8 @@ var PatientClient = class extends BaseServiceClient {
448
539
  body: request
449
540
  });
450
541
  }
542
+ // No HealthCloud schema is published for this response — see
543
+ // `InsuranceEligibilityResponse` for why it stays a raw `JsonValue`.
451
544
  checkInsuranceEligibility(request) {
452
545
  return this.send("POST", "/insurance/eligibility", {
453
546
  body: request
@@ -627,6 +720,12 @@ var HCSDK = class {
627
720
  this.rppg = new RppgClient(this.http);
628
721
  this.session = new SessionClient(this.http);
629
722
  this.telehealth = new TelehealthClient(this.http);
723
+ this.fieldAgent = new FieldAgentClient(
724
+ this.http,
725
+ (token) => this.setAccessToken(token),
726
+ () => this.state.tenantId
727
+ );
728
+ this.mcp = new MCPClient(this.http);
630
729
  }
631
730
  setAccessToken(token) {
632
731
  this.state.accessToken = token;
@@ -729,5 +828,6 @@ export {
729
828
  SDKError,
730
829
  assertEnvironment,
731
830
  isServiceName,
732
- resolveBaseUrl
831
+ resolveBaseUrl,
832
+ withTenantId
733
833
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthcloudai/hc-sdk",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "All-in-one HealthCloud SDK for the new HealthCloud APIs.",
5
5
  "author": "Healthcheck Systems Inc",
6
6
  "license": "MIT",