Triggering Functions imported from external package


[00:00] So with CourseBuilder we have the consumer apps, right? So these are in apps, and then we have packages, and we have a core package. And the core package carries ingest function pieces, right? So we have these pieces, and one of the things that we want to be able to do is use ingest in the context of core and then distribute those functions as we see fit. So how that is today is over here, we end up with inside of ingest, we have this video processing folder that has all the functions that are related to video processing.

[00:53] These have all been kind of all the dependencies have been separated so fundamentally everything is already coming from core, right? Like, so it's using only packages that exist in core, except for our ingest server. And the issue here is that all this configuration happens in here, right? Like we get all of our events and we get the middleware and then we have to call create function and each one of these pieces, so config trigger, and then the function exists within create function and ultimately to me what this would look like is something like this where you let's see I'll just copy that and I'd say const Ingest config equals that thing, right And then you'd have this, cost ingest trigger, like so. And then kind of the big one here, and you can see it's already lighting up red, right?

[02:25] The big one here is this one, and you'd say, let's ingest. Handler's actually probably pretty good. Paste that in, right? So now we have that one, and we can move that into here. So you end up with this kind of simple stack that actually works pretty decently here the trigger let's see so the trigger throws it off One of the things that I actually like about this and that I've always thought was interesting is because create function takes ordered arguments, this gives you this ability to look at this differently.

[03:17] And then for us, it's like, what interface would this need to have? And then what am I missing here as well? And that probably has some, let's see. And I think this demonstrates kind of the nature of it. So type string is not assignable to type triggers from client ingest, and blibbity blah, right?

[03:40] Like, so what does that mean? And what does that mean in terms of typing these? So what kind of interface can I have and how can I make this aware right like how can I make that aware of the the events that are available maybe right like because when you then pass this in, what I end up losing is obviously all of the typing? So how do I make this trigger and the handler and think about typing here? Is this just an interface for this specific handler?

[04:18] Or is this an interface for this context? How do I create that context through, whether it's generics or whatever I might need to do so that I can pull this out? Because Once this is pulled out, now I have a ton of flexibility. This can live basically anywhere as long as I can pass it a type. We expect you to be this generic type.

[04:42] One way to look at that, just in terms of how we're doing it today, We have this adapter for our database, which is Drizzle. You come in here and there's a course builder adapter type. You get this interface that has these things. This is the level of flatness that would make our life more simple in terms of consuming these things. And then in core you end up...

[05:11] No, that's where this is. And then you end up with a next adapter, basically. So if I come down to next, you get this and it gets specifically typed for this thing. I don't know, that's probably not even relevant. I'm just saying this is, you know, like, so we have multiple packages.

[05:34] I want it to be in core. I want to, events work just fine, but I want to be able to have my functions inside of video processing, inside of core ingest. And then I want to assemble those, like so, as assemble the puzzle pieces over here so that I could just import these. And, you know, like having create function here is actually fine because create function then is going to combine all of that context all the middleware all that stuff on the consumer side