Skip to content

Commit db894d0

Browse files
committed
chore: add custom command to generate types from supabase autogen
1 parent 40a6210 commit db894d0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
You are a skilled TypeScript developer tasked with creating a library of DTO (Data Transfer Object) types and a Command Model for the application. Your task is to analyse the database model definition, and then create appropriate DTO types that accurately represent the data structures required by the API, while maintaining the connection to the underlying database models.
2+
3+
First, carefully review the following input data:
4+
5+
<database_models>
6+
@database.types.ts
7+
</database_models>
8+
9+
Your task is to create TypeScript type definitions for the DTO and Command Models, ensuring that they are derived from the database models. Follow these steps:
10+
11+
1. Analyse the database models.
12+
2. Create DTO and Command Model types, using the database entity definitions.
13+
3. Ensure consistency between DTO and Command Models.
14+
4. Use appropriate TypeScript features to create, narrow, or extend types as needed.
15+
5. Perform a final check to ensure that all DTOs are included and correctly linked to entity definitions.
16+
17+
Before creating the final output, work inside the <dto_analysis> tags in your thinking block to show your thought process and ensure that all requirements are met. In your analysis:
18+
- List all DTOs and Command Models, numbering each one.
19+
- For each DTO and Command Model:
20+
- Identify the relevant database entities and any necessary type transformations.
21+
- Describe the TypeScript functions or tools you plan to use.
22+
- Create a brief outline of the DTO and Command Model structure.
23+
- Explain how you will ensure that each DTO and Command Model is directly or indirectly linked to the entity type definitions.
24+
25+
After completing your analysis, provide the final definitions for the DTO and Command Model types that will appear in the src/types.ts file. Use clear and descriptive names for your types and add comments to explain complex type manipulations or non-obvious relationships.
26+
27+
Remember:
28+
- Make sure that all DTOs and Command Models are included.
29+
- Each DTO and Command Model should directly refer to one or more database entities.
30+
- Use TypeScript features such as Pick, Omit, Partial, etc. as needed.
31+
- Add comments to explain complex or non-obvious type manipulations.
32+
33+
The final result should consist solely of the DTO and Command Model type definitions that you will save in the src/types - create new files and/or update existing files, without duplicating or re-doing any work done in the thinking block.

0 commit comments

Comments
 (0)