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
[Feature Request] Plugin System #562
Comments
Hi @fimion! As I'm basically in maintenance & PM mode for oazapfts currently I don't think I can be of much help but when you're interested in leading this I'd be more then happy to assist in design and review 👍 |
My gut-feeling is that the codebase is not in the greatest shape to be hooked into. So this might bring some long needed refactors with it. But before working on actual code, let's discuss the points you already brought up |
It's understandble to want to not just jam this in. Plugin RegistrationI'm imagining from a generator cli end user standpoint that we would provide a command line argument that would let you point to multiple scripts that would be able to register at start up. From a development perspective, I'd have these scripts need an object as default export that would have a predefined shape to them with potential methods attached that could hook into the various parts. We could expose a method to help with the type definitions as well as potentially do some run time checks? a plugin file would ultimately look something like this: import { defineOazapftsPlugin } from "oazapfts/codegen";
export default defineOazapftsPlugin({
// Various methods and or properties here
}); Initial Registration pointsFrom an outside developer perspective (who has not fully studied the code), here are some initial places i could see allowing people to hook into stuff
I feel like with this amount of access, there would be good opportunity to modify things as needed. |
Will look at this tomorrow and give feedback 🤙 |
Cool! This makes a lot of sense to me 👍 Additional hooks I imagine helpful:
In general I wonder If we might be able to create a backbone architecture that takes a OAS object in und calls plugins for the single steps required to create an API client. (We'll probably also need some shared context/state) Maybe we can then refactor Regarding the plugin registration on the CLI level I'm a little torn between args But whatever the case, those would eventually land as imported objects in the This is exiting! Looking forward to this 🤙 |
Alright, i'm gonna start digging into some of this today. |
I've made a first pass at what the definition of a plugin would look like based on this discussion, but have not yet started adding the actual implementation of the hooks for this into the existing system. (figured I'd wait to make sure i'm headed in the right direction). The next step would be to move the current functionality over to use this "lifecycle hook" based system possibly. |
in order to move towards a more functional and modular architecture move state that previously was helt on Generator class to a context the idea behind this is to pass the context object around between internal units as well as plugin callbacks and all shared state would be managed on the context object ref #562
in order to move towards a more functional and modular architecture move state that previously was helt on Generator class to a context the idea behind this is to pass the context object around between internal units as well as plugin callbacks and all shared state would be managed on the context object ref #562
in order to move towards a more functional and modular architecture move state that previously was helt on Generator class to a context the idea behind this is to pass the context object around between internal units as well as plugin callbacks and all shared state would be managed on the context object ref #562
Had a few more thoughts to this. We should keep in mind that the codegen also has a "library" API -> you don't need to use it from CLI but can also directly call it in a build script. This means:
import { generateSource, definePlugin } from 'oazapfts';
type MyCustomPluginOpts {
petThePanda: boolean;
}
const myPlugin = definePlugin<MyCustomPluginOpts>((hooks) => { /* ... */ });
const api = await generateSource(mySpec, { plugins: [myPlugin], petThePanda: true }); Not sure if this is the ideal way to get there nor if it's even feasible but I hope it illustrates my point. With this in mind It might maybe also make sense to create an abstraction on top of minimist for the plugins where we require this: definePlugin<MyCustomPluginOpts>(
{
cliArgs: {
petThePanda: {
name: 'panda', // would default to kebab('petThePanda')
type: "boolean",
alias: ["p"],
description: "wether the API should pet the panda or not"
}
}
},
(hooks) => {}
); |
Yeah, i see what you are saying. have a bit of a head cold today, so i'll spend some time pondering this. we will need to change it so that |
Hi @fimion Made quite some progress on #584. I have started to prepare some of the hook-in points in the new There are still some other things to refactor. Will look into that when I find my next batch of time for this.
|
We might also want to get a closer look at what |
Hey @fimion just want to check in with you on this. I have been unavailable for the past two months but would like to try to move the current WIP to a stable release now. Are you still interested in helping out with the plugin setup? I'm a little torn between moving forward and potentially moving into parts where you already have plans or waiting for you to chime in. Let me know if you have a preference on how we should continue. |
I too have been somewhat unavailable the last couple of months and my schedule is gonna be pretty packed until late may. I would say go ahead an proceed how you would like, and i'll see if i can jump in and help where i can. |
Awesome! Will do. All the best for your upcoming projects 🤙 |
Based on #293 and #341 and my own interests (I want to decorate the generated functions), I would like to formally open a feature request for a Plugin System for the oazapfts code generation.
The initial points we should probably define are:
I'm more than happy to lead the charge on this.
The text was updated successfully, but these errors were encountered: