-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: Refactor integration hooks type #11304
Conversation
🦋 Changeset detectedLatest commit: 13e2244 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
.changeset/curvy-otters-jog.md
Outdated
@@ -0,0 +1,18 @@ | |||
--- | |||
'astro': minor | |||
'@astrojs/db': minor |
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.
We should create a new changeset only for @astrojs/db
that shows the migration path of the new type. Since this is a breaking change, I believe this should stand out in the changelog
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.
Just noting that I'll review here when I have a docs PR!
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 is barely even a breaking change for @astrojs/db
though. It breaks something we never said was there (the AstroDbIntegration
type). The helper defineDbIntegration
method shown on the docs continues to work with no changes.
The main difference is requiring the new version of astro
.
But I'll write that up either way
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.
Just leaving a placeholder for docs! When I have a docs PR submitted, I can review it and this!
.changeset/curvy-otters-jog.md
Outdated
@@ -0,0 +1,18 @@ | |||
--- | |||
'astro': minor | |||
'@astrojs/db': minor |
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.
Just noting that I'll review here when I have a docs PR!
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.
Quick review for docs! Looks great, I am mostly suggesting a more "use case" description to kick this off!
Additionally, there is another change in here to @astrojs/db
that will need a corresponding docs update, as this type being removed is currently documented.
It is not documented Sarah, |
@Fryuni Sorry, I thought I checked closely, but I was concerned about this example which you're right, is not the type itself. As long as this example doesn't need updating, then no docs are needed, you're correct! |
Just pinging @Fryuni to look at my changeset suggestions! The Docs PR has already been approved and is ready for next week, so this is just tiny details now! 🙌 |
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
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.
Approving for docs!
* feat: Refactor integration hooks type * Revert formatting changes * More detailed changelog * Add changeset for Astro DB * Apply suggestions from code review Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca> --------- Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
astro
AstroIntegration['hooks']
type into a globalAstro.IntegrationHooks
interface to allow for third-party extensions.As discussed on Discord, this breaks only a very narrow use case that wasn't documented as being supported and relied on the hooks not being extensible in order to create an extension workaround on top of it. So it is not being considered as a breaking change.
@astrojs/db
AstroDbIntegration
type (BREAKING)defineDbIntegration
just so people don't have to change their code for that, it is no longer neededTesting
This doesn't change any runtime behavior
Docs
We can now document how integrations can add their own hooks 😄
Future scope
This PR only allows integrations to declare the types for their hooks; it doesn't provide any higher-level mechanism to trigger those hooks. Triggering them is already possible with the following code:
In the future, we might provide some way for integrations to trigger their hooks with less boilerplate