-
Notifications
You must be signed in to change notification settings - Fork 80
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
Allow for custom events in receive()
without warning
#277
Comments
If possible, I'd like to avoid adding a new API such as
I'm not sure how that would possibly work. const webhooks = new Webhooks({
customEvents: ['custom1','custom2']
}) In terms of TypeScript, I'm not so sure. I guess we could add a type variable type CustomEvent1 = { name: "custom1", payload: { /* ... */ } }
type CustomEvent2 = { name: "custom2", payload: { /* ... */ } }
type CustomEvents = CustomEvent1 | CustomEvent2
const webhooks = new Webhooks<CustomEvents> ({
customEvents: ['custom1','custom2']
}) But I wonder if there is a more elegant solution.
Update: nevermind the event plugin thinking. It's quite different and will likely happen on a different level.
So far that was not a problem, we do have automated updates in place, and we could expand it to all recent breaking versions, so even people stuck in v5, v6, etc could still get all supported event names out of the box. |
@bcoe what do you think about this API type CustomEvent = {
name: "custom";
id: string;
payload: {
/* types for your possible payloads */
};
};
const webhooks = new Webhooks<CustomEvent>({
customEvents: ["custom"],
});
webhooks.on("custom", (event) => {
// get full type testing and intellisense for `event`
}); No idea how exactly this would work, but I think it could :D |
@gr2m sorry for the slow response. I think something like this would be great, could we potentially provide it to the upstream API via a plugin, then perhaps I could configure it with the octokit instance. |
I think there is a better approach that doesn't require a type argument, see my comment here: #250 (comment) |
Problem
We've gotten into the habit of using a few custom events in our bot infrastructure (you can see the approach in action here).
The latest version of
probot
is stricter about the events accepted, so we ended up needing to do something like this:I believe this approach works, but we receive a warning.
Proposed Solution
It would be great to have another method, e.g.,
receiveLoose
, orreceiveUnchecked
, which:string
rather than aEventNames.StringNames
.Beyond folks like us, who've written some of our own custom events, I believe this would create value for folks who are pinned on older versions of the library, when/if new event types are added to the GitHub API.
The text was updated successfully, but these errors were encountered: