Open radhay-1199 opened 1 year ago
hi @radhay-1199 So rather than using the Templator as an API we want to move towards making it a Nest.js module and then directly use it to call our methods right?
i do have a question though even if we do this we still will have to keep our document handling code right? we can't get rid of it all like it was stated in the issue #121 to remove custom logic templator does provide storing and creation of templates along with data transfomation , so can rather just create the module and then using the methods of Templator abstract the part where we use Templator for generation
@varun7singh yes you are right we need to expose the existing templator service as a module for this doc gen so that it can be used k internally. Or we can publish a sdk for templator so that it can be used across.
right @radhay-1199 could you clear my other dobut regarding the custom logic
what i really mean to say is we can abstract the code from the custom logic where Templator is used but is there anything else we could?
One thing i have in my mind is that we can handle the custom logic in another module which deals with the input handling and use the templator methods there this would significantly clean up code for generating documents.
Thanks!!
@varun7singh if you decide to expose templator as a module of nest js you will have to migrate the dependent tables of templator too in doc generator. You are right that we will can abstract out the part where templator handling is done as a separate utility and perform those actions from there. I meant the same thing when i said exposing templater APIs as sdk as it will help in using these apis directly from code
Yeah you're right sdks would help here
@varun7singh you can go thorugh this repo for templator. Set this up locally. LMK if you need any clarity.
@radhay-1199 i did go throught the repo so just for clarity i'll state it again so we essentially do want to publish Templator as npm package or sdk and then use the various methods availabe to us in Doc-Gen right?
similarly in Templator we could create a service similar to the functionality the endpoints provide eg /process and then inject that service in Doc-Gen where required right or the other way like create a new templatorService in Doc-Gen and use all Templator methods there to provide the same functionality and then inject this service to generate Documents
Thanks!!
SOmewhaT yes..!!! 🛸 So what I meant was even if you create a module out of the current templator various modules in doc generator may be using this module. So if we expose our APIs as SDK in this module then every other module in the doc gen (i.e PDF generation module, docx generation module, etc) can use the same methods of SDK. Since we are on typescript we can define the common request and response objects of these SDKs and it will be type-safe throughout.
Okay great!! Thanks a ton
Okay so further reading it seems to me we can easily utilize the Nest.js libraries to allow templator as a local dependency here then in docgen we can create a module named templatorModule and utilize the methods by calling the methods from the library?
i thought of building a npm package and publishing it to the registry but this seems to be simplistic and efficient
Does this approach seem feasible? @radhay-1199 Also can we discuss how the migrations will be affected here? Thanks!!
@varun7singh I think making Templater a nest.js library would take significant effort because it's a complete application in itself, you'd have to extract a library out of it. Now coming on to migrations, it can be solved using multiple database setups one db for Templater and one for doc-gen. That's my take.
@yuvrajsab So essentially we want to create a module in templater which can be used in DocGen my question is should we continue storing the templates in the Templater DB or we should we should use DocGen's DB here?
@varun7singh We will leverage the templater service for creating templates and that service will store the templates in its Db only.
@yuvrajsab could you do me a favor and read through this link
Also currently the previous codebase of DocGenerator used the generateByTemplate method and it took the template id as input i feel rather than this for better ui/ux we can grab all the templates stored from the service above and display them to the user to use?
Refactor the Templater component of the doc generator service into a separate NestJS module. This modularization will make it easier to embed and utilize the Templater module within the main service. Additionally, explore the possibility of using a GitHub Submodule to manage the integration of the Templater module.