Skip to content
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

feat(store): remove name config option from tables #818

Merged
merged 7 commits into from
May 15, 2023
Merged

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented May 14, 2023

Depends on #815

  • The name config option for tables was more confusing than useful. With it we had two ways of setting the "name" of a table: 1. via the table config's key in the tables config, and 2. via the name field in the table config. The file name of the autogenerated library always depended on the table config's key in the tables config, while the table metadata and id depended on the name option. Using the name argument also made it much harder to infer client types based on the table's name than using the table config's key in the tables config.

  • This PR removes the name field from the user-facing config, so that the config's field is always autofilled with the table config's key in the tables config.

@alvrs alvrs requested a review from frolic as a code owner May 14, 2023 11:29
dk1a
dk1a previously approved these changes May 14, 2023
Copy link
Contributor

@dk1a dk1a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with name being confusing

I can see it being useful for tables with long prefixes, for example
UnitStatsElementalAttack
UnitStatsElementalDefense
both get cut to UnitStatsElement and conflict with each other,
but it seems fine to expect people to not make such table names

frolic
frolic previously approved these changes May 14, 2023
Copy link
Member

@frolic frolic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little sad these sorts of configurability are going away, but I agree its a little confusing when to use which value (config key vs overridden name). Definitely on board to prioritize simplicity + opinionated and find ways to reintroduce this when it makes sense to do and worth the complexity trade off.

@@ -163,7 +157,7 @@ export const zTablesConfig = z.record(zTableName, zTableConfig).transform((table
// default name depends on tableName
for (const tableName of Object.keys(tables)) {
const table = tables[tableName];
table.name ??= tableName.slice(0, STORE_SELECTOR_MAX_LENGTH);
table.name = tableName.slice(0, STORE_SELECTOR_MAX_LENGTH);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there anything we can do at the type hint level to make folks aware of this limitation? like should a >16 length string fail TS? or warn? does zod provide any helpers for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants