Cognovis FHIR SDK API reference
Generated from the TypeScript declarations published in @cognovis/fhir-sdk 0.35.0, the version the npm dist-tag latest named at render time. Cognovis FHIR SDK · All SDKs.
Entry points
- @cognovis/fhir-sdk
- @cognovis/fhir-sdk/client
- @cognovis/fhir-sdk/node
- @cognovis/fhir-sdk/dental
- @cognovis/fhir-sdk/dental-core
- @cognovis/fhir-sdk/r4
- @cognovis/fhir-sdk/release-profiles
- @cognovis/fhir-sdk/release-compatibility
- @cognovis/fhir-sdk/terminology
- @cognovis/fhir-sdk/canonicals
- @cognovis/fhir-sdk/bootstrap
@cognovis/fhir-sdk/bootstrap
- bootstrapStore function
- BootstrapDigestMismatchError class
- BootstrapDownloadTooLargeError class
- MAX_TARBALL_BYTES const
- BootstrapFetchError class
- BootstrapInstallError class
- BootstrapUnsafeResourceError class
- BootstrapUnverifiableError class
- headersForUrl function
- writePathFor function
- BootstrapOptions interface
- BootstrapResult interface
- PackageOutcome type
- TarballFetcher type
- COGNOVIS_REGISTRY const
- EXTERNAL_SNAPSHOT_SKIP_REASON const
- PUBLIC_FHIR_REGISTRIES const
- resolveRegistryUrls function
- skipReason function
- unknownOriginSkipReason function
- ZTS_SKIP_REASON const
- loadInstalledManifest function
- ClosureEntry interface
- PackageOrigin type
- ReleaseManifest interface
- CONFORMANCE_RESOURCE_TYPES const
- MAX_TAR_ENTRIES const
- MAX_UNCOMPRESSED_BYTES const
- readConformanceResources function
- readTarEntries function
- sha256Hex function
- TarballFormatError class
- ConformanceResource interface
bootstrapStore function
Installs the release closure into a standard FHIR server. Packages that must not be redistributed are skipped with a recorded reason, every fetched tarball is verified against the digest the manifest pins, and each package is reported as installed, skipped or failed.
function bootstrapStore(options: BootstrapOptions): Promise<BootstrapResult>;
BootstrapDigestMismatchError class
Thrown when a fetched tarball does not match the digest the manifest pins.
class BootstrapDigestMismatchError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly packageId: string;
readonly expected: string;
readonly actual: string;
constructor(packageId: string, expected: string, actual: string);
}
BootstrapDownloadTooLargeError class
Thrown when a registry response exceeds the documented download ceiling.
class BootstrapDownloadTooLargeError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly url: string;
constructor(url: string, observed: number | null);
}
MAX_TARBALL_BYTES const
Largest package tarball this SDK will download. The largest package in the release closure, hl7.fhir.r4.core@4.0.1, is about 12.8 MB compressed, so this leaves a factor of five of headroom while bounding what a hostile or broken registry can make a consumer buffer. The ceiling is enforced before the digest is computed, because the digest gate only protects what has already been read.
const MAX_TARBALL_BYTES: number;
BootstrapFetchError class
Thrown when no configured registry served a package.
class BootstrapFetchError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly packageId: string;
readonly attempted: readonly string[];
constructor(packageId: string, attempted: readonly string[], cause: unknown);
}
BootstrapInstallError class
Thrown when a conformance resource could not be written to the server.
class BootstrapInstallError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly packageId: string;
constructor(packageId: string, resource: ConformanceResource, cause: unknown);
}
BootstrapUnsafeResourceError class
Thrown when a resource inside a package tarball carries a value that must not be interpolated into a request path. A digest pin attests that the bytes are the ones the release pinned; it says nothing about whether their content is benign. Anything from the archive that ends up in a URL is therefore validated before the write.
class BootstrapUnsafeResourceError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly packageId: string;
readonly resourceType: string;
constructor(packageId: string, resourceType: string, reason: string);
}
BootstrapUnverifiableError class
Thrown when a closure entry carries no digest to verify its bytes against.
class BootstrapUnverifiableError extends Error {
readonly code: import("../index.js").FhirSdkErrorCode;
readonly packageId: string;
constructor(packageId: string);
}
headersForUrl function
Headers that may travel to one specific URL. Credentials are scoped to the registry they belong to: only a URL on the Cognovis registry receives the configured headers, every other host receives none.
function headersForUrl(url: string, cognovisRegistryHeaders: Readonly<Record<string, string>> | undefined): Readonly<Record<string, string>>;
writePathFor function
Returns the path a resource is written to, or throws when the resource carries a value that must not appear in a URL.
function writePathFor(packageId: string, resource: ConformanceResource): {
method: 'PUT' | 'POST';
path: string;
};
BootstrapOptions interface
Configuration of a bootstrap run.
interface BootstrapOptions {
/** Transport writing to the target FHIR server. */
readonly transport: FhirTransport;
/**
* The closure to install. Defaults to the closure of the installed
* `@cognovis/fhir-release` package.
*/
readonly closure?: readonly ClosureEntry[];
/** Restricts the run to these package ids. */
readonly only?: readonly string[];
/** Tarball fetcher. Defaults to `fetch`. */
readonly fetchTarball?: TarballFetcher;
/**
* Extra headers for requests to the Cognovis registry, typically the
* authorization header carrying the registry token.
*
* These headers are sent to `COGNOVIS_REGISTRY` and to nothing else. Public
* FHIR registries are third-party hosts, and a Cognovis credential has no
* business reaching them.
*/
readonly cognovisRegistryHeaders?: Record<string, string>;
/**
* When true, the first failing package aborts the run with its typed error
* instead of being recorded as a failed outcome.
*/
readonly failFast?: boolean;
}
BootstrapResult interface
Outcome of a complete bootstrap run.
interface BootstrapResult {
readonly packages: readonly PackageOutcome[];
readonly installed: number;
readonly skipped: number;
readonly failed: number;
}
PackageOutcome type
Outcome of one closure package.
type PackageOutcome = {
readonly packageId: string;
readonly version: string;
readonly status: 'installed';
/** The registry URL the bytes came from. */
readonly registry: string;
readonly resourceCount: number;
} | {
readonly packageId: string;
readonly version: string;
readonly status: 'skipped';
readonly reason: string;
} | {
readonly packageId: string;
readonly version: string;
readonly status: 'failed';
readonly error: string;
};
TarballFetcher type
Fetches the bytes of a package tarball from a registry URL. `headers` is what may be sent to that specific URL. It is empty for every registry other than the Cognovis one, so a custom fetcher cannot widen the audience of a credential by accident.
type TarballFetcher = (url: string, headers: Readonly<Record<string, string>>) => Promise<Uint8Array>;
COGNOVIS_REGISTRY const
The Cognovis npm registry, which serves the private Implementation Guides.
const COGNOVIS_REGISTRY = "https://npm.cognovis.de";
EXTERNAL_SNAPSHOT_SKIP_REASON const
Reason recorded for packages pinned to a lock snapshot instead of a version.
const EXTERNAL_SNAPSHOT_SKIP_REASON = "Pinned to a release lock snapshot rather than to a published registry version; no registry serves these bytes.";
PUBLIC_FHIR_REGISTRIES const
The public FHIR package registries, in the order they are tried.
const PUBLIC_FHIR_REGISTRIES: readonly ["https://packages.fhir.org", "https://packages2.fhir.org/packages", "https://packages.simplifier.net"];
resolveRegistryUrls function
Returns the candidate tarball URLs for a closure entry, in the order they should be tried. An empty list means the package must not be fetched.
function resolveRegistryUrls(entry: ClosureEntry): string[];
skipReason function
Returns why a closure entry is skipped, or `null` when it is installable. An unrecognised origin is skipped rather than guessed at, and says so: giving it the external-snapshot reason would have misreported why it was skipped.
function skipReason(entry: ClosureEntry): string | null;
unknownOriginSkipReason function
Reason recorded for an origin this version of the SDK does not know.
function unknownOriginSkipReason(origin: string): string;
ZTS_SKIP_REASON const
Reason recorded for every package a terminology service licenses.
const ZTS_SKIP_REASON = "Licensed terminology package: its bytes are fetched from the terminology service by the operator and are never mirrored, bundled or redistributed by this SDK.";
loadInstalledManifest function
Returns the manifest pinned by this SDK release. The default manifest is a static dependency so bundlers can include it in a standalone executable. Pass `fromDir` to resolve and read an installed `@cognovis/fhir-release` package from a specific directory instead. @param fromDir - Optional directory from which to resolve the release package. When omitted, returns the exact manifest pinned by this SDK.
function loadInstalledManifest(fromDir?: string): ReleaseManifest;
ClosureEntry interface
One package of the release closure.
interface ClosureEntry {
readonly packageId: string;
readonly version: string;
readonly origin: PackageOrigin;
/** How the entry was pinned, for example `registry` or `lock-snapshot`. */
readonly source?: string;
/** Digest of the package tarball, hex-encoded, or `null` when unpinned. */
readonly sha256?: string | null;
}
PackageOrigin type
Where the bytes of a closure package legitimately come from.
type PackageOrigin = 'private' | 'public' | 'zts' | 'external-snapshot' | (string & {});
ReleaseManifest interface
The parts of the release manifest the bootstrap depends on.
interface ReleaseManifest {
readonly closure: readonly ClosureEntry[];
readonly closureDigest?: string;
}
CONFORMANCE_RESOURCE_TYPES const
Resource types installed by the bootstrap. `ImplementationGuide` is deliberately absent: it is packaging metadata whose `definition.resource.reference` entries point at the examples of the guide, which a server that enforces referential integrity rejects on write. Nothing in validation or terminology resolution depends on it.
const CONFORMANCE_RESOURCE_TYPES: readonly ["CapabilityStatement", "CodeSystem", "CompartmentDefinition", "ConceptMap", "NamingSystem", "OperationDefinition", "SearchParameter", "StructureDefinition", "StructureMap", "TerminologyCapabilities", "ValueSet"];
MAX_TAR_ENTRIES const
Largest number of entries a package archive may contain. The same package has about 5,000 entries.
const MAX_TAR_ENTRIES = 50000;
MAX_UNCOMPRESSED_BYTES const
Largest uncompressed archive this SDK will decompress. The largest package in the release closure, hl7.fhir.r4.core@4.0.1, expands to about 49 MB, so this leaves roughly a factor of five of headroom while still bounding a decompression bomb.
const MAX_UNCOMPRESSED_BYTES: number;
readConformanceResources function
Extracts the conformance resources of a FHIR package tarball. Non-JSON entries, package metadata (`package.json`, `.index.json`), anything under an `example/` directory, and resources outside `CONFORMANCE_RESOURCE_TYPES` are ignored.
function readConformanceResources(tarball: Uint8Array): ConformanceResource[];
readTarEntries function
Iterates the regular file entries of an uncompressed tar archive. Every header is checksum-verified, every size is bounded by what is left of the archive, and the cursor is asserted to advance, so a crafted header cannot make the parser walk backwards or loop.
function readTarEntries(archive: Uint8Array): Array<{
name: string;
content: Uint8Array;
}>;
sha256Hex function
Hex-encoded SHA-256 digest of the given bytes.
function sha256Hex(bytes: Uint8Array): string;
TarballFormatError class
Thrown when an archive does not parse as a well-formed tar or gzip stream, or exceeds a documented limit. The bootstrap treats archive bytes as untrusted input even after the digest gate: a digest attests that these are the pinned bytes, not that they are benign.
class TarballFormatError extends Error {
constructor(reason: string);
}
ConformanceResource interface
A conformance resource read from a package tarball.
interface ConformanceResource {
readonly resourceType: string;
readonly id?: string;
readonly url?: string;
readonly [key: string]: unknown;
}