-
-
Notifications
You must be signed in to change notification settings - Fork 187
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(NOTIFY-1146): use better type system for user storage #4907
base: main
Are you sure you want to change the base?
Conversation
export enum UserStorageFeatureNames { | ||
Notifications = 'notifications', | ||
Accounts = 'accounts_v2', | ||
Networks = 'networks', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to make 100% sure these names are identical to what they were before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I see that account_v2 change lol.
We might not need this as we are resolving the issue through a delete endpoint.
But not against it if we want a fresh clean slate
UserStorageSchema[Feature][0] extends typeof ALLOW_ARBITRARY_KEYS | ||
? string | ||
: UserStorageSchema[Feature][number]; | ||
|
||
type UserStorageFeatureAndKey = { | ||
feature: UserStorageFeatures; | ||
key: UserStorageFeatureKeys<UserStorageFeatures>; | ||
feature: UserStorageFeatureNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice if some outside interfaces are backwards compatible. Supporting string unions or enums.
E.g. if I'm an SDK user, I now have to add an additional import for using user storage. That's not great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also can you make sure that we have the correct exports for the subpaths?
E.g. If I'm importing the SDK through /SDK, can I also access the enum from here?
Explanation
This PR adds an enum for feature names so we stop relying on string values for user storage operations.
This enum is also now exported from the packages, in both SDK and UserStorage paths.
References
https://consensyssoftware.atlassian.net/browse/NOTIFY-1146
Changelog
@metamask/profile-sync-controller
UserStorageFeatureNames
enumChecklist