Open akmalmzamri opened 3 months ago
this is pretty great @akmalmzamri ! I am also interested in this for a project of mine, perhaps we can connect if you are also still interested in this? Can you send me a dm on twitter or an email flip[@]shareworks.nl? cheers Flip
Background
This PR will allow users to load schemas from a JSON file when running
generate
command, hence skipping the manual data entry. This will make it easy to move from one project to another that has shared schemasSample usage
Notable changes
-f, --from-file
togenerate
commandsrc/types.d.ts
tosrc/utils.ts
so it can be reused in schema validationbuildSchema
will process array of schemas instead of a single one. ThegenerateResources
will process the schema array one by oneprintGenerateNextSteps
function now process schema array. The output is updated accordinglyInput sample
Here's a sample of a valid
schema.json
(basically the shape ofSchema
)Validation
This PR also comes with the necessary validation such as requiring the table name to be snakeCase. The validation is done by Zod. If errors are present in the schema, Kirimase will stop the execution and log the errors appropriately, such as
Note on using Zod
Since strict mode is not enabled in this project, we will not be able to fully utilize Zod, such as type inferring