-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FHIR Package Loader Rewrite #42
Conversation
- Refactored package loader w/ interfaces for db, registry, current, cache, and loader - SQL Lite JS database implementation for package and resource metadata - FHIR, NPM, and build.fhir.org registry client implementations - Diskbased cache for accessing the local .fhir cache - BasePackageLoader implementation that ties them all together
* Add tests for SQLJSPackageDB Test the save, find, stats, and clear class methods. No tests are added for the logging methods. Minor styling changes in some other files, as applied by prettier. * Make test for SQLJSPackageDB.findResourceInfo stricter Check properties of the returned resource to make sure it matches one of the expected results. Remove unneeded comment from saveResourceInfo test. * Expect last added resource from findResourceInfo
- Remove FHIRDefinitions - Remove load function - Remove old API (fpl function) - Remove other unused errors, classes, and functions - Update app.ts to use new classes - Update README
* Update dependencies Add eslint config file based on requirements for updated eslint dependencies. Remove @types/tar dependency because types are now included in the tar dependency. Minor usage updates for tar and commander based on changes to package export. Minor fixes for linting rules. * Update node types to latest 20.x version Other packages with recent minor updates are also updated. No change to the packages in dependency notes.
- BasePackageLoader tests - DefaultPackageLoader tests - Additional json files used taken from fpl and sushi
- Fix spy usage in BasePackageLoader tests - Add BasePackageLoader tests for more coverage - Add DefaultPackageLoader tests - Change log message on successful package load to use the actual loaded version, which may be different than the requested version.
Various changes to better support the needs of SUSHI while remaining neutral for other environments and applications. Including: * VirtualPackage interface for pseudo packages not in the registry or local FHIR cache * DiskBased and InMemory implementations of Virtual Package * Support for loading VirtualPackages in the BasePackageLoader * Support for '|version' when searching by key * New exportDB function in SQLJSPackageDB and BasePackageLoader for debugging purposes * New --export flag in CLI app to export a SQLite DB file from the loaded packages * Added sort to find functions' options, with initial ByLoadOrder and ByType implementations (the original type argument is now just a filter, no longer affecting sort) * Added resolveVersion function to RegistryClient interface and corresponding implementations * Moved LRU cache from DiskBasedPackageCache to BasePackageLoader * getPackageInfos returns all loaded package infos when search key is '*' * BasePackageLoader returns helpful tips about SSL certificates and proxies when error is due to self-signed certificates * SafeMode option with values OFF, CLONE, and FREEZE * Optimize queries and indices * Expose database optimization function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really great! This was my first time really digging into this rewrite, and this really breaks out all the separations of concerns and nicely brings them all together for the implementation for SUSHI. I left a few small comments, but none of them are big changes of anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's finally here! The big FPL refactor! @jafeltra already caught most everything I noticed, but there was one minor discrepancy in the readme that I want to point out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for making all those changes! 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hooray for new FPL!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reapproving for such nicely sorted imports! 💯 💯
Description: And now for something completely different...
This PR represents a total rewrite of the FHIR Package Loader -- with completely new interfaces, implementations, and APIs. This rewrite was necessary to address limitations in the package loader as well as support future use cases (such as transitive dependencies, multiple versions of the the same package, etc).
The new FHIR Package Loader now utilizes an in-memory database (currently sql.js) to store and query metadata about packages and their resources. This reduces memory usage per-resource since now only the metadata is kept in memory (vs the entire JSON object). With more efficient memory usage, we can now load all resources from the package (instead of just conformance resources) and we will also be able to load transitive packages in the future.
Separate concerns of the package loader have been separated out into their own interfaces and implementations, including:
PackageDB
interface w/SQLJSPackageDB
implementation. Note that sql.js was chosen due to its support for synchronous queries -- which causes the least disruption to SUSHI (which has many synchronous functions).RegistryClient
interface w/FHIRRegistryClient
,NPMRegistryClient
,RedundantRegistryClient
, andDefaultRegistryClient
implementationsCurrentBuildClient
interface w/BuildDotFhirDotOrgClient
implementationPackageCache
interface w/DiskBasedPackageCache
implementationVirtualPackage
interface w/DiskBasedVirtualPackage
andInMemoryVirtualPackage
implementationsPackageLoader
interface w/BasePackageLoader
implementation that accepts implementations of the previous interfaces and ties them together for a complete package loading solution.This approach allows for additional capabilities in the future, such as implementations that work well in web browsers.
Testing Instructions:
NOTE: Much of this PR contains code that was previously reviewed before merging into the
new-fpl
feature branch. Those reviews, however, typically only involved one reviewer -- and some of the initial code never went through a PR. So... review and test accordingly.Related Issue: Implements #30.