-
Notifications
You must be signed in to change notification settings - Fork 11
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
Option to omit certain models #32
Comments
In the meantime, I've authored a bruteforce codemod that post-processes generated schemas: export default function transformer(file, api) {
const j = api.jscodeshift
// Remove all but the first VariableDeclaration
let source = j(file.source)
.find(j.VariableDeclaration)
.forEach((path, i) => {
if (i) j(path).remove()
})
.toSource()
return (
source
// Remove blank exports left behind by the above transformation
.replace(/export {};/g, '')
// Collapse multiple empty lines to one
.replace(/\n\n+/g, '\n\n')
)
} Usage: npx jscodeshift -t path/to/this/file.js --extensions=ts --parser=ts path/to/generated/schemas |
Are you open to an API option for this (or accepting a PR for it)? I think the simplest API here would be an array of strings representing the models you want to opt in, defaulting to everything being included. You could use that one api to then deprecate the If not, given that I have a clear workaround, I'm happy to close the issue. |
Hi, sorry for the delayed response, got a lot to do right now. I'd be happy to review a PR. Could you give a quick example on how an example usage for various scenarios of your proposed solution would look like? Thanks for your effort! |
No worries - I'd suggest an array of string representing all of the options you support. I pulled this list from https://github.com/m1212e/prismabox/blob/main/src/index.ts#L40-L53 includeModels = [
"enums",
"plain",
"relations",
"where",
"whereUnique",
"plainInputCreate",
"plainInputUpdate",
"relationsInputCreate",
"relationsInputUpdate",
"select",
"include",
"orderBy",
] Then in that index file, just check if Some ideas of additional things you could support:
|
Thats nice. I like that idea! |
Hi there! First off, thanks for this very useful library.
I'm looking to use this to automate the construction of Typebox types in the context of a feathers app and so I don't need anything but the plain models. I'm also unfortunately forced to use an older version of Typebox which doesn't support things like
Composite
(so I can't just ignore the other types and need to proactively edit the generated files). I see the input model option, but is there a way to only generate the plain models? From what I can tell, it looks like this would be an easy option to add here if not already supported:https://github.com/m1212e/prismabox/blob/main/src/index.ts#L40-L53
The text was updated successfully, but these errors were encountered: