@icure/medindex-sdk
Thin TypeScript SDK for iCure's medINDEX REST layer (the Swiss medication reference database,
served by hci-medication-module's standalone Spring Boot module in
hci-medication-importer).
This SDK is deliberately independent of iCure's sdk-codegen/Kotlin-Multiplatform pipeline —
see docs/adr/0001-openapi-based-not-sdk-codegen.md
for why. Types are generated from the standalone server's own OpenAPI spec; the client wrapper
on top is hand-written.
Status
src/types/generated.ts is real openapi-typescript output, generated from a live standalone
server's OpenAPI spec (see openapi.json, a manually-regenerated snapshot).
Do not hand-edit it — re-run npm run regenerate-spec (see
scripts/regenerate-spec.sh) against a live standalone server
whenever the backend DTOs change. src/types/dto.ts is the one hand-maintained file: it aliases
generated.ts's components['schemas'][...] types to the flat names the rest of the SDK uses.
Usage (once published)
import { MedIndexClient } from '@icure/medindex-sdk'
const client = new MedIndexClient({ baseUrl: 'https://medindex.example.com/rest/v2/medindex' })
for await (const product of client.product.iterateByLabel('aspirin', 'de')) {
console.log(product.brandName)
}
Development
npm install
npm run build # tsup -> dist/ (ESM + CJS + .d.ts)
npm test # vitest
npm run typecheck # tsc --noEmit
Error handling
Every failure mode throws a typed error (see src/errors.ts): MedIndexNotFoundError,
MedIndexValidationError, MedIndexServerError, MedIndexNetworkError — all extending
MedIndexError.
Publishing
Tag a commit with a semver tag (vX.Y.Z) on main; the publish GitHub Actions workflow builds,
tests, and publishes @icure/medindex-sdk to npmjs.com as a private (restricted-access)
package under the @icure org — requires npm org membership to install.