Tool which generates a typescript client for SurrealDB and zod schema of a given database
When using the `-f` option to specify a schema file in surql-gen, the tool sometimes generates Zod schemas for all tables in the SurrealDB instance rather than limiting its scope to the tables defined in the specified schema file. This behavior is not consistent with the expected functionality, which should only focus on the schema provided in the specified file. ## Description Even when a specific schema file is provided with the `-f` option, the tool retrieves information for all tables in the SurrealDB instance using `getAllTableInfo()` and generates Zod schemas for all of them instead of only the subset of tables intended for processing (if applicable). ## Expected Behavior The tool should limit its schema generation to only the tables defined in the provided schema file when the `-f` option is used. ## Potential Fix 1. Track Tables from the Schema File: - Parse the schema file to identify which tables are defined or updated. ```js const getTablesFromSchemaFile = (schemaContent: string): string[] => { const tableRegex = /DEFINE\s+TABLE\s+(\w+)/g; const tables = []; let match; while ((match = tableRegex.exec(schemaContent)) !== null) { tables.push(match[1]); } return tables; }; ``` 2. Filter `getAllTableInfo()`: - Modify the logic to filter the results of `getAllTableInfo()` to include only the tables that were defined or updated by the schema file. - Use result from above to filter results of `getAllTableInfo()`
This issue appears to be discussing a feature request or bug report related to the repository. Based on the content, it seems to be resolved. The issue was opened by jascenc1 and has received 9 comments.