ubiquity-os / ubiquity-os-kernel

1 stars 13 forks source link

Type Guarding #10

Closed 0x4007 closed 1 month ago

0x4007 commented 8 months ago

We should design a "type guard funnel" where the webhook receiver function goes in this order:

  1. Any object being passed in [^1^]
  2. Any GitHub webhook event types [^2^]
  3. Any GitHub webhook event subtype [^3^]

This will greatly simplify dealing with types when writing the business logic (the event handlers.) I am not totally sure if we can skip step 2. but for now I'll leave it in.

I started implementing here, although it is not functional: ubiquibot-kernel/handlers/handlers.ts. I am struggling to identify the correct types and getting this funnel to work.

[^1^]: in the future we can support Telegram events in tandem with GitHub events. I'm not totally sure if its a good idea to merge the two, but it will be more clear when we complete the connection/integration/bridge between the Telegram bot and the GitHub bot. However I can certainly see benefits having access to the same commands from both the Telegram bot private message interface, and the public GitHub issue comment interface, which leads me to believe that combining the codebase can be beneficial. [^2^]: defined in Octokit, e.g. issue_comment [^3^]: e.g. issue_comment.created

0x4007 commented 8 months ago

@whilefoo I need your help here!

ubiquibot-dev[bot] commented 1 month ago
# Issue was not closed as completed. Skipping.