/** Loads and caches FHIR StructureDefinitions from bundled, local, and remote sources. */ import { PackageDownloader } from '../package/package-downloader.js'; import { PackageRegistryClient } from '../package/package-registry-client.js'; import type { StructureDefinition } from './structure-definition-types'; import type { ProfileSourcesConfig, ValidationSettings } from '../types'; import type { ProfileSourceContext } from '../persistence'; export { normalizeKnownStructureDefinitionCanonicalUrl } from './sd-loader-version-utils'; export type { StructureDefinition, ElementDefinition, ElementType, Constraint, Binding } from './structure-definition-types'; export declare class StructureDefinitionLoader { private cachePath; private bundledPath; private cache; private availableProfiles; private packageSources; private packageDownloader; private registryClient; private autoDownload; private profileSourcesConfig; private allowedPackages; private packageVersionPins; private initializationPromise; private dbCacheNotFound; private profileNotFound; private profileLoadPromises; private initializationComplete; private pinnedCanonicals; private readonly maxCacheEntries; private readonly externalProfileCacheKeys; private profileSourceContext?; private profileResolutionSettings?; constructor(cachePath: string, bundledPath?: string | null, options?: { autoDownload?: boolean; profileSourcesConfig?: ProfileSourcesConfig; allowedPackages?: string[]; packageVersionPins?: Record; packageDownloader?: PackageDownloader; registryClient?: PackageRegistryClient; maxCacheEntries?: number; }); waitForInitialization(): Promise; /** * Set pinned canonical map from the package resolver. When set, * loadProfile() resolves unversioned URLs to their pinned version * before looking up caches, eliminating runtime ambiguity. */ setPinnedCanonicals(pinned: Map): void; getPinnedCanonicalCount(): number; private initializeCache; /** * Load multiple StructureDefinitions in batch (optimized) * This is 3-5x faster than calling loadProfile() repeatedly */ loadProfilesBatch(urls: string[], fhirVersion?: 'R4' | 'R5' | 'R6'): Promise>; /** * Bind subsequent profile loads to the current validation request. Scoped * validator instances make this stable for the duration of a tenant run. */ setProfileResolutionContext(context?: ProfileSourceContext, settings?: ValidationSettings): void; getProfileResolutionContext(): ProfileSourceContext | undefined; loadProfile(url: string, fhirVersion?: 'R4' | 'R5' | 'R6'): Promise; private pruneProfileCache; private oldestEvictableCacheKey; private loadContext; hasBaseProfiles(): Promise; /** * Synchronously resolve a profile canonical URL to its base FHIR resource type * (e.g. "http://fhir.de/StructureDefinition/ISiKPatient" → "Patient"). * Returns null if the profile is not in the in-memory cache. */ getBaseResourceType(canonicalUrl: string): string | null; isProfileAvailable(url: string): boolean; getAvailableProfiles(): string[]; loadIGPackage(packageId: string, version?: string): Promise; setAutoDownload(enabled: boolean): void; /** * Update which remote sources are allowed for profile resolution. */ setProfileSourcesConfig(config: ProfileSourcesConfig): void; getProfileSourcesConfig(): ProfileSourcesConfig; isAutoDownloadEnabled(): boolean; setAllowedPackages(packages: string[]): void; getAllowedPackages(): string[]; /** * Pin package versions used by auto-download. */ setPackageVersionPins(pins: Record): void; getPackageVersionPins(): Record; /** * Cache a profile from external source (e.g., FHIR client) * This ensures profiles loaded from the FHIR server are reused in subsequent validation runs */ cacheProfile(url: string, profile: StructureDefinition, fhirVersion?: 'R4' | 'R5' | 'R6'): void; private resolvePinnedCanonical; /** * Register an external StructureDefinition with the loader. * * Unlike cacheProfile(), this method caches using the same version-specific * cache key format that loadProfile() uses (`${url}:${fhirVersion}`), so the * registered profile is actually discoverable by the main validation path. * * Used by: * - Conformance test harness (case-runner) to preload supporting profiles * - External callers that want to inject a profile without filesystem/download */ registerExternalProfile(sd: StructureDefinition, fhirVersion?: 'R4' | 'R5' | 'R6'): boolean; clearCache(): void; } //# sourceMappingURL=structure-definition-loader.d.ts.map