-
Notifications
You must be signed in to change notification settings - Fork 16
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
Refactor Account API support and container management #556
Conversation
src/cli.mjs
Outdated
const argvInput = _argvInput; | ||
const logger = container.resolve("logger"); | ||
const parseYargs = container.resolve("parseYargs"); | ||
const logger = _container.resolve("logger"); |
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.
rename to container
? the declaration these used to conflict with no longer exists
/** | ||
* Standardizes the region of a database path. | ||
* | ||
* @param {string | undefined} databasePath - The database path to standardize. | ||
* @returns {string | undefined} The standardized database path. | ||
* @throws {TypeError} If the database path is not a string. | ||
*/ |
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.
if this also confirmed the rg was valid, it could save us a lot of distributed correctness checks. thoughts?
Problem
While working on #554 to support v2 Account API endpoints, a few sharp edges emerged:
run
, which makes it impossible to test library code directlyaccount.mjs
andfauna-account-client.mjs
.Solution
While this could have been at least 2 separate PRs (container changes first, then api client changes), I didn't discover this problem until testing the API changes. If reviewing this is too bothersome, I can break them apart.
The major changes include:
FaunaAccountClient
class into set of api methods exported asaccountAPI
:account.mjs
andfauna-account-client.mjs
have effectively been merged intoaccount-api.mjs
. This module contains all the API endpoints we currently support in the CLI as well as helpers to handle Account API responses.version
to the fetch helper in the module../config/container.mjs
: In order to test library code directly, we need to be able to set the container outside ofrun
contexts. By moving the container singleton into a different module with a setter,setContainer
, we can easily manage dependency resolution in tests outside ofrun
executions.Places to pay attention:
./config/container.mjs
./lib/account-api.mjs
./cli.mjs
./test/mocha-root-hooks.mjs
Everything else is mostly import changes or test changes.
Result
You can now call v1 and v2 endpoints. Additionally, the account API interface has been simplified to be:
Testing
All impacted code paths have either a) new tests or b) updated tests.