Skip to content

Latest commit

 

History

History
48 lines (33 loc) · 2.73 KB

File metadata and controls

48 lines (33 loc) · 2.73 KB

HDS JAVASCRIPT LIBRARY

CI codecov

Generic toolkit for server and web applications — Health Data Safe.

Full documentation: healthdatasafe.github.io/hds-lib-js

Features

  1. HDS Data Model — Load and query the HDS data model: items, streams, authorizations, event types, datasources
  2. App Templates — Consent-based data collection and sharing (Manager, Collector, Invite, Client flows). Includes the AppTemplate JSON loader and custom-field declarations (template-private streams via clientData.hdsCustomField). See ts/appTemplates/CUSTOM-FIELDS-AND-SYSTEM.md for the design reference. (System messaging now flows through the CMC per-collector channel — see open-pryv.io/components/cmc/IMPLEMENTERS-GUIDE.md.)
  3. HDSSettings — Per-app user settings (locale, theme, timezone, date format, unit system)
  4. HDSProfile — Account-level profile (display name, avatar, date of birth, sex, country)
  5. Pryv extensions — Extends Pryv JS lib with Socket.io and Monitor support
  6. Toolkit — Stream auto-creation, reminders, duration parsing, event formatting (eventToShortText handles {drug} / {regimen} / {procedure} payload shapes uniformly, with optional ×count, procedure findings, and truncated notes)

Quick start

import HDSLib from 'hds-lib';

HDSLib.settings.setServiceInfoURL('https://demo.datasafe.dev/reg/service/info');
await HDSLib.initHDSModel();

const model = HDSLib.getHDSModel();
const weight = model.itemsDefs.forKey('body-weight');

// Resolve the itemDef for an event — walks parent streams for context-via-substream cases
// (e.g. event on `treatment-fertility` resolves to `treatment-coded` registered at `treatment`).
const itemDef = model.itemsDefs.forEvent(event);

Dev

Requires Node.js >= 24. Source code is TypeScript in ./ts/ — tests run directly from source (Node 24 type stripping).

npm test               # Run tests (from ts/ source, no build needed)
npm run build          # Webpack bundle (dist/)
npm run lint           # ESLint
npm run test:coverage  # Coverage report

tsc is only used by the prepare script for npm/git-dep consumers.

Browser test suite: build then run npx backloop.dev ./dist and open https://l.backloop.dev:4443/tests.html