npm package: @healthcloudai/hc-assets-connector
Description: Healthcheck Assets SDK with TypeScript
Author: Healthcheck Systems Inc
Latest version: 0.0.5

# Healthcheck Assets Connector

This connector lets you fetch authenticated content, fetch tenant-scoped public content, and update the stored user image reference.
It reuses the configured login client together with the shared Healthcheck HTTP client.

---

## Features

1. Get authenticated patient content
2. Get public content for the configured tenant
3. Update the stored user image reference
4. Reuse the configured login client for base URL, tenant context, and auth headers where needed

---

## Installation

```sh
npm install @healthcloudai/hc-assets-connector \
@healthcloudai/hc-login-connector \
@healthcloudai/hc-http
```

---

## Import

```ts
import { HCAssetsClient } from "@healthcloudai/hc-assets-connector";
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
import { FetchClient } from "@healthcloudai/hc-http";
```

---

## Usage

### Configuration

```ts
const httpClient = new FetchClient();
const loginClient = new HCLoginClient(httpClient);

loginClient.configure("demo-tenant", "dev");
await loginClient.login("john.doe@example.com", "ExamplePassword123!");

const assetsClient = new HCAssetsClient(httpClient, loginClient);
```

Reuse the same configured `HCLoginClient` instance when creating `HCAssetsClient` so both connectors use the same tenant and auth state.

---

## Methods

### Get Content

Public signature: `assetsClient.getContent(type?)`

Returns authenticated content for the current patient context.
If `type` is provided, the client appends it as a query string.
Current supported content categories are:
`Article`, `Video`, `LegalNotice`, `FAQ`, `Guide`, `News`, `PrivacyPolicy`, `Announcement`, and `HealthTip`.

```ts
const content = await assetsClient.getContent();
const privacyPolicy = await assetsClient.getContent("privacypolicy");
```

#### Full API request

This method performs an authenticated `GET` request internally and does not send a request body.
If `type` is provided, the client appends it as a query string.

#### API response

Status:

```txt
200
```

```json
{
  "Data": [
    {
      "ID": "content-id-example",
      "Name": "What causes COVID?",
      "Description": "<p>Example content body.</p>",
      "ImageURL": null,
      "ContentType": "FAQ",
      "PublicationDate": "2026-03-18T08:15:20.987Z",
      "ExpirationDate": null,
      "ExternalLink": null,
      "Article": null,
      "Featured": false,
      "Status": "ACTIVE",
      "ThumbnailURL": null,
      "VideoURL": null,
      "IsFirstDocument": false,
      "SelectedAccountTenantIDs": [
        "demo-tenant",
        "other-tenant-example"
      ],
      "TenantID": "platformadmin"
    }
  ],
  "ErrorMessage": null,
  "IsOK": true
}
```

---

### Get Public Content

Public signature: `assetsClient.getPublicContent(type?)`

Returns public content for the configured tenant.
This method sends a `POST` body with `TenantID` from `loginClient.getTenantId()` and does not use `getAuthHeader()`.
If `type` is provided, the client appends it as a query string.
At the moment, `registrationFAQ` is the only valid type for this method because it is used before the user is logged in.

```ts
const publicContent = await assetsClient.getPublicContent("registrationFAQ");
```

#### Full API request

```json
{
  "Data": {
    "TenantID": "demo-tenant"
  }
}
```

#### API response

Status:

```txt
200
```

```json
{
  "Data": [
    {
      "ID": "content-id-example",
      "Name": "Where can I go for other questions or support?",
      "Description": "<pre><code>Contact support@example.com for help.</code></pre>",
      "ImageURL": null,
      "ContentType": "Registration FAQ",
      "PublicationDate": "2026-03-27T09:53:47.239Z",
      "ExpirationDate": null,
      "ExternalLink": null,
      "Article": null,
      "Featured": false,
      "Status": "ACTIVE",
      "ThumbnailURL": null,
      "VideoURL": null,
      "IsFirstDocument": false,
      "SelectedAccountTenantIDs": [
        "demo-tenant"
      ],
      "TenantID": "platformadmin"
    }
  ],
  "ErrorMessage": null,
  "IsOK": true
}
```
---

## How It Works

- `HCAssetsClient` builds requests from `loginClient.getBaseUrl()`.
- `getContent()` uses authenticated headers from `loginClient.getAuthHeader()`.
- `getPublicContent()` builds a public `POST` body from `loginClient.getTenantId()` and does not send auth headers.

---

## Notes

- `HCLoginClient` must already be configured before using this connector.
- `getContent()`  requires an authenticated login client.
- `getPublicContent()` uses tenant context from the configured login client and sends a `POST` body.
- The optional `type` argument is appended as a query string when provided.
- For `getPublicContent()`, `registrationFAQ` is currently the only valid type. This method is used before the user is logged in.