-
Notifications
You must be signed in to change notification settings - Fork 0
feat(di)!: a module declares what it expects from outside #86
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9dce3cb
feat(di)!: a module declares what it expects from outside
btravers 08bd611
feat(starters)!: every module in the packages names its needs
btravers 0e728e1
feat(examples)!: a slice says which ports come from the root
btravers 6f964fa
docs: a need is declared, never absorbed
btravers dac49f8
fix(docs): the needs sweep broke a table row and nine prose lines
btravers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| "@btravstack/contract": minor | ||
| "@btravstack/di": minor | ||
| "@btravstack/config": minor | ||
| "@btravstack/core": minor | ||
| "@btravstack/testing": minor | ||
| "@btravstack/observability": minor | ||
| "@btravstack/http": minor | ||
| "@btravstack/temporal": minor | ||
| "@btravstack/amqp": minor | ||
| --- | ||
|
|
||
| A module declares what it expects from outside | ||
|
|
||
| `Module(name)({ … })` takes a fourth list, `needs`, and a port the module | ||
| depends on but neither provides nor imports must be named there. Anything it | ||
| owes and does not name is refused at that call, with the port in the message: | ||
|
|
||
| ``` | ||
| Property '"UNDECLARED NEEDS — name it in `needs`"' is missing in type | ||
| '{ provides: [...]; exports: [...]; }' but required in type | ||
| '{ readonly "UNDECLARED NEEDS — name it in `needs`": Logger; }'. | ||
| ``` | ||
|
|
||
| Before this, a need nothing local satisfied simply travelled to whoever | ||
| composed the module, and a composition root could satisfy an imported module's | ||
| dependency without that module ever mentioning it — measured: a slice's | ||
| provider received the root's service while importing nothing at all. A slice | ||
| directory could not be read on its own. | ||
|
|
||
| `needs` is the explicit stand-in for NestJS's `@Global`, which this container | ||
| does not have and now does not need: the port is named, the supplier is not, so | ||
| the slice still composes into any root that answers it. | ||
|
|
||
| `Scope` is exempt — nothing can provide it, and the entry point discharges it. | ||
| `Env` is not: every module that reads the environment says `needs: [Env]`, and | ||
| so does every module that imports one, up to the root `start` hands one to. | ||
|
|
||
| The three starter sugars — `HttpModule`, `AmqpModule`, `TemporalModule` — take | ||
| `needs` too and re-declare the gate over their augmented tuples, so a | ||
| composition root written with a sugar is checked exactly like a bare | ||
| `Module(name)`. | ||
|
|
||
| `@btravstack/di` additionally exports `NeedsGate` and `Unmet`, which a package | ||
| offering its own shaped module needs in order to re-declare the gate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.